Project

General

Profile

« Previous | Next » 

Revision 1953

Added by darkviper over 11 years ago

solved some problems with MultiLingual module

View differences:

settings.php
90 90
//	$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
91 91
	$mLang = Translate::getinstance();
92 92
	$mLang->enableAddon('admin\pages');
93
	$oDb = WbDatabase::getInstance();
93 94
	$sDisabled = ' disabled="disabled"';
94 95
	$sSelected = ' selected="selected"';
95 96
	$sChecked  = ' checked="checked"';
......
417 418
	} else {
418 419
		$oTpl->set_var('DISPLAY_VIEWERS', 'display:none;');
419 420
	}
420
/*-- start multilanguage page_code 20090904 --------------------------------------------*/
421
// Work-out if page languages feature is enabled
421
/*-- start multilanguage page_code -----------------------------------------------------*/
422 422
	$oTpl->set_block('main_block', 'show_page_code_block',  'show_page_code');
423 423
	if( (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) &&
424 424
		 isset($aCurrentPage['page_code']) && class_exists('m_MultiLingual_Lib'))
425 425
	{
426
		// workout field is set but module missing
427
		$oTpl->set_var('TEXT_PAGE_CODE',
428
						   '<a href="'.WB_URL.'/modules/MultiLingual/update_keys.php?page_id='.$page_id.'">'.$mLang->TEXT_PAGE_CODE.'</a>'
429
		);
430
	/*-- begin recursive function page_code list ---------------------------------------*/
431
		function page_code_list($parent)
432
		{
433
			global $admin, $database, $oTpl, $aCurrentPage, $pageCode;
434
			$default_language = DEFAULT_LANGUAGE;
435

  
436
			$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` '
437
				 . 'WHERE `parent`='.$parent.' AND `language`=\''.$default_language.'\' '
438
				 . 'ORDER BY `position` ASC';
439
			$get_pages = $database->query($sql);
440

  
441
			while($page = $get_pages->fetchRow(MYSQL_ASSOC))
442
			{
443
				if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; }
444

  
445
				$oTpl->set_var('FLAG_CODE_ICON',' none ');
446
				if( $page['parent'] == 0 )
447
				{
448
					$oTpl->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
449
				}
450

  
451
				// If the current page cannot be parent, then its children neither
452
				$list_next_level = true;
453
				// Stop users from adding pages with a level of more than the set page level limit
454
				if($page['level']+1 < PAGE_LEVEL_LIMIT)
455
				{
456
					$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
457
								   $admin->is_group_match($admin->get_user_id(), $page['admin_users']));
458
					$title_prefix = '';
459
					for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
460
					// $space = str_repeat('&nbsp;', 3);  $space.'&lt;'..'&gt;'
461
					$oTpl->set_var(array(
462
											'VALUE' => intval($page['page_code']),
463
											'PAGE_VALUE' => $title_prefix.$page['menu_title'],
464
											'PAGE_CODE' => $title_prefix.$page['page_id']
465
											)
466
									);
467
					if($aCurrentPage['page_code'] == $page['page_code'])
468
					{
469
						$oTpl->set_var('SELECTED', ' selected="selected"');
470
					} elseif($aCurrentPage['page_code'] == $page['page_code'])
471
					{
472
						$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
473
						$list_next_level=false;
474
					} elseif($can_modify != true)
475
					{
476
						$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
477
					} else {
478
						$oTpl->set_var('SELECTED', '');
479
					}
480
					$oTpl->parse('page_code_list', 'page_code_list_block', true);
481
				}
482
				if ($list_next_level)
483
					page_code_list($page['page_id']);
484
			}
426
		$aTplBlockData = array();
427
	// workout field is set but module missing
428
		$aTplBlockData['PAGE_CODE_LABEL_TEXT'] = $mLang->TEXT_PAGE_CODE;
429
		$aTplBlockData['PAGE_CODE_UPDATE_URL'] = WB_REL.'/modules/MultiLingual/update_keys.php?page_id='.$page_id;
430
	// get the root element(level 0) of current page with same language  in same menu
431
		$sql =  'SELECT `page_id` FROM `'.$oDb->TablePrefix.'pages` '
432
		     .  'WHERE `language`=\''.DEFAULT_LANGUAGE.'\' '
433
		     .         'AND `level`=0 ';
434
		if(defined('MULTIPLE_MENUS') && MULTIPLE_MENUS == 'true') {
435
			$sql .=    'AND `menu`='.$aCurrentPage['menu'].' ';
485 436
		}
486
	/*-- end recursive function page_code list -----------------------------------------*/
487
		// Insert code_page values from page to modify
437
		$sql .= 'ORDER BY `position` ASC';
438
		$iLangStartPageId = $oDb->get_one($sql);
439
	// read the tree of the found root element
440
		$oPageList = new a_pages_SmallRawPageTree();
441
		$aLangCodePagesList = $oPageList->getParentList($iLangStartPageId);
442
	// create option list for the select box
488 443
		$oTpl->set_block('show_page_code_block', 'page_code_list_block', 'page_code_list');
489
		if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
490
			$selected = ($aCurrentPage['parent'] == 0 ? $sSelected : '');
491
			$oTpl->set_var(array(
492
					'VALUE' => 0,
493
					'PAGE_CODE' => $mLang->TEXT_NONE,
494
					'PAGE_VALUE' => '',
495
					'SELECTED' => $selected
496
				)
497
			);
444
		$aTplItemData = array();
445
		$bPageCodeIsSelected = false;
446
	// add 'no selection' option at top
447
		if($admin->get_permission('pages_add_l0') OR !$aCurrentPage['level'])
448
		{
449
			$aTplItemData['PAGE_CODE_VALUE']      = 0;
450
			$aTplItemData['PAGE_CODE_PAGE_TITLE'] = $mLang->TEXT_NONE;
451
			$bPageCodeIsSelected = ($aCurrentPage['page_code'] == 0);
452
			$aTplItemData['PAGE_CODE_SELECTED'] = ($bPageCodeIsSelected ? $sSelected : '');
453
			$oTpl->set_var($aTplItemData);
498 454
			$oTpl->parse('page_code_list', 'page_code_list_block', true);
455
			$aTplItemData = array();
499 456
		}
500
		// get pagecode form this page_id
501
		page_code_list(0);
457
		$iLastEntryLevel = 0;
458
		$bSkipChildren = false;
459
	// loop through all items
460
		while (list(, $aPage) = each($aLangCodePagesList)) 
461
		{
462
		// skip child pages where current user has no rights for
463
			if($bSkipChildren && ($aPage['level'] > $iLastEntryLevel)) { continue; }
464
			$bSkipChildren   = false;
465
			$iLastEntryLevel = $aPage['level'];
466
		//skip entry if it's not visible
467
			if(($admin->page_is_visible($aPage)==false) && ($aPage['visibility'] <> 'none') ) { continue; }
468
		// insert language flag on level 0
469
			$sThemeRel = WB_REL.'/'.str_replace(WB_URL, '', THEME_URL).'/images/flags/'.strtolower($aPage['language']).'.png)';
470
			$aTplItemData['PAGE_CODE_ICON_URL'] = ($aPage['level'] ? 'url('.$sThemeRel.')' : 'none');
471
		// create indent chars
472
			$sTitlePrefix = str_repeat('--&nbsp;', $aPage['level']).'&nbsp;';
473
			$aTplItemData['PAGE_CODE_PAGE_TITLE'] = $sTitlePrefix . $aPage['menu_title'];
474
			$aTplItemData['PAGE_CODE_VALUE']      = intval($aPage['page_code']);
475
		// set SELECTED status of this entry
476
			if( $aPage['page_id'] == $aCurrentPage['page_code']
477
			    && $aCurrentPage['page_code'] != 0
478
				&& !$bPageCodeIsSelected
479
			  )
480
			{ // 
481
				$aTplItemData['PAGE_CODE_SELECTED'] = $sSelected;
482
				$bPageCodeIsSelected = true;
483
			} elseif(!$aPage['iswriteable'])
484
			{ // 
485
				$aTplItemData['PAGE_CODE_SELECTED'] = $sDisabled.' class="disabled"';
486
				$bSkipChildren = true;
487
			} else {
488
				$aTplItemData['PAGE_CODE_SELECTED'] = '';
489
			}
490
		// output item data
491
			$oTpl->set_var($aTplItemData);
492
			$oTpl->parse('page_code_list', 'page_code_list_block', true);
493
			$aTplItemData = array();
494
		}
495
	// output block data
496
		$oTpl->set_var($aTplBlockData);
502 497
		$oTpl->parse('show_page_code', 'show_page_code_block', true);
503 498
	}else {
504 499
		$oTpl->set_block('show_page_code', '');
505 500
	}
506
/*-- end multilanguage page_code 20090904 ----------------------------------------------*/
501
/*-- end multilanguage page_code -------------------------------------------------------*/
507 502

  
508 503
/*-- show list of parent pages ---------------------------------------------------------*/
509 504
	$oTpl->set_block('main_block', 'parent_page_list_block', 'parent_page_list');
......
515 510
					) );
516 511
		$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
517 512
	}
513

  
518 514
	parent_list(0);
519 515
	$oTpl->set_var('DISPLAY_MODIFIED', ($modified_ts == 'Unknown' ? 'hide' : ''));
520 516

  

Also available in: Unified diff