Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/category_helper.php
Show All 25 Lines | |||||
/** | /** | ||||
* ID of primary language (only for caching) | * ID of primary language (only for caching) | ||||
* | * | ||||
* @var int | * @var int | ||||
*/ | */ | ||||
var $_primaryLanguageId = false; | var $_primaryLanguageId = false; | ||||
/** | /** | ||||
* Returns module information based on given module name or current category (relative to module root categories) | * Returns module information based on given module name or current category | ||||
* (relative to module root categories). | |||||
* | * | ||||
* @param Array $params | * @param array $params Tag params. | ||||
* @param Array $category_ids category parent path (already as array) | * @param array $category_path Category parent path. | ||||
* @return Array | * | ||||
* @access public | * @return array | ||||
*/ | */ | ||||
public function getCategoryModule($params, $category_ids) | public function getCategoryModule(array $params, array $category_path) | ||||
{ | { | ||||
$module_info = Array (); | // Get module by name. | ||||
if ( isset($params['module']) ) { | if ( isset($params['module']) ) { | ||||
// get module by name specified | return $this->Application->findModule('Name', $params['module']); | ||||
$module_info = $this->Application->findModule('Name', $params['module']); | |||||
} | } | ||||
elseif ( $category_ids ) { | |||||
// get module by category path | // Get module by category path. | ||||
$module_root_categories = $this->getModuleRootCategories(); | if ( $category_path ) { | ||||
$common_categories = array_intersect($category_ids, $module_root_categories); | foreach ( array_reverse($category_path) as $module_category_id ) { | ||||
$module_category_id = array_shift($common_categories); // get 1st common category | |||||
$module_info = $this->Application->findModule('RootCat', $module_category_id); | $module_info = $this->Application->findModule('RootCat', $module_category_id); | ||||
} | |||||
if ( $module_info && $module_info['Var'] != 'adm' ) { | |||||
return $module_info; | return $module_info; | ||||
} | } | ||||
/** | |||||
* Returns root categories from all modules | |||||
* | |||||
* @return Array | |||||
* @access protected | |||||
*/ | |||||
protected function getModuleRootCategories() | |||||
{ | |||||
static $root_categories = null; | |||||
if ( !isset($root_categories) ) { | |||||
$root_categories = Array (); | |||||
foreach ($this->Application->ModuleInfo as $module_info) { | |||||
array_push($root_categories, $module_info['RootCat']); | |||||
} | } | ||||
$root_categories = array_unique($root_categories); | |||||
} | } | ||||
return $root_categories; | return array(); | ||||
} | } | ||||
/** | /** | ||||
* Converts multi-dimensional category structure in one-dimensional option array (category_id=>category_name) | * Converts multi-dimensional category structure in one-dimensional option array (category_id=>category_name) | ||||
* | * | ||||
* @param Array $data | * @param Array $data | ||||
* @param int $parent_category_id | * @param int $parent_category_id | ||||
* @param int $language_id | * @param int $language_id | ||||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Line(s) | |||||
$page_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $page_url); | $page_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $page_url); | ||||
}*/ | }*/ | ||||
$text = str_replace('@@' . $page_id . '@@', $page_url, $text); | $text = str_replace('@@' . $page_id . '@@', $page_url, $text); | ||||
} | } | ||||
return $text; | return $text; | ||||
} | } | ||||
} | } | ||||
No newline at end of file |