Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/categories/categories_tag_processor.php
Show All 12 Lines | |||||
*/ | */ | ||||
defined('FULL_PATH') or die('restricted access!'); | defined('FULL_PATH') or die('restricted access!'); | ||||
class CategoriesTagProcessor extends kDBTagProcessor { | class CategoriesTagProcessor extends kDBTagProcessor { | ||||
function SubCatCount($params) | function SubCatCount($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
if ( isset($params['today']) && $params['today'] ) { | if ( isset($params['today']) && $params['today'] ) { | ||||
$sql = 'SELECT COUNT(*) | $sql = 'SELECT COUNT(*) | ||||
FROM ' . $object->TableName . ' | FROM ' . $object->TableName . ' | ||||
WHERE (ParentPath LIKE "' . $object->GetDBField('ParentPath') . '%") AND (CreatedOn > ' . (adodb_mktime() - 86400) . ')'; | WHERE (ParentPath LIKE "' . $object->GetDBField('ParentPath') . '%") AND (CreatedOn > ' . (adodb_mktime() - 86400) . ')'; | ||||
return $this->Conn->GetOne($sql) - 1; | return $this->Conn->GetOne($sql) - 1; | ||||
} | } | ||||
return $object->GetDBField('CachedDescendantCatsQty'); | return $object->GetDBField('CachedDescendantCatsQty'); | ||||
} | } | ||||
/** | /** | ||||
* Returns category count in system | * Returns category count in system | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
function CategoryCount($params) | function CategoryCount($params) | ||||
{ | { | ||||
/** @var kCountHelper $count_helper */ | |||||
$count_helper = $this->Application->recallObject('CountHelper'); | $count_helper = $this->Application->recallObject('CountHelper'); | ||||
/* @var $count_helper kCountHelper */ | |||||
$today_only = isset($params['today']) && $params['today']; | $today_only = isset($params['today']) && $params['today']; | ||||
return $count_helper->CategoryCount($today_only); | return $count_helper->CategoryCount($today_only); | ||||
} | } | ||||
function IsNew($params) | function IsNew($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return $object->GetDBField('IsNew') ? 1 : 0; | return $object->GetDBField('IsNew') ? 1 : 0; | ||||
} | } | ||||
function IsPick($params) | function IsPick($params) | ||||
{ | { | ||||
return $this->IsEditorsPick($params); | return $this->IsEditorsPick($params); | ||||
} | } | ||||
/** | /** | ||||
* Returns item's editors pick status (using not formatted value) | * Returns item's editors pick status (using not formatted value) | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function IsEditorsPick($params) | function IsEditorsPick($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return $object->GetDBField('EditorsPick') == 1; | return $object->GetDBField('EditorsPick') == 1; | ||||
} | } | ||||
function ItemIcon($params) | function ItemIcon($params) | ||||
{ | { | ||||
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); | $grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); | ||||
$grid = $grids[ $params['grid'] ]; | $grid = $grids[ $params['grid'] ]; | ||||
if (!array_key_exists('Icons', $grid)) { | if (!array_key_exists('Icons', $grid)) { | ||||
return ''; | return ''; | ||||
} | } | ||||
$icons = $grid['Icons']; | $icons = $grid['Icons']; | ||||
$icon_prefix = array_key_exists('icon_prefix', $params)? $params['icon_prefix'] : 'icon16_'; | $icon_prefix = array_key_exists('icon_prefix', $params)? $params['icon_prefix'] : 'icon16_'; | ||||
if (array_key_exists('name', $params)) { | if (array_key_exists('name', $params)) { | ||||
$icon_name = $params['name']; | $icon_name = $params['name']; | ||||
return array_key_exists($icon_name, $icons) ? $icons[$icon_name] : ''; | return array_key_exists($icon_name, $icons) ? $icons[$icon_name] : ''; | ||||
} | } | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
if ($object->GetDBField('ThemeId') > 0) { | if ($object->GetDBField('ThemeId') > 0) { | ||||
if (!$object->GetDBField('IsMenu')) { | if (!$object->GetDBField('IsMenu')) { | ||||
return $icon_prefix . 'section_menuhidden_system.png'; | return $icon_prefix . 'section_menuhidden_system.png'; | ||||
} | } | ||||
return $icon_prefix . 'section_system.png'; | return $icon_prefix . 'section_system.png'; | ||||
} | } | ||||
Show All 15 Lines | |||||
return $icon_prefix . 'section_new.png'; // show gris icon only in grids | return $icon_prefix . 'section_new.png'; // show gris icon only in grids | ||||
} | } | ||||
return $icon_prefix . 'section.png'; | return $icon_prefix . 'section.png'; | ||||
} | } | ||||
function ItemCount($params) | function ItemCount($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$ci_table = $this->Application->getUnitOption('ci', 'TableName'); | $ci_table = $this->Application->getUnitOption('ci', 'TableName'); | ||||
$module_prefixes = implode(',', $this->Conn->qstrArray($this->_getModulePrefixes())); | $module_prefixes = implode(',', $this->Conn->qstrArray($this->_getModulePrefixes())); | ||||
$sql = 'SELECT COUNT(*) | $sql = 'SELECT COUNT(*) | ||||
FROM ' . $object->TableName . ' c | FROM ' . $object->TableName . ' c | ||||
JOIN ' . $ci_table . ' ci ON c.CategoryId = ci.CategoryId | JOIN ' . $ci_table . ' ci ON c.CategoryId = ci.CategoryId | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$this->Application->Redirect($home_template, Array('pass'=>'all')); | $this->Application->Redirect($home_template, Array('pass'=>'all')); | ||||
}; | }; | ||||
} | } | ||||
function CategoryPath($params) | function CategoryPath($params) | ||||
{ | { | ||||
/** @var kNavigationBar $navigation_bar */ | |||||
$navigation_bar = $this->Application->recallObject('kNavigationBar'); | $navigation_bar = $this->Application->recallObject('kNavigationBar'); | ||||
/* @var $navigation_bar kNavigationBar */ | |||||
return $navigation_bar->build($params); | return $navigation_bar->build($params); | ||||
} | } | ||||
/** | /** | ||||
* Shows category path to specified category | * Shows category path to specified category | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function FieldCategoryPath($params) | function FieldCategoryPath($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
$category_id = $object->GetDBField($field); | $category_id = $object->GetDBField($field); | ||||
if ($category_id) { | if ($category_id) { | ||||
$params['cat_id'] = $category_id; | $params['cat_id'] = $category_id; | ||||
/** @var kNavigationBar $navigation_bar */ | |||||
$navigation_bar = $this->Application->recallObject('kNavigationBar'); | $navigation_bar = $this->Application->recallObject('kNavigationBar'); | ||||
/* @var $navigation_bar kNavigationBar */ | |||||
return $navigation_bar->build($params); | return $navigation_bar->build($params); | ||||
} | } | ||||
return ''; | return ''; | ||||
} | } | ||||
function CurrentCategoryName($params) | function CurrentCategoryName($params) | ||||
{ | { | ||||
/** @var kDBList $cat_object */ | |||||
$cat_object = $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List'); | $cat_object = $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List'); | ||||
/* @var $cat_object kDBList */ | |||||
$sql = 'SELECT '.$this->getTitleField().' | $sql = 'SELECT '.$this->getTitleField().' | ||||
FROM '.$cat_object->TableName.' | FROM '.$cat_object->TableName.' | ||||
WHERE CategoryId = '.(int)$this->Application->GetVar('m_cat_id'); | WHERE CategoryId = '.(int)$this->Application->GetVar('m_cat_id'); | ||||
return $this->Conn->GetOne($sql); | return $this->Conn->GetOne($sql); | ||||
} | } | ||||
/** | /** | ||||
* Returns current category name | * Returns current category name | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @todo Find where it's used | * @todo Find where it's used | ||||
*/ | */ | ||||
function CurrentCategory($params) | function CurrentCategory($params) | ||||
{ | { | ||||
return $this->CurrentCategoryName($params); | return $this->CurrentCategoryName($params); | ||||
} | } | ||||
function getTitleField() | function getTitleField() | ||||
{ | { | ||||
/** @var kMultiLanguage $ml_formatter */ | |||||
$ml_formatter = $this->Application->recallObject('kMultiLanguage'); | $ml_formatter = $this->Application->recallObject('kMultiLanguage'); | ||||
/* @var $ml_formatter kMultiLanguage */ | |||||
return $ml_formatter->LangFieldName('Name'); | return $ml_formatter->LangFieldName('Name'); | ||||
} | } | ||||
/** | /** | ||||
* Returns symlinked category for given category | * Returns symlinked category for given category | ||||
* | * | ||||
* @param int $category_id | * @param int $category_id | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
return $this->PrintList2($params); | return $this->PrintList2($params); | ||||
} | } | ||||
} | } | ||||
function Meta($params) | function Meta($params) | ||||
{ | { | ||||
$object = $this->Application->recallObject($this->Prefix); // .'.-item' | $object = $this->Application->recallObject($this->Prefix); // .'.-item' | ||||
/* @var $object CategoriesItem */ | /** @var CategoriesItem $object */ | ||||
$meta_type = $params['name']; | $meta_type = $params['name']; | ||||
if ($object->isLoaded()) { | if ($object->isLoaded()) { | ||||
// 1. get module prefix by current category | // 1. get module prefix by current category | ||||
/** @var CategoryHelper $category_helper */ | |||||
$category_helper = $this->Application->recallObject('CategoryHelper'); | $category_helper = $this->Application->recallObject('CategoryHelper'); | ||||
/* @var $category_helper CategoryHelper */ | |||||
$category_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); | $category_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); | ||||
$module_info = $category_helper->getCategoryModule($params, $category_path); | $module_info = $category_helper->getCategoryModule($params, $category_path); | ||||
if ( $module_info ) { | if ( $module_info ) { | ||||
// 2. get item template by current category & module prefix | // 2. get item template by current category & module prefix | ||||
/** @var kRewriteUrlProcessor $rewrite_processor */ | |||||
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | $rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor'); | ||||
/* @var $rewrite_processor kRewriteUrlProcessor */ | |||||
$category_params = Array ( | $category_params = Array ( | ||||
'CategoryId' => $object->GetID(), | 'CategoryId' => $object->GetID(), | ||||
'ParentPath' => $object->GetDBField('ParentPath'), | 'ParentPath' => $object->GetDBField('ParentPath'), | ||||
); | ); | ||||
$item_template = $rewrite_processor->GetItemTemplate($category_params, $module_info['Var']); | $item_template = $rewrite_processor->GetItemTemplate($category_params, $module_info['Var']); | ||||
if ($this->Application->GetVar('t') == $item_template) { | if ($this->Application->GetVar('t') == $item_template) { | ||||
// we are located on item's details page | // we are located on item's details page | ||||
/** @var kCatDBItem $item */ | |||||
$item = $this->Application->recallObject($module_info['Var']); | $item = $this->Application->recallObject($module_info['Var']); | ||||
/* @var $item kCatDBItem */ | |||||
// 3. get item's meta data | // 3. get item's meta data | ||||
$value = $item->GetField('Meta'.$meta_type); | $value = $item->GetField('Meta'.$meta_type); | ||||
if ($value) { | if ($value) { | ||||
return $value; | return $value; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | |||||
// first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update | // first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update | ||||
return true; | return true; | ||||
} | } | ||||
// if we don't have to ask, then assume user selected "Yes" in permcache update dialog | // if we don't have to ask, then assume user selected "Yes" in permcache update dialog | ||||
$continue = 1; | $continue = 1; | ||||
} | } | ||||
/** @var kPermCacheUpdater $updater */ | |||||
$updater = $this->Application->makeClass('kPermCacheUpdater', Array ($continue)); | $updater = $this->Application->makeClass('kPermCacheUpdater', Array ($continue)); | ||||
/* @var $updater kPermCacheUpdater */ | |||||
if ( $continue === '0' ) { // No in dialog | if ( $continue === '0' ) { // No in dialog | ||||
$updater->clearData(); | $updater->clearData(); | ||||
$this->Application->Redirect($params['destination_template']); | $this->Application->Redirect($params['destination_template']); | ||||
} | } | ||||
$ret = false; // don't ask for update | $ret = false; // don't ask for update | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Allows to detect if root category being edited | * Allows to detect if root category being edited | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
*/ | */ | ||||
function IsRootCategory($params) | function IsRootCategory($params) | ||||
{ | { | ||||
/** @var CategoriesItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object CategoriesItem */ | |||||
return $object->IsRoot(); | return $object->IsRoot(); | ||||
} | } | ||||
/** | /** | ||||
* Returns home category id | * Returns home category id | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | |||||
// category not supplied -> get current from PrintList | // category not supplied -> get current from PrintList | ||||
$category = $this->getObject($params); | $category = $this->getObject($params); | ||||
} | } | ||||
else { | else { | ||||
if ( "$cat_id" == 'Root' ) { | if ( "$cat_id" == 'Root' ) { | ||||
$cat_id = $this->Application->findModule('Name', $params['module'], 'RootCat'); | $cat_id = $this->Application->findModule('Name', $params['module'], 'RootCat'); | ||||
} | } | ||||
/** @var CategoriesItem $category */ | |||||
$category = $this->Application->recallObject($this->Prefix . '.-c' . $cat_id, $this->Prefix, Array ('skip_autoload' => true)); | $category = $this->Application->recallObject($this->Prefix . '.-c' . $cat_id, $this->Prefix, Array ('skip_autoload' => true)); | ||||
/* @var $category CategoriesItem */ | |||||
$category->Load($cat_id); | $category->Load($cat_id); | ||||
} | } | ||||
$test_path = $category->GetDBField('ParentPath'); | $test_path = $category->GetDBField('ParentPath'); | ||||
} | } | ||||
} | } | ||||
return strpos($current_path, $test_path) !== false; | return strpos($current_path, $test_path) !== false; | ||||
} | } | ||||
/** | /** | ||||
* Checks if user have one of required permissions | * Checks if user have one of required permissions | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function HasPermission($params) | function HasPermission($params) | ||||
{ | { | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$params['raise_warnings'] = 0; | $params['raise_warnings'] = 0; | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id'); | $params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id'); | ||||
return $perm_helper->TagPermissionCheck($params); | return $perm_helper->TagPermissionCheck($params); | ||||
} | } | ||||
/** | /** | ||||
* Prepares name for field with event in it (used only on front-end) | * Prepares name for field with event in it (used only on front-end) | ||||
* | * | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$date = $row_data[$row_data['NewDate'] > $row_data['ModDate'] ? 'NewDate' : 'ModDate']; | $date = $row_data[$row_data['NewDate'] > $row_data['ModDate'] ? 'NewDate' : 'ModDate']; | ||||
// format date | // format date | ||||
$format = isset($params['format']) ? $params['format'] : '_regional_DateTimeFormat'; | $format = isset($params['format']) ? $params['format'] : '_regional_DateTimeFormat'; | ||||
if ( preg_match("/_regional_(.*)/", $format, $regs) ) { | if ( preg_match("/_regional_(.*)/", $format, $regs) ) { | ||||
/** @var LanguagesItem $lang */ | |||||
$lang = $this->Application->recallObject('lang.current'); | $lang = $this->Application->recallObject('lang.current'); | ||||
/* @var $lang LanguagesItem */ | |||||
if ( $regs[1] == 'DateTimeFormat' ) { | if ( $regs[1] == 'DateTimeFormat' ) { | ||||
// combined format | // combined format | ||||
$format = $lang->GetDBField('DateFormat') . ' ' . $lang->GetDBField('TimeFormat'); | $format = $lang->GetDBField('DateFormat') . ' ' . $lang->GetDBField('TimeFormat'); | ||||
} | } | ||||
else { | else { | ||||
// simple format | // simple format | ||||
$format = $lang->GetDBField($regs[1]); | $format = $lang->GetDBField($regs[1]); | ||||
} | } | ||||
} | } | ||||
return adodb_date($format, $date); | return adodb_date($format, $date); | ||||
} | } | ||||
function CategoryItemCount($params) | function CategoryItemCount($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
$params['cat_id'] = $object->GetID(); | $params['cat_id'] = $object->GetID(); | ||||
/** @var kCountHelper $count_helper */ | |||||
$count_helper = $this->Application->recallObject('CountHelper'); | $count_helper = $this->Application->recallObject('CountHelper'); | ||||
/* @var $count_helper kCountHelper */ | |||||
return $count_helper->CategoryItemCount($params['prefix'], $params); | return $count_helper->CategoryItemCount($params['prefix'], $params); | ||||
} | } | ||||
/** | /** | ||||
* Returns prefix + any word (used for shared between categories per page settings) | * Returns prefix + any word (used for shared between categories per page settings) | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function VarName($params) | function VarName($params) | ||||
{ | { | ||||
return $this->Prefix.'_'.$params['type']; | return $this->Prefix.'_'.$params['type']; | ||||
} | } | ||||
/** | /** | ||||
* Checks if current category is valid symbolic link to another category | * Checks if current category is valid symbolic link to another category | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function IsCategorySymLink($params) | function IsCategorySymLink($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
$sym_category_id = $object->GetDBField('SymLinkCategoryId'); | $sym_category_id = $object->GetDBField('SymLinkCategoryId'); | ||||
if (is_null($sym_category_id)) | if (is_null($sym_category_id)) | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
Show All 34 Lines | |||||
/** | /** | ||||
* Returns module prefix based on root category for given | * Returns module prefix based on root category for given | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function GetModulePrefix($params) | function GetModulePrefix($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$parent_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); | $parent_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); | ||||
/** @var CategoryHelper $category_helper */ | |||||
$category_helper = $this->Application->recallObject('CategoryHelper'); | $category_helper = $this->Application->recallObject('CategoryHelper'); | ||||
/* @var $category_helper CategoryHelper */ | |||||
$module_info = $category_helper->getCategoryModule($params, $parent_path); | $module_info = $category_helper->getCategoryModule($params, $parent_path); | ||||
return $module_info ? $module_info['Var'] : 'c'; | return $module_info ? $module_info['Var'] : 'c'; | ||||
} | } | ||||
function ImageSrc($params) | function ImageSrc($params) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
if ( $suggestion !== false ) { | if ( $suggestion !== false ) { | ||||
$this->Application->setCache($cache_key, $suggestion); | $this->Application->setCache($cache_key, $suggestion); | ||||
return $suggestion; | return $suggestion; | ||||
} | } | ||||
// 3. suggestion not found in database, ask webservice | // 3. suggestion not found in database, ask webservice | ||||
/** @var kCurlHelper $curl_helper */ | |||||
$curl_helper = $this->Application->recallObject('CurlHelper'); | $curl_helper = $this->Application->recallObject('CurlHelper'); | ||||
/* @var $curl_helper kCurlHelper */ | |||||
$curl_helper->SetRequestData(array( | $curl_helper->SetRequestData(array( | ||||
'appid' => $this->Application->ConfigValue('YahooApplicationId'), | 'appid' => $this->Application->ConfigValue('YahooApplicationId'), | ||||
'query' => $keywords, | 'query' => $keywords, | ||||
)); | )); | ||||
$xml_data = $curl_helper->Send('http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion'); | $xml_data = $curl_helper->Send('http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion'); | ||||
/** @var kXMLHelper $xml_helper */ | |||||
$xml_helper = $this->Application->recallObject('kXMLHelper'); | $xml_helper = $this->Application->recallObject('kXMLHelper'); | ||||
/* @var $xml_helper kXMLHelper */ | |||||
/** @var kXMLNode $root_node */ | |||||
$root_node =& $xml_helper->Parse($xml_data); | $root_node =& $xml_helper->Parse($xml_data); | ||||
/* @var $root_node kXMLNode */ | |||||
/** @var kXMLNode $result */ | |||||
$result = $root_node->FindChild('RESULT'); | $result = $root_node->FindChild('RESULT'); | ||||
/* @var $result kXMLNode */ | |||||
if ( is_object($result) ) { | if ( is_object($result) ) { | ||||
// webservice responded -> save in local database | // webservice responded -> save in local database | ||||
$fields_hash = Array ('MisspelledWord' => $keywords, 'SuggestedCorrection' => $result->Data); | $fields_hash = Array ('MisspelledWord' => $keywords, 'SuggestedCorrection' => $result->Data); | ||||
$this->Conn->doInsert($fields_hash, $table_name); | $this->Conn->doInsert($fields_hash, $table_name); | ||||
$this->Application->setCache($cache_key, $result->Data); | $this->Application->setCache($cache_key, $result->Data); | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
* Show CachedNavbar of current item primary category | * Show CachedNavbar of current item primary category | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function CategoryName($params) | function CategoryName($params) | ||||
{ | { | ||||
// show category cachednavbar of | // show category cachednavbar of | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId'); | $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId'); | ||||
$cache_key = 'category_paths[%CIDSerial:' . $category_id . '%][%PhrasesSerial%][Adm:' . (int)$this->Application->isAdmin . ']'; | $cache_key = 'category_paths[%CIDSerial:' . $category_id . '%][%PhrasesSerial%][Adm:' . (int)$this->Application->isAdmin . ']'; | ||||
$category_path = $this->Application->getCache($cache_key); | $category_path = $this->Application->getCache($cache_key); | ||||
if ($category_path === false) { | if ($category_path === false) { | ||||
// not chached | // not chached | ||||
Show All 38 Lines | |||||
/** | /** | ||||
* Returns page object based on requested params | * Returns page object based on requested params | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return CategoriesItem | * @return CategoriesItem | ||||
*/ | */ | ||||
function &_getPage($params) | function &_getPage($params) | ||||
{ | { | ||||
/** @var kDBItem $page */ | |||||
$page = $this->Application->recallObject($this->Prefix . '.' . $this->_getPageSpecial($params), null, $params); | $page = $this->Application->recallObject($this->Prefix . '.' . $this->_getPageSpecial($params), null, $params); | ||||
/* @var $page kDBItem */ | |||||
// 1. load by given id | // 1. load by given id | ||||
$page_id = array_key_exists('page_id', $params) ? $params['page_id'] : 0; | $page_id = array_key_exists('page_id', $params) ? $params['page_id'] : 0; | ||||
if ( $page_id ) { | if ( $page_id ) { | ||||
if ( $page_id != $page->GetID() ) { | if ( $page_id != $page->GetID() ) { | ||||
// load if different | // load if different | ||||
$page->Load($page_id); | $page->Load($page_id); | ||||
Show All 10 Lines | |||||
} | } | ||||
// different path in structure AND design template differs from requested template | // different path in structure AND design template differs from requested template | ||||
$structure_path_match = mb_strtolower($page->GetDBField('NamedParentPath')) == mb_strtolower('Content/' . $template); | $structure_path_match = mb_strtolower($page->GetDBField('NamedParentPath')) == mb_strtolower('Content/' . $template); | ||||
$design_match = $page->GetDBField('CachedTemplate') == $template; | $design_match = $page->GetDBField('CachedTemplate') == $template; | ||||
if ( !$structure_path_match && !$design_match ) { | if ( !$structure_path_match && !$design_match ) { | ||||
// Same sql like in "c:getPassedID". Load, when current page object doesn't match requested page object | // Same sql like in "c:getPassedID". Load, when current page object doesn't match requested page object | ||||
/** @var kThemesHelper $themes_helper */ | |||||
$themes_helper = $this->Application->recallObject('ThemesHelper'); | $themes_helper = $this->Application->recallObject('ThemesHelper'); | ||||
/* @var $themes_helper kThemesHelper */ | |||||
$page_id = $themes_helper->getPageByTemplate($template); | $page_id = $themes_helper->getPageByTemplate($template); | ||||
$page->Load($page_id); | $page->Load($page_id); | ||||
} | } | ||||
return $page; | return $page; | ||||
} | } | ||||
Show All 39 Lines | |||||
$num = kUtil::crc32($name); | $num = kUtil::crc32($name); | ||||
} | } | ||||
} | } | ||||
if ( !$num ) { | if ( !$num ) { | ||||
return 'NO CONTENT NUM SPECIFIED'; | return 'NO CONTENT NUM SPECIFIED'; | ||||
} | } | ||||
/** @var kDBItem $page */ | |||||
$page =& $this->_getPage($params); | $page =& $this->_getPage($params); | ||||
/* @var $page kDBItem */ | |||||
if ( !$page->isLoaded() ) { | if ( !$page->isLoaded() ) { | ||||
// page is not created yet => all blocks are empty | // page is not created yet => all blocks are empty | ||||
return ''; | return ''; | ||||
} | } | ||||
/** @var PageHelper $page_helper */ | |||||
$page_helper = $this->Application->recallObject('PageHelper'); | $page_helper = $this->Application->recallObject('PageHelper'); | ||||
/* @var $page_helper PageHelper */ | |||||
/** @var kDBItem $content */ | |||||
$content = $this->Application->recallObject('content.-block', null, Array ('skip_autoload' => true)); | $content = $this->Application->recallObject('content.-block', null, Array ('skip_autoload' => true)); | ||||
/* @var $content kDBItem */ | |||||
if ( !$page_helper->loadContentBlock($content, $page, $num) && EDITING_MODE ) { | if ( !$page_helper->loadContentBlock($content, $page, $num) && EDITING_MODE ) { | ||||
$page_helper->createNewContentBlock($page->GetID(), $num); | $page_helper->createNewContentBlock($page->GetID(), $num); | ||||
$page_helper->loadContentBlock($content, $page, $num); | $page_helper->loadContentBlock($content, $page, $num); | ||||
} | } | ||||
$edit_code_before = $edit_code_after = ''; | $edit_code_before = $edit_code_after = ''; | ||||
$inline_editing = isset($params['mode']) && $params['mode'] == 'inline'; | $inline_editing = isset($params['mode']) && $params['mode'] == 'inline'; | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
if ( $this->Application->GetVar('admin_scripts_included') || !EDITING_MODE ) { | if ( $this->Application->GetVar('admin_scripts_included') || !EDITING_MODE ) { | ||||
return ''; | return ''; | ||||
} | } | ||||
$this->Application->SetVar('admin_scripts_included', 1); | $this->Application->SetVar('admin_scripts_included', 1); | ||||
$js_url = $this->Application->BaseURL() . 'core/admin_templates/js'; | $js_url = $this->Application->BaseURL() . 'core/admin_templates/js'; | ||||
/** @var MinifyHelper $minify_helper */ | |||||
$minify_helper = $this->Application->recallObject('MinifyHelper'); | $minify_helper = $this->Application->recallObject('MinifyHelper'); | ||||
/* @var $minify_helper MinifyHelper */ | |||||
$to_compress = Array ( | $to_compress = Array ( | ||||
$js_url . '/jquery/thickbox/thickbox.css', | $js_url . '/jquery/thickbox/thickbox.css', | ||||
$js_url . '/../incs/cms.css', | $js_url . '/../incs/cms.css', | ||||
$js_url . '/../img/toolbar/toolbar-sprite.css', | $js_url . '/../img/toolbar/toolbar-sprite.css', | ||||
); | ); | ||||
$css_compressed = $minify_helper->CompressScriptTag(Array ('files' => implode('|', $to_compress), 'templates_base' => $js_url . '/../')); | $css_compressed = $minify_helper->CompressScriptTag(Array ('files' => implode('|', $to_compress), 'templates_base' => $js_url . '/../')); | ||||
Show All 37 Lines | |||||
$url_params = Array ('theme-file_event' => 'OnSaveLayout', 'source' => $template, 'pass' => 'all,theme-file', '__NO_REWRITE__' => 1); | $url_params = Array ('theme-file_event' => 'OnSaveLayout', 'source' => $template, 'pass' => 'all,theme-file', '__NO_REWRITE__' => 1); | ||||
$save_layout_url = $this->Application->HREF('index', '', $url_params); | $save_layout_url = $this->Application->HREF('index', '', $url_params); | ||||
$url_params = Array ('content_event' => 'OnSaveContentBlock', 'pass' => 'all,content', '__NO_REWRITE__' => 1, 'no_amp' => 1); | $url_params = Array ('content_event' => 'OnSaveContentBlock', 'pass' => 'all,content', '__NO_REWRITE__' => 1, 'no_amp' => 1); | ||||
$save_content_url = $this->Application->HREF('index', ADMIN_DIRECTORY, $url_params, 'index.php'); | $save_content_url = $this->Application->HREF('index', ADMIN_DIRECTORY, $url_params, 'index.php'); | ||||
$page =& $this->_getPage($params); | $page =& $this->_getPage($params); | ||||
/** @var PageHelper $page_helper */ | |||||
$page_helper = $this->Application->recallObject('PageHelper'); | $page_helper = $this->Application->recallObject('PageHelper'); | ||||
/* @var $page_helper PageHelper */ | |||||
$class_params = Array ( | $class_params = Array ( | ||||
'languagePrefix' => 'l' . $this->Application->GetVar('m_lang') . '_', | 'languagePrefix' => 'l' . $this->Application->GetVar('m_lang') . '_', | ||||
'pageId' => $page->GetID(), | 'pageId' => $page->GetID(), | ||||
'pageInfo' => $page->isLoaded() ? $page_helper->getPageInfo( $page->GetID() ) : Array (), | 'pageInfo' => $page->isLoaded() ? $page_helper->getPageInfo( $page->GetID() ) : Array (), | ||||
'editUrl' => $edit_template_url, | 'editUrl' => $edit_template_url, | ||||
'browseUrl' => $this->Application->HREF('', '', Array ('editing_mode' => '#EDITING_MODE#', '__NO_REWRITE__' => 1)), | 'browseUrl' => $this->Application->HREF('', '', Array ('editing_mode' => '#EDITING_MODE#', '__NO_REWRITE__' => 1)), | ||||
'saveLayoutUrl' => $save_layout_url, | 'saveLayoutUrl' => $save_layout_url, | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
$edit_code .= $this->toolbarButton('preview', 'la_ToolTip_Preview', $tabs); | $edit_code .= $this->toolbarButton('preview', 'la_ToolTip_Preview', $tabs); | ||||
if ( $this->Application->CheckAdminPermission('CATEGORY.REVISION.HISTORY.VIEW', 0) ) { | if ( $this->Application->CheckAdminPermission('CATEGORY.REVISION.HISTORY.VIEW', 0) ) { | ||||
$edit_code .= $this->toolbarButton('history', 'la_ToolTip_History', $tabs); | $edit_code .= $this->toolbarButton('history', 'la_ToolTip_History', $tabs); | ||||
} | } | ||||
$edit_code .= $tabs . 'a_toolbar.Render();' . "\n"; | $edit_code .= $tabs . 'a_toolbar.Render();' . "\n"; | ||||
/** @var kDBItem $revision */ | |||||
$revision = $this->Application->recallObject('page-revision.current'); | $revision = $this->Application->recallObject('page-revision.current'); | ||||
/* @var $revision kDBItem */ | |||||
/** @var PageHelper $page_helper */ | |||||
$page_helper = $this->Application->recallObject('PageHelper'); | $page_helper = $this->Application->recallObject('PageHelper'); | ||||
/* @var $page_helper PageHelper */ | |||||
foreach ( $page_helper->getToolbarButtonsState($revision) as $toolbar_button => $is_enabled ) { | foreach ( $page_helper->getToolbarButtonsState($revision) as $toolbar_button => $is_enabled ) { | ||||
$edit_code .= $tabs . 'a_toolbar.SetEnabled("' . $toolbar_button . '", ' . json_encode($is_enabled) . ');'; | $edit_code .= $tabs . 'a_toolbar.SetEnabled("' . $toolbar_button . '", ' . json_encode($is_enabled) . ');'; | ||||
} | } | ||||
$publishing_tools = $this->Application->Phrase('la_btn_PublishingTools', false, true); | $publishing_tools = $this->Application->Phrase('la_btn_PublishingTools', false, true); | ||||
$edit_code .= substr($tabs, 0, -1) . '</script> | $edit_code .= substr($tabs, 0, -1) . '</script> | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
return $tabs . 'a_toolbar.AddButton(new ToolBarButton("' . $name . '", "' . $phrase . '", ' . $action . '));'; | return $tabs . 'a_toolbar.AddButton(new ToolBarButton("' . $name . '", "' . $phrase . '", ' . $action . '));'; | ||||
} | } | ||||
function _getThemeFileId() | function _getThemeFileId() | ||||
{ | { | ||||
$template = $this->Application->GetVar('t'); | $template = $this->Application->GetVar('t'); | ||||
if (!$this->Application->TemplatesCache->TemplateExists($template) && !$this->Application->isAdmin) { | if (!$this->Application->TemplatesCache->TemplateExists($template) && !$this->Application->isAdmin) { | ||||
/** @var CategoriesEventHandler $cms_handler */ | |||||
$cms_handler = $this->Application->recallObject($this->Prefix . '_EventHandler'); | $cms_handler = $this->Application->recallObject($this->Prefix . '_EventHandler'); | ||||
/* @var $cms_handler CategoriesEventHandler */ | |||||
$template = ltrim($cms_handler->GetDesignTemplate(), '/'); | $template = ltrim($cms_handler->GetDesignTemplate(), '/'); | ||||
} | } | ||||
$file_path = dirname($template) == '.' ? '' : '/' . dirname($template); | $file_path = dirname($template) == '.' ? '' : '/' . dirname($template); | ||||
$file_name = basename($template); | $file_name = basename($template); | ||||
$sql = 'SELECT FileId | $sql = 'SELECT FileId | ||||
Show All 10 Lines | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function AdminEditButton($params) | protected function AdminEditButton($params) | ||||
{ | { | ||||
if ( EDITING_MODE != EDITING_MODE_CONTENT ) { | if ( EDITING_MODE != EDITING_MODE_CONTENT ) { | ||||
return ''; | return ''; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$params['item_prefix'] = 'c'; | $params['item_prefix'] = 'c'; | ||||
if ( $this->Prefix == 'st' ) { | if ( $this->Prefix == 'st' ) { | ||||
$params['button_icon'] = 'section_properties.png'; | $params['button_icon'] = 'section_properties.png'; | ||||
$params['button_class'] = 'cms-section-properties-btn'; | $params['button_class'] = 'cms-section-properties-btn'; | ||||
$params['button_title'] = 'la_btn_SectionProperties'; | $params['button_title'] = 'la_btn_SectionProperties'; | ||||
} | } | ||||
return parent::AdminEditButton($params); | return parent::AdminEditButton($params); | ||||
} | } | ||||
/** | /** | ||||
* Builds site menu | * Builds site menu | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function CachedMenu($params) | function CachedMenu($params) | ||||
{ | { | ||||
/** @var MenuHelper $menu_helper */ | |||||
$menu_helper = $this->Application->recallObject('MenuHelper'); | $menu_helper = $this->Application->recallObject('MenuHelper'); | ||||
/* @var $menu_helper MenuHelper */ | |||||
return $menu_helper->menuTag($this->getPrefixSpecial(), $params); | return $menu_helper->menuTag($this->getPrefixSpecial(), $params); | ||||
} | } | ||||
/** | /** | ||||
* Trick to allow some kind of output formatting when using CachedMenu tag | * Trick to allow some kind of output formatting when using CachedMenu tag | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
Show All 23 Lines | |||||
* Prints sub-pages of given/current page. | * Prints sub-pages of given/current page. | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @todo This could be reached by using "parent_cat_id" parameter. Only difference here is new block parameter "path". Need to rewrite. | * @todo This could be reached by using "parent_cat_id" parameter. Only difference here is new block parameter "path". Need to rewrite. | ||||
*/ | */ | ||||
function PrintSubPages($params) | function PrintSubPages($params) | ||||
{ | { | ||||
/** @var kDBList $list */ | |||||
$list = $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params); | $list = $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params); | ||||
/* @var $list kDBList */ | |||||
$category_id = array_key_exists('category_id', $params) ? $params['category_id'] : $this->Application->GetVar('m_cat_id'); | $category_id = array_key_exists('category_id', $params) ? $params['category_id'] : $this->Application->GetVar('m_cat_id'); | ||||
$list->addFilter('current_pages', TABLE_PREFIX . 'CategoryItems.CategoryId = ' . $category_id); | $list->addFilter('current_pages', TABLE_PREFIX . 'CategoryItems.CategoryId = ' . $category_id); | ||||
$list->Query(); | $list->Query(); | ||||
$list->GoFirst(); | $list->GoFirst(); | ||||
$o = ''; | $o = ''; | ||||
Show All 13 Lines | |||||
/** | /** | ||||
* Builds link for browsing current page on Front-End | * Builds link for browsing current page on Front-End | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function PageBrowseLink($params) | function PageBrowseLink($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
/** @var kThemesHelper $themes_helper */ | |||||
$themes_helper = $this->Application->recallObject('ThemesHelper'); | $themes_helper = $this->Application->recallObject('ThemesHelper'); | ||||
/* @var $themes_helper kThemesHelper */ | |||||
/** @var SiteConfigHelper $site_config_helper */ | |||||
$site_config_helper = $this->Application->recallObject('SiteConfigHelper'); | $site_config_helper = $this->Application->recallObject('SiteConfigHelper'); | ||||
/* @var $site_config_helper SiteConfigHelper */ | |||||
$settings = $site_config_helper->getSettings(); | $settings = $site_config_helper->getSettings(); | ||||
$url_params = Array ( | $url_params = Array ( | ||||
'm_cat_id' => $object->GetID(), | 'm_cat_id' => $object->GetID(), | ||||
'm_theme' => $themes_helper->getCurrentThemeId(), | 'm_theme' => $themes_helper->getCurrentThemeId(), | ||||
'editing_mode' => $settings['default_editing_mode'], | 'editing_mode' => $settings['default_editing_mode'], | ||||
'pass' => 'm', | 'pass' => 'm', | ||||
Show All 14 Lines | |||||
* Builds a link for securely accessing a page later (even if it will not be publicly accessible) | * Builds a link for securely accessing a page later (even if it will not be publicly accessible) | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function DirectLink($params) | protected function DirectLink($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
/** @var kThemesHelper $themes_helper */ | |||||
$themes_helper = $this->Application->recallObject('ThemesHelper'); | $themes_helper = $this->Application->recallObject('ThemesHelper'); | ||||
/* @var $themes_helper kThemesHelper */ | |||||
$url_params = Array ( | $url_params = Array ( | ||||
'm_cat_id' => $object->GetID(), | 'm_cat_id' => $object->GetID(), | ||||
'm_theme' => $themes_helper->getCurrentThemeId(), | 'm_theme' => $themes_helper->getCurrentThemeId(), | ||||
'pass' => 'm', | 'pass' => 'm', | ||||
'authkey' => $object->GetDBField('DirectLinkAuthKey'), | 'authkey' => $object->GetDBField('DirectLinkAuthKey'), | ||||
'__SSL__' => 0, | '__SSL__' => 0, | ||||
'__NO_SID__' => 0, | '__NO_SID__' => 0, | ||||
Show All 12 Lines | |||||
/** | /** | ||||
* Builds link to category as a cms page | * Builds link to category as a cms page | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function ContentPageLink($params) | function ContentPageLink($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$params['t'] = mb_strtolower($object->GetDBField('NamedParentPath')); | $params['t'] = mb_strtolower($object->GetDBField('NamedParentPath')); | ||||
$params['m_cat_id'] = 0; | $params['m_cat_id'] = 0; | ||||
return $this->Application->ProcessParsedTag('m', 'Link', $params); | return $this->Application->ProcessParsedTag('m', 'Link', $params); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | |||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function CurrentPath($params) | function CurrentPath($params) | ||||
{ | { | ||||
$block_params = $this->prepareTagParams($params); | $block_params = $this->prepareTagParams($params); | ||||
$block_params['name'] = $block_params['render_as']; | $block_params['name'] = $block_params['render_as']; | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($this->Prefix); | $object = $this->Application->recallObject($this->Prefix); | ||||
/* @var $object kDBItem */ | |||||
$category_ids = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); | $category_ids = explode('|', substr($object->GetDBField('ParentPath'), 1, -1)); | ||||
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); | $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); | ||||
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); | $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); | ||||
$language = (int)$this->Application->GetVar('m_lang'); | $language = (int)$this->Application->GetVar('m_lang'); | ||||
Show All 40 Lines | |||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
function BlockInfo($params) | function BlockInfo($params) | ||||
{ | { | ||||
if (!EDITING_MODE) { | if (!EDITING_MODE) { | ||||
return ''; | return ''; | ||||
} | } | ||||
/** @var TemplateHelper $template_helper */ | |||||
$template_helper = $this->Application->recallObject('TemplateHelper'); | $template_helper = $this->Application->recallObject('TemplateHelper'); | ||||
/* @var $template_helper TemplateHelper */ | |||||
return $template_helper->blockInfo( $params['name'] ); | return $template_helper->blockInfo( $params['name'] ); | ||||
} | } | ||||
/** | /** | ||||
* Hide all editing tabs except permission tab, when editing "Home" (ID = 0) category | * Hide all editing tabs except permission tab, when editing "Home" (ID = 0) category | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
Show All 27 Lines | |||||
if ($this->Application->prefixRegistred($prefix)) { | if ($this->Application->prefixRegistred($prefix)) { | ||||
$module_path = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/'; | $module_path = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/'; | ||||
$module_name = $this->Application->findModule('Path', $module_path, 'Name'); | $module_name = $this->Application->findModule('Path', $module_path, 'Name'); | ||||
$ret[$prefix] = mb_strtolower($module_name) . '/export'; | $ret[$prefix] = mb_strtolower($module_name) . '/export'; | ||||
} | } | ||||
} | } | ||||
/** @var JSONHelper $json_helper */ | |||||
$json_helper = $this->Application->recallObject('JSONHelper'); | $json_helper = $this->Application->recallObject('JSONHelper'); | ||||
/* @var $json_helper JSONHelper */ | |||||
return $json_helper->encode($ret); | return $json_helper->encode($ret); | ||||
} | } | ||||
/** | /** | ||||
* Checks, that "view in browse mode" functionality available | * Checks, that "view in browse mode" functionality available | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
Show All 10 Lines | |||||
/** | /** | ||||
* Returns a link for editing product | * Returns a link for editing product | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function ItemEditLink($params) | function ItemEditLink($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
$edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit'; | $edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit'; | ||||
$url_params = Array ( | $url_params = Array ( | ||||
'm_opener' => 'd', | 'm_opener' => 'd', | ||||
$this->Prefix.'_mode' => 't', | $this->Prefix.'_mode' => 't', | ||||
$this->Prefix.'_event' => 'OnEdit', | $this->Prefix.'_event' => 'OnEdit', | ||||
$this->Prefix.'_id' => $object->GetID(), | $this->Prefix.'_id' => $object->GetID(), | ||||
Show All 38 Lines | |||||
* @return string | * @return string | ||||
*/ | */ | ||||
function AllowedCategoriesJSON($params) | function AllowedCategoriesJSON($params) | ||||
{ | { | ||||
if ($this->Application->RecallVar('user_id') == USER_ROOT) { | if ($this->Application->RecallVar('user_id') == USER_ROOT) { | ||||
$categories = true; | $categories = true; | ||||
} | } | ||||
else { | else { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$perm_prefix = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix'); | $perm_prefix = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix'); | ||||
$categories = $perm_helper->getPermissionCategories($perm_prefix . '.' . ($object->IsNewItem() ? 'ADD' : 'MODIFY')); | $categories = $perm_helper->getPermissionCategories($perm_prefix . '.' . ($object->IsNewItem() ? 'ADD' : 'MODIFY')); | ||||
} | } | ||||
/** @var JSONHelper $json_helper */ | |||||
$json_helper = $this->Application->recallObject('JSONHelper'); | $json_helper = $this->Application->recallObject('JSONHelper'); | ||||
/* @var $json_helper JSONHelper */ | |||||
return $json_helper->encode($categories); | return $json_helper->encode($categories); | ||||
} | } | ||||
function PageEditable($params) | function PageEditable($params) | ||||
{ | { | ||||
if ($this->Application->isDebugMode()) { | if ($this->Application->isDebugMode()) { | ||||
return true; | return true; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return !$object->GetDBField('Protected'); | return !$object->GetDBField('Protected'); | ||||
} | } | ||||
/** | /** | ||||
* Returns element for "__item__" navigation bar part | * Returns element for "__item__" navigation bar part | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function CategoryItemElement($params) | protected function CategoryItemElement($params) | ||||
{ | { | ||||
/** @var CategoryHelper $category_helper */ | |||||
$category_helper = $this->Application->recallObject('CategoryHelper'); | $category_helper = $this->Application->recallObject('CategoryHelper'); | ||||
/* @var $category_helper CategoryHelper */ | |||||
/** @var kNavigationBar $navigation_bar */ | |||||
$navigation_bar = $this->Application->recallObject('kNavigationBar'); | $navigation_bar = $this->Application->recallObject('kNavigationBar'); | ||||
/* @var $navigation_bar kNavigationBar */ | |||||
$category_id = isset($params['cat_id']) ? $params['cat_id'] : $this->Application->GetVar('m_cat_id'); | $category_id = isset($params['cat_id']) ? $params['cat_id'] : $this->Application->GetVar('m_cat_id'); | ||||
$parent_path = explode('|', substr($navigation_bar->getParentPath($category_id), 1, -1)); | $parent_path = explode('|', substr($navigation_bar->getParentPath($category_id), 1, -1)); | ||||
array_shift($parent_path); // remove "Content" category | array_shift($parent_path); // remove "Content" category | ||||
$module_info = $category_helper->getCategoryModule($params, $parent_path); | $module_info = $category_helper->getCategoryModule($params, $parent_path); | ||||
if ( !$module_info ) { | if ( !$module_info ) { | ||||
return ''; | return ''; | ||||
} | } | ||||
$module_prefix = $module_info['Var']; | $module_prefix = $module_info['Var']; | ||||
/** @var kCatDBItem $object */ | |||||
$object = $this->Application->recallObject($module_prefix); | $object = $this->Application->recallObject($module_prefix); | ||||
/* @var $object kCatDBItem */ | |||||
$title_field = $this->Application->getUnitOption($module_prefix, 'TitleField'); | $title_field = $this->Application->getUnitOption($module_prefix, 'TitleField'); | ||||
$block_params = $this->prepareTagParams($params); | $block_params = $this->prepareTagParams($params); | ||||
$block_params['name'] = $params['render_as']; | $block_params['name'] = $params['render_as']; | ||||
$block_params['title'] = $object->GetField($title_field); | $block_params['title'] = $object->GetField($title_field); | ||||
$block_params['prefix'] = $module_prefix; | $block_params['prefix'] = $module_prefix; | ||||
return $this->Application->ParseBlock($block_params); | return $this->Application->ParseBlock($block_params); | ||||
} | } | ||||
} | } |