Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/reviews/reviews_tag_processor.php
Show All 18 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 */ | |||||
$item_prefix = $this->Application->findModule('Name', $object->GetDBField('Module'), 'Var'); | $item_prefix = $this->Application->findModule('Name', $object->GetDBField('Module'), 'Var'); | ||||
$edit_template = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($item_prefix, 'AdminTemplatePrefix') . 'edit'; | $edit_template = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($item_prefix, 'AdminTemplatePrefix') . 'edit'; | ||||
$url_params = Array ( | $url_params = Array ( | ||||
'm_opener' => 'd', | 'm_opener' => 'd', | ||||
$item_prefix.'_mode' => 't', | $item_prefix.'_mode' => 't', | ||||
$item_prefix.'_event' => 'OnEdit', | $item_prefix.'_event' => 'OnEdit', | ||||
$item_prefix.'_id' => $object->GetDBField('CatalogItemId'), | $item_prefix.'_id' => $object->GetDBField('CatalogItemId'), | ||||
'm_cat_id' => $object->GetDBField('CatalogItemCategory'), | 'm_cat_id' => $object->GetDBField('CatalogItemCategory'), | ||||
'pass' => 'all,'.$item_prefix, | 'pass' => 'all,'.$item_prefix, | ||||
'no_pass_through' => 1, | 'no_pass_through' => 1, | ||||
); | ); | ||||
return $this->Application->HREF($edit_template,'', $url_params); | return $this->Application->HREF($edit_template,'', $url_params); | ||||
} | } | ||||
function HelpfulLink($params) | function HelpfulLink($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); | $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); | ||||
$params['events[' . $parent_prefix . ']'] = 'OnReviewHelpful'; | $params['events[' . $parent_prefix . ']'] = 'OnReviewHelpful'; | ||||
$params['review_id'] = $object->GetID(); | $params['review_id'] = $object->GetID(); | ||||
return $this->Application->ProcessParsedTag($parent_prefix, 'ItemLink', $params); | return $this->Application->ProcessParsedTag($parent_prefix, 'ItemLink', $params); | ||||
} | } | ||||
/** | /** | ||||
* Prints overall rating statistics | * Prints overall rating statistics | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
protected function PrintRatingPercents($params) | protected function PrintRatingPercents($params) | ||||
{ | { | ||||
static $cache = null; | static $cache = null; | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); | $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); | ||||
/** @var kCatDBItem $main_object */ | |||||
$main_object = $this->Application->recallObject($parent_prefix); | $main_object = $this->Application->recallObject($parent_prefix); | ||||
/* @var $main_object kCatDBItem */ | |||||
if ( !isset($cache) ) { | if ( !isset($cache) ) { | ||||
$sql = 'SELECT COUNT(*), Rating | $sql = 'SELECT COUNT(*), Rating | ||||
FROM ' . $object->TableName . ' | FROM ' . $object->TableName . ' | ||||
WHERE ItemId = ' . $main_object->GetDBField('ResourceId') . ' | WHERE ItemId = ' . $main_object->GetDBField('ResourceId') . ' | ||||
GROUP BY Rating'; | GROUP BY Rating'; | ||||
$cache = $this->Conn->GetCol($sql, 'Rating'); | $cache = $this->Conn->GetCol($sql, 'Rating'); | ||||
} | } | ||||
Show All 31 Lines | |||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
function Field($params) | function Field($params) | ||||
{ | { | ||||
$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 */ | |||||
if ($field == 'ReviewText') { | if ($field == 'ReviewText') { | ||||
if ($object->GetDBField('TextFormat') == 1) { | if ($object->GetDBField('TextFormat') == 1) { | ||||
$params['no_special'] = 'no_special'; | $params['no_special'] = 'no_special'; | ||||
} | } | ||||
else { | else { | ||||
unset($params['no_special']); | unset($params['no_special']); | ||||
} | } | ||||
} | } | ||||
return parent::Field($params); | return parent::Field($params); | ||||
} | } | ||||
function AlreadyReviewed($params) | function AlreadyReviewed($params) | ||||
{ | { | ||||
$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); | $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); | ||||
/** @var kCatDBItem $main_object */ | |||||
$main_object = $this->Application->recallObject($parent_prefix); | $main_object = $this->Application->recallObject($parent_prefix); | ||||
/* @var $main_object kCatDBItem */ | |||||
/** @var SpamHelper $spam_helper */ | |||||
$spam_helper = $this->Application->recallObject('SpamHelper'); | $spam_helper = $this->Application->recallObject('SpamHelper'); | ||||
/* @var $spam_helper SpamHelper */ | |||||
$spam_helper->InitHelper($main_object->GetDBField('ResourceId'), 'Review', 0, $main_object->GetCol('ResourceId')); | $spam_helper->InitHelper($main_object->GetDBField('ResourceId'), 'Review', 0, $main_object->GetCol('ResourceId')); | ||||
return $spam_helper->InSpamControl(); | return $spam_helper->InSpamControl(); | ||||
} | } | ||||
function HasError($params) | function HasError($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return method_exists($object, 'GetErrorMsg') ? parent::HasError($params) : 0; | return method_exists($object, 'GetErrorMsg') ? parent::HasError($params) : 0; | ||||
} | } | ||||
/** | /** | ||||
* Preserve main item id in subitem pagination url | * Preserve main item id in subitem pagination url | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function PageLink($params) | function PageLink($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var kDBList */ | |||||
$parent_info = $object->getLinkedInfo(); | $parent_info = $object->getLinkedInfo(); | ||||
if ($parent_info['ParentId'] > 0) { | if ($parent_info['ParentId'] > 0) { | ||||
$params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix']; | $params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix']; | ||||
} | } | ||||
return parent::PageLink($params); | return parent::PageLink($params); | ||||
▲ Show 20 Lines • Show All 42 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 */ | |||||
$rating = isset($params['rating']) ? $params['rating'] : $object->GetDBField('Rating'); | $rating = isset($params['rating']) ? $params['rating'] : $object->GetDBField('Rating'); | ||||
$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->ratingBarSimple($rating, '', null, $small_style); | return $rating_helper->ratingBarSimple($rating, '', null, $small_style); | ||||
} | } | ||||
} | } | ||||
No newline at end of file |