Index: trunk/core/kernel/db/db_tag_processor.php =================================================================== diff -u -r3344 -r3368 --- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 3344) +++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 3368) @@ -25,7 +25,7 @@ */ function IsNewMode($params) { - $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); + $object =& $this->getObject($params); return $object->GetID() <= 0; } @@ -37,7 +37,7 @@ */ function GetItemName($params) { - $item_name = $this->Application->getUnitOption($this->Prefix,'ViewMenuPhrase'); + $item_name = $this->Application->getUnitOption($this->Prefix, 'ViewMenuPhrase'); return $this->Application->Phrase($item_name); } @@ -149,7 +149,6 @@ */ function PrintList($params) { -// $list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params); $list =& $this->GetList($params); $id_field = $this->Application->getUnitOption($this->Prefix,'IDField'); @@ -192,7 +191,7 @@ /** * Enter description here... * - * @param unknown_type $params + * @param Array $params * @return kDBList */ function &GetList($params) @@ -375,9 +374,8 @@ function NotLastItem($params) { - $list =& $this->Application->recallObject($this->getPrefixSpecial()); - - return ($list->CurrentIndex < min($list->PerPage, $list->RecordsCount)-1); + $object =& $this->getObject($params); // maybe we should use $this->GetList($params) instead + return ($object->CurrentIndex < min($object->PerPage, $object->RecordsCount) - 1); } function PageLink($params) @@ -412,12 +410,12 @@ * @return Array * @access protected */ - function prepareTagParams($tag_params=Array()) + function prepareTagParams($tag_params = Array()) { - $ret=$tag_params; - $ret['Prefix']=$this->Prefix; - $ret['Special']=$this->Special; - $ret['PrefixSpecial']=$this->getPrefixSpecial(); + $ret = $tag_params; + $ret['Prefix'] = $this->Prefix; + $ret['Special'] = $this->Special; + $ret['PrefixSpecial'] = $this->getPrefixSpecial(); return $ret; } @@ -473,7 +471,7 @@ if( !$this->Application->IsAdmin() ) $params['no_special'] = 'no_special'; - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); + $object =& $this->getObject($params); if ( $this->HasParam($params, 'db') ) { @@ -577,18 +575,16 @@ function Error($params) { $field = $params['field']; - $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); - + $object =& $this->getObject($params); $msg = $object->GetErrorMsg($field, false); - return $msg; } function HasError($params) { if ($params['field'] == 'any') { - $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); + $object =& $this->getObject($params); $skip_fields = getArrayValue($params, 'except'); $skip_fields = $skip_fields ? explode(',', $skip_fields) : Array(); @@ -612,7 +608,7 @@ function IsRequired($params) { $field = $params['field']; - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); + $object =& $this->getObject($params);; $options = $object->GetFieldOptions($field); return getArrayValue($options,'required'); @@ -621,7 +617,7 @@ function PredefinedOptions($params) { $field = $params['field']; - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); + $object =& $this->getObject($params); $value = $object->GetDBField($field); $options = $object->GetFieldOptions($field); @@ -676,7 +672,7 @@ function Format($params) { $field = $params['field']; - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); + $object =& $this->getObject($params); $options = $object->GetFieldOptions($field); @@ -835,7 +831,7 @@ function prepareInputName($params) { $field = $params['field']; - $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); + $object =& $this->getObject($params); $formatter_class = getArrayValue($object->Fields, $field, 'formatter'); if ($formatter_class == 'kMultiLanguage') @@ -974,7 +970,7 @@ */ function PerPage($params) { - $object =& $this->Application->recallObject( $this->getPrefixSpecial() ); + $object =& $this->getObject($params); return $object->PerPage; } @@ -986,43 +982,41 @@ */ function PerPageEquals($params) { - $object =& $this->Application->recallObject( $this->getPrefixSpecial() ); + $object =& $this->getObject($params); return $object->PerPage == $params['value']; } function SaveEvent($params) { - // SaveEvent is set during onbuild, but we may need it before any other tag calls onBuild - $prefix_special = $this->getPrefixSpecial(); - $item = $this->Application->recallObject($prefix_special); - - return $this->Application->GetVar($prefix_special.'_SaveEvent'); + // SaveEvent is set during OnItemBuild, but we may need it before any other tag calls OnItemBuild + $object =& $this->getObject($params); + return $this->Application->GetVar($this->getPrefixSpecial().'_SaveEvent'); } function NextId($params) { - $prefix_special=$this->getPrefixSpecial(); - $ids = explode(',', $this->Application->RecallVar($prefix_special.'_selected_ids')); - $item = $this->Application->recallObject($prefix_special); - $cur_id = $item->GetId(); + $object =& $this->getObject($params); + $ids = explode(',', $this->Application->RecallVar($this->getPrefixSpecial().'_selected_ids')); - $i = array_search($cur_id,$ids); + $cur_id = $object->GetID(); + + $i = array_search($cur_id, $ids); if ($i !== false) { - return $i < count($ids)-1 ? $ids[$i+1] : ''; + return $i < count($ids) - 1 ? $ids[$i + 1] : ''; } return ''; } function PrevId($params) { - $prefix_special=$this->getPrefixSpecial(); - $ids = explode(',', $this->Application->RecallVar($prefix_special.'_selected_ids')); - $item = $this->Application->recallObject($prefix_special); - $cur_id = $item->GetId(); + $object =& $this->getObject($params); + $ids = explode(',', $this->Application->RecallVar($this->getPrefixSpecial().'_selected_ids')); - $i = array_search($cur_id,$ids); + $cur_id = $object->GetID(); + + $i = array_search($cur_id, $ids); if ($i !== false) { - return $i > 0 ? $ids[$i-1] : ''; + return $i > 0 ? $ids[$i - 1] : ''; } return ''; } @@ -1050,15 +1044,15 @@ */ function FieldEquals($params) { - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); + $object =& $this->getObject($params); $ret = $object->GetDBField($this->SelectParam($params, 'name,field')) == $params['value']; // if( getArrayValue($params,'inverse') ) $ret = !$ret; return $ret; } function ItemIcon($params) { - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); + $object =& $this->getObject($params); $grids = $this->Application->getUnitOption($this->Prefix,'Grids'); $icons =& $grids[ $params['grid'] ]['Icons']; @@ -1192,7 +1186,7 @@ */ function ConfigFormElement($params) { - $object =& $this->Application->recallObject( $this->getPrefixSpecial() ); + $object =& $this->getObject($params); $field = $params['field']; $helper =& $this->Application->recallObject('InpCustomFieldsHelper'); @@ -1233,7 +1227,7 @@ */ function CustomField($params) { - $object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); + $object =& $this->getObject($params); $field = $this->SelectParam($params, 'name,field'); @@ -1250,8 +1244,7 @@ function CustomFieldLabel($params) { - $prefix = $this->Prefix; - $object =& $this->Application->recallObject( $prefix ); + $object =& $this->Application->recallObject($this->Prefix); // not using Special here (for what purpose ?) $field = $this->SelectParam($params, 'name,field'); @@ -1360,7 +1353,7 @@ function SearchFormat($params) { $field = $params['field']; - $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix.'_List', $params); + $object =& $this->GetList($params); $options = $object->GetFieldOptions($field); @@ -1425,6 +1418,18 @@ } return '../../'.$module_folder.'/admin_templates/'; } + + /** + * Returns object used in tag processor + * + * @access public + * @return kDBBase + */ + function &getObject($params = Array()) + { + $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); + return $object; + } }