qa-page-admin-pages.php 18.9 KB
Newer Older
Gideon Greenspan committed
1 2 3
<?php
	
/*
Gideon Greenspan committed
4
	Question2Answer by Gideon Greenspan and contributors
Gideon Greenspan committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

	http://www.question2answer.org/

	
	File: qa-include/qa-page-admin-pages.php
	Version: See define()s at top of qa-include/qa-base.php
	Description: Controller for admin page for editing custom pages and external links


	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/

	if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
		header('Location: ../');
		exit;
	}

	require_once QA_INCLUDE_DIR.'qa-app-admin.php';
	require_once QA_INCLUDE_DIR.'qa-app-format.php';
	require_once QA_INCLUDE_DIR.'qa-db-selects.php';

	
//	Get current list of pages and determine the state of this admin page

	$pageid=qa_post_text('edit');
	if (!isset($pageid))
		$pageid=qa_get('edit');
		
Gideon Greenspan committed
43
	list($pages, $editpage)=qa_db_select_with_pending(
Gideon Greenspan committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
		qa_db_pages_selectspec(),
		isset($pageid) ? qa_db_page_full_selectspec($pageid, true) : null
	);
	
	if ((qa_clicked('doaddpage') || qa_clicked('doaddlink') || qa_get('doaddlink') || qa_clicked('dosavepage')) && !isset($editpage)) {
		$editpage=array('title' => qa_get('text'), 'tags' => qa_get('url'), 'nav' => qa_get('nav'), 'position' => 1);
		$isexternal=qa_clicked('doaddlink') || qa_get('doaddlink') || qa_post_text('external');
		
	} elseif (isset($editpage))
		$isexternal=$editpage['flags'] & QA_PAGE_FLAGS_EXTERNAL;
	

//	Check admin privileges (do late to allow one DB query)

	if (!qa_admin_check_privileges($qa_content))
		return $qa_content;
		
		
//	Define an array of navigation settings we can change, option name => language key
	
	$hascustomhome=qa_has_custom_home();
	
	$navoptions=array(
		'nav_home' => 'main/nav_home',
		'nav_activity' => 'main/nav_activity',
		 $hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home' => $hascustomhome ? 'main/nav_qa' : 'admin/nav_qa_is_home',
		'nav_questions' => 'main/nav_qs',
		'nav_hot' => 'main/nav_hot',
		'nav_unanswered' => 'main/nav_unanswered',
		'nav_tags' => 'main/nav_tags',
		'nav_categories' => 'main/nav_categories',
		'nav_users' => 'main/nav_users',
		'nav_ask' => 'main/nav_ask',
	);
	
	$navpaths=array(
		'nav_home' => '',
		'nav_activity' => 'activity',
		'nav_qa_not_home' => 'qa',
		'nav_qa_is_home' => '',
		'nav_questions' => 'questions',
		'nav_hot' => 'hot',
		'nav_unanswered' => 'unanswered',
		'nav_tags' => 'tags',
		'nav_categories' => 'categories',
		'nav_users' => 'users',
		'nav_ask' => 'ask',
	);
	
	if (!qa_opt('show_custom_home'))
		unset($navoptions['nav_home']);
		
	if (!qa_using_categories())
		unset($navoptions['nav_categories']);

	if (!qa_using_tags())
		unset($navoptions['nav_tags']);


//	Process saving an old or new page

Gideon Greenspan committed
105 106
	$securityexpired=false;

Gideon Greenspan committed
107 108 109 110
	if (qa_clicked('docancel'))
		$editpage=null;

	elseif (qa_clicked('dosaveoptions') || qa_clicked('doaddpage') || qa_clicked('doaddlink')) {
Gideon Greenspan committed
111 112 113
		if (!qa_check_form_security_code('admin/pages', qa_post_text('code')))
			$securityexpired=true;
		else foreach ($navoptions as $optionname => $langkey)
Gideon Greenspan committed
114 115 116 117 118 119
			qa_set_option($optionname, (int)qa_post_text('option_'.$optionname));

	} elseif (qa_clicked('dosavepage')) {
		require_once QA_INCLUDE_DIR.'qa-db-admin.php';
		require_once QA_INCLUDE_DIR.'qa-util-string.php';
		
Gideon Greenspan committed
120 121 122 123
		if (!qa_check_form_security_code('admin/pages', qa_post_text('code')))
			$securityexpired=true;
		else {
			$reloadpages=false;
Gideon Greenspan committed
124
			
Gideon Greenspan committed
125 126 127 128 129 130 131 132 133
			if (qa_post_text('dodelete')) {
				qa_db_page_delete($editpage['pageid']);
				
				$searchmodules=qa_load_modules_with('search', 'unindex_page');
				foreach ($searchmodules as $searchmodule)
					$searchmodule->unindex_page($editpage['pageid']);
				
				$editpage=null;
				$reloadpages=true;
Gideon Greenspan committed
134 135
			
			} else {
Gideon Greenspan committed
136 137 138 139 140 141 142 143 144 145 146
				$inname=qa_post_text('name');
				$inposition=qa_post_text('position');
				$inpermit=(int)qa_post_text('permit');
				$inurl=qa_post_text('url');
				$innewwindow=qa_post_text('newwindow');
				$inheading=qa_post_text('heading');
				$incontent=qa_post_text('content');
	
				$errors=array();
				
			//	Verify the name (navigation link) is legitimate
Gideon Greenspan committed
147
			
Gideon Greenspan committed
148 149 150 151
				if (empty($inname))
					$errors['name']=qa_lang('main/field_required');
				elseif (qa_strlen($inname)>QA_DB_MAX_CAT_PAGE_TITLE_LENGTH)
					$errors['name']=qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TITLE_LENGTH);
Gideon Greenspan committed
152
							
Gideon Greenspan committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
				if ($isexternal) {
				
				//	Verify the url is legitimate (vaguely)
				
					if (empty($inurl))
						$errors['url']=qa_lang('main/field_required');
					elseif (qa_strlen($inurl)>QA_DB_MAX_CAT_PAGE_TAGS_LENGTH)
						$errors['url']=qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH);
	
				} else {
				
				//	Verify the heading is legitimate
				
					if (qa_strlen($inheading)>QA_DB_MAX_TITLE_LENGTH)
						$errors['heading']=qa_lang_sub('main/max_length_x', QA_DB_MAX_TITLE_LENGTH);
				
				//	Verify the slug is legitimate (and try some defaults if we're creating a new page, and it's not)
						
					for ($attempt=0; $attempt<100; $attempt++) {
						switch ($attempt) {
							case 0:
								$inslug=qa_post_text('slug');
								if (!isset($inslug))
									$inslug=implode('-', qa_string_to_words($inname));
								break;
								
							case 1:
								$inslug=qa_lang_sub('admin/page_default_slug', $inslug);
								break;
								
							default:
								$inslug=qa_lang_sub('admin/page_default_slug', $attempt-1);
								break;
						}
						
						list($matchcategoryid, $matchpage)=qa_db_select_with_pending(
							qa_db_slugs_to_category_id_selectspec($inslug),
							qa_db_page_full_selectspec($inslug, false)
						);
						
						if (empty($inslug))
							$errors['slug']=qa_lang('main/field_required');
						elseif (qa_strlen($inslug)>QA_DB_MAX_CAT_PAGE_TAGS_LENGTH)
							$errors['slug']=qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH);
						elseif (preg_match('/[\\+\\/]/', $inslug))
							$errors['slug']=qa_lang_sub('admin/slug_bad_chars', '+ /');
						elseif (qa_admin_is_slug_reserved($inslug))
							$errors['slug']=qa_lang('admin/slug_reserved');
						elseif (isset($matchpage) && ($matchpage['pageid']!=@$editpage['pageid']))
							$errors['slug']=qa_lang('admin/page_already_used');
						elseif (isset($matchcategoryid))
							$errors['slug']=qa_lang('admin/category_already_used');
						else
							unset($errors['slug']);
						
						if (isset($editpage['pageid']) || !isset($errors['slug'])) // don't try other options if editing existing page
Gideon Greenspan committed
209 210 211 212
							break;
					}
				}
				
Gideon Greenspan committed
213 214 215
			//	Perform appropriate database action
		
				if (isset($editpage['pageid'])) { // changing existing page
Gideon Greenspan committed
216
					if ($isexternal)
Gideon Greenspan committed
217 218 219 220 221 222
						qa_db_page_set_fields($editpage['pageid'],
							isset($errors['name']) ? $editpage['title'] : $inname,
							QA_PAGE_FLAGS_EXTERNAL | ($innewwindow ? QA_PAGE_FLAGS_NEW_WINDOW : 0),
							isset($errors['url']) ? $editpage['tags'] : $inurl,
							null, null, $inpermit);
	
Gideon Greenspan committed
223
					else {
Gideon Greenspan committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237
						$setheading=isset($errors['heading']) ? $editpage['heading'] : $inheading;
						$setslug=isset($errors['slug']) ? $editpage['tags'] : $inslug;
						$setcontent=isset($errors['content']) ? $editpage['content'] : $incontent;
						
						qa_db_page_set_fields($editpage['pageid'],
							isset($errors['name']) ? $editpage['title'] : $inname,
							0,
							$setslug, $setheading, $setcontent, $inpermit);
	
						$searchmodules=qa_load_modules_with('search', 'unindex_page');
						foreach ($searchmodules as $searchmodule)
							$searchmodule->unindex_page($editpage['pageid']);
						
						$indextext=qa_viewer_text($setcontent, 'html');
Gideon Greenspan committed
238 239 240
						
						$searchmodules=qa_load_modules_with('search', 'index_page');
						foreach ($searchmodules as $searchmodule)
Gideon Greenspan committed
241
							$searchmodule->index_page($editpage['pageid'], $setslug, $setheading, $setcontent, 'html', $indextext);
Gideon Greenspan committed
242 243
					}
					
Gideon Greenspan committed
244 245
					qa_db_page_move($editpage['pageid'], substr($inposition, 0, 1), substr($inposition, 1));
					
Gideon Greenspan committed
246
					$reloadpages=true;
Gideon Greenspan committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
		
					if (empty($errors))
						$editpage=null;
					else
						$editpage=@$pages[$editpage['pageid']];
		
				} else { // creating a new one
					if (empty($errors)) {
						if ($isexternal)
							$pageid=qa_db_page_create($inname, QA_PAGE_FLAGS_EXTERNAL | ($innewwindow ? QA_PAGE_FLAGS_NEW_WINDOW : 0), $inurl, null, null, $inpermit);
						else {
							$pageid=qa_db_page_create($inname, 0, $inslug, $inheading, $incontent, $inpermit);
						
							$indextext=qa_viewer_text($incontent, 'html');
							
							$searchmodules=qa_load_modules_with('search', 'index_page');
							foreach ($searchmodules as $searchmodule)
								$searchmodule->index_page($pageid, $inslug, $inheading, $incontent, 'html', $indextext);
						}
						
						qa_db_page_move($pageid, substr($inposition, 0, 1), substr($inposition, 1));
	
						$editpage=null;
						$reloadpages=true;
					}
Gideon Greenspan committed
272
				}
Gideon Greenspan committed
273 274 275
				
				if (qa_clicked('dosaveview') && empty($errors) && !$isexternal)
					qa_redirect($inslug);							
Gideon Greenspan committed
276
			}
Gideon Greenspan committed
277 278 279 280 281
			
			if ($reloadpages) {
				qa_db_flush_pending_result('navpages');
				$pages=qa_db_select_with_pending(qa_db_pages_selectspec());
			}
Gideon Greenspan committed
282 283 284 285 286 287 288 289
		}
	}
		
		
//	Prepare content for theme
	
	$qa_content=qa_content_prepare();

Gideon Greenspan committed
290 291
	$qa_content['title']=qa_lang_html('admin/admin_title').' - '.qa_lang_html('admin/pages_title');	
	$qa_content['error']=$securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
Gideon Greenspan committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335

	if (isset($editpage)) {
		$positionoptions=array();
		
		if (!$isexternal)
			$positionoptions['_'.max(1, @$editpage['position'])]=qa_lang_html('admin/no_link');
		
		$navlangkey=array(
			'B' => 'admin/before_main_menu',
			'M' => 'admin/after_main_menu',
			'O' => 'admin/opposite_main_menu',
			'F' => 'admin/after_footer',
		);
		
		foreach ($navlangkey as $nav => $langkey) {
			$previous=null;
			$passedself=false;
			$maxposition=0;
			
			foreach ($pages as $key => $page)
				if ($page['nav']==$nav) {
					if (isset($previous))
						$positionhtml=qa_lang_html_sub('admin/after_x_tab', qa_html($passedself ? $page['title'] : $previous['title']));
					else
						$positionhtml=qa_lang_html($langkey);
						
					if ($page['pageid']==@$editpage['pageid'])
						$passedself=true;
		
					$maxposition=max($maxposition, $page['position']);
					$positionoptions[$nav.$page['position']]=$positionhtml;
						
					$previous=$page;
				}
				
			if ((!isset($editpage['pageid'])) || $nav!=@$editpage['nav']) {
				$positionvalue=isset($previous) ? qa_lang_html_sub('admin/after_x_tab', qa_html($previous['title'])) : qa_lang_html($langkey);
				$positionoptions[$nav.(isset($previous) ? (1+$maxposition) : 1)]=$positionvalue;
			}
		}
		
		$positionvalue=@$positionoptions[$editpage['nav'].$editpage['position']];
		
		$permitoptions=qa_admin_permit_options(QA_PERMIT_ALL, QA_PERMIT_ADMINS, false, false);
Gideon Greenspan committed
336
		$permitvalue=@$permitoptions[isset($inpermit) ? $inpermit : $editpage['permit']];
Gideon Greenspan committed
337 338
		
		$qa_content['form']=array(
Gideon Greenspan committed
339
			'tags' => 'method="post" action="'.qa_path_html(qa_request()).'"',
Gideon Greenspan committed
340 341 342 343 344
			
			'style' => 'tall',
			
			'fields' => array(
				'name' => array(
Gideon Greenspan committed
345
					'tags' => 'name="name" id="name"',
Gideon Greenspan committed
346 347 348 349 350 351
					'label' => qa_lang_html($isexternal ? 'admin/link_name' : 'admin/page_name'),
					'value' => qa_html(isset($inname) ? $inname : @$editpage['title']),
					'error' => qa_html(@$errors['name']),
				),
				
				'delete' => array(
Gideon Greenspan committed
352
					'tags' => 'name="dodelete" id="dodelete"',
Gideon Greenspan committed
353 354 355 356 357 358 359
					'label' => qa_lang_html($isexternal ? 'admin/delete_link' : 'admin/delete_page'),
					'value' => 0,
					'type' => 'checkbox',
				),
				
				'position' => array(
					'id' => 'position_display',
Gideon Greenspan committed
360
					'tags' => 'name="position"',
Gideon Greenspan committed
361 362 363 364 365 366 367 368
					'label' => qa_lang_html('admin/position'),
					'type' => 'select',
					'options' => $positionoptions,
					'value' => $positionvalue,
				),
				
				'permit' => array(
					'id' => 'permit_display',
Gideon Greenspan committed
369
					'tags' => 'name="permit"',
Gideon Greenspan committed
370 371 372 373 374 375 376 377
					'label' => qa_lang_html('admin/permit_to_view'),
					'type' => 'select',
					'options' => $permitoptions,
					'value' => $permitvalue,
				),
				
				'slug' => array(
					'id' => 'slug_display',
Gideon Greenspan committed
378
					'tags' => 'name="slug"',
Gideon Greenspan committed
379 380 381 382 383 384 385
					'label' => qa_lang_html('admin/page_slug'),
					'value' => qa_html(isset($inslug) ? $inslug : @$editpage['tags']),
					'error' => qa_html(@$errors['slug']),
				),
				
				'url' => array(
					'id' => 'url_display',
Gideon Greenspan committed
386
					'tags' => 'name="url"',
Gideon Greenspan committed
387 388 389 390 391 392 393
					'label' => qa_lang_html('admin/link_url'),
					'value' => qa_html(isset($inurl) ? $inurl : @$editpage['tags']),
					'error' => qa_html(@$errors['url']),
				),
				
				'newwindow' => array(
					'id' => 'newwindow_display',
Gideon Greenspan committed
394
					'tags' => 'name="newwindow"',
Gideon Greenspan committed
395 396 397 398 399 400 401
					'label' => qa_lang_html('admin/link_new_window'),
					'value' => (isset($innewwindow) ? $innewwindow : (@$editpage['flags'] & QA_PAGE_FLAGS_NEW_WINDOW)) ? 1 : 0,
					'type' => 'checkbox',
				),
				
				'heading' => array(
					'id' => 'heading_display',
Gideon Greenspan committed
402
					'tags' => 'name="heading"',
Gideon Greenspan committed
403 404 405 406 407 408 409
					'label' => qa_lang_html('admin/page_heading'),
					'value' => qa_html(isset($inheading) ? $inheading : @$editpage['heading']),
					'error' => qa_html(@$errors['heading']),
				),
				
				'content' => array(
					'id' => 'content_display',
Gideon Greenspan committed
410
					'tags' => 'name="content"',
Gideon Greenspan committed
411 412 413 414 415 416 417 418 419 420 421 422
					'label' => qa_lang_html('admin/page_content_html'),
					'value' => qa_html(isset($incontent) ? $incontent : @$editpage['content']),
					'error' => qa_html(@$errors['content']),
					'rows' => 16,
				),
			),

			'buttons' => array(
				'save' => array(
					'label' => qa_lang_html(isset($editpage['pageid']) ? 'main/save_button' : ($isexternal ? 'admin/add_link_button' : 'admin/add_page_button')),
				),
				
Gideon Greenspan committed
423 424 425 426 427
				'saveview' => array(
					'tags' => 'name="dosaveview"',
					'label' => qa_lang_html('admin/save_view_button'),
				),
				
Gideon Greenspan committed
428
				'cancel' => array(
Gideon Greenspan committed
429
					'tags' => 'name="docancel"',
Gideon Greenspan committed
430 431 432 433 434 435 436 437
					'label' => qa_lang_html('main/cancel_button'),
				),
			),
			
			'hidden' => array(
				'dosavepage' => '1', // for IE
				'edit' => @$editpage['pageid'],
				'external' => (int)$isexternal,
Gideon Greenspan committed
438
				'code' => qa_get_form_security_code('admin/pages'),
Gideon Greenspan committed
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
			),
		);
		
		if ($isexternal) {
			unset($qa_content['form']['fields']['slug']);
			unset($qa_content['form']['fields']['heading']);
			unset($qa_content['form']['fields']['content']);
		
		} else {
			unset($qa_content['form']['fields']['url']);
			unset($qa_content['form']['fields']['newwindow']);
		}
		
		if (isset($editpage['pageid']))
			qa_set_display_rules($qa_content, array(
				'position_display' => '!dodelete',
				'permit_display' => '!dodelete',
				($isexternal ? 'url_display' : 'slug_display') => '!dodelete',
				($isexternal ? 'newwindow_display' : 'heading_display') => '!dodelete',
				'content_display' => '!dodelete',
			));
		
		else {
			unset($qa_content['form']['fields']['slug']);
			unset($qa_content['form']['fields']['delete']);
		}
		
Gideon Greenspan committed
466 467 468
		if ($isexternal || !isset($editpage['pageid']))
			unset($qa_content['form']['buttons']['saveview']);
		
Gideon Greenspan committed
469 470 471 472 473 474 475
		$qa_content['focusid']='name';
	
	} else {

	//	List of standard navigation links

		$qa_content['form']=array(
Gideon Greenspan committed
476
			'tags' => 'method="post" action="'.qa_self_html().'"',
Gideon Greenspan committed
477 478 479 480 481 482 483
			
			'style' => 'tall',
			
			'fields' => array(),

			'buttons' => array(
				'save' => array(
Gideon Greenspan committed
484
					'tags' => 'name="dosaveoptions"',
Gideon Greenspan committed
485 486 487 488
					'label' => qa_lang_html('main/save_button'),
				),

				'addpage' => array(
Gideon Greenspan committed
489
					'tags' => 'name="doaddpage"',
Gideon Greenspan committed
490 491 492 493
					'label' => qa_lang_html('admin/add_page_button'),
				),

				'addlink' => array(
Gideon Greenspan committed
494
					'tags' => 'name="doaddlink"',
Gideon Greenspan committed
495 496 497
					'label' => qa_lang_html('admin/add_link_button'),
				),
			),
Gideon Greenspan committed
498 499 500 501
			
			'hidden' => array(
				'code' => qa_get_form_security_code('admin/pages'),
			),
Gideon Greenspan committed
502 503 504 505 506 507 508 509 510 511
		);
		
		$qa_content['form']['fields']['navlinks']=array(
			'label' => qa_lang_html('admin/nav_links_explanation'),
			'type' => 'static',
			'tight' => true,
		);

		foreach ($navoptions as $optionname => $langkey) {
			$qa_content['form']['fields'][$optionname]=array(
Gideon Greenspan committed
512 513
				'label' => '<a href="'.qa_path_html($navpaths[$optionname]).'">'.qa_lang_html($langkey).'</a>',
				'tags' => 'name="option_'.$optionname.'"',
Gideon Greenspan committed
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
				'type' => 'checkbox',
				'value' => qa_opt($optionname),
			);
		}
		
		$qa_content['form']['fields'][]=array(
			'type' => 'blank'
		);

	//	List of suggested plugin pages

		$listhtml='';
		
		$pagemodules=qa_load_modules_with('page', 'suggest_requests');
		
		foreach ($pagemodules as $tryname => $trypage) {
			$suggestrequests=$trypage->suggest_requests();
		
			foreach ($suggestrequests as $suggestrequest) {
Gideon Greenspan committed
533
				$listhtml.='<li><b><a href="'.qa_path_html($suggestrequest['request']).'">'.qa_html($suggestrequest['title']).'</a></b>';
Gideon Greenspan committed
534 535 536 537
				
				$listhtml.=qa_lang_html_sub('admin/plugin_module', qa_html($tryname));

				$listhtml.=strtr(qa_lang_html('admin/add_link_link'), array(
Gideon Greenspan committed
538 539
					'^1' => '<a href="'.qa_path_html(qa_request(), array('doaddlink' => 1, 'text' => $suggestrequest['title'], 'url' => $suggestrequest['request'], 'nav' => @$suggestrequest['nav'])).'">',
					'^2' => '</a>',
Gideon Greenspan committed
540 541 542
				));
				
				if (method_exists($trypage, 'admin_form'))
Gideon Greenspan committed
543
					$listhtml.=' - <a href="'.qa_admin_module_options_path('page', $tryname).'">'.qa_lang_html('admin/options').'</a>';
Gideon Greenspan committed
544
					
Gideon Greenspan committed
545
				$listhtml.='</li>';
Gideon Greenspan committed
546 547 548 549 550 551 552
			}
		}

		if (strlen($listhtml))
			$qa_content['form']['fields']['plugins']=array(
				'label' => qa_lang_html('admin/plugin_pages_explanation'),
				'type' => 'custom',
Gideon Greenspan committed
553
				'html' => '<ul style="margin-bottom:0;">'.$listhtml.'</ul>',
Gideon Greenspan committed
554 555 556 557 558 559 560
			);
		
	//	List of custom pages or links

		$listhtml='';
		
		foreach ($pages as $page) {
Gideon Greenspan committed
561
			$listhtml.='<li><b><a href="'.qa_custom_page_url($page).'">'.qa_html($page['title']).'</a></b>';
Gideon Greenspan committed
562 563
			
			$listhtml.=strtr(qa_lang_html(($page['flags'] & QA_PAGE_FLAGS_EXTERNAL) ? 'admin/edit_link' : 'admin/edit_page'), array(
Gideon Greenspan committed
564 565
				'^1' => '<a href="'.qa_path_html('admin/pages', array('edit' => $page['pageid'])).'">',
				'^2' => '</a>',
Gideon Greenspan committed
566 567
			));
								
Gideon Greenspan committed
568
			$listhtml.='</li>';
Gideon Greenspan committed
569 570 571 572 573
		}
		
		$qa_content['form']['fields']['pages']=array(
			'label' => strlen($listhtml) ? qa_lang_html('admin/click_name_edit') : qa_lang_html('admin/pages_explanation'),
			'type' => 'custom',
Gideon Greenspan committed
574
			'html' => strlen($listhtml) ? '<ul style="margin-bottom:0;">'.$listhtml.'</ul>' : null,
Gideon Greenspan committed
575 576 577 578 579 580 581 582 583 584 585 586
		);
	}

	$qa_content['navigation']['sub']=qa_admin_sub_navigation();

	
	return $qa_content;


/*
	Omit PHP closing tag to help avoid accidental output
*/