Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/cat_tag_processor.php
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
$status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField'); | $status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField'); | ||||
if (!$status_fields) { | if (!$status_fields) { | ||||
return $icons['default']; | return $icons['default']; | ||||
} | } | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
$value = $object->GetDBField($status_fields[0]); // sets base status icon | $value = $object->GetDBField($status_fields[0]); // sets base status icon | ||||
if ($value == STATUS_ACTIVE) { | if ($value == STATUS_ACTIVE) { | ||||
// if( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) $value = 'POP'; | // if( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) $value = 'POP'; | ||||
// if( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) $value = 'HOT'; | // if( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) $value = 'HOT'; | ||||
if( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) $value = 'NEW'; | if( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) $value = 'NEW'; | ||||
// if( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) $value = 'PICK'; | // if( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) $value = 'PICK'; | ||||
Show All 30 Lines | |||||
// set by PrintList2 tag | // set by PrintList2 tag | ||||
$item_id = $this->Application->GetVar($this->getPrefixSpecial() . '_id'); | $item_id = $this->Application->GetVar($this->getPrefixSpecial() . '_id'); | ||||
if ( !$item_id && ($this->Special != 'next' && $this->Special != 'previous') ) { | if ( !$item_id && ($this->Special != 'next' && $this->Special != 'previous') ) { | ||||
// set from page url | // set from page url | ||||
$item_id = $this->Application->GetVar($this->Prefix . '_id'); | $item_id = $this->Application->GetVar($this->Prefix . '_id'); | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$params['m_cat_page'] = 1; | $params['m_cat_page'] = 1; | ||||
$params['m_cat_id'] = $object->GetDBField('CategoryId'); | $params['m_cat_id'] = $object->GetDBField('CategoryId'); | ||||
$params['pass_category'] = 1; | $params['pass_category'] = 1; | ||||
$params[$this->Prefix . '_id'] = $item_id ? $item_id : $object->GetID(); | $params[$this->Prefix . '_id'] = $item_id ? $item_id : $object->GetID(); | ||||
return $this->Application->ProcessParsedTag('m', 't', $params); | return $this->Application->ProcessParsedTag('m', 't', $params); | ||||
} | } | ||||
/** | /** | ||||
* Builds link for browsing current item on Front-End | * Builds link for browsing current item on Front-End | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function PageBrowseLink($params) | function PageBrowseLink($params) | ||||
{ | { | ||||
/** @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(); | ||||
$params['editing_mode'] = $settings['default_editing_mode']; | $params['editing_mode'] = $settings['default_editing_mode']; | ||||
$params['m_theme'] = $themes_helper->getCurrentThemeId(); | $params['m_theme'] = $themes_helper->getCurrentThemeId(); | ||||
$params['admin'] = 1; | $params['admin'] = 1; | ||||
return $this->ItemLink($params); | return $this->ItemLink($params); | ||||
} | } | ||||
function CategoryPath($params) | function CategoryPath($params) | ||||
{ | { | ||||
if ($this->Application->isAdminUser) { | if ($this->Application->isAdminUser) { | ||||
// path for module root category in admin | // path for module root category in admin | ||||
if (!isset($params['cat_id'])) { | if (!isset($params['cat_id'])) { | ||||
$params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0); | $params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0); | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
// path for category item category in front-end | // path for category item category in front-end | ||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
$params['cat_id'] = $object->GetDBField('CategoryId'); | $params['cat_id'] = $object->GetDBField('CategoryId'); | ||||
} | } | ||||
/** @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); | ||||
} | } | ||||
function BuildListSpecial($params) | function BuildListSpecial($params) | ||||
{ | { | ||||
if ($this->Special != '') return $this->Special; | if ($this->Special != '') return $this->Special; | ||||
if ( isset($params['parent_cat_id']) ) { | if ( isset($params['parent_cat_id']) ) { | ||||
Show All 23 Lines | |||||
return $object->GetRecordsCount(false) != $object->GetRecordsCount() ? $object->GetRecordsCount().' / '.$object->GetRecordsCount(false) : $object->GetRecordsCount(); | return $object->GetRecordsCount(false) != $object->GetRecordsCount() ? $object->GetRecordsCount().' / '.$object->GetRecordsCount(false) : $object->GetRecordsCount(); | ||||
} | } | ||||
function ListReviews($params) | function ListReviews($params) | ||||
{ | { | ||||
$prefix = $this->Prefix . '-rev'; | $prefix = $this->Prefix . '-rev'; | ||||
/** @var kDBTagProcessor $review_tag_processor */ | |||||
$review_tag_processor = $this->Application->recallObject($prefix . '.item_TagProcessor'); | $review_tag_processor = $this->Application->recallObject($prefix . '.item_TagProcessor'); | ||||
/* @var $review_tag_processor kDBTagProcessor */ | |||||
return $review_tag_processor->PrintList($params); | return $review_tag_processor->PrintList($params); | ||||
} | } | ||||
function ReviewCount($params) | function ReviewCount($params) | ||||
{ | { | ||||
/** @var kDBTagProcessor $review_tag_processor */ | |||||
$review_tag_processor = $this->Application->recallObject('rev.item_TagProcessor'); | $review_tag_processor = $this->Application->recallObject('rev.item_TagProcessor'); | ||||
/* @var $review_tag_processor kDBTagProcessor */ | |||||
return $review_tag_processor->TotalRecords($params); | return $review_tag_processor->TotalRecords($params); | ||||
} | } | ||||
function InitCatalogTab($params) | function InitCatalogTab($params) | ||||
{ | { | ||||
$tab_params['mode'] = $this->Application->GetVar('tm'); // single/multi selection possible | $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['special'] = $this->Application->GetVar('ts'); // use special for this tab | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* 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 kCatDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kCatDBItem */ | |||||
// 1. category restriction | // 1. category restriction | ||||
$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'); | ||||
// 2. owner restriction | // 2. owner restriction | ||||
$owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); | $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); | ||||
if (!$owner_field) { | if (!$owner_field) { | ||||
$owner_field = 'CreatedById'; | $owner_field = 'CreatedById'; | ||||
Show All 27 Lines | |||||
/** | /** | ||||
* Allows to detect if item has any additional images available | * Allows to detect if item has any additional images available | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function HasAdditionalImages($params) | function HasAdditionalImages($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$cache_key = $object->Prefix . '_additional_images[%' . $this->Application->incrementCacheSerial($object->Prefix, $object->GetID(), false) . '%]'; | $cache_key = $object->Prefix . '_additional_images[%' . $this->Application->incrementCacheSerial($object->Prefix, $object->GetID(), false) . '%]'; | ||||
$ret = $this->Application->getCache($cache_key); | $ret = $this->Application->getCache($cache_key); | ||||
if ($ret === false) { | if ($ret === false) { | ||||
$this->Conn->nextQueryCachable = true; | $this->Conn->nextQueryCachable = true; | ||||
$sql = 'SELECT ImageId | $sql = 'SELECT ImageId | ||||
FROM ' . $this->Application->getUnitOption('img', 'TableName') . ' | FROM ' . $this->Application->getUnitOption('img', 'TableName') . ' | ||||
Show All 19 Lines | |||||
$pending_status = Array (STATUS_PENDING, STATUS_PENDING_EDITING); | $pending_status = Array (STATUS_PENDING, STATUS_PENDING_EDITING); | ||||
return in_array($object->GetDBField('Status'), $pending_status); | return in_array($object->GetDBField('Status'), $pending_status); | ||||
} | } | ||||
function IsFavorite($params) | function IsFavorite($params) | ||||
{ | { | ||||
static $favorite_status = Array (); | static $favorite_status = Array (); | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
if (!isset($favorite_status[$this->Special])) { | if (!isset($favorite_status[$this->Special])) { | ||||
$resource_ids = $object->GetCol('ResourceId'); | $resource_ids = $object->GetCol('ResourceId'); | ||||
$user_id = $this->Application->RecallVar('user_id'); | $user_id = $this->Application->RecallVar('user_id'); | ||||
$sql = 'SELECT FavoriteId, ResourceId | $sql = 'SELECT FavoriteId, ResourceId | ||||
FROM '.$this->Application->getUnitOption('fav', 'TableName').' | FROM '.$this->Application->getUnitOption('fav', 'TableName').' | ||||
WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))'; | WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))'; | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | |||||
* Dynamic votes indicator | * Dynamic votes indicator | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function VotesIndicator($params) | function VotesIndicator($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
/** @var RatingHelper $rating_helper */ | |||||
$rating_helper = $this->Application->recallObject('RatingHelper'); | $rating_helper = $this->Application->recallObject('RatingHelper'); | ||||
/* @var $rating_helper RatingHelper */ | |||||
$small_style = array_key_exists('small_style', $params) ? $params['small_style'] : false; | $small_style = array_key_exists('small_style', $params) ? $params['small_style'] : false; | ||||
return $rating_helper->ratingBar($object, true, '', $small_style); | return $rating_helper->ratingBar($object, true, '', $small_style); | ||||
} | } | ||||
function RelevanceIndicator($params) | function RelevanceIndicator($params) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 117 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); | ||||
} | } | ||||
/** | /** | ||||
* Counts category item count in system (not category-dependent) | * Counts category item count in system (not category-dependent) | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
function ItemCount($params) | function ItemCount($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->ItemCount($this->Prefix, $today_only); | return $count_helper->ItemCount($this->Prefix, $today_only); | ||||
} | } | ||||
/** | /** | ||||
* Displays list of allowed categories on "Suggest Link" and similar forms. | * Displays list of allowed categories on "Suggest Link" and similar forms. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
'c.Status = ' . STATUS_ACTIVE, | 'c.Status = ' . STATUS_ACTIVE, | ||||
); | ); | ||||
$sql = 'SELECT c.' . $title_field . ' AS CategoryName, | $sql = 'SELECT c.' . $title_field . ' AS CategoryName, | ||||
c.' . $id_field . ', | c.' . $id_field . ', | ||||
c.l' . $this->Application->GetVar('m_lang') . '_CachedNavbar AS CachedNavbar | c.l' . $this->Application->GetVar('m_lang') . '_CachedNavbar AS CachedNavbar | ||||
FROM ' . $this->Application->getUnitOption('c', 'TableName') . ' c'; | FROM ' . $this->Application->getUnitOption('c', 'TableName') . ' c'; | ||||
/** @var kCountHelper $count_helper */ | |||||
$count_helper = $this->Application->recallObject('CountHelper'); | $count_helper = $this->Application->recallObject('CountHelper'); | ||||
/* @var $count_helper kCountHelper */ | |||||
list ($sql, $where_clause) = $count_helper->attachViewPermissionCheck('c', $sql, $where_clause); | list ($sql, $where_clause) = $count_helper->attachViewPermissionCheck('c', $sql, $where_clause); | ||||
return $sql . ' WHERE (' . implode(') AND (', $where_clause) . ') ORDER BY c.' . $title_field . ' ASC'; | return $sql . ' WHERE (' . implode(') AND (', $where_clause) . ') ORDER BY c.' . $title_field . ' ASC'; | ||||
} | } | ||||
function PrintMoreCategories($params) | function PrintMoreCategories($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$category_ids = $this->Field($params); | $category_ids = $this->Field($params); | ||||
if (!$category_ids) { | if (!$category_ids) { | ||||
return ''; | return ''; | ||||
} | } | ||||
$category_ids = explode('|', substr($category_ids, 1, -1)); | $category_ids = explode('|', substr($category_ids, 1, -1)); | ||||
Show All 38 Lines | |||||
/** | /** | ||||
* Registers hit for item (one time per session) | * Registers hit for item (one time per session) | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
*/ | */ | ||||
function RegisterHit($params) | function RegisterHit($params) | ||||
{ | { | ||||
/** @var kCatDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kCatDBItem */ | |||||
if ($object->isLoaded()) { | if ($object->isLoaded()) { | ||||
$object->RegisterHit(); | $object->RegisterHit(); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns link to item's author public profile | * Returns link to item's author public profile | ||||
Show All 28 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 23 Lines | |||||
$sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . ' | $sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . ' | ||||
FROM ' . $this->Application->getUnitOption('lang', 'TableName') . ' | FROM ' . $this->Application->getUnitOption('lang', 'TableName') . ' | ||||
WHERE Enabled = 1'; | WHERE Enabled = 1'; | ||||
$languages = $this->Conn->GetCol($sql); | $languages = $this->Conn->GetCol($sql); | ||||
} | } | ||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
foreach ($languages as $language_id) { | foreach ($languages as $language_id) { | ||||
$check_field = 'l' . $language_id . '_' . $field; | $check_field = 'l' . $language_id . '_' . $field; | ||||
if ($object->GetErrorMsg($check_field, false)) { | if ($object->GetErrorMsg($check_field, false)) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Returns list of categories, that have add/edit permission for current category item type | * Returns list of categories, that have add/edit permission for current category item type | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @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); | ||||
} | } | ||||
} | } |