Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Tue, Sep 23, 9:10 AM

in-portal

Index: branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php (revision 5537)
@@ -0,0 +1,154 @@
+<?php
+
+ class kCatDBTagProcessor extends kDBTagProcessor {
+
+ 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
+ if ($value == STATUS_ACTIVE) {
+ if( $object->GetDBField('IsPop') ) $value = 'POP';
+ if( $object->GetDBField('IsHot') ) $value = 'HOT';
+ if( $object->GetDBField('IsNew') ) $value = 'NEW';
+ if( $object->GetDBField('EditorsPick') ) $value = 'PICK';
+ }
+
+ return isset($icons[$value]) ? $icons[$value] : $icons['default'];
+ }
+
+ /**
+ * Returns path where exported category items should be saved
+ *
+ * @param Array $params
+ */
+ function ExportPath($params)
+ {
+ $ret = EXPORT_PATH.'/';
+
+ if( getArrayValue($params, 'as_url') )
+ {
+ $ret = str_replace( FULL_PATH.'/', $this->Application->BaseURL(), $ret);
+ }
+
+ $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options'));
+ $ret .= $export_options['ExportFilename'].'.'.($export_options['ExportFormat'] == 1 ? 'csv' : 'xml');
+
+ return $ret;
+ }
+
+ function CategoryPath($params)
+ {
+ if (!isset($params['cat_id'])) {
+ $params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0);
+ }
+
+ $block_params['separator'] = $params['separator'];
+
+ if ($params['cat_id'] == 0) {
+ $block_params['name'] = $params['rootcatblock'];
+ return $this->Application->ParseBlock($block_params);
+ }
+ else {
+ $cat_object =& $this->Application->recallObject('c', 'c_List');
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name
+ FROM '.$cat_object->TableName.'
+ WHERE CategoryId = '.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ if ($res === false) {
+ // in case if category is deleted
+ return '';
+ }
+ $block_params['name'] = $params['block'];
+ $block_params['cat_name'] = $res['Name'];
+ $block_params['cat_id'] = $res['CategoryId'];
+
+ $next_params['separator'] = $params['separator'];
+ $next_params['rootcatblock'] = $params['rootcatblock'];
+ $next_params['block'] = $params['block'];
+ $next_params['cat_id'] = $res['ParentId'];
+ return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_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 ExportStatus($params)
+ {
+ $export_object =& $this->Application->recallObject('CatItemExportHelper');
+
+ $event = new kEvent($this->getPrefixSpecial().':OnDummy');
+
+ $action_method = 'perform'.ucfirst($this->Special);
+ $field_values = $export_object->$action_method($event);
+
+ // finish code is done from JS now
+ if ($field_values['start_from'] == $field_values['total_records'])
+ {
+ if ($this->Special == 'import') {
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ $this->Application->Redirect('categories/cache_updater', Array('pass' => 'm', 'continue' => 1, 'no_amp' => 1));
+ }
+ elseif ($this->Special == 'export') {
+ $template = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder').'/'.$this->Special.'_finish';
+ $this->Application->Redirect($template, Array('pass' => 'all'));
+ }
+ }
+
+ $export_options = $export_object->loadOptions($event);
+ return $export_options['start_from'] * 100 / $export_options['total_records'];
+ }
+
+ function CatalogItemCount($params)
+ {
+ $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params);
+ 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);
+ }
+
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.11
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.11.2/kernel/units/category_items/category_items_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.11.2/kernel/units/category_items/category_items_config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.11.2/kernel/units/category_items/category_items_config.php (revision 5537)
@@ -0,0 +1,76 @@
+<?php
+
+$config = Array(
+ 'Prefix' => 'ci',
+ 'ItemClass' => Array('class'=>'CategoryItems_DBItem','file'=>'category_items_dbitem.php','build_event'=>'OnItemBuild'),
+ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
+ 'EventHandlerClass' => Array('class'=>'CategoryItemsEventHander','file'=>'category_items_event_handler.php','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'CategoryItemsTagProcessor','file'=>'category_items_tag_processor.php','build_event'=>'OnBuild'),
+ 'AutoLoad' => true,
+
+ 'Clones' => Array(
+ 'l-ci' => Array('ParentPrefix' => 'l'),
+ 'n-ci' => Array('ParentPrefix' => 'n'),
+ 'bb-ci' => Array('ParentPrefix' => 'bb'),
+ 'p-ci' => Array('ParentPrefix' => 'p'),
+ 'cms-ci'=> Array('ParentPrefix' => 'cms',),
+ ),
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ ),
+ 'IDField' => 'CategoryId', // in this case idfield doesn't exit in destination table
+ 'StatusField' => Array('CategoryStatus'), // field, that is affected by Approve/Decline events
+
+ 'TableName' => TABLE_PREFIX.'CategoryItems',
+ 'ParentTableKey'=> 'ResourceId',
+ 'ForeignKey' => 'ItemResourceId',
+// 'ParentPrefix' => 'p',
+ 'AutoDelete' => true,
+ 'AutoClone' => false,
+
+ 'CalculatedFields' => Array(
+ '' => Array (
+ 'CategoryName' => 'c.CachedNavbar',
+ 'DummyId' => 'IF(ISNULL(c.CategoryId),0,c.CategoryId)',
+ 'CategoryStatus'=> 'c.Status',
+ )
+ ),
+ 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'Category AS c ON c.CategoryId = %1$s.CategoryId',
+ ), // key - special, value - list select sql
+ 'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
+ ),
+ 'ListSortings' => Array(
+ '' => Array(
+ 'Sorting' => Array('CategoryName' => 'asc'),
+ )
+ ),
+ 'Fields' => Array(
+ 'DummyId' => Array(),
+ 'CategoryId' => Array('type'=>'int','not_null'=>1,'default'=>0),
+ 'ItemResourceId' => Array('not_null' => 1, 'default' => 0),
+ 'PrimaryCat' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'ItemPrefix' => Array('type' => 'string','not_null'=>1,'default'=>''),
+ 'Filename' => Array('type' => 'string','not_null'=>1,'default'=>''),
+ ),
+ 'VirtualFields' => Array(
+ 'CategoryName' => Array(),
+ 'DummyId' => Array(),
+ 'CategoryStatus' => Array(),
+ ),
+
+ 'Grids' => Array(
+ 'Default' => Array(
+ 'Icons' => Array('default' => 'icon16_cat.gif', 0 => 'icon16_cat_disabled.gif', 1 => 'icon16_cat.gif', 2 => 'icon16_cat_pending.gif'), // icons for each StatusField values, if no matches or no statusfield selected, then "default" icon is used
+ 'Fields' => Array(
+ 'CategoryName' => Array( 'title'=>'la_col_Category', 'data_block' => 'grid_checkbox_category_td'),
+ ),
+
+ ),
+ ),
+ );
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.11.2/kernel/units/category_items/category_items_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.11
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php (revision 5537)
@@ -0,0 +1,154 @@
+<?php
+
+ class kCatDBTagProcessor extends kDBTagProcessor {
+
+ 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
+ if ($value == STATUS_ACTIVE) {
+ if( $object->GetDBField('IsPop') ) $value = 'POP';
+ if( $object->GetDBField('IsHot') ) $value = 'HOT';
+ if( $object->GetDBField('IsNew') ) $value = 'NEW';
+ if( $object->GetDBField('EditorsPick') ) $value = 'PICK';
+ }
+
+ return isset($icons[$value]) ? $icons[$value] : $icons['default'];
+ }
+
+ /**
+ * Returns path where exported category items should be saved
+ *
+ * @param Array $params
+ */
+ function ExportPath($params)
+ {
+ $ret = EXPORT_PATH.'/';
+
+ if( getArrayValue($params, 'as_url') )
+ {
+ $ret = str_replace( FULL_PATH.'/', $this->Application->BaseURL(), $ret);
+ }
+
+ $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options'));
+ $ret .= $export_options['ExportFilename'].'.'.($export_options['ExportFormat'] == 1 ? 'csv' : 'xml');
+
+ return $ret;
+ }
+
+ function CategoryPath($params)
+ {
+ if (!isset($params['cat_id'])) {
+ $params['cat_id'] = $this->Application->RecallVar($params['session_var'], 0);
+ }
+
+ $block_params['separator'] = $params['separator'];
+
+ if ($params['cat_id'] == 0) {
+ $block_params['name'] = $params['rootcatblock'];
+ return $this->Application->ParseBlock($block_params);
+ }
+ else {
+ $cat_object =& $this->Application->recallObject('c', 'c_List');
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name
+ FROM '.$cat_object->TableName.'
+ WHERE CategoryId = '.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ if ($res === false) {
+ // in case if category is deleted
+ return '';
+ }
+ $block_params['name'] = $params['block'];
+ $block_params['cat_name'] = $res['Name'];
+ $block_params['cat_id'] = $res['CategoryId'];
+
+ $next_params['separator'] = $params['separator'];
+ $next_params['rootcatblock'] = $params['rootcatblock'];
+ $next_params['block'] = $params['block'];
+ $next_params['cat_id'] = $res['ParentId'];
+ return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_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 ExportStatus($params)
+ {
+ $export_object =& $this->Application->recallObject('CatItemExportHelper');
+
+ $event = new kEvent($this->getPrefixSpecial().':OnDummy');
+
+ $action_method = 'perform'.ucfirst($this->Special);
+ $field_values = $export_object->$action_method($event);
+
+ // finish code is done from JS now
+ if ($field_values['start_from'] == $field_values['total_records'])
+ {
+ if ($this->Special == 'import') {
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ $this->Application->Redirect('categories/cache_updater', Array('pass' => 'm', 'continue' => 1, 'no_amp' => 1));
+ }
+ elseif ($this->Special == 'export') {
+ $template = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder').'/'.$this->Special.'_finish';
+ $this->Application->Redirect($template, Array('pass' => 'all'));
+ }
+ }
+
+ $export_options = $export_object->loadOptions($event);
+ return $export_options['start_from'] * 100 / $export_options['total_records'];
+ }
+
+ function CatalogItemCount($params)
+ {
+ $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params);
+ 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);
+ }
+
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.11
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.11.2/core/units/category_items/category_items_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.11.2/core/units/category_items/category_items_config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.11.2/core/units/category_items/category_items_config.php (revision 5537)
@@ -0,0 +1,76 @@
+<?php
+
+$config = Array(
+ 'Prefix' => 'ci',
+ 'ItemClass' => Array('class'=>'CategoryItems_DBItem','file'=>'category_items_dbitem.php','build_event'=>'OnItemBuild'),
+ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
+ 'EventHandlerClass' => Array('class'=>'CategoryItemsEventHander','file'=>'category_items_event_handler.php','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'CategoryItemsTagProcessor','file'=>'category_items_tag_processor.php','build_event'=>'OnBuild'),
+ 'AutoLoad' => true,
+
+ 'Clones' => Array(
+ 'l-ci' => Array('ParentPrefix' => 'l'),
+ 'n-ci' => Array('ParentPrefix' => 'n'),
+ 'bb-ci' => Array('ParentPrefix' => 'bb'),
+ 'p-ci' => Array('ParentPrefix' => 'p'),
+ 'cms-ci'=> Array('ParentPrefix' => 'cms',),
+ ),
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ ),
+ 'IDField' => 'CategoryId', // in this case idfield doesn't exit in destination table
+ 'StatusField' => Array('CategoryStatus'), // field, that is affected by Approve/Decline events
+
+ 'TableName' => TABLE_PREFIX.'CategoryItems',
+ 'ParentTableKey'=> 'ResourceId',
+ 'ForeignKey' => 'ItemResourceId',
+// 'ParentPrefix' => 'p',
+ 'AutoDelete' => true,
+ 'AutoClone' => false,
+
+ 'CalculatedFields' => Array(
+ '' => Array (
+ 'CategoryName' => 'c.CachedNavbar',
+ 'DummyId' => 'IF(ISNULL(c.CategoryId),0,c.CategoryId)',
+ 'CategoryStatus'=> 'c.Status',
+ )
+ ),
+ 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'Category AS c ON c.CategoryId = %1$s.CategoryId',
+ ), // key - special, value - list select sql
+ 'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
+ ),
+ 'ListSortings' => Array(
+ '' => Array(
+ 'Sorting' => Array('CategoryName' => 'asc'),
+ )
+ ),
+ 'Fields' => Array(
+ 'DummyId' => Array(),
+ 'CategoryId' => Array('type'=>'int','not_null'=>1,'default'=>0),
+ 'ItemResourceId' => Array('not_null' => 1, 'default' => 0),
+ 'PrimaryCat' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'ItemPrefix' => Array('type' => 'string','not_null'=>1,'default'=>''),
+ 'Filename' => Array('type' => 'string','not_null'=>1,'default'=>''),
+ ),
+ 'VirtualFields' => Array(
+ 'CategoryName' => Array(),
+ 'DummyId' => Array(),
+ 'CategoryStatus' => Array(),
+ ),
+
+ 'Grids' => Array(
+ 'Default' => Array(
+ 'Icons' => Array('default' => 'icon16_cat.gif', 0 => 'icon16_cat_disabled.gif', 1 => 'icon16_cat.gif', 2 => 'icon16_cat_pending.gif'), // icons for each StatusField values, if no matches or no statusfield selected, then "default" icon is used
+ 'Fields' => Array(
+ 'CategoryName' => Array( 'title'=>'la_col_Category', 'data_block' => 'grid_checkbox_category_td'),
+ ),
+
+ ),
+ ),
+ );
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.11.2/core/units/category_items/category_items_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.11
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline