Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Aug 30, 6:57 PM

in-portal

Index: branches/unlabeled/unlabeled-1.3.2/kernel/units/custom_fields/custom_fields_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.3.2/kernel/units/custom_fields/custom_fields_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.3.2/kernel/units/custom_fields/custom_fields_tag_processor.php (revision 6438)
@@ -0,0 +1,120 @@
+<?php
+
+ class CustomFieldsTagProcessor extends kDBTagProcessor {
+
+ /**
+ * Return LEFT JOINed custom field name from main item config
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetMainField($params)
+ {
+ $object =& $this->getObject($params);
+ $append = isset($params['append']) && $params['append'] ? $params['append'] : '';
+ return 'cust_'.$object->GetDBField('FieldName').$append;
+ }
+
+ function CustomField($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'Field', $params);
+ }
+
+ function CustomFormat($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'Format', $params);
+ }
+
+ function CustomInputName($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'InputName', $params);
+ }
+
+ function CustomError($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'Error', $params);
+ }
+
+ function setParamValue(&$params, $param_name)
+ {
+ // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level)
+ if (!isset($params[$param_name])) {
+ $params[$param_name] = $this->Application->Parser->GetParam($param_name, 1);
+ }
+
+ return $params[$param_name];
+ }
+
+ /**
+ * Prints list content using block specified
+ *
+ * @param Array $params
+ * @return string
+ * @access public
+ */
+ function PrintList($params)
+ {
+ $this->setParamValue($params, 'SourcePrefix');
+ $this->setParamValue($params, 'value_field');
+
+ $list =& $this->GetList($params);
+ $id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
+
+ $list->Query();
+ $o = '';
+ $list->GoFirst();
+
+ $block_params = $this->prepareTagParams($params);
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+ $block_params['pass_params'] = 'true';
+
+ $prev_heading = '';
+ $display_original = false;
+ $source_prefix = getArrayValue($params, 'SourcePrefix');
+ if ($source_prefix) {
+ $source_object =& $this->Application->recallObject($source_prefix);
+ $display_original = $this->Application->ProcessParsedTag($source_prefix, 'DisplayOriginal', Array('display_original' => $this->setParamValue($params, 'display_original')));
+ }
+
+ if ($display_original) {
+ $block_params['display_original'] = $display_original;
+ $block_params['original_title'] = $this->setParamValue($params, 'original_title');
+ $original_object =& $this->Application->recallObject($source_prefix.'.original');
+ }
+
+ if ($this->Special == 'general') {
+ $this->groupRecords($list->Records, 'Heading');
+ }
+
+ while (!$list->EOL())
+ {
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
+
+ if ($source_prefix) {
+ $list->SetDBField($params['value_field'], $source_object->GetDBField('cust_'.$list->GetDBField('FieldName')));
+ if ($display_original) {
+ $list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName')));
+ }
+ $block_params['field'] = 'cust_'.$list->GetDBField('FieldName');
+ $block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0;
+ }
+
+ $o.= $this->Application->ParseBlock($block_params, 1);
+ $prev_heading = $list->GetDBField('Heading');
+ $list->GoNext();
+ }
+
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ return $o;
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.3.2/kernel/units/custom_fields/custom_fields_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.3
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/tools/system_tools.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/tools/system_tools.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/tools/system_tools.tpl (revision 6438)
@@ -0,0 +1,29 @@
+<inp2:m_RequireLogin permissions="in-portal:service.view" system="1"/>
+<inp2:m_include t="incs/header" nobody="yes"/>
+
+<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
+<inp2:m_ParseBlock name="section_header" icon="icon46_modules" title="!la_title_SystemTools!"/>
+
+<inp2:m_ParseBlock name="blue_bar" prefix="adm" title_preset="system_tools" module="in-portal" icon="icon46_modules"/>
+
+<inp2:m_DefineElement name="service_elem">
+ <tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
+ <inp2:m_inc param="tab_index" by="1"/>
+ <td class="text" style="width: 300px;">
+ <inp2:m_phrase label="$title"/>:
+ </td>
+ <td valign="top" width="100">
+ <input class="button" type="submit" name="events[adm][<inp2:m_param name="event_name"/>]" value="Go">
+ </td>
+ <td class="error">&nbsp;</td>
+ </tr>
+</inp2:m_DefineElement>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder" id="config_table">
+ <inp2:m_RenderElement name="service_elem" title="la_Service_ResetModRwCache" event_name="OnResetModRwCache"/>
+ <inp2:m_RenderElement name="service_elem" title="la_Service_ResetCMSMenuCache" event_name="OnResetCMSMenuCache"/>
+ <inp2:m_RenderElement name="service_elem" title="la_Service_ResetSections" event_name="OnResetSections"/>
+ <inp2:m_RenderElement name="service_elem" title="la_Service_ConfigCache" event_name="OnResetConfigsCache"/>
+</table>
+
+<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.3.2/kernel/admin_templates/tools/system_tools.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.3
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.3.2/core/units/custom_fields/custom_fields_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.3.2/core/units/custom_fields/custom_fields_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.3.2/core/units/custom_fields/custom_fields_tag_processor.php (revision 6438)
@@ -0,0 +1,120 @@
+<?php
+
+ class CustomFieldsTagProcessor extends kDBTagProcessor {
+
+ /**
+ * Return LEFT JOINed custom field name from main item config
+ *
+ * @param Array $params
+ * @return string
+ */
+ function GetMainField($params)
+ {
+ $object =& $this->getObject($params);
+ $append = isset($params['append']) && $params['append'] ? $params['append'] : '';
+ return 'cust_'.$object->GetDBField('FieldName').$append;
+ }
+
+ function CustomField($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'Field', $params);
+ }
+
+ function CustomFormat($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'Format', $params);
+ }
+
+ function CustomInputName($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'InputName', $params);
+ }
+
+ function CustomError($params)
+ {
+ $params['name'] = $this->GetMainField($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+ return $this->Application->ProcessParsedTag($source_prefix, 'Error', $params);
+ }
+
+ function setParamValue(&$params, $param_name)
+ {
+ // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level)
+ if (!isset($params[$param_name])) {
+ $params[$param_name] = $this->Application->Parser->GetParam($param_name, 1);
+ }
+
+ return $params[$param_name];
+ }
+
+ /**
+ * Prints list content using block specified
+ *
+ * @param Array $params
+ * @return string
+ * @access public
+ */
+ function PrintList($params)
+ {
+ $this->setParamValue($params, 'SourcePrefix');
+ $this->setParamValue($params, 'value_field');
+
+ $list =& $this->GetList($params);
+ $id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
+
+ $list->Query();
+ $o = '';
+ $list->GoFirst();
+
+ $block_params = $this->prepareTagParams($params);
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+ $block_params['pass_params'] = 'true';
+
+ $prev_heading = '';
+ $display_original = false;
+ $source_prefix = getArrayValue($params, 'SourcePrefix');
+ if ($source_prefix) {
+ $source_object =& $this->Application->recallObject($source_prefix);
+ $display_original = $this->Application->ProcessParsedTag($source_prefix, 'DisplayOriginal', Array('display_original' => $this->setParamValue($params, 'display_original')));
+ }
+
+ if ($display_original) {
+ $block_params['display_original'] = $display_original;
+ $block_params['original_title'] = $this->setParamValue($params, 'original_title');
+ $original_object =& $this->Application->recallObject($source_prefix.'.original');
+ }
+
+ if ($this->Special == 'general') {
+ $this->groupRecords($list->Records, 'Heading');
+ }
+
+ while (!$list->EOL())
+ {
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
+
+ if ($source_prefix) {
+ $list->SetDBField($params['value_field'], $source_object->GetDBField('cust_'.$list->GetDBField('FieldName')));
+ if ($display_original) {
+ $list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName')));
+ }
+ $block_params['field'] = 'cust_'.$list->GetDBField('FieldName');
+ $block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0;
+ }
+
+ $o.= $this->Application->ParseBlock($block_params, 1);
+ $prev_heading = $list->GetDBField('Heading');
+ $list->GoNext();
+ }
+
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ return $o;
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.3.2/core/units/custom_fields/custom_fields_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.3
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/recursive_helper.php
===================================================================
--- branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/recursive_helper.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/recursive_helper.php (revision 6438)
@@ -0,0 +1,171 @@
+<?php
+
+ class kRecursiveHelper extends kHelper {
+
+ function DeleteCategory($category_id)
+ {
+ $id_field = $this->Application->getUnitOption('c', 'IDField');
+ $table_name = $this->Application->getUnitOption('c', 'TableName');
+
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table_name.'
+ WHERE ParentId = '.$category_id;
+
+ $sub_categories = $this->Conn->GetCol($sql);
+ if ($sub_categories) {
+ foreach ($sub_categories as $sub_category_id) {
+ $this->DeleteCategory($sub_category_id);
+ }
+ }
+
+ $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ // 1. remove category items from this category if it is supplemental (non-primary) category to them
+ $sql = 'DELETE FROM '.$ci_table.'
+ WHERE ('.$id_field.' = '.$category_id.') AND (PrimaryCat = 0)';
+ $this->Conn->Query($sql);
+
+ $temp_handler =& $this->Application->recallObject('c_TempHandler', 'kTempTablesHandler');
+
+ // 2. delete items this have this category as primary
+ $delete_ids = $this->getCategoryItems($category_id, true);
+
+ foreach ($delete_ids as $item_prefix => $resource_ids) {
+ if (!$item_prefix) {
+ // not ItemPrefix filled -> old categoryitem linking
+ continue;
+ }
+ $item_ids = $this->GetItemIDs($item_prefix, $resource_ids);
+ $temp_handler->BuildTables($item_prefix, $item_ids);
+ $temp_handler->DeleteItems($item_prefix, '', $item_ids);
+ }
+
+ // 3. delete this category
+ $temp_handler->BuildTables('c', Array($category_id));
+ $temp_handler->DeleteItems('c', '', Array($category_id));
+ }
+
+ /**
+ * Converts resource ids list to id field list for given prefix
+ *
+ * @param string $prefix
+ * @param Array $resource_ids
+ * @return Array
+ */
+ function GetItemIDs($prefix, $resource_ids)
+ {
+ if (!$resource_ids) {
+ return Array();
+ }
+
+ $id_field = $this->Application->getUnitOption($prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table_name.'
+ WHERE ResourceId IN ('.implode(',', $resource_ids).')';
+ return $this->Conn->GetCol($sql);
+ }
+
+ // moves selected categories to destination category
+ function MoveCategories($category_ids, $dest_category_id)
+ {
+ if (!$category_ids) return ;
+
+ $id_field = $this->Application->getUnitOption('c', 'IDField');
+ $table_name = $this->Application->getUnitOption('c', 'TableName');
+
+ $sql = 'UPDATE '.$table_name.'
+ SET ParentId = '.$dest_category_id.'
+ WHERE '.$id_field.' IN ('.implode(',', $category_ids).')';
+ $this->Conn->Query($sql);
+ }
+
+ /**
+ * Complete cloning or category with subcategories and subitems
+ *
+ * @param int $category_id
+ */
+ function PasteCategory($category_id)
+ {
+ $backup_category_id = $this->Application->GetVar('m_cat_id');
+
+ // 1. clone category
+ $temp_handler =& $this->Application->recallObject('c_TempHandler', 'kTempTablesHandler');
+ $temp_handler->BuildTables('c', Array($category_id));
+ $new_category_id = array_pop( $temp_handler->CloneItems('c', '', Array($category_id)) );
+ $this->Application->SetVar('m_cat_id', $new_category_id);
+
+ $id_field = $this->Application->getUnitOption('c', 'IDField');
+ $table_name = $this->Application->getUnitOption('c', 'TableName');
+
+ // 2. assign supplemental items to current category to new category
+ $paste_ids = $this->getCategoryItems($category_id, false);
+
+ foreach ($paste_ids as $item_prefix => $resource_ids) {
+ if (!$item_prefix) {
+ // not ItemPrefix filled -> old categoryitem linking
+ continue;
+ }
+
+ $item_object =& $this->Application->recallObject($item_prefix.'.-item', null, Array('skip_autoload' => true));
+ foreach ($resource_ids as $item_resource_id) {
+ $item_object->Load($item_resource_id, 'ResourceId');
+ $item_object->assignToCategory($new_category_id, false);
+ }
+ }
+
+ // 3. clone items that have current category as primary
+ $paste_ids = $this->getCategoryItems($category_id, true);
+
+ foreach ($paste_ids as $item_prefix => $resource_ids) {
+ if (!$item_prefix) {
+ // not ItemPrefix filled -> old categoryitem linking
+ continue;
+ }
+
+ // 2. clone items from current category (for each prefix separately)
+ $item_ids = $this->GetItemIDs($item_prefix, $resource_ids);
+ $temp_handler->BuildTables($item_prefix, $item_ids);
+ $temp_handler->CloneItems($item_prefix, '', $item_ids);
+ }
+
+ // 4. do same stuff for each subcategory
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table_name.'
+ WHERE ParentId = '.$category_id;
+
+ $sub_categories = $this->Conn->GetCol($sql);
+ if ($sub_categories) {
+ foreach ($sub_categories as $sub_category_id) {
+ $this->PasteCategory($sub_category_id);
+ }
+ }
+
+ $this->Application->SetVar('m_cat_id', $backup_category_id);
+ }
+
+ /**
+ * Returns grouped category items
+ *
+ * @param int $category_id
+ * @param bool $item_primary_category
+ * @return Array
+ */
+ function getCategoryItems($category_id, $item_primary_category = true)
+ {
+ $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+
+ $sql = 'SELECT ItemPrefix, ItemResourceId
+ FROM '.$ci_table.'
+ WHERE (CategoryId = '.$category_id.') AND (PrimaryCat = '.($item_primary_category ? 1 : 0).')';
+ $category_items = $this->Conn->GetCol($sql, 'ItemResourceId');
+
+ $item_ids = Array();
+ foreach ($category_items as $resource_id => $item_prefix) {
+ $item_ids[$item_prefix][] = $resource_id;
+ }
+ return $item_ids;
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/recursive_helper.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.3
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/helpers_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/helpers_config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/helpers_config.php (revision 6438)
@@ -0,0 +1,18 @@
+<?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'),
+ ),
+ );
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.3.2/core/units/general/helpers/helpers_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.3
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline