Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1242617
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Nov 20, 2:21 PM
Size
46 KB
Mime Type
text/x-diff
Expires
Sat, Nov 22, 2:21 PM (9 h, 7 m)
Engine
blob
Format
Raw Data
Handle
808816
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/themes/default2007/platform/elements/navigation_bar.tpl
===================================================================
--- trunk/themes/default2007/platform/elements/navigation_bar.tpl (revision 8717)
+++ trunk/themes/default2007/platform/elements/navigation_bar.tpl (revision 8718)
@@ -1,36 +1,37 @@
+<inp2:m_DefaultParam titles="" templates="" show_category="0"/>
+
<inp2:m_DefineElement name="root_category">
<img src="<inp2:m_TemplatesBase module="In-Portal"/>img/icon_home.gif" width="9" height="9" alt=""/> <a href="<inp2:c_CategoryLink template="__default__" />"><inp2:m_RootCategoryName/></a>
</inp2:m_DefineElement>
-<inp2:m_DefineElement name="category_link">
+<inp2:m_DefineElement name="module_root">
<inp2:m_param name="separator"/>
- <a href="<inp2:c_CategoryLink template="__default__" />"><inp2:m_param name="cat_name"/></a>
+ <a href="<inp2:c_CategoryLink template="$module_index" cat_id="$cat_id"/>"><inp2:m_param name="title"/></a>
</inp2:m_DefineElement>
-<inp2:m_DefineElement name="template_link">
+<inp2:m_DefineElement name="nav_link">
<inp2:m_param name="separator"/>
- <a href="<inp2:m_Link template="$template" m_cat_id="0"/>"><inp2:m_phrase name="$title"/></a>
+ <inp2:m_if check="m_Param" name="category">
+ <a href="<inp2:c_CategoryLink template="__default__" />"><inp2:m_param name="title"/></a>
+ <inp2:m_else/>
+ <a href="<inp2:m_Link template="$template" m_cat_id="0"/>"><inp2:m_param name="title"/></a>
+ </inp2:m_if>
</inp2:m_DefineElement>
-<inp2:m_DefineElement name="current_category">
+<inp2:m_DefineElement name="module_item">
<inp2:m_param name="separator"/>
- <span> <inp2:m_param name="cat_name"/></span>
+ <a href="<inp2:$prefix_ItemLink template="$template" />"><inp2:m_param name="title"/></a>
</inp2:m_DefineElement>
-<inp2:m_DefineElement name="current_template">
+<inp2:m_DefineElement name="current_item">
<inp2:m_param name="separator"/>
- <span> <inp2:m_phrase name="$title"/></span>
+ <span> <inp2:m_param name="title"/></span>
</inp2:m_DefineElement>
-
<table style="width: 100%;">
<tr>
<td class="navigation-bar">
- <inp2:m_if check="m_Param" name="titles">
- <inp2:c_NavigationBar separator=">" render_as="template_link" current_render_as="current_template" root_cat_render_as="root_category" titles="$titles" templates="$templates"/>
- <inp2:m_else/>
- <inp2:c_CategoryPath separator=">" render_as="category_link" current_render_as="current_category" root_cat_render_as="root_category" />
- </inp2:m_if>
- </td>
+ <inp2:c_CategoryPath separator=">" render_as="nav_link" current_render_as="current_item" module_item_render_as="module_item" root_cat_render_as="root_category" module_root_render_as="module_root" titles="$titles" templates="$templates" show_category="$show_category"/>
+ </td>
</tr>
</table>
\ No newline at end of file
Property changes on: trunk/themes/default2007/platform/elements/navigation_bar.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/core/units/categories/categories_tag_processor.php
===================================================================
--- trunk/core/units/categories/categories_tag_processor.php (revision 8717)
+++ trunk/core/units/categories/categories_tag_processor.php (revision 8718)
@@ -1,613 +1,517 @@
<?php
class CategoriesTagProcessor extends kDBTagProcessor {
function SubCatCount($params)
{
$object =& $this->getObject($params);
if (isset($params['today']) && $params['today']) {
$sql = 'SELECT COUNT(*)
FROM '.$object->TableName.'
WHERE (ParentPath LIKE "'.$object->GetDBField('ParentPath').'%") AND (CreatedOn > '.(adodb_mktime() - 86400).')';
return $this->Conn->GetOne($sql) - 1;
}
return $object->GetDBField('CachedDescendantCatsQty');
}
function IsNew($params)
{
$object =& $this->getObject($params);
return $object->GetDBField('IsNew') ? 1 : 0;
}
function IsPick($params)
{
return $this->IsEditorsPick($params);
}
/**
* Returns item's editors pick status (using not formatted value)
*
* @param Array $params
* @return bool
*/
function IsEditorsPick($params)
{
$object =& $this->getObject($params);
return $object->GetDBField('EditorsPick') == 1;
}
function ItemIcon($params)
{
// only for categories, not structure
if ($this->Prefix != 'c') {
return parent::ItemIcon($params);
}
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
$status = $object->GetDBField('Status');
if($status == 1)
{
$ret = $object->GetDBField('IsNew') ? 'icon16_cat_new.gif' : 'icon16_cat.gif';
}
else
{
$ret = $status ? 'icon16_cat_pending.gif' : 'icon16_cat_disabled.gif';
}
return $ret;
}
function ItemCount($params)
{
$cat_object =& $this->getObject($params);
$ci_table = $this->Application->getUnitOption('l-ci', 'TableName');
$sql = ' SELECT COUNT(*)
FROM '.$cat_object->TableName.' c
LEFT JOIN '.$ci_table.' ci
ON c.CategoryId=ci.CategoryId
WHERE c.ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"
AND NOT (ci.CategoryId IS NULL)';
return $this->Conn->GetOne($sql);
}
function ListCategories($params)
{
return $this->PrintList2($params);
}
function RootCategoryName($params)
{
return $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
}
function CheckModuleRoot($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
$module_root_cat = $this->Application->findModule('Name', $module_name, 'RootCat');
$additional_cats = $this->SelectParam($params, 'add_cats');
if ($additional_cats) {
$additional_cats = explode(',', $additional_cats);
}
else {
$additional_cats = array();
}
if ($this->Application->GetVar('m_cat_id') == $module_root_cat || in_array($this->Application->GetVar('m_cat_id'), $additional_cats)) {
$home_template = getArrayValue($params, 'home_template');
if (!$home_template) return;
$this->Application->Redirect($home_template, Array('pass'=>'all'));
};
}
function CategoryPath($params)
{
- $module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
- $module_category_id = $this->Application->findModule('Name', $module_name, 'RootCat');
- $module_item_id = $this->Application->GetVar($this->Application->findModule('Name', $module_name, 'Var').'_id');
-
- $block_params['separator'] = $params['separator'];
-
- if (!isset($params['cat_id'])) {
- $params['cat_id'] = getArrayValue($params, 'cat_id') ? $params['cat_id'] : $this->Application->GetVar('m_cat_id');
- }
-
- if ($params['cat_id'] == 0) {
- $block_params['current'] = 1;
- $block_params['cat_id'] = 0;
- $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
- $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as');
- return $this->Application->ParseBlock($block_params);
- }
- else {
- $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
- $navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
-
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
- $sql = 'SELECT '.$navbar_field.', ParentPath
- FROM '.$table_name.'
- WHERE '.$id_field.' = '.$params['cat_id'];
- $category_data = $this->Conn->GetRow($sql);
- $ret = '';
- if ($category_data) {
- $category_names = explode('&|&', $category_data[$navbar_field]);
- $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
-
- // add "Home" category at beginning of path
- array_unshift($category_names, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params));
- array_unshift($category_ids, 0);
-
- foreach ($category_ids as $category_pos => $category_id) {
- $block_params['cat_id'] = $category_id;
- $block_params['cat_name'] = $category_names[$category_pos];
- $block_params['current'] = ($params['cat_id'] == $category_id) && !$module_item_id ? 1 : 0;
- $block_params['is_module_root'] = $category_id == $module_category_id ? 1 : 0;
- $block_params['name'] = $this->SelectParam($params, 'render_as,block');
-
- // which block to parse as current ?
- if ($category_id == 0) {
- $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,block_root_cat,rootcatblock,render_as,block');
- }
-
- if ($block_params['is_module_root'] == 1) { // module root
- $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,block_module_root,rootmoduleblock,render_as,block');
- }
-
- if ($block_params['current'] == 1) { // current cat (label)
- $block_params['name'] = $this->SelectParam($params, 'current_render_as,block_current,currentblock,render_as,block');
- }
+ $category_helper =& $this->Application->recallObject('CategoryHelper');
+ /* @var $category_helper CategoryHelper */
- $this->Application->SetVar($this->Prefix.'_id', $category_id);
- $ret .= $this->Application->ParseBlock($block_params, 1);
- }
- }
-
- return $ret;
- }
- }
-
- function NavigationBar($params)
- {
- $titles = explode(',', $params['titles']);
- $templates = explode(',', $params['templates']);
-
- array_unshift($titles, $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params));
- array_unshift($templates, '');
-
- $block_params = $this->prepareTagParams($params);
- $current_template = $this->Application->GetVar('t');
-
- $ret = '';
- foreach ($templates as $template_index => $template) {
- $block_params['current'] = ($template == $current_template);
- $block_params['title'] = $titles[$template_index];
- $block_params['template'] = $template;
-
- switch ($template) {
- case '':
- $block_params['name'] = $params['root_cat_render_as'];
- break;
-
- case $current_template:
- $block_params['name'] = $params['current_render_as'];
- break;
-
- default:
- $block_params['name'] = $params['render_as'];
- break;
- }
-
- $ret .= $this->Application->ParseBlock($block_params);
- }
-
- return $ret;
+ return $category_helper->NavigationBar($params);
}
function CurrentCategoryName($params)
{
$cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List');
$sql = 'SELECT '.$this->getTitleField().'
FROM '.$cat_object->TableName.'
WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
return $this->Conn->GetOne($sql);
}
function getTitleField()
{
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
return $ml_formatter->LangFieldName('Name');
}
function CategoryLink($params)
{
$params = array_merge(Array('pass' => 'm'), $params);
$cat_id = getArrayValue($params, 'cat_id');
if ($cat_id === false) {
$cat_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
}
if ("$cat_id" == 'Root') {
$params['m_cat_id'] = $this->Application->findModule('Name', $params['module'], 'RootCat');
unset($params['module']);
}
else {
$params['m_cat_id'] = $cat_id;
}
unset($params['cat_id']);
$params['pass_category'] = 1;
return $this->Application->ProcessParsedTag('m', 't', $params);
}
function CategoryList($params)
{
//$object =& $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params );
$object =& $this->GetList($params);
if ($object->RecordsCount == 0)
{
if (isset($params['block_no_cats'])) {
$params['name'] = $params['block_no_cats'];
return $this->Application->ParseBlock($params);
}
else {
return '';
}
}
if (isset($params['block'])) {
return $this->PrintList($params);
}
else {
$params['block'] = $params['block_main'];
if (isset($params['block_row_start'])) {
$params['row_start_block'] = $params['block_row_start'];
}
if (isset($params['block_row_end'])) {
$params['row_end_block'] = $params['block_row_end'];
}
return $this->PrintList2($params);
}
}
function Meta($params)
{
$name = getArrayValue($params, 'name');
$object =& $this->Application->recallObject($this->Prefix.'.-item');
$field = $object->GetField('Meta'.$name);
if ($field) return $field;
switch ($name) {
case 'Description':
$conf = 'Category_MetaDesc';
break;
case 'Keywords':
$conf = 'Category_MetaKey';
break;
}
return $this->Application->ConfigValue($conf);
}
function BuildListSpecial($params)
{
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar($this->Prefix.'_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
$types = $this->SelectParam($params, 'types');
$except = $this->SelectParam($params, 'except');
$no_special = isset($params['no_special']) && $params['no_special'];
if ($no_special) return $this->Special;
if ($types.$except.$parent_cat_id == '') {
return parent::BuildListSpecial($params);
}
$special = crc32($types.$except.$parent_cat_id);
return $special;
}
function IsCurrent($params)
{
$object =& $this->getObject($params);
if ($object->GetID() == $this->Application->GetVar('m_cat_id')) {
return true;
}
else {
return false;
}
}
/**
* Substitutes category in last template base on current category
* This is required becasue when you navigate catalog using AJAX, last_template is not updated
* but when you open item edit from catalog last_template is used to build opener_stack
* So, if we don't substitute m_cat_id in last_template, after saving item we'll get redirected
* to the first category we've opened, not the one we navigated to using AJAX
*
* @param Array $params
*/
function UpdateLastTemplate($params)
{
$category_id = $this->Application->GetVar('m_cat_id');
$wid = $this->Application->GetVar('m_wid');
list($index_file, $env) = explode('|', $this->Application->RecallVar(rtrim('last_template_'.$wid, '_')), 2);
$this->Application->SetVar(ENV_VAR_NAME, str_replace('%5C', '\\', $env));
$this->Application->HttpQuery->processQueryString();
// update required fields
$this->Application->SetVar('m_cat_id', $category_id);
$this->Application->Session->SaveLastTemplate($params['template']);
}
function GetParentCategory($params)
{
$parent_id = 0;
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table = $this->Application->getUnitOption($this->Prefix,'TableName');
$cat_id = $this->Application->GetVar('m_cat_id');
if ($cat_id > 0) {
$sql = 'SELECT ParentId
FROM '.$table.'
WHERE '.$id_field.' = '.$cat_id;
$parent_id = $this->Conn->GetOne($sql);
}
return $parent_id;
}
function InitCacheUpdater($params)
{
safeDefine('CACHE_PERM_CHUNK_SIZE', 30);
$continue = $this->Application->GetVar('continue');
$total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) {
// first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update
return true;
}
if ($continue === false) {
// if we don't have to ask, then assume user selected "Yes" in permcache update dialog
$continue = 1;
}
$updater =& $this->Application->recallObject('kPermCacheUpdater', null, Array('continue' => $continue));
if ($continue === '0') { // No in dialog
$updater->clearData();
$this->Application->Redirect($params['destination_template']);
}
$ret = false; // don't ask for update
if ($continue == 1) { // Initial run
$updater->setData();
}
if ($continue == 2) { // Continuing
// called from AJAX request => returns percent
$needs_more = true;
while ($needs_more && $updater->iteration <= CACHE_PERM_CHUNK_SIZE) {
// until proceeeded in this step category count exceeds category per step limit
$needs_more = $updater->DoTheJob();
}
if ($needs_more) {
// still some categories are left for next step
$updater->setData();
}
else {
// all done -> redirect
$updater->clearData();
$this->Application->RemoveVar('PermCache_UpdateRequired');
$this->Application->Redirect($params['destination_template']);
}
$ret = $updater->getDonePercent();
}
return $ret;
}
/**
* Parses warning block, but with style="display: none;". Used during permissions saving from AJAX
*
* @param Array $params
* @return string
*/
function SaveWarning($params)
{
if ($this->Prefix != 'c') {
// don't use this method for other prefixes then Category, that use this tag processor
parent::SaveWarning($params);
return ;
}
$main_prefix = getArrayValue($params, 'main_prefix');
if ($main_prefix && $main_prefix != '$main_prefix') {
$top_prefix = $main_prefix;
}
else {
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
$temp_tables = substr($this->Application->GetVar($top_prefix.'_mode'), 0, 1) == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
if (!$temp_tables) {
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
$block_name = $this->SelectParam($params, 'render_as,name');
if ($block_name) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $block_name;
$block_params['edit_mode'] = $temp_tables ? 1 : 0;
$block_params['display'] = $temp_tables && $modified ? 1 : 0;
return $this->Application->ParseBlock($block_params);
}
else {
return $temp_tables && $modified ? 1 : 0;
}
return ;
}
/**
* Allows to detect if this prefix has something in clipboard
*
* @param Array $params
* @return bool
*/
function HasClipboard($params)
{
$clipboard = $this->Application->RecallVar('clipboard');
if ($clipboard) {
$clipboard = unserialize($clipboard);
foreach ($clipboard as $prefix => $clipboard_data) {
foreach ($clipboard_data as $mode => $ids) {
if (count($ids)) return 1;
}
}
}
return 0;
}
/**
* Allows to detect if root category being edited
*
* @param Array $params
*/
function IsRootCategory($params)
{
$object =& $this->getObject($params);
return $object->IsRoot();
}
function CatalogItemCount($params)
{
$object =& $this->GetList($params);
if (!$object->Counted) {
$object->CountRecs();
}
return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintPages($params)
{
if ($this->Application->Parser->GetParam('no_special')) {
$params['no_special'] = $this->Application->Parser->GetParam('no_special');
}
return parent::PrintPages($params);
}
function InitCatalog($params)
{
$tab_prefixes = $this->Application->GetVar('tp'); // {all, <prefixes_list>, none}
if ($tab_prefixes === false) $tab_prefixes = 'all';
$skip_prefixes = isset($params['skip_prefixes']) && $params['skip_prefixes'] ? explode(',', $params['skip_prefixes']) : Array();
// get all prefixes available
$prefixes = Array();
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
if ($module_data['Var'] == 'm') continue;
$prefixes[] = $module_data['Var'];
}
if ($tab_prefixes == 'none') {
$skip_prefixes = array_unique(array_merge($skip_prefixes, $prefixes));
}
elseif ($tab_prefixes != 'all') {
// prefix list here
$tab_prefixes = explode(',', $tab_prefixes); // list of prefixes that should stay
$skip_prefixes = array_unique(array_merge($skip_prefixes, array_diff($prefixes, $tab_prefixes)));
}
$params['name'] = $params['render_as'];
$params['skip_prefixes'] = implode(',', $skip_prefixes);
return $this->Application->ParseBlock($params, 1);
}
function IsActive($params)
{
$cat_id = isset($params['cat_id']) && $params['cat_id'] ? $params['cat_id'] : false;
if ($cat_id === false) {
// category not supplied -> get current from PrintList
$cat_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
$current_cat =& $this->getObject($params);
}
else {
if ("$cat_id" == 'Root') {
$cat_id = $this->Application->findModule('Name', $params['module'], 'RootCat');
}
$current_cat =& $this->Application->recallObject($this->Prefix.'.-c'.$cat_id, $this->Prefix, Array ('skip_autoload' => true));
$current_cat->Load($cat_id);
}
$current_path = $current_cat->GetDBField('ParentPath');
static $parent_path = null;
if (!isset($parent_path)) {
$parent_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'));
}
return strpos($parent_path, $current_path) !== false;
}
/**
* Checks if user have one of required permissions
*
* @param Array $params
* @return bool
*/
function HasPermission($params)
{
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$params['raise_warnings'] = 0;
$object =& $this->getObject($params);
/* @var $object kDBItem */
$params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
return $perm_helper->TagPermissionCheck($params, $this->getPrefixSpecial().'_HasPermission');
}
/**
* Prepares name for field with event in it (used only on front-end)
*
* @param Array $params
* @return string
*/
function SubmitName($params)
{
return 'events['.$this->Prefix.']['.$params['event'].']';
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/categories/categories_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.43
\ No newline at end of property
+1.44
\ No newline at end of property
Index: trunk/core/units/general/helpers/category_helper.php
===================================================================
--- trunk/core/units/general/helpers/category_helper.php (nonexistent)
+++ trunk/core/units/general/helpers/category_helper.php (revision 8718)
@@ -0,0 +1,221 @@
+<?php
+
+ class CategoryHelper extends kHelper {
+
+ function NavigationBar($params)
+ {
+ $main_category_id = isset($params['cat_id']) ? $params['cat_id'] : $this->Application->GetVar('m_cat_id');
+
+ $ret = $this->getHomeCategoryPath($params);
+ if (!getArrayValue($params, 'titles') && !getArrayValue($params, 'templates')) {
+ // no static templates given, show only category path
+ return $ret . $this->getCategoryPath($main_category_id, $params);
+ }
+
+ $navigation_parts = $this->getNavigationParts($params['titles'], $params['templates']);
+
+ $block_params = Array ('category' => 0);
+ $block_params['separator'] = $params['separator'];
+ $current_template = $this->Application->GetVar('t');
+
+ foreach ($navigation_parts as $template => $title) {
+ $block_params['template'] = $template;
+
+ if ($title == '__item__') {
+ if (getArrayValue($params, 'show_category')) {
+ $ret .= $this->getCategoryPath($main_category_id, $params);
+ }
+
+ $category_path = $this->getCategoryParentPath($main_category_id);
+ $module_info = $this->getCategoryModule($params, array_keys($category_path));
+ $module_prefix = $module_info['Var'];
+ $object =& $this->Application->recallObject($module_prefix);
+ /* @var $object kCatDBItem */
+
+ $title_field = $this->Application->getUnitOption($module_prefix, 'TitleField');
+ $block_params['title'] = $object->GetField($title_field);
+ $block_params['prefix'] = $module_prefix;
+ $block_params['current'] = 0;
+
+ $block_params['name'] = $this->SelectParam($params, 'module_item_render_as,render_as');
+ }
+ else {
+ $block_params['current'] = ($template == $current_template);
+ $block_params['title'] = $this->Application->Phrase($title);
+
+ $block_params['name'] = $template == $current_template ? $params['current_render_as'] : $params['render_as'];
+ }
+
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Get navigation parts
+ *
+ * @param Array $titles
+ * @param Array $templates
+ * @return Array
+ */
+ function getNavigationParts($titles, $templates)
+ {
+ $titles = explode(',', $titles);
+ $templates = explode(',', $templates);
+
+ $ret = Array ();
+ foreach ($templates as $template_pos => $template) {
+ $ret[$template] = $titles[$template_pos];
+ }
+
+ return $ret;
+ }
+
+ function getCategoryPath($main_category_id, $params)
+ {
+ $category_path = $this->getCategoryParentPath($main_category_id);
+ if (!$category_path) {
+ // in "Home" category
+ return '';
+ }
+
+ $module_info = $this->getCategoryModule($params, array_keys($category_path));
+
+ $module_category_id = $module_info['RootCat'];
+ $module_item_id = $this->Application->GetVar($module_info['Var'].'_id');
+
+ $ret = '';
+ $block_params['category'] = 1;
+ $block_params['separator'] = $params['separator'];
+ foreach ($category_path as $category_id => $category_name) {
+ $block_params['cat_id'] = $category_id;
+ $block_params['cat_name'] = $block_params['title'] = $category_name;
+ $block_params['current'] = ($main_category_id == $category_id) && !$module_item_id ? 1 : 0;
+ $block_params['is_module_root'] = $category_id == $module_category_id ? 1 : 0;
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+
+ // which block to parse as current ?
+ if ($block_params['is_module_root']) {
+ $block_params['name'] = $this->SelectParam($params, 'module_root_render_as,render_as');
+ $block_params['module_index'] = $module_info['TemplatePath'].'index';
+ }
+
+ if ($block_params['current']) {
+ $block_params['name'] = $this->SelectParam($params, 'current_render_as,render_as');
+ }
+
+ $this->Application->SetVar('c_id', $category_id);
+ $ret .= $this->Application->ParseBlock($block_params, 1);
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Returns module information based on given module name or current category (relative to module root categories)
+ *
+ * @param Array $params
+ * @param Array $category_ids category parent path (already as array)
+ * @return Array
+ */
+ function getCategoryModule($params, $category_ids)
+ {
+ if (isset($params['module'])) {
+ // get module by name specified
+ $module_info = $this->Application->findModule('Name', $params['module']);
+
+ }
+ elseif ($category_ids) {
+ // get module by category path
+ $module_root_categories = $this->getModuleRootCategories();
+ $module_category_id = array_shift(array_intersect($category_ids, $module_root_categories));
+ $module_info = $this->Application->findModule('RootCat', $module_category_id);
+ }
+
+ return $module_info;
+ }
+
+ function getHomeCategoryPath($params)
+ {
+ $block_params['cat_id'] = 0;
+ $block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
+ $block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,render_as');
+ return $this->Application->ParseBlock($block_params);
+ }
+
+ function getModuleRootCategories()
+ {
+ static $root_categories = null;
+
+ if (!isset($root_categories)) {
+ $root_categories = Array ();
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ array_push($root_categories, $module_info['RootCat']);
+ }
+
+ $root_categories = array_unique($root_categories);
+ }
+
+ return $root_categories;
+ }
+
+ function getCategoryParentPath($main_category_id)
+ {
+ static $cached_path = null;
+
+ if ($main_category_id == 0) {
+ // don't query path for "Home" category
+ return Array ();
+ }
+
+ if (!isset($cached_path[$main_category_id])) {
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
+
+ $id_field = $this->Application->getUnitOption('c', 'IDField');
+ $table_name = $this->Application->getUnitOption('c', 'TableName');
+
+ $sql = 'SELECT '.$navbar_field.', ParentPath
+ FROM '.$table_name.'
+ WHERE '.$id_field.' = '.$main_category_id;
+ $category_data = $this->Conn->GetRow($sql);
+
+ $cached_path[$main_category_id] = Array ();
+ if ($category_data) {
+ $category_names = explode('&|&', $category_data[$navbar_field]);
+ $category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
+
+ foreach ($category_ids as $category_index => $category_id) {
+ $cached_path[$main_category_id][$category_id] = $category_names[$category_index];
+ }
+ }
+ }
+ return $cached_path[$main_category_id];
+ }
+
+ /**
+ * Not tag, method for parameter
+ * selection from list in this TagProcessor
+ *
+ * @param Array $params
+ * @param string $possible_names
+ * @return string
+ * @access public
+ */
+ function SelectParam($params, $possible_names)
+ {
+ if (!is_array($params)) return;
+ if (!is_array($possible_names))
+
+ $possible_names = explode(',', $possible_names);
+ foreach ($possible_names as $name)
+ {
+ if( isset($params[$name]) ) return $params[$name];
+ }
+ return false;
+ }
+ }
+
+
+?>
\ No newline at end of file
Property changes on: trunk/core/units/general/helpers/category_helper.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/units/general/helpers/helpers_config.php
===================================================================
--- trunk/core/units/general/helpers/helpers_config.php (revision 8717)
+++ trunk/core/units/general/helpers/helpers_config.php (revision 8718)
@@ -1,26 +1,27 @@
<?php
$config = Array(
'Prefix' => 'helpers',
'EventHandlerClass' => Array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
'RegisterClasses' => Array(
Array('pseudo'=>'kMultiLanguageHelper','class'=>'kMultiLanguageHelper','file'=>'multilanguage.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'SearchHelper','class'=>'kSearchHelper','file'=>'search_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'SectionsHelper','class'=>'kSectionsHelper','file'=>'sections_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'PermissionsHelper','class'=>'kPermissionsHelper','file'=>'permissions_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'ModulesHelper','class'=>'kModulesHelper','file'=>'modules.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'ModRewriteHelper','class'=>'kModRewriteHelper','file'=>'mod_rewrite_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'RecursiveHelper','class'=>'kRecursiveHelper','file'=>'recursive_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'FilenamesHelper','class'=>'kFilenamesHelper','file'=>'filenames_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'ClipboardHelper','class'=>'kClipboardHelper','file'=>'clipboard_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'ColumnPickerHelper','class'=>'kColumnPickerHelper','file'=>'col_picker_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'ThemesHelper','class'=>'kThemesHelper','file'=>'themes_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'CaptchaHelper','class'=>'kCaptchaHelper','file'=>'captcha_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'PriorityHelper','class'=>'kPriorityHelper','file'=>'priority_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo' => 'CurlHelper', 'class' => 'kCurlHelper','file' => 'curl_helper.php', 'build_event' => '', 'require_classes' => Array('kHelper')),
Array('pseudo'=>'CountHelper','class'=>'kCountHelper','file'=>'count_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo'=>'ImageHelper','class'=>'ImageHelper','file'=>'image_helper.php','build_event'=>'','require_classes'=>'kHelper'),
+ Array('pseudo'=>'CategoryHelper','class'=>'CategoryHelper','file'=>'category_helper.php','build_event'=>'','require_classes'=>'kHelper'),
),
);
\ No newline at end of file
Property changes on: trunk/core/units/general/helpers/helpers_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8
\ No newline at end of property
+1.9
\ No newline at end of property
Index: trunk/core/units/general/cat_tag_processor.php
===================================================================
--- trunk/core/units/general/cat_tag_processor.php (revision 8717)
+++ trunk/core/units/general/cat_tag_processor.php (revision 8718)
@@ -1,418 +1,418 @@
<?php
class kCatDBTagProcessor extends kDBTagProcessor {
/**
* Permission Helper
*
* @var kPermissionsHelper
*/
var $PermHelper = null;
function kCatDBTagProcessor()
{
parent::kDBTagProcessor();
$this->PermHelper = $this->Application->recallObject('PermissionsHelper');
}
function ItemIcon($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$icons =& $grids[ $params['grid'] ]['Icons'];
$status_fields = $this->Application->getUnitOption($this->Prefix,'StatusField');
if (!$status_fields) return $icons['default'];
$value = $object->GetDBField($status_fields[0]); // sets base status icon
/* @var $object kDBItem */
if ($value == STATUS_ACTIVE) {
if( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) $value = 'POP';
if( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) $value = 'HOT';
if( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) $value = 'NEW';
if( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) $value = 'PICK';
}
return isset($icons[$value]) ? $icons[$value] : $icons['default'];
}
/**
* Allows to create valid mod-rewrite compatible link to module item
*
* @param Array $params
* @param string $id_prefix
* @return string
*/
- function ItemLink($params, $id_prefix)
+ function ItemLink($params, $id_prefix = null)
{
$params = array_merge($params, Array('pass' => 'm,'.$this->Prefix) );
$item_id = isset($params[$id_prefix.'_id']) && $params[$id_prefix.'_id'];
if (!$item_id) {
$item_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
if (!$item_id) {
$item_id = $this->Application->GetVar($this->Prefix.'_id');
}
}
$params[$this->Prefix.'_id'] = $item_id;
$object =& $this->getObject($params);
$params['m_cat_id'] = $object->GetDBField('CategoryId');
$params['pass_category'] = 1;
return $this->Application->ProcessParsedTag('m', 't', $params);
}
function CategoryPath($params)
{
if ($this->Application->IsAdmin()) {
// path for module root category in admin
if (!isset($params['cat_id'])) {
$params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0);
}
}
else {
// path for category item category in front-end
$object =& $this->getObject($params);
$params['cat_id'] = $object->GetDBField('CategoryId');
}
return $this->Application->ProcessParsedTag('c', 'CategoryPath', $params);
}
function BuildListSpecial($params)
{
if ($this->Special != '') return $this->Special;
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
}
$recursive = isset($params['recursive']);
$types = $this->SelectParam($params, 'types');
$except = $this->SelectParam($params, 'except');
if ($types.$except.$recursive == '') {
return parent::BuildListSpecial($params);
}
$special = crc32($parent_cat_id.$types.$except.$recursive);
return $special;
}
function CatalogItemCount($params)
{
$object =& $this->GetList($params);
if (!$object->Counted) {
$object->CountRecs();
}
return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount;
}
function ListReviews($params)
{
$prefix = $this->Prefix.'-rev';
$review_tag_processor =& $this->Application->recallObject($prefix.'.item_TagProcessor');
return $review_tag_processor->PrintList($params);
}
function ReviewCount($params)
{
$review_tag_processor =& $this->Application->recallObject('rev.item_TagProcessor');
return $review_tag_processor->TotalRecords($params);
}
function InitCatalogTab($params)
{
$tab_params['mode'] = $this->Application->GetVar('tm'); // single/multi selection possible
$tab_params['special'] = $this->Application->GetVar('ts'); // use special for this tab
$tab_params['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid
// set default params (same as in catalog)
if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi';
if ($tab_params['special'] === false) $tab_params['special'] = '';
if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes';
// pass params to block with tab content
$params['name'] = $params['render_as'];
$params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
$params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
$params['tab_mode'] = $tab_params['mode'];
$params['tab_dependant'] = $tab_params['dependant'];
$params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name
return $this->Application->ParseBlock($params, 1);
}
/**
* Show CachedNavbar of current item primary category
*
* @param Array $params
* @return string
*/
function CategoryName($params)
{
// show category cachednavbar of
$object =& $this->getObject($params);
$category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId');
$category_path = $this->Application->getCache('category_paths', $category_id);
if ($category_path === false) {
// not chached
if ($category_id > 0) {
$category_path = trim($this->CategoryName( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $object->GetDBField('CachedNavbar')), ' > ');
}
else {
$category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') );
}
$this->Application->setCache('category_paths', $category_id, $category_path);
}
return $category_path;
}
/**
* Allows to determine if original value should be shown
*
* @param Array $params
* @return bool
*/
function DisplayOriginal($params)
{
// original id found & greather then zero + show original
$display_original = isset($params['display_original']) && $params['display_original'];
$owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField');
if (!$owner_field) {
$owner_field = 'CreatedById';
}
$object =& $this->getObject($params);
$perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $this->Prefix);
return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id');
}
/**
* Checks if user have one of required permissions
*
* @param Array $params
* @return bool
*/
function HasPermission($params)
{
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$params['raise_warnings'] = 0;
$object =& $this->getObject($params);
/* @var $object kDBItem */
$params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
return $perm_helper->TagPermissionCheck($params, $this->getPrefixSpecial().'_HasPermission');
}
/**
* Creates link to current category or to module root category, when current category is home
*
* @param Array $params
* @return string
*/
function SuggestItemLink($params)
{
if (!isset($params['cat_id'])) {
$params['cat_id'] = $this->Application->GetVar('m_cat_id');
}
if ($params['cat_id'] == 0) {
$params['cat_id'] = $this->Application->findModule('Var', $this->Prefix, 'RootCat');
}
return $this->Application->ProcessParsedTag('c', 'CategoryLink', $params);
}
/**
* Allows to detect if item has any additional images available
*
* @param Array $params
* @return string
*/
function HasAdditionalImages($params)
{
$object =& $this->getObject($params);
$sql = 'SELECT ImageId
FROM '.$this->Application->getUnitOption('img', 'TableName').'
WHERE ResourceId = '.$object->GetDBField('ResourceId').' AND DefaultImg != 1 AND Enabled = 1';
return $this->Conn->GetOne($sql) ? 1 : 0;
}
/**
* Checks that item is pending
*
* @param Array $params
* @return bool
*/
function IsPending($params)
{
$object =& $this->getObject($params);
$pending_status = Array (STATUS_PENDING, STATUS_PENDING_EDITING);
return in_array($object->GetDBField('Status'), $pending_status);
}
function IsFavorite($params)
{
static $favorite_status = null;
$object =& $this->getObject($params);
/* @var $object kDBList */
if (!isset($favorite_status)) {
$resource_ids = $object->GetCol('ResourceId');
$user_id = $this->Application->RecallVar('user_id');
$sql = 'SELECT FavoriteId, ResourceId
FROM '.$this->Application->getUnitOption('fav', 'TableName').'
WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))';
$favorite_status = $this->Conn->GetCol($sql, 'ResourceId');
}
return isset($favorite_status[$object->GetDBField('ResourceId')]);
}
/**
* Returns item's editors pick status (using not formatted value)
*
* @param Array $params
* @return bool
*/
function IsEditorsPick($params)
{
$object =& $this->getObject($params);
return $object->GetDBField('EditorsPick') == 1;
}
function FavoriteToggleLink($params)
{
$fav_prefix = $this->Prefix.'-fav';
$params['pass'] = implode(',', Array('m', $this->Prefix, $fav_prefix));
$params[$fav_prefix.'_event'] = 'OnFavoriteToggle';
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* Checks if item is passed in url
*
* @param Array $params
* @return bool
*/
function ItemAvailable($params)
{
return $this->Application->GetVar($this->getPrefixSpecial().'_id') > 0;
}
function SortingSelected($params)
{
$list =& $this->GetList($params);
$user_sorting_start = $this->getUserSortIndex();
$sorting = strtolower($list->GetOrderField($user_sorting_start).'|'.$list->GetOrderDirection($user_sorting_start));
if ($sorting == strtolower($params['sorting'])) return $params['selected'];
}
function CombinedSortingDropDownName($params)
{
return $this->Prefix.'_CombinedSorting';
}
/**
* Prepares name for field with event in it (used only on front-end)
*
* @param Array $params
* @return string
*/
function SubmitName($params)
{
return 'events['.$this->Prefix.']['.$params['event'].']';
}
/**
* Returns prefix + any word (used for shared between categories per page settings)
*
* @param Array $params
* @return string
*/
function VarName($params)
{
return $this->Prefix.'_'.$params['type'];
}
/**
* Checks if we are viewing module root category
*
* @param Array $params
* @return bool
*/
function IsModuleHome($params)
{
$root_category = $this->Application->findModule('Var', $this->Prefix, 'RootCat');
return $root_category == $this->Application->GetVar('m_cat_id');
}
/**
* Dynamic votes indicator
*
* @param Array $params
*
* @return string
*/
function VotesIndicator($params)
{
$blocks_params = $this->prepareTagParams($params);
$blocks_params['name'] = $params['render_as'];
$object =& $this->getObject($params);
/* @var $object kDBItem */
if ($this->Application->ConfigValue('UseFloatRating')) {
$rating = $object->GetDBField('CachedRating');
$float_rating = floor(($rating - floor($rating)) / 0.25) * 0.25;
}
else {
$rating = round( $object->GetDBField('CachedRating') );
$float_rating = 0;
}
$i = 1;
$ret = '';
while ($i <= 5) {
$blocks_params['number'] = $i;
$blocks_params['active'] = $rating >= $i ? 1 : 0;
if ($rating > $i - 1 && $rating < $i && $float_rating > 0) {
$blocks_params['active'] = 1;
$blocks_params['float_rating'] = $float_rating;
}
else {
$blocks_params['float_rating'] = '';
}
$ret .= trim($this->Application->ParseBlock($blocks_params));
$i++;
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/general/cat_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.34
\ No newline at end of property
+1.35
\ No newline at end of property
Event Timeline
Log In to Comment