Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Tue, Jun 24, 11:28 PM

in-portal

Index: branches/unlabeled/unlabeled-1.4.10/kernel/units/config_general/config_general_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.10/kernel/units/config_general/config_general_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.10/kernel/units/config_general/config_general_tag_processor.php (revision 3790)
@@ -0,0 +1,100 @@
+<?php
+
+class ConfigGeneralTagProcessor extends kDBTagProcessor {
+
+ function PrintList($params)
+ {
+ $list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params);
+/* $prefix_special = $this->getPrefixSpecial();
+
+ if ( !($list->OriginalParams == $params) ) {
+ $this->Application->removeObject($prefix_special);
+ $list =& $this->Application->recallObject($prefix_special,$this->Prefix.'_List',$params);
+ }
+ */
+ $id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
+
+ $list->PerPage=-1;
+ $list->Query();
+ $o = '';
+ $list->GoFirst();
+
+ $block_params=$this->prepareTagParams($params);
+ $block_params['name']=$params['block'];
+ $block_params['pass_params']='true';
+ $block_params['IdField'] = $id_field;
+
+ while (!$list->EOL())
+ {
+ $stored_cat=$this->Application->RecallVar("StoredRootCatId", "");
+ if ($stored_cat!=""){
+ $list->Records[$list->CurrentIndex]["RootCat"]=$stored_cat;
+ }
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) );
+ $o.= $this->Application->ParseBlock($block_params, 1);
+ $list->GoNext();
+ }
+
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ $this->Application->RemoveVar("StoredRootCatId");
+ return $o;
+ }
+
+ function CategoryPath($params)
+ {
+ $object=&$this->Application->recallObject("confg");
+ $root_cat=$object->GetDBField("RootCat");
+
+ if (!isset($params['cat_id'])){
+ $stored_cat=$this->Application->RecallVar("StoredRootCatId", "");
+ if ($stored_cat){
+ $params['cat_id'] = $stored_cat;
+ }else{
+ $params['cat_id'] = $root_cat;
+ }
+ }
+
+
+ $block_params['current'] = 1;
+
+ $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( $this->getPrefixSpecial(), $this->Prefix.'_List' );
+ $sql = 'SELECT CategoryId, ParentId, Name FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ $block_params['name'] = $params['block'];
+ $block_params['cat_name'] = $res['Name'];
+ $block_params['separator'] = $params['separator'];
+ $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 SaveWarning($params){
+
+ $object=&$this->Application->recallObject($this->getPrefixSpecial());
+ $root_cat=$object->GetDBField("RootCat");
+ $stored_cat=$this->Application->RecallVar("StoredRootCatId", "");
+
+ if ($stored_cat!="" && $stored_cat!=$root_cat){
+ return $this->Application->ParseBlock($params);
+ }
+ return "";
+ }
+
+ function AllowAffiliateRegistration($params)
+ {
+ return $this->Application->ConfigValue('Comm_RegisterAsAffiliate') ? 1 : 0;
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.10/kernel/units/config_general/config_general_tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.10/kernel/units/categories/categories_item.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.10/kernel/units/categories/categories_item.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.10/kernel/units/categories/categories_item.php (revision 3790)
@@ -0,0 +1,151 @@
+<?php
+
+ class CategoriesItem extends kDBItem
+ {
+ /**
+ * Use automatic filename generation
+ *
+ * @var bool
+ */
+ var $useFilenames = true;
+
+ function Create()
+ {
+ if (!$this->Validate()) return false;
+
+ $this->SetDBField('ResourceId', $this->Application->NextResourceId());
+ $this->SetDBField('CreatedById', $this->Application->GetVar('u_id') );
+ $this->SetDBField('CreatedOn_date', adodb_mktime() );
+ $this->SetDBField('CreatedOn_time', adodb_mktime() );
+
+ if ($this->useFilenames) {
+ $this->checkFilename();
+ $this->generateFilename();
+ }
+
+ $this->SetDBField('ParentId', $this->Application->GetVar('m_cat_id') );
+ $ret = parent::Create();
+ if($ret)
+ {
+ $sql = 'UPDATE %s SET ParentPath = %s WHERE CategoryId = %s';
+ $parent_path = $this->buildParentPath();
+ $this->Conn->Query( sprintf($sql, $this->TableName, $this->Conn->qstr($parent_path), $this->GetID() ) );
+
+ $this->SetDBField('ParentPath', $parent_path);
+ }
+ return $ret;
+
+ }
+
+ function Update($id=null, $system_update=false)
+ {
+ if ($this->useFilenames) {
+ $this->checkFilename();
+ $this->generateFilename();
+ }
+ $ret = parent::Update($id, $system_update);
+ return $ret;
+ }
+
+ function buildParentPath()
+ {
+ $parent_id = $this->GetDBField('ParentId');
+
+ $cat_table = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+ $sql = 'SELECT ParentPath FROM '.$cat_table.' WHERE CategoryId = %s';
+ $parent_path = $this->Conn->GetOne( sprintf($sql, $parent_id) );
+ if(!$parent_path) $parent_path = '|'.$parent_id.'|';
+
+ return $parent_path.$this->GetID().'|';
+ }
+
+ /**
+ * replace not allowed symbols with "_" chars + remove duplicate "_" chars in result
+ *
+ * @param string $string
+ * @return string
+ */
+ function stripDisallowed($string)
+ {
+ $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`',
+ '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~',
+ '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',');
+
+ $string = str_replace($not_allowed, '_', $string);
+ $string = preg_replace('/(_+)/', '_', $string);
+ $string = $this->checkAutoFilename($string);
+
+ return $string;
+ }
+
+ function checkFilename()
+ {
+ if( !$this->GetDBField('AutomaticFilename') )
+ {
+ $filename = $this->GetDBField('Filename');
+ $this->SetDBField('Filename', $this->stripDisallowed($filename) );
+ }
+ }
+
+ function checkAutoFilename($filename)
+ {
+ if(!$filename) return $filename;
+
+ $item_id = !$this->GetID() ? 0 : $this->GetID();
+
+ // check temp table
+ $sql_temp = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE Filename = '.$this->Conn->qstr($filename);
+ $found_temp_ids = $this->Conn->GetCol($sql_temp);
+
+ // check live table
+ $sql_live = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE Filename = '.$this->Conn->qstr($filename);
+ $found_live_ids = $this->Conn->GetCol($sql_live);
+
+ $found_item_ids = array_unique( array_merge($found_temp_ids, $found_live_ids) );
+
+ $has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets);
+
+ $duplicates_found = (count($found_item_ids) > 1) || ($found_item_ids && $found_item_ids[0] != $item_id);
+ if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number
+ {
+ $append = $duplicates_found ? '_a' : '';
+ if($has_page)
+ {
+ $filename = $rets[1].'_'.$rets[2];
+ $append = $rets[3] ? $rets[3] : '_a';
+ }
+
+ // check live & temp table
+ $sql_temp = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE (Filename = %s) AND ('.$this->IDField.' != '.$item_id.')';
+ $sql_live = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE (Filename = %s) AND ('.$this->IDField.' != '.$item_id.')';
+ while ( $this->Conn->GetOne( sprintf($sql_temp, $this->Conn->qstr($filename.$append)) ) > 0 ||
+ $this->Conn->GetOne( sprintf($sql_live, $this->Conn->qstr($filename.$append)) ) > 0 )
+ {
+ if (substr($append, -1) == 'z') $append .= 'a';
+ $append = substr($append, 0, strlen($append) - 1) . chr( ord( substr($append, -1) ) + 1 );
+ }
+
+ return $filename.$append;
+ }
+
+ return $filename;
+ }
+
+ /**
+ * Generate item's filename based on it's title field value
+ *
+ * @return string
+ */
+ function generateFilename()
+ {
+ if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false;
+
+ $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $name = $this->stripDisallowed( $this->GetDBField($title_field) );
+
+ if ( $name != $this->GetDBField('Filename') ) $this->SetDBField('Filename', $name);
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.10/kernel/units/categories/categories_item.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.10/core/units/categories/categories_item.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.10/core/units/categories/categories_item.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.10/core/units/categories/categories_item.php (revision 3790)
@@ -0,0 +1,151 @@
+<?php
+
+ class CategoriesItem extends kDBItem
+ {
+ /**
+ * Use automatic filename generation
+ *
+ * @var bool
+ */
+ var $useFilenames = true;
+
+ function Create()
+ {
+ if (!$this->Validate()) return false;
+
+ $this->SetDBField('ResourceId', $this->Application->NextResourceId());
+ $this->SetDBField('CreatedById', $this->Application->GetVar('u_id') );
+ $this->SetDBField('CreatedOn_date', adodb_mktime() );
+ $this->SetDBField('CreatedOn_time', adodb_mktime() );
+
+ if ($this->useFilenames) {
+ $this->checkFilename();
+ $this->generateFilename();
+ }
+
+ $this->SetDBField('ParentId', $this->Application->GetVar('m_cat_id') );
+ $ret = parent::Create();
+ if($ret)
+ {
+ $sql = 'UPDATE %s SET ParentPath = %s WHERE CategoryId = %s';
+ $parent_path = $this->buildParentPath();
+ $this->Conn->Query( sprintf($sql, $this->TableName, $this->Conn->qstr($parent_path), $this->GetID() ) );
+
+ $this->SetDBField('ParentPath', $parent_path);
+ }
+ return $ret;
+
+ }
+
+ function Update($id=null, $system_update=false)
+ {
+ if ($this->useFilenames) {
+ $this->checkFilename();
+ $this->generateFilename();
+ }
+ $ret = parent::Update($id, $system_update);
+ return $ret;
+ }
+
+ function buildParentPath()
+ {
+ $parent_id = $this->GetDBField('ParentId');
+
+ $cat_table = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+ $sql = 'SELECT ParentPath FROM '.$cat_table.' WHERE CategoryId = %s';
+ $parent_path = $this->Conn->GetOne( sprintf($sql, $parent_id) );
+ if(!$parent_path) $parent_path = '|'.$parent_id.'|';
+
+ return $parent_path.$this->GetID().'|';
+ }
+
+ /**
+ * replace not allowed symbols with "_" chars + remove duplicate "_" chars in result
+ *
+ * @param string $string
+ * @return string
+ */
+ function stripDisallowed($string)
+ {
+ $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`',
+ '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~',
+ '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',');
+
+ $string = str_replace($not_allowed, '_', $string);
+ $string = preg_replace('/(_+)/', '_', $string);
+ $string = $this->checkAutoFilename($string);
+
+ return $string;
+ }
+
+ function checkFilename()
+ {
+ if( !$this->GetDBField('AutomaticFilename') )
+ {
+ $filename = $this->GetDBField('Filename');
+ $this->SetDBField('Filename', $this->stripDisallowed($filename) );
+ }
+ }
+
+ function checkAutoFilename($filename)
+ {
+ if(!$filename) return $filename;
+
+ $item_id = !$this->GetID() ? 0 : $this->GetID();
+
+ // check temp table
+ $sql_temp = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE Filename = '.$this->Conn->qstr($filename);
+ $found_temp_ids = $this->Conn->GetCol($sql_temp);
+
+ // check live table
+ $sql_live = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE Filename = '.$this->Conn->qstr($filename);
+ $found_live_ids = $this->Conn->GetCol($sql_live);
+
+ $found_item_ids = array_unique( array_merge($found_temp_ids, $found_live_ids) );
+
+ $has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets);
+
+ $duplicates_found = (count($found_item_ids) > 1) || ($found_item_ids && $found_item_ids[0] != $item_id);
+ if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number
+ {
+ $append = $duplicates_found ? '_a' : '';
+ if($has_page)
+ {
+ $filename = $rets[1].'_'.$rets[2];
+ $append = $rets[3] ? $rets[3] : '_a';
+ }
+
+ // check live & temp table
+ $sql_temp = 'SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE (Filename = %s) AND ('.$this->IDField.' != '.$item_id.')';
+ $sql_live = 'SELECT '.$this->IDField.' FROM '.kTempTablesHandler::GetLiveName($this->TableName).' WHERE (Filename = %s) AND ('.$this->IDField.' != '.$item_id.')';
+ while ( $this->Conn->GetOne( sprintf($sql_temp, $this->Conn->qstr($filename.$append)) ) > 0 ||
+ $this->Conn->GetOne( sprintf($sql_live, $this->Conn->qstr($filename.$append)) ) > 0 )
+ {
+ if (substr($append, -1) == 'z') $append .= 'a';
+ $append = substr($append, 0, strlen($append) - 1) . chr( ord( substr($append, -1) ) + 1 );
+ }
+
+ return $filename.$append;
+ }
+
+ return $filename;
+ }
+
+ /**
+ * Generate item's filename based on it's title field value
+ *
+ * @return string
+ */
+ function generateFilename()
+ {
+ if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false;
+
+ $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $name = $this->stripDisallowed( $this->GetDBField($title_field) );
+
+ if ( $name != $this->GetDBField('Filename') ) $this->SetDBField('Filename', $name);
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.10/core/units/categories/categories_item.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.10/core/admin_templates/stylesheets/stylesheets_edit.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.4.10/core/admin_templates/stylesheets/stylesheets_edit.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.10/core/admin_templates/stylesheets/stylesheets_edit.tpl (revision 3790)
@@ -0,0 +1,70 @@
+<inp2:m_set nobody="yes"/>
+<inp2:m_include t="incs/header"/>
+
+<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
+<inp2:m_ParseBlock name="section_header" icon="icon46_style" title="!la_title_Stylesheets!"/>
+
+<inp2:m_include t="stylesheets/stylesheets_tabs"/>
+
+<inp2:m_ParseBlock name="blue_bar" prefix="css" title_preset="stylesheets_edit" module="in-portal" icon="icon46_style"/>
+
+<!-- ToolBar --->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
+ submit_event('css','<inp2:css_SaveEvent/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
+ submit_event('css','OnCancelEdit');
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
+ go_to_id('css', '<inp2:css_PrevId/>');
+ }
+ ) );
+ a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
+ go_to_id('css', '<inp2:css_NextId/>');
+ }
+ ) );
+
+ a_toolbar.Render();
+
+ <inp2:m_if prefix="css" function="IsSingle"/>
+ a_toolbar.HideButton('prev');
+ a_toolbar.HideButton('next');
+ a_toolbar.HideButton('sep1');
+ <inp2:m_else/>
+ <inp2:m_if prefix="css" function="IsLast"/>
+ a_toolbar.DisableButton('next');
+ <inp2:m_endif/>
+ <inp2:m_if prefix="css" function="IsFirst"/>
+ a_toolbar.DisableButton('prev');
+ <inp2:m_endif/>
+ <inp2:m_endif/>
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:css_SaveWarning name="grid_save_warning"/>
+<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
+ <inp2:m_ParseBlock name="subsection" title="!la_section_General!"/>
+
+ <inp2:m_ParseBlock name="inp_id_label" prefix="css" field="StylesheetId" title="!la_fld_StylesheetId!"/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="css" field="Name" title="!la_fld_Name!" size="40"/>
+ <inp2:m_ParseBlock name="inp_edit_textarea" prefix="css" field="Description" title="!la_fld_Description!" rows="10" cols="40"/>
+ <inp2:m_ParseBlock name="inp_edit_textarea" prefix="css" field="AdvancedCSS" title="!la_fld_AdvancedCSS!" rows="10" cols="40"/>
+ <inp2:m_ParseBlock name="inp_edit_checkbox" prefix="css" field="Enabled" title="!la_fld_Enabled!"/>
+</table>
+
+<inp2:m_include t="incs/footer"/>
+
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.10/core/admin_templates/stylesheets/stylesheets_edit.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline