Index: branches/5.2.x/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r14588 -r14601
--- branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 14588)
+++ branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 14601)
@@ -1,6 +1,6 @@
Name == 'OnResetCMSMenuCache') {
// events from "Tools -> System Tools" section are controlled via that section "edit" permission
@@ -258,8 +260,11 @@
* Apply system filter to categories list
*
* @param kEvent $event
+ * @return void
+ * @access protected
+ * @see kDBEventHandler::OnListBuild()
*/
- function SetCustomQuery(&$event)
+ protected function SetCustomQuery(&$event)
{
parent::SetCustomQuery($event);
@@ -395,6 +400,8 @@
}
$p_item =& $this->Application->recallObject($related_prefix . '.current', null, Array('skip_autoload' => true));
+ /* @var $p_item kCatDBItem */
+
$p_item->Load( (int)$id );
$p_resource_id = $p_item->GetDBField('ResourceId');
@@ -615,9 +622,9 @@
if ($page_id === false && EDITING_MODE) {
// create missing pages, when in editing mode
$object =& $this->Application->recallObject($this->Prefix . '.rebuild', null, Array('skip_autoload' => true));
- /* @var $object kDBItem */
+ /* @var $object CategoriesItem */
- $created = $this->_prepareAutoPage($object, $template, null, SMS_MODE_AUTO, false); // create virtual (not system!) page
+ $created = $this->_prepareAutoPage($object, $template, null, SMS_MODE_AUTO); // create virtual (not system!) page
if ($created) {
if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->isAdmin) {
$updater =& $this->Application->makeClass('kPermCacheUpdater');
@@ -657,8 +664,10 @@
*
* @param kCatDBItem $object
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function prepareObject(&$object, &$event)
+ protected function prepareObject(&$object, &$event)
{
if ($event->Special != '-virtual') {
$object =& $event->getObject( Array('skip_autoload' => true) );
@@ -681,22 +690,25 @@
*/
function OnAfterCopyToLive(&$event)
{
+ $object =& $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true, 'live_table' => true));
+ /* @var $object CategoriesItem */
+
$parent_path = false;
- $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true));
- $object->Load($event->getEventParam('id'));
- if ($event->getEventParam('temp_id') == 0) {
- if ($object->isLoaded()) {
+ $object->Load( $event->getEventParam('id') );
+
+ if ( $event->getEventParam('temp_id') == 0 ) {
+ if ( $object->isLoaded() ) {
// update path only for real categories (not including "Home" root category)
- $fields_hash = Array('ParentPath' => $object->buildParentPath());
- $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID());
+ $fields_hash = Array ('ParentPath' => $object->buildParentPath());
+ $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = ' . $object->GetID());
$parent_path = $fields_hash['ParentPath'];
}
}
else {
$parent_path = $object->GetDBField('ParentPath');
}
- if ($parent_path) {
+ if ( $parent_path ) {
$cache_updater =& $this->Application->makeClass('kPermCacheUpdater', Array (null, $parent_path));
/* @var $cache_updater kPermCacheUpdater */
@@ -708,36 +720,39 @@
* Set cache modification mark if needed
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnBeforeDeleteFromLive(&$event)
+ protected function OnBeforeDeleteFromLive(&$event)
{
+ parent::OnBeforeDeleteFromLive($event);
+
$id = $event->getEventParam('id');
- // loding anyway, because this object is needed by "c-perm:OnBeforeDeleteFromLive" event
- $temp_object =& $event->getObject( Array('skip_autoload' => true) );
- /* @var $temp_object kDBItem */
-
+ // loading anyway, because this object is needed by "c-perm:OnBeforeDeleteFromLive" event
+ $temp_object =& $event->getObject(Array ('skip_autoload' => true));
+ /* @var $temp_object CategoriesItem */
+
$temp_object->Load($id);
- if ($id == 0) {
- if ($temp_object->isLoaded()) {
+ if ( $id == 0 ) {
+ if ( $temp_object->isLoaded() ) {
// new category -> update cache (not loaded when "Home" category)
$this->Application->StoreVar('PermCache_UpdateRequired', 1);
}
+
return ;
}
// existing category was edited, check if in-cache fields are modified
- $live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true, 'skip_autoload' => true));
+ $live_object =& $this->Application->recallObject($event->Prefix . '.-item', null, Array ('live_table' => true, 'skip_autoload' => true));
+ /* @var $live_object CategoriesItem */
+
$live_object->Load($id);
+ $cached_fields = Array ('l' . $this->Application->GetDefaultLanguageId() . '_Name', 'Filename', 'Template', 'ParentId', 'Priority');
- $cached_fields = Array(
- 'l' . $this->Application->GetDefaultLanguageId() . '_Name',
- 'Filename', 'Template', 'ParentId', 'Priority'
- );
-
foreach ($cached_fields as $cached_field) {
- if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
+ if ( $live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field) ) {
// use session instead of REQUEST because of permission editing in category can contain
// multiple submits, that changes data before OnSave event occurs
$this->Application->StoreVar('PermCache_UpdateRequired', 1);
@@ -761,20 +776,24 @@
* Reset root-category flag when new category is created
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnPreCreate(&$event)
+ protected function OnPreCreate(&$event)
{
// 1. for permission editing of Home category
$this->Application->RemoveVar('IsRootCategory_' . $this->Application->GetVar('m_wid'));
parent::OnPreCreate($event);
$object =& $event->getObject();
+ /* @var $object kDBItem */
// 2. preset template
$category_id = $this->Application->GetVar('m_cat_id');
$root_category = $this->Application->getBaseCategory();
- if ($category_id == $root_category) {
+
+ if ( $category_id == $root_category ) {
$object->SetDBField('Template', $this->_getDefaultDesign());
}
@@ -792,32 +811,27 @@
* Checks cache update mark and redirect to cache if needed
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnSave(&$event)
+ protected function OnSave(&$event)
{
+ // get data from live table before it is overwritten by parent OnSave method call
$ids = $this->getSelectedIDs($event, true);
$is_editing = implode('', $ids);
+ $old_statuses = $is_editing ? $this->_getCategoryStatus($ids) : Array ();
- if ($is_editing) {
- $old_statuses = $this->_getCategoryStatus($ids);
- }
-
$object =& $event->getObject();
/* @var $object CategoriesItem */
- /*if ($object->IsRoot()) {
- $event->setEventParam('master_ids', Array(0));
- $this->RemoveRequiredFields($object);
- }*/
-
parent::OnSave($event);
- if ($event->status != kEvent::erSUCCESS) {
- return ;
+ if ( $event->status != kEvent::erSUCCESS ) {
+ return;
}
// 1. update priorities
- $tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid'));
+ $tmp = $this->Application->RecallVar('priority_changes' . $this->Application->GetVar('m_wid'));
$changes = $tmp ? unserialize($tmp) : Array ();
$changed_ids = array_keys($changes);
@@ -826,21 +840,21 @@
$priority_helper->updatePriorities($event, $changes, Array (0 => $event->getEventParam('ids')));
- if ($this->Application->RecallVar('PermCache_UpdateRequired')) {
+ if ( $this->Application->RecallVar('PermCache_UpdateRequired') ) {
$this->Application->RemoveVar('IsRootCategory_' . $this->Application->GetVar('m_wid'));
}
$this->Application->StoreVar('RefreshStructureTree', 1);
$this->_resetMenuCache();
- if ($is_editing) {
+ if ( $is_editing ) {
// 2. send email event to category owner, when it's status is changed (from admin)
$object->SwitchToLive();
$new_statuses = $this->_getCategoryStatus($ids);
$process_statuses = Array (STATUS_ACTIVE, STATUS_DISABLED);
foreach ($new_statuses as $category_id => $new_status) {
- if ($new_status != $old_statuses[$category_id] && in_array($new_status, $process_statuses)) {
+ if ( $new_status != $old_statuses[$category_id] && in_array($new_status, $process_statuses) ) {
$object->Load($category_id);
$email_event = $new_status == STATUS_ACTIVE ? 'CATEGORY.APPROVE' : 'CATEGORY.DENY';
$this->Application->EmailEventUser($email_event, $object->GetDBField('CreatedById'));
@@ -868,18 +882,20 @@
/**
* Creates a new item in temp table and
- * stores item id in App vars and Session on succsess
+ * stores item id in App vars and Session on success
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnPreSaveCreated(&$event)
+ protected function OnPreSaveCreated(&$event)
{
- $object =& $event->getObject( Array('skip_autoload' => true) );
+ $object =& $event->getObject( Array ('skip_autoload' => true) );
/* @var $object CategoriesItem */
- if ($object->IsRoot()) {
+ if ( $object->IsRoot() ) {
// don't create root category while saving permissions
- return ;
+ return;
}
$priority_helper =& $this->Application->recallObject('PriorityHelper');
@@ -910,13 +926,15 @@
$this->Conn->Query($sql);
}
-
/**
- * Exclude root categories from deleting
- *
- * @param kEvent $event
- */
- function customProcessing(&$event, $type)
+ * Exclude root categories from deleting
+ *
+ * @param kEvent $event
+ * @param string $type
+ * @return void
+ * @access protected
+ */
+ protected function customProcessing(&$event, $type)
{
if ($event->Name == 'OnMassDelete' && $type == 'before') {
$ids = $event->getEventParam('ids');
@@ -1001,28 +1019,31 @@
* by calling its Delete method if sub-item has AutoDelete set to true in its config file
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnMassDelete(&$event)
+ protected function OnMassDelete(&$event)
{
- if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) {
$event->status = kEvent::erFAIL;
- return;
+ return ;
}
+ $to_delete = Array ();
$ids = $this->StoreSelectedIDs($event);
- $to_delete = array();
- if ($recycle_bin = $this->Application->ConfigValue('RecycleBinFolder')) {
+
+ if ( $recycle_bin = $this->Application->ConfigValue('RecycleBinFolder') ) {
$rb =& $this->Application->recallObject('c.recycle', null, Array ('skip_autoload' => true));
/* @var $rb CategoriesItem */
$rb->Load($recycle_bin);
-
- $cat =& $event->getObject(Array('skip_autoload' => true));
+
+ $cat =& $event->getObject(Array ('skip_autoload' => true));
/* @var $cat CategoriesItem */
foreach ($ids as $id) {
$cat->Load($id);
- if (preg_match('/^'.preg_quote($rb->GetDBField('ParentPath'),'/').'/', $cat->GetDBField('ParentPath'))) {
+ if ( preg_match('/^' . preg_quote($rb->GetDBField('ParentPath'), '/') . '/', $cat->GetDBField('ParentPath')) ) {
$to_delete[] = $id;
continue;
}
@@ -1037,7 +1058,7 @@
$this->customProcessing($event, 'before');
$ids = $event->getEventParam('ids');
- if ($ids) {
+ if ( $ids ) {
$recursive_helper =& $this->Application->recallObject('RecursiveHelper');
/* @var $recursive_helper kRecursiveHelper */
@@ -1067,7 +1088,10 @@
function OnCopy(&$event)
{
$this->Application->RemoveVar('clipboard');
+
$clipboard_helper =& $this->Application->recallObject('ClipboardHelper');
+ /* @var $clipboard_helper kClipboardHelper */
+
$clipboard_helper->setClipboard($event, 'copy', $this->StoreSelectedIDs($event));
$this->clearSelectedIDs($event);
}
@@ -1080,7 +1104,10 @@
function OnCut(&$event)
{
$this->Application->RemoveVar('clipboard');
+
$clipboard_helper =& $this->Application->recallObject('ClipboardHelper');
+ /* @var $clipboard_helper kClipboardHelper */
+
$clipboard_helper->setClipboard($event, 'cut', $this->StoreSelectedIDs($event));
$this->clearSelectedIDs($event);
}
@@ -1122,28 +1149,31 @@
}
/**
- * Paste categories with subitems from clipboard
+ * Paste categories with sub-items from clipboard
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnPaste(&$event)
+ protected function OnPaste(&$event)
{
- if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) || !$this->_checkPastePermission($event)) {
+ if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) || !$this->_checkPastePermission($event) ) {
$event->status = kEvent::erFAIL;
- return ;
+ return;
}
$clipboard_data = $event->getEventParam('clipboard_data');
- if (!$clipboard_data['cut'] && !$clipboard_data['copy']) {
- return false;
+ if ( !$clipboard_data['cut'] && !$clipboard_data['copy'] ) {
+ return;
}
// 1. get ParentId of moved category(-es) before it gets updated!!!)
+ $source_category_id = 0;
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
- if ($clipboard_data['cut']) {
+ if ( $clipboard_data['cut'] ) {
$sql = 'SELECT ParentId
FROM ' . $table_name . '
WHERE ' . $id_field . ' = ' . $clipboard_data['cut'][0];
@@ -1153,20 +1183,20 @@
$recursive_helper =& $this->Application->recallObject('RecursiveHelper');
/* @var $recursive_helper kRecursiveHelper */
- if ($clipboard_data['cut']) {
+ if ( $clipboard_data['cut'] ) {
$recursive_helper->MoveCategories($clipboard_data['cut'], $this->Application->GetVar('m_cat_id'));
}
- if ($clipboard_data['copy']) {
+ if ( $clipboard_data['copy'] ) {
// don't allow to copy/paste system OR theme-linked virtual pages
$sql = 'SELECT ' . $id_field . '
FROM ' . $table_name . '
WHERE ' . $id_field . ' IN (' . implode(',', $clipboard_data['copy']) . ') AND (`Type` = ' . PAGE_TYPE_VIRTUAL . ') AND (ThemeId = 0)';
$allowed_ids = $this->Conn->GetCol($sql);
- if (!$allowed_ids) {
- return ;
+ if ( !$allowed_ids ) {
+ return;
}
foreach ($allowed_ids as $id) {
@@ -1177,17 +1207,17 @@
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
- if ($clipboard_data['cut']) {
- $priority_helper->recalculatePriorities($event, 'ParentId = '.$source_category_id);
+ if ( $clipboard_data['cut'] ) {
+ $priority_helper->recalculatePriorities($event, 'ParentId = ' . $source_category_id);
}
// recalculate priorities of newly pasted categories in destination category
$parent_id = $this->Application->GetVar('m_cat_id');
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $parent_id);
- if ($clipboard_data['cut'] || $clipboard_data['copy']) {
+ if ( $clipboard_data['cut'] || $clipboard_data['copy'] ) {
// rebuild with progress bar
- if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) {
+ if ( $this->Application->ConfigValue('QuickCategoryPermissionRebuild') ) {
$updater =& $this->Application->makeClass('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
@@ -1254,12 +1284,16 @@
* Sets correct status for new categories created on front-end
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnBeforeItemCreate(&$event)
+ protected function OnBeforeItemCreate(&$event)
{
+ parent::OnBeforeItemCreate($event);
+
$this->_beforeItemChange($event);
- if ($this->Application->isAdminUser || $event->Prefix == 'st') {
+ if ( $this->Application->isAdminUser || $event->Prefix == 'st' ) {
// don't check category permissions when auto-creating structure pages
return ;
}
@@ -1269,14 +1303,17 @@
$new_status = false;
$category_id = $this->Application->GetVar('m_cat_id');
- if ($perm_helper->CheckPermission('CATEGORY.ADD', 0, $category_id)) {
+
+ if ( $perm_helper->CheckPermission('CATEGORY.ADD', 0, $category_id) ) {
$new_status = STATUS_ACTIVE;
}
- else if ($perm_helper->CheckPermission('CATEGORY.ADD.PENDING', 0, $category_id)) {
- $new_status = STATUS_PENDING;
+ else {
+ if ( $perm_helper->CheckPermission('CATEGORY.ADD.PENDING', 0, $category_id) ) {
+ $new_status = STATUS_PENDING;
+ }
}
- if ($new_status) {
+ if ( $new_status ) {
$object =& $event->getObject();
/* @var $object kDBItem */
@@ -1285,10 +1322,6 @@
// don't forget to set Priority for suggested from Front-End categories
$min_priority = $this->_getNextPriority($object->GetDBField('ParentId'), $object->TableName);
$object->SetDBField('Priority', $min_priority);
-
- /*if (!$this->Application->isAdminUser) {
- $object->SetDBField('IsMenu', 0); // add all suggested categories as non-menu
- }*/
}
else {
$event->status = kEvent::erPERM_FAIL;
@@ -1315,15 +1348,17 @@
* Sets correct status for new categories created on front-end
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnBeforeItemUpdate(&$event)
+ protected function OnBeforeItemUpdate(&$event)
{
parent::OnBeforeItemUpdate($event);
$object =& $event->getObject();
/* @var $object kDBItem */
- if ($object->GetChangedFields()) {
+ if ( $object->GetChangedFields() ) {
$object->SetDBField('ModifiedById', $this->Application->RecallVar('user_id'));
}
@@ -1393,53 +1428,58 @@
{
parent::SetPagination($event);
- if (!$this->Application->isAdmin) {
+ if ( !$this->Application->isAdmin ) {
$page_var = $event->getEventParam('page_var');
- if ($page_var !== false) {
+
+ if ( $page_var !== false ) {
$page = $this->Application->GetVar($page_var);
- if (is_numeric($page)) {
+
+ if ( is_numeric($page) ) {
$object =& $event->getObject();
+ /* @var $object kDBList */
+
$object->SetPage($page);
}
}
}
}
/**
- * Apply same processing to each item beeing selected in grid
+ * Apply same processing to each item being selected in grid
*
* @param kEvent $event
- * @access private
+ * @return void
+ * @access protected
*/
- function iterateItems(&$event)
+ protected function iterateItems(&$event)
{
- if ($event->Name != 'OnMassApprove' && $event->Name != 'OnMassDecline') {
- return parent::iterateItems($event);
+ if ( $event->Name != 'OnMassApprove' && $event->Name != 'OnMassDecline' ) {
+ parent::iterateItems($event);
}
- if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) {
$event->status = kEvent::erFAIL;
return;
}
- $object =& $event->getObject( Array('skip_autoload' => true) );
+ $object =& $event->getObject(Array ('skip_autoload' => true));
/* @var $object CategoriesItem */
$ids = $this->StoreSelectedIDs($event);
- if ($ids) {
+ if ( $ids ) {
$propagate_category_status = $this->Application->GetVar('propagate_category_status');
- $status_field = array_shift( $this->Application->getUnitOption($event->Prefix,'StatusField') );
+ $status_field = array_shift( $this->Application->getUnitOption($event->Prefix, 'StatusField') );
foreach ($ids as $id) {
$object->Load($id);
$object->SetDBField($status_field, $event->Name == 'OnMassApprove' ? 1 : 0);
- if ($object->Update()) {
- if ($propagate_category_status) {
- $sql = 'UPDATE '.$object->TableName.'
- SET '.$status_field.' = '.$object->GetDBField($status_field).'
- WHERE TreeLeft BETWEEN '.$object->GetDBField('TreeLeft').' AND '.$object->GetDBField('TreeRight');
+ if ( $object->Update() ) {
+ if ( $propagate_category_status ) {
+ $sql = 'UPDATE ' . $object->TableName . '
+ SET ' . $status_field . ' = ' . $object->GetDBField($status_field) . '
+ WHERE TreeLeft BETWEEN ' . $object->GetDBField('TreeLeft') . ' AND ' . $object->GetDBField('TreeRight');
$this->Conn->Query($sql);
}
@@ -1514,19 +1554,24 @@
/**
* Returns default design based on given virtual template (used from kApplication::Run)
*
+ * @param string $t
* @return string
+ * @access public
*/
- function GetDesignTemplate($t = null)
+ public function GetDesignTemplate($t = null)
{
- if (!isset($t)) {
+ if ( !isset($t) ) {
$t = $this->Application->GetVar('t');
}
$page =& $this->Application->recallObject($this->Prefix . '.-virtual', null, Array ('page' => $t));
- if ($page->isLoaded()) {
+ /* @var $page CategoriesItem */
+
+ if ( $page->isLoaded() ) {
$real_t = $page->GetDBField('CachedTemplate');
- $this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId') );
- if ($page->GetDBField('FormId')) {
+ $this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId'));
+
+ if ( $page->GetDBField('FormId') ) {
$this->Application->SetVar('form_id', $page->GetDBField('FormId'));
}
}
@@ -1550,7 +1595,7 @@
$template = $theme->GetField('TemplateAliases', $real_t);
- if ($template) {
+ if ( $template ) {
return $template;
}
@@ -1684,10 +1729,14 @@
}
/**
- * Enter description here...
+ * Creates category based on given TPL file
*
- * @param StructureItem $object
+ * @param CategoriesItem $object
* @param string $template
+ * @param int $theme_id
+ * @param int $system_mode
+ * @param array $template_info
+ * @return bool
*/
function _prepareAutoPage(&$object, $template, $theme_id = null, $system_mode = SMS_MODE_AUTO, $template_info = Array ())
{
@@ -1980,12 +2029,14 @@
* Removes this item and it's children (recursive) from structure dropdown
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function OnAfterItemLoad(&$event)
+ protected function OnAfterItemLoad(&$event)
{
parent::OnAfterItemLoad($event);
- if (!$this->Application->isAdmin) {
+ if ( !$this->Application->isAdmin ) {
// calculate priorities dropdown only for admin
return ;
}
@@ -1994,9 +2045,9 @@
/* @var $object kDBItem */
// remove this category & it's children from dropdown
- $sql = 'SELECT '.$object->IDField.'
- FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
- WHERE ParentPath LIKE "'.$object->GetDBField('ParentPath').'%"';
+ $sql = 'SELECT ' . $object->IDField . '
+ FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ WHERE ParentPath LIKE "' . $object->GetDBField('ParentPath') . '%"';
$remove_categories = $this->Conn->GetCol($sql);
$field_options = $object->GetFieldOptions('ParentId');
@@ -2008,9 +2059,9 @@
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
- $priority_helper->preparePriorities($event, false, 'ParentId = '.$object->GetDBField('ParentId'));
+ $priority_helper->preparePriorities($event, false, 'ParentId = ' . $object->GetDBField('ParentId'));
- // storing prioriry right after load for comparing when updating
+ // storing priority right after load for comparing when updating
$object->SetDBField('OldPriority', $object->GetDBField('Priority'));
}
@@ -2186,14 +2237,15 @@
$keywords = kUtil::unhtmlentities( trim($this->Application->GetVar('keywords')) );
$query_object =& $this->Application->recallObject('HTTPQuery');
+ /* @var $query_object kHTTPQuery */
+
$sql = 'SHOW TABLES LIKE "'.$search_table.'"';
- if(!isset($query_object->Get['keywords']) &&
- !isset($query_object->Post['keywords']) &&
- $this->Conn->Query($sql))
- {
- return; // used when navigating by pages or changing sorting in search results
+ if ( !isset($query_object->Get['keywords']) && !isset($query_object->Post['keywords']) && $this->Conn->Query($sql) ) {
+ // used when navigating by pages or changing sorting in search results
+ return;
}
+
if(!$keywords || strlen($keywords) < $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
@@ -2241,12 +2293,11 @@
$search_config_map = Array();
foreach ($field_list as $key => $field) {
- $options = $object->getFieldOptions($field);
$local_table = TABLE_PREFIX.$search_config[$field]['TableName'];
$weight_sum += $search_config[$field]['Priority']; // counting weight sum; used when making relevance clause
// processing multilingual fields
- if (getArrayValue($options, 'formatter') == 'kMultiLanguage') {
+ if ( $object->GetFieldOption($field, 'formatter') == 'kMultiLanguage' ) {
$field_list[$key.'_primary'] = 'l'.$this->Application->GetDefaultLanguageId().'_'.$field;
$field_list[$key] = 'l'.$lang.'_'.$field;
@@ -2349,6 +2400,11 @@
}
}
+ // exclude template based sections from search results (ie. registration)
+ if ( $this->Application->ConfigValue('ExcludeTemplateSectionsFromSearch') ) {
+ $where_clause .= ' AND ' . $items_table . '.ThemeId = 0';
+ }
+
// making relevance clause
$positive_words = $search_helper->getPositiveKeywords($keywords);
$this->Application->StoreVar('highlight_keywords', serialize($positive_words));
@@ -2465,27 +2521,31 @@
* Load item if id is available
*
* @param kEvent $event
+ * @return void
+ * @access protected
*/
- function LoadItem(&$event)
+ protected function LoadItem(&$event)
{
- if ($event->Special != '-virtual') {
+ if ( $event->Special != '-virtual' ) {
parent::LoadItem($event);
- return ;
+ return;
}
$object =& $event->getObject();
/* @var $object kDBItem */
$id = $this->getPassedID($event);
- if ($object->isLoaded() && !is_array($id) && ($object->GetID() == $id)) {
+ if ( $object->isLoaded() && !is_array($id) && ($object->GetID() == $id) ) {
// object is already loaded by same id
- return ;
+ return;
}
- if ($object->Load($id, null, true)) {
+ if ( $object->Load($id, null, true) ) {
$actions =& $this->Application->recallObject('kActions');
- $actions->Set($event->getPrefixSpecial().'_id', $object->GetID() );
+ /* @var $actions Params */
+
+ $actions->Set($event->getPrefixSpecial() . '_id', $object->GetID());
}
else {
$object->setID($id);
Index: branches/5.2.x/core/install/install_data.sql
===================================================================
diff -u -r14598 -r14601
--- branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 14598)
+++ branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 14601)
@@ -15,6 +15,7 @@
INSERT INTO ConfigurationValues VALUES(DEFAULT, 'FilenameSpecialCharReplacement', '-', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_FilenameSpecialCharReplacement', 'select', NULL, '_=+_||-=+-', 10.12, 0, 0, NULL);
INSERT INTO ConfigurationValues VALUES(DEFAULT, 'YahooApplicationId', '', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_YahooApplicationId', 'text', NULL, NULL, 10.13, 0, 0, NULL);
INSERT INTO ConfigurationValues VALUES(DEFAULT, 'Search_MinKeyword_Length', '3', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_Search_MinKeyword_Length', 'text', NULL, NULL, 10.14, 0, 0, NULL);
+INSERT INTO ConfigurationValues VALUES(DEFAULT, 'ExcludeTemplateSectionsFromSearch', '0', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_ExcludeTemplateSectionsFromSearch', 'checkbox', '', '', 10.15, 0, 0, NULL);
INSERT INTO ConfigurationValues VALUES(DEFAULT, 'Category_MetaKey', '', 'In-Portal', 'in-portal:configure_categories', 'la_Text_MetaInfo', 'la_category_metakey', 'textarea', '', '', 20.01, 0, 1, NULL);
INSERT INTO ConfigurationValues VALUES(DEFAULT, 'Category_MetaDesc', '', 'In-Portal', 'in-portal:configure_categories', 'la_Text_MetaInfo', 'la_category_metadesc', 'textarea', '', '', 20.02, 0, 1, NULL);
Index: branches/5.2.x/core/install/upgrades.sql
===================================================================
diff -u -r14585 -r14601
--- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14585)
+++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14601)
@@ -2105,4 +2105,6 @@
UPDATE Category
SET DirectLinkAuthKey = SUBSTRING( MD5( CONCAT(CategoryId, ':', ParentId, ':', l<%PRIMARY_LANGUAGE%>_Name, ':b38') ), 1, 20)
-WHERE DirectLinkAuthKey = '';
\ No newline at end of file
+WHERE DirectLinkAuthKey = '';
+
+INSERT INTO ConfigurationValues VALUES(DEFAULT, 'ExcludeTemplateSectionsFromSearch', '0', 'In-Portal', 'in-portal:configure_categories', 'la_title_General', 'la_config_ExcludeTemplateSectionsFromSearch', 'checkbox', '', '', 10.15, 0, 0, NULL);
\ No newline at end of file
Index: branches/5.2.x/core/install/english.lang
===================================================================
diff -u -r14588 -r14601
--- branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14588)
+++ branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14601)
@@ -149,6 +149,7 @@
RGVmYXVsdCBSZWdpc3RyYXRpb24gQ291bnRyeQ==
RGVmYXVsdCBBbmFseXRpY3MgVHJhY2tpbmcgQ29kZQ==
VGVtcGxhdGUgZm9yICJGaWxlIG5vdCBmb3VuZCAoNDA0KSIgRXJyb3I=
+ RXhjbHVkZSB0ZW1wbGF0ZSBiYXNlZCBTZWN0aW9ucyBmcm9tIFNlYXJjaCBSZXN1bHRzIChpZS4gVXNlciBSZWdpc3RyYXRpb24p
RmlsZW5hbWUgU3BlY2lhbCBDaGFyIFJlcGxhY2VtZW50
Rmlyc3QgRGF5IE9mIFdlZWs=
QWx3YXlzIHVzZSBJbWFnZU1hZ2ljayB0byByZXNpemUgaW1hZ2Vz