Index: branches/unlabeled/unlabeled-1.37.2/kernel/include/itemdb.php =================================================================== diff -u -r8183 -r8332 --- branches/unlabeled/unlabeled-1.37.2/kernel/include/itemdb.php (.../itemdb.php) (revision 8183) +++ branches/unlabeled/unlabeled-1.37.2/kernel/include/itemdb.php (.../itemdb.php) (revision 8332) @@ -2,8 +2,8 @@ define('FT_OPTION', 1); // option formatter -class clsItemDB -{ +class clsItemDB +{ var $Formatters = Array(); // by Alex var $m_dirtyFieldsMap = array(); var $Data = array(); @@ -13,46 +13,46 @@ var $id_field; var $NoResourceId; var $debuglevel; - + var $Prefix = ''; var $Special = ''; - + var $SelectSQL = 'SELECT * FROM %s WHERE %s'; - + /** * Application object * * @var kApplication */ var $Application = null; - + /** * Connection to database * * @var kDBConnection */ var $Conn = null; - + function clsItemDB() { if (class_exists('kApplication')) { // just in case when aplication is not found - $this->Application =& kApplication::Instance(); + $this->Application =& kApplication::Instance(); $this->Conn =& $this->Application->GetADODBConnection(); } - + $this->adodbConnection = &GetADODBConnection(); $this->tablename=""; $this->NoResourceId=0; $this->debuglevel=0; } - + // ============================================================================================ function GetFormatter($field) { return $this->HasFormatter($field) ? $this->Formatters[$field] : false; } - + function isLiveTable() { global $objSession; @@ -68,14 +68,14 @@ { case FT_OPTION: $this->Formatters[$field]['options'] = $params; - break; + break; } } - /* + /* function FormatFields() { // format item in list data before printing - + foreach($this->Formatters as $field => $formatter) $this->Data[$field] = $this->FormatField($field); } @@ -90,20 +90,20 @@ { case FT_OPTION: return $fmt['options'][ $this->Data[$field] ]; - break; + break; } } else return $this->Get($field); } - + function HasFormatter($field) { // checks if formatter is set for field return isset($this->Formatters[$field]) ? 1 : 0; } // ============================================================================================ - + function UnsetIdField() { $f = $this->IdField(); @@ -120,7 +120,7 @@ function IdField() { if(!strlen($this->id_field)) - { + { return $this->tablename."Id"; } else @@ -134,17 +134,17 @@ function SetUniqueId($value) { - $var = $this->IdField(); - + $var = $this->IdField(); + if( $this->UsingTempTable() ) $value = $this->UniqueId(); - + $this->Set($var, $value); } function SetModified($UserId=NULL,$modificationDate=null) { global $objSession; - + $keys = array_keys($this->Data); if(in_array("Modified",$keys)) { @@ -162,28 +162,32 @@ { echo '
'.print_r($this->Data, true).'
'; } - + // ================================================================= function GetFormatted($name) - { + { // get formatted field value return $this->FormatField($name); } - function Get($name) - { + function Get($name, $ifempty=null) + { // get un-formatted field value //if( !isset($this->Data[$name]) ) print_pre( debug_backtrace() ); - return $this->HasField($name) ? $this->Data[$name] : ''; + $ret = $this->HasField($name) ? $this->Data[$name] : ''; + if (isset($ifempty) && $ret == '') { + $ret = $this->Data[$ifempty]; + } + return $ret; } // ================================================================= function HasField($name) { // checks if field exists in item - return isset($this->Data[$name]) ? 1 : 0; + return isset($this->Data[$name]) ? 1 : 0; } - + /** * Set's value(-s) of field(-s) specified. * Modifies HasChanges flag automatically. @@ -207,8 +211,8 @@ $this->_Set($name,$value); } } - - + + /** * Set's value(-s) of field(-s) specified. * Modifies HasChanges flag automatically. @@ -240,9 +244,9 @@ } } else - { - foreach($list as $field) - { + { + foreach($list as $field) + { $this->m_dirtyFieldsMap[$field] = $this->Data[$field]; } } @@ -256,9 +260,9 @@ $this->m_dirtyFieldsMap=array(); } else - { - foreach($list as $value) - { + { + foreach($list as $value) + { $varname = "m_" . $value; unset($this->m_dirtyFieldsMap[$value]); } @@ -271,9 +275,9 @@ } function SetFromArray($data, $dirty = false) - { + { if(is_array($data)) - { + { $this->Data = $data; if($dirty) $this->m_dirtyFieldsMap = $data; } @@ -290,7 +294,7 @@ } function Delete() - { + { global $Errors; if($this->Get($this->IdField())==0) @@ -316,7 +320,7 @@ global $Errors, $objSession; if( !$this->raiseEvent('OnBeforeItemUpdate') ) return false; - + if( count($this->m_dirtyFieldsMap) == 0 ) return true; $this->SetModified($UpdatedBy, $modificationDate); @@ -328,17 +332,17 @@ { if( is_null($value) ) { - $value = 'NULL'; + $value = 'NULL'; } else { - $value = $this->adodbConnection->qstr( isset($GLOBALS['_CopyFromEditTable']) ? $value : stripslashes($value) ); + $value = $this->adodbConnection->qstr( isset($GLOBALS['_CopyFromEditTable']) ? $value : stripslashes($value) ); } $sql .= '`'.$key.'` = '.$value.', '; } } $sql = preg_replace('/(.*), $/','\\1',$sql); - + $sql .= ' WHERE '.$this->IdField().' = '.$this->adodbConnection->qstr( $this->UniqueId() ); if( $this->debuglevel > 0 ) echo $sql.'
'; @@ -349,28 +353,28 @@ } if( $objSession->GetVariable('HasChanges') == 2 ) $objSession->SetVariable('HasChanges', 1); - + $this->raiseEvent('OnAfterItemUpdate'); - + return true; } - + function ReplaceID($new_id) { - // replace item's id, because Update method + // replace item's id, because Update method // is too dummy to do this autommatically // USED in temporary table editing stuff $db =& $this->adodbConnection; - $sql = "UPDATE %1\$s SET `%2\$s` = %3\$s WHERE `%2\$s` = %4\$s"; + $sql = "UPDATE %1\$s SET `%2\$s` = %3\$s WHERE `%2\$s` = %4\$s"; $sql = sprintf($sql, $this->tablename, $this->IdField(), $new_id, (int)$this->UniqueId() ); if($this->debuglevel > 0) echo $sql.'
'; $db->Execute($sql); } - + function CreateSQL() { global $Errors; - + $sql = "INSERT INTO ".$this->tablename." ("; $first = 1; foreach ($this->Data as $key => $value) @@ -413,10 +417,10 @@ } } $sql = sprintf('%s)',$sql); - + return $sql; } - + /** * Set's HasChanges flag based on new field * with $name with value $value. @@ -426,27 +430,27 @@ * @access private */ function DetectChanges($name, $value) - { + { global $objSession; if( !is_object($objSession) ) return false; - + //echo "class: ".get_class($this)."
"; if (!isset($this->Data[$name]) ) return false; - - if ( getArrayValue($this->Data, $name) != $value && $value != '') { + + if ( getArrayValue($this->Data, $name) != $value && $value != '') { //echo "$name Modified tt ".$this->Data[$name]." tt $value
"; if ($objSession->GetVariable("HasChanges") != 1) { - $objSession->SetVariable("HasChanges", 2); + $objSession->SetVariable("HasChanges", 2); } } } - + function Create() { global $Errors, $objSession; - + if( !$this->raiseEvent('OnBeforeItemCreate') ) return false; - + if($this->debuglevel) echo "Creating Item: ".get_class($this)."
"; if($this->NoResourceId!=1 && (int)$this->Get("ResourceId")==0) { @@ -474,36 +478,36 @@ } */ $this->raiseEvent('OnAfterItemCreate'); - + return true; } function Increment($field, $calculate_hot = false) - { + { global $Errors; - + if ($calculate_hot) { $sql = "SELECT $field FROM ".$this->tablename." WHERE ".$this->IdField()." = ".$this->UniqueId(); $rs = $this->adodbConnection->Execute($sql); - + $sql = "SELECT MAX($field) AS max_value FROM ".$this->tablename." WHERE ROUND($field) = ".round($rs->fields[$field]); $rs = $this->adodbConnection->Execute($sql); //echo "MAX VALUE: ".$rs->fields['max_value']."
"; //echo "MAX SQL: $sql
"; $new_val = $rs->fields['max_value'] + 1; - + $sql = "SELECT count($field) AS count FROM ".$this->tablename." WHERE $field = $new_val"; - $rsc = $this->adodbConnection->Execute($sql); - + $rsc = $this->adodbConnection->Execute($sql); + while ($rsc->fields['count'] != 0) { $sql = "SELECT count($field) AS count FROM ".$this->tablename." WHERE $field = $new_val"; - $rsc = $this->adodbConnection->Execute($sql); + $rsc = $this->adodbConnection->Execute($sql); //echo "New Value:$new_val
"; if ($rsc->fields['count'] > 0) { $new_val = $new_val + 0.000001; } } - + $sql = "Update ".$this->tablename." set $field=$new_val where ".$this->IdField()."=" . $this->UniqueId(); } else { @@ -517,7 +521,7 @@ $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Increment"); return false; } - + if ($calculate_hot) { $this->Set($field,$new_val); } @@ -527,7 +531,7 @@ } function Decrement($field) - { + { global $Errors; $sql = "Update ".$this->tablename." set $field=$field-1 where ".$this->IdField()."=" .(int)$this->UniqueId(); @@ -541,7 +545,7 @@ } $this->Set($field,$this->Get($field)-1); } - + function GetFieldList($UseLoadedData=FALSE) { if(count($this->Data) && $UseLoadedData==TRUE) @@ -554,38 +558,38 @@ } return $res; } - + function UsingTempTable() { global $objSession; - + $temp = $objSession->GetEditTable($this->tablename); $p = GetTablePrefix()."ses"; $t = substr($temp,0,strlen($p)); - $ThisTable = substr($this->tablename,0,strlen($p)); + $ThisTable = substr($this->tablename,0,strlen($p)); if($t==$ThisTable) { return TRUE; } else return FALSE; } - + function LoadFromDatabase($Id, $IdField = null) // custom IdField by Alex { global $objSession,$Errors; - + if(!isset($Id)) { $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase"); return false; } - + // --------- multiple ids allowed: begin ----------------- $id_field = isset($IdField) ? $IdField : $this->IdField(); if( !is_array($id_field) ) $id_field = Array($id_field); if( !is_array($Id) ) $Id = Array($Id); - + $i = 0; $id_count = count($id_field); $conditions = Array(); while($i < $id_count) @@ -595,7 +599,7 @@ } $sql = sprintf($this->SelectSQL, $this->tablename, implode(' AND ', $conditions) ); // --------- multiple ids allowed: end -------------------- - if($this->debuglevel) echo "Load SQL: $sql
"; + if($this->debuglevel) echo "Load SQL: $sql
"; $result = $this->adodbConnection->Execute($sql); if ($result === false) { @@ -609,13 +613,13 @@ $this->Clean(); return TRUE; } - + function FieldExists($field) { $res = array_key_exists($field,$this->Data); - return $res; + return $res; } - + function ValueExists($Field,$Value) { $sql = "SELECT $Field FROM ".$this->tablename." WHERE $Field='$Value'"; @@ -639,7 +643,7 @@ else $ret = 0; } - + function FieldMin($Field) { $sql = "SELECT Min($Field) as m FROM ".$this->tablename; @@ -651,18 +655,18 @@ else $ret = 0; } - + function TableExists($table = null) { static $tables_found = Array (); - + if($table == null) $table = $this->tablename; - + if (!isset($tables_found[$table])) { - // checks if table specified in item exists in db + // checks if table specified in item exists in db $db =& GetADODBConnection(); $sql = "SHOW TABLES LIKE '%s'"; - + $rs = $db->Execute( sprintf($sql, $table) ); if ($rs->RecordCount() == 1) { // table exists in normal case @@ -674,24 +678,24 @@ $tables_found[$table] = $rs->RecordCount() == 1 ? 1 : 0; } } - + return $tables_found[$table]; } - + function raiseEvent($name, $id = null) { return true; - + /*if (!getArrayValue($GLOBALS, '_CopyFromEditTable')) { return true; } - + if( !isset($id) ) $id = $this->GetID(); $event = new kEvent( Array('name'=>$name,'prefix'=>$this->Prefix,'special'=>$this->Special) ); $event->setEventParam('id', $id); $this->Application->HandleEvent($event); return $event->status == erSUCCESS ? true : false;*/ } - + } ?> Index: branches/unlabeled/unlabeled-1.61.2/kernel/include/category.php =================================================================== diff -u -r8119 -r8332 --- branches/unlabeled/unlabeled-1.61.2/kernel/include/category.php (.../category.php) (revision 8119) +++ branches/unlabeled/unlabeled-1.61.2/kernel/include/category.php (.../category.php) (revision 8332) @@ -11,6 +11,8 @@ var $Permissions; var $DescriptionField = ''; + var $PrimaryDescriptionField = ''; + var $DescriptionField = ''; function clsCategory($CategoryId=NULL) { @@ -21,6 +23,9 @@ $this->TitleField = $ml_formatter->LangFieldName('Name'); $this->DescriptionField = $ml_formatter->LangFieldName('Description'); + $this->PrimaryTitleField = $ml_formatter->LangFieldName('Name', 1); + $this->PrimaryDescriptionField = $ml_formatter->LangFieldName('Description', 1); + $this->tablename = GetTablePrefix()."Category"; $this->type=1; $this->BasePermission ="CATEGORY"; @@ -373,7 +378,7 @@ $res = $this->Get($navbar_field); if (!strlen($res)) { $this->UpdateCachedPath(); - $res = $this->Get($navbar_field); + $res = $this->Get($navbar_field, $ml_formatter->LangFieldName('CachedNavbar',1)); } return str_replace('&|&', ' > ', $res); } @@ -815,7 +820,7 @@ function GetNavbar() { $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - return str_replace('&|&', ' > ', $this->Get($ml_formatter->LangFieldName('CachedNavbar'))); + return str_replace('&|&', ' > ', $this->Get($ml_formatter->LangFieldName('CachedNavbar'), $ml_formatter->LangFieldName('CachedNavbar', 1))); } function ParseObject($element) @@ -865,14 +870,14 @@ @field:cat.name @description:Category name */ - $ret = $this->HighlightField($this->TitleField); + $ret = $this->HighlightText($this->Get($this->TitleField, $this->PrimaryTitleField)); break; case "description": /* @field:cat.description @description:Category Description */ - $ret = ($this->Get($this->DescriptionField)); + $ret = ($this->Get($this->DescriptionField, $this->PrimaryDescriptionField)); $ret = $this->HighlightText($ret); break; case "cachednavbar": @@ -1540,14 +1545,18 @@ var $TitleField = ''; var $DescriptionField = ''; + var $PrimaryTitleField; + var $PrimaryDescriptionField; function clsCatList() { global $m_var_list; $this->clsItemCollection(); $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $this->TitleField = $ml_formatter->LangFieldName('Name'); + $this->PrimaryTitleField = $ml_formatter->LangFieldName('Name', 1); $this->DescriptionField = $ml_formatter->LangFieldName('Description'); + $this->PrimaryDescriptionField = $ml_formatter->LangFieldName('Description', 1); $this->Prefix = 'c'; $this->classname="clsCategory"; @@ -2110,7 +2119,7 @@ foreach ($fields_hash as $field_name => $field_value) { $d->Set($field_name, $field_value); } - + $d->Create(); if (!$from_import) { Index: branches/unlabeled/unlabeled-1.1.2/admin/install/upgrades/changelog_4_1_0.txt =================================================================== diff -u -r8293 -r8332 --- branches/unlabeled/unlabeled-1.1.2/admin/install/upgrades/changelog_4_1_0.txt (.../changelog_4_1_0.txt) (revision 8293) +++ branches/unlabeled/unlabeled-1.1.2/admin/install/upgrades/changelog_4_1_0.txt (.../changelog_4_1_0.txt) (revision 8332) @@ -3,6 +3,7 @@ File in-portal/admin/include/elements.php changed File in-portal/admin/include/mainscript.php changed File in-portal/admin/include/style.css changed +File in-portal/admin/include/tabs.js changed File in-portal/admin/install/db_reconfig.php changed File in-portal/admin/install/dbinfo.php changed File in-portal/admin/install/domain.php changed @@ -11,6 +12,7 @@ File in-portal/admin/install/general_error.php changed File in-portal/admin/install/get_license.php changed File in-portal/admin/install/inportal_data.sql changed +File in-portal/admin/install/inportal_remove.sql changed File in-portal/admin/install/inportal_schema.sql changed File in-portal/admin/install/install_finish.php changed File in-portal/admin/install/install_lib.php changed @@ -31,12 +33,15 @@ File in-portal/admin/install/warning.php changed File in-portal/admin/install/langpacks/english.lang changed File in-portal/admin/install/upgrades/changelog_4_0_1.txt changed -File in-portal/admin/install/upgrades/changelog_4_1_0.txt is new; release_4_1_0 revision 1.1.2.4 +File in-portal/admin/install/upgrades/changelog_4_1_0.txt is new; release_4_1_0 revision 1.1.2.5 File in-portal/admin/install/upgrades/inportal_upgrade_v1.3.2.sql is removed; release_4_0_1 revision 1.2 File in-portal/admin/install/upgrades/inportal_upgrade_v4.1.0.php is new; release_4_1_0 revision 1.1.2.2 -File in-portal/admin/install/upgrades/inportal_upgrade_v4.1.0.sql is new; release_4_1_0 revision 1.1.2.3 +File in-portal/admin/install/upgrades/inportal_upgrade_v4.1.0.sql is new; release_4_1_0 revision 1.1.2.4 +File in-portal/admin/install/upgrades/readme_4_1_0.txt is new; release_4_1_0 revision 1.1.2.1 File in-portal/admin/tools/server_info.php changed +File in-portal/admin/users/adduser.php changed File in-portal/kernel/parser.php changed +File in-portal/kernel/admin/include/toolbar/sendmail.php changed File in-portal/kernel/admin_templates/catalog.tpl changed File in-portal/kernel/admin_templates/catalog_tab.tpl changed File in-portal/kernel/admin_templates/no_permission.tpl changed @@ -58,6 +63,7 @@ File in-portal/kernel/admin_templates/visits/visits_list.tpl changed File in-portal/kernel/include/category.php changed File in-portal/kernel/include/config.php changed +File in-portal/kernel/include/customfield.php changed File in-portal/kernel/include/custommetadata.php changed File in-portal/kernel/include/emailmessage.php changed File in-portal/kernel/include/globals.php changed @@ -172,6 +178,7 @@ File kernel.X/core/units/general/cat_event_handler.php changed File kernel.X/core/units/general/custom_fields.php changed File kernel.X/core/units/general/inp1_parser.php changed +File kernel.X/core/units/general/main_event_handler.php changed File kernel.X/core/units/general/xml_helper.php changed File kernel.X/core/units/general/helpers/count_helper.php is new; release_4_1_0 revision 1.4 File kernel.X/core/units/general/helpers/curl_helper.php is new; release_4_1_0 revision 1.1