Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Sep 28, 9:03 AM

in-portal

Index: branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_tag_processor.php (revision 5215)
@@ -0,0 +1,210 @@
+<?php
+
+class ConfigurationTagProcessor extends kDBTagProcessor {
+
+
+ function Init($prefix,$special,$event_params=null)
+ {
+ parent::Init($prefix, $special, $event_params);
+ $this->Application->LinkVar('module_key');
+ }
+
+ /**
+ * Prints list content using block specified
+ *
+ * @param Array $params
+ * @return string
+ * @access public
+ */
+ function PrintList($params)
+ {
+ $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';
+ $block_params['IdField'] = $list->IDField;
+
+ $prev_heading = '';
+ $next_block = $params['full_block'];
+ $this->groupRecords($list->Records, 'heading');
+ $field_values = $this->Application->GetVar($this->getPrefixSpecial(true));
+
+ while (!$list->EOL())
+ {
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
+
+ // using 2 blocks for drawing o row in case if current & next record titles match
+ $next_item_prompt = $list->CurrentIndex + 1 < $list->RecordsCount ? $list->Records[$list->CurrentIndex + 1]['prompt'] : '';
+ $this_item_prompt = $list->GetDBField('prompt');
+
+ if ($next_item_prompt == $this_item_prompt) {
+ $curr_block = $params['half_block1'];
+ $next_block = $params['half_block2'];
+ } else {
+ $curr_block = $next_block;
+ $next_block = $params['full_block'];
+ }
+
+ $block_params['name'] = $curr_block;
+
+ $block_params['show_heading'] = ($prev_heading != $list->GetDBField('heading') ) ? 1 : 0;
+
+ // set values from submit if any
+ if ($field_values) {
+ $list->SetDBField('VariableValue', $field_values[$list->GetDBField('VariableName')]['VariableValue']);
+ }
+
+ $o.= $this->Application->ParseBlock($block_params, 1);
+ $prev_heading = $list->GetDBField('heading');
+ $list->GoNext();
+ }
+
+ $this->Application->RemoveVar('ModuleRootCategory');
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ return $o;
+ }
+
+ function getModuleItemName()
+ {
+ $module = $this->Application->GetVar('module');
+ $table = $this->Application->getUnitOption('confs', 'TableName');
+
+ $sql = 'SELECT ConfigHeader
+ FROM '.$table.'
+ WHERE ModuleName = '.$this->Conn->qstr($module);
+ return $this->Conn->GetOne($sql);
+ }
+
+ function PrintConfList($params)
+ {
+ $list =& $this->GetList($params);
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+
+ $list->PerPage = -1;
+ $list->Query();
+ $o = '';
+ $list->GoFirst();
+
+ $tmp_row = Array();
+
+ while (!$list->EOL()) {
+ $rec = $list->getCurrentRecord();
+ $tmp_row[0][$rec['VariableName']] = $rec['VariableValue'];
+ $tmp_row[0][$rec['VariableName'].'_prompt'] = $rec['prompt'];
+ $list->GoNext();
+ }
+
+ $list->Records = $tmp_row;
+
+ $block_params = $this->prepareTagParams($params);
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+ $block_params['module_key'] = $this->Application->GetVar('module_key');
+ $block_params['module_item'] = $this->getModuleItemName();
+ $list->GoFirst();
+
+ return $this->Application->ParseBlock($block_params, 1);
+
+ }
+
+ function ShowRelevance($params)
+ {
+ return $this->Application->GetVar('module_key') != '_';
+ }
+
+ function ConfigValue($params)
+ {
+ return $this->Application->ConfigValue($params['name']);
+ }
+
+ function Error($params)
+ {
+ $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
+ $field = $object->GetDBField($params['id_field']);
+
+ $errors = $this->Application->GetVar('errormsgs');
+ $errors = $errors[$this->getPrefixSpecial()];
+
+ if (isset($errors[$field])) {
+ $msg = $this->Application->Phrase($errors[$field]);
+ }
+ else {
+ $msg = '';
+ }
+
+ return $msg;
+ }
+
+ /**
+ * Allows to show category path of selected module
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CategoryPath($params)
+ {
+ if (!isset($params['cat_id'])) {
+ $params['cat_id'] = $this->ModuleRootCategory( Array() );
+ }
+
+ $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');
+
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ if ($res === false) {
+ // in case if category is deleted
+ return '';
+ }
+ $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);
+ }
+ }
+
+ /**
+ * Shows edit warning in case if module root category changed but not saved
+ *
+ * @param Array $params
+ * @return string
+ */
+ function SaveWarning($params)
+ {
+ $temp_category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($temp_category_id !== false) {
+ return $this->Application->ParseBlock($params);
+ }
+ return '';
+ }
+
+ function ModuleRootCategory($params)
+ {
+ $category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($category_id === false) {
+ $category_id = $this->Application->findModule('Name', $this->Application->GetVar('module'), 'RootCat');
+ }
+ return $category_id;
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/kernel/units/configuration/configuration_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/kernel/units/general/main_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/kernel/units/general/main_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/kernel/units/general/main_event_handler.php (revision 5215)
@@ -0,0 +1,124 @@
+<?php
+
+ class MainEventHandler extends kEventHandler {
+
+
+ /**
+ * Description
+ *
+ * @var kDBConnection
+ * @access public
+ */
+ var $Conn;
+
+ /**
+ * Adds ability to address db connection
+ *
+ * @return kDBEventHandler
+ * @access public
+ */
+ function MainEventHandler()
+ {
+ parent::kBase();
+ $this->Conn =& $this->Application->GetADODBConnection();
+ }
+
+ /**
+ * Created url part for this module
+ *
+ * @param kEvent $event
+ */
+ function BuildEnv(&$event)
+ {
+ $prefix_special = $event->getPrefixSpecial();
+ $url_params = $event->getEventParam('url_params');
+
+ $query_vars = $this->Application->getUnitOption($event->Prefix, 'QueryString');
+
+ //if pass events is off and event is not implicity passed
+ if ( !$event->getEventParam('pass_events') && !isset($url_params[$prefix_special.'_event']) )
+ {
+ $url_params[$prefix_special.'_event'] = ''; // remove event from url if requested
+ //otherwise it will use value from get_var
+ }
+
+ if(!$query_vars) return true;
+
+ $processed_params = Array();
+ foreach($query_vars as $index => $var_name)
+ {
+ //if value passed in params use it, otherwise use current from application
+ $var_name = $prefix_special.'_'.$var_name;
+ $processed_params[$var_name] = isset( $url_params[$var_name] ) ? $url_params[$var_name] : $this->Application->GetVar($var_name);
+ if ( isset($url_params[$var_name]) ) unset( $url_params[$var_name] );
+ }
+
+ $ret = '';
+ $default_language_id = $this->Application->GetDefaultLanguageId();
+ if( $processed_params['m_lang'] != $default_language_id )
+ {
+ $language_name = $this->Application->getCache('language_names', $processed_params['m_lang']);
+ if ($language_name === false) {
+ $sql = 'SELECT PackName
+ FROM '.TABLE_PREFIX.'Language
+ WHERE LanguageId = '.$processed_params['m_lang'];
+ $language_name = $this->Conn->GetOne($sql);
+ $this->Application->setCache('language_names', $processed_params['m_lang'], $language_name);
+ }
+ $ret .= $language_name.'/';
+ }
+
+ $default_theme_id = $this->Application->GetDefaultThemeId();
+ if( $processed_params['m_theme'] != $default_theme_id )
+ {
+ $theme_name = $this->Application->getCache('theme_names', $processed_params['m_theme']);
+ if ($theme_name === false) {
+ $sql = 'SELECT Name
+ FROM '.TABLE_PREFIX.'Theme
+ WHERE ThemeId = '.$processed_params['m_theme'];
+ $theme_name = $this->Conn->GetOne($sql);
+ $this->Application->setCache('theme_names', $processed_params['m_theme'], $theme_name);
+
+ }
+ $ret .= $theme_name.'/';
+ }
+
+ if ($processed_params['m_cat_id'] > 0) {
+ $ret .= $this->Application->getFilename('c', $processed_params['m_cat_id']).'/';
+ }
+
+ $force_page_adding = false;
+ if (getArrayValue($url_params, 'reset'))
+ {
+ unset($url_params['reset']);
+ if ($processed_params['m_cat_id'])
+ {
+ $processed_params['m_cat_page'] = 1;
+ $force_page_adding = true;
+ }
+ }
+
+ if( $processed_params['m_cat_page'] > 1 || $force_page_adding )
+ {
+ $ret = preg_replace('/(.*)\//', '\\1', $ret).'_'.$processed_params['m_cat_page'].'/';
+ }
+
+ $template = getArrayValue($url_params, 't');
+ $category_template = $processed_params['m_cat_id'] ? $this->Application->getCache('category_templates', $processed_params['m_cat_id']) : '';
+
+ // remove template from url if it is category index cached template
+ if ($template == $category_template || strtolower($template) == '__default__') {
+ $template = '';
+ }
+
+ if ($template) {
+ $ret .= $template.'/';
+ }
+ unset($url_params['t']);
+
+ $event->setEventParam('url_params', $url_params);
+ $event->setEventParam('env_string', strtolower($ret) );
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/kernel/units/general/main_event_handler.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/kernel/db/db_connection.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/core/kernel/db/db_connection.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/core/kernel/db/db_connection.php (revision 5215)
@@ -0,0 +1,573 @@
+<?php
+
+ /**
+ * Multi database connection class
+ *
+ */
+ class kDBConnection {
+
+ /**
+ * Current database type
+ *
+ * @var string
+ * @access private
+ */
+ var $dbType = 'mysql';
+
+ /**
+ * Created connection handle
+ *
+ * @var resource
+ * @access private
+ */
+ var $connectionID = null;
+
+ /**
+ * Handle of currenty processed recordset
+ *
+ * @var resource
+ * @access private
+ */
+ var $queryID = null;
+
+ /**
+ * DB type specific function mappings
+ *
+ * @var Array
+ * @access private
+ */
+ var $metaFunctions = Array();
+
+ /**
+ * Function to handle sql errors
+ *
+ * @var string
+ * @access private
+ */
+ var $errorHandler = '';
+
+ /**
+ * Error code
+ *
+ * @var int
+ * @access private
+ */
+ var $errorCode = 0;
+
+ /**
+ * Error message
+ *
+ * @var string
+ * @access private
+ */
+ var $errorMessage = '';
+
+ /**
+ * Defines if database connection
+ * operations should generate debug
+ * information
+ *
+ * @var bool
+ */
+ var $debugMode = false;
+
+ /**
+ * Last query to database
+ *
+ * @var string
+ */
+ var $lastQuery = '';
+
+ /**
+ * Initializes connection class with
+ * db type to used in future
+ *
+ * @param string $dbType
+ * @return DBConnection
+ * @access public
+ */
+ function kDBConnection($dbType, $errorHandler = '')
+ {
+ $this->dbType = $dbType;
+// $this->initMetaFunctions();
+ if (!$errorHandler) {
+ $this->errorHandler = Array(&$this, 'handleError');
+ }
+ else {
+ $this->errorHandler=$errorHandler;
+ }
+ }
+
+ /**
+ * Set's custom error
+ *
+ * @param int $code
+ * @param string $msg
+ * @access public
+ */
+ function setError($code, $msg)
+ {
+ $this->errorCode = $code;
+ $this->errorMessage = $msg;
+ }
+
+ /**
+ * Checks if previous query execution
+ * raised an error.
+ *
+ * @return bool
+ * @access public
+ */
+ function hasError()
+ {
+ return !($this->errorCode == 0);
+ }
+
+ /**
+ * Caches function specific to requested
+ * db type
+ *
+ * @access private
+ */
+ function initMetaFunctions()
+ {
+ $ret = Array();
+ switch ($this->dbType)
+ {
+ case 'mysql':
+ $ret = Array(); // only define functions, that name differs from "dbType_<meta_name>"
+
+ break;
+
+
+ }
+ $this->metaFunctions = $ret;
+ }
+
+ /**
+ * Get's function for specific db type
+ * based on it's meta name
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ */
+ function getMetaFunction($name)
+ {
+ /*if (!isset($this->metaFunctions[$name])) {
+ $this->metaFunctions[$name] = $name;
+ }*/
+
+ return $this->dbType.'_'.$name;
+ }
+
+
+ /**
+ * Try to connect to database server
+ * using specified parameters and set
+ * database to $db if connection made
+ *
+ * @param string $host
+ * @param string $user
+ * @param string $pass
+ * @param string $db
+ * @access public
+ */
+ function Connect($host, $user, $pass, $db, $force_new = false)
+ {
+ $func = $this->getMetaFunction('connect');
+ $this->connectionID = $func($host, $user, $pass, $force_new) or die('Can\'t connect to db');
+ if ($this->connectionID) {
+ $this->setDB($db);
+ $this->showError();
+ }
+ }
+
+ function ReConnect($host, $user, $pass, $db)
+ {
+ $func = $this->getMetaFunction('close');
+ $func($this->connectionID);
+ $this->Connect($host, $user, $pass, $db);
+ }
+
+ /**
+ * Shows error message from previous operation
+ * if it failed
+ *
+ * @access private
+ */
+ function showError($sql = '')
+ {
+ $this->setError(0, ''); // reset error
+ if ($this->connectionID) {
+ $func = $this->getMetaFunction('errno'); $this->errorCode = $func($this->connectionID);
+ if ($this->hasError()) {
+ $func = $this->getMetaFunction('error'); $this->errorMessage = $func($this->connectionID);
+ if (is_array($this->errorHandler)) {
+ $func = $this->errorHandler[1];
+ $ret = $this->errorHandler[0]->$func($this->errorCode, $this->errorMessage, $sql);
+ }
+ else {
+ $func = $this->errorHandler;
+ $ret = $func($this->errorCode,$this->errorMessage,$sql);
+ }
+ if (!$ret) exit;
+ }
+ }
+ }
+
+ /**
+ * Default error handler for sql errors
+ *
+ * @param int $code
+ * @param string $msg
+ * @param string $sql
+ * @return bool
+ * @access private
+ */
+ function handleError($code, $msg, $sql)
+ {
+ echo '<b>Processing SQL</b>: '.$sql.'<br>';
+ echo '<b>Error ('.$code.'):</b> '.$msg.'<br>';
+ return false;
+ }
+
+ /**
+ * Set's database name for connection
+ * to $new_name
+ *
+ * @param string $new_name
+ * @return bool
+ * @access public
+ */
+ function setDB($new_name)
+ {
+ if (!$this->connectionID) return false;
+ $func = $this->getMetaFunction('select_db');
+ return $func($new_name);
+ }
+
+ /**
+ * Returns first field of first line
+ * of recordset if query ok or false
+ * otherwise
+ *
+ * @param string $sql
+ * @param int $offset
+ * @return string
+ * @access public
+ */
+ function GetOne($sql, $offset = 0)
+ {
+ $row = $this->GetRow($sql, $offset);
+ if(!$row) return false;
+
+ return array_shift($row);
+ }
+
+ /**
+ * Returns first row of recordset
+ * if query ok, false otherwise
+ *
+ * @param stirng $sql
+ * @param int $offset
+ * @return Array
+ * @access public
+ */
+ function GetRow($sql, $offset = 0)
+ {
+ $sql .= ' '.$this->getLimitClause($offset, 1);
+ $ret = $this->Query($sql);
+ if(!$ret) return false;
+
+ return array_shift($ret);
+ }
+
+ /**
+ * Returns 1st column of recordset as
+ * one-dimensional array or false otherwise
+ * Optional parameter $key_field can be used
+ * to set field name to be used as resulting
+ * array key
+ *
+ * @param string $sql
+ * @param string $key_field
+ * @return Array
+ * @access public
+ */
+ function GetCol($sql, $key_field = null)
+ {
+ $rows = $this->Query($sql);
+ if (!$rows) return $rows;
+
+ $i = 0; $row_count = count($rows);
+ $ret = Array();
+ if (isset($key_field)) {
+ while ($i < $row_count) {
+ $ret[$rows[$i][$key_field]] = array_shift($rows[$i]);
+ $i++;
+ }
+ }
+ else {
+ while ($i < $row_count) {
+ $ret[] = array_shift($rows[$i]);
+ $i++;
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * Queries db with $sql query supplied
+ * and returns rows selected if any, false
+ * otherwise. Optional parameter $key_field
+ * allows to set one of the query fields
+ * value as key in string array.
+ *
+ * @param string $sql
+ * @param string $key_field
+ * @return Array
+ */
+ function Query($sql, $key_field = null)
+ {
+ $this->lastQuery = $sql;
+ if ($this->debugMode) return $this->debugQuery($sql,$key_field);
+ $query_func = $this->getMetaFunction('query');
+ $this->queryID = $query_func($sql,$this->connectionID);
+ if (is_resource($this->queryID)) {
+ $ret = Array();
+ $fetch_func = $this->getMetaFunction('fetch_assoc');
+ if (isset($key_field)) {
+ while (($row = $fetch_func($this->queryID))) {
+ $ret[$row[$key_field]] = $row;
+ }
+ }
+ else {
+ while (($row = $fetch_func($this->queryID))) {
+ $ret[] = $row;
+ }
+ }
+ $this->Destroy();
+ return $ret;
+ }
+ $this->showError($sql);
+ return false;
+ }
+
+ function ChangeQuery($sql)
+ {
+ $this->Query($sql);
+ return $this->errorCode == 0 ? true : false;
+ }
+
+ function debugQuery($sql, $key_field = null)
+ {
+ global $debugger;
+ $query_func = $this->getMetaFunction('query');
+
+ // set 1st checkpoint: begin
+ $isSkipTable = true;
+ $profileSQLs = defined('DBG_SQL_PROFILE') && DBG_SQL_PROFILE;
+ if ($profileSQLs) {
+ $isSkipTable = isSkipTable($sql);
+ if (!$isSkipTable) {
+ $queryID = $debugger->generateID();
+ $debugger->profileStart('sql_'.$queryID, $debugger->formatSQL($sql));
+ }
+ }
+ // set 1st checkpoint: end
+
+ $this->queryID = $query_func($sql, $this->connectionID);
+
+ if( is_resource($this->queryID) )
+ {
+ $ret = Array();
+ $fetch_func = $this->getMetaFunction('fetch_assoc');
+ if( isset($key_field) )
+ {
+ while( ($row = $fetch_func($this->queryID)) )
+ {
+ $ret[$row[$key_field]] = $row;
+ }
+ }
+ else
+ {
+ while( ($row = $fetch_func($this->queryID)) )
+ {
+ $ret[] = $row;
+ }
+ }
+ // set 2nd checkpoint: begin
+ if(!$isSkipTable) {
+ $debugger->profileFinish('sql_'.$queryID);
+ $debugger->profilerAddTotal('sql', 'sql_'.$queryID);
+ }
+ $this->Destroy();
+ // set 2nd checkpoint: end
+ return $ret;
+ }
+ else {
+ // set 2nd checkpoint: begin
+ if(!$isSkipTable) {
+ $debugger->profileFinish('sql_'.$queryID);
+ $debugger->profilerAddTotal('sql', 'sql_'.$queryID);
+ }
+ // set 2nd checkpoint: end
+ }
+ $this->showError($sql);
+ return false;
+ }
+
+ /**
+ * Free memory used to hold recordset handle
+ *
+ * @access private
+ */
+ function Destroy()
+ {
+ if($this->queryID)
+ {
+ $free_func = $this->getMetaFunction('free_result');
+ $free_func($this->queryID);
+ $this->queryID = null;
+ }
+ }
+
+ /**
+ * Returns auto increment field value from
+ * insert like operation if any, zero otherwise
+ *
+ * @return int
+ * @access public
+ */
+ function getInsertID()
+ {
+ $func = $this->getMetaFunction('insert_id');
+ return $func($this->connectionID);
+ }
+
+ /**
+ * Returns row count affected by last query
+ *
+ * @return int
+ * @access public
+ */
+ function getAffectedRows()
+ {
+ $func = $this->getMetaFunction('affected_rows');
+ return $func($this->connectionID);
+ }
+
+ /**
+ * Returns LIMIT sql clause part for specific db
+ *
+ * @param int $offset
+ * @param int $rows
+ * @return string
+ * @access private
+ */
+ function getLimitClause($offset, $rows)
+ {
+ if(!($rows > 0)) return '';
+
+ switch ($this->dbType) {
+
+ default:
+ return 'LIMIT '.$offset.','.$rows;
+ break;
+ }
+ }
+
+ /**
+ * Correctly quotes a string so that all strings are escaped. We prefix and append
+ * to the string single-quotes.
+ * An example is $db->qstr("Don't bother",magic_quotes_runtime());
+ *
+ * @param s the string to quote
+ * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc().
+ * This undoes the stupidity of magic quotes for GPC.
+ *
+ * @return quoted string to be sent back to database
+ */
+ function qstr($s,$magic_quotes=false)
+ {
+ $replaceQuote = "\\'";
+ if (!$magic_quotes)
+ {
+ if ($replaceQuote[0] == '\\')
+ {
+ // only since php 4.0.5
+ $s = str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
+ }
+ return "'".str_replace("'",$replaceQuote,$s)."'";
+ }
+
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+
+ if($replaceQuote == "\\'") // ' already quoted, no need to change anything
+ {
+ return "'$s'";
+ }
+ else // change \' to '' for sybase/mssql
+ {
+ $s = str_replace('\\\\','\\',$s);
+ return "'".str_replace("\\'",$replaceQuote,$s)."'";
+ }
+ }
+
+ /**
+ * Returns last error code occured
+ *
+ * @return int
+ */
+ function getErrorCode()
+ {
+ return $this->errorCode;
+ }
+
+ /**
+ * Returns last error message
+ *
+ * @return string
+ * @access public
+ */
+ function getErrorMsg()
+ {
+ return $this->errorMessage;
+ }
+
+ function doInsert($fields_hash, $table, $type = 'INSERT')
+ {
+ $fields_sql = '';
+ $values_sql = '';
+ foreach ($fields_hash as $field_name => $field_value) {
+ $fields_sql .= '`'.$field_name.'`,';
+ $values_sql .= $this->qstr($field_value).',';
+ }
+
+ $fields_sql = preg_replace('/(.*),$/', '\\1', $fields_sql);
+ $values_sql = preg_replace('/(.*),$/', '\\1', $values_sql);
+ $sql = strtoupper($type).' INTO `'.$table.'` ('.$fields_sql.') VALUES ('.$values_sql.')';
+
+ return $this->ChangeQuery($sql);
+ }
+
+ function doUpdate($fields_hash, $table, $key_clause)
+ {
+ if (!$fields_hash) return true;
+
+ $fields_sql = '';
+ foreach ($fields_hash as $field_name => $field_value) {
+ $fields_sql .= '`'.$field_name.'` = '.$this->qstr($field_value).',';
+ }
+
+ $fields_sql = preg_replace('/(.*),$/', '\\1', $fields_sql);
+
+ $sql = 'UPDATE `'.$table.'` SET '.$fields_sql.' WHERE '.$key_clause;
+
+ return $this->ChangeQuery($sql);
+ }
+ }
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/core/kernel/db/db_connection.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/configuration/configuration_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_tag_processor.php (revision 5215)
@@ -0,0 +1,210 @@
+<?php
+
+class ConfigurationTagProcessor extends kDBTagProcessor {
+
+
+ function Init($prefix,$special,$event_params=null)
+ {
+ parent::Init($prefix, $special, $event_params);
+ $this->Application->LinkVar('module_key');
+ }
+
+ /**
+ * Prints list content using block specified
+ *
+ * @param Array $params
+ * @return string
+ * @access public
+ */
+ function PrintList($params)
+ {
+ $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';
+ $block_params['IdField'] = $list->IDField;
+
+ $prev_heading = '';
+ $next_block = $params['full_block'];
+ $this->groupRecords($list->Records, 'heading');
+ $field_values = $this->Application->GetVar($this->getPrefixSpecial(true));
+
+ while (!$list->EOL())
+ {
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
+
+ // using 2 blocks for drawing o row in case if current & next record titles match
+ $next_item_prompt = $list->CurrentIndex + 1 < $list->RecordsCount ? $list->Records[$list->CurrentIndex + 1]['prompt'] : '';
+ $this_item_prompt = $list->GetDBField('prompt');
+
+ if ($next_item_prompt == $this_item_prompt) {
+ $curr_block = $params['half_block1'];
+ $next_block = $params['half_block2'];
+ } else {
+ $curr_block = $next_block;
+ $next_block = $params['full_block'];
+ }
+
+ $block_params['name'] = $curr_block;
+
+ $block_params['show_heading'] = ($prev_heading != $list->GetDBField('heading') ) ? 1 : 0;
+
+ // set values from submit if any
+ if ($field_values) {
+ $list->SetDBField('VariableValue', $field_values[$list->GetDBField('VariableName')]['VariableValue']);
+ }
+
+ $o.= $this->Application->ParseBlock($block_params, 1);
+ $prev_heading = $list->GetDBField('heading');
+ $list->GoNext();
+ }
+
+ $this->Application->RemoveVar('ModuleRootCategory');
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ return $o;
+ }
+
+ function getModuleItemName()
+ {
+ $module = $this->Application->GetVar('module');
+ $table = $this->Application->getUnitOption('confs', 'TableName');
+
+ $sql = 'SELECT ConfigHeader
+ FROM '.$table.'
+ WHERE ModuleName = '.$this->Conn->qstr($module);
+ return $this->Conn->GetOne($sql);
+ }
+
+ function PrintConfList($params)
+ {
+ $list =& $this->GetList($params);
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+
+ $list->PerPage = -1;
+ $list->Query();
+ $o = '';
+ $list->GoFirst();
+
+ $tmp_row = Array();
+
+ while (!$list->EOL()) {
+ $rec = $list->getCurrentRecord();
+ $tmp_row[0][$rec['VariableName']] = $rec['VariableValue'];
+ $tmp_row[0][$rec['VariableName'].'_prompt'] = $rec['prompt'];
+ $list->GoNext();
+ }
+
+ $list->Records = $tmp_row;
+
+ $block_params = $this->prepareTagParams($params);
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+ $block_params['module_key'] = $this->Application->GetVar('module_key');
+ $block_params['module_item'] = $this->getModuleItemName();
+ $list->GoFirst();
+
+ return $this->Application->ParseBlock($block_params, 1);
+
+ }
+
+ function ShowRelevance($params)
+ {
+ return $this->Application->GetVar('module_key') != '_';
+ }
+
+ function ConfigValue($params)
+ {
+ return $this->Application->ConfigValue($params['name']);
+ }
+
+ function Error($params)
+ {
+ $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
+ $field = $object->GetDBField($params['id_field']);
+
+ $errors = $this->Application->GetVar('errormsgs');
+ $errors = $errors[$this->getPrefixSpecial()];
+
+ if (isset($errors[$field])) {
+ $msg = $this->Application->Phrase($errors[$field]);
+ }
+ else {
+ $msg = '';
+ }
+
+ return $msg;
+ }
+
+ /**
+ * Allows to show category path of selected module
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CategoryPath($params)
+ {
+ if (!isset($params['cat_id'])) {
+ $params['cat_id'] = $this->ModuleRootCategory( Array() );
+ }
+
+ $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');
+
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $sql = 'SELECT CategoryId, ParentId, '.$ml_formatter->LangFieldName('Name').' AS Name
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ if ($res === false) {
+ // in case if category is deleted
+ return '';
+ }
+ $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);
+ }
+ }
+
+ /**
+ * Shows edit warning in case if module root category changed but not saved
+ *
+ * @param Array $params
+ * @return string
+ */
+ function SaveWarning($params)
+ {
+ $temp_category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($temp_category_id !== false) {
+ return $this->Application->ParseBlock($params);
+ }
+ return '';
+ }
+
+ function ModuleRootCategory($params)
+ {
+ $category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($category_id === false) {
+ $category_id = $this->Application->findModule('Name', $this->Application->GetVar('module'), 'RootCat');
+ }
+ return $category_id;
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/core/units/configuration/configuration_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/core/units/general/main_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.13.2/core/units/general/main_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.13.2/core/units/general/main_event_handler.php (revision 5215)
@@ -0,0 +1,124 @@
+<?php
+
+ class MainEventHandler extends kEventHandler {
+
+
+ /**
+ * Description
+ *
+ * @var kDBConnection
+ * @access public
+ */
+ var $Conn;
+
+ /**
+ * Adds ability to address db connection
+ *
+ * @return kDBEventHandler
+ * @access public
+ */
+ function MainEventHandler()
+ {
+ parent::kBase();
+ $this->Conn =& $this->Application->GetADODBConnection();
+ }
+
+ /**
+ * Created url part for this module
+ *
+ * @param kEvent $event
+ */
+ function BuildEnv(&$event)
+ {
+ $prefix_special = $event->getPrefixSpecial();
+ $url_params = $event->getEventParam('url_params');
+
+ $query_vars = $this->Application->getUnitOption($event->Prefix, 'QueryString');
+
+ //if pass events is off and event is not implicity passed
+ if ( !$event->getEventParam('pass_events') && !isset($url_params[$prefix_special.'_event']) )
+ {
+ $url_params[$prefix_special.'_event'] = ''; // remove event from url if requested
+ //otherwise it will use value from get_var
+ }
+
+ if(!$query_vars) return true;
+
+ $processed_params = Array();
+ foreach($query_vars as $index => $var_name)
+ {
+ //if value passed in params use it, otherwise use current from application
+ $var_name = $prefix_special.'_'.$var_name;
+ $processed_params[$var_name] = isset( $url_params[$var_name] ) ? $url_params[$var_name] : $this->Application->GetVar($var_name);
+ if ( isset($url_params[$var_name]) ) unset( $url_params[$var_name] );
+ }
+
+ $ret = '';
+ $default_language_id = $this->Application->GetDefaultLanguageId();
+ if( $processed_params['m_lang'] != $default_language_id )
+ {
+ $language_name = $this->Application->getCache('language_names', $processed_params['m_lang']);
+ if ($language_name === false) {
+ $sql = 'SELECT PackName
+ FROM '.TABLE_PREFIX.'Language
+ WHERE LanguageId = '.$processed_params['m_lang'];
+ $language_name = $this->Conn->GetOne($sql);
+ $this->Application->setCache('language_names', $processed_params['m_lang'], $language_name);
+ }
+ $ret .= $language_name.'/';
+ }
+
+ $default_theme_id = $this->Application->GetDefaultThemeId();
+ if( $processed_params['m_theme'] != $default_theme_id )
+ {
+ $theme_name = $this->Application->getCache('theme_names', $processed_params['m_theme']);
+ if ($theme_name === false) {
+ $sql = 'SELECT Name
+ FROM '.TABLE_PREFIX.'Theme
+ WHERE ThemeId = '.$processed_params['m_theme'];
+ $theme_name = $this->Conn->GetOne($sql);
+ $this->Application->setCache('theme_names', $processed_params['m_theme'], $theme_name);
+
+ }
+ $ret .= $theme_name.'/';
+ }
+
+ if ($processed_params['m_cat_id'] > 0) {
+ $ret .= $this->Application->getFilename('c', $processed_params['m_cat_id']).'/';
+ }
+
+ $force_page_adding = false;
+ if (getArrayValue($url_params, 'reset'))
+ {
+ unset($url_params['reset']);
+ if ($processed_params['m_cat_id'])
+ {
+ $processed_params['m_cat_page'] = 1;
+ $force_page_adding = true;
+ }
+ }
+
+ if( $processed_params['m_cat_page'] > 1 || $force_page_adding )
+ {
+ $ret = preg_replace('/(.*)\//', '\\1', $ret).'_'.$processed_params['m_cat_page'].'/';
+ }
+
+ $template = getArrayValue($url_params, 't');
+ $category_template = $processed_params['m_cat_id'] ? $this->Application->getCache('category_templates', $processed_params['m_cat_id']) : '';
+
+ // remove template from url if it is category index cached template
+ if ($template == $category_template || strtolower($template) == '__default__') {
+ $template = '';
+ }
+
+ if ($template) {
+ $ret .= $template.'/';
+ }
+ unset($url_params['t']);
+
+ $event->setEventParam('url_params', $url_params);
+ $event->setEventParam('env_string', strtolower($ret) );
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.13.2/core/units/general/main_event_handler.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