Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1033768
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 20, 10:08 PM
Size
21 KB
Mime Type
text/x-diff
Expires
Sun, Jun 22, 10:08 PM (2 h, 2 m)
Engine
blob
Format
Raw Data
Handle
668092
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.13.2/kernel/units/general/cat_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/kernel/units/general/cat_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/kernel/units/general/cat_tag_processor.php (revision 6431)
@@ -0,0 +1,236 @@
+<?php
+
+ class kCatDBTagProcessor extends kDBTagProcessor {
+
+ /**
+ * Permission Helper
+ *
+ * @var kPermissionsHelper
+ */
+ var $PermHelper = null;
+
+ function kCatDBTagProcessor()
+ {
+ parent::kDBTagProcessor();
+ $this->PermHelper = $this->Application->recallObject('PermissionsHelper');
+ }
+
+ 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'];
+ }
+
+ /**
+ * Allows to create valid mod-rewrite compatible link to module item
+ *
+ * @param Array $params
+ * @param string $id_prefix
+ * @return string
+ */
+ function ItemLink($params, $id_prefix)
+ {
+ $params = array_merge($params, Array('pass' => 'm,'.$this->Prefix) );
+
+ $item_id = isset($params[$id_prefix.'_id']) && $params[$id_prefix.'_id'];
+ if (!$item_id) {
+ $item_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
+ if (!$item_id) {
+ $item_id = $this->Application->GetVar($this->Prefix.'_id');
+ }
+ }
+ $params[$this->Prefix.'_id'] = $item_id;
+
+ $object =& $this->getObject($params);
+ $params['m_cat_id'] = $object->GetDBField('CategoryId');
+ $params['pass_category'] = 1;
+
+ return $this->Application->ProcessParsedTag('m', 't', $params);
+ }
+
+ /**
+ * 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);
+ }
+
+ return $this->Application->ProcessParsedTag('c', 'CategoryPath', $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('m_opener' => 'r', '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->GetList($params);
+ if (!$object->Counted) {
+ $object->CountRecs();
+ }
+ 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);
+ }
+
+ function InitCatalogTab($params)
+ {
+ $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['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid
+
+ // set default params (same as in catalog)
+ if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi';
+ if ($tab_params['special'] === false) $tab_params['special'] = '';
+ if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes';
+
+ // pass params to block with tab content
+ $params['name'] = $params['render_as'];
+ $params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
+ $params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
+ $params['tab_mode'] = $tab_params['mode'];
+ $params['tab_dependant'] = $tab_params['dependant'];
+ $params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name
+
+ return $this->Application->ParseBlock($params, 1);
+ }
+
+ /**
+ * Show CachedNavbar of current item primary category
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CategoryName($params)
+ {
+ // show category cachednavbar of
+ $object =& $this->getObject($params);
+ $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId');
+
+ $category_path = $this->Application->getCache('category_paths', $category_id);
+ if ($category_path === false) {
+ // not chached
+ if ($category_id > 0) {
+ $category_path = trim($this->CategoryName( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $object->GetDBField('CachedNavbar')), ' > ');
+ }
+ else {
+ $category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') );
+ }
+ $this->Application->setCache('category_paths', $category_id, $category_path);
+ }
+ return $category_path;
+ }
+
+ /**
+ * Allows to determine if original value should be shown
+ *
+ * @param Array $params
+ * @return bool
+ */
+ function DisplayOriginal($params)
+ {
+ // original id found & greather then zero + show original
+ $display_original = isset($params['display_original']) && $params['display_original'];
+
+ $object =& $this->getObject($params);
+ $perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $this->Prefix);
+
+ return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id');
+ }
+
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/kernel/units/general/cat_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.13
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php (revision 6431)
@@ -0,0 +1,102 @@
+<?php
+
+// define('DBG_IP', 'xxx.yyy.zzz.ddd'); // Define IP addreses, that are allowed to user debugger, semicolon separated. All allowed if none specified.
+// define('SILENT_LOG', 1); // Log all php errors on site to separate file (/silent_log.txt)
+// define('DBG_REQUREST_LOG', '/path/to/file');// Log all user requests to site into filename specified
+// define('DBG_SITE_PATH', '/relative_path/'); // set alternative BASE_PATH for old in-portal parts (where no K4 included)
+
+ InitDebugger();
+
+ /**
+ * Allows to determine if debug is allowed by user, who is viewing site
+ *
+ * @return bool
+ */
+ function DebugAllowed()
+ {
+ $ip_addresses = defined('DBG_IP') && DBG_IP ? explode(';', DBG_IP) : Array($_SERVER['REMOTE_ADDR']);
+
+ return in_array($_SERVER['REMOTE_ADDR'], $ip_addresses) &&
+ !(defined('IS_INSTALL') && IS_INSTALL);
+ }
+
+ /**
+ * Performs initial debugger configuration by defining control constants
+ *
+ */
+ function InitDebugger()
+ {
+ if (!DebugAllowed()) {
+ // debug is not allowed
+ return false;
+ }
+ define('DEBUG_MODE', 1); // Debug mode is allowed
+
+ define('DBG_LOCAL_BASE_PATH', 'w:'); // Folder name on mapped drive, where site resides
+// define('DBG_TOOLBAR_BUTTONS', 1); // Show "Show Debugger" & "Refresh Frame" buttons (on front)
+
+// define('DBG_USE_HIGHLIGHT', 0); // Use "highlight_string" php function for debugger output formatting
+// define('DBG_RAISE_ON_WARNINGS',1); // Show debugger output in case of any non-fatal error
+ define('DBG_SQL_PROFILE',1); // Profile SQL queries
+ define('DBG_SQL_FAILURE', defined('IS_INSTALL') && IS_INSTALL ? 0 : 1); // treat sql errors as fatal errors except for installation process
+
+ define('DBG_SHOW_HTTPQUERY', 1); // Show http query content (parsed user submit, GPC)
+ define('DBG_SHOW_SESSIONDATA', 1); // Show session data (at script finish)
+
+ define('DBG_EDIT_HELP', 1); // Show help filename on help screen
+// define('DBG_HELP', 1); // Show FCK editor when viewing help screen
+
+// define('DBG_FORCE_THEME', 1); // Use this theme_id instead of one in url
+ define('DBG_PHRASES', 1); // Add ability to translate phrases on the fly (K4 templates only)
+ define('DBG_WINDOW_WIDTH', 700);// Set custom debugger layer width (in pixels)
+
+// define('DBG_REDIRECT', 1); // Show links with redirect url instead of performing it (useful in events debugging)
+// define('DBG_ZEND_PRESENT',0); // Set to 0 to debug debugger (because debugger automatically got disabled during zend debug sessions)
+// define('DBG_VALIDATE_CONFIGS',1); // Check that config fields match ones from database
+// define('DBG_SHOW_TAGS', 1); // Show tags beeing processed
+
+ // for ADODB to work: begin
+ define('ADODB_OUTP', 'dbg_SQLLog');
+ function dbg_SQLLog($msg, $new_line = false) { }
+ // for ADODB to work: end
+
+ function isSkipTable($sql)
+ {
+ // don't show sqls that use one or more tables from list below
+ static $skipTables = Array( 'PermissionConfig','SessionData','Permissions',
+ 'Phrase','Cache','Modules','PermCache','Events',
+ 'PersistantSessionData','EmailQueue','UserSession',
+ 'ThemeFiles', 'Language','ConfigurationValues');
+
+ // make exception for scripts listed below
+ $filename = basename($_SERVER['PHP_SELF']);
+ switch ($filename) {
+ case 'session_list.php':
+ $allow_tables = Array('UserSession', 'SessionData');
+ break;
+
+ default:
+ $allow_tables = Array();
+ break;
+ }
+
+ foreach ($allow_tables as $allowed_table) {
+ unset($skipTables[ array_search($allowed_table, $skipTables)]);
+ }
+
+ foreach ($skipTables as $table) {
+ if( tableMatch($table,$sql) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function tableMatch($table_name,$sql)
+ {
+ static $prefix = '';
+ $prefix = defined('TABLE_PREFIX')?TABLE_PREFIX:GetTablePrefix();
+ return strpos($sql,$prefix.$table_name)!==false;
+ }
+ }
+?>
Property changes on: branches/unlabeled/unlabeled-1.13.2/tools/debug_sample.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.13
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.13.2/core/units/general/cat_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/core/units/general/cat_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/core/units/general/cat_tag_processor.php (revision 6431)
@@ -0,0 +1,236 @@
+<?php
+
+ class kCatDBTagProcessor extends kDBTagProcessor {
+
+ /**
+ * Permission Helper
+ *
+ * @var kPermissionsHelper
+ */
+ var $PermHelper = null;
+
+ function kCatDBTagProcessor()
+ {
+ parent::kDBTagProcessor();
+ $this->PermHelper = $this->Application->recallObject('PermissionsHelper');
+ }
+
+ 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'];
+ }
+
+ /**
+ * Allows to create valid mod-rewrite compatible link to module item
+ *
+ * @param Array $params
+ * @param string $id_prefix
+ * @return string
+ */
+ function ItemLink($params, $id_prefix)
+ {
+ $params = array_merge($params, Array('pass' => 'm,'.$this->Prefix) );
+
+ $item_id = isset($params[$id_prefix.'_id']) && $params[$id_prefix.'_id'];
+ if (!$item_id) {
+ $item_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
+ if (!$item_id) {
+ $item_id = $this->Application->GetVar($this->Prefix.'_id');
+ }
+ }
+ $params[$this->Prefix.'_id'] = $item_id;
+
+ $object =& $this->getObject($params);
+ $params['m_cat_id'] = $object->GetDBField('CategoryId');
+ $params['pass_category'] = 1;
+
+ return $this->Application->ProcessParsedTag('m', 't', $params);
+ }
+
+ /**
+ * 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);
+ }
+
+ return $this->Application->ProcessParsedTag('c', 'CategoryPath', $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('m_opener' => 'r', '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->GetList($params);
+ if (!$object->Counted) {
+ $object->CountRecs();
+ }
+ 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);
+ }
+
+ function InitCatalogTab($params)
+ {
+ $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['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid
+
+ // set default params (same as in catalog)
+ if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi';
+ if ($tab_params['special'] === false) $tab_params['special'] = '';
+ if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes';
+
+ // pass params to block with tab content
+ $params['name'] = $params['render_as'];
+ $params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
+ $params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
+ $params['tab_mode'] = $tab_params['mode'];
+ $params['tab_dependant'] = $tab_params['dependant'];
+ $params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name
+
+ return $this->Application->ParseBlock($params, 1);
+ }
+
+ /**
+ * Show CachedNavbar of current item primary category
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CategoryName($params)
+ {
+ // show category cachednavbar of
+ $object =& $this->getObject($params);
+ $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId');
+
+ $category_path = $this->Application->getCache('category_paths', $category_id);
+ if ($category_path === false) {
+ // not chached
+ if ($category_id > 0) {
+ $category_path = trim($this->CategoryName( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $object->GetDBField('CachedNavbar')), ' > ');
+ }
+ else {
+ $category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') );
+ }
+ $this->Application->setCache('category_paths', $category_id, $category_path);
+ }
+ return $category_path;
+ }
+
+ /**
+ * Allows to determine if original value should be shown
+ *
+ * @param Array $params
+ * @return bool
+ */
+ function DisplayOriginal($params)
+ {
+ // original id found & greather then zero + show original
+ $display_original = isset($params['display_original']) && $params['display_original'];
+
+ $object =& $this->getObject($params);
+ $perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $this->Prefix);
+
+ return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id');
+ }
+
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/core/units/general/cat_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.13
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Event Timeline
Log In to Comment