Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 4:07 PM

in-portal

This file is larger than 256 KB, so syntax highlighting was skipped.
Index: branches/RC/core/kernel/utility/formatters/multilang_formatter.php
===================================================================
--- branches/RC/core/kernel/utility/formatters/multilang_formatter.php (revision 11759)
+++ branches/RC/core/kernel/utility/formatters/multilang_formatter.php (revision 11760)
@@ -1,161 +1,166 @@
<?php
class kMultiLanguage extends kFormatter
{
/**
* Returns ML field equivalent to field name specifed
*
* @param string $field_name
* @param bool $from_primary use primary/current language for name custruction
* @return string
*/
function LangFieldName($field_name, $from_primary = false)
{
if (preg_match('/^l[0-9]+_/', $field_name)) return $field_name;
$lang = $from_primary ? $this->Application->GetDefaultLanguageId() : $this->Application->GetVar('m_lang');
if (!$lang || ($lang == 'default')) {
$lang = $this->Application->GetDefaultLanguageId();
}
return 'l'.$lang.'_'.$field_name;
}
function PrepareOptions($field_name, &$field_options, &$object)
{
if (getArrayValue($object->Fields, $field_name, 'master_field')) return;
$lang_field_name = $this->LangFieldName($field_name);
//substitude title field
$title_field = $this->Application->getUnitOption($object->Prefix, 'TitleField');
if ($title_field == $field_name) {
$this->Application->setUnitOption($object->Prefix, 'TitleField', $lang_field_name);
}
//substitude fields
$fields = $this->Application->getUnitOption($object->Prefix, 'Fields');
if ( isset($fields[$field_name]) ) {
$fields[$lang_field_name] = $fields[$field_name];
$fields[$lang_field_name]['master_field'] = $field_name;
$fields[$lang_field_name]['error_field'] = $field_name;
$object->Fields[$lang_field_name] = $fields[$lang_field_name];
$fields[$field_name]['required'] = false;
$object->Fields[$field_name]['required'] = false;
$object->VirtualFields[$field_name] = $object->Fields[$field_name];
}
$this->Application->setUnitOption($object->Prefix, 'Fields', $fields);
//substitude virtual fields
$virtual_fields = $this->Application->getUnitOption($object->Prefix, 'VirtualFields');
if ( isset($virtual_fields[$field_name]) ) {
$virtual_fields[$lang_field_name] = $virtual_fields[$field_name];
$virtual_fields[$lang_field_name]['master_field'] = $field_name;
$object->VirtualFields[$lang_field_name] = $virtual_fields[$lang_field_name];
$virtual_fields[$field_name]['required'] = false;
$object->VirtualFields[$field_name]['required'] = false;
}
$this->Application->setUnitOption($object->Prefix, 'VirtualFields', $virtual_fields);
//substitude grid fields
$grids = $this->Application->getUnitOption($object->Prefix, 'Grids', Array());
foreach ($grids as $name => $grid) {
if ( getArrayValue($grid, 'Fields', $field_name) ) {
array_rename_key($grids[$name]['Fields'], $field_name, $lang_field_name);
}
// update sort fields - used for sorting and filtering in SQLs
foreach ($grid['Fields'] as $grid_fld_name => $fld_options) {
if (isset($fld_options['sort_field']) && $fld_options['sort_field'] == $field_name) {
$grids[$name]['Fields'][$grid_fld_name]['sort_field'] = $lang_field_name;
}
}
}
$this->Application->setUnitOption($object->Prefix, 'Grids', $grids);
//substitude default sortings
$sortings = $this->Application->getUnitOption($object->Prefix, 'ListSortings', Array());
foreach ($sortings as $special => $the_sortings) {
if (isset($the_sortings['ForcedSorting'])) {
array_rename_key($sortings[$special]['ForcedSorting'], $field_name, $lang_field_name);
}
if (isset($the_sortings['Sorting'])) {
array_rename_key($sortings[$special]['Sorting'], $field_name, $lang_field_name);
}
}
$this->Application->setUnitOption($object->Prefix, 'ListSortings', $sortings);
//TODO: substitude possible language-fields sortings after changing language
}
/*function UpdateSubFields($field, $value, &$options, &$object)
{
}
*/
/**
* Checks, that field value on primary language is set
*
* @param string $field
* @param mixed $value
* @param Array $options
* @param kDBItem $object
*/
function UpdateMasterFields($field, $value, &$options, &$object)
{
$master_field = array_key_exists('master_field', $options) ? $options['master_field'] : false;
if (!$master_field) {
return ;
}
// moved here from Parse, because at Parse time not all of the fields may be set - this is extremly actual, when working with PopulateMlFields mode
$lang = $this->Application->GetVar('m_lang');
$def_lang = $this->Application->GetDefaultLanguageId();
if (!$this->Application->GetVar('allow_translation') && ($lang != $def_lang) && getArrayValue($options, 'required')) {
$def_lang_field = 'l' . $def_lang . '_' . $master_field;
if ( !$object->ValidateRequired($def_lang_field, $options) ) {
$object->SetError($master_field, 'primary_lang_required');
if (array_key_exists($def_lang_field, $object->Fields)) {
$object->SetError($def_lang_field, 'primary_lang_required');
}
}
}
}
function Format($value, $field_name, &$object, $format=null)
{
$master_field = isset($object->Fields[$field_name]['master_field']) ? $object->Fields[$field_name]['master_field'] : false;
if (!$master_field) { // if THIS field is master it does NOT have reference to it's master_field
$lang = $this->Application->GetVar('m_lang');
$value = $object->GetDBField('l'.$lang.'_'.$field_name); //getting value of current language
$master_field = $field_name; // THIS is master_field
}
$options = $object->GetFieldOptions($field_name);
$format = isset($format) ? $format : ( isset($options['format']) ? $options['format'] : null);
- if ( $value == '' && $format != 'no_default') { // try to get default language value
+ // use strpos, becase 2 comma-separated formats could be specified
+ if ($value == '' && strpos($format, 'no_default') === false) { // try to get default language value
$def_lang_value = $object->GetDBField('l'.$this->Application->GetDefaultLanguageId().'_'.$master_field);
- if ($def_lang_value == '') return NULL;
- return $def_lang_value; //return value from default language
+ if ($def_lang_value == '') {
+ return NULL;
+ }
+
+ return $this->_replaceFCKLinks($def_lang_value, $options, $format); //return value from default language
}
- return $value;
+
+ return $this->_replaceFCKLinks($value, $options, $format);
}
/**
* Performs required field check on primary language
*
* @param mixed $value
* @param string $field_name
* @param kDBItem $object
* @return string
*/
function Parse($value, $field_name, &$object)
{
if ($value == '') return NULL;
return $value;
}
}
\ No newline at end of file
Index: branches/RC/core/kernel/utility/formatters/formatter.php
===================================================================
--- branches/RC/core/kernel/utility/formatters/formatter.php (revision 11759)
+++ branches/RC/core/kernel/utility/formatters/formatter.php (revision 11760)
@@ -1,188 +1,240 @@
<?php
class kFormatter extends kBase {
+ /**
+ * Reference to category helper
+ *
+ * @var CategoryHelper
+ */
+ var $_categoryHelper = null;
+
+ function kFormatter()
+ {
+ parent::kBase();
+
+ $this->_categoryHelper =& $this->Application->recallObject('CategoryHelper');
+ }
+
+ /**
+ * Replace FCK links like "@@ID@@" to real page urls, when "using_fck" option is set.
+ *
+ * @param string $text
+ * @param Array $options
+ * @param string $format
+ * @return string
+ */
+ function _replaceFCKLinks(&$value, $options, $format = null)
+ {
+ if ((isset($format) && strpos($format, 'fck_ready') !== false) || (!array_key_exists('using_fck', $options) || !$options['using_fck'])) {
+ // in textarea, where fck will be used OR not using fck
+ return $value;
+ }
+
+ return $this->_categoryHelper->replacePageIds($value);
+ }
/**
* Convert's value to match type from config
*
* @param mixed $value
* @param Array $options
* @return mixed
* @access protected
*/
function TypeCast($value, $options)
{
$ret = true;
if( isset($options['type']) )
{
$field_type = $options['type'];
if ($field_type == 'numeric') {
trigger_error('Invalid field type <strong>'.$field_type.'</strong> (in TypeCast method), please use <strong>float</strong> instead', E_USER_NOTICE);
$field_type = 'float';
}
$type_ok = preg_match('#int|integer|double|float|real|numeric|string#', $field_type);
if ($field_type == 'string') {
if (!$this->Application->IsAdmin() && isset($options['allow_html']) && $options['allow_html']) {
// this allows to revert htmlspecialchars call for each field submitted on front-end
$value = unhtmlentities($value);
}
return $value;
}
static $comma = null;
static $thousands = null;
if (is_null($comma) || is_null($thousands)) {
$lang =& $this->Application->recallObject('lang.current');
$comma = $lang->GetDBField('DecimalPoint');
$thousands = $lang->GetDBField('ThousandSep');
}
$value = str_replace($thousands, '', $value);
$value = str_replace($comma, '.', $value);
if ($value != '' && $type_ok)
{
$ret = is_numeric($value);
if($ret)
{
$f = 'is_'.$field_type;
settype($value, $field_type);
$ret = $f($value);
}
}
}
return $ret ? $value : false;
}
function TypeCastArray($src, &$object)
{
$dst = array();
foreach ($src as $id => $row) {
$tmp_row = array();
foreach ($row as $fld => $value) {
$tmp_row[$fld] = $this->TypeCast($value, $object->Fields[$fld]);
}
$dst[$id] = $tmp_row;
}
return $dst;
}
//function Format($value, $options, &$errors)
- function Format($value, $field_name, &$object, $format=null)
+ function Format($value, $field_name, &$object, $format = null)
{
- if ( is_null($value) ) return '';
+ if ( is_null($value) ) {
+ return '';
+ }
$options = $object->GetFieldOptions($field_name);
- if ( isset($format) ) $options['format'] = $format;
- $tc_value = $value; // $this->TypeCast($value,$options);
- if( ($tc_value === false) || ("$tc_value" != "$value") ) return $value; // for leaving badly formatted date on the form
+ if (!isset($format) && array_key_exists('format', $options)) {
+ $format = $options['format'];
+ }
- if (isset($options['format'])) {
- $tc_value = sprintf($options['format'], $tc_value);
+ if ($value === false) {
+ // used ?
+ return $value; // for leaving badly formatted date on the form
+ }
+
+ $original_format = $format;
+ if (isset($format)) {
+ if (strpos($format, 'fck_ready') !== false) {
+ $format = trim(str_replace('fck_ready', '', $format), ';');
+ }
+ }
+
+ if (isset($format) && $format) {
+ $value = sprintf($format, $value);
}
if (preg_match('#int|integer|double|float|real|numeric#', $options['type'])) {
$lang =& $this->Application->recallObject('lang.current');
- return $lang->formatNumber($tc_value);
+ return $lang->formatNumber($value);
+ }
+ elseif ($options['type'] == 'string') {
+ $value = $this->_replaceFCKLinks($value, $options, $original_format);
}
- return $tc_value;
+ return $value;
}
/**
* Performs basic type validation on form field value
*
* @param mixed $value
* @param string $field_name
* @param kDBItem $object
* @return mixed
*/
function Parse($value, $field_name, &$object)
{
- if ($value == '') return NULL;
+ if ($value == '') {
+ return NULL;
+ }
$options = $object->GetFieldOptions($field_name);
$tc_value = $this->TypeCast($value,$options);
- if($tc_value === false) return $value; // for leaving badly formatted date on the form
+ if ($tc_value === false) {
+ return $value; // for leaving badly formatted date on the form
+ }
if(isset($options['type'])) {
if (preg_match('#double|float|real|numeric#', $options['type'])) {
$tc_value = str_replace(',', '.', $tc_value);
}
}
if (isset($options['regexp'])) {
if (!preg_match($options['regexp'], $value)) {
$object->SetError($field_name, 'invalid_format');
}
}
return $tc_value;
}
function HumanFormat($format)
{
return $format;
}
/**
* The method is supposed to alter config options or cofigure object in some way based on its usage of formatters
* The methods is called for every field with formatter defined when configuring item.
* Could be used for adding additional VirtualFields to an object required by some special Formatter
*
* @param string $field_name
* @param array $field_options
* @param kDBBase $object
*/
function PrepareOptions($field_name, &$field_options, &$object)
{
}
/**
* Used for split fields like timestamp -> date, time
* Called from DBItem to update sub fields values after loading item
*
* @param unknown_type $field
* @param unknown_type $value
* @param unknown_type $options
* @param unknown_type $object
*/
function UpdateSubFields($field, $value, &$options, &$object)
{
}
/**
* Used for split fields like timestamp -> date, time
* Called from DBItem Validate (before validation) to get back master field value from its sub_fields
*
* @param string $field
* @param mixed $value
* @param Array $options
* @param kDBItem $object
*/
function UpdateMasterFields($field, $value, &$options, &$object)
{
}
/* function GetErrorMsg($pseudo_error, $options)
{
if ( isset($options['error_msgs'][$pseudo_error]) ) {
return $options['error_msgs'][$pseudo_error];
}
else {
return $this->ErrorMsgs[$pseudo_error];
}
}*/
function GetSample($field, &$options, &$object)
{
if (isset($options['sample_value'])) return $options['sample_value'];
}
}
\ No newline at end of file
Index: branches/RC/core/kernel/db/db_tag_processor.php
===================================================================
--- branches/RC/core/kernel/db/db_tag_processor.php (revision 11759)
+++ branches/RC/core/kernel/db/db_tag_processor.php (revision 11760)
@@ -1,2511 +1,2515 @@
<?php
class kDBTagProcessor extends TagProcessor {
/**
* Description
*
* @var kDBConnection
* @access public
*/
var $Conn;
function kDBTagProcessor()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
/**
* Returns true if "new" button was pressed in toolbar
*
* @param Array $params
* @return bool
*/
function IsNewMode($params)
{
$object =& $this->getObject($params);
return $object->GetID() <= 0;
}
/**
* Returns view menu name for current prefix
*
* @param Array $params
* @return string
*/
function GetItemName($params)
{
$item_name = $this->Application->getUnitOption($this->Prefix, 'ViewMenuPhrase');
return $this->Application->Phrase($item_name);
}
function ViewMenu($params)
{
$block_params = $params;
unset($block_params['block']);
$block_params['name'] = $params['block'];
$list =& $this->GetList($params);
$block_params['PrefixSpecial'] = $list->getPrefixSpecial();
return $this->Application->ParseBlock($block_params);
}
function SearchKeyword($params)
{
$list =& $this->GetList($params);
return $this->Application->RecallVar($list->getPrefixSpecial().'_search_keyword');
}
/**
* Draw filter menu content (for ViewMenu) based on filters defined in config
*
* @param Array $params
* @return string
*/
function DrawFilterMenu($params)
{
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['spearator_block'];
$separator = $this->Application->ParseBlock($block_params);
$filter_menu = $this->Application->getUnitOption($this->Prefix,'FilterMenu');
if (!$filter_menu) {
trigger_error('<span class="debug_error">no filters defined</span> for prefix <b>'.$this->Prefix.'</b>, but <b>DrawFilterMenu</b> tag used', E_USER_WARNING);
return '';
}
// Params: label, filter_action, filter_status
$block_params['name'] = $params['item_block'];
$view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
if ($view_filter === false) {
$event_params = Array ('prefix' => $this->Prefix, 'special' => $this->Special, 'name' => 'OnRemoveFilters');
$this->Application->HandleEvent( new kEvent($event_params) );
$view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
}
$view_filter = unserialize($view_filter);
$filters = Array();
$prefix_special = $this->getPrefixSpecial();
foreach ($filter_menu['Filters'] as $filter_key => $filter_params) {
$group_params = isset($filter_params['group_id']) ? $filter_menu['Groups'][ $filter_params['group_id'] ] : Array();
if (!isset($group_params['element_type'])) {
$group_params['element_type'] = 'checkbox';
}
if (!$filter_params) {
$filters[] = $separator;
continue;
}
$block_params['label'] = addslashes( $this->Application->Phrase($filter_params['label']) );
if (getArrayValue($view_filter,$filter_key)) {
$submit = 0;
if (isset($params['old_style'])) {
$status = $group_params['element_type'] == 'checkbox' ? 1 : 2;
}
else {
$status = $group_params['element_type'] == 'checkbox' ? '[\'img/check_on.gif\']' : '[\'img/menu_dot.gif\']';
}
}
else {
$submit = 1;
$status = 'null';
}
$block_params['filter_action'] = 'set_filter("'.$prefix_special.'","'.$filter_key.'","'.$submit.'",'.$params['ajax'].');';
$block_params['filter_status'] = $status; // 1 - checkbox, 2 - radio, 0 - no image
$filters[] = $this->Application->ParseBlock($block_params);
}
return implode('', $filters);
}
/**
* Draws auto-refresh submenu in View Menu.
*
* @param Array $params
* @return string
*/
function DrawAutoRefreshMenu($params)
{
$refresh_intervals = $this->Application->ConfigValue('AutoRefreshIntervals');
if (!$refresh_intervals) {
trigger_error('<span class="debug_error">no filters defined</span> for prefix <strong>'.$this->Prefix.'</strong>, but <strong>DrawAutoRefreshMenu</strong> tag used', E_USER_WARNING);
return '';
}
$refresh_intervals = explode(',', $refresh_intervals);
$view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view');
$current_refresh_interval = $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_refresh_interval.'.$view_name);
if ($current_refresh_interval === false) {
// if no interval was selected before, then choose 1st interval
$current_refresh_interval = $refresh_intervals[0];
}
$ret = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
foreach ($refresh_intervals as $refresh_interval) {
$block_params['label'] = $this->_formatInterval($refresh_interval);
$block_params['refresh_interval'] = $refresh_interval;
$block_params['selected'] = $current_refresh_interval == $refresh_interval;
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Tells, that current grid is using auto refresh
*
* @param Array $params
* @return bool
*/
function UseAutoRefresh($params)
{
$view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view');
return $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_auto_refresh.'.$view_name);
}
/**
* Returns current grid refresh interval
*
* @param Array $params
* @return bool
*/
function AutoRefreshInterval($params)
{
$view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view');
return $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_refresh_interval.'.$view_name);
}
/**
* Formats time interval using given text for hours and minutes
*
* @param int $intervalmMinutes
* @param string $hour_text Text for hours
* @param string $min_text Text for minutes
* @return unknown
*/
function _formatInterval($interval, $hour_text = 'h', $min_text = 'min')
{
// 65
$minutes = $interval % 60;
$hours = ($interval - $minutes) / 60;
$ret = '';
if ($hours) {
$ret .= $hours.$hour_text.' ';
}
if ($minutes) {
$ret .= $minutes.$min_text;
}
return $ret;
}
function IterateGridFields($params)
{
$mode = $params['mode'];
$def_block = isset($params['block']) ? $params['block'] : '';
$force_block = isset($params['force_block']) ? $params['force_block'] : false;
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$grid_config = $grids[$params['grid']]['Fields'];
$picker_helper =& $this->Application->RecallObject('ColumnPickerHelper');
/* @var $picker_helper kColumnPickerHelper */
$picker_helper->ApplyPicker($this->getPrefixSpecial(), $grid_config, $params['grid']);
if ($mode == 'fields') {
return "'".join("','", array_keys($grid_config))."'";
}
$std_params['pass_params'] = 'true';
$std_params['PrefixSpecial'] = $this->getPrefixSpecial();
$object =& $this->GetList($params);
$o = '';
$i = 0;
foreach ($grid_config as $field => $options) {
$i++;
$block_params = Array();
$block_params['name'] = $force_block ? $force_block : (isset($options[$mode.'_block']) ? $options[$mode.'_block'] : $def_block);
$block_params['field'] = $field;
$block_params['sort_field'] = isset($options['sort_field']) ? $options['sort_field'] : $field;
$block_params['filter_field'] = isset($options['filter_field']) ? $options['filter_field'] : $field;
$w = $picker_helper->GetWidth($field);
if ($w) $options['width'] = $w;
/*if (isset($options['filter_width'])) {
$block_params['filter_width'] = $options['filter_width'];
}
elseif (isset($options['width'])) {
if (isset($options['filter_block']) && preg_match('/range/', $options['filter_block'])) {
if ($options['width'] < 60) {
$options['width'] = 60;
$block_params['filter_width'] = 20;
}
else {
$block_params['filter_width'] = $options['width'] - 40;
}
}
else {
$block_params['filter_width'] = max($options['width']-10, 20);
}
}*/
/*if (isset($block_params['filter_width'])) $block_params['filter_width'] .= 'px';
if (isset($options['filter_block']) && preg_match('/range/', $options['filter_block'])) {
$block_params['filter_width'] = '20px';
}
else {
$block_params['filter_width'] = '97%';
// $block_params['filter_width'] = max($options['width']-10, 20);
}*/
$field_options = $object->GetFieldOptions($field);
if (array_key_exists('use_phrases', $field_options)) {
$block_params['use_phrases'] = $field_options['use_phrases'];
}
$block_params['is_last'] = ($i == count($grid_config));
$block_params = array_merge($std_params, $options, $block_params);
$o.= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
function PickerCRC($params)
{
/* @var $picker_helper kColumnPickerHelper */
$picker_helper =& $this->Application->RecallObject('ColumnPickerHelper');
$picker_helper->SetGridName($params['grid']);
$data = $picker_helper->LoadColumns($this->getPrefixSpecial());
return $data['crc'];
}
function FreezerPosition($params)
{
/* @var $picker_helper kColumnPickerHelper */
$picker_helper =& $this->Application->RecallObject('ColumnPickerHelper');
$picker_helper->SetGridName($params['grid']);
$data = $picker_helper->LoadColumns($this->getPrefixSpecial());
$freezer_pos = array_search('__FREEZER__', $data['order']);
return $freezer_pos === false || in_array('__FREEZER__', $data['hidden_fields']) ? 1 : ++$freezer_pos;
}
function GridFieldsCount($params)
{
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
$grid_config = $grids[$params['grid']]['Fields'];
return count($grid_config);
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($params)
{
$params['no_table'] = 1;
return $this->PrintList2($params);
}
function InitList($params)
{
$list_name = isset($params['list_name']) ? $params['list_name'] : '';
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
if( !getArrayValue($names_mapping, $this->Prefix, $list_name) )
{
$list =& $this->GetList($params);
}
}
function BuildListSpecial($params)
{
return $this->Special;
}
/**
* Returns key, that identifies each list on template (used internally, not tag)
*
* @param Array $params
* @return string
*/
function getUniqueListKey($params)
{
$types = $this->SelectParam($params, 'types');
$except = $this->SelectParam($params, 'except');
$list_name = $this->SelectParam($params, 'list_name');
if (!$list_name) {
$list_name = $this->Application->Parser->GetParam('list_name');
}
return $types.$except.$list_name;
}
/**
* Enter description here...
*
* @param Array $params
* @return kDBList
*/
function &GetList($params)
{
$list_name = $this->SelectParam($params, 'list_name,name');
if (!$list_name) {
$list_name = $this->Application->Parser->GetParam('list_name');
}
$requery = isset($params['requery']) && $params['requery'];
if ($list_name && !$requery){
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
$special = is_array($names_mapping) && isset($names_mapping[$this->Prefix]) && isset($names_mapping[$this->Prefix][$list_name]) ? $names_mapping[$this->Prefix][$list_name] : false;
// $special = getArrayValue($names_mapping, $this->Prefix, $list_name);
if(!$special)
{
$special = $this->BuildListSpecial($params);
}
}
else
{
$special = $this->BuildListSpecial($params);
}
$prefix_special = rtrim($this->Prefix.'.'.$special, '.');
$params['skip_counting'] = true;
$list =& $this->Application->recallObject( $prefix_special, $this->Prefix.'_List', $params);
/* @var $list kDBList */
if ($requery) {
$this->Application->HandleEvent($an_event, $prefix_special.':OnListBuild', $params);
}
if (array_key_exists('offset', $params)) {
$list->Offset += $params['offset']; // apply custom offset
}
$list->Query($requery);
if (array_key_exists('offset', $params)) {
$list->Offset -= $params['offset']; // remove custom offset
}
$this->Special = $special;
if ($list_name) {
$names_mapping[$this->Prefix][$list_name] = $special;
$this->Application->SetVar('NamesToSpecialMapping', $names_mapping);
}
return $list;
}
function ListMarker($params)
{
$list =& $this->GetList($params);
$ret = $list->getPrefixSpecial();
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
/**
* Prepares name for field with event in it (used only on front-end)
*
* @param Array $params
* @return string
*/
function SubmitName($params)
{
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
return 'events['.$prefix_special.']['.$params['event'].']';
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList2($params)
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
if ($per_page !== false) $params['per_page'] = $per_page;
$list =& $this->GetList($params);
$o = '';
$direction = (isset($params['direction']) && $params['direction']=="H")?"H":"V";
$columns = (isset($params['columns'])) ? $params['columns'] : 1;
$id_field = (isset($params['id_field'])) ? $params['id_field'] : $this->Application->getUnitOption($this->Prefix, 'IDField');
if ($columns > 1 && $direction == 'V') {
$records_left = array_splice($list->Records, $list->SelectedCount); // because we have 1 more record for "More..." link detection (don't need to sort it)
$list->Records = $this->LinearToVertical($list->Records, $columns, $list->GetPerPage());
$list->Records = array_merge($list->Records, $records_left);
}
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$block_params['column_width'] = $params['column_width'] = 100 / $columns;
$block_start_row_params = $this->prepareTagParams($params);
$block_start_row_params['name'] = $this->SelectParam($params, 'row_start_render_as,block_row_start,row_start_block');
$block_end_row_params=$this->prepareTagParams($params);
$block_end_row_params['name'] = $this->SelectParam($params, 'row_end_render_as,block_row_end,row_end_block');
$block_empty_cell_params = $this->prepareTagParams($params);
$block_empty_cell_params['name'] = $this->SelectParam($params, 'empty_cell_render_as,block_empty_cell,empty_cell_block');
$i=0;
$backup_id=$this->Application->GetVar($this->Prefix."_id");
$displayed = array();
$column_number = 1;
$cache_mod_rw = $this->Application->getUnitOption($this->Prefix, 'CacheModRewrite') && $this->Application->RewriteURLs();
$limit = isset($params['limit']) ? $params['limit'] : false;
while (!$list->EOL() && (!$limit || $i<$limit))
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
$this->Application->SetVar( $this->Prefix.'_id', $list->GetDBField($id_field) );
$block_params['is_last'] = ($i == $list->SelectedCount - 1);
$block_params['last_row'] = ($i + (($i+1) % $columns) >= $list->SelectedCount - 1);
$block_params['not_last'] = !$block_params['is_last']; // for front-end
if ($cache_mod_rw) {
if ($this->Prefix == 'c') {
// for listing subcategories in category
$this->Application->setCache('filenames', $this->Prefix.'_'.$list->GetDBField($id_field), $list->GetDBField('NamedParentPath'));
$this->Application->setCache('category_tree', $list->GetDBField($id_field), $list->GetDBField('TreeLeft') . ';' . $list->GetDBField('TreeRight'));
} else {
// for listing items in category
$this->Application->setCache('filenames', 'c_'.$list->GetDBField('CategoryId'), $list->GetDBField('CategoryFilename'));
$this->Application->setCache('filenames', $this->Prefix.'_'.$list->GetDBField($id_field), $list->GetDBField('Filename'));
}
}
if ($i % $columns == 0) {
// record in this iteration is first in row, then open row
$column_number = 1;
$o.= $block_start_row_params['name'] ?
$this->Application->ParseBlock($block_start_row_params, 1) :
(!isset($params['no_table']) ? '<tr>' : '');
}
else {
$column_number++;
}
$block_params['first_col'] = $column_number == 1 ? 1 : 0;
$block_params['last_col'] = $column_number == $columns ? 1 : 0;
$block_params['column_number'] = $column_number;
$block_params['num'] = ($i+1);
$this->PrepareListElementParams($list, $block_params); // new, no need to rewrite PrintList
$o.= $this->Application->ParseBlock($block_params, 1);
array_push($displayed, $list->GetDBField($id_field));
if($direction == 'V' && $list->SelectedCount % $columns > 0 && $column_number == ($columns - 1) && ceil(($i + 1) / $columns) > $list->SelectedCount % ceil($list->SelectedCount / $columns)) {
// if vertical output, then draw empty cells vertically, not horizontally
$o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : '<td>&nbsp;</td>';
$i++;
}
if (($i + 1) % $columns == 0) {
// record in next iteration is first in row too, then close this row
$o.= $block_end_row_params['name'] ?
$this->Application->ParseBlock($block_end_row_params, 1) :
(!isset($params['no_table']) ? '</tr>' : '');
}
$list->GoNext();
$i++;
}
// append empty cells in place of missing cells in last row
while ($i % $columns != 0) {
// until next cell will be in new row append empty cells
$o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : '<td>&nbsp;</td>';
if (($i+1) % $columns == 0) {
// record in next iteration is first in row too, then close this row
$o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params, 1) : '</tr>';
}
$i++;
}
$cur_displayed = $this->Application->GetVar($this->Prefix.'_displayed_ids');
if (!$cur_displayed) {
$cur_displayed = Array();
}
else {
$cur_displayed = explode(',', $cur_displayed);
}
$displayed = array_unique(array_merge($displayed, $cur_displayed));
$this->Application->SetVar($this->Prefix.'_displayed_ids', implode(',',$displayed));
$this->Application->SetVar( $this->Prefix.'_id', $backup_id);
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
if (isset($params['more_link_render_as'])) {
$block_params = $params;
$params['render_as'] = $params['more_link_render_as'];
$o .= $this->MoreLink($params);
}
return $o;
}
/**
* Allows to modify block params & current list record before PrintList parses record
*
* @param kDBList $object
* @param Array $block_params
*/
function PrepareListElementParams(&$object, &$block_params)
{
// $fields_hash =& $object->getCurrentRecord();
}
function MoreLink($params)
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
if ($per_page !== false) $params['per_page'] = $per_page;
$list =& $this->GetList($params);
if ($list->PerPage < $list->RecordsCount) {
$block_params = array();
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
return $this->Application->ParseBlock($block_params, 1);
}
}
function NotLastItem($params)
{
$object =& $this->getList($params); // maybe we should use $this->GetList($params) instead
return ($object->CurrentIndex < min($object->PerPage == -1 ? $object->RecordsCount : $object->PerPage, $object->RecordsCount) - 1);
}
function PageLink($params)
{
$t = isset($params['template']) ? $params['template'] : '';
unset($params['template']);
if (!$t) $t = $this->Application->GetVar('t');
if (isset($params['page'])) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $params['page']);
unset($params['page']);
}
if (!isset($params['pass'])) {
$params['pass'] = 'm,'.$this->getPrefixSpecial();
}
return $this->Application->HREF($t, '', $params);
}
function ColumnWidth($params)
{
$columns = $this->Application->Parser->GetParam('columns');
return round(100/$columns).'%';
}
/**
* Append prefix and special to tag
* params (get them from tagname) like
* they were really passed as params
*
* @param Array $tag_params
* @return Array
* @access protected
*/
function prepareTagParams($tag_params = Array())
{
/*if (isset($tag_params['list_name'])) {
$list =& $this->GetList($tag_params);
$this->Init($list->Prefix, $list->Special);
}*/
$ret = $tag_params;
$ret['Prefix'] = $this->Prefix;
$ret['Special'] = $this->Special;
$ret['PrefixSpecial'] = $this->getPrefixSpecial();
return $ret;
}
function GetISO($currency)
{
if ($currency == 'selected') {
$iso = $this->Application->RecallVar('curr_iso');
}
elseif ($currency == 'primary' || $currency == '') {
$iso = $this->Application->GetPrimaryCurrency();
}
else { //explicit currency
$iso = $currency;
}
return $iso;
}
function ConvertCurrency($value, $iso)
{
$converter =& $this->Application->recallObject('kCurrencyRates');
// convery primary currency to selected (if they are the same, converter will just return)
$value = $converter->Convert($value, 'PRIMARY', $iso);
return $value;
}
function AddCurrencySymbol($value, $iso)
{
$currency =& $this->Application->recallObject('curr.-'.$iso, null, Array('skip_autoload' => true));
if( !$currency->isLoaded() ) $currency->Load($iso, 'ISO');
$symbol = $currency->GetDBField('Symbol');
if (!$symbol) $symbol = $currency->GetDBField('ISO').'&nbsp;';
if ($currency->GetDBField('SymbolPosition') == 0) {
$value = $symbol.$value;
}
if ($currency->GetDBField('SymbolPosition') == 1) {
$value = $value.$symbol;
}
return $value;
}
/**
* Get's requested field value
*
* @param Array $params
* @return string
* @access public
*/
function Field($params)
{
$field = $this->SelectParam($params, 'name,field');
if( !$this->Application->IsAdmin() ) $params['no_special'] = 'no_special';
$object =& $this->getObject($params);
if ( $this->HasParam($params, 'db') )
{
$value = $object->GetDBField($field);
}
else
{
if( $this->HasParam($params, 'currency') )
{
$iso = $this->GetISO($params['currency']);
$original = $object->GetDBField($field);
$value = $this->ConvertCurrency($original, $iso);
$object->SetDBField($field, $value);
$object->Fields[$field]['converted'] = true;
}
$format = getArrayValue($params, 'format');
if (!$format || $format == '$format') {
$format = null;
}
$value = $object->GetField($field, $format);
if( $this->SelectParam($params, 'negative') )
{
if(strpos($value, '-') === 0)
{
$value = substr($value, 1);
}
else
{
$value = '-'.$value;
}
}
if( $this->HasParam($params, 'currency') )
{
$value = $this->AddCurrencySymbol($value, $iso);
$params['no_special'] = 1;
}
}
if( !$this->HasParam($params, 'no_special') ) $value = htmlspecialchars($value);
if( getArrayValue($params,'checked' ) ) $value = ($value == ( isset($params['value']) ? $params['value'] : 1)) ? 'checked' : '';
if( isset($params['plus_or_as_label']) ) {
$value = substr($value, 0,1) == '+' ? substr($value, 1) : $this->Application->Phrase($value);
}
elseif( isset($params['as_label']) && $params['as_label'] ) $value = $this->Application->Phrase($value);
$first_chars = $this->SelectParam($params,'first_chars,cut_first');
if($first_chars)
{
$needs_cut = mb_strlen($value) > $first_chars;
$value = mb_substr($value, 0, $first_chars);
if ($needs_cut) $value .= ' ...';
}
if( getArrayValue($params,'nl2br' ) ) $value = nl2br($value);
if ($value != '') $this->Application->Parser->DataExists = true;
if( $this->HasParam($params, 'currency') )
{
//restoring value in original currency, for other Field tags to work properly
$object->SetDBField($field, $original);
}
return $value;
}
function SetField($params)
{
// <inp2:SetField field="Value" src=p:cust_{$custom_name}"/>
$object =& $this->getObject($params);
$dst_field = $this->SelectParam($params, 'name,field');
list($prefix_special, $src_field) = explode(':', $params['src']);
$src_object =& $this->Application->recallObject($prefix_special);
$object->SetDBField($dst_field, $src_object->GetDBField($src_field));
}
/**
* Checks if parameter is passed
* Note: works like Tag and line simple method too
*
* @param Array $params
* @param string $param_name
* @return bool
*/
function HasParam($params, $param_name = null)
{
if( !isset($param_name) )
{
$param_name = $this->SelectParam($params, 'name');
$params = $this->Application->Parser->Params;
}
$value = isset($params[$param_name]) ? $params[$param_name] : false;
return $value && ($value != '$'.$param_name);
}
function PhraseField($params)
{
$field_label = $this->Field($params);
$translation = $this->Application->Phrase( $field_label );
return $translation;
}
function Error($params)
{
$field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$msg = $object->GetErrorMsg($field, false);
return $msg;
}
function HasError($params)
{
if ($params['field'] == 'any')
{
$object =& $this->getObject($params);
$skip_fields = getArrayValue($params, 'except');
$skip_fields = $skip_fields ? explode(',', $skip_fields) : Array();
return $object->HasErrors($skip_fields);
}
else
{
$fields = $this->SelectParam($params, 'field,fields');
$fields = explode(',', $fields);
$res = false;
foreach($fields as $field)
{
$params['field'] = $field;
$res = $res || ($this->Error($params) != '');
}
return $res;
}
}
function ErrorWarning($params)
{
if (!isset($params['field'])) {
$params['field'] = 'any';
}
if ($this->HasError($params)) {
$params['prefix'] = $this->getPrefixSpecial();
return $this->Application->ParseBlock($params);
}
}
function IsRequired($params)
{
$field = $params['field'];
$object =& $this->getObject($params);;
$formatter_class = getArrayValue($object->Fields, $field, 'formatter');
if ($formatter_class == 'kMultiLanguage')
{
$formatter =& $this->Application->recallObject($formatter_class);
$field = $formatter->LangFieldName($field);
}
$options = $object->GetFieldOptions($field);
return getArrayValue($options,'required');
}
function FieldOption($params)
{
$object =& $this->getObject($params);;
$options = $object->GetFieldOptions($params['field']);
$ret = isset($options[$params['option']]) ? $options[$params['option']] : '';
if (isset($params['as_label']) && $params['as_label']) $ret = $this->Application->ReplaceLanguageTags($ret);
return $ret;
}
function PredefinedOptions($params)
{
$object =& $this->getObject($params);
$field = $params['field'];
$value = array_key_exists('value', $params) ? $params['value'] : $object->GetDBField($field);
$field_options = $object->GetFieldOptions($field);
if (!array_key_exists('options', $field_options) || !is_array($field_options['options'])) {
trigger_error('Options not defined for <strong>'.$object->Prefix.'</strong> field <strong>'.$field.'</strong>', E_USER_WARNING);
return '';
}
$options = $field_options['options'];
if ($this->HasParam($params, 'has_empty')) {
$empty_value = array_key_exists('empty_value', $params) ? $params['empty_value'] : '';
$options = array_merge_recursive2(Array ($empty_value => ''), $options); // don't use other array merge function, because they will reset keys !!!
}
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
if (method_exists($object, 'EOL') && count($object->Records) == 0) {
// for drawing grid column filter
$block_params['field_name'] = '';
}
else {
$block_params['field_name'] = $this->InputName($params); // depricated (produces warning when used as grid filter), but used in Front-End (submission create), admin (submission view)
}
$selected_param_name = getArrayValue($params, 'selected_param');
if (!$selected_param_name) {
$selected_param_name = $params['selected'];
}
$selected = $params['selected'];
$o = '';
if ($this->HasParam($params, 'no_empty') && !getArrayValue($options, '')) {
// removes empty option, when present (needed?)
array_shift($options);
}
if (strpos($value, '|') !== false) {
// multiple checkboxes OR multiselect
$value = explode('|', substr($value, 1, -1) );
foreach ($options as $key => $val) {
$block_params['key'] = $key;
$block_params['option'] = $val;
$block_params[$selected_param_name] = ( in_array($key, $value) ? ' '.$selected : '');
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
else {
// single selection radio OR checkboxes OR dropdown
foreach ($options as $key => $val) {
$block_params['key'] = $key;
$block_params['option'] = $val;
$block_params[$selected_param_name] = (strlen($key) == strlen($value) && ($key == $value) ? ' '.$selected : '');
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
return $o;
}
function PredefinedSearchOptions($params)
{
$object =& $this->getObject($params);
/* @var $object kDBList */
$params['value'] = $this->SearchField($params);
return $this->PredefinedOptions($params);
}
function Format($params)
{
$field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$options = $object->GetFieldOptions($field);
$format = $options[ $this->SelectParam($params, 'input_format') ? 'input_format' : 'format' ];
$formatter_class = getArrayValue($options,'formatter');
if ($formatter_class) {
$formatter =& $this->Application->recallObject($formatter_class);
$human_format = getArrayValue($params,'human');
$edit_size = getArrayValue($params,'edit_size');
$sample = getArrayValue($params,'sample');
if($sample)
{
return $formatter->GetSample($field, $options, $object);
}
elseif($human_format || $edit_size)
{
$format = $formatter->HumanFormat($format);
return $edit_size ? strlen($format) : $format;
}
}
return $format;
}
/**
* Returns grid padination information
* Can return links to pages
*
* @param Array $params
* @return mixed
*/
function PageInfo($params)
{
$object =& $this->GetList($params);
/* @var $object kDBList */
$type = $params['type'];
unset($params['type']); // remove parameters used only by current tag
$ret = '';
switch ($type) {
case 'current':
$ret = $object->Page;
break;
case 'total':
$ret = $object->GetTotalPages();
break;
case 'prev':
$ret = $object->Page > 1 ? $object->Page - 1 : false;
break;
case 'next':
$ret = $object->Page < $object->GetTotalPages() ? $object->Page + 1 : false;
break;
}
if ($ret && isset($params['as_link']) && $params['as_link']) {
unset($params['as_link']); // remove parameters used only by current tag
$params['page'] = $ret;
$current_page = $object->Page; // backup current page
$ret = $this->PageLink($params);
$this->Application->SetVar($object->getPrefixSpecial().'_Page', $current_page); // restore page
}
return $ret;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintPages($params)
{
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
$total_pages = $list->GetTotalPages();
if ($total_pages > 1) $this->Application->Parser->DataExists = true;
if($total_pages == 0) $total_pages = 1; // display 1st page as selected in case if we have no pages at all
$o = '';
// what are these 2 lines for?
$this->Application->SetVar($prefix_special.'_event','');
$this->Application->SetVar($prefix_special.'_id','');
$current_page = $list->Page; // $this->Application->RecallVar($prefix_special.'_Page');
$block_params = $this->prepareTagParams($params);
$split = ( isset($params['split'] ) ? $params['split'] : 10 );
$split_start = $current_page - ceil($split/2);
if ($split_start < 1){
$split_start = 1;
}
$split_end = $split_start + $split-1;
if ($split_end > $total_pages) {
$split_end = $total_pages;
$split_start = max($split_end - $split + 1, 1);
}
if ($current_page > 1){
$prev_block_params = $this->prepareTagParams();
if ($total_pages > $split){
$prev_block_params['page'] = max($current_page-$split, 1);
$prev_block_params['name'] = $this->SelectParam($params, 'prev_page_split_render_as,prev_page_split_block');
if ($prev_block_params['name']){
$o .= $this->Application->ParseBlock($prev_block_params, 1);
}
}
$prev_block_params['name'] = 'page';
$prev_block_params['page'] = $current_page-1;
$prev_block_params['name'] = $this->SelectParam($params, 'prev_page_render_as,block_prev_page,prev_page_block');
if ($prev_block_params['name']) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page-1);
$o .= $this->Application->ParseBlock($prev_block_params, 1);
}
}
else {
if ( $no_prev_page_block = $this->SelectParam($params, 'no_prev_page_render_as,block_no_prev_page') ) {
$block_params['name'] = $no_prev_page_block;
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
$separator_params['name'] = $this->SelectParam($params, 'separator_render_as,block_separator');
for ($i = $split_start; $i <= $split_end; $i++)
{
if ($i == $current_page) {
$block = $this->SelectParam($params, 'current_render_as,active_render_as,block_current,active_block');
}
else {
$block = $this->SelectParam($params, 'link_render_as,inactive_render_as,block_link,inactive_block');
}
$block_params['name'] = $block;
$block_params['page'] = $i;
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $i);
$o .= $this->Application->ParseBlock($block_params, 1);
if ($this->SelectParam($params, 'separator_render_as,block_separator')
&& $i < $split_end)
{
$o .= $this->Application->ParseBlock($separator_params, 1);
}
}
if ($current_page < $total_pages){
$next_block_params = $this->prepareTagParams();
$next_block_params['page']=$current_page+1;
$next_block_params['name'] = $this->SelectParam($params, 'next_page_render_as,block_next_page,next_page_block');
if ($next_block_params['name']){
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page+1);
$o .= $this->Application->ParseBlock($next_block_params, 1);
}
if ($total_pages > $split){
$next_block_params['page']=min($current_page+$split, $total_pages);
$next_block_params['name'] = $this->SelectParam($params, 'next_page_split_render_as,next_page_split_block');
if ($next_block_params['name']){
$o .= $this->Application->ParseBlock($next_block_params, 1);
}
}
}
else {
if ( $no_next_page_block = $this->SelectParam($params, 'no_next_page_render_as,block_no_next_page') ) {
$block_params['name'] = $no_next_page_block;
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page);
return $o;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PaginationBar($params)
{
return $this->PrintPages($params);
}
/**
* Returns field name (processed by kMultiLanguage formatter
* if required) and item's id from it's IDField or field required
*
* @param Array $params
* @return Array (id,field)
* @access private
*/
function prepareInputName($params)
{
$field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$formatter_class = getArrayValue($object->Fields, $field, 'formatter');
if ($formatter_class == 'kMultiLanguage') {
$formatter =& $this->Application->recallObject($formatter_class);
/* @var $formatter kMultiLanguage */
$force_primary = isset($object->Fields[$field]['force_primary']) && $object->Fields[$field]['force_primary'];
$field = $formatter->LangFieldName($field, $force_primary);
}
if (array_key_exists('force_id', $params)) {
$id = $params['force_id'];
}
else {
$id_field = getArrayValue($params, 'IdField');
$id = $id_field ? $object->GetDBField($id_field) : $object->GetID();
}
return Array($id, $field);
}
/**
* Returns input field name to
* be placed on form (for correct
* event processing)
*
* @param Array $params
* @return string
* @access public
*/
function InputName($params)
{
list($id, $field) = $this->prepareInputName($params);
$ret = $this->getPrefixSpecial().'['.$id.']['.$field.']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
/**
* Allows to override various field options through hidden fields with specific names in submit.
* This tag generates this special names
*
* @param Array $params
* @return string
* @author Alex
*/
function FieldModifier($params)
{
list($id, $field) = $this->prepareInputName($params);
$ret = 'field_modifiers['.$this->getPrefixSpecial().']['.$field.']['.$params['type'].']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
if (isset($params['value'])) {
$object =& $this->getObject($params);
$field_modifiers[$field][$params['type']] = $params['value'];
$object->ApplyFieldModifiers($field_modifiers);
}
return $ret;
}
/**
* Returns index where 1st changable sorting field begins
*
* @return int
* @access private
*/
function getUserSortIndex()
{
$list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings');
$sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : '';
$user_sorting_start = 0;
if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
$user_sorting_start = count($forced_sorting);
}
return $user_sorting_start;
}
/**
* Returns order direction for given field
*
*
*
* @param Array $params
* @return string
* @access public
*/
function Order($params)
{
$field = $params['field'];
$user_sorting_start = $this->getUserSortIndex();
$list =& $this->GetList($params);
if ($list->GetOrderField($user_sorting_start) == $field)
{
return strtolower($list->GetOrderDirection($user_sorting_start));
}
elseif($this->Application->ConfigValue('UseDoubleSorting') && $list->GetOrderField($user_sorting_start+1) == $field)
{
return '2_'.strtolower($list->GetOrderDirection($user_sorting_start+1));
}
else
{
return 'no';
}
}
/**
* Detects, that current sorting is not default
*
* @param Array $params
* @return bool
*/
function OrderChanged($params)
{
$list =& $this->GetList($params);
$user_sorting_start = $this->getUserSortIndex();
$sorting_configs = $this->Application->getUnitOption($this->Prefix, 'ConfigMapping', Array ());
$list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings', Array ());
$sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : '';
if (array_key_exists('DefaultSorting1Field', $sorting_configs)) {
$list_sortings[$sorting_prefix]['Sorting'] = Array (
$this->Application->ConfigValue($sorting_configs['DefaultSorting1Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting1Dir']),
$this->Application->ConfigValue($sorting_configs['DefaultSorting2Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting2Dir']),
);
}
$sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting');
$sort_fields = is_array($sorting) ? array_keys($sorting) : Array ();
for ($order_number = 0; $order_number < 2; $order_number++) {
// currect sorting in list
$sorting_pos = $user_sorting_start + $order_number;
$current_order_field = $list->GetOrderField($sorting_pos, true);
$current_order_direction = $list->GetOrderDirection($sorting_pos, true);
if (!$current_order_field || !$current_order_direction) {
// no sorting defined for this sorting position
continue;
}
// user sorting found
if (array_key_exists($order_number, $sort_fields)) {
// default sorting found
$default_order_field = $sort_fields[$order_number];
$default_order_direction = $sorting[$default_order_field];
if ($current_order_field != $default_order_field || $current_order_direction != $default_order_direction) {
// #1. user sorting differs from default sorting -> changed
return true;
}
}
else {
// #2. user sorting + no default sorting -> changed
return true;
}
}
// #3. user sorting match default or not defined -> not changed
return false;
}
/**
* Get's information of sorting field at "pos" position,
* like sorting field name (type="field") or sorting direction (type="direction")
*
* @param Array $params
* @return mixed
*/
function OrderInfo($params)
{
$user_sorting_start = $this->getUserSortIndex() + --$params['pos'];
$list =& $this->GetList($params);
// $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
if($params['type'] == 'field') return $list->GetOrderField($user_sorting_start);
if($params['type'] == 'direction') return $list->GetOrderDirection($user_sorting_start);
}
/**
* Checks if sorting field/direction matches passed field/direction parameter
*
* @param Array $params
* @return bool
*/
function IsOrder($params)
{
$params['type'] = isset($params['field']) ? 'field' : 'direction';
$value = $this->OrderInfo($params);
if( isset($params['field']) ) return $params['field'] == $value;
if( isset($params['direction']) ) return $params['direction'] == $value;
}
/**
* Returns list perpage
*
* @param Array $params
* @return int
*/
function PerPage($params)
{
$object =& $this->getObject($params);
return $object->PerPage;
}
/**
* Checks if list perpage matches value specified
*
* @param Array $params
* @return bool
*/
function PerPageEquals($params)
{
$object =& $this->getObject($params);
return $object->PerPage == $params['value'];
}
function SaveEvent($params)
{
// 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)
{
$object =& $this->getObject($params);
$wid = $this->Application->GetTopmostWid($this->Prefix);
$session_name = rtrim($this->getPrefixSpecial().'_selected_ids_'.$wid, '_');
$ids = explode(',', $this->Application->RecallVar($session_name));
$cur_id = $object->GetID();
$i = array_search($cur_id, $ids);
if ($i !== false) {
return $i < count($ids) - 1 ? $ids[$i + 1] : '';
}
return '';
}
function PrevId($params)
{
$object =& $this->getObject($params);
$wid = $this->Application->GetTopmostWid($this->Prefix);
$session_name = rtrim($this->getPrefixSpecial().'_selected_ids_'.$wid, '_');
$ids = explode(',', $this->Application->RecallVar($session_name));
$cur_id = $object->GetID();
$i = array_search($cur_id, $ids);
if ($i !== false) {
return $i > 0 ? $ids[$i - 1] : '';
}
return '';
}
function IsSingle($params)
{
return ($this->NextId($params) === '' && $this->PrevId($params) === '');
}
function IsLast($params)
{
return ($this->NextId($params) === '');
}
function IsFirst($params)
{
return ($this->PrevId($params) === '');
}
/**
* Checks if field value is equal to proposed one
*
* @param Array $params
* @return bool
*/
function FieldEquals($params)
{
$object =& $this->getObject($params);
$ret = $object->GetDBField($this->SelectParam($params, 'name,field')) == $params['value'];
// if( getArrayValue($params,'inverse') ) $ret = !$ret;
return $ret;
}
/**
* Checks, that grid has icons defined and they should be shown
*
* @param Array $params
* @return bool
*/
function UseItemIcons($params)
{
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
return array_key_exists('Icons', $grids[ $params['grid'] ]);
}
/**
* Returns corresponding to grid layout selector column width
*
* @param Array $params
* @return int
*/
function GridSelectorColumnWidth($params)
{
$width = 0;
if ($params['selector']) {
$width += $params['selector_width'];
}
if ($this->UseItemIcons($params)) {
$width += $params['icon_width'];
}
return $width;
}
/**
* Returns grids item selection mode (checkbox, radio, )
*
* @param Array $params
* @return string
*/
function GridSelector($params)
{
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
return array_key_exists('Selector', $grids[ $params['grid'] ]) ? $grids[ $params['grid'] ]['Selector'] : $params['default'];
}
function ItemIcon($params)
{
$object =& $this->getObject($params);
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$icons =& $grids[ $params['grid'] ]['Icons'];
$key = '';
$status_fields = $this->Application->getUnitOption($this->Prefix,'StatusField');
if(!$status_fields) return $icons['default'];
foreach($status_fields as $status_field)
{
$key .= $object->GetDBField($status_field).'_';
}
$key = rtrim($key,'_');
$value = ($key !== false) ? $key : 'default';
return isset($icons[$value]) ? $icons[$value] : $icons['default'];
}
/**
* Generates bluebar title + initializes prefixes used on page
*
* @param Array $params
* @return string
*/
function SectionTitle($params)
{
$preset_name = replaceModuleSection($params['title_preset']);
$title_presets = $this->Application->getUnitOption($this->Prefix,'TitlePresets');
$title_info = getArrayValue($title_presets, $preset_name);
if ($title_info === false) {
$title = str_replace('#preset_name#', $preset_name, $params['title']);
if ($this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title']) {
$title .= ' - '.$params['group_title'];
}
return $title;
}
if (getArrayValue($title_presets,'default')) {
// use default labels + custom labels specified in preset used
$title_info = array_merge_recursive2($title_presets['default'], $title_info);
}
$title = $title_info['format'];
// 1. get objects in use for title construction
$objects = Array();
$object_status = Array();
$status_labels = Array();
$prefixes = getArrayValue($title_info,'prefixes');
$all_tag_params = getArrayValue($title_info,'tag_params');
if ($prefixes) {
// extract tag_perams passed directly to SectionTitle tag for specific prefix
foreach ($params as $tp_name => $tp_value) {
if (preg_match('/(.*)\[(.*)\]/', $tp_name, $regs)) {
$all_tag_params[ $regs[1] ][ $regs[2] ] = $tp_value;
unset($params[$tp_name]);
}
}
$tag_params = Array();
foreach ($prefixes as $prefix_special) {
$prefix_data = $this->Application->processPrefix($prefix_special);
$prefix_data['prefix_special'] = rtrim($prefix_data['prefix_special'],'.');
if ($all_tag_params) {
$tag_params = getArrayValue($all_tag_params, $prefix_data['prefix_special']);
if (!$tag_params) $tag_params = Array();
}
$tag_params = array_merge_recursive2($params, $tag_params);
$objects[ $prefix_data['prefix_special'] ] =& $this->Application->recallObject($prefix_data['prefix_special'], $prefix_data['prefix'], $tag_params);
$object_status[ $prefix_data['prefix_special'] ] = $objects[ $prefix_data['prefix_special'] ]->IsNewItem() ? 'new' : 'edit';
// a. set object's status field (adding item/editing item) for each object in title
if (getArrayValue($title_info[ $object_status[ $prefix_data['prefix_special'] ].'_status_labels' ],$prefix_data['prefix_special'])) {
$status_labels[ $prefix_data['prefix_special'] ] = $title_info[ $object_status[ $prefix_data['prefix_special'] ].'_status_labels' ][ $prefix_data['prefix_special'] ];
$title = str_replace('#'.$prefix_data['prefix_special'].'_status#', $status_labels[ $prefix_data['prefix_special'] ], $title);
}
// b. setting object's titlefield value (in titlebar ONLY) to default in case if object beeing created with no titlefield filled in
if ($object_status[ $prefix_data['prefix_special'] ] == 'new') {
$new_value = $this->getInfo( $objects[ $prefix_data['prefix_special'] ], 'titlefield' );
if(!$new_value && getArrayValue($title_info['new_titlefield'],$prefix_data['prefix_special']) ) $new_value = $this->Application->Phrase($title_info['new_titlefield'][ $prefix_data['prefix_special'] ]);
$title = str_replace('#'.$prefix_data['prefix_special'].'_titlefield#', $new_value, $title);
}
}
}
// replace to section title
$section = array_key_exists('section', $params) ? $params['section'] : false;
if ($section) {
$sections_helper =& $this->Application->recallObject('SectionsHelper');
/* @var $sections_helper kSectionsHelper */
$section_data =& $sections_helper->getSectionData($section);
$title = str_replace('#section_label#', '!' . $section_data['label'] . '!', $title);
}
// 2. replace phrases if any found in format string
$title = $this->Application->ReplaceLanguageTags($title, false);
// 3. find and replace any replacement vars
preg_match_all('/#(.*_.*)#/Uis',$title,$rets);
if ($rets[1]) {
$replacement_vars = array_keys( array_flip($rets[1]) );
foreach ($replacement_vars as $replacement_var) {
$var_info = explode('_',$replacement_var,2);
$object =& $objects[ $var_info[0] ];
$new_value = $this->getInfo($object,$var_info[1]);
$title = str_replace('#'.$replacement_var.'#', $new_value, $title);
}
}
// replace trailing spaces inside title preset + '' occurences into single space
$title = preg_replace('/[ ]*\'\'[ ]*/', ' ', $title);
if ($this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title']) {
$title .= ' - '.$params['group_title'];
}
$cut_first = getArrayValue($params, 'cut_first');
if ($cut_first && mb_strlen($title) > $cut_first) {
if (!preg_match('/<a href="(.*)">(.*)<\/a>/',$title)) {
$title = mb_substr($title, 0, $cut_first).' ...';
}
}
return $title;
}
function getInfo(&$object, $info_type)
{
switch ($info_type)
{
case 'titlefield':
$field = $this->Application->getUnitOption($object->Prefix,'TitleField');
return $field !== false ? $object->GetField($field) : 'TitleField Missing';
break;
case 'recordcount':
$of_phrase = $this->Application->Phrase('la_of');
return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' '.$of_phrase.' '.$object->NoFilterCount : $object->RecordsCount;
break;
default:
return $object->GetField($info_type);
break;
}
}
function GridInfo($params)
{
$object =& $this->GetList($params);
/* @var $object kDBList */
switch ($params['type']) {
case 'filtered':
return $object->GetRecordsCount();
case 'total':
return $object->GetNoFilterCount();
case 'from':
return $object->RecordsCount ? $object->Offset+1 : 0; //0-based
case 'to':
return $object->PerPage > 0 ? min($object->Offset + $object->PerPage, $object->RecordsCount) : $object->RecordsCount;
case 'total_pages':
return $object->GetTotalPages();
case 'needs_pagination':
return ($object->PerPage != -1) && (($object->RecordsCount > $object->PerPage) || ($object->Page > 1));
}
}
/**
* Parses block depending on its element type.
* For radio and select elements values are taken from 'value_list_field' in key1=value1,key2=value2
* format. key=value can be substituted by <SQL>SELECT f1 AS OptionName, f2 AS OptionValue... FROM <PREFIX>TableName </SQL>
* where prefix is TABLE_PREFIX
*
* @param Array $params
* @return string
*/
function ConfigFormElement($params)
{
$object =& $this->getObject($params);
$field = $params['field'];
$helper =& $this->Application->recallObject('InpCustomFieldsHelper');
/* @var $helper InpCustomFieldsHelper */
$element_type = $object->GetDBField($params['element_type_field']);
if($element_type == 'label') $element_type = 'text';
$params['name'] = $params['blocks_prefix'].$element_type;
switch ($element_type) {
case 'select':
case 'multiselect':
case 'radio':
$field_options = $object->GetFieldOptions($field, 'options');
if ($object->GetDBField('DirectOptions')) {
// used for custom fields
$field_options['options'] = $object->GetDBField('DirectOptions');
}
else {
// used for configuration
$field_options['options'] = $helper->GetValuesHash($object->GetDBField($params['value_list_field']), ',');
}
$object->SetFieldOptions($field, $field_options);
break;
case 'text':
case 'textarea':
$params['field_params'] = $helper->ParseConfigSQL($object->GetDBField($params['value_list_field']));
break;
case 'password':
case 'checkbox':
default:
break;
}
return $this->Application->ParseBlock($params, 1);
}
/**
* Get's requested custom field value
*
* @param Array $params
* @return string
* @access public
*/
function CustomField($params)
{
$params['name'] = 'cust_'.$this->SelectParam($params, 'name,field');
return $this->Field($params);
}
function CustomFieldLabel($params)
{
$object =& $this->getObject($params);
$field = $this->SelectParam($params, 'name,field');
$sql = 'SELECT FieldLabel
FROM '.$this->Application->getUnitOption('cf', 'TableName').'
WHERE FieldName = '.$this->Conn->qstr($field);
return $this->Application->Phrase($this->Conn->GetOne($sql));
}
/**
* transposes 1-dimensional array elements for vertical alignment according to given columns and per_page parameters
*
* @param array $arr
* @param int $columns
* @param int $per_page
* @return array
*/
function LinearToVertical(&$arr, $columns, $per_page)
{
$rows = $columns;
// in case if after applying per_page limit record count less then
// can fill requrested column count, then fill as much as we can
$cols = min(ceil($per_page / $columns), ceil(count($arr) / $columns));
$imatrix = array();
for ($row = 0; $row < $rows; $row++) {
for ($col = 0; $col < $cols; $col++) {
$source_index = $row * $cols + $col;
if (!isset($arr[$source_index])) {
// in case if source array element count is less then element count in one row
continue;
}
$imatrix[$col * $rows + $row] = $arr[$source_index];
}
}
ksort($imatrix);
return array_values($imatrix);
}
/**
* If data was modfied & is in TempTables mode, then parse block with name passed;
* remove modification mark if not in TempTables mode
*
* @param Array $params
* @return string
* @access public
* @author Alexey
*/
function SaveWarning($params)
{
$main_prefix = getArrayValue($params, 'main_prefix');
if ($main_prefix && $main_prefix != '$main_prefix') {
$top_prefix = $main_prefix;
}
else {
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
$temp_tables = substr($this->Application->GetVar($top_prefix.'_mode'), 0, 1) == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
if ($temp_tables && $modified) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,name');
$block_params['edit_mode'] = $temp_tables ? 1 : 0;
return $this->Application->ParseBlock($block_params);
}
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
/**
* Returns list record count queries (on all pages)
*
* @param Array $params
* @return int
*/
function TotalRecords($params)
{
$list =& $this->GetList($params);
if (!$list->Counted) $list->CountRecs();
return $list->RecordsCount;
}
/**
* Range filter field name
*
* @param Array $params
* @return string
*/
function SearchInputName($params)
{
$field = $this->SelectParam($params, 'field,name');
$ret = 'custom_filters['.$this->getPrefixSpecial().']['.$params['grid'].']['.$field.']['.$params['filter_type'].']';
if (isset($params['type'])) {
$ret .= '['.$params['type'].']';
}
return $ret;
}
/**
* Return range filter field value
*
* @param Array $params
* @return string
*/
function SearchField($params) // RangeValue
{
$field = $this->SelectParam($params, 'field,name');
$view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view');
$custom_filter = $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_custom_filter.'.$view_name/*, ALLOW_DEFAULT_SETTINGS*/);
$custom_filter = $custom_filter ? unserialize($custom_filter) : Array();
if (isset($custom_filter[ $params['grid'] ][$field])) {
$ret = $custom_filter[ $params['grid'] ][$field][ $params['filter_type'] ]['submit_value'];
if (isset($params['type'])) {
$ret = $ret[ $params['type'] ];
}
if( !$this->HasParam($params, 'no_special') ) $ret = htmlspecialchars($ret);
return $ret;
}
return '';
}
function SearchFormat($params)
{
$field = $params['field'];
$object =& $this->GetList($params);
$options = $object->GetFieldOptions($field);
$format = $options[ $this->SelectParam($params, 'input_format') ? 'input_format' : 'format' ];
$formatter_class = getArrayValue($options,'formatter');
if($formatter_class)
{
$formatter =& $this->Application->recallObject($formatter_class);
$human_format = getArrayValue($params,'human');
$edit_size = getArrayValue($params,'edit_size');
$sample = getArrayValue($params,'sample');
if($sample)
{
return $formatter->GetSample($field, $options, $object);
}
elseif($human_format || $edit_size)
{
$format = $formatter->HumanFormat($format);
return $edit_size ? strlen($format) : $format;
}
}
return $format;
}
/**
* Returns error of range field
*
* @param unknown_type $params
* @return unknown
*/
function SearchError($params)
{
$field = $this->SelectParam($params, 'field,name');
$error_var_name = $this->getPrefixSpecial().'_'.$field.'_error';
$pseudo = $this->Application->RecallVar($error_var_name);
if ($pseudo) {
$this->Application->RemoveVar($error_var_name);
}
$object =& $this->Application->recallObject($this->Prefix.'.'.$this->Special.'-item', null, Array('skip_autoload' => true));
/* @var $object kDBItem */
$object->SetError($field, $pseudo);
return $object->GetErrorMsg($field, false);
}
/**
* Returns templates path for module, which is gathered from prefix module
*
* @param Array $params
* @return string
* @author Alex
*/
function ModulePath($params)
{
$force_module = getArrayValue($params, 'module');
if ($force_module) {
if ($force_module == '#session#') {
$force_module = preg_replace('/([^:]*):.*/', '\1', $this->Application->RecallVar('module'));
if (!$force_module) $force_module = 'core';
}
else {
$force_module = mb_strtolower($force_module);
}
if ($force_module == 'core') {
$module_folder = 'core';
}
else {
$module_folder = trim( $this->Application->findModule('Name', $force_module, 'Path'), '/');
}
}
else {
$module_folder = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder');
}
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);
if (isset($params['requery']) && $params['requery']) {
$this->Application->HandleEvent($q_event, $this->getPrefixSpecial().':LoadItem', $params);
}
return $object;
}
/**
* Checks if object propery value matches value passed
*
* @param Array $params
* @return bool
*/
function PropertyEquals($params)
{
$object =& $this->getObject($params);
$property_name = $this->SelectParam($params, 'name,var,property');
return $object->$property_name == $params['value'];
}
/**
* Group list records by header, saves internal order in group
*
* @param Array $records
* @param string $heading_field
*/
function groupRecords(&$records, $heading_field)
{
$sorted = Array();
$i = 0; $record_count = count($records);
while ($i < $record_count) {
$sorted[ $records[$i][$heading_field] ][] = $records[$i];
$i++;
}
$records = Array();
foreach ($sorted as $heading => $heading_records) {
$records = array_merge_recursive($records, $heading_records);
}
}
function DisplayOriginal($params)
{
return false;
}
function MultipleEditing($params)
{
$wid = $this->Application->GetTopmostWid($this->Prefix);
$session_name = rtrim($this->getPrefixSpecial().'_selected_ids_'.$wid, '_');
$selected_ids = explode(',', $this->Application->RecallVar($session_name));
$ret = '';
if ($selected_ids) {
$selected_ids = explode(',', $selected_ids);
$object =& $this->getObject( array_merge_recursive2($params, Array('skip_autoload' => true)) );
$params['name'] = $params['render_as'];
foreach ($selected_ids as $id) {
$object->Load($id);
$ret .= $this->Application->ParseBlock($params);
}
}
return $ret;
}
/**
* Returns import/export process percent
*
* @param Array $params
* @return int
* @deprecated Please convert to event-model, not tag based
*/
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 is used?
$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') {
// used for orders export in In-Commerce
$finish_t = $this->Application->RecallVar('export_finish_t');
$this->Application->Redirect($finish_t, Array('pass' => 'all'));
$this->Application->RemoveVar('export_finish_t');
}
}
$export_options = $export_object->loadOptions($event);
return $export_options['start_from'] * 100 / $export_options['total_records'];
}
/**
* 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 FieldTotal($params)
{
$list =& $this->GetList($params);
return $list->GetFormattedTotal($this->SelectParam($params, 'field,name'), $params['function']);
}
function SetFCKDefaultLanguage()
{
$lang_id = $this->Application->GetDefaultLanguageId();
$sql="SELECT Locale FROM ".TABLE_PREFIX."Language WHERE LanguageId = ".$lang_id;
$lang_prefix = strtolower($this->Conn->GetOne($sql));
$lang_file=strtolower($this->Conn->GetOne($sql)).'.js';
if (file_exists(FULL_PATH.EDITOR_PATH.'/editor/lang/'.$lang_file))
{
return $lang_prefix;
}
$aLangPrefix = explode("-",$lang_prefix);
if (file_exists(FULL_PATH.EDITOR_PATH.'/editor/lang/'.$aLangPrefix[0].'.js'))
{
return $aLangPrefix[0];
}
return 'en';
}
function FCKEditor($params)
{
$params['no_special'] = 1;
+ $params['format'] = array_key_exists('format', $params) ? $params['format'] . ';fck_ready' : 'fck_ready';
$value = $this->Field($params);
$name = array_key_exists('name', $params) ? $params['name'] : $this->InputName($params);
$theme_path = substr($this->Application->GetFrontThemePath(), 1) . '/inc/';
if (!file_exists(FULL_PATH . '/' . $theme_path . 'style.css')) {
$theme_path = EDITOR_PATH;
}
$styles_xml = $this->Application->BaseURL() . $theme_path . 'styles.xml';
$styles_css = $this->Application->BaseURL() . $theme_path . 'style.css';
$bgcolor = array_key_exists('bgcolor', $params) ? $params['bgcolor'] : $this->Application->GetVar('bgcolor');
if (!$bgcolor) {
$bgcolor = '#ffffff';
}
- $url = '';
- $st_id = $this->Application->GetVar('st_id');
- if ($st_id) {
+ $preview_url = '';
+ $page_id = $this->Application->GetVar('c_id');
+ $content_id = $this->Application->GetVar('content_id');
+ if ($page_id && $content_id) {
+ // editing content block from Front-End, not category in admin
$sql = 'SELECT NamedParentPath
- FROM ' . $this->Application->getUnitOption('st', 'TableName') . '
- WHERE ' . $this->Application->getUnitOption('st', 'IDField') . ' = ' . $st_id;
- $tpl = $this->Conn->GetOne($sql);
-
- $url_params = Array ('pass' => 'm', 'm_cat_id' => $st_id, 'index_file' => 'index.php');
- $url = $this->Application->HREF($tpl, '_FRONT_END_', $url_params);
+ FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
+ WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $page_id;
+ $template = strtolower( $this->Conn->GetOne($sql) );
+
+ $url_params = Array ('m_cat_id' => $page_id, 'no_amp' => 1, 'editing_mode' => EDITING_MODE_CMS, 'pass' => 'm');
+ $preview_url = $this->Application->HREF($template, '_FRONT_END_', $url_params, 'index.php');
+ $preview_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $preview_url);
}
include_once(FULL_PATH . EDITOR_PATH . 'fckeditor.php');
$oFCKeditor = new FCKeditor($name);
$oFCKeditor->FullUrl = $this->Application->BaseURL();
$oFCKeditor->BaseUrl = BASE_PATH . '/';
$oFCKeditor->BasePath = BASE_PATH . EDITOR_PATH;
$oFCKeditor->Width = $params['width'] ;
$oFCKeditor->Height = $params['height'] ;
- $oFCKeditor->ToolbarSet = $st_id ? 'Advanced' : 'Default';
+ $oFCKeditor->ToolbarSet = $page_id && $content_id ? 'Advanced' : 'Default';
$oFCKeditor->Value = $value;
- $oFCKeditor->PreviewUrl = $url;
+ $oFCKeditor->PreviewUrl = $preview_url;
$oFCKeditor->DefaultLanguage = $this->SetFCKDefaultLanguage();
$oFCKeditor->LateLoad = array_key_exists('late_load', $params) && $params['late_load'];
$oFCKeditor->Config = Array (
//'UserFilesPath' => $pathtoroot.'kernel/user_files',
'ProjectPath' => BASE_PATH . '/',
'CustomConfigurationsPath' => $this->Application->BaseURL() . 'core/admin_templates/js/inp_fckconfig.js',
'StylesXmlPath' => $styles_xml,
'EditorAreaCSS' => $styles_css,
'DefaultStyleLabel' => $this->Application->Phrase('la_editor_default_style'),
// 'Debug' => 1,
'Admin' => 1,
'K4' => 1,
'newBgColor' => $bgcolor,
- 'PreviewUrl' => $url,
+ 'PreviewUrl' => $preview_url,
'BaseUrl' => BASE_PATH . '/',
'DefaultLanguage' => $this->SetFCKDefaultLanguage(),
'EditorAreaStyles' => 'body { background-color: '.$bgcolor.' }',
);
return $oFCKeditor->CreateHtml();
}
function IsNewItem($params)
{
$object =& $this->getObject($params);
return $object->IsNewItem();
}
/**
* Creates link to an item including only it's id
*
* @param Array $params
* @return string
*/
function ItemLink($params)
{
$object =& $this->getObject($params);
if (!isset($params['pass'])) {
$params['pass'] = 'm';
}
$params[$object->getPrefixSpecial().'_id'] = $object->GetID();
$m =& $this->Application->recallObject('m_TagProcessor');
return $m->t($params);
}
/**
* Calls OnNew event from template, when no other event submitted
*
* @param Array $params
*/
function PresetFormFields($params)
{
$prefix = $this->getPrefixSpecial();
if (!$this->Application->GetVar($prefix.'_event')) {
$this->Application->HandleEvent(new kEvent($prefix.':OnNew'));
}
}
function PrintSerializedFields($params)
{
$object =& $this->getObject();
$field = $this->SelectParam($params, 'field');
$data = unserialize($object->GetDBField($field));
$o = '';
$std_params['name'] = $params['render_as'];
$std_params['field'] = $params['field'];
$std_params['pass_params'] = true;
foreach ($data as $key => $row) {
$block_params = array_merge($std_params, $row, array('key'=>$key));
$o .= $this->Application->ParseBlock($block_params);
}
return $o;
}
/**
* Checks if current prefix is main item
*
* @param Array $params
* @return bool
*/
function IsTopmostPrefix($params)
{
return $this->Prefix == $this->Application->GetTopmostPrefix($this->Prefix);
}
function PermSection($params)
{
$section = $this->SelectParam($params, 'section,name');
$perm_sections = $this->Application->getUnitOption($this->Prefix, 'PermSection');
return isset($perm_sections[$section]) ? $perm_sections[$section] : '';
}
function PerPageSelected($params)
{
$list =& $this->GetList($params);
return $list->PerPage == $params['per_page'] ? $params['selected'] : '';
}
/**
* Returns prefix + generated sepcial + any word
*
* @param Array $params
* @return string
*/
function VarName($params)
{
$list =& $this->GetList($params);
return $list->getPrefixSpecial().'_'.$params['type'];
}
/**
* Returns edit tabs by specified preset name or false in case of error
*
* @param string $preset_name
* @return mixed
*/
function getEditTabs($preset_name)
{
$presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
if (!$presets || !isset($presets[$preset_name]) || count($presets[$preset_name]) == 0) {
return false;
}
return count($presets[$preset_name]) > 1 ? $presets[$preset_name] : false;
}
/**
* Detects if specified preset has tabs in it
*
* @param Array $params
* @return bool
*/
function HasEditTabs($params)
{
return $this->getEditTabs($params['preset_name']) ? true : false;
}
/**
* Sorts edit tabs based on their priority
*
* @param Array $tab_a
* @param Array $tab_b
* @return int
*/
function sortEditTabs($tab_a, $tab_b)
{
if ($tab_a['priority'] == $tab_b['priority']) {
return 0;
}
return $tab_a['priority'] < $tab_b['priority'] ? -1 : 1;
}
/**
* Prints edit tabs based on preset name specified
*
* @param Array $params
* @return string
*/
function PrintEditTabs($params)
{
$edit_tabs = $this->getEditTabs($params['preset_name']);
if (!$edit_tabs) {
return ;
}
usort($edit_tabs, Array (&$this, 'sortEditTabs'));
$ret = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
foreach ($edit_tabs as $tab_info) {
$block_params['title'] = $tab_info['title'];
$block_params['template'] = $tab_info['t'];
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Performs image resize to required dimensions and returns resulting url (cached resized image)
*
* @param Array $params
* @return string
*/
function ImageSrc($params)
{
$max_width = isset($params['MaxWidth']) ? $params['MaxWidth'] : false;
$max_height = isset($params['MaxHeight']) ? $params['MaxHeight'] : false;
$logo_filename = isset($params['LogoFilename']) ? $params['LogoFilename'] : false;
$logo_h_margin = isset($params['LogoHMargin']) ? $params['LogoHMargin'] : false;
$logo_v_margin = isset($params['LogoVMargin']) ? $params['LogoVMargin'] : false;
$object =& $this->getObject($params);
$field = $this->SelectParam($params, 'name,field');
return $object->GetField($field, 'resize:'.$max_width.'x'.$max_height.';wm:'.$logo_filename.'|'.$logo_h_margin.'|'.$logo_v_margin);
}
/**
* Allows to retrieve given setting from unit config
*
* @param Array $params
* @return mixed
*/
function UnitOption($params)
{
return $this->Application->getUnitOption($this->Prefix, $params['name']);
}
/**
* Returns list of allowed toolbar buttons or false, when all is allowed
*
* @param Array $params
* @return string
*/
function VisibleToolbarButtons($params)
{
$preset_name = replaceModuleSection($params['title_preset']);
$title_presets = $this->Application->getUnitOption($this->Prefix, 'TitlePresets');
if (!array_key_exists($preset_name, $title_presets)) {
trigger_error('Title preset not specified or missing (in tag "<strong>' . $this->getPrefixSpecial() . ':' . __METHOD__ . '</strong>")', E_USER_WARNING);
return false;
}
$preset_info = $title_presets[$preset_name];
if (!array_key_exists('toolbar_buttons', $preset_info) || !is_array($preset_info['toolbar_buttons'])) {
return false;
}
// always add search buttons
array_push($preset_info['toolbar_buttons'], 'search', 'search_reset_alt');
$toolbar_buttons = array_map('addslashes', $preset_info['toolbar_buttons']);
return $toolbar_buttons ? "'" . implode("', '", $toolbar_buttons) . "'" : 'false';
}
/**
* Checks, that "To" part of at least one of range filters is used
*
* @param Array $params
* @return bool
*/
function RangeFiltersUsed($params)
{
$search_helper =& $this->Application->recallObject('SearchHelper');
/* @var $search_helper kSearchHelper */
return $search_helper->rangeFiltersUsed($this->getPrefixSpecial(), $params['grid']);
}
/**
* This is abstract tag, used to modify unit config data based on template, where it's used.
* Tag is called from "combined_header" block in admin only.
*
* @param Array $params
*/
function ModifyUnitConfig($params)
{
}
/**
* Checks, that field is visible on edit form
*
* @param Array $params
* @return bool
*/
function FieldVisible($params)
{
$check_field = $params['field'];
$fields = $this->Application->getUnitOption($this->Prefix, 'Fields');
if (!array_key_exists($check_field, $fields)) {
// field not found in real fields array -> it's 100% virtual then
$fields = $this->Application->getUnitOption($this->Prefix, 'VirtualFields');
}
if (!array_key_exists($check_field, $fields)) {
$params['field'] = 'Password';
return $check_field == 'VerifyPassword' ? $this->FieldVisible($params) : true;
}
$show_mode = array_key_exists('show_mode', $fields[$check_field]) ? $fields[$check_field]['show_mode'] : true;
if ($show_mode === smDEBUG) {
return defined('DEBUG_MODE') && DEBUG_MODE;
}
return $show_mode;
}
/**
* Checks, that there area visible fields in given section on edit form
*
* @param Array $params
* @return bool
*/
function FieldsVisible($params)
{
if (!$params['fields']) {
return true;
}
$check_fields = explode(',', $params['fields']);
$fields = $this->Application->getUnitOption($this->Prefix, 'Fields');
$virtual_fields = $this->Application->getUnitOption($this->Prefix, 'VirtualFields');
foreach ($check_fields as $check_field) {
// when at least one field in subsection is visible, then subsection is visible too
if (array_key_exists($check_field, $fields)) {
$show_mode = array_key_exists('show_mode', $fields[$check_field]) ? $fields[$check_field]['show_mode'] : true;
}
else {
$show_mode = array_key_exists('show_mode', $virtual_fields[$check_field]) ? $virtual_fields[$check_field]['show_mode'] : true;
}
if (($show_mode === true) || (($show_mode === smDEBUG) && (defined('DEBUG_MODE') && DEBUG_MODE))) {
// field is visible
return true;
}
}
return false;
}
}
?>
\ No newline at end of file
Index: branches/RC/core/units/categories/categories_config.php
===================================================================
--- branches/RC/core/units/categories/categories_config.php (revision 11759)
+++ branches/RC/core/units/categories/categories_config.php (revision 11760)
@@ -1,390 +1,390 @@
<?php
$config = Array (
'Prefix' => 'c',
'ItemClass' => Array ('class' => 'CategoriesItem', 'file' => 'categories_item.php', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'CategoriesEventHandler', 'file' => 'categories_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'CategoriesTagProcessor', 'file' => 'categories_tag_processor.php', 'build_event' => 'OnBuild'),
'RegisterClasses' => Array (
Array ('pseudo' => 'kPermCacheUpdater', 'class' => 'kPermCacheUpdater', 'file' => 'cache_updater.php', 'build_event' => ''),
),
'ConfigPriority' => 0,
'Hooks' => Array (
Array (
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'adm', //self
'HookToSpecial' => '*',
'HookToEvent' => Array('OnRebuildThemes'),
'DoPrefix' => '',
'DoSpecial' => '',
'DoEvent' => 'OnAfterRebuildThemes',
),
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => '',
'HookToSpecial' => '*',
'HookToEvent' => Array('OnAfterConfigRead'),
'DoPrefix' => 'cdata',
'DoSpecial' => '*',
'DoEvent' => 'OnDefineCustomFields',
),
),
'AutoLoad' => true,
'CatalogItem' => true,
'AdminTemplatePath' => 'categories',
'AdminTemplatePrefix' => 'categories_',
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
'AggregateTags' => Array (
Array (
'AggregateTo' => 'm',
'AggregatedTagName' => 'CategoryLink',
'LocalTagName' => 'CategoryLink',
),
),
'IDField' => 'CategoryId',
'StatusField' => Array ('IsMenu'), // 'Status'
'TitleField' => 'Name',
'TitlePhrase' => 'la_Text_Category',
'ItemType' => 1, // used for custom fields only
'StatisticsInfo' => Array (
'pending' => Array (
'icon' => 'icon16_cat_pending.gif',
'label' => 'la_tab_Categories',
'js_url' => '#url#',
'url' => Array('t' => 'catalog/advanced_view', 'SetTab' => 'c', 'pass' => 'm,c.showall', 'c.showall_event' => 'OnSetFilterPattern', 'c.showall_filters' => 'show_active=0,show_pending=1,show_disabled=0,show_new=1,show_pick=1'),
'status' => STATUS_PENDING,
),
),
'TableName' => TABLE_PREFIX.'Category',
'ViewMenuPhrase' => 'la_text_Categories',
'CatalogTabIcon' => 'icon16_folder.gif',
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array ('c' => '!la_title_Adding_Page!'), // la_title_Adding_Category
'edit_status_labels' => Array ('c' => '!la_title_Editing_Page!'), // la_title_Editing_Category
),
'category_list' => Array ('prefixes' => Array ('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
'catalog' => Array (
'prefixes' => Array (), 'format' => "<span id='category_path'>!la_title_Categories!</span>",
'toolbar_buttons' => Array ('select', 'cancel', 'upcat', 'homecat', 'new_cat', 'new_link', 'new_article', 'new_topic', 'new_item', 'edit', 'delete', 'approve', 'decline', 'cut', 'copy', 'paste', 'move_up', 'move_down', 'rebuild_cache', 'view')
),
'advanced_view' => Array (
'prefixes' => Array (), 'format' => "!la_title_AdvancedView!",
'toolbar_buttons' => Array ('select', 'cancel', 'new_cat', 'new_link', 'new_article', 'new_topic', 'new_item', 'edit', 'delete', 'approve', 'decline', 'view'),
),
'reviews' => Array ('prefixes' => Array (), 'format' => "!la_title_Reviews!"),
'review_edit' => Array ('prefixes' => Array (), 'format' => "!la_title_Editing_Review!"),
'categories_edit' => Array ('prefixes' => Array ('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_General!"),
'categories_properties' => Array ('prefixes' => Array ('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Properties!"),
'categories_relations' => Array ('prefixes' => Array ('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Relations!"),
'categories_related_searches' => Array (
'prefixes' => Array ('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_RelatedSearches!",
'toolbar_buttons' => Array ('new_related_search', 'edit', 'delete', 'move_up', 'move_down', 'approve', 'decline', 'view'),
),
'categories_images' => Array ('prefixes' => Array ('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Images!"),
'categories_permissions' => Array ('prefixes' => Array ('c', 'g_List'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Permissions!"),
'categories_custom' => Array ('prefixes' => Array ('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Custom!"),
'categories_update' => Array ('prefixes' => Array (), 'format' => "!la_title_UpdatingCategories!"),
'images_edit' => Array (
'prefixes' => Array ('c', 'c-img'),
'new_status_labels' => Array ('c-img' => '!la_title_Adding_Image!'),
'edit_status_labels' => Array ('c-img' => '!la_title_Editing_Image!'),
'new_titlefield' => Array ('c-img' => ''),
'format' => "#c_status# '#c_titlefield#' - #c-img_status# '#c-img_titlefield#'",
),
'relations_edit' => Array (
'prefixes' => Array ('c', 'c-rel'),
'new_status_labels' => Array ('c-rel' => "!la_title_Adding_Relationship! '!la_title_New_Relationship!'"),
'edit_status_labels' => Array ('c-rel' => '!la_title_Editing_Relationship!'),
'format' => "#c_status# '#c_titlefield#' - #c-rel_status#",
),
'related_searches_edit' => Array (
'prefixes' => Array ('c', 'c-search'),
'new_status_labels' => Array ('c-search' => "!la_title_Adding_RelatedSearch_Keyword!"),
'edit_status_labels' => Array ('c-search' => '!la_title_Editing_RelatedSearch_Keyword!'),
'format' => "#c_status# '#c_titlefield#' - #c-search_status#",
),
'edit_content' => Array ('format' => '!la_EditingContent!'),
'tree_site' => Array ('format' => '!la_selecting_categories!'),
),
'EditTabPresets' => Array (
'Default' => Array (
'general' => Array ('title' => 'la_tab_General', 't' => 'categories/categories_edit', 'priority' => 1),
'properties' => Array ('title' => 'la_tab_Properties', 't' => 'categories/categories_edit_properties', 'priority' => 2),
'relations' => Array ('title' => 'la_tab_Relations', 't' => 'categories/categories_edit_relations', 'priority' => 3),
'related_searches' => Array ('title' => 'la_tab_Related_Searches', 't' => 'categories/categories_edit_related_searches', 'priority' => 4),
'images' => Array ('title' => 'la_tab_Images', 't' => 'categories/categories_edit_images', 'priority' => 5),
'permissions' => Array ('title' => 'la_tab_Permissions', 't' => 'categories/categories_edit_permissions', 'priority' => 6),
'custom' => Array ('title' => 'la_tab_Custom', 't' => 'categories/categories_edit_custom', 'priority' => 7),
),
),
'PermItemPrefix' => 'CATEGORY',
'PermSection' => Array ('main' => 'CATEGORY:in-portal:categories', /*'search' => 'in-portal:configuration_search',*/ 'email' => 'in-portal:configuration_email', 'custom' => 'in-portal:configuration_custom'),
'Sections' => Array (
'in-portal:configure_categories' => Array (
'parent' => 'in-portal:website_setting_folder',
'icon' => 'settings_output',
'label' => 'la_tab_ConfigOutput',
'url' => Array ('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view', 'edit'),
'priority' => 11.1,
'type' => stTREE,
),
'in-portal:configuration_search' => Array (
'parent' => 'in-portal:website_setting_folder',
'icon' => 'settings_search',
'label' => 'la_tab_ConfigSearch',
'url' => Array ('t' => 'config/config_search', 'module_key' => 'category', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view', 'edit'),
'priority' => 11.2,
'type' => stTREE,
),
'in-portal:configuration_email' => Array (
'parent' => 'in-portal:website_setting_folder',
'icon' => 'settings_email',
'label' => 'la_tab_ConfigE-mail',
'url' => Array ('t' => 'config/config_email', 'module' => 'Core:Category', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view', 'edit'),
'priority' => 11.3,
'type' => stTREE,
),
'in-portal:configuration_custom' => Array (
'parent' => 'in-portal:website_setting_folder',
'icon' => 'settings_custom',
'label' => 'la_tab_ConfigCustom',
'url' => Array ('t' => 'custom_fields/custom_fields_list', 'cf_type' => 1, 'pass_section' => true, 'pass' => 'm,cf'),
'permissions' => Array ('view', 'add', 'edit', 'delete'),
'priority' => 11.4,
'type' => stTREE,
),
),
'FilterMenu' => Array (
'Groups' => Array (
Array ('mode' => 'AND', 'filters' => Array ('show_active', 'show_pending', 'show_disabled'), 'type' => WHERE_FILTER),
Array ('mode' => 'AND', 'filters' => Array ('show_new'), 'type' => HAVING_FILTER),
Array ('mode' => 'AND', 'filters' => Array ('show_pick'), 'type' => WHERE_FILTER),
),
'Filters' => Array (
'show_active' => Array ('label' =>'la_Active', 'on_sql' => '', 'off_sql' => 'Status != 1'),
'show_pending' => Array ('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => 'Status != 2'),
'show_disabled' => Array ('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => 'Status != 0'),
's1' => Array (),
'show_new' => Array ('label' => 'la_Text_New', 'on_sql' => '', 'off_sql' => '`IsNew` != 1'),
'show_pick' => Array ('label' => 'la_prompt_EditorsPick', 'on_sql' => '', 'off_sql' => '`EditorsPick` != 1'),
)
),
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Images img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1
LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'
),
'SubItems' => Array ('c-rel', 'c-search','c-img', 'c-cdata', 'c-perm', 'content'),
'ListSortings' => Array (
'' => Array (
'Sorting' => Array ('Priority' => 'desc', 'Name' => 'asc'),
)
),
'CalculatedFields' => Array (
'' => Array (
'CurrentSort' => "REPLACE(ParentPath, CONCAT('|', ".'%1$s'.".CategoryId, '|'), '')",
'SameImages' => 'img.SameImages',
'LocalThumb' => 'img.LocalThumb',
'ThumbPath' => 'img.ThumbPath',
'ThumbUrl' => 'img.ThumbUrl',
'LocalImage' => 'img.LocalImage',
'LocalPath' => 'img.LocalPath',
'FullUrl' => 'img.Url',
)
),
'CacheModRewrite' => true,
'Fields' => Array (
'CategoryId' => Array ('type' => 'int', 'not_null' => 1,'default' => 0),
'Type' => Array ('type' => 'int', 'not_null' => 1,'default' => 0),
'SymLinkCategoryId' => Array ('type' => 'int', 'default' => NULL),
'ParentId' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (), 'not_null' => 1,'default' => 0, 'required' => 1),
'Name' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'format'=>'no_default', 'not_null' => 1, 'required' => 1, 'default' => ''),
'Filename' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'AutomaticFilename' => Array ('type' => 'int', 'not_null' => 1, 'default' => 1),
- 'Description' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'format'=>'no_default', 'default' => null),
+ 'Description' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'format' => 'no_default', 'using_fck' => 1, 'default' => null),
'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'required' => 1, 'not_null' => 1),
'EditorsPick' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Status' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled' ), 'use_phrases' => 1, 'not_null' => 1,'default' => 1),
'Priority' => Array ('type' => 'int', 'not_null' => 1, 'formatter' => 'kOptionsFormatter', 'options' => Array (), 'default' => 0),
- 'MetaKeywords' => Array ('type' => 'string', 'default' => null),
+ 'MetaKeywords' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
'CachedDescendantCatsQty' => Array ('type' => 'int', 'default' => 0),
'CachedNavbar' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'default' => null),
'CreatedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => 0),
'ResourceId' => Array ('type' => 'int', 'default' => null),
'ParentPath' => Array ('type' => 'string', 'default' => null),
'TreeLeft' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'TreeRight' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'NamedParentPath' => Array ('type' => 'string', 'default' => null),
- 'MetaDescription' => Array ('type' => 'string', 'default' => null),
+ 'MetaDescription' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
'HotItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'NewItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'PopItem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
'Modified' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1,'default' => '#NOW#'),
'ModifiedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => 0),
'CachedTemplate' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
// fields from Pages
'Template' => Array (
'type' => 'string',
'formatter' => 'kOptionsFormatter',
'options_sql' => ' SELECT CONCAT(tf.Description, " (", TRIM(TRAILING ".des" FROM TRIM(TRAILING ".tpl" FROM FileName) ), ")") AS Title,
CONCAT(FilePath, "/", TRIM(TRAILING ".tpl" FROM FileName)) AS Value
FROM ' . TABLE_PREFIX . 'ThemeFiles AS tf
LEFT JOIN ' . TABLE_PREFIX . 'Theme AS t ON t.ThemeId = tf.ThemeId
WHERE (t.Enabled = 1) AND (tf.FileName NOT LIKE "%%.elm.tpl") AND (tf.FileName NOT LIKE "%%.des.tpl") AND (tf.FilePath = "/designs")
ORDER BY tf.Description ASC, tf.FileName ASC',
'option_key_field' => 'Value', 'option_title_field' => 'Title',
/*'required' => 1,*/ 'default' => null
),
'UseExternalUrl' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0
),
'ExternalUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'UseMenuIconUrl' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0
),
'MenuIconUrl' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'Title' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'format'=>'no_default', 'default' => '', 'not_null'=>1),
'MenuTitle' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'format'=>'no_default', 'not_null' => 1, 'default' => ''),
'MetaTitle' => Array ('type' => 'string', 'default' => null),
- 'IndexTools' => Array ('type' => 'string', 'default' => null),
+ 'IndexTools' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
'IsIndex' =>
Array (
'type' => 'int', 'not_null' => 1, 'default' => 0,
'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_Regular', 1 => 'la_CategoryIndex', 2 => 'la_Container'), 'use_phrases' => 1,
),
'IsMenu' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Show', 0 => 'la_Hide'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1),
'IsSystem' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_System', 0 => 'la_Regular'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
'FormId' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array ('' => ''),
'options_sql' => 'SELECT Title, FormId FROM '.TABLE_PREFIX.'Forms ORDER BY Title',
'option_key_field' => 'FormId', 'option_title_field' => 'Title',
'default' => 0
),
'FormSubmittedTemplate' => Array ('type' => 'string', 'default' => null),
'Translated' => Array ('type' => 'int', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'default' => 0, 'db_type' => 'tinyint', 'index_type' => 'int'),
'FriendlyURL' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'ThemeId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
),
'VirtualFields' => Array (
'CurrentSort' => Array('type' => 'string', 'default' => ''),
'IsNew' => Array('type' => 'int', 'default' => 0),
'OldPriority' => Array('type' => 'int', 'default' => 0),
// for primary image
'SameImages' => Array('type' => 'string', 'default' => ''),
'LocalThumb' => Array('type' => 'string', 'default' => ''),
'ThumbPath' => Array('type' => 'string', 'default' => ''),
'ThumbUrl' => Array('type' => 'string', 'default' => ''),
'LocalImage' => Array('type' => 'string', 'default' => ''),
'LocalPath' => Array('type' => 'string', 'default' => ''),
'FullUrl' => Array('type' => 'string', 'default' => ''),
),
'Grids' => Array(
'Default' => Array (
'Icons' => Array(1 => 'icon16_folder.gif', 0 => 'icon16_folder-red.gif'),
'Fields' => Array(
'CategoryId' => Array( 'title'=>'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', ),
'Name' => Array( 'title'=>'la_col_PageTitle', 'data_block' => 'page_browse_td', 'filter_block' => 'grid_like_filter'),
'Modified' => Array( 'title'=>'la_col_Modified', 'filter_block' => 'grid_date_range_filter' ),
'Template' => Array( 'title'=>'la_col_TemplateType', 'filter_block' => 'grid_options_filter' ),
'IsMenu' => Array( 'title'=>'la_col_Visible', 'filter_block' => 'grid_options_filter' ),
'IsSystem' => Array( 'title'=>'la_col_System', 'filter_block' => 'grid_options_filter', ),
'Priority' => Array( 'title'=>'la_col_Priority', 'filter_block' => 'grid_options_filter', ),
),
),
'Radio' => Array (
'Selector' => 'radio',
'Icons' => Array(1 => 'icon16_folder.gif', 0 => 'icon16_folder-red.gif'),
'Fields' => Array(
'CategoryId' => Array( 'title'=>'la_col_Id', 'data_block' => 'grid_radio_td', 'filter_block' => 'grid_range_filter', ),
'Name' => Array( 'title'=>'la_col_PageTitle', 'data_block' => 'page_browse_td', 'filter_block' => 'grid_like_filter'),
'Modified' => Array( 'title'=>'la_col_Modified', 'filter_block' => 'grid_date_range_filter' ),
'Template' => Array( 'title'=>'la_col_TemplateType', 'filter_block' => 'grid_options_filter' ),
'IsMenu' => Array( 'title'=>'la_col_Visible', 'filter_block' => 'grid_options_filter' ),
'IsSystem' => Array( 'title'=>'la_col_System', 'filter_block' => 'grid_options_filter', ),
'Priority' => Array( 'title'=>'la_col_Priority', 'filter_block' => 'grid_options_filter', ),
),
),
'Structure' => Array (
'Icons' => Array(1 => 'icon16_folder.gif', 0 => 'icon16_folder-red.gif'),
'Fields' => Array(
'CategoryId' => Array( 'title'=>'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', ),
'Name' => Array( 'title'=>'la_col_PageTitle', 'data_block' => 'page_browse_td', 'filter_block' => 'grid_like_filter'),
'Modified' => Array( 'title'=>'la_col_Modified', 'filter_block' => 'grid_date_range_filter' ),
'Template' => Array( 'title'=>'la_col_TemplateType', 'filter_block' => 'grid_options_filter' ),
'IsMenu' => Array( 'title'=>'la_col_Visible', 'filter_block' => 'grid_options_filter' ),
'Path' => Array( 'title'=>'la_col_Path', 'data_block' => 'page_entercat_td', 'filter_block' => 'grid_like_filter' ),
'IsSystem' => Array( 'title'=>'la_col_System', 'filter_block' => 'grid_options_filter', ),
'Priority' => Array( 'title'=>'la_col_Priority', 'filter_block' => 'grid_options_filter', ),
),
),
),
'ConfigMapping' => Array (
'PerPage' => 'Perpage_Category',
'ShortListPerPage' => 'Perpage_Category_Short',
'DefaultSorting1Field' => 'Category_Sortfield',
'DefaultSorting2Field' => 'Category_Sortfield2',
'DefaultSorting1Dir' => 'Category_Sortorder',
'DefaultSorting2Dir' => 'Category_Sortorder2',
),
);
\ No newline at end of file
Index: branches/RC/core/units/categories/categories_tag_processor.php
===================================================================
--- branches/RC/core/units/categories/categories_tag_processor.php (revision 11759)
+++ branches/RC/core/units/categories/categories_tag_processor.php (revision 11760)
@@ -1,2036 +1,2002 @@
<?php
class CategoriesTagProcessor extends kDBTagProcessor {
/**
* Cached version of site menu
*
* @var Array
*/
var $Menu = null;
/**
* Parent path mapping used in CachedMenu tag
*
* @var Array
*/
var $ParentPaths = Array ();
function SubCatCount($params)
{
$object =& $this->getObject($params);
if (isset($params['today']) && $params['today']) {
$sql = 'SELECT COUNT(*)
FROM '.$object->TableName.'
WHERE (ParentPath LIKE "'.$object->GetDBField('ParentPath').'%") AND (CreatedOn > '.(adodb_mktime() - 86400).')';
return $this->Conn->GetOne($sql) - 1;
}
return $object->GetDBField('CachedDescendantCatsQty');
}
/**
* Returns category count in system
*
* @param Array $params
* @return int
*/
function CategoryCount($params)
{
$count_helper =& $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
$today_only = isset($params['today']) && $params['today'];
return $count_helper->CategoryCount($today_only);
}
function IsNew($params)
{
$object =& $this->getObject($params);
return $object->GetDBField('IsNew') ? 1 : 0;
}
function IsPick($params)
{
return $this->IsEditorsPick($params);
}
/**
* Returns item's editors pick status (using not formatted value)
*
* @param Array $params
* @return bool
*/
function IsEditorsPick($params)
{
$object =& $this->getObject($params);
return $object->GetDBField('EditorsPick') == 1;
}
function ItemIcon($params)
{
// only for categories, not structure
if ($this->Prefix != 'c') {
return parent::ItemIcon($params);
}
$object =& $this->getObject($params);
if ($object->GetDBField('IsMenu')) {
$status = $object->GetDBField('Status');
if ($status == 1) {
$ret = $object->GetDBField('IsNew') ? 'icon16_cat_new.gif' : 'icon16_folder.gif';
}
else {
$ret = $status ? 'icon16_cat_pending.gif' : 'icon16_cat_disabled.gif';
}
}
else {
$ret = 'icon16_folder-red.gif';
}
return $ret;
}
function ItemCount($params)
{
$object =& $this->getObject($params);
$ci_table = $this->Application->getUnitOption('l-ci', 'TableName');
$sql = 'SELECT COUNT(*)
FROM ' . $object->TableName . ' c
LEFT JOIN ' . $ci_table . ' ci ON c.CategoryId = ci.CategoryId
WHERE (c.TreeLeft BETWEEN ' . $object->GetDBField('TreeLeft') . ' AND ' . $object->GetDBField('TreeRight') . ') AND NOT (ci.CategoryId IS NULL)';
return $this->Conn->GetOne($sql);
}
function ListCategories($params)
{
return $this->PrintList2($params);
}
function RootCategoryName($params)
{
return $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
}
function CheckModuleRoot($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
$module_root_cat = $this->Application->findModule('Name', $module_name, 'RootCat');
$additional_cats = $this->SelectParam($params, 'add_cats');
if ($additional_cats) {
$additional_cats = explode(',', $additional_cats);
}
else {
$additional_cats = array();
}
if ($this->Application->GetVar('m_cat_id') == $module_root_cat || in_array($this->Application->GetVar('m_cat_id'), $additional_cats)) {
$home_template = getArrayValue($params, 'home_template');
if (!$home_template) return;
$this->Application->Redirect($home_template, Array('pass'=>'all'));
};
}
function CategoryPath($params)
{
$category_helper =& $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
return $category_helper->NavigationBar($params);
}
/**
* Shows category path to specified category
*
* @param Array $params
* @return string
*/
function FieldCategoryPath($params)
{
$object =& $this->getObject();
/* @var $object kDBItem */
$field = $this->SelectParam($params, 'name,field');
$category_id = $object->GetDBField($field);
if ($category_id) {
$params['cat_id'] = $category_id;
return $this->CategoryPath($params);
}
return '';
}
function CurrentCategoryName($params)
{
$cat_object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List');
$sql = 'SELECT '.$this->getTitleField().'
FROM '.$cat_object->TableName.'
WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
return $this->Conn->GetOne($sql);
}
/**
* Returns current category name
*
* @param Array $params
* @return string
* @todo Find where it's used
*/
function CurrentCategory($params)
{
return $this->CurrentCategoryName($params);
}
function getTitleField()
{
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
return $ml_formatter->LangFieldName('Name');
}
function getCategorySymLink($category_id)
{
static $cache = null;
if (!isset($cache)) {
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
$sql = 'SELECT SymLinkCategoryId, '.$id_field.'
FROM '.$table_name.'
WHERE SymLinkCategoryId IS NOT NULL';
$cache = $this->Conn->GetCol($sql, $id_field);
}
if (isset($cache[$category_id])) {
//check if sym. link category is valid
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
$sql = 'SELECT '.$id_field.'
FROM '.$table_name.'
WHERE '.$id_field.' = '.$cache[$category_id];
$category_id = $this->Conn->GetOne($sql)? $cache[$category_id] : $category_id;
}
return $category_id;
}
function CategoryLink($params)
{
$category_id = getArrayValue($params, 'cat_id');
if ($category_id === false) {
$category_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
}
if ("$category_id" == 'Root') {
$category_id = $this->Application->findModule('Name', $params['module'], 'RootCat');
}
elseif ("$category_id" == 'current') {
$category_id = $this->Application->GetVar('m_cat_id');
}
$category_id = $this->getCategorySymLink($category_id);
unset($params['cat_id'], $params['module']);
$new_params = Array ('pass' => 'm', 'm_cat_id' => $category_id, 'pass_category' => 1);
$params = array_merge_recursive2($params, $new_params);
return $this->Application->ProcessParsedTag('m', 't', $params);
}
function CategoryList($params)
{
//$object =& $this->Application->recallObject( $this->getPrefixSpecial() , $this->Prefix.'_List', $params );
$object =& $this->GetList($params);
if ($object->RecordsCount == 0)
{
if (isset($params['block_no_cats'])) {
$params['name'] = $params['block_no_cats'];
return $this->Application->ParseBlock($params);
}
else {
return '';
}
}
if (isset($params['block'])) {
return $this->PrintList($params);
}
else {
$params['block'] = $params['block_main'];
if (isset($params['block_row_start'])) {
$params['row_start_block'] = $params['block_row_start'];
}
if (isset($params['block_row_end'])) {
$params['row_end_block'] = $params['block_row_end'];
}
return $this->PrintList2($params);
}
}
function Meta($params)
{
$object =& $this->Application->recallObject($this->Prefix); // .'.-item'
/* @var $object CategoriesItem */
$meta_type = $params['name'];
if ($object->isLoaded()) {
// 1. get module prefix by current category
$category_helper =& $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
$category_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1));
$module_info = $category_helper->getCategoryModule($params, $category_path);
// In-Edit & Proj-CMS module prefixes doesn't have custom field with item template
if ($module_info && $module_info['Var'] != 'adm' && $module_info['Var'] != 'st') {
// 2. get item template by current category & module prefix
$mod_rewrite_helper = $this->Application->recallObject('ModRewriteHelper');
/* @var $mod_rewrite_helper kModRewriteHelper */
$category_params = Array (
'CategoryId' => $object->GetID(),
'ParentPath' => $object->GetDBField('ParentPath'),
);
$item_template = $mod_rewrite_helper->GetItemTemplate($category_params, $module_info['Var']);
if ($this->Application->GetVar('t') == $item_template) {
// we are located on item's details page
$item =& $this->Application->recallObject($module_info['Var']);
/* @var $item kCatDBItem */
// 3. get item's meta data
$value = $item->GetField('Meta'.$meta_type);
if ($value) {
return $value;
}
}
// 4. get category meta data
$value = $object->GetField('Meta'.$meta_type);
if ($value) {
return $value;
}
}
}
// 5. get default meta data
switch ($meta_type) {
case 'Description':
$config_name = 'Category_MetaDesc';
break;
case 'Keywords':
$config_name = 'Category_MetaKey';
break;
}
return $this->Application->ConfigValue($config_name);
}
function BuildListSpecial($params)
{
if ( isset($params['parent_cat_id']) ) {
$parent_cat_id = $params['parent_cat_id'];
}
else {
$parent_cat_id = $this->Application->GetVar($this->Prefix.'_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
$no_special = isset($params['no_special']) && $params['no_special'];
if ($no_special) return $this->Special;
$list_unique_key = $this->getUniqueListKey($params);
// check for "admin" variable, because we are parsing front-end template from admin when using template editor feature
if ($this->Application->GetVar('admin') || !$this->Application->IsAdmin()) {
// add parent category to special, when on Front-End,
// because there can be many category lists on same page
$list_unique_key .= $parent_cat_id;
}
if ($list_unique_key == '') {
return parent::BuildListSpecial($params);
}
return crc32($list_unique_key);
}
function IsCurrent($params)
{
$object =& $this->getObject($params);
if ($object->GetID() == $this->Application->GetVar('m_cat_id')) {
return true;
}
else {
return false;
}
}
/**
* Substitutes category in last template base on current category
* This is required becasue when you navigate catalog using AJAX, last_template is not updated
* but when you open item edit from catalog last_template is used to build opener_stack
* So, if we don't substitute m_cat_id in last_template, after saving item we'll get redirected
* to the first category we've opened, not the one we navigated to using AJAX
*
* @param Array $params
*/
function UpdateLastTemplate($params)
{
$category_id = $this->Application->GetVar('m_cat_id');
$wid = $this->Application->GetVar('m_wid');
list($index_file, $env) = explode('|', $this->Application->RecallVar(rtrim('last_template_'.$wid, '_')), 2);
$vars_backup = Array ();
$vars = $this->Application->HttpQuery->processQueryString( str_replace('%5C', '\\', $env) );
foreach ($vars as $var_name => $var_value) {
$vars_backup[$var_name] = $this->Application->GetVar($var_name);
$this->Application->SetVar($var_name, $var_value);
}
// update required fields
$this->Application->SetVar('m_cat_id', $category_id);
$this->Application->Session->SaveLastTemplate($params['template']);
foreach ($vars_backup as $var_name => $var_value) {
$this->Application->SetVar($var_name, $var_value);
}
}
function GetParentCategory($params)
{
$parent_id = 0;
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table = $this->Application->getUnitOption($this->Prefix,'TableName');
$cat_id = $this->Application->GetVar('m_cat_id');
if ($cat_id > 0) {
$sql = 'SELECT ParentId
FROM '.$table.'
WHERE '.$id_field.' = '.$cat_id;
$parent_id = $this->Conn->GetOne($sql);
}
return $parent_id;
}
function InitCacheUpdater($params)
{
safeDefine('CACHE_PERM_CHUNK_SIZE', 30);
$continue = $this->Application->GetVar('continue');
$total_cats = (int) $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
if ($continue === false && $total_cats > CACHE_PERM_CHUNK_SIZE) {
// first step, if category count > CACHE_PERM_CHUNK_SIZE, then ask for cache update
return true;
}
if ($continue === false) {
// if we don't have to ask, then assume user selected "Yes" in permcache update dialog
$continue = 1;
}
$updater =& $this->Application->recallObject('kPermCacheUpdater', null, Array('continue' => $continue));
/* @var $updater kPermCacheUpdater */
if ($continue === '0') { // No in dialog
$updater->clearData();
$this->Application->Redirect($params['destination_template']);
}
$ret = false; // don't ask for update
if ($continue == 1) { // Initial run
$updater->setData();
}
if ($continue == 2) { // Continuing
// called from AJAX request => returns percent
$needs_more = true;
while ($needs_more && $updater->iteration <= CACHE_PERM_CHUNK_SIZE) {
// until proceeeded in this step category count exceeds category per step limit
$needs_more = $updater->DoTheJob();
}
if ($needs_more) {
// still some categories are left for next step
$updater->setData();
}
else {
// all done -> redirect
$updater->SaveData();
$this->Application->RemoveVar('PermCache_UpdateRequired');
$this->Application->Redirect($params['destination_template']);
}
$ret = $updater->getDonePercent();
}
return $ret;
}
/**
* Parses warning block, but with style="display: none;". Used during permissions saving from AJAX
*
* @param Array $params
* @return string
*/
function SaveWarning($params)
{
if ($this->Prefix == 'st') {
// don't use this method for other prefixes then Category, that use this tag processor
return parent::SaveWarning($params);
}
$main_prefix = getArrayValue($params, 'main_prefix');
if ($main_prefix && $main_prefix != '$main_prefix') {
$top_prefix = $main_prefix;
}
else {
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
$temp_tables = substr($this->Application->GetVar($top_prefix.'_mode'), 0, 1) == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
if (!$temp_tables) {
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
$block_name = $this->SelectParam($params, 'render_as,name');
if ($block_name) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $block_name;
$block_params['edit_mode'] = $temp_tables ? 1 : 0;
$block_params['display'] = $temp_tables && $modified ? 1 : 0;
return $this->Application->ParseBlock($block_params);
}
else {
return $temp_tables && $modified ? 1 : 0;
}
return ;
}
/**
* Allows to detect if this prefix has something in clipboard
*
* @param Array $params
* @return bool
*/
function HasClipboard($params)
{
$clipboard = $this->Application->RecallVar('clipboard');
if ($clipboard) {
$clipboard = unserialize($clipboard);
foreach ($clipboard as $prefix => $clipboard_data) {
foreach ($clipboard_data as $mode => $ids) {
if (count($ids)) return 1;
}
}
}
return 0;
}
/**
* Allows to detect if root category being edited
*
* @param Array $params
*/
function IsRootCategory($params)
{
$object =& $this->getObject($params);
return $object->IsRoot();
}
/**
* Returns home category id
*
* @param Array $params
* @return int
*/
function HomeCategory($params)
{
static $root_category = null;
if (!isset($root_category)) {
$root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
}
return $root_category;
}
/**
* Used for disabling "Home" and "Up" buttons in category list
*
* @param Array $params
* @return bool
*/
function ModuleRootCategory($params)
{
return $this->Application->GetVar('m_cat_id') == $this->HomeCategory($params);
}
function CatalogItemCount($params)
{
$object =& $this->GetList($params);
if (!$object->Counted) {
$object->CountRecs();
}
return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintPages($params)
{
if ($this->Application->Parser->GetParam('no_special')) {
$params['no_special'] = $this->Application->Parser->GetParam('no_special');
}
return parent::PrintPages($params);
}
function InitCatalog($params)
{
$tab_prefixes = $this->Application->GetVar('tp'); // {all, <prefixes_list>, none}
if ($tab_prefixes === false) $tab_prefixes = 'all';
$skip_prefixes = isset($params['skip_prefixes']) && $params['skip_prefixes'] ? explode(',', $params['skip_prefixes']) : Array();
$replace_main = isset($params['replace_m']) && $params['replace_m'];
// get all prefixes available
$prefixes = Array();
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
$prefix = $module_data['Var'];
if ($prefix == 'adm'/* || $prefix == 'm'*/) continue;
if ($prefix == 'm' && $replace_main) {
$prefix = 'c';
}
$prefixes[] = $prefix;
}
if ($tab_prefixes == 'none') {
$skip_prefixes = array_unique(array_merge($skip_prefixes, $prefixes));
unset($skip_prefixes[ array_search($replace_main ? 'c' : 'm', $skip_prefixes) ]);
}
elseif ($tab_prefixes != 'all') {
// prefix list here
$tab_prefixes = explode(',', $tab_prefixes); // list of prefixes that should stay
$skip_prefixes = array_unique(array_merge($skip_prefixes, array_diff($prefixes, $tab_prefixes)));
}
$params['name'] = $params['render_as'];
$params['skip_prefixes'] = implode(',', $skip_prefixes);
return $this->Application->ParseBlock($params, 1);
}
/**
* Determines, that printed category/menu item is currently active (will also match parent category)
*
* @param Array $params
* @return bool
*/
function IsActive($params)
{
static $current_path = null;
if (!isset($current_path)) {
$sql = 'SELECT ParentPath
FROM ' . TABLE_PREFIX . 'Category
WHERE CategoryId = ' . $this->Application->GetVar('m_cat_id');
$current_path = $this->Conn->GetOne($sql);
}
if (array_key_exists('parent_path', $params)) {
$test_path = $params['parent_path'];
}
else {
$template = $params['template'];
if ($template) {
// when using from "c:CachedMenu" tag
$sql = 'SELECT ParentPath
FROM ' . TABLE_PREFIX . 'Category
WHERE NamedParentPath = ' . $this->Conn->qstr('Content/' . $template);
$test_path = $this->Conn->GetOne($sql);
}
else {
// when using from "c:PrintList" tag
$cat_id = array_key_exists('cat_id', $params) && $params['cat_id'] ? $params['cat_id'] : false;
if ($cat_id === false) {
// category not supplied -> get current from PrintList
$category =& $this->getObject($params);
}
else {
if ("$cat_id" == 'Root') {
$cat_id = $this->Application->findModule('Name', $params['module'], 'RootCat');
}
$category =& $this->Application->recallObject($this->Prefix . '.-c' . $cat_id, $this->Prefix, Array ('skip_autoload' => true));
$category->Load($cat_id);
}
$test_path = $category->GetDBField('ParentPath');
}
}
return strpos($current_path, $test_path) !== false;
}
/**
* Checks if user have one of required permissions
*
* @param Array $params
* @return bool
*/
function HasPermission($params)
{
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$params['raise_warnings'] = 0;
$object =& $this->getObject($params);
/* @var $object kDBItem */
$params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
return $perm_helper->TagPermissionCheck($params);
}
/**
* Prepares name for field with event in it (used only on front-end)
*
* @param Array $params
* @return string
*/
function SubmitName($params)
{
return 'events['.$this->Prefix.']['.$params['event'].']';
}
/**
* Returns last modification date of items in category / system
*
* @param Array $params
* @return string
*/
function LastUpdated($params)
{
$category_id = $this->Application->GetVar('m_cat_id');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
if (isset($params['local']) && $params['local'] && $category_id > 0) {
// scan only current category & it's children
$sql = 'SELECT TreeLeft, TreeRight
FROM '.TABLE_PREFIX.'Category
WHERE CategoryId = '.$category_id;
$tree_info = $this->Conn->GetRow($sql);
$sql = 'SELECT MAX(c.Modified) AS ModDate, MAX(c.CreatedOn) AS NewDate
FROM '.TABLE_PREFIX.'Category c
WHERE c.TreeLeft BETWEEN '.$tree_info['TreeLeft'].' AND '.$tree_info['TreeRight'];
}
else {
// scan all categories in system
$sql = 'SELECT MAX(Modified) AS ModDate, MAX(CreatedOn) AS NewDate
FROM '.$table_name;
}
$row_data = $this->Conn->GetRow($sql);
if (!$row_data) {
return '';
}
$date = $row_data[ $row_data['NewDate'] > $row_data['ModDate'] ? 'NewDate' : 'ModDate' ];
// format date
$format = isset($params['format']) ? $params['format'] : '_regional_DateTimeFormat';
if (preg_match("/_regional_(.*)/", $format, $regs)) {
$lang =& $this->Application->recallObject('lang.current');
if ($regs[1] == 'DateTimeFormat') {
// combined format
$format = $lang->GetDBField('DateFormat').' '.$lang->GetDBField('TimeFormat');
}
else {
// simple format
$format = $lang->GetDBField($regs[1]);
}
}
return adodb_date($format, $date);
}
function CategoryItemCount($params)
{
$object =& $this->getObject($params);
/* @var $object kDBList */
$params['cat_id'] = $object->GetID();
$count_helper =& $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
return $count_helper->CategoryItemCount($params['prefix'], $params);
}
/**
* Returns prefix + any word (used for shared between categories per page settings)
*
* @param Array $params
* @return string
*/
function VarName($params)
{
return $this->Prefix.'_'.$params['type'];
}
/**
* Checks if current category is valid symbolic link to another category
*
* @param Array $params
* @return string
*/
function IsCategorySymLink($params)
{
$object =& $this->getObject($params);
/* @var $object kDBList */
$sym_category_id = $object->GetDBField('SymLinkCategoryId');
if (is_null($sym_category_id))
{
return false;
}
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
$sql = 'SELECT '.$id_field.'
FROM '.$table_name.'
WHERE '.$id_field.' = '.$sym_category_id;
return $this->Conn->GetOne($sql)? true : false;
}
/**
* Returns module prefix based on root category for given
*
* @param Array $params
* @return string
*/
function GetModulePrefix($params)
{
$object =& $this->getObject($params);
/* @var $object kDBItem */
$parent_path = explode('|', substr($object->GetDBField('ParentPath'), 1, -1));
$category_helper =& $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
$module_info = $category_helper->getCategoryModule($params, $parent_path);
return $module_info['Var'];
}
function ImageSrc($params)
{
list ($ret, $tag_processed) = $this->processAggregatedTag('ImageSrc', $params, $this->getPrefixSpecial());
return $tag_processed ? $ret : false;
}
function PageLink($params)
{
$t = isset($params['template']) ? $params['template'] : '';
unset($params['template']);
if (!$t) $t = $this->Application->GetVar('t');
if (isset($params['page'])) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $params['page']);
unset($params['page']);
}
$params['m_cat_page'] = $this->Application->GetVar($this->getPrefixSpecial().'_Page');
if (!isset($params['pass'])) {
$params['pass'] = 'm,'.$this->getPrefixSpecial();
}
return $this->Application->HREF($t, '', $params);
}
/**
* Returns spelling suggestions against search keyword
*
* @param Array $params
* @return string
*/
function SpellingSuggestions($params)
{
$keywords = unhtmlentities( trim($this->Application->GetVar('keywords')) );
if (!$keywords) {
return ;
}
// 1. try to get already cached suggestion
$suggestion = $this->Application->getCache('search.suggestion', $keywords);
if ($suggestion !== false) {
return $suggestion;
}
$table_name = $this->Application->getUnitOption('spelling-dictionary', 'TableName');
// 2. search suggestion in database
$sql = 'SELECT SuggestedCorrection
FROM ' . $table_name . '
WHERE MisspelledWord = ' . $this->Conn->qstr($keywords);
$suggestion = $this->Conn->GetOne($sql);
if ($suggestion !== false) {
$this->Application->setCache('search.suggestion', $keywords, $suggestion);
return $suggestion;
}
// 3. suggestion not found in database, ask webservice
$app_id = $this->Application->ConfigValue('YahooApplicationId');
$url = 'http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?appid=' . $app_id . '&query=';
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
$xml_data = $curl_helper->Send($url . urlencode($keywords));
$xml_helper =& $this->Application->recallObject('kXMLHelper');
/* @var $xml_helper kXMLHelper */
$root_node =& $xml_helper->Parse($xml_data);
$result = $root_node->FindChild('RESULT');
/* @var $result kXMLNode */
if (is_object($result)) {
// webservice responded -> save in local database
$fields_hash = Array (
'MisspelledWord' => $keywords,
'SuggestedCorrection' => $result->Data,
);
$this->Conn->doInsert($fields_hash, $table_name);
$this->Application->setCache('search.suggestion', $keywords, $result->Data);
return $result->Data;
}
return '';
}
/**
* Shows link for searching by suggested word
*
* @param Array $params
* @return string
*/
function SuggestionLink($params)
{
$params['keywords'] = $this->SpellingSuggestions($params);
return $this->Application->ProcessParsedTag('m', 'Link', $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'];
$special = $tab_params['special'] ? $tab_params['special'] : $this->Special;
$params['prefix'] = trim($this->Prefix.'.'.$special, '.');
$prefix_append = $this->Application->GetVar('prefix_append');
if ($prefix_append) {
$params['prefix'] .= $prefix_append;
}
$default_grid = array_key_exists('default_grid', $params) ? $params['default_grid'] : 'Default';
$radio_grid = array_key_exists('radio_grid', $params) ? $params['radio_grid'] : 'Radio';
$params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.');
$params['tab_mode'] = $tab_params['mode'];
$params['grid_name'] = ($tab_params['mode'] == 'multi') ? $default_grid : $radio_grid;
$params['tab_dependant'] = $tab_params['dependant'];
$params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name
if ($special == 'showall' || $special == 'user') {
$params['grid_name'] .= 'ShowAll';
}
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) {
$cached_navbar = $object->GetField('CachedNavbar');
if ($category_id == $object->GetDBField('ParentId')) {
// parent category cached navbar is one element smaller, then current ones
$cached_navbar = explode('&|&', $cached_navbar);
array_pop($cached_navbar);
$cached_navbar = implode('&|&', $cached_navbar);
}
else {
// no relation with current category object -> query from db
$sql = 'SELECT l' . $this->Application->GetVar('m_lang') . '_CachedNavbar
FROM ' . $object->TableName . '
WHERE ' . $object->IDField . ' = ' . $category_id;
$cached_navbar = $this->Conn->GetOne($sql);
}
$cached_navbar = preg_replace('/^(Content&\|&|Content)/i', '', $cached_navbar);
$category_path = trim($this->CategoryName( Array('cat_id' => 0) ).' > '.str_replace('&|&', ' > ', $cached_navbar), ' > ');
}
else {
$category_path = $this->Application->Phrase( $this->Application->ConfigValue('Root_Name') );
}
$this->Application->setCache('category_paths', $category_id, $category_path);
}
return $category_path;
}
// structure related
/**
* Returns page object based on requested params
*
* @param Array $params
* @return PagesItem
*/
function &_getPage($params)
{
$page =& $this->Application->recallObject($this->Prefix . '.-virtual', null, $params);
/* @var $page kDBItem */
// 1. load by given id
$page_id = array_key_exists('page_id', $params) ? $params['page_id'] : false;
if ($page_id) {
if ($page_id != $page->GetID()) {
// load if different
$page->Load($page_id);
}
return $page;
}
// 2. load by template
$template = array_key_exists('page', $params) ? $params['page'] : '';
if (!$template) {
$template = $this->Application->GetVar('t');
}
// different path in structure AND design template differes from requested template
$structure_path_match = strtolower( $page->GetDBField('NamedParentPath') ) == strtolower('Content/' . $template);
$design_match = $page->GetDBField('CachedTemplate') == $template;
if (!$structure_path_match && !$design_match) {
// Same sql like in "c:getPassedID". Load, when current page object doesn't match requested page object
$themes_helper =& $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
$page_id = $themes_helper->getPageByTemplate($template);
$page->Load($page_id);
}
return $page;
}
/**
* Returns requested content block content of current or specified page
*
* @param Array $params
* @return string
*/
function ContentBlock($params)
{
$num = getArrayValue($params, 'num');
if (!$num) {
return 'NO CONTENT NUM SPECIFIED';
}
$page =& $this->_getPage($params);
/* @var $page kDBItem */
if (!$page->isLoaded()) {
// page is not created yet => all blocks are empty
return '';
}
$page_id = $page->GetID();
$content =& $this->Application->recallObject('content.-block', null, Array ('skip_autoload' => true));
/* @var $content kDBItem */
$data = Array ('PageId' => $page_id, 'ContentNum' => $num);
$content->Load($data);
if (!$content->isLoaded()) {
// bug: missing content blocks are created even if user have no SMS-management rights
$content->SetFieldsFromHash($data);
$content->Create();
}
$edit_code_before = $edit_code_after = '';
if (EDITING_MODE == EDITING_MODE_CMS) {
$bg_color = isset($params['bgcolor']) ? $params['bgcolor'] : '#ffffff';
$url_params = Array (
'pass' => 'm,c,content',
'm_opener' => 'd',
'c_id' => $page->GetID(),
'content_id' => $content->GetID(),
'front' => 1,
'admin' => 1,
'__URLENCODE__' => 1,
'__NO_REWRITE__'=> 1,
'escape' => 1,
'index_file' => 'index.php',
// 'bgcolor' => $bg_color,
// '__FORCE_SID__' => 1
);
$additional_css = '';
if (isset($params['float'])) {
$additional_css .= 'position: relative; width: 100%; float: ' . $params['float'] . ';';
}
// link from Front-End to admin, don't remove "index.php"
$edit_url = $this->Application->HREF('categories/edit_content', ADMIN_DIRECTORY, $url_params, 'index.php');
$edit_code_before = '
<div class="cms-edit-btn-container">
<div class="cms-edit-btn" style="' . $additional_css . '" onclick="$form_name=\'kf_cont_'.$content->GetID().'\'; open_popup(\'content\', \'OnEdit\', \'categories/edit_content\');">
<div class="cms-btn-image">
<img src="' . $this->Application->BaseURL() . 'core/admin_templates/img/top_frame/icons/content_mode.gif" width="15" height="16" alt=""/>
</div>
<div class="cms-btn-text">Edit '.(defined('DEBUG_MODE') && DEBUG_MODE ? " - #{$num}" : '').'</div>
</div>
<div class="cms-btn-content">';
$edit_form = '<form method="POST" style="display: inline; margin: 0px" name="kf_cont_'.$content->GetID().'" id="kf_cont_'.$content->GetID().'" action="'.$edit_url.'">';
$edit_form .= '<input type="hidden" name="c_id" value="'.$page->GetID().'"/>';
$edit_form .= '<input type="hidden" name="content_id" value="'.$content->GetID().'"/>';
$edit_form .= '<input type="hidden" name="front" value="1"/>';
$edit_form .= '<input type="hidden" name="bgcolor" value="'.$bg_color.'"/>';
$edit_form .= '<input type="hidden" name="m_lang" value="'.$this->Application->GetVar('m_lang').'"/>';
$edit_form .= '</form>';
$edit_code_after = '</div></div>';
if (array_key_exists('forms_later', $params) && $params['forms_later']) {
$all_forms = $this->Application->GetVar('all_forms');
$this->Application->SetVar('all_forms', $all_forms . $edit_form);
}
else {
$edit_code_after .= $edit_form;
}
}
if ($this->Application->GetVar('_editor_preview_') == 1) {
$data = $this->Application->RecallVar('_editor_preview_content_');
} else {
$data = $content->GetField('Content');
}
- $data = $this->_transformContentBlockData($data, $params);
-
- return $edit_code_before . $this->_replacePageIds($data) . $edit_code_after;
+ return $edit_code_before . $this->_transformContentBlockData($data, $params) . $edit_code_after;
}
/**
* Apply all kinds of content block data transformations without rewriting ContentBlock tag
*
* @param string $data
* @return string
*/
function _transformContentBlockData(&$data, $params)
{
return $data;
}
/**
- * Replace links like "@@ID@@" to actual template names in given text
- *
- * @param string $text
- * @return string
- */
- function _replacePageIds($text)
- {
- if (!preg_match_all('/@@(\\d+)@@/', $text, $regs)) {
- return $text;
- }
-
- $page_ids = $regs[1];
-
- $sql = 'SELECT NamedParentPath, CategoryId
- FROM ' . TABLE_PREFIX . 'Category
- WHERE CategoryId IN (' . implode(',', $page_ids) . ')';
-
- $templates = $this->Conn->GetCol($sql, 'CategoryId');
-
- foreach ($page_ids as $page_id) {
- if (!array_key_exists($page_id, $templates)) {
- // internal page was deleted, but link to it was found in given content block data
- continue;
- }
-
- $text = preg_replace('/@@' . $page_id . '@@/', $this->Application->HREF(strtolower($templates[$page_id]), '', Array ('pass' => 'm')), $text);
- }
-
- return $text;
- }
-
- /**
* Returns current page name or page based on page/page_id parameters
*
* @param Array $params
* @return string
* @todo Used?
*/
function PageName($params)
{
$page =& $this->_getPage($params);
return $page->GetDBField('Name');
}
/**
* Returns current/given page information
*
* @param Array $params
* @return string
*/
function PageInfo($params)
{
$page =& $this->_getPage($params);
if ($params['type'] == 'index_tools') {
$page_info = $page->GetDBField('IndexTools');
if ($page_info) {
return $page_info;
}
else {
if (PROTOCOL == 'https://') {
return $this->Application->ConfigValue('cms_DefaultIndextoolsCode_SSL');
}
else {
return $this->Application->ConfigValue('cms_DefaultIndextoolsCode');
}
}
}
switch ($params['type']) {
case 'title':
$db_field = 'Title';
break;
case 'htmlhead_title':
$db_field = 'Name';
break;
case 'meta_title':
$db_field = 'MetaTitle';
break;
case 'meta_keywords':
$db_field = 'MetaKeywords';
$cat_field = 'Keywords';
break;
case 'meta_description':
$db_field = 'MetaDescription';
$cat_field = 'Description';
break;
default:
return '';
}
$default = isset($params['default']) ? $params['default'] : '';
$val = $page->GetField($db_field);
if (!$default) {
if ($this->Application->isModuleEnabled('In-Portal')) {
if (!$val && ($params['type'] == 'meta_keywords' || $params['type'] == 'meta_description')) {
// take category meta if it's not set for the page
return $this->Application->ProcessParsedTag('c', 'Meta', Array('name' => $cat_field));
}
}
}
if (isset($params['force_default']) && $params['force_default']) {
return $default;
}
if (preg_match('/^_Auto:/', $val)) {
$val = $default;
/*if ($db_field == 'Title') {
$page->SetDBField($db_field, $default);
$page->Update();
}*/
}
elseif ($page->GetID() == false) {
return $default;
}
return $val;
}
/**
* Includes admin css and js, that are required for cms usage on Front-Edn
*
*
* @param Array $params
* @return string
*/
function EditingScripts($params)
{
if ($this->Application->GetVar('admin_scripts_included') || !EDITING_MODE) {
return ;
}
$this->Application->SetVar('admin_scripts_included', 1);
$js_url = $this->Application->BaseURL() . 'core/admin_templates/js';
$ret = '<link rel="stylesheet" href="' . $js_url . '/jquery/thickbox/thickbox.css" type="text/css" media="screen"/>' . "\n";
$ret .= '<link rel="stylesheet" href="' . $js_url . '/../incs/cms.css" type="text/css" media="screen"/>' . "\n";
if (EDITING_MODE == EDITING_MODE_LAYOUT) {
$ret .= ' <style type="text/css" media="all">
div.movable-element .movable-header { cursor: move; }
</style>';
}
$ret .= '<script type="text/javascript" src="' . $js_url . '/jquery/jquery.pack.js"></script>' . "\n";
$ret .= '<script type="text/javascript" src="' . $js_url . '/jquery/jquery-ui.custom.min.js"></script>' . "\n";
$ret .= '<script type="text/javascript" src="' . $js_url . '/is.js"></script>' . "\n";
$ret .= '<script type="text/javascript" src="' . $js_url . '/application.js"></script>' . "\n";
$ret .= '<script type="text/javascript" src="' . $js_url . '/script.js"></script>' . "\n";
$ret .= '<script type="text/javascript" src="' . $js_url . '/jquery/thickbox/thickbox.js"></script>' . "\n";
$ret .= '<script type="text/javascript" src="' . $js_url . '/template_manager.js"></script>' . "\n";
$ret .= '<script language="javascript">' . "\n";
$ret .= "TB.pathToImage = 'js/jquery/thickbox/loadingAnimation.gif';" . "\n";
$template = $this->Application->GetVar('t');
$theme_id = $this->Application->GetVar('m_theme');
$url_params = Array ('block' => '#BLOCK#', 'theme-file_event' => '#EVENT#', 'theme_id' => $theme_id, 'source' => $template, 'pass' => 'all,theme-file', 'front' => 1, 'no_amp' => 1);
$edit_template_url = $this->Application->HREF('themes/template_edit', ADMIN_DIRECTORY, $url_params, 'index.php');
$this_url = $this->Application->HREF('', '', Array ('editing_mode' => '#EDITING_MODE#', 'no_amp' => 1));
$ret .= "var aTemplateManager = new TemplateManager('" . $edit_template_url . "', '" . $this_url . "', " . (int)EDITING_MODE . ");\n";
$ret .= "var main_title = '" . addslashes( $this->Application->ConfigValue('Site_Name') ) . "';" . "\n";
$ret .= "var base_url = '" . $this->Application->BaseURL() . "';" . "\n";
$ret .= 'TB.closeHtml = \'<img src="' . $js_url . '/../img/close_window15.gif" width="15" height="15" style="border-width: 0px;" alt="close"/><br/>\';' . "\n";
$url_params = Array('m_theme' => '', 'pass' => 'm', 'm_opener' => 'r', 'no_amp' => 1);
$browse_url = $this->Application->HREF('catalog/catalog', ADMIN_DIRECTORY, $url_params, 'index.php');
$browse_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $browse_url);
$ret .= '
var topmost = window.top;
topmost.document.title = document.title + \' - '.$this->Application->Phrase('la_AdministrativeConsole').'\';
t = \''.$this->Application->GetVar('t').'\';
if (window.parent.frames["menu"] != undefined) {
if ( $.isFunction(window.parent.frames["menu"].SyncActive) ) {
window.parent.frames["menu"].SyncActive("' . $browse_url . '");
}
}
';
$ret .= '</script>' . "\n";
// add form, so admin scripts could work
$ret .= '<form id="kernel_form" name="kernel_form" enctype="multipart/form-data" method="post" action="' . $browse_url . '">
<input type="hidden" name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="' . MAX_UPLOAD_SIZE . '" />
<input type="hidden" name="sid" id="sid" value="' . $this->Application->GetSID() . '" />
</form>';
return $ret;
}
/**
* Prints "Edit Page" button on cms page
*
* @param Array $params
* @return string
*/
function EditPage($params)
{
if (!EDITING_MODE) {
return '';
}
$display_mode = array_key_exists('mode', $params) ? $params['mode'] : false;
$edit_code = '';
$page =& $this->_getPage($params);
if (!$page->isLoaded()) {
// when "EditingScripts" tag is not used, make sure, that scripts are also included
return $this->EditingScripts($params);
}
// show "EditPage" button only for pages, that exists in structure
if ($display_mode != 'end') {
$url_params = Array(
'pass' => 'm,c',
'm_opener' => 'd',
'c_id' => $page->GetID(),
'c_mode' => 't',
'c_event' => 'OnEdit',
'front' => 1,
'__URLENCODE__' => 1,
'__NO_REWRITE__'=> 1,
'escape' => 1,
'index_file' => 'index.php',
);
$edit_url = $this->Application->HREF('categories/categories_edit', '/admin', $url_params);
$edit_btn = '
<div class="cms-section-properties-btn"' . ($display_mode === false ? ' style="margin: 0px;"' : '') . ' onmouseover="window.status=\''.$edit_url.'\'; return true" onclick="$form_name=\'kf_'.$page->GetID().'\'; open_popup(\'c\', \'OnEdit\', \'categories/categories_edit\');">
<div class="cms-btn-image">
<img src="' . $this->Application->BaseURL() . 'core/admin_templates/img/top_frame/icons/content_mode.gif" width="15" height="16" alt=""/>
</div>
<div class="cms-btn-text">Section Properties</div>
</div>' . "\n";
if ($display_mode == 'start') {
// button with border around the page
$edit_code .= '<div class="cms-section-properties-btn-container">' . $edit_btn . '<div class="cms-btn-content">';
}
else {
// button without border around the page
$edit_code .= $edit_btn;
}
}
if ($display_mode == 'end') {
// draw border around the page
$edit_code .= '</div></div>';
}
if ($display_mode != 'end') {
$edit_code .= '<form method="POST" style="display: inline; margin: 0px" name="kf_'.$page->GetID().'" id="kf_'.$page->GetID().'" action="'.$edit_url.'"></form>';
// when "EditingScripts" tag is not used, make sure, that scripts are also included
$edit_code .= $this->EditingScripts($params);
}
return $edit_code;
}
/**
* Builds cached menu version
*
* @return Array
*/
function _prepareMenu()
{
static $root_cat = null;
static $root_path = null;
if (!$root_cat) {
$root_cat = $this->Application->ModuleInfo['Core']['RootCat'];
$root_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId = '.$root_cat);
}
if (!$this->Menu) {
$menu = $this->Conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "cms_menu"');
if ($menu && $menu['Cached'] > 0) {
$menu = unserialize($menu['Data']);
$this->ParentPaths = $menu['ParentPaths'];
}
else {
$menu = $this->_altBuildMenuStructure(array('CategoryId' => $root_cat, 'ParentPath' => $root_path));
$menu['ParentPaths'] = $this->ParentPaths;
$this->Conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("cms_menu", '.$this->Conn->qstr(serialize($menu)).', '.adodb_mktime().')');
}
unset($menu['ParentPaths']);
$this->Menu = $menu;
}
return Array ($this->Menu, $root_path);
}
/**
* Returns category id based tag parameters
*
* @param Array $params
* @return int
*/
function _getCategoryId($params)
{
$cat = isset($params['category_id']) && $params['category_id'] != '' ? $params['category_id'] : $this->Application->GetVar('m_cat_id');
if ("$cat" == 'parent') {
$this_category =& $this->Application->recallObject('c');
/* @var $this_category kDBItem */
$cat = $this_category->GetDBField('ParentId');
}
else if ($cat == 0) {
$cat = $this->Application->ModuleInfo['Core']['RootCat'];
}
return $cat;
}
/**
* Prepares cms menu item block parameters
*
* @param Array $page
* @param int $real_cat_id
* @param string $root_path
* @return Array
*/
function _prepareMenuItem($page, $real_cat_id, $root_path)
{
static $language_id = null;
static $primary_language_id = null;
if (!isset($language_id)) {
$language_id = $this->Application->GetVar('m_lang');
$primary_language_id = $this->Application->GetDefaultLanguageId();
}
$title = $page['l'.$language_id.'_ItemName'] ? $page['l'.$language_id.'_ItemName'] : $page['l'.$primary_language_id.'_ItemName'];
$active = false;
$category_active = false;
if ($page['ItemType'] == 'cat') {
if ( isset($this->ParentPaths[$real_cat_id])) {
$active = strpos($this->ParentPaths[$real_cat_id], $page['ParentPath']) !== false;
}
$category_active = $page['CategoryId'] == $real_cat_id;
}
if ($page['ItemType'] == 'cat_index') {
$check_path = str_replace($root_path, '', $page['ParentPath']);
$active = strpos($parent_path, $check_path) !== false;
}
if ($page['ItemType'] == 'page') {
$active = $page['ItemPath'] == preg_replace('/^Content\//i', '', $this->Application->GetVar('t'));
}
$block_params = Array (
'title'=> $title,
'template'=> preg_replace('/^Content\//i', '', $page['ItemPath']),
'active'=>$active,
'category_active' => $category_active, // new
'parent_path'=>$page['ParentPath'],
'parent_id'=>$page['ParentId'],
'cat_id'=>$page['CategoryId'],
'is_index'=>$page['IsIndex'],
'item_type'=>$page['ItemType'],
'page_id'=>$page['ItemId'],
'has_sub_menu' => isset($page['sub_items']) && count($page['sub_items']) > 0,
'external_url' => $page['UseExternalUrl'] ? $page['ExternalUrl'] : false,
'menu_icon' => $page['UseMenuIconUrl'] ? $page['MenuIconUrl'] : false,
);
return $block_params;
}
/**
* Builds site menu
*
* @param Array $params
* @return string
*/
function CachedMenu($params)
{
list ($menu, $root_path) = $this->_prepareMenu();
$cat = $this->_getCategoryId($params);
$parent_path = isset($this->ParentPaths[$cat]) ? $this->ParentPaths[$cat] : '';
$parent_path = str_replace($root_path, '', $parent_path); //menu starts from module path
$levels = explode('|',trim($parent_path,'|'));
if ($levels[0] === '') $levels = array();
if (isset($params['level']) && $params['level'] > count($levels)) return ;
$level = max(isset($params['level']) ? $params['level']-1 : count($levels)-1, 0);
$parent = isset($levels[$level]) ? $levels[$level] : 0;
$cur_menu =& $menu;
$menu_path = array_slice($levels, 0, $level+1);
foreach ($menu_path as $elem) {
$cur_menu =& $cur_menu['c'.$elem]['sub_items'];
}
$ret = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
$this->Application->SetVar('cur_parent_path', $parent_path);
$real_cat_id = $this->Application->GetVar('m_cat_id');
if (is_array($cur_menu) && $cur_menu) {
$cur_item = 1;
$cur_menu = $this->_removeNonMenuItems($cur_menu);
$block_params['total_items'] = count($cur_menu);
foreach ($cur_menu as $page) {
$block_params = array_merge_recursive2(
$block_params,
$this->_prepareMenuItem($page, $real_cat_id, $root_path)
);
$block_params['is_last'] = $cur_item == $block_params['total_items'];
$block_params['is_first'] = $cur_item == 1;
// bug #1: this breaks active section highlighting when 2 menu levels are printed on same page (both visible)
// bug #2: people doesn't pass cat_id parameter to m_Link tags in their blocks, so this line helps them; when removed their links will lead to nowhere
$this->Application->SetVar('m_cat_id', $page['CategoryId']);
$ret .= $this->Application->ParseBlock($block_params, 1);
$cur_item++;
}
$this->Application->SetVar('m_cat_id', $real_cat_id);
}
return $ret;
}
/**
* Returns only items, that are visible in menu
*
* @param Array $menu
* @return Array
*/
function _removeNonMenuItems($menu)
{
foreach ($menu as $menu_index => $menu_item) {
// $menu_index is in "cN" format, where N is category id
if (!$menu_item['IsMenu']) {
unset($menu[$menu_index]);
}
}
return $menu;
}
/**
* Trick to allow some kind of output formatting when using CachedMenu tag
*
* @param Array $params
* @return bool
*/
function SplitColumn($params)
{
return $this->Application->GetVar($params['i']) > ceil($params['total'] / $params['columns']);
}
/**
* Returns direct children count of given category
*
* @param Array $params
* @return int
*/
function HasSubCats($params)
{
$sql = 'SELECT COUNT(*)
FROM ' . TABLE_PREFIX . 'Category
WHERE ParentId = ' . $params['cat_id'];
return $this->Conn->GetOne($sql);
}
/**
* Prints sub-pages of given/current page.
*
* @param Array $params
* @return string
* @todo This could be reached by using "parent_cat_id" parameter. Only difference here is new block parameter "path". Need to rewrite.
*/
function PrintSubPages($params)
{
$list =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params);
/* @var $list kDBList */
$category_id = array_key_exists('category_id', $params) ? $params['category_id'] : $this->Application->GetVar('m_cat_id');
$list->addFilter('current_pages', TABLE_PREFIX . 'CategoryItems.CategoryId = ' . $category_id);
$list->Query();
$list->GoFirst();
$o = '';
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
while (!$list->EOL()) {
$block_params['path'] = $list->GetDBField('Path');
$o .= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
}
return $o;
}
/**
* Builds link for browsing current page on Front-End
*
* @param Array $params
* @return string
*/
function PageBrowseLink($params)
{
$object =& $this->getObject($params);
$template = $object->GetDBField('NamedParentPath');
$url_params = Array ('admin' => 1, 'pass' => 'm', 'm_cat_id' => $object->GetID(), 'index_file' => 'index.php');
return $this->Application->HREF($template, '_FRONT_END_', $url_params);
}
/**
* Builds link to cms page (used?)
*
* @param Array $params
* @return string
*/
function ContentPageLink($params)
{
$object =& $this->getObject($params);
$params['t'] = $object->GetDBField('NamedParentPath');
$params['m_cat_id'] = 0;
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* Builds cache for children of given category (no matter, what menu status is)
*
* @param Array $parent
* @return Array
*/
function _altBuildMenuStructure($parent)
{
static $languages_count = null;
if (!isset($languages_count)) {
$sql = 'SELECT COUNT(*)
FROM ' . TABLE_PREFIX . 'Language';
$languages_count = ceil($this->Conn->GetOne($sql) / 5) * 5;
}
$items = Array ();
$lang_part = '';
for ($i = 1; $i <= $languages_count; $i++) {
// $lang_part .= 'c.l' . $i . '_Name AS l' . $i . '_ItemName,' . "\n";
$lang_part .= 'c.l' . $i . '_MenuTitle AS l' . $i . '_ItemName,' . "\n";
}
// Sub-categories from current category
$query = 'SELECT
c.CategoryId AS CategoryId,
CONCAT(\'c\', c.CategoryId) AS ItemId,
c.Priority AS ItemPriority,
' . $lang_part . '
LOWER( IF(IsIndex = 2, (
SELECT cc.NamedParentPath FROM ' . TABLE_PREFIX . 'Category AS cc
WHERE
cc.ParentId = c.CategoryId
AND
cc.Status IN (1,4)
AND
cc.IsIndex = 1
),
c.NamedParentPath) ) AS ItemPath,
0 AS IsIndex,
c.ParentPath AS ParentPath,
c.ParentId As ParentId,
\'cat\' AS ItemType,
c.IsMenu, c.UseExternalUrl, c.ExternalUrl, c.UseMenuIconUrl, c.MenuIconUrl
FROM ' . TABLE_PREFIX . 'Category AS c
WHERE
c.Status IN (1,4) AND
#c.IsMenu = 1 AND
c.ParentId = ' . $parent['CategoryId'];
$items = array_merge($items, $this->Conn->Query($query, 'ItemId'));
uasort($items, Array (&$this, '_menuSort'));
$the_items = array();
foreach ($items as $an_item) {
$the_items[ $an_item['ItemId'] ] = $an_item;
$this->ParentPaths[ $an_item['CategoryId'] ] = $an_item['ParentPath'];
}
$items = $the_items;
foreach ($items as $key => $menu_item) {
if ($menu_item['CategoryId'] == $parent['CategoryId']) {
continue;
}
$sub_items = $this->_altBuildMenuStructure($menu_item);
if ($sub_items) {
$items[$key]['sub_items'] = $sub_items;
}
}
return $items;
}
/**
* Method for sorting pages by priority in decending order
*
* @param Array $a
* @param Array $b
* @return int
*/
function _menuSort($a, $b)
{
if ($a['ItemPriority'] == $b['ItemPriority']) {
return 0;
}
return ($a['ItemPriority'] < $b['ItemPriority']) ? 1 : -1; //descending
}
/**
* Prepares cms page description for search result page
*
* @param Array $params
* @return string
*/
function SearchDescription($params)
{
$object =& $this->getObject($params);
$desc = $object->GetField('MetaDescription');
if (!$desc) {
$sql = 'SELECT *
FROM ' . TABLE_PREFIX . 'PageContent
WHERE PageId = ' . $object->GetID() . ' AND ContentNum = 1';
$content = $this->Conn->GetRow($sql);
if ($content['l'.$this->Application->GetVar('m_lang').'_Content']) {
$desc = $content['l'.$this->Application->GetVar('m_lang').'_Content'];
}
else {
$desc = $content['l'.$this->Application->GetDefaultLanguageId().'_Content'];
}
}
return mb_substr($desc, 0, 300).(mb_strlen($desc) > 300 ? '...' : '');
}
/**
* Simplified version of "c:CategoryLink" for "c:PrintList"
*
* @param Array $params
* @return string
* @todo Used? Needs refactoring.
*/
function EnterCatLink($params)
{
$object =& $this->getObject($params);
$url_params = Array ('pass' => 'm', 'm_cat_id' => $object->GetID());
return $this->Application->HREF($params['template'], '', $url_params);
}
/**
* Simplified version of "c:CategoryPath", that do not use blocks for rendering
*
* @param Array $params
* @return string
* @todo Used? Maybe needs to be removed.
*/
function PagePath($params)
{
$object =& $this->getObject($params);
$path = $object->GetField('CachedNavbar');
if ($path) {
$items = explode('&|&', $path);
array_shift($items);
return implode(' -&gt; ', $items);
}
return '';
}
/**
* Returns configuration variable value
*
* @param Array $params
* @return string
* @todo Needs to be replaced with "m:GetConfig" tag; Not used now (were used on structure_edit.tpl).
*/
function AllowManualFilenames($params)
{
return $this->Application->ConfigValue('ProjCMSAllowManualFilenames');
}
/**
* Draws path to current page (each page can be link to it)
*
* @param Array $params
* @return string
*/
function CurrentPath($params)
{
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $block_params['render_as'];
$object =& $this->Application->recallObject($this->Prefix);
/* @var $object kDBItem */
$category_ids = explode('|', substr($object->GetDBField('ParentPath'), 1, -1));
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
$language = $this->Application->GetVar('m_lang');
$sql = 'SELECT l'.$language.'_Name AS Name, NamedParentPath
FROM '.$table_name.'
WHERE '.$id_field.' IN ('.implode(',', $category_ids).')';
$categories_data = $this->Conn->Query($sql);
$ret = '';
foreach ($categories_data as $index => $category_data) {
if ($category_data['Name'] == 'Content') {
continue;
}
$block_params['title'] = $category_data['Name'];
$block_params['template'] = preg_replace('/^Content\//i', '', $category_data['NamedParentPath']);
$block_params['is_first'] = $index == 1; // because Content is 1st element
$block_params['is_last'] = $index == count($categories_data) - 1;
$ret .= $this->Application->ParseBlock($block_params);
}
return $ret;
}
/**
* Synonim to PrintList2 for "onlinestore" theme
*
* @param Array $params
* @return string
*/
function ListPages($params)
{
return $this->PrintList2($params);
}
/**
* Returns information about parser element locations in template
*
* @param Array $params
* @return mixed
*/
function BlockInfo($params)
{
if (!EDITING_MODE) {
return '';
}
$template_helper =& $this->Application->recallObject('TemplateHelper');
/* @var $template_helper TemplateHelper */
return $template_helper->blockInfo( $params['name'] );
}
/**
* Hide all editing tabs except permission tab, when editing "Home" (ID = 0) category
*
* @param Array $params
*/
function ModifyUnitConfig($params)
{
$root_category = $this->Application->RecallVar('IsRootCategory_' . $this->Application->GetVar('m_wid'));
if (!$root_category) {
return ;
}
$edit_tab_presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
$edit_tab_presets['Default'] = Array (
'permissions' => $edit_tab_presets['Default']['permissions'],
);
$this->Application->setUnitOption($this->Prefix, 'EditTabPresets', $edit_tab_presets);
}
/**
* Prints catalog export templates
*
* @param Array $params
* @return string
*/
function PrintCatalogExportTemplates($params)
{
$prefixes = explode(',', $params['prefixes']);
$ret = Array ();
foreach ($prefixes as $prefix) {
if ($this->Application->prefixRegistred($prefix)) {
$ret[$prefix] = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/export';
}
}
$json_helper =& $this->Application->recallObject('JSONHelper');
/* @var $json_helper JSONHelper */
return $json_helper->encode($ret);
}
}
\ No newline at end of file
Index: branches/RC/core/units/categories/categories_event_handler.php
===================================================================
--- branches/RC/core/units/categories/categories_event_handler.php (revision 11759)
+++ branches/RC/core/units/categories/categories_event_handler.php (revision 11760)
@@ -1,1818 +1,1823 @@
<?php
class CategoriesEventHandler extends kDBEventHandler {
/**
* Allows to override standart permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array (
'OnRebuildCache' => Array ('self' => 'add|edit'),
'OnCopy' => Array ('self' => 'add|edit'),
'OnCut' => Array ('self' => 'edit'),
'OnPasteClipboard' => Array ('self' => 'add|edit'),
'OnPaste' => Array ('self' => 'add|edit', 'subitem' => 'edit'),
'OnRecalculatePriorities' => Array ('self' => 'add|edit'), // category ordering
'OnItemBuild' => Array ('self' => true), // always allow to view individual categories (regardless of CATEGORY.VIEW right)
'OnUpdatePreviewBlock' => Array ('self' => true), // for FCKEditor integration
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* Categories are sorted using special sorting event
*
*/
function mapEvents()
{
parent::mapEvents();
$events_map = Array (
'OnMassMoveUp' => 'OnChangePriority',
'OnMassMoveDown' => 'OnChangePriority',
);
$this->eventMethods = array_merge($this->eventMethods, $events_map);
}
/**
* Checks permissions of user
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
if (!$this->Application->IsAdmin()) {
if ($event->Name == 'OnSetSortingDirect') {
// allow sorting on front event without view permission
return true;
}
if ($event->Name == 'OnItemBuild') {
$category_id = $this->getPassedID($event);
if ($category_id == 0) {
return true;
}
}
}
$check_events = Array (
'OnEdit', 'OnSave', 'OnMassDelete', 'OnMassApprove',
'OnMassDecline', 'OnMassMoveUp', 'OnMassMoveDown'
);
if (in_array($event->Name, $check_events)) {
$items = $this->_getPermissionCheckInfo($event);
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
if (($event->Name == 'OnSave') && array_key_exists(0, $items)) {
// adding new item (ID = 0)
$perm_value = $perm_helper->AddCheckPermission($items[0]['ParentId'], $event->Prefix) > 0;
}
else {
// leave only items, that can be edited
$ids = Array ();
$check_method = ($event->Name == 'OnMassDelete') ? 'DeleteCheckPermission' : 'ModifyCheckPermission';
foreach ($items as $item_id => $item_data) {
if ($perm_helper->$check_method($item_data['CreatedById'], $item_data['ParentId'], $event->Prefix) > 0) {
$ids[] = $item_id;
}
}
if (!$ids) {
// no items left for editing -> no permission
return $perm_helper->finalizePermissionCheck($event, false);
}
$perm_value = true;
$event->setEventParam('ids', $ids); // will be used later by "kDBEventHandler::StoreSelectedIDs" method
}
return $perm_helper->finalizePermissionCheck($event, $perm_value);
}
if ($event->Name == 'OnPasteClipboard') {
// forces permission check to work by current category for "Paste In Category" operation
$category_id = $this->Application->GetVar('m_cat_id');
$this->Application->SetVar('c_id', $category_id);
}
return parent::CheckPermission($event);
}
/**
* Returns category item IDs, that require permission checking
*
* @param kEvent $event
* @return string
*/
function _getPermissionCheckIDs(&$event)
{
if ($event->Name == 'OnSave') {
$selected_ids = implode(',', $this->getSelectedIDs($event, true));
if (!$selected_ids) {
$selected_ids = 0; // when saving newly created item (OnPreCreate -> OnPreSave -> OnSave)
}
}
else {
// OnEdit, OnMassDelete events, when items are checked in grid
$selected_ids = implode(',', $this->StoreSelectedIDs($event));
}
return $selected_ids;
}
/**
* Returns information used in permission checking
*
* @param kEvent $event
* @return Array
*/
function _getPermissionCheckInfo(&$event)
{
// when saving data from temp table to live table check by data from temp table
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
if ($event->Name == 'OnSave') {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $event->Prefix);
}
$sql = 'SELECT ' . $id_field . ', CreatedById, ParentId
FROM ' . $table_name . '
WHERE ' . $id_field . ' IN (' . $this->_getPermissionCheckIDs($event) . ')';
$items = $this->Conn->Query($sql, $id_field);
if (!$items) {
// when creating new category, then no IDs are stored in session
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
list ($id, $fields_hash) = each($items_info);
if (array_key_exists('ParentId', $fields_hash)) {
$item_category = $fields_hash['ParentId'];
}
else {
$item_category = $this->Application->RecallVar('m_cat_id'); // saved in c:OnPreCreate event permission checking
}
$items[$id] = Array (
'CreatedById' => $this->Application->RecallVar('user_id'),
'ParentId' => $item_category,
);
}
return $items;
}
/**
* Set's mark, that root category is edited
*
* @param kEvent $event
*/
function OnEdit(&$event)
{
$category_id = $this->Application->GetVar($event->getPrefixSpecial().'_id');
$this->Application->StoreVar('IsRootCategory_'.$this->Application->GetVar('m_wid'), $category_id === '0');
parent::OnEdit($event);
}
/**
* Adds selected link to listing
*
* @param kEvent $event
*/
function OnProcessSelected(&$event)
{
$object =& $event->getObject();
/* @var $object kDBItem */
$selected_ids = $this->Application->GetVar('selected_ids');
$this->RemoveRequiredFields($object);
$object->SetDBField($this->Application->RecallVar('dst_field'), $selected_ids['c']);
$object->Update();
$this->finalizePopup($event);
}
/**
* Apply system filter to categories list
*
* @param kEvent $event
*/
function SetCustomQuery(&$event)
{
parent::SetCustomQuery($event);
$object =& $event->getObject();
/* @var $object kDBList */
// don't show "Content" category in advanced view
$object->addFilter('system_categories', '%1$s.Status <> 4');
// show system templates from current theme only + all virtual templates
$object->addFilter('theme_filter', '%1$s.ThemeId = ' . $this->_getCurrentThemeId() . ' OR %1$s.ThemeId = 0');
if ($event->Special == 'showall') {
// if using recycle bin don't show categories from there
$recycle_bin = $this->Application->ConfigValue('RecycleBinFolder');
if ($recycle_bin) {
$sql = 'SELECT TreeLeft, TreeRight
FROM '.TABLE_PREFIX.'Category
WHERE CategoryId = '.$recycle_bin;
$tree_indexes = $this->Conn->GetRow($sql);
$object->addFilter('recyclebin_filter', '%1$s.TreeLeft < '.$tree_indexes['TreeLeft'].' OR %1$s.TreeLeft > '.$tree_indexes['TreeRight']);
}
}
if ($event->getEventParam('parent_cat_id') !== false) {
$parent_cat_id = $event->getEventParam('parent_cat_id');
if ("$parent_cat_id" == 'Root') {
$module_name = $event->getEventParam('module') ? $event->getEventParam('module') : 'In-Commerce';
$parent_cat_id = $this->Application->findModule('Name', $module_name, 'RootCat');
}
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
if ("$parent_cat_id" != 'any') {
if ($event->getEventParam('recursive')) {
if ($parent_cat_id > 0) {
// not "Home" category
$tree_indexes = $this->Application->getTreeIndex($parent_cat_id);
$object->addFilter('parent_filter', TABLE_PREFIX.'Category.TreeLeft BETWEEN '.$tree_indexes['TreeLeft'].' AND '.$tree_indexes['TreeRight']);
}
}
else {
$object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id);
}
}
$object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission
if ($this->Application->RecallVar('user_id') != -1) {
// apply permission filters to all users except "root"
$groups = explode(',',$this->Application->RecallVar('UserGroups'));
foreach ($groups as $group) {
$view_filters[] = 'FIND_IN_SET('.$group.', acl)';
}
$view_filter = implode(' OR ', $view_filters);
$object->addFilter('perm_filter2', $view_filter);
}
if (!$this->Application->IsAdmin()) {
// apply status filter only on front
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
// process "types" and "except" parameters
$type_clauses = Array();
$types = $event->getEventParam('types');
$types = $types ? explode(',', $types) : Array ();
$except_types = $event->getEventParam('except');
$except_types = $except_types ? explode(',', $except_types) : Array ();
if (in_array('related', $types) || in_array('related', $except_types)) {
$related_to = $event->getEventParam('related_to');
if (!$related_to) {
$related_prefix = $event->Prefix;
}
else {
$sql = 'SELECT Prefix
FROM '.TABLE_PREFIX.'ItemTypes
WHERE ItemName = '.$this->Conn->qstr($related_to);
$related_prefix = $this->Conn->GetOne($sql);
}
$rel_table = $this->Application->getUnitOption('rel', 'TableName');
$item_type = (int)$this->Application->getUnitOption($event->Prefix, 'ItemType');
if ($item_type == 0) {
trigger_error('<strong>ItemType</strong> not defined for prefix <strong>' . $event->Prefix . '</strong>', E_USER_WARNING);
}
// process case, then this list is called inside another list
$prefix_special = $event->getEventParam('PrefixSpecial');
if (!$prefix_special) {
$prefix_special = $this->Application->Parser->GetParam('PrefixSpecial');
}
$id = false;
if ($prefix_special !== false) {
$processed_prefix = $this->Application->processPrefix($prefix_special);
if ($processed_prefix['prefix'] == $related_prefix) {
// printing related categories within list of items (not on details page)
$list =& $this->Application->recallObject($prefix_special);
/* @var $list kDBList */
$id = $list->GetID();
}
}
if ($id === false) {
// printing related categories for single item (possibly on details page)
if ($related_prefix == 'c') {
$id = $this->Application->GetVar('m_cat_id');
}
else {
$id = $this->Application->GetVar($related_prefix . '_id');
}
}
$p_item =& $this->Application->recallObject($related_prefix . '.current', null, Array('skip_autoload' => true));
$p_item->Load( (int)$id );
$p_resource_id = $p_item->GetDBField('ResourceId');
$sql = 'SELECT SourceId, TargetId FROM '.$rel_table.'
WHERE
(Enabled = 1)
AND (
(Type = 0 AND SourceId = '.$p_resource_id.' AND TargetType = '.$item_type.')
OR
(Type = 1
AND (
(SourceId = '.$p_resource_id.' AND TargetType = '.$item_type.')
OR
(TargetId = '.$p_resource_id.' AND SourceType = '.$item_type.')
)
)
)';
$related_ids_array = $this->Conn->Query($sql);
$related_ids = Array();
foreach ($related_ids_array as $key => $record) {
$related_ids[] = $record[ $record['SourceId'] == $p_resource_id ? 'TargetId' : 'SourceId' ];
}
if (count($related_ids) > 0) {
$type_clauses['related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_ids).')';
$type_clauses['related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_ids).')';
}
else {
$type_clauses['related']['include'] = '0';
$type_clauses['related']['except'] = '1';
}
$type_clauses['related']['having_filter'] = false;
}
if (in_array('category_related', $type_clauses)) {
$object->removeFilter('parent_filter');
$resource_id = $this->Conn->GetOne('
SELECT ResourceId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
WHERE CategoryId = '.$parent_cat_id
);
$sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
WHERE SourceId = '.$resource_id.' AND SourceType = 1';
$related_cats = $this->Conn->GetCol($sql);
$related_cats = is_array($related_cats) ? $related_cats : Array();
$sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
WHERE TargetId = '.$resource_id.' AND TargetType = 1 AND Type = 1';
$related_cats2 = $this->Conn->GetCol($sql);
$related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
$related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
if ($related_cats) {
$type_clauses['category_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
$type_clauses['category_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
}
else
{
$type_clauses['category_related']['include'] = '0';
$type_clauses['category_related']['except'] = '1';
}
$type_clauses['category_related']['having_filter'] = false;
}
if (in_array('product_related', $types)) {
$object->removeFilter('parent_filter');
$product_id = $event->getEventParam('product_id') ? $event->getEventParam('product_id') : $this->Application->GetVar('p_id');
$resource_id = $this->Conn->GetOne('
SELECT ResourceId FROM '.$this->Application->getUnitOption('p', 'TableName').'
WHERE ProductId = '.$product_id
);
$sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
WHERE SourceId = '.$resource_id.' AND TargetType = 1';
$related_cats = $this->Conn->GetCol($sql);
$related_cats = is_array($related_cats) ? $related_cats : Array();
$sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
WHERE TargetId = '.$resource_id.' AND SourceType = 1 AND Type = 1';
$related_cats2 = $this->Conn->GetCol($sql);
$related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
$related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
if ($related_cats) {
$type_clauses['product_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
$type_clauses['product_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
}
else {
$type_clauses['product_related']['include'] = '0';
$type_clauses['product_related']['except'] = '1';
}
$type_clauses['product_related']['having_filter'] = false;
}
$type_clauses['menu']['include'] = '%1$s.IsMenu = 1';
$type_clauses['menu']['except'] = '%1$s.IsMenu = 0';
$search_helper =& $this->Application->recallObject('SearchHelper');
/* @var $search_helper kSearchHelper */
$search_helper->SetComplexFilter($event, $type_clauses, implode(',', $types), implode(',', $except_types));
}
/**
* Returns current theme id
*
* @return int
*/
function _getCurrentThemeId()
{
$themes_helper =& $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
return (int)$themes_helper->getCurrentThemeId();
}
/**
* Enter description here...
*
* @param kEvent $event
* @return int
*/
function getPassedID(&$event)
{
static $page_by_template = Array ();
if ($event->Special == 'current') {
return $this->Application->GetVar('m_cat_id');
}
$event->setEventParam('raise_warnings', 0);
$page_id = parent::getPassedID($event);
if ($page_id === false) {
$template = $event->getEventParam('page');
if (!$template) {
$template = $this->Application->GetVar('t');
}
// bug: when template contains "-" symbols (or others, that stripDisallowed will remplace) it's not found
if (!array_key_exists($template, $page_by_template)) {
$sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
WHERE
(
(NamedParentPath = ' . $this->Conn->qstr($template) . ') OR
(NamedParentPath = ' . $this->Conn->qstr('Content/' . $template) . ') OR
(IsSystem = 1 AND CachedTemplate = ' . $this->Conn->qstr($template) . ')
) AND (ThemeId = ' . $this->_getCurrentThemeId() . ' OR ThemeId = 0)';
$page_id = $this->Conn->GetOne($sql);
}
else {
$page_id = $page_by_template[$template];
}
if ($page_id === false && EDITING_MODE) {
// create missing pages, when in editing mode
$object =& $this->Application->recallObject($this->Prefix . '.-new', null, Array('skip_autoload' => true));
/* @var $object kDBItem */
$created = $this->_prepareAutoPage($object, $template, null, SMS_MODE_AUTO, false); // create virtual (not system!) page
if ($created) {
if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild') || !$this->Application->IsAdmin()) {
$updater =& $this->Application->recallObject('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
}
$event->CallSubEvent('OnResetMenuCache');
$this->Application->RemoveVar('PermCache_UpdateRequired');
$page_id = $object->GetID();
$this->Application->SetVar('m_cat_id', $page_id);
}
}
if ($page_id) {
$page_by_template[$template] = $page_id;
}
}
if (!$page_id && !$this->Application->IsAdmin()) {
$page_id = $this->Application->GetVar('m_cat_id');
}
return $page_id;
}
function ParentGetPassedId(&$event)
{
return parent::GetPassedId($event);
}
/**
* Adds calculates fields for item statuses
*
* @param kCatDBItem $object
* @param kEvent $event
*/
function prepareObject(&$object, &$event)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
$object->addCalculatedField(
'IsNew',
' IF(%1$s.NewItem = 2,
IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
$this->Application->ConfigValue('Category_DaysNew').
'*3600*24), 1, 0),
%1$s.NewItem
)');
}
/**
* Set correct parent path for newly created categories
*
* @param kEvent $event
*/
function OnAfterCopyToLive(&$event)
{
$parent_path = false;
$object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true));
$object->Load($event->getEventParam('id'));
if ($event->getEventParam('temp_id') == 0) {
if ($object->isLoaded()) {
// update path only for real categories (not including "Home" root category)
$fields_hash = Array('ParentPath' => $object->buildParentPath());
$this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID());
$parent_path = $fields_hash['ParentPath'];
}
}
else {
$parent_path = $object->GetDBField('ParentPath');
}
if ($parent_path) {
$cache_updater =& $this->Application->recallObject('kPermCacheUpdater', null, array('strict_path' => $parent_path));
$cache_updater->OneStepRun();
$cache_updater->StrictPath = false;
}
}
/**
* Set cache modification mark if needed
*
* @param kEvent $event
*/
function OnBeforeDeleteFromLive(&$event)
{
$id = $event->getEventParam('id');
// loding anyway, because this object is needed by "c-perm:OnBeforeDeleteFromLive" event
$temp_object =& $event->getObject( Array('skip_autoload' => true) );
$temp_object->Load($id);
if ($id == 0) {
if ($temp_object->isLoaded()) {
// new category -> update cache (not loaded when "Home" category)
$this->Application->StoreVar('PermCache_UpdateRequired', 1);
}
return ;
}
// existing category was edited, check if in-cache fields are modified
$live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true, 'skip_autoload' => true));
$live_object->Load($id);
$cached_fields = Array('Name', 'Filename', 'Template', 'ParentId', 'Priority');
foreach ($cached_fields as $cached_field) {
if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
// use session instead of REQUEST because of permission editing in category can contain
// multiple submits, that changes data before OnSave event occurs
$this->Application->StoreVar('PermCache_UpdateRequired', 1);
break;
}
}
}
/**
* Calls kDBEventHandler::OnSave original event
* Used in proj-cms:StructureEventHandler->OnSave
*
* @param kEvent $event
*/
function parentOnSave(&$event)
{
parent::OnSave($event);
}
/**
* Reset root-category flag when new category is created
*
* @param kEvent $event
*/
function OnPreCreate(&$event)
{
// 1. for permission editing of Home category
$this->Application->RemoveVar('IsRootCategory_' . $this->Application->GetVar('m_wid'));
parent::OnPreCreate($event);
$object =& $event->getObject();
// 2. preset template
// $object->SetDBField('Template', $this->_getDefaultDesign());
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
// 3. prepare priorities dropdown
$category_id = $this->Application->GetVar('m_cat_id');
$priority_helper->preparePriorities($event, true, 'ParentId = ' . $category_id);
}
/**
* Checks cache update mark and redirect to cache if needed
*
* @param kEvent $event
*/
function OnSave(&$event)
{
$object =& $event->getObject();
if ($object->IsRoot()) {
$event->setEventParam('master_ids', Array(0));
$this->RemoveRequiredFields($object);
}
parent::OnSave($event);
if ($event->status != erSUCCESS) {
return ;
}
// 1. update priorities
$tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid'));
$changes = $tmp ? unserialize($tmp) : Array ();
$changed_ids = array_keys($changes);
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$priority_helper->updatePriorities($event, $changes, Array (0 => $event->getEventParam('ids')));
if ($this->Application->RecallVar('PermCache_UpdateRequired')) {
$this->Application->RemoveVar('IsRootCategory_' . $this->Application->GetVar('m_wid'));
}
$this->Application->StoreVar('RefreshStructureTree', 1);
$event->CallSubEvent('OnResetMenuCache');
}
/**
* Creates a new item in temp table and
* stores item id in App vars and Session on succsess
*
* @param kEvent $event
*/
function OnPreSaveCreated(&$event)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
/* @var $object CategoriesItem */
if ($object->IsRoot()) {
// don't create root category while saving permissions
return ;
}
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$category_id = $this->Application->GetVar('m_cat_id');
$priority_helper->preparePriorities($event, true, 'ParentId = ' . $category_id);
parent::OnPreSaveCreated($event);
}
/**
* Deletes sym link to other category
*
* @param kEvent $event
*/
function OnAfterItemDelete(&$event)
{
parent::OnAfterItemDelete($event);
$object =& $event->getObject();
/* @var $object kDBItem */
$sql = 'UPDATE '.$object->TableName.'
SET SymLinkCategoryId = NULL
WHERE SymLinkCategoryId = '.$object->GetID();
$this->Conn->Query($sql);
}
/**
* Exclude root categories from deleting
*
* @param kEvent $event
*/
function customProcessing(&$event, $type)
{
if ($event->Name == 'OnMassDelete' && $type == 'before') {
$ids = $event->getEventParam('ids');
if (!$ids || $this->Application->ConfigValue('AllowDeleteRootCats')) {
return ;
}
// get module root categories and exclude them
foreach ($this->Application->ModuleInfo as $module_info) {
$root_categories[] = $module_info['RootCat'];
}
$root_categories = array_unique($root_categories);
if ($root_categories && array_intersect($ids, $root_categories)) {
$event->setEventParam('ids', array_diff($ids, $root_categories));
$this->Application->StoreVar('root_delete_error', 1);
}
}
$change_events = Array ('OnPreSave', 'OnPreSaveCreated', 'OnUpdate', 'OnSave');
if ($type == 'after' && in_array($event->Name, $change_events)) {
$object =& $event->getObject();
$tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid'));
$changes = $tmp ? unserialize($tmp) : array();
if (!isset($changes[$object->GetID()])) {
$changes[$object->GetId()]['old'] = $object->GetID() == 0 ? 'new' : $object->GetDBField('OldPriority');
}
if ($changes[$object->GetId()]['old'] == $object->GetDBField('Priority')) return ;
$changes[$object->GetId()]['new'] = $object->GetDBField('Priority');
$changes[$object->GetId()]['parent'] = $object->GetDBField('ParentId');
$this->Application->StoreVar('priority_changes'.$this->Application->GetVar('m_wid'), serialize($changes));
}
}
/**
* Checks, that given template exists (physically) in given theme
*
* @param string $template
* @param int $theme_id
* @return bool
*/
function _templateFound($template, $theme_id = null)
{
static $init_made = false;
if (!$init_made) {
$this->Application->InitParser(true);
$init_made = true;
}
if (!isset($theme_id)) {
$theme_id = $this->_getCurrentThemeId();
}
$theme_name = $this->_getThemeName($theme_id);
return $this->Application->TemplatesCache->TemplateExists('theme:' . $theme_name . '/' . $template);
}
/**
* Removes ".tpl" in template path
*
* @param string $template
* @return string
*/
function _stripTemplateExtension($template)
{
// return preg_replace('/\.[^.\\\\\\/]*$/', '', $template);
return preg_replace('/^[\\/]{0,1}(.*)\.tpl$/', "$1", $template);
}
/**
* Deletes all selected items.
* Automatically recurse into sub-items using temp handler, and deletes sub-items
* by calling its Delete method if sub-item has AutoDelete set to true in its config file
*
* @param kEvent $event
*/
function OnMassDelete(&$event)
{
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
return;
}
$ids = $this->StoreSelectedIDs($event);
$to_delete = array();
if ($recycle_bin = $this->Application->ConfigValue('RecycleBinFolder')) {
$rb =& $this->Application->recallObject('c.recycle', null, Array ('skip_autoload' => true));
$rb->Load($recycle_bin);
$cat =& $event->getObject(Array('skip_autoload' => true));
foreach ($ids as $id) {
$cat->Load($id);
if (preg_match('/^'.preg_quote($rb->GetDBField('ParentPath'),'/').'/', $cat->GetDBField('ParentPath'))) {
$to_delete[] = $id;
continue;
}
$cat->SetDBField('ParentId', $recycle_bin);
$cat->Update();
}
$ids = $to_delete;
$event->redirect = 'categories/cache_updater';
}
$event->setEventParam('ids', $ids);
$this->customProcessing($event, 'before');
$ids = $event->getEventParam('ids');
if ($ids) {
$recursive_helper =& $this->Application->recallObject('RecursiveHelper');
/* @var $recursive_helper kRecursiveHelper */
foreach ($ids as $id) {
$recursive_helper->DeleteCategory($id, $event->Prefix);
}
}
$this->clearSelectedIDs($event);
// update priorities
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
// after deleting categories, all priorities should be recalculated
$parent_id = $this->Application->GetVar('m_cat_id');
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $parent_id);
$this->Application->StoreVar('RefreshStructureTree', 1);
$event->CallSubEvent('OnResetMenuCache');
}
/**
* Add selected items to clipboard with mode = COPY (CLONE)
*
* @param kEvent $event
*/
function OnCopy(&$event)
{
$this->Application->RemoveVar('clipboard');
$clipboard_helper =& $this->Application->recallObject('ClipboardHelper');
$clipboard_helper->setClipboard($event, 'copy', $this->StoreSelectedIDs($event));
$this->clearSelectedIDs($event);
}
/**
* Add selected items to clipboard with mode = CUT
*
* @param kEvent $event
*/
function OnCut(&$event)
{
$this->Application->RemoveVar('clipboard');
$clipboard_helper =& $this->Application->recallObject('ClipboardHelper');
$clipboard_helper->setClipboard($event, 'cut', $this->StoreSelectedIDs($event));
$this->clearSelectedIDs($event);
}
/**
* Controls all item paste operations. Can occur only with filled clipbord.
*
* @param kEvent $event
*/
function OnPasteClipboard(&$event)
{
$clipboard = unserialize( $this->Application->RecallVar('clipboard') );
foreach ($clipboard as $prefix => $clipboard_data) {
$paste_event = new kEvent($prefix.':OnPaste', Array('clipboard_data' => $clipboard_data));
$this->Application->HandleEvent($paste_event);
$event->redirect = $paste_event->redirect;
$event->redirect_params = $paste_event->redirect_params;
$event->status = $paste_event->status;
}
}
/**
* Paste categories with subitems from clipboard
*
* @param kEvent $event
*/
function OnPaste(&$event)
{
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
return;
}
$clipboard_data = $event->getEventParam('clipboard_data');
if (!$clipboard_data['cut'] && !$clipboard_data['copy']) {
return false;
}
// 1. get ParentId of moved category(-es) before it gets updated!!!)
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
if ($clipboard_data['cut']) {
$sql = 'SELECT ParentId
FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
WHERE ' . $id_field . ' = ' . $clipboard_data['cut'][0];
$source_category_id = $this->Conn->GetOne($sql);
}
$recursive_helper =& $this->Application->recallObject('RecursiveHelper');
/* @var $recursive_helper kRecursiveHelper */
if ($clipboard_data['cut']) {
$recursive_helper->MoveCategories($clipboard_data['cut'], $this->Application->GetVar('m_cat_id'));
}
if ($clipboard_data['copy']) {
foreach ($clipboard_data['copy'] as $id) {
$recursive_helper->PasteCategory($id, $event->Prefix);
}
}
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
if ($clipboard_data['cut']) {
$priority_helper->recalculatePriorities($event, 'ParentId = '.$source_category_id);
}
// recalculate priorities of newly pasted categories in destination category
$parent_id = $this->Application->GetVar('m_cat_id');
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $parent_id);
if ($clipboard_data['cut'] || $clipboard_data['copy']) {
// rebuild with progress bar
if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) {
$updater =& $this->Application->recallObject('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
}
else {
$event->redirect = 'categories/cache_updater';
}
$event->CallSubEvent('OnResetMenuCache');
$this->Application->StoreVar('RefreshStructureTree', 1);
}
}
/**
* Occurs when pasting category
*
* @param kEvent $event
*/
/*function OnCatPaste(&$event)
{
$inp_clipboard = $this->Application->RecallVar('ClipBoard');
$inp_clipboard = explode('-', $inp_clipboard, 2);
if($inp_clipboard[0] == 'COPY')
{
$saved_cat_id = $this->Application->GetVar('m_cat_id');
$cat_ids = $event->getEventParam('cat_ids');
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
$table = $this->Application->getUnitOption($event->Prefix, 'TableName');
$ids_sql = 'SELECT '.$id_field.' FROM '.$table.' WHERE ResourceId IN (%s)';
$resource_ids_sql = 'SELECT ItemResourceId FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = %s AND PrimaryCat = 1';
$object =& $this->Application->recallObject($event->Prefix.'.item', $event->Prefix, Array('skip_autoload' => true));
foreach($cat_ids as $source_cat => $dest_cat)
{
$item_resource_ids = $this->Conn->GetCol( sprintf($resource_ids_sql, $source_cat) );
if(!$item_resource_ids) continue;
$this->Application->SetVar('m_cat_id', $dest_cat);
$item_ids = $this->Conn->GetCol( sprintf($ids_sql, implode(',', $item_resource_ids) ) );
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($item_ids) $temp->CloneItems($event->Prefix, $event->Special, $item_ids);
}
$this->Application->SetVar('m_cat_id', $saved_cat_id);
}
}*/
/**
* Cleares clipboard content
*
* @param kEvent $event
*/
function OnClearClipboard(&$event)
{
$this->Application->RemoveVar('clipboard');
}
/**
* Sets correct status for new categories created on front-end
*
* @param kEvent $event
*/
function OnBeforeItemCreate(&$event)
{
$this->_beforeItemChange($event);
if ($this->Application->IsAdmin() || $event->Prefix == 'st') {
// don't check category permissions when auto-creating structure pages
return ;
}
$perm_helper =& $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$new_status = false;
$category_id = $this->Application->GetVar('m_cat_id');
if ($perm_helper->CheckPermission('CATEGORY.ADD', 0, $category_id)) {
$new_status = STATUS_ACTIVE;
}
else if ($perm_helper->CheckPermission('CATEGORY.ADD.PENDING', 0, $category_id)) {
$new_status = STATUS_PENDING;
}
if ($new_status) {
$object =& $event->getObject();
/* @var $object kDBItem */
$object->SetDBField('Status', $new_status);
}
else {
$event->status = erPERM_FAIL;
return ;
}
}
/**
* Sets correct status for new categories created on front-end
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
parent::OnBeforeItemUpdate($event);
$this->_beforeItemChange($event);
}
/**
* Performs redirect to correct suggest confirmation template
*
* @param kEvent $event
*/
function OnCreate(&$event)
{
parent::OnCreate($event);
if ($this->Application->IsAdmin() || $event->status != erSUCCESS) {
return ;
}
$object =& $event->getObject();
$cache_updater =& $this->Application->recallObject('kPermCacheUpdater', null, array('strict_path' => $object->GetDBField('ParentPath')));
$cache_updater->OneStepRun();
$cache_updater->StrictPath = false;
$is_active = ($object->GetDBField('Status') == STATUS_ACTIVE);
$next_template = $is_active ? 'suggest_confirm_template' : 'suggest_pending_confirm_template';
$event->redirect = $this->Application->GetVar($next_template);
$event->SetRedirectParam('opener', 's');
// send email events
$perm_prefix = $this->Application->getUnitOption($event->Prefix, 'PermItemPrefix');
$event_suffix = $is_active ? 'ADD' : 'ADD.PENDING';
$this->Application->EmailEventAdmin($perm_prefix.'.'.$event_suffix);
$this->Application->EmailEventUser($perm_prefix.'.'.$event_suffix, $object->GetDBField('CreatedById'));
}
/**
* Returns current per-page setting for list
*
* @param kEvent $event
* @return int
*/
function getPerPage(&$event)
{
if (!$this->Application->IsAdmin()) {
$event->setEventParam('same_special', true);
}
return parent::getPerPage($event);
}
/**
* Set's correct page for list
* based on data provided with event
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetPagination(&$event)
{
parent::SetPagination($event);
if (!$this->Application->IsAdmin()) {
$page_var = $event->getEventParam('page_var');
if ($page_var !== false) {
$page = $this->Application->GetVar($page_var);
if (is_numeric($page)) {
$object =& $event->getObject();
$object->SetPage($page);
}
}
}
}
/**
* Apply same processing to each item beeing selected in grid
*
* @param kEvent $event
* @access private
*/
function iterateItems(&$event)
{
if ($event->Name != 'OnMassApprove' && $event->Name != 'OnMassDecline') {
return parent::iterateItems($event);
}
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
return;
}
$object =& $event->getObject( Array('skip_autoload' => true) );
$ids = $this->StoreSelectedIDs($event);
if ($ids) {
$status_field = array_shift( $this->Application->getUnitOption($event->Prefix,'StatusField') );
foreach ($ids as $id) {
$object->Load($id);
switch ($event->Name) {
case 'OnMassApprove':
$object->SetDBField($status_field, 1);
break;
case 'OnMassDecline':
$object->SetDBField($status_field, 0);
break;
}
if ($this->Application->GetVar('propagate_category_status')) {
$sql = 'UPDATE '.$object->TableName.'
SET '.$status_field.' = '.$object->GetDBField('Status').'
WHERE TreeLeft BETWEEN '.$object->GetDBField('TreeLeft').' AND '.$object->GetDBField('TreeRight');
$this->Conn->Query($sql);
}
if ($object->Update()) {
$event->status = erSUCCESS;
}
else {
$event->status = erFAIL;
$event->redirect = false;
break;
}
}
}
$this->clearSelectedIDs($event);
$this->Application->StoreVar('RefreshStructureTree', 1);
}
/**
* Checks, that currently loaded item is allowed for viewing (non permission-based)
*
* @param kEvent $event
* @return bool
*/
function checkItemStatus(&$event)
{
$status_fields = $this->Application->getUnitOption($event->Prefix,'StatusField');
if (!$status_fields) {
return true;
}
$status_field = array_shift($status_fields);
if ($status_field == 'Status' || $status_field == 'Enabled') {
$object =& $event->getObject();
if (!$object->isLoaded()) {
return true;
}
return $object->GetDBField($status_field) == STATUS_ACTIVE || $object->GetDBField($status_field) == 4;
}
return true;
}
// ============= for cms page processing =======================
/**
* Returns default design template
*
* @return string
*/
function _getDefaultDesign()
{
$default_design = $this->Application->ConfigValue('cms_DefaultDesign');
return '/' . trim($default_design ? $default_design : 'designs/default_design', '/');
}
/**
* Returns default design based on given virtual template (used from kApplication::Run)
*
* @return string
*/
function GetDesignTemplate($t = null)
{
if (!isset($t)) {
$t = $this->Application->GetVar('t');
}
$page =& $this->Application->recallObject($this->Prefix . '.-virtual', null, Array ('page' => $t));
if($page->isLoaded()) {
$real_t = $page->GetDBField('CachedTemplate');
$this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId') );
if ($page->GetDBField('FormId')) {
$this->Application->SetVar('form_id', $page->GetDBField('FormId'));
}
}
else {
$real_t = $this->_getDefaultDesign();
}
// $this->Application->SetVar('t', $t);
return $real_t;
}
/**
* Sets category id based on found template (used from kApplication::Run)
*
* @deprecated
*/
/*function SetCatByTemplate()
{
$t = $this->Application->GetVar('t');
$page =& $this->Application->recallObject($this->Prefix . '.-virtual');
if ($page->isLoaded()) {
$this->Application->SetVar('m_cat_id', $page->GetDBField('CategoryId') );
}
}*/
/**
* Prepares template paths
*
* @param kEvent $event
*/
function _beforeItemChange(&$event)
{
$object =& $event->getObject();
/* @var $object kDBItem */
$object->SetDBField('Template', $this->_stripTemplateExtension( $object->GetDBField('Template') ));
if ($object->GetDBField('IsSystem') == 1) {
if (!$this->_templateFound($object->GetDBField('Template'), $object->GetDBField('ThemeId'))) {
$object->SetError('Template', 'template_file_missing', 'la_error_TemplateFileMissing');
}
}
$this->_saveTitleField($object, 'Title');
$this->_saveTitleField($object, 'MenuTitle');
}
/**
* Sets page name to requested field in case when:
* 1. page was auto created (through theme file rebuld)
* 2. requested field is emtpy
*
* @param kDBItem $object
* @param string $field
* @author Alex
*/
function _saveTitleField(&$object, $field)
{
$value = $object->GetField($field);
if ($value == '' || preg_match('/^_Auto: (.*)/', $value)) {
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
/* @var $ml_formatter kMultiLanguage */
$object->SetField(
$ml_formatter->LangFieldName($field),
$object->GetField( $ml_formatter->LangFieldName('Name') )
);
}
}
/**
* Don't allow to delete system pages, when not in debug mode
*
* @param kEvent $event
*/
function OnBeforeItemDelete(&$event)
{
$object =& $event->getObject();
if ($object->GetDBField('IsSystem') && !$this->Application->isDebugMode()) {
$event->status = erFAIL;
}
}
/**
* Enter description here...
*
* @param StructureItem $object
* @param string $template
*/
function _prepareAutoPage(&$object, $template, $theme_id = null, $system_mode = SMS_MODE_AUTO, $template_info = Array ())
{
$template = $this->_stripTemplateExtension($template);
if ($system_mode == SMS_MODE_AUTO) {
$system = $this->_templateFound($template, $theme_id) ? 1 : 0;
}
else {
$system = $system_mode == SMS_MODE_FORCE ? 1 : 0;
}
if ($system && $template_info === false) {
// do not autocreate system pages, when browsing through site
return false;
}
if (!isset($theme_id)) {
$theme_id = $this->_getCurrentThemeId();
}
$root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
$page_category = $this->Application->GetVar('m_cat_id');
if (!$page_category) {
$page_category = $root_category;
$this->Application->SetVar('m_cat_id', $page_category);
}
if (!$system && strpos($template, '/') !== false) {
// virtual page, but have "/" in template path -> create it's path
$category_path = explode('/', $template);
$template = array_pop($category_path);
$page_category = $this->_getParentCategoryFromPath($category_path, $root_category, $theme_id);
}
$page_name = $system ? '_Auto: ' . $template : $template;
$page_description = '';
if ($system) {
$design_template = strtolower($template); // leading "/" not added !
if ($template_info) {
if (array_key_exists('name', $template_info) && $template_info['name']) {
$page_name = $template_info['name'];
}
if (array_key_exists('desc', $template_info) && $template_info['desc']) {
$page_description = $template_info['desc'];
}
if (array_key_exists('section', $template_info) && $template_info['section']) {
// this will override any global "m_cat_id"
$page_category = $this->_getParentCategoryFromPath(explode('||', $template_info['section']), $root_category, $theme_id);
}
}
}
else {
$design_template = $this->_getDefaultDesign(); // leading "/" added !
}
// put all templates to then end of list (in their category)
$sql = 'SELECT MIN(Priority)
FROM ' . $object->TableName . '
WHERE ParentId = ' . $page_category;
$min_priority = (int)$this->Conn->GetOne($sql);
$object->Clear();
$object->SetDBField('ParentId', $page_category);
$object->SetDBField('IsSystem', $system);
// system templates don't build their NamedParentPath based on their location because they are all added under
// "Content" when theme file structure is rebuilded and for ex. file "in-edit/designs/general" will have filename
// (after stripDisallowed) like "in_edit_designs_general" witch is less readable like "in-edit/designs/general"
// as for now.
// TODO: 1. make system template NamedParentPath dependent on their location in structure.
// 2. load cms-page not only by NamedParentPath, but also by 'OR (Template = "$template" AND IsSystem = 1)'
// This way we can store CMS-blocks based on system template name on HDD no matter where it's location is
// and we can address him from template using his system path OR structure path (CMS-blocks should work too).
$object->SetDBField('IsMenu', 0);
$object->SetDBField('ThemeId', $system ? $theme_id : 0);
$object->SetDBField('Priority', $min_priority - 1);
$object->SetDBField('Template', $design_template);
$object->SetDBField('CachedTemplate', $design_template);
$primary_language = $this->Application->GetDefaultLanguageId();
$current_language = $this->Application->GetVar('m_lang');
$object->SetDBField('l' . $primary_language . '_Name', $page_name);
$object->SetDBField('l' . $current_language . '_Name', $page_name);
$object->SetDBField('l' . $primary_language . '_Description', $page_description);
$object->SetDBField('l' . $current_language . '_Description', $page_description);
return $object->Create();
}
function _getParentCategoryFromPath($category_path, $base_category, $theme_id = null)
{
static $category_ids = Array ();
if (!$category_path) {
return $base_category;
}
if (array_key_exists(implode('||', $category_path), $category_ids)) {
return $category_ids[ implode('||', $category_path) ];
}
$backup_category_id = $this->Application->GetVar('m_cat_id');
$object =& $this->Application->recallObject($this->Prefix . '.-item', null, Array ('skip_autoload' => true));
/* @var $object kDBItem */
$parent_id = $base_category;
$filenames_helper =& $this->Application->recallObject('FilenamesHelper');
/* @var $filenames_helper kFilenamesHelper */
$safe_category_path = array_map(Array (&$filenames_helper, 'replaceSequences'), $category_path);
foreach ($category_path as $category_order => $category_name) {
$this->Application->SetVar('m_cat_id', $parent_id);
// get virtual category first, when possible
$sql = 'SELECT ' . $object->IDField . '
FROM ' . $object->TableName . '
WHERE
(
Filename = ' . $this->Conn->qstr($safe_category_path[$category_order]) . ' OR
Filename = ' . $this->Conn->qstr( $filenames_helper->replaceSequences('_Auto: ' . $category_name) ) . '
) AND
(ParentId = ' . $parent_id . ') AND
(ThemeId = 0 OR ThemeId = ' . $theme_id . ')
ORDER BY ThemeId ASC';
$parent_id = $this->Conn->GetOne($sql);
if ($parent_id === false) {
// page not found
$template = implode('/', array_slice($safe_category_path, 0, $category_order + 1));
// don't process system templates in sub-categories
$system = $this->_templateFound($template, $theme_id) && (strpos($template, '/') === false);
if (!$this->_prepareAutoPage($object, $category_name, $theme_id, $system ? SMS_MODE_FORCE : false)) {
// page was not created
break;
}
$parent_id = $object->GetID();
}
}
$this->Application->SetVar('m_cat_id', $backup_category_id);
$category_ids[ implode('||', $category_path) ] = $parent_id;
return $parent_id;
}
/**
* Returns theme name by it's id. Used in structure page creation.
*
* @param int $theme_id
* @return string
*/
function _getThemeName($theme_id)
{
static $themes = null;
if (!isset($themes)) {
$id_field = $this->Application->getUnitOption('theme', 'IDField');
$table_name = $this->Application->getUnitOption('theme', 'TableName');
$sql = 'SELECT Name, ' . $id_field . '
FROM ' . $table_name . '
WHERE Enabled = 1';
$themes = $this->Conn->GetCol($sql, $id_field);
}
return array_key_exists($theme_id, $themes) ? $themes[$theme_id] : false;
}
/**
* Resets SMS-menu cache
*
* @param kEvent $event
*/
function OnResetMenuCache(&$event)
{
$this->Conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName IN ("cms_menu", "StructureTree")');
}
/**
* Updates structure config
*
* @param kEvent $event
*/
function OnAfterConfigRead(&$event)
{
parent::OnAfterConfigRead($event);
if (defined('IS_INSTALL') && IS_INSTALL) {
// skip any processing, because Category table doesn't exists until install is finished
return ;
}
$root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
// set root category
$section_ajustments = $this->Application->getUnitOption($event->Prefix, 'SectionAdjustments');
$section_ajustments['in-portal:browse'] = Array (
'url' => Array ('m_cat_id' => $root_category),
'late_load' => Array ('m_cat_id' => $root_category),
'onclick' => 'checkCatalog(' . $root_category . ')',
);
$this->Application->setUnitOption($event->Prefix, 'SectionAdjustments', $section_ajustments);
// prepare structure dropdown
$category_helper =& $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
$fields['ParentId']['default'] = (int)$this->Application->GetVar('m_cat_id');
$fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions();
// limit design list by theme
$design_folders = Array ('tf.FilePath = "/designs"', 'tf.FilePath = "/platform/designs"');
foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
$design_folders[] = 'tf.FilePath = "/' . $module_info['TemplatePath'] . 'designs"';
}
$design_folders = array_unique($design_folders);
$theme_id = $this->_getCurrentThemeId();
$design_sql = $fields['Template']['options_sql'];
$design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $design_folders) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql);
$fields['Template']['options_sql'] = $design_sql;
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
if ($this->Application->IsAdmin()) {
// don't sort by Front-End sorting fields
$config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
$remove_keys = Array ('DefaultSorting1Field', 'DefaultSorting2Field', 'DefaultSorting1Dir', 'DefaultSorting2Dir');
foreach ($remove_keys as $remove_key) {
unset($config_mapping[$remove_key]);
}
$this->Application->setUnitOption($event->Prefix, 'ConfigMapping', $config_mapping);
}
else {
// sort by parent path on Front-End only
$list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings');
$list_sortings['']['ForcedSorting'] = Array ("CurrentSort" => 'asc');
$this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
}
// add grids for advanced view (with primary category column)
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
$process_grids = Array ('Default', 'Radio');
foreach ($process_grids as $process_grid) {
$grid_data = $grids[$process_grid];
$grid_data['Fields']['CachedNavbar'] = Array ('title' => 'la_col_Path', 'data_block' => 'grid_parent_category_td', 'filter_block' => 'grid_like_filter');
$grids[$process_grid . 'ShowAll'] = $grid_data;
}
$this->Application->setUnitOption($this->Prefix, 'Grids', $grids);
}
/**
* Removes this item and it's children (recursive) from structure dropdown
*
* @param kEvent $event
*/
function OnAfterItemLoad(&$event)
{
parent::OnAfterItemLoad($event);
if (!$this->Application->IsAdmin()) {
return ;
}
$object =& $event->getObject();
// remove this category & it's children from dropdown
$sql = 'SELECT '.$object->IDField.'
FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
WHERE ParentPath LIKE "'.$object->GetDBField('ParentPath').'%"';
$remove_categories = $this->Conn->GetCol($sql);
$field_options = $object->GetFieldOptions('ParentId');
foreach ($remove_categories as $remove_category) {
unset($field_options['options'][$remove_category]);
}
$object->SetFieldOptions('ParentId', $field_options);
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$priority_helper->preparePriorities($event, false, 'ParentId = '.$object->GetDBField('ParentId'));
// storing prioriry right after load for comparing when updating
$object->SetDBField('OldPriority', $object->GetDBField('Priority'));
}
/**
* Builds list
*
* @param kEvent $event
* @access protected
*/
function OnListBuild(&$event)
{
parent::OnListBuild($event);
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$priority_helper->preparePriorities($event, false, 'ParentId = '.$this->Application->GetVar('m_cat_id'));
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnAfterRebuildThemes(&$event)
{
$sql = 'SELECT t.ThemeId, CONCAT( tf.FilePath, \'/\', tf.FileName ) AS Path, tf.FileMetaInfo
FROM '.TABLE_PREFIX.'ThemeFiles AS tf
LEFT JOIN '.TABLE_PREFIX.'Theme AS t ON t.ThemeId = tf.ThemeId
WHERE t.Enabled = 1 AND tf.FileType = 1
AND (
SELECT COUNT(CategoryId)
FROM ' . TABLE_PREFIX . 'Category
WHERE CONCAT(\'/\', ' . TABLE_PREFIX . 'Category.Template, \'.tpl\') = CONCAT( tf.FilePath, \'/\', tf.FileName )
) = 0 ';
$files = $this->Conn->Query($sql, 'Path');
if (!$files) {
// all possible pages are already created
return ;
}
set_time_limit(0);
ini_set('memory_limit', -1);
$dummy =& $this->Application->recallObject($event->Prefix . '.-dummy', null, Array ('skip_autoload' => true));
/* @var $dummy kDBItem */
$error_count = 0;
foreach ($files as $a_file => $file_info) {
$status = $this->_prepareAutoPage($dummy, $a_file, $file_info['ThemeId'], SMS_MODE_FORCE, unserialize($file_info['FileMetaInfo'])); // create system page
if (!$status) {
$error_count++;
}
}
if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) {
$updater =& $this->Application->recallObject('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
}
$event->CallSubEvent('OnResetMenuCache');
if ($error_count) {
// allow user to review error after structure page creation
$event->MasterEvent->redirect = false;
}
}
/**
* Processes OnMassMoveUp, OnMassMoveDown events
*
* @param kEvent $event
*/
function OnChangePriority(&$event)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
$ids = $this->StoreSelectedIDs($event);
if ($ids) {
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
$parent_id = $this->Application->GetVar('m_cat_id');
$sql = 'SELECT Priority, '.$id_field.'
FROM '.$table_name.'
WHERE '.$id_field.' IN ('.implode(',', $ids).')';
$priorities = $this->Conn->GetCol($sql, $id_field);
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
foreach ($ids as $id) {
$new_priority = $priorities[$id] + ($event->Name == 'OnMassMoveUp' ? +1 : -1);
$changes = Array (
$id => Array ('old' => $priorities[$id], 'new' => $new_priority, 'parent' => $parent_id),
);
$sql = 'UPDATE '.$table_name.'
SET Priority = '.$new_priority.'
WHERE '.$id_field.' = '.$id;
$this->Conn->Query($sql);
$priority_helper->updatePriorities($event, $changes, Array ($id => $id));
}
}
$this->clearSelectedIDs($event);
$this->Application->StoreVar('RefreshStructureTree', 1);
}
/**
* Completely recalculates priorities in current category
*
* @param kEvent $event
*/
function OnRecalculatePriorities(&$event)
{
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$parent_id = $this->Application->GetVar('m_cat_id');
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $parent_id);
}
/**
* Update Preview Block for FCKEditor
*
* @param kEvent $event
*/
function OnUpdatePreviewBlock(&$event)
{
$event->status = erSTOP;
$string = unhtmlentities($this->Application->GetVar('preview_content'));
+ $category_helper =& $this->Application->recallObject('CategoryHelper');
+ /* @var $category_helper CategoryHelper */
+
+ $string = $category_helper->replacePageIds($string);
+
$this->Application->StoreVar('_editor_preview_content_', $string);
}
}
?>
\ No newline at end of file
Index: branches/RC/core/units/themes/themes_config.php
===================================================================
--- branches/RC/core/units/themes/themes_config.php (revision 11759)
+++ branches/RC/core/units/themes/themes_config.php (revision 11760)
@@ -1,133 +1,133 @@
<?php
$config = Array(
'Prefix' => 'theme',
'ItemClass' => Array('class'=>'ThemeItem','file'=>'theme_item.php','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ThemesEventHandler','file'=>'themes_eh.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ThemesTagProcessor','file'=>'themes_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
'IDField' => 'ThemeId',
'StatusField' => Array('Enabled', 'PrimaryTheme'),
'PermSection' => Array('main' => 'in-portal:configure_themes'),
'Sections' => Array (
'in-portal:configure_themes' => Array (
'parent' => 'in-portal:website_setting_folder',
'icon' => 'conf_themes',
'label' => 'la_tab_Themes',
'url' => Array('t' => 'themes/themes_list', 'pass' => 'm'),
'permissions' => Array ('view', 'add', 'edit', 'delete'),
'priority' => 5,
'type' => stTREE,
),
),
'TitleField' => 'Name',
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array('theme' => '!la_title_Adding_Theme!'),
'edit_status_labels' => Array('theme' => '!la_title_Editing_Theme!'),
'new_titlefield' => Array('theme' => '!la_title_NewTheme!'),
),
'themes_list' => Array('prefixes' => Array('theme_List'), 'format' => "!la_tab_Themes!"),
'themes_edit_general' => Array('prefixes' => Array('theme'), 'format' => "#theme_status# '#theme_titlefield#' - !la_title_General!"),
'themes_edit_files' => Array('prefixes' => Array('theme', 'theme-file_List'), 'format' => "#theme_status# '#theme_titlefield#' - !la_title_ThemeFiles!"),
'theme_file_edit' => Array (
'prefixes' => Array ('theme', 'theme-file'),
'new_status_labels' => Array ('theme-file' => '!la_title_AddingThemeFile!'),
'edit_status_labels' => Array ('theme-file' => '!la_title_EditingThemeFile!'),
'new_titlefield' => Array ('theme-file' => '!la_title_NewThemeFile!'),
'format' => "#theme_status# '#theme_titlefield#' - #theme-file_status# '#theme-file_titlefield#'",
),
'block_edit' => Array('prefixes' => Array('theme-file'), 'format' => "!la_title_EditingThemeFile! '#theme-file_titlefield#'"),
),
'EditTabPresets' => Array (
'Default' => Array (
'general' => Array ('title' => 'la_tab_General', 't' => 'themes/themes_edit', 'priority' => 1),
'files' => Array ('title' => 'la_tab_Files', 't' => 'themes/themes_edit_files', 'priority' => 2),
),
),
'TableName' => TABLE_PREFIX.'Theme',
'SubItems' => Array('theme-file'),
'FilterMenu' => Array(
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array(0,1), 'type' => WHERE_FILTER),
),
'Filters' => Array(
0 => Array('label' =>'la_Enabled', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 1' ),
1 => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 0' ),
)
),
'AutoDelete' => true,
'AutoClone' => true,
'ListSQLs' => Array ('' => ' SELECT %1$s.* %2$s
FROM %s
LEFT JOIN '.TABLE_PREFIX.'Stylesheets st ON st.StylesheetId = %1$s.StylesheetId'),
'ItemSQLs' => Array ( '' => ' SELECT %1$s.* %2$s
FROM %s
LEFT JOIN '.TABLE_PREFIX.'Stylesheets st ON st.StylesheetId = %1$s.StylesheetId'),
'ListSortings' => Array (
'' => Array(
'Sorting' => Array('Name' => 'asc'),
)
),
'CalculatedFields' => Array (
'' => Array (
'StyleName' => 'st.Name',
'LastCompiled' => 'st.LastCompiled',
),
),
'Fields' => Array(
'ThemeId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Name' => Array('type' => 'string','not_null' => 1, 'required' => 1, 'default' => ''),
'Enabled' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1=>'la_Enabled', 0=>'la_Disabled'), 'use_phrases'=>1, 'not_null' => 1, 'default' => 1),
- 'Description' => Array('type' => 'string','default' => null),
+ 'Description' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
'PrimaryTheme' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
'CacheTimeout' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'StylesheetId' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Stylesheets', 'option_key_field' => 'StylesheetId', 'option_title_field' => 'Name', 'not_null' => 1, 'default' => 0),
),
'VirtualFields' => Array (
'StyleName' => Array ('type' => 'string', 'default' => ''),
'LastCompiled' => Array ('type' => 'int', 'default' => null),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif', '1_1' => 'icon16_theme_primary.gif', '1_0' => 'icon16_theme.gif', '0_0' => 'icon16_theme_disabled.gif'),
'Fields' => Array(
'ThemeId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Name' => Array( 'title'=>'la_col_Name', 'filter_block' => 'grid_like_filter'),
'Description' => Array( 'title'=>'la_col_Description', 'filter_block' => 'grid_like_filter'),
'Enabled' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'),
// 'PrimaryTheme' => Array( 'title'=>'la_col_Primary', 'filter_block' => 'grid_options_filter'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/translator/translator_config.php
===================================================================
--- branches/RC/core/units/translator/translator_config.php (revision 11759)
+++ branches/RC/core/units/translator/translator_config.php (revision 11760)
@@ -1,46 +1,46 @@
<?php
$config = Array(
'Prefix' => 'trans',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'TranslatorEventHandler','file'=>'translator_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'TranslatorTagProcessor','file'=>'translator_tp.php','build_event'=>'OnBuild'),
'AutoLoad' => false,
'hooks' => Array(),
'QueryString' => Array(
1 => 'prefix',
2 => 'field',
3 => 'multi_line',
4 => 'event',
),
'IDField' => 'N/A',
'TitlePhrase' => 'la_text_Translation',
'TitlePresets' => Array(
'default' => Array(
'new_status_labels' => Array('trans'=>'!la_title_Adding_Order!'),
'edit_status_labels' => Array('trans'=>'!la_title_Editing_Order!'),
'new_titlefield' => Array('trans'=>''),
),
'trans_edit' => Array('prefixes' => Array('trans'), 'format' => '!la_title_EditingTranslation!'),
),
'ItemSQLs' => Array ('' => ''),
'Fields' => Array(
),
'VirtualFields' => Array(
'Original' => Array(),
'Language' => Array(),
'SwitchLanguage' => Array('formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Language', 'option_key_field' => 'LanguageId','option_title_field' => 'PackName'),
- 'Translation' => Array(),
+ 'Translation' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => ''),
),
'Grids' => Array(),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/mailing_lists/mailing_lists_config.php
===================================================================
--- branches/RC/core/units/mailing_lists/mailing_lists_config.php (revision 11759)
+++ branches/RC/core/units/mailing_lists/mailing_lists_config.php (revision 11760)
@@ -1,122 +1,122 @@
<?php
$config = Array (
'Prefix' => 'mailing-list',
'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'MailingListEventHandler', 'file' => 'mailing_list_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'MailingListTagProcessor', 'file' => 'mailing_list_tp.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
'RegularEvents' => Array (
'generate_mailing_queue' => Array ('EventName' => 'OnGenerateEmailQueue', 'RunInterval' => 1800, 'Type' => reAFTER),
'process_mailing_queue' => Array ('EventName' => 'OnProcessEmailQueue', 'RunInterval' => 1800, 'Type' => reAFTER),
),
'IDField' => 'MailingId',
'TableName' => TABLE_PREFIX . 'MailingLists',
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array ('mailing-list' => '!la_title_AddingMailingList!'),
'edit_status_labels' => Array ('mailing-list' => '!la_title_ViewingMailingList!'),
),
'mailing_list_list' => Array ('prefixes' => Array ('mailing-list_List'), 'format' => "!la_title_MailingLists!"),
'mailing_list_edit' => Array ('prefixes' => Array ('mailing-list'), 'format' => "#mailing-list_status#"),
),
'PermSection' => Array('main' => 'in-portal:mailing_lists'),
'Sections' => Array (
'in-portal:mailing_folder' => Array (
'parent' => 'in-portal:users',
'icon' => 'custom',
'label' => 'la_title_MailingLists',
'permissions' => Array (),
'priority' => 7,
'type' => stTREE,
),
'in-portal:mailing_lists' => Array (
'parent' => 'in-portal:mailing_folder',
'icon' => 'custom',
'label' => 'la_title_MailingLists',
'url' => Array('t' => 'mailing_lists/mailing_list_list', 'pass' => 'm'),
'permissions' => Array('view', 'add', 'edit', 'delete'),
'priority' => 7.1,
'type' => stTAB,
),
),
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s FROM %1$s',
),
'ListSortings' => Array (
'' => Array (
'Sorting' => Array ('MailingId' => 'desc'),
)
),
'Fields' => Array (
'MailingId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'PortalUserId' => Array(
'type' => 'int',
'formatter' => 'kLEFTFormatter',
'options' => Array (-1 => 'root'),
'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login',
'required' => 1, 'not_null' => 1, 'default' => -1,
),
'To' => Array ('type' => 'string', 'required' => 1, 'default' => NULL),
'ToParsed' => Array ('type' => 'string', 'default' => NULL),
'Attachments' => Array (
'type' => 'string',
'formatter' => 'kUploadFormatter', 'upload_dir' => ITEM_FILES_PATH, 'max_size' => 50000000,
'multiple' => 10, 'direct_links' => true, 'file_types' => '*.*', 'files_description' => 'All Files',
'default' => NULL
),
'Subject' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
- 'MessageText' => Array ('type' => 'string', 'default' => NULL),
- 'MessageHtml' => Array ('type' => 'string', 'default' => NULL),
+ 'MessageText' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL),
+ 'MessageHtml' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL),
'Status' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_NotProcessed', 2 => 'la_opt_PartiallyProcessed', 3 => 'la_opt_Processed', 4 => 'la_opt_Cancelled'), 'use_phrases' => 1,
'not_null' => 1, 'required' => 1, 'default' => 1
),
'EmailsQueued' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'EmailsSent' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'EmailsTotal' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array ('default' => 'icon16_custom.gif'),
'Fields' => Array (
'MailingId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', ),
'Subject' => Array ('title' => 'la_col_Subject', 'filter_block' => 'grid_like_filter', ),
'MessageText' => Array ('title' => 'la_col_MessageText', 'filter_block' => 'grid_like_filter', 'cut_first' => 100),
'MessageHtml' => Array ('title' => 'la_col_MessageHtml', 'filter_block' => 'grid_like_filter', 'cut_first' => 100),
'Status' => Array ('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter',),
'EmailsQueued' => Array ('title' => 'la_col_EmailsQueued', 'filter_block' => 'grid_range_filter',),
'EmailsSent' => Array ('title' => 'la_col_EmailsSent', 'filter_block' => 'grid_range_filter',),
'EmailsTotal' => Array ('title' => 'la_col_EmailsTotal', 'filter_block' => 'grid_range_filter',),
),
),
),
);
\ No newline at end of file
Index: branches/RC/core/units/selectors/selectors_config.php
===================================================================
--- branches/RC/core/units/selectors/selectors_config.php (revision 11759)
+++ branches/RC/core/units/selectors/selectors_config.php (revision 11760)
@@ -1,134 +1,134 @@
<?php
$config = Array(
'Prefix' => 'selectors',
'ItemClass' => Array('class'=>'SelectorsItem','file'=>'selectors_item.php','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'SelectorsEventHandler','file'=>'selectors_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'SelectorsTagProcessor','file'=>'selectors_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Clones' => Array(
'selectorsbase' => Array(
'Hooks' => Array(),
'Constrain' => 'Type = 1',
'SubItems' => Array('selectorsblock'),
),
'selectorsblock' => Array(
'Hooks' => Array(),
'Constrain' => 'Type = 2',
'ForeignKey' => Array('css' => 'StylesheetId', 'selectorsbase' => 'ParentId'),
'ParentTableKey' => Array('css' => 'StylesheetId', 'selectorsbase' => 'SelectorId'),
'ParentPrefix' => 'selectorsbase',
),
),
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'selectors',
'HookToSpecial' => '',
'HookToEvent' => Array('OnItemBuild'),
'DoPrefix' => '',
'DoSpecial' => '',
'DoEvent' => 'OnPrepareBaseStyles',
),
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'selectors',
'HookToSpecial' => 'block',
'HookToEvent' => Array('OnListBuild'),
'DoPrefix' => '',
'DoSpecial' => 'block',
'DoEvent' => 'OnPrepareBaseStyles',
),
),
'MyHooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => Array('Prefix1.*', 'Prefix2.Special1'),
'HookToEvents' => Array('OnBeforeItemUpdate', 'OnBeforeItemCreate'),
'DoPrefix' => Array('Prefix1.*', 'Prefix2.Special1'),
'DoEvent' => 'OnMyEvent',
),
),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
),
'IDField' => 'SelectorId',
'TitleField' => 'Name',
'TableName' => TABLE_PREFIX.'StylesheetSelectors',
'ForeignKey' => 'StylesheetId',
'ParentTableKey' => 'StylesheetId',
'ParentPrefix' => 'css',
'AutoDelete' => true,
'AutoClone' => true,
'ListSQLs' => Array( ''=>' SELECT %1$s.*
FROM %s',
), // key - special, value - list select sql
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Name' => 'asc'),
)
),
'Fields' => Array(
'SelectorId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'StylesheetId' => Array('type' => 'int', 'unique'=>Array('SelectorName'), 'current_table_only' => 1, 'not_null' => 1, 'default' => 0),
'Name' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1),
'SelectorName' => Array('type' => 'string', 'unique'=>Array('StylesheetId'), 'current_table_only' => 1, 'not_null' => '1','default' => '','required'=>1),
'SelectorData' => Array('type' => 'string', 'not_null' => '1','default' => ''),
- 'Description' => Array('type' => 'string','not_null' => '1','default' => ''),
+ 'Description' => Array('type' => 'string', 'formatter' => 'kFormatter', 'not_null' => 1, 'using_fck' => 1, 'default' => ''),
'Type' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'options'=>Array( 1 => 'la_BaseSelectors', 2 => 'la_BlockSelectors'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
- 'AdvancedCSS' => Array('type' => 'string','not_null' => '1','default' => ''),
+ 'AdvancedCSS' => Array('type' => 'string', 'formatter' => 'kFormatter', 'not_null' => 1, 'using_fck' => 1, 'default' => ''),
'ParentId' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'required' => 1, 'not_null' => 1, 'default' => 0),
),
'VirtualFields' => Array(
'FontStyle' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','normal'=>'normal','italic'=>'italic','oblique'=>'oblique'), 'default'=>'' ),
'FontWeight' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','100'=>'100','200'=>'200','300'=>'300','normal'=>'normal','500'=>'500','600'=>'600','bold'=>'bold','800'=>'800','900'=>'900','lighter'=>'lighter','bolder'=>'bolder') ),
'StyleCursor' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','default'=>'default','auto'=>'auto','n-resize'=>'n-resize','ne-resize'=>'ne-resize','e-resize'=>'e-resize','se-resize'=>'se-resize','s-resize'=>'s-resize','sw-resize'=>'sw-resize','w-resize'=>'w-resize','nw-resize'=>'nw-resize','crosshair'=>'crosshair','pointer'=>'pointer','move'=>'move','text'=>'text','wait'=>'wait','help'=>'help','hand'=>'hand','all-scroll'=>'all-scroll','col-resize'=>'col-resize','row-resize'=>'row-resize','no-drop'=>'no-drop','not-allowed'=>'not-allowed','progress'=>'progress','vertical-text'=>'vertical-text','alias'=>'alias','cell'=>'cell','copy'=>'copy','count-down'=>'count-down','count-up'=>'count-up','count-up-down'=>'count-up-down','grab'=>'grab','grabbing'=>'grabbing','spinning'=>'spinning') ),
'StyleDisplay' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','none'=>'none','inline'=>'inline','block'=>'block','inline-block'=>'inline-block','list-item'=>'list-item','marker'=>'marker','compact'=>'compact','run-in'=>'run-in','table-header-group'=>'table-header-group','table-footer-group'=>'table-footer-group','table'=>'table','inline-table'=>'inline-table','table-caption'=>'table-caption','table-row'=>'table-row','table-row-group'=>'table-row-group','table-column'=>'table-column','table-column-group'=>'table-column-group') ),
'TextAlign' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','left'=>'left','right'=>'right','center'=>'center','justify'=>'justify') ),
'TextDecoration' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','none'=>'none','underline'=>'underline','overline'=>'overline','line-through'=>'line-through','blink'=>'blink') ),
'StyleVisibility' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','visible'=>'visible','hidden'=>'hidden','collapse'=>'collapse') ),
'StylePosition' => Array('type'=>'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>'','inherit'=>'inherit','static'=>'static','relative'=>'relative','absolute'=>'absolute','fixed'=>'fixed') ),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_selector.gif'),
'Fields' => Array(
'Name' => Array( 'title'=>'la_col_Name', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_like_filter'),
'SelectorName' => Array( 'title'=>'la_col_SelectorName', 'filter_block' => 'grid_like_filter'),
'Description' => Array( 'title'=>'la_col_Description', 'data_block' => 'grid_description_td', 'filter_block' => 'grid_like_filter'),
),
),
'BlockStyles' => Array(
'Icons' => Array('default'=>'icon16_selector.gif'),
'Fields' => Array(
'Name' => Array( 'title'=>'la_col_Name', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_like_filter'),
'SelectorName' => Array( 'title'=>'la_col_SelectorName', 'filter_block' => 'grid_like_filter'),
'Description' => Array( 'title'=>'la_col_Description', 'data_block' => 'grid_description_td', 'filter_block' => 'grid_like_filter'),
'ParentId' => Array('title'=>'la_col_Basedon', 'filter_block' => 'grid_options_filter'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/content/content_config.php
===================================================================
--- branches/RC/core/units/content/content_config.php (revision 11759)
+++ branches/RC/core/units/content/content_config.php (revision 11760)
@@ -1,58 +1,53 @@
<?php
- $config = Array(
- 'Prefix' => 'content',
- 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
- 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
- 'EventHandlerClass' => Array('class'=>'kDBEventHandler','file'=>'','build_event'=>'OnBuild'),
- 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
- 'AutoLoad' => true,
- 'QueryString' => Array(
- 1 => 'id',
- 2 => 'Page',
- 3 => 'event',
- 4 => 'mode',
- ),
- 'IDField' => 'PageContentId',
- 'ParentTableKey'=> 'CategoryId', // linked field in master table
- 'ForeignKey' => 'PageId', // linked field in subtable
- 'ParentPrefix' => 'c',
- 'AutoDelete' => true,
- 'AutoClone' => true,
-
- 'TitleField' => 'ContentNum', // field, used in bluebar when editing existing item
-
- 'ViewMenuPhrase' => 'la_text_Pages',
-
- 'TitlePhrase' => 'la_text_PageContent',
-
- 'TitlePresets' => Array(
- 'default' => Array( 'new_status_labels' => Array('content'=>'!la_title_Adding_Content!'),
- 'edit_status_labels' => Array('content'=>'!la_title_Editing_Content!'),
- 'new_titlefield' => Array('content'=>''),
- ),
- 'content_edit' => Array('prefixes' => Array('content'), 'format' => '#content_status# - !la_title_General!'),
- ),
-
- 'TableName' => TABLE_PREFIX.'PageContent',
-
-// 'PermSection' => Array('main' => 'CATEGORY:in-portal:structure', ),
-
- 'ListSQLs' => Array('' => 'SELECT * FROM %s'), // key - special, value - list select sql
- 'ListSortings' => Array(
- '' => Array(
- 'Sorting' => Array('ContentNum' => 'asc'),
- )
- ),
- 'ItemSQLs' => Array('' => 'SELECT * FROM %s'),
-
- 'Fields' => Array (
- 'PageContentId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'ContentNum' => Array('type' => 'int','not_null' => 1, 'default' => 0),
- 'PageId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
- 'Content' => Array('type' => 'string','formatter'=>'kMultiLanguage', 'format'=>'no_default', 'default' => ''),
- 'Translated' => Array ('type' => 'int', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'default' => 0, 'db_type' => 'tinyint', 'index_type' => 'int'),
- ),
+ $config = Array (
+ 'Prefix' => 'content',
+ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array ('class' => 'ContentEventHandler', 'file' => 'content_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+ 'AutoLoad' => true,
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'Page',
+ 3 => 'event',
+ 4 => 'mode',
+ ),
+
+ 'IDField' => 'PageContentId',
+ 'ParentTableKey' => 'CategoryId', // linked field in master table
+ 'ForeignKey' => 'PageId', // linked field in subtable
+ 'ParentPrefix' => 'c',
+ 'AutoDelete' => true,
+ 'AutoClone' => true,
+
+ 'TitleField' => 'ContentNum', // field, used in bluebar when editing existing item
+ 'ViewMenuPhrase' => 'la_text_Pages',
+ 'TitlePhrase' => 'la_text_PageContent',
+
+ 'TitlePresets' => Array (
+ 'default' => Array (
+ 'new_status_labels' => Array ('content' => '!la_title_Adding_Content!'),
+ 'edit_status_labels' => Array ('content' => '!la_title_Editing_Content!'),
+ ),
+ 'content_edit' => Array ('prefixes' => Array ('content'), 'format' => '#content_status# - !la_title_General!'),
+ ),
+
+ 'TableName' => TABLE_PREFIX . 'PageContent',
+
+ 'ListSQLs' => Array ('' => 'SELECT * FROM %s'),
+ 'ListSortings' => Array (
+ '' => Array (
+ 'Sorting' => Array ('ContentNum' => 'asc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'PageContentId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'ContentNum' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'PageId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'Content' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'format' => 'no_default', 'using_fck' => 1, 'default' => ''),
+ 'Translated' => Array ('type' => 'int', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'default' => 0, 'db_type' => 'tinyint', 'index_type' => 'int'),
+ ),
);
-?>
\ No newline at end of file
Index: branches/RC/core/units/content/content_eh.php
===================================================================
--- branches/RC/core/units/content/content_eh.php (nonexistent)
+++ branches/RC/core/units/content/content_eh.php (revision 11760)
@@ -0,0 +1,23 @@
+<?php
+
+ class ContentEventHandler extends kDBEventHandler {
+
+ /**
+ * Checks permissions of user
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ $perm_helper =& $this->Application->recallObject('PermissionsHelper');
+ /* @var $perm_helper kPermissionsHelper */
+
+ $user_id = $this->Application->RecallVar('user_id');
+
+ // user can change top category
+ $perm_status = $perm_helper->CheckUserPermission($user_id, 'CATEGORY.MODIFY', 0, 0);
+
+ return $perm_helper->finalizePermissionCheck($event, $perm_status);
+ }
+
+ }
\ No newline at end of file
Index: branches/RC/core/units/groups/groups_config.php
===================================================================
--- branches/RC/core/units/groups/groups_config.php (revision 11759)
+++ branches/RC/core/units/groups/groups_config.php (revision 11760)
@@ -1,129 +1,129 @@
<?php
$config = Array (
'Prefix' => 'g',
'ItemClass' => Array ('class' => 'GroupsItem', 'file' => 'groups_item.php', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'GroupsEventHandler', 'file' => 'groups_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'GroupTagProcessor', 'file' => 'group_tp.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'mode',
),
'IDField' => 'GroupId',
'StatusField' => Array ('Enabled'),
'TitleField' => 'Name',
'SubItems' => Array ('g-perm', 'g-ug'),
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array('g' => '!la_title_Adding_Group!'),
'edit_status_labels' => Array('g' => '!la_title_Editing_Group!'),
'new_titlefield' => Array('g' => ''),
),
'group_list' => Array ('prefixes' => Array ('g.total_List'), 'format' => "!la_title_Groups!"),
'groups_edit' => Array ('prefixes' => Array ('g'), 'format' => "#g_status# '#g_titlefield#' - !la_title_General!"),
'groups_edit_users' => Array ('prefixes' => Array ('g', 'g-ug_List'), 'format' => "#g_status# '#g_titlefield#' - !la_title_Users!" ),
'groups_edit_permissions' => Array ('prefixes' => Array ('g'), 'format' => "#g_status# '#g_titlefield#' - !la_title_Permissions!" ),
'groups_edit_additional_permissions' => Array ('prefixes' => Array ('g'), 'format' => "#g_status# '#g_titlefield#' - !la_title_AdditionalPermissions!" ),
'select_group' => Array('prefixes' => Array ('g.user_List'), 'format' => "!la_title_Groups! - !la_title_SelectGroup!"),
),
'EditTabPresets' => Array (
'Default' => Array (
'general' => Array ('title' => 'la_tab_General', 't' => 'groups/groups_edit', 'priority' => 1),
'users' => Array ('title' => 'la_tab_Users', 't' => 'groups/groups_edit_users', 'priority' => 2),
'permissions' => Array ('title' => 'la_tab_Permissions', 't' => 'groups/groups_edit_permissions', 'priority' => 3),
),
),
'PermSection' => Array ('main' => 'in-portal:user_groups'),
'TableName' => TABLE_PREFIX.'PortalGroup',
'ListSQLs' => Array (
'' => 'SELECT %1$s.* %2$s FROM %1$s',
),
'ListSortings' => Array (
'' => Array (
'Sorting' => Array ('Name' => 'asc'),
),
),
'CalculatedFields' => Array (
'total' => Array (
'UserCount' => 'SELECT COUNT(*) FROM ' . TABLE_PREFIX . 'UserGroup ug WHERE ug.GroupId = %1$s.GroupId',
),
),
'Fields' => Array (
'GroupId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Name' => Array ('type' => 'string', 'not_null' => 1, 'required' => 1, 'default' => ''),
- 'Description' => Array ('type' => 'string', 'default' => null),
+ 'Description' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'System' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Personal' => Array ('type' => 'int','not_null' => 1, 'default' => 0),
'Enabled' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1 => 'la_Enabled', 0 => 'la_Disabled'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1),
'ResourceId' => Array ('type' => 'int','not_null' => 1, 'default' => 0),
'FrontRegistration' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0
),
),
'VirtualFields' => Array (
'UserCount' => Array ('type' => 'int', 'default' => 0),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array (1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'),
'Fields' => Array (
'GroupId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Name' => Array ('title' => 'la_col_GroupName'),
'UserCount' => Array ('title' => 'la_col_UserCount', 'filter_block' => 'grid_range_filter'),
'FrontRegistration' => Array ('title' => 'la_col_FrontRegistration', 'filter_block' => 'grid_options_filter'),
),
),
'UserGroups' => Array (
'Icons' => Array (1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'),
'Fields' => Array (
'GroupId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Name' => Array ('title' => 'la_col_GroupName'),
),
),
'Radio' => Array (
'Icons' => Array (1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'),
'Selector' => 'radio',
'Fields' => Array (
'GroupId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_radio_td', 'filter_block' => 'grid_range_filter'),
'Name' => Array ('title' => 'la_col_GroupName'),
'Description' => Array ('title' => 'la_col_Description'),
),
),
'GroupSelector' => Array (
'Icons' => Array (1 => 'icon16_group.gif', 0 => 'icon16_group_disabled.gif'),
'Fields' => Array (
'GroupId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Name' => Array ('title' => 'la_col_GroupName'),
'Description' => Array ('title' => 'la_col_Description'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/reviews/reviews_config.php
===================================================================
--- branches/RC/core/units/reviews/reviews_config.php (revision 11759)
+++ branches/RC/core/units/reviews/reviews_config.php (revision 11760)
@@ -1,197 +1,197 @@
<?php
$config = Array (
'Prefix' => 'rev',
'Clones' => Array (
'l-rev' => Array(
'ParentPrefix' => 'l',
'ConfigMapping' => Array (
'PerPage' => 'Perpage_LinkReviews',
'ShortListPerPage' => 'Perpage_LinkReviews_Short',
'DefaultSorting1Field' => 'Link_ReviewsSort',
'DefaultSorting2Field' => 'Link_ReviewsSort2',
'DefaultSorting1Dir' => 'Link_ReviewsOrder',
'DefaultSorting2Dir' => 'Link_ReviewsOrder2',
'ReviewDelayInterval' => 'link_ReviewDelay_Interval',
'ReviewDelayValue' => 'link_ReviewDelay_Value',
),
),
'n-rev' => Array (
'ParentPrefix' => 'n',
'ConfigMapping' => Array (
'PerPage' => 'Perpage_NewsReviews',
'ShortListPerPage' => 'Perpage_NewsReviews_Short',
'DefaultSorting1Field' => 'News_SortReviews',
'DefaultSorting2Field' => 'News_SortReviews2',
'DefaultSorting1Dir' => 'News_SortReviewsOrder',
'DefaultSorting2Dir' => 'News_SortReviewsOrder2',
'ReviewDelayInterval' => 'News_ReviewDelay_Interval',
'ReviewDelayValue' => 'News_ReviewDelay_Value',
),
),
'bb-rev' => Array (
'ParentPrefix' => 'bb',
'ConfigMapping' => Array (
'PerPage' => 'Perpage_TopicReviews',
'ReviewDelayInterval' => 'topic_ReviewDelay_Interval',
'ReviewDelayValue' => 'topic_ReviewDelay_Value',
),
),
'p-rev' => Array (
'ParentPrefix' => 'p',
'ConfigMapping' => Array (
'PerPage' => 'Comm_Perpage_Reviews',
'ReviewDelayInterval' => 'product_ReviewDelay_Value',
'ReviewDelayValue' => 'product_ReviewDelay_Interval',
),
),
),
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ReviewsEventHandler','file'=>'reviews_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ReviewsTagProcessor','file'=>'reviews_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
'ParentPrefix' => 'p', // replace all usage of rev to "p-rev" and then remove this param from here and Prefix too
'ConfigMapping' => Array (
'PerPage' => 'Comm_Perpage_Reviews',
'ReviewDelayInterval' => 'product_ReviewDelay_Value',
'ReviewDelayValue' => 'product_ReviewDelay_Interval',
),
'IDField' => 'ReviewId',
'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events
'TableName' => TABLE_PREFIX.'ItemReview',
'ParentTableKey' => 'ResourceId', // linked field in master table
'ForeignKey' => 'ItemId', // linked field in subtable
'AutoDelete' => true,
'AutoClone' => true,
'TitlePresets' => Array (
'reviews_edit' => Array('format' => "!la_title_Editing_Review!"),
),
'FilterMenu' => Array (
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER),
),
'Filters' => Array(
'show_active' => Array('label' =>'la_Active', 'on_sql' => '', 'off_sql' => '%1$s.Status != 1' ),
'show_pending' => Array('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => '%1$s.Status != 2' ),
'show_disabled' => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Status != 0' ),
)
),
'CalculatedFields' => Array (
'' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
),
'products' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
'ItemName' => 'pr.l1_Name',
'ProductId' => 'pr.ProductId',
),
'product' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
'ItemName' => 'pr.l1_Name',
'ProductId' => 'pr.ProductId',
),
),
// key - special, value - list select sql
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = %1$s.CreatedById',
'products' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Products pr ON pr.ResourceId = %1$s.ItemId
LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = %1$s.CreatedById',
'product' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Products pr ON pr.ResourceId = %1$s.ItemId
LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = %1$s.CreatedById',
),
'ItemSQLs' => Array ('' => 'SELECT * FROM %s'),
'ListSortings' => Array (
'' => Array(
'ForcedSorting' => Array('Priority' => 'desc'),
'Sorting' => Array('CreatedOn' => 'desc'),
)
),
'Fields' => Array (
'ReviewId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'CreatedOn' => Array('type' => 'int', 'formatter'=>'kDateFormatter', 'default'=>'#NOW#'),
- 'ReviewText' => Array('type'=>'string','required'=>1,'not_null'=>1,'default'=>''),
+ 'ReviewText' => Array('type' => 'string', 'formatter' => 'kFormatter', 'required' => 1, 'not_null' => 1, 'using_fck' => 1, 'default' => ''),
'Rating' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'lu_None', 1 => 'lu_Rating_1', 2 => 'lu_Rating_2', 3 => 'lu_Rating_3', 4 => 'lu_Rating_4', 5 => 'lu_Rating_5'), 'use_phrases' => 1, 'min_value_inc' => 0, 'max_value_inc' => 5, 'default' => 0),
'IPAddress' => Array('type'=>'string','max_value_inc'=>15,'not_null'=>1,'default'=>''),
'ItemId' => Array('type'=>'int','not_null'=>1,'default'=>0),
'CreatedById' => Array('type' => 'int', 'formatter'=>'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'','left_key_field'=>'PortalUserId','left_title_field'=>'Login','required'=>1,'not_null'=>1,'default'=>-1),
'ItemType' => Array('type'=>'int','not_null'=>1,'default'=>0),
'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0),
'Status' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'use_phrases' => 1, 'options'=>Array(1=>'la_Active',2=>'la_Pending',0=>'la_Disabled'),'not_null'=>1,'default'=>2 ),
'TextFormat' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_text', 1 => 'la_html'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
'Module' => Array('type'=>'string','not_null'=>1,'default'=>''),
),
'VirtualFields' => Array (
'ReviewedBy' => Array('type' => 'string', 'default' => ''),
'CatalogItemName' => Array ('type' => 'string', 'default' => ''),
'CatalogItemId' => Array ('type' => 'int', 'default' => 0),
'CatalogItemCategory' => Array ('type' => 'int', 'default' => 0),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array ('default'=>'icon16_custom.gif',1=>'icon16_review.gif',2=>'icon16_review_pending.gif',0=>'icon16_review_disabled.gif'),
'Fields' => Array (
'ReviewId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'ReviewText' => Array( 'title'=>'la_col_ReviewText', 'filter_block' => 'grid_like_filter'),
'ReviewedBy' => Array( 'title'=>'la_col_ReviewedBy', 'filter_block' => 'grid_like_filter'),
'CreatedOn' => Array( 'title'=>'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter'),
'Status' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'),
'Rating' => Array( 'title'=>'la_col_Rating', 'filter_block' => 'grid_options_filter'),
),
),
'ReviewsSection' => Array (
'Icons' => Array ('default'=>'icon16_custom.gif',1=>'icon16_review.gif',2=>'icon16_review_pending.gif',0=>'icon16_review_disabled.gif'),
'Fields' => Array (
'ReviewId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'ReviewText' => Array( 'title'=>'la_col_ReviewText', 'data_block' => 'grid_reviewtext_td', 'filter_block' => 'grid_like_filter'),
'ReviewedBy' => Array( 'title'=>'la_col_ReviewedBy', 'filter_block' => 'grid_like_filter'),
'CreatedOn' => Array( 'title'=>'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter'),
'Status' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'),
'Rating' => Array( 'title'=>'la_col_Rating', 'filter_block' => 'grid_options_filter'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/forms/forms_config.php
===================================================================
--- branches/RC/core/units/forms/forms_config.php (revision 11759)
+++ branches/RC/core/units/forms/forms_config.php (revision 11760)
@@ -1,110 +1,110 @@
<?php
$config = Array(
'Prefix' => 'form',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'FormsEventHandler','file'=>'forms_eh.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'FormsTagProcessor','file'=>'forms_tp.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array(
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'form', //self
'HookToSpecial' => '*',
'HookToEvent' => Array('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '',
'DoEvent' => 'OnCreateSubmissionNodes',
),
),
'TableName' => TABLE_PREFIX.'Forms',
'IDField' => 'FormId',
'TitleField' => 'Title',
'PermSection' => Array('main' => 'in-portal:forms'),
'Sections' => Array(
'in-portal:forms' => Array(
'parent' => 'in-portal:site',
'icon' => 'in-portal:form',
'label' => 'la_tab_CMSForms', //'la_tab_FormsConfig',
'url' => Array('t' => 'forms/forms_list', 'pass' => 'm'), // set "container" parameter (in section definition, not url) to true when form editing should be disabled, but submissions still visible
'permissions' => Array('view', 'add', 'edit', 'delete'),
'priority' => 7,
// 'show_mode' => smSUPER_ADMIN,
'type' => stTREE,
),
),
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('form'=>'!la_title_Adding_Form!'),
'edit_status_labels' => Array('form'=>'!la_title_Editing_Form!'),
'new_titlefield' => Array('form'=>''),
),
'forms_list'=>Array('prefixes' => Array('form_List'),
'format' => "!la_title_Forms!",
),
'forms_edit'=>Array( 'prefixes' => Array('form'),
'format' => "#form_status# '#form_titlefield#' - !la_title_General!",
),
'forms_edit_fields' => Array( 'prefixes' => Array('form'),
'format' => "#form_status# '#form_titlefield#' - !la_title_Fields!",
),
'form_field_edit' => Array( 'prefixes' => Array('form', 'formflds'),
'new_status_labels' => Array('formflds'=>"!la_title_Adding_FormField!"),
'edit_status_labels' => Array('formflds'=>'!la_title_Editing_FormField!'),
'new_titlefield' => Array('formflds'=>''),
'format' => "#form_status# '#form_titlefield#' - #formflds_status# '#formflds_titlefield#'",
),
'tree_submissions'=>Array(
'format' => "!la_title_FormSubmissions!",
),
),
'EditTabPresets' => Array (
'Default' => Array (
'general' => Array ('title' => 'la_tab_General', 't' => 'forms/forms_edit', 'priority' => 1),
'fields' => Array ('title' => 'la_tab_Fields', 't' => 'forms/forms_edit_fields', 'priority' => 2),
),
),
'ListSQLs' => Array(
''=>' SELECT %1$s.* %2$s FROM %1$s',
), // key - special, value - list select sql
'ItemSQLs' => Array(
''=>'SELECT %1$s.* %2$s FROM %1$s',
),
'SubItems' => Array('formflds'),
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Title' => 'asc'),
)
),
'Fields' => Array(
'FormId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0, 'filter_type' => 'equals'),
'Title' => Array('type' => 'string','not_null' => 1, 'default' => '','required' => 1),
- 'Description' => Array('type' => 'string', 'default' => null,),
+ 'Description' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_form.gif'),
'Fields' => Array(
'FormId' => Array( 'title'=>'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'),
'Title' => Array( 'title' => 'la_col_Title', 'filter_block' => 'grid_like_filter'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/phrases/phrases_config.php
===================================================================
--- branches/RC/core/units/phrases/phrases_config.php (revision 11759)
+++ branches/RC/core/units/phrases/phrases_config.php (revision 11760)
@@ -1,196 +1,196 @@
<?php
$config = Array (
'Prefix' => 'phrases',
'Clones' => Array (
'phrases-single' => Array (
'ForeignKey' => false,
'ParentTableKey' => false,
'ParentPrefix' => false,
)
),
'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'PhrasesEventHandler', 'file' => 'phrases_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array (
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'phrases',
'HookToSpecial' => '',
'HookToEvent' => Array('OnCreate'),
'DoPrefix' => 'phrases',
'DoSpecial' => '',
'DoEvent' => 'OnBeforePhraseCreate',
),
Array (
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'phrases',
'HookToSpecial' => '',
'HookToEvent' => Array('OnBeforeItemCreate', 'OnBeforeItemUpdate'),
'DoPrefix' => 'phrases',
'DoSpecial' => '',
'DoEvent' => 'OnSetLastUpdated',
),
),
'QueryString' => Array (
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'label',
5 => 'mode', // labels can be edited directly
),
'IDField' => 'PhraseId',
'TitleField' => 'Phrase',
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array ('phrases' => '!la_title_Adding_Phrase!'),
'edit_status_labels' => Array ('phrases' => '!la_title_Editing_Phrase!'),
),
'phrase_edit' => Array ('prefixes' => Array ('phrases'), 'format' => '#phrases_status# #phrases_titlefield#'),
// for separate phrases list
'phrases_list_st' => Array ('prefixes' => Array ('phrases.st_List'), 'format' => "!la_title_Phrases!"),
'phrase_edit_single' => Array ('prefixes' => Array ('phrases'), 'format' => '#phrases_status# #phrases_titlefield#'),
),
'FilterMenu' => Array (
'Groups' => Array (
Array ('mode' => 'AND', 'filters' => Array ('show_front', 'show_admin', 'show_both'), 'type' => WHERE_FILTER),
Array ('mode' => 'AND', 'filters' => Array ('translated', 'not_translated'), 'type' => WHERE_FILTER),
),
'Filters' => Array (
'show_front' => Array ('label' =>'la_PhraseType_Front', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 0'),
'show_admin' => Array ('label' => 'la_PhraseType_Admin', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 1'),
'show_both' => Array ('label' => 'la_PhraseType_Both', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 2'),
's1' => Array (),
'translated' => Array ('label' => 'la_PhraseTranslated', 'on_sql' => '', 'off_sql' => '%1$s.Translation = pri.Translation'),
'not_translated' => Array ('label' => 'la_PhraseNotTranslated', 'on_sql' => '', 'off_sql' => '%1$s.Translation != pri.Translation'),
)
),
'Sections' => Array (
// "Phrases"
'in-portal:phrases' => Array (
'parent' => 'in-portal:site',
'icon' => 'core:settings_general',
'label' => 'la_title_Phrases',
'url' => Array ('t' => 'languages/phrase_list', 'pass' => 'm'),
'permissions' => Array ('view', 'add', 'edit', 'delete'),
// 'perm_prefix' => 'lang',
'priority' => 5,
// 'show_mode' => smSUPER_ADMIN,
'type' => stTREE,
),
),
'TableName' => TABLE_PREFIX . 'Phrase',
'CalculatedFields' => Array (
'' => Array (
'PrimaryTranslation' => 'pri.Translation',
),
'st' => Array (
'PackName' => 'lang.PackName',
),
),
'ListSQLs' => Array(
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN ' . TABLE_PREFIX . 'Phrase pri ON (%1$s.Phrase = pri.Phrase) AND (pri.LanguageId = 1)',
'st' => 'SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN ' . TABLE_PREFIX . 'Language lang ON (%1$s.LanguageId = lang.LanguageId)',
),
'ListSortings' => Array (
'' => Array (
'Sorting' => Array ('Phrase' => 'asc'),
)
),
'ForeignKey' => 'LanguageId',
'ParentTableKey' => 'LanguageId',
'ParentPrefix' => 'lang',
'AutoDelete' => true,
'AutoClone' => true,
'Fields' => Array (
'Phrase' => Array (
'type' => 'string',
'required' => 1, 'unique' => Array ('LanguageId'),
'not_null' => 1, 'default' => ''
),
- 'Translation' => Array ('type' => 'string', 'required'=>1,'not_null' => '1', 'default' => ''),
+ 'Translation' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'required' => 1, 'not_null' => 1, 'using_fck' => 1, 'default' => ''),
'PhraseType' => Array ('type' => 'int', 'required'=>1,'formatter' => 'kOptionsFormatter', 'options'=>Array (0=>'la_PhraseType_Front',1=>'la_PhraseType_Admin',2=>'la_PhraseType_Both'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
'PhraseId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'LanguageId' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY LocalName', 'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName',
'not_null' => 1, 'default' => 0
),
'LastChanged' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1, 'default' => 0),
'LastChangeIP' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'Module' => Array (
'type' => 'string',
'formatter' => 'kOptionsFormatter', 'options'=>Array ('' => ''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1 ORDER BY LoadOrder', 'option_key_field' => 'Name', 'option_title_field' => 'Name',
'not_null' => 1, 'default' => 'In-Portal'
),
),
'VirtualFields' => Array (
'PrimaryTranslation' => Array (),
'LangFile' => Array (),
'ImportOverwrite' => Array (),
'DoNotEncode' => Array (),
'PackName' => Array (
'type' => 'string',
'formatter' => 'kOptionsFormatter',
'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName', 'option_title_field' => 'PackName', 'option_key_field' => 'PackName',
),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array ('default' => 'icon16_language_var.gif'),
'Fields' => Array (
'Phrase' => Array ('title' => 'la_col_Label', 'data_block' => 'grid_checkbox_td'),
'Translation' => Array ('title' => 'la_col_Translation'),
'PrimaryTranslation' => Array ('title' => 'la_col_PrimaryValue'),
'PhraseType' => Array ('title' => 'la_col_PhraseType', 'filter_block' => 'grid_options_filter'),
'LastChanged' => Array ('title' => 'la_col_LastChanged', 'filter_block' => 'grid_date_range_filter'),
'Module' => Array ('title' => 'la_col_Module', 'filter_block' => 'grid_options_filter'),
),
),
'Phrases' => Array (
'Icons' => Array ('default' => 'icon16_language_var.gif'),
'Fields' => Array (
'PhraseId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 50),
'Phrase' => Array ('title' => 'la_col_Name', 'filter_block' => 'grid_like_filter', 'width' => 150),
'Translation' => Array ('title' => 'la_col_Translation', 'filter_block' => 'grid_like_filter', 'width' => 150),
'PackName' => Array ('title' => 'la_col_Language', 'filter_block' => 'grid_options_filter', 'width' => 100),
'PhraseType' => Array ('title' => 'la_col_Location', 'filter_block' => 'grid_options_filter', 'width' => 80),
'LastChanged' => Array ('title' => 'la_col_LastChanged', 'filter_block' => 'grid_date_range_filter'),
'Module' => Array ('title' => 'la_col_Module', 'filter_block' => 'grid_options_filter'),
),
),
),
);
\ No newline at end of file
Index: branches/RC/core/units/stylesheets/stylesheets_config.php
===================================================================
--- branches/RC/core/units/stylesheets/stylesheets_config.php (revision 11759)
+++ branches/RC/core/units/stylesheets/stylesheets_config.php (revision 11760)
@@ -1,136 +1,136 @@
<?php
$config = Array(
'Prefix' => 'css',
'ItemClass' => Array('class'=>'StylesheetsItem','file'=>'stylesheets_item.php','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'StylesheetsEventHandler','file'=>'stylesheets_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'css',
'HookToSpecial' => '',
'HookToEvent' => Array('OnSave'),
'DoPrefix' => '',
'DoSpecial' => '',
'DoEvent' => 'OnCompileStylesheet',
),
),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'mode',
),
'IDField' => 'StylesheetId',
'StatusField' => Array('Enabled'),
'TitleField' => 'Name',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('css'=>'!la_title_Adding_Stylesheet!'),
'edit_status_labels' => Array('css'=>'!la_title_Editing_Stylesheet!'),
'new_titlefield' => Array('css'=>'!la_title_New_Stylesheet!'),
),
'styles_list' => Array('prefixes' => Array('css_List'), 'format' => "!la_title_Stylesheets!"),
'stylesheets_edit' => Array('prefixes' => Array('css'), 'format' => "#css_status# '#css_titlefield#' - !la_title_General!"),
'base_styles' => Array('prefixes' => Array('css','selectors.base_List'), 'format' => "#css_status# '#css_titlefield#' - !la_title_BaseStyles!"),
'block_styles' => Array('prefixes' => Array('css','selectors.block_List'), 'format' => "#css_status# '#css_titlefield#' - !la_title_BlockStyles!"),
'base_style_edit' => Array( 'prefixes' => Array('css','selectors'),
'new_status_labels' => Array('selectors'=>'!la_title_Adding_BaseStyle!'),
'edit_status_labels' => Array('selectors'=>'!la_title_Editing_BaseStyle!'),
'new_titlefield' => Array('selectors'=>'!la_title_New_BaseStyle!'),
'format' => "#css_status# '#css_titlefield#' - #selectors_status# '#selectors_titlefield#'"),
'block_style_edit' => Array( 'prefixes' => Array('css','selectors'),
'new_status_labels' => Array('selectors'=>'!la_title_Adding_BlockStyle!'),
'edit_status_labels' => Array('selectors'=>'!la_title_Editing_BlockStyle!'),
'new_titlefield' => Array('selectors'=>'!la_title_New_BlockStyle!'),
'format' => "#css_status# '#css_titlefield#' - #selectors_status# '#selectors_titlefield#'"),
'style_edit' => Array('prefixes' => Array('selectors'), 'format' => "!la_title_EditingStyle! '#selectors_titlefield#'"),
),
'EditTabPresets' => Array (
'Default' => Array (
'general' => Array ('title' => 'la_tab_General', 't' => 'stylesheets/stylesheets_edit', 'priority' => 1),
'block_styles' => Array ('title' => 'la_tab_BlockStyles', 't' => 'stylesheets/stylesheets_edit_block', 'priority' => 2),
'base_styles' => Array ('title' => 'la_tab_BaseStyles', 't' => 'stylesheets/stylesheets_edit_base', 'priority' => 3),
),
),
'PermSection' => Array('main' => 'in-portal:configure_styles'),
/*'Sections' => Array (
'in-portal:configure_styles' => Array (
'parent' => 'in-portal:website_setting_folder',
'icon' => 'style',
'label' => 'la_tab_Stylesheets',
'url' => Array('t' => 'stylesheets/stylesheets_list', 'pass' => 'm'),
'permissions' => Array('view', 'add', 'edit', 'delete'),
'priority' => 10,
'type' => stTREE,
),
),*/
'TableName' => TABLE_PREFIX.'Stylesheets',
'SubItems' => Array('selectorsbase', 'selectorsblock'),
'FilterMenu' => Array(
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array(0,1), 'type' => WHERE_FILTER),
),
'Filters' => Array(
0 => Array('label' =>'la_Enabled', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 1' ),
1 => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 0' ),
)
),
'AutoDelete' => true,
'AutoClone' => true,
'ListSQLs' => Array( ''=>'SELECT * FROM %s',
), // key - special, value - list select sql
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Name' => 'asc'),
)
),
'Fields' => Array(
'StylesheetId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Name' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1),
- 'Description' => Array('type' => 'string','not_null' => '1','default' => ''),
- 'AdvancedCSS' => Array('type' => 'string','not_null' => '1','default' => ''),
+ 'Description' => Array('type' => 'string', 'formatter' => 'kFormatter', 'not_null' => 1, 'using_fck' => 1, 'default' => ''),
+ 'AdvancedCSS' => Array('type' => 'string', 'formatter' => 'kFormatter', 'not_null' => 1, 'using_fck' => 1, 'default' => ''),
'LastCompiled' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1, 'default' => 0),
'Enabled' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'options'=>Array(0 => 'la_Disabled', 1 => 'la_Enabled'), 'use_phrases' => 1, 'not_null' => '1','default' => 0),
),
'VirtualFields' => Array(),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif',0=>'icon16_style_disabled.gif',1=>'icon16_style.gif'),
'Fields' => Array(
'Name' => Array( 'title'=>'la_col_Name', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_like_filter'),
'Description' => Array( 'title'=>'la_col_Description', 'first_chars' => 100, 'filter_block' => 'grid_like_filter'),
'Enabled' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'),
'LastCompiled' => Array('title' => 'la_col_LastCompiled', 'filter_block' => 'grid_date_range_filter'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/units/general/helpers/category_helper.php
===================================================================
--- branches/RC/core/units/general/helpers/category_helper.php (revision 11759)
+++ branches/RC/core/units/general/helpers/category_helper.php (revision 11760)
@@ -1,429 +1,462 @@
<?php
class CategoryHelper extends kHelper {
/**
* Structure tree for ParentId field in category or category items
*
* @var Array
*/
var $_structureTree = null;
/**
* Prints category path using given blocks. Also supports used defined path elements at the end.
*
* @param Array $params
* @return string
*/
function NavigationBar($params)
{
$main_category_id = isset($params['cat_id']) ? $params['cat_id'] : $this->Application->GetVar('m_cat_id');
$home_element = $this->getHomeCategoryPath($params, $main_category_id);
if (!getArrayValue($params, 'titles') && !getArrayValue($params, 'templates')) {
// no static templates given, show only category path
return $home_element . $this->getCategoryPath($main_category_id, $params);
}
$navigation_parts = $this->getNavigationParts($params['titles'], $params['templates']);
$ret = '';
$block_params = Array (); //$params; // sort of TagProcessor:prepareTagParams
$block_params['no_editing'] = 1;
$block_params['category'] = 0;
$block_params['separator'] = $params['separator'];
$current_template = $this->Application->GetVar('t');
$show_category = getArrayValue($params, 'show_category');
foreach ($navigation_parts as $template => $title) {
$block_params['template'] = $template;
if ($title == '__item__') {
if ($show_category) {
$ret .= $this->getCategoryPath($main_category_id, $params);
$show_category = false;
}
$category_path = $this->getCategoryParentPath($main_category_id);
$module_info = $this->getCategoryModule($params, array_keys($category_path));
if (!$module_info) {
continue;
}
$module_prefix = $module_info['Var'];
$object =& $this->Application->recallObject($module_prefix);
/* @var $object kCatDBItem */
$title_field = $this->Application->getUnitOption($module_prefix, 'TitleField');
$block_params['title'] = $object->GetField($title_field);
$block_params['prefix'] = $module_prefix;
$block_params['current'] = 0;
$block_params['name'] = $this->SelectParam($params, 'module_item_render_as,render_as');
}
else {
$block_params['current'] = ($template == $current_template);
$block_params['title'] = $this->Application->Phrase($title);
$block_params['name'] = $template == $current_template ? $params['current_render_as'] : $params['render_as'];
}
$ret .= $this->Application->ParseBlock($block_params);
}
if ($show_category) {
$params['no_current'] = true;
return $home_element . ($show_category ? $this->getCategoryPath($main_category_id, $params) : '') . $ret;
}
return $home_element . $ret;
}
/**
* Get navigation parts
*
* @param Array $titles
* @param Array $templates
* @return Array
*/
function getNavigationParts($titles, $templates)
{
$titles = explode(',', $titles);
$templates = explode(',', $templates);
$ret = Array ();
foreach ($templates as $template_pos => $template) {
$ret[$template] = $titles[$template_pos];
}
return $ret;
}
/**
* Renders path to given category using given blocks.
*
* @param int $main_category_id
* @param Array $params
* @return string
*/
function getCategoryPath($main_category_id, $params)
{
$category_path = $this->getCategoryParentPath($main_category_id);
if (!$category_path) {
// in "Home" category
return '';
}
$module_info = $this->getCategoryModule($params, array_keys($category_path));
$module_category_id = $module_info['RootCat'];
$module_item_id = $this->Application->GetVar($module_info['Var'].'_id');
$ret = '';
$block_params['category'] = 1;
$block_params['no_editing'] = 1;
$block_params['separator'] = $params['separator'];
$no_current = isset($params['no_current']) && $params['no_current'];
$backup_category_id = $this->Application->GetVar('c_id');
foreach ($category_path as $category_id => $category_name) {
$block_params['cat_id'] = $category_id;
$block_params['cat_name'] = $block_params['title'] = $category_name;
if ($no_current) {
$block_params['current'] = 0;
}
else {
$block_params['current'] = ($main_category_id == $category_id) && !$module_item_id ? 1 : 0;
}
$block_params['is_module_root'] = $category_id == $module_category_id ? 1 : 0;
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
// which block to parse as current ?
if ($block_params['is_module_root']) {
$block_params['name'] = $this->SelectParam($params, 'module_root_render_as,render_as');
$block_params['module_index'] = $module_info['TemplatePath'].'index';
}
if ($block_params['current']) {
$block_params['name'] = $this->SelectParam($params, 'current_render_as,render_as');
}
$this->Application->SetVar('c_id', $category_id);
$ret .= $this->Application->ParseBlock($block_params);
}
$this->Application->SetVar('c_id', $backup_category_id);
return $ret;
}
/**
* Returns module information based on given module name or current category (relative to module root categories)
*
* @param Array $params
* @param Array $category_ids category parent path (already as array)
* @return Array
*/
function getCategoryModule($params, $category_ids)
{
if (isset($params['module'])) {
// get module by name specified
$module_info = $this->Application->findModule('Name', $params['module']);
}
elseif ($category_ids) {
// get module by category path
$module_root_categories = $this->getModuleRootCategories();
$module_category_id = array_shift(array_intersect($category_ids, $module_root_categories));
$module_info = $this->Application->findModule('RootCat', $module_category_id);
}
return $module_info;
}
/**
* Renders path to top catalog category
*
* @param Array $params
* @param int $current_category
* @return string
*/
function getHomeCategoryPath($params, $current_category)
{
$block_params['cat_id'] = $this->Application->findModule('Name', 'Core', 'RootCat'); // 0;
$block_params['no_editing'] = 1;
$block_params['current'] = $current_category == $block_params['cat_id'] ? 1 : 0;
$block_params['separator'] = $params['separator'];
$block_params['cat_name'] = $this->Application->ProcessParsedTag('m', 'RootCategoryName', $params);
$block_params['name'] = $this->SelectParam($params, 'root_cat_render_as,render_as');
return $this->Application->ParseBlock($block_params);
}
/**
* Returns root categories from all modules
*
* @return Array
*/
function getModuleRootCategories()
{
static $root_categories = null;
if (!isset($root_categories)) {
$root_categories = Array ();
foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
array_push($root_categories, $module_info['RootCat']);
}
$root_categories = array_unique($root_categories);
}
return $root_categories;
}
/**
* Returns given category's parent path as array of id=>name elements
*
* @param int $main_category_id
* @return Array
*/
function getCategoryParentPath($main_category_id)
{
static $cached_path = null;
if ($main_category_id == 0) {
// don't query path for "Home" category
return Array ();
}
if (!isset($cached_path[$main_category_id])) {
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
$navbar_field = $ml_formatter->LangFieldName('CachedNavBar');
$id_field = $this->Application->getUnitOption('c', 'IDField');
$table_name = $this->Application->getUnitOption('c', 'TableName');
$sql = 'SELECT '.$navbar_field.', ParentPath
FROM '.$table_name.'
WHERE '.$id_field.' = '.$main_category_id;
$category_data = $this->Conn->GetRow($sql);
$skip_category = $this->Application->findModule('Name', 'Core', 'RootCat');
$cached_path[$main_category_id] = Array ();
if ($category_data) {
$category_names = explode('&|&', $category_data[$navbar_field]);
$category_ids = explode('|', substr($category_data['ParentPath'], 1, -1));
foreach ($category_ids as $category_index => $category_id) {
if ($category_id == $skip_category) {
continue;
}
$cached_path[$main_category_id][$category_id] = $category_names[$category_index];
}
}
}
return $cached_path[$main_category_id];
}
/**
* Not tag, method for parameter
* selection from list in this TagProcessor
*
* @param Array $params
* @param string $possible_names
* @return string
* @access public
*/
function SelectParam($params, $possible_names)
{
if (!is_array($params)) return;
if (!is_array($possible_names))
$possible_names = explode(',', $possible_names);
foreach ($possible_names as $name)
{
if( isset($params[$name]) ) return $params[$name];
}
return false;
}
/**
* Converts multi-dimensional category structure in one-dimensional option array (category_id=>category_name)
*
* @param Array $data
* @param int $parent_category_id
* @param int_type $language_id
* @param int $theme_id
* @param int $level
* @return Array
*/
function _printChildren(&$data, $parent_category_id, $language_id, $theme_id, $level = 0)
{
if ($data['ThemeId'] != $theme_id && $data['ThemeId'] != 0) {
// don't show system templates from different themes
return Array ();
}
$ret = Array($parent_category_id => str_repeat('-', $level).' '.$data['l'.$language_id.'_Name']);
if ($data['children']) {
$level++;
foreach ($data['children'] as $category_id => $category_data) {
$ret = array_merge_recursive2($ret, $this->_printChildren($data['children'][$category_id], $category_id, $language_id, $theme_id, $level));
}
}
return $ret;
}
/**
* Returns information about children under parent path (recursive)
*
* @param int $parent_category_id
* @param int $language_count
* @return Array
*/
function _getChildren($parent_category_id, $language_count)
{
$id_field = $this->Application->getUnitOption('c', 'IDField');
// get category children + parent category
$sql = 'SELECT *
FROM '.$this->Application->getUnitOption('c', 'TableName').'
WHERE ParentId = '.$parent_category_id.' OR '.$id_field.' = '.$parent_category_id.'
ORDER BY Priority DESC';
$categories = $this->Conn->Query($sql, $id_field);
$parent_data = $categories[$parent_category_id];
unset($categories[$parent_category_id]);
// no children for this category
$data = Array ('id' => $parent_data[$id_field], 'children' => false, 'ThemeId' => $parent_data['ThemeId']);
for ($i = 1; $i <= $language_count; $i++) {
$data['l'.$i.'_Name'] = $parent_data['l'.$i.'_Name'];
}
if (!$categories) {
// no children
return $data;
}
// category has children
foreach ($categories as $category_id => $category_data) {
$data['children'][$category_id] = $this->_getChildren($category_id, $language_count);
}
return $data;
}
/**
* Generates OR retrieves from cache structure tree
*
* @return Array
*/
function &_getStructureTree()
{
// get cached version of structure tree
$sql = 'SELECT Data
FROM ' . TABLE_PREFIX . 'Cache
WHERE VarName = "StructureTree"';
$data = $this->Conn->GetOne($sql);
if ($data) {
$data = unserialize($data);
return $data;
}
// generate structure tree from scratch
$ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$language_count = $ml_helper->getLanguageCount();
$root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
$data = $this->_getChildren($root_category, $language_count);
$fields_hash = Array (
'VarName' => 'StructureTree',
'Data' => serialize($data),
'Cached' => adodb_mktime(),
);
$this->Conn->doInsert($fields_hash, TABLE_PREFIX.'Cache', 'REPLACE');
return $data;
}
/**
* Returns category structure as field option list
*
* @return Array
*/
function getStructureTreeAsOptions()
{
if (defined('IS_INSTALL') && IS_INSTALL) {
// no need to create category structure during install, because it's not used there
return Array ();
}
if (isset($this->_structureTree)) {
return $this->_structureTree;
}
$themes_helper =& $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
$data = $this->_getStructureTree();
$theme_id = (int)$themes_helper->getCurrentThemeId();
$root_category = $this->Application->findModule('Name', 'Core', 'RootCat');
$this->_structureTree = $this->_printChildren($data, $root_category, $this->Application->GetVar('m_lang'), $theme_id);
return $this->_structureTree;
}
- }
+ /**
+ * Replace links like "@@ID@@" to actual template names in given text
+ *
+ * @param string $text
+ * @return string
+ */
+ function replacePageIds($text)
+ {
+ if (!preg_match_all('/@@(\\d+)@@/', $text, $regs)) {
+ return $text;
+ }
+
+ $page_ids = $regs[1];
-?>
\ No newline at end of file
+ $sql = 'SELECT NamedParentPath, CategoryId
+ FROM ' . TABLE_PREFIX . 'Category
+ WHERE CategoryId IN (' . implode(',', $page_ids) . ')';
+ $templates = $this->Conn->GetCol($sql, 'CategoryId');
+
+ foreach ($page_ids as $page_id) {
+ if (!array_key_exists($page_id, $templates)) {
+ // internal page was deleted, but link to it was found in given content block data
+ continue;
+ }
+
+ $url_params = Array ('m_cat_id' => $page_id, 'pass' => 'm');
+ $page_url = $this->Application->HREF(strtolower($templates[$page_id]), '', $url_params);
+ /*if ($this->Application->IsAdmin()) {
+ $page_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $page_url);
+ }*/
+ $text = preg_replace('/@@' . $page_id . '@@/', $page_url, $text);
+ }
+
+ return $text;
+ }
+ }
\ No newline at end of file
Index: branches/RC/core/units/email_messages/email_messages_config.php
===================================================================
--- branches/RC/core/units/email_messages/email_messages_config.php (revision 11759)
+++ branches/RC/core/units/email_messages/email_messages_config.php (revision 11760)
@@ -1,125 +1,125 @@
<?php
$config = Array (
'Prefix' => 'emailmessages',
'ItemClass' => Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array('class' => 'EmailMessagesEventHandler', 'file' => 'email_messages_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array('class' => 'EmailMessageTagProcessor', 'file' => 'email_message_tp.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'mode',
),
'IDField' => 'EmailMessageId',
'TitleField' => 'Subject',
'TitlePresets' => Array (
'email_messages_direct_list' => Array ('prefixes' => Array ('emailmessages.st_List'), 'format' => "!la_title_EmailMessages!"),
'email_messages_edit_direct' => Array (
'prefixes' => Array ('emailmessages'),
'new_status_labels' => Array ('emailmessages' => '!la_title_Adding_E-mail!'),
'edit_status_labels' => Array ('emailmessages' => '!la_title_Editing_E-mail!'),
'format' => '#emailmessages_status# - #emailmessages_titlefield#',
),
),
'Sections' => Array (
'in-portal:configemail' => Array(
'parent' => 'in-portal:site',
'icon' => 'core:e-mail',
'label' => 'la_tab_E-mails',
'url' => Array('t' => 'languages/email_message_list', 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 6,
'type' => stTREE,
),
),
'TableName' => TABLE_PREFIX.'EmailMessage',
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Events ON '.TABLE_PREFIX.'Events.EventId = %1$s.EventId'
),
'ItemSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Events ON '.TABLE_PREFIX.'Events.EventId = %1$s.EventId'
),
'ForeignKey' => 'LanguageId',
'ParentTableKey' => 'LanguageId',
'ParentPrefix' => 'lang',
'AutoDelete' => true,
'AutoClone' => true,
'CalculatedFields' => Array (
'' => Array (
'Description' => TABLE_PREFIX.'Events.Description',
'Module' => TABLE_PREFIX.'Events.Module',
'Type' => TABLE_PREFIX.'Events.Type',
'ReplacementTags' => TABLE_PREFIX.'Events.ReplacementTags',
),
),
'Fields' => Array (
'EmailMessageId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Template' => Array('type' => 'string', 'default' => null),
'MessageType' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('text'=>'la_Text','html'=>'la_Html'), 'use_phrases' => 1, 'not_null' => '1','default' => 'text'),
'LanguageId' => Array(
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName', 'option_key_field' => 'LanguageId', 'option_title_field' => 'PackName',
'not_null' => 1, 'default' => 0
),
'EventId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
'Subject' => Array('type' => 'string', 'default' => null),
),
'VirtualFields' => Array (
- 'Headers' => Array('type'=>'string'),
- 'Body' => Array('type'=>'string'),
+ 'Headers' => Array('type' => 'string', 'default' => ''),
+ 'Body' => Array('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => ''),
'ReplacementTags' => Array ('type' => 'string', 'default' => null),
'Description' => Array('type'=>'string', 'sql_filter_type'=>'having'),
'Module' => Array('type' => 'string','not_null' => '1','default' => ''),
'Type' => Array('formatter'=>'kOptionsFormatter', 'options' => Array (1 => 'la_Text_Admin', 0 => 'la_Text_User'), 'use_phrases' => 1, 'default' => 0, 'not_null' => 1),
// for mass mail sending
'MassSubject' => Array ('type' => 'string', 'default' => ''),
'MassAttachment' => Array ('type' => 'string', 'formatter' => 'kUploadFormatter', 'upload_dir' => ITEM_FILES_PATH, 'max_size' => 50000000, 'default' => ''),
- 'MassHtmlMessage' => Array ('type' => 'string', 'default' => 'Type your Message Here'),
- 'MassTextMessage' => Array ('type' => 'string', 'default' => 'Type your Message Here'),
+ 'MassHtmlMessage' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => 'Type your Message Here'),
+ 'MassTextMessage' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => 'Type your Message Here'),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'),
'Fields' => Array(
'Subject' => Array( 'title'=>'la_col_Subject', 'filter_block' => 'grid_like_filter'),
'Description' => Array( 'title'=>'la_col_Description', 'data_block' => 'label_grid_checkbox_td', 'filter_block' => 'grid_like_filter'),
'Type' => Array( 'title'=>'la_col_Type', 'filter_block' => 'grid_options_filter'),
),
),
'Emails' => Array(
'Icons' => Array ('default' => 'icon16_custom.gif'),
'Fields' => Array(
'EventId' => Array( 'title'=>'la_col_Id', 'filter_block' => 'grid_range_filter'),
'Subject' => Array( 'title'=>'la_col_Subject', 'filter_block' => 'grid_like_filter'),
'Description' => Array( 'title'=>'la_col_Description', 'data_block' => 'label_grid_checkbox_td', 'filter_block' => 'grid_like_filter'),
'Type' => Array( 'title'=>'la_col_Type', 'filter_block' => 'grid_options_filter'),
'LanguageId' => Array( 'title'=>'la_col_Language', 'filter_block' => 'grid_options_filter'),
),
),
),
);
?>
\ No newline at end of file
Index: branches/RC/core/admin_templates/forms/form_field_edit.tpl
===================================================================
--- branches/RC/core/admin_templates/forms/form_field_edit.tpl (revision 11759)
+++ branches/RC/core/admin_templates/forms/form_field_edit.tpl (revision 11760)
@@ -1,59 +1,59 @@
<inp2:m_include t="incs/header" />
<inp2:m_RenderElement name="combined_header" section="in-portal:forms" prefix="form" title_preset="form_field_edit"/>
<!-- 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('formflds','<inp2:formflds_SaveEvent/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('formflds','OnCancel');
}
) );
a_toolbar.Render();
</script>
</td>
</tr>
</tbody>
</table>
<inp2:m_RenderElement name="inp_edit_hidden" prefix="formflds" field="Type" db="db"/>
<inp2:m_RenderElement name="inp_edit_hidden" prefix="formflds" field="FormId"/>
<inp2:formflds_SaveWarning name="grid_save_warning"/>
<inp2:formflds_ErrorWarning name="form_error_warning"/>
<div id="scroll_container">
<table class="edit-form">
<inp2:m_RenderElement name="subsection" title="!la_section_General!"/>
<inp2:m_RenderElement name="inp_id_label" prefix="formflds" field="FormFieldId" title="!la_prompt_FieldId!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="formflds" field="FieldName" title="!la_prompt_FieldName!" size="40"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="formflds" field="FieldLabel" title="!la_prompt_FieldLabel!" size="40"/>
<inp2:m_RenderElement name="subsection" title="!la_tab_AdminUI!"/>
<!--<inp2:m_RenderElement name="inp_edit_box" prefix="formflds" field="Heading" title="!la_prompt_heading!" size="40"/>-->
<inp2:m_RenderElement name="inp_edit_box" prefix="formflds" field="Prompt" title="!la_prompt_FieldPrompt!" size="40"/>
<inp2:m_RenderElement name="inp_edit_options" prefix="formflds" field="ElementType" title="!la_prompt_InputType!"/>
<inp2:m_RenderElement name="inp_edit_options" prefix="formflds" field="Validation" title="!la_prompt_validation!"/>
- <inp2:m_RenderElement name="inp_edit_textarea" prefix="formflds" field="ValueList" title="!la_prompt_ValueList!" cols="40" rows="5"/>
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="formflds" field="ValueList" title="!la_prompt_ValueList!" allow_html="0" cols="40" rows="5"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="formflds" field="DefaultValue" title="!la_prompt_DefaultValue!" size="40"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="formflds" field="Priority" title="!la_field_Priority!" size="10"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="formflds" field="Required" title="!la_fld_Required!"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="formflds" field="DisplayInGrid" title="!la_fld_DisplayInGrid!"/>
<inp2:m_if check="m_IsDebugMode">
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="formflds" field="IsSystem" title="!la_fld_IsSystem!"/>
</inp2:m_if>
<inp2:m_RenderElement name="inp_edit_filler"/>
</table>
</div>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: branches/RC/core/admin_templates/incs/form_blocks.tpl
===================================================================
--- branches/RC/core/admin_templates/incs/form_blocks.tpl (revision 11759)
+++ branches/RC/core/admin_templates/incs/form_blocks.tpl (revision 11760)
@@ -1,1065 +1,1065 @@
<inp2:m_DefineElement name="combined_header" permission_type="view" perm_section="" perm_prefix="" perm_event="" system_permission="1" title_preset="" tab_preset="" additional_title_render_as="" additional_blue_bar_render_as="" pagination_prefix="" parent="1" grid="Default">
<inp2:m_if check="m_Param" name="perm_section" inverse="1">
<inp2:adm_SectionInfo section="$section" info="perm_section" result_to_var="perm_section"/>
</inp2:m_if>
<inp2:m_if check="m_Param" name="permission_type">
<inp2:m_RequireLogin permissions="{$perm_section}.{$permission_type}" perm_event="$perm_event" perm_prefix="$perm_prefix" system="$system_permission"/>
<inp2:m_else/>
<inp2:m_RequireLogin permissions="{$perm_section}" perm_event="$perm_event" perm_prefix="$perm_prefix" system="$system_permission"/>
</inp2:m_if>
<inp2:m_if check="m_Param" name="prefix" inverse="1"><inp2:adm_SectionInfo section="$section" info="SectionPrefix" result_to_var="prefix"/></inp2:m_if>
<inp2:m_if check="m_get" var="m_wid" inverse="1">
<inp2:m_if check="m_GetConfig" name="UseSmallHeader">
<img src="img/spacer.gif" height="8" width="1" alt=""/>
<inp2:m_else/>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<!--## <tr<inp2:m_ifnot check="m_ModuleEnabled" module="Proj-Base"> style="background: url(<inp2:adm_SectionInfo section="$section" parent="$parent" info="module_path"/>img/logo_bg.gif) no-repeat top right; height: 55px;"</inp2:m_ifnot>> ##-->
<tr>
<td valign="top" class="admintitle" align="left" style="padding-top: 10px; padding-bottom: 10px;">
<img width="46" height="46" src="<inp2:adm_SectionInfo section='$section' parent='$parent' info='module_path'/>img/icons/icon46_<inp2:adm_SectionInfo section='$section' parent='$parent' info='icon'/>.gif" align="absmiddle" title="<inp2:adm_SectionInfo section='$section' parent='$parent' info='label'/>" alt=""/>&nbsp;<inp2:adm_SectionInfo section="$section" parent="$parent" info="label"/>
</td>
<inp2:m_if check="m_Param" name="additional_title_render_as">
<inp2:m_RenderElement name="$additional_title_render_as" pass_params="1"/>
</inp2:m_if>
</tr>
</table>
</inp2:m_if>
<inp2:m_else/>
<inp2:m_if check="m_Param" name="additional_title_render_as">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<!--## <tr<inp2:m_ifnot check="m_ModuleEnabled" module="Proj-Base"> style="background: url(<inp2:adm_SectionInfo section="$section" parent="$parent" info="module_path"/>img/logo_bg.gif) no-repeat top right; height: 55px;"</inp2:m_ifnot>> ##-->
<tr>
<inp2:m_RenderElement name="$additional_title_render_as" pass_params="1"/>
</tr>
</table>
</inp2:m_if>
</inp2:m_if>
<inp2:$prefix_ModifyUnitConfig pass_params="1"/>
<inp2:m_if check="m_Param" name="tabs">
<inp2:m_include t="$tabs" pass_params="1"/>
</inp2:m_if>
<inp2:m_if check="m_Param" name="tab_preset">
<inp2:m_RenderElement name="edit_tabs" prefix="$prefix" preset_name="$tab_preset"/>
</inp2:m_if>
<table border="0" cellpadding="2" cellspacing="0" class="bordered-no-bottom" width="100%" style="height: 30px;">
<tr>
<td class="header_left_bg" nowrap="nowrap" style="vertical-align: middle;">
<inp2:adm_SectionInfo section="$section" info="label" result_to_var="default_title"/>
<inp2:adm_SectionInfo section="$section" parent="$parent" info="label" result_to_var="group_title"/>
<span class="tablenav_link" id="blue_bar">
<inp2:$prefix_SectionTitle title_preset="$title_preset" section="$section" title="$default_title" group_title="$group_title" cut_first="100" pass_params="true"/>
</span>
</td>
<td align="right" class="tablenav" style="vertical-align: middle;">
<inp2:m_if check="m_Param" name="additional_blue_bar_render_as">
<inp2:m_RenderElement name="$additional_blue_bar_render_as" pass_params="1"/>
<inp2:m_else/>
<inp2:m_if check="m_Param" name="pagination">
<inp2:$prefix_SelectParam possible_names="pagination_prefix,prefix" result_to_var="pagination_prefix"/>
<inp2:m_RenderElement name="grid_pagination_elem" PrefixSpecial="$pagination_prefix" pass_params="1"/>
</inp2:m_if>
</inp2:m_if>
</td>
</tr>
</table>
<script type="text/javascript">
var $visible_toolbar_buttons = <inp2:m_if check="{$prefix}_VisibleToolbarButtons" title_preset="$title_preset">[<inp2:$prefix_VisibleToolbarButtons title_preset="$title_preset"/>]<inp2:m_else/>true</inp2:m_if>;
set_window_title( RemoveTranslationLink(document.getElementById('blue_bar').innerHTML, false).replace(/(<[^<]+>)/g, '').replace(/\s+/g, ' ').trim() + ' - <inp2:m_Phrase label="la_AdministrativeConsole" js_escape="1"/>');
setHelpLink('<inp2:lang.current_Field name="UserDocsUrl" js_escape="1"/>', '<inp2:m_Param name="title_preset" js_escape="1"/>');
</script>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_original_label">
<td><inp2:$prefix.original_Field field="$field" nl2br="1"/></td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="subsection" prefix="" fields="" colspan="3">
<inp2:m_if check="m_Param" name="prefix" equals_to="">
<tr class="subsectiontitle">
<td colspan="<inp2:m_param name='colspan'/>"><inp2:m_phrase label="$title"/></td>
</tr>
<inp2:m_else/>
<inp2:m_if check="{$prefix}_FieldsVisible" fields="$fields">
<tr class="subsectiontitle">
<td colspan="<inp2:m_param name='colspan'/>"><inp2:m_phrase label="$title"/></td>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<td><inp2:m_phrase name="$original_title"/></td>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_field_caption" title="" subfield="" NamePrefix="">
<inp2:m_inc param="tab_index" by="1"/>
<td class="label-cell" onmouseover="show_form_error('<inp2:m_Param name='prefix' js_escape='1'/>', '<inp2:m_Param name='field' js_escape='1'/>')" onmouseout="hide_form_error('<inp2:m_Param name='prefix' js_escape='1'/>')">
<inp2:m_if check="m_Param" name="title">
<label for="<inp2:m_param name='NamePrefix'/><inp2:{$prefix}_InputName field='$field' subfield='$subfield'/>">
<span class="<inp2:m_if check='{$prefix}_HasError' field='$field'>error-cell</inp2:m_if>" >
<inp2:m_phrase label="$title"/></span><inp2:m_if check="{$prefix}_IsRequired" field="$field"><span class="field-required">&nbsp;*</span></inp2:m_if>:
</label>
<inp2:m_else/>
&nbsp;
</inp2:m_if>
</td>
<td class="control-mid">&nbsp;</td>
<script type="text/javascript">
if (typeof(fields['<inp2:m_Param name="prefix" js_escape="1"/>']) == 'undefined') {
fields['<inp2:m_Param name="prefix" js_escape="1"/>'] = new Object();
}
fields['<inp2:m_Param name="prefix" js_escape="1"/>']['<inp2:m_Param name="field" js_escape="1"/>'] = '<inp2:m_phrase label="$title" js_escape="1"/>'
</script>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_label" is_last="" subfield="" style="" format="" db="" hint_label="" as_label="" currency="" no_special="" nl2br="0" is_last="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell" valign="top">
<span style="<inp2:m_Param name='style'/>" id="<inp2:$prefix_InputName field='$field' subfield='$subfield'/>">
<inp2:{$prefix}_Field field="$field" format="$format" as_label="$as_label" currency="$currency" nl2br="$nl2br" no_special="$no_special"/>
</span>
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><span class="small"><inp2:m_phrase label="$hint_label"/></span></inp2:m_if>
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' db='$db'/>">
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_id_label">
<inp2:m_ifnot check="Field" field="$field" equals_to="|0">
<inp2:m_RenderElement name="inp_label" pass_params="true"/>
</inp2:m_ifnot>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_error">
<script type="text/javascript">
add_form_error('<inp2:m_Param name="prefix" js_escape="1"/>', '<inp2:m_Param name="field" js_escape="1"/>', '<inp2:{$prefix}_InputName field="$field"/>', '<inp2:{$prefix}_Error field="$field" js_escape="1"/>')
</script>
<!--##<td class="error-cell"><inp2:{$prefix}_Error field="$field"/>&nbsp;</td>##-->
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_box" subfield="" class="" format="" is_last="" maxlength="" onblur="" onchange="" size="" onkeyup="" style="width: 100%">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" subfield="$subfield" title="$title" is_last="$is_last"/>
<td class="control-cell">
<input style="<inp2:m_Param name='style'/>" type="text" name="<inp2:{$prefix}_InputName field='$field' subfield='$subfield'/>" id="<inp2:{$prefix}_InputName field='$field' subfield='$subfield'/>" value="<inp2:{$prefix}_Field field='$field' format='$format' subfield='$subfield'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>" onkeyup="<inp2:m_Param name='onkeyup'/>" onchange="<inp2:m_Param name='onchange'/>">
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><span class="small"><inp2:m_phrase label="$hint_label"/></span></inp2:m_if>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_password" class="" size="" style="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title"/>
<td class="control-cell">
<input style="<inp2:m_Param name='style'/>" type="password" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" class="<inp2:m_param name='class'/>" />
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><span class="small"><inp2:m_phrase label="$hint_label"/></span></inp2:m_if>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_upload" class="" size="" thumbnail="" is_last="" style="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<inp2:m_if check="m_Param" name="thumbnail">
<inp2:m_if check="{$prefix}_FieldEquals" name="$field" value="" inverse="inverse">
<img src="<inp2:{$prefix}_Field field='$field' format='resize:{$thumbnail}'/>" alt=""/><br />
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="hidden" id="<inp2:{$prefix}_InputName field='Delete{$field}'/>" name="<inp2:{$prefix}_InputName field='Delete{$field}'/>" value="0" />
<input type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='Delete{$field}'/>" onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='Delete{$field}'/>'));">
</td>
<td>
<label for="_cb_<inp2:{$prefix}_InputName field='Delete{$field}'/>"><inp2:m_phrase name="la_btn_DeleteImage"/></label>
</td>
</tr>
</table>
</inp2:m_if>
<input type="file" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" class="<inp2:m_param name='class'/>">
<inp2:m_else/>
<input type="file" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" class="<inp2:m_param name='class'/>">
<inp2:m_if check="{$prefix}_FieldEquals" name="$field" value="" inverse="inverse">
(<inp2:{$prefix}_Field field="$field"/>)
</inp2:m_if>
</inp2:m_if>
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>[upload]" id="<inp2:{$prefix}_InputName field='$field'/>[upload]" value="<inp2:{$prefix}_Field field='$field'/>">
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_box_ml">
<inp2:m_RenderElement name="inp_edit_box" format="no_default" pass_params="true"/>
<!--##
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<td class="label-cell" valign="top">
<span class="<inp2:m_if check='{$prefix}_HasError' field='$field'>error-cell</inp2:m_if>" >
<inp2:m_phrase label="$title"/><inp2:m_if check="{$prefix}_IsRequired" field="$field"><span class="field-required">&nbsp;*</span></inp2:m_if>:</span><br>
<a href="javascript:PreSaveAndOpenTranslator('<inp2:m_param name='prefix'/>', '<inp2:m_param name='field'/>', 'popups/translator');" title="<inp2:m_Phrase label='la_Translate'/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand" border="0"></a>
</td>
<td class="control-cell">
<input style="<inp2:m_Param name='style'/>" type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' format='no_default'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>">
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
##-->
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_swf_upload" class="" is_last="" style="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<div class="uploader-main" id="<inp2:{$prefix}_InputName field='$field'/>_progress">
<div class="uploader-percent" id="<inp2:{$prefix}_InputName field='$field'/>_percent">0%</div>
<div class="uploader-left">
<div class="uploader-done" id="<inp2:{$prefix}_InputName field='$field'/>_done"></div>
</div>
<table style="border-collapse: collapse; width: 100%;">
<tr>
<td style="width: 120px">Uploading:</td><td id="<inp2:{$prefix}_InputName field='$field'/>_progress_filename"></td>
</tr>
<tr>
<td>Progress:</td><td id="<inp2:{$prefix}_InputName field='$field'/>_progress_progress"></td>
</tr>
<tr>
<td>Time elapsed:</td><td id="<inp2:{$prefix}_InputName field='$field'/>_progress_elapsed"></td>
</tr>
<tr>
<td>Time remaining:</td><td id="<inp2:{$prefix}_InputName field='$field'/>_progress_remaining"></td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><a href="javascript:UploadsManager.CancelUpload('<inp2:{$prefix}_InputName field='$field'/>')">Cancel</a></td>
</tr>
</table>
</div>
<table cellpadding="0" cellspacing="3">
<tr>
<td style="width: 63px; height: 21px;" id="<inp2:{$prefix}_InputName field='$field'/>_place_holder">
&nbsp;
</td>
<td>
<input class="button" type="button" onclick="UploadsManager.StartUpload('<inp2:{$prefix}_InputName field='$field'/>')" value="Upload"/>
</td>
</tr>
</table>
<div id="<inp2:{$prefix}_InputName field='$field'/>_queueinfo"></div>
<div id="<inp2:{$prefix}_InputName field='$field'/>_holder"></div>
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>[upload]" id="<inp2:{$prefix}_InputName field='$field'/>[upload]" value="<inp2:{$prefix}_Field field='$field'/>"><br/>
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>[tmp_ids]" id="<inp2:{$prefix}_InputName field='$field'/>[tmp_ids]" value="">
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>[tmp_names]" id="<inp2:{$prefix}_InputName field='$field'/>[tmp_names]" value="">
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>[tmp_deleted]" id="<inp2:{$prefix}_InputName field='$field'/>[tmp_deleted]" value="">
<script type="text/javascript">
UploadsManager.AddUploader('<inp2:{$prefix}_InputName field="$field"/>',
{
baseUrl: '<inp2:m_TemplatesBase />',
allowedFiletypesDescription : '<inp2:{$prefix}_FieldOption field="$field" option="files_description" js_escape="1"/>',
allowedFiletypes : '<inp2:{$prefix}_FieldOption field="$field" option="file_types"/>',
allowedFilesize : '<inp2:{$prefix}_FieldOption field="$field" option="max_size"/>',
multiple : '<inp2:{$prefix}_FieldOption field="$field" option="multiple"/>',
prefix : '<inp2:m_Param name="prefix"/>',
field : '<inp2:m_Param name="field"/>',
urls : '<inp2:{$prefix}_Field field="$field" format="file_urls" js_escape="1"/>',
names : '<inp2:{$prefix}_Field field="$field" format="file_names" js_escape="1"/>',
sizes : '<inp2:{$prefix}_Field field="$field" format="file_sizes" js_escape="1"/>',
flashsid : '<inp2:m_SID/>',
uploadURL : '<inp2:m_t pass="m,$prefix" {$prefix}_event="OnUploadFile" js_escape="1" no_amp="1" />',
deleteURL : '<inp2:m_t pass="m,$prefix" {$prefix}_event="OnDeleteFile" field="#FIELD#" file="#FILE#" js_escape="1" no_amp="1"/>',
tmp_url : '<inp2:m_t pass="m,$prefix" {$prefix}_event="OnViewFile" tmp="1" field="#FIELD#" file="#FILE#" id="#ID#" js_escape="1" no_amp="1" />',
// Button settings
buttonImageURL: 'img/upload.png', // Relative to the Flash file
buttonWidth: 63,
buttonHeight: 21,
buttonText: '<span class="theFont">Browse</span>',
buttonTextStyle: ".theFont { font-size: 12; font-family: arial, sans}",
buttonTextTopPadding: 2,
buttonTextLeftPadding: 9,
buttonPlaceholderId: '<inp2:{$prefix}_InputName field="$field"/>_place_holder'
}
)
</script>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_hidden" db="">
<input type="hidden" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' db='$db'/>">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_date" class="" is_last="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="{$field}_date" title="$title" is_last="$is_last"/>
<td class="control-cell">
<input type="text" name="<inp2:{$prefix}_InputName field='{$field}_date'/>" id="<inp2:{$prefix}_InputName field='{$field}_date'/>" value="<inp2:{$prefix}_Field field='{$field}_date' format='_regional_InputDateFormat'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:{$prefix}_Format field='{$field}_date' input_format='1' edit_size='edit_size'/>" class="<inp2:m_param name='class'/>" datepickerIcon="<inp2:m_ProjectBase/>core/admin_templates/img/calendar_icon.gif">&nbsp;
<img src="img/calendar_icon.gif" id="cal_img_<inp2:{$prefix}_InputName field='{$field}'/>"
style="cursor: pointer; margin-right: 5px"
title="Date selector"
/>
<span class="small">(<inp2:{$prefix}_Format field="{$field}_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
Calendar.setup({
inputField : "<inp2:{$prefix}_InputName field='{$field}_date'/>",
ifFormat : Calendar.phpDateFormat("<inp2:{$prefix}_Format field='{$field}_date' input_format='1'/>"),
button : "cal_img_<inp2:{$prefix}_InputName field='{$field}'/>",
align : "br",
singleClick : true,
showsTime : true,
weekNumbers : false,
firstDay : <inp2:m_GetConfig var="FirstDayOfWeek"/>,
onUpdate : function(cal) {
runOnChange('<inp2:$prefix_InputName field='{$field}_date'/>');
}
});
</script>
<input type="hidden" name="<inp2:{$prefix}_InputName field='{$field}_time'/>" id="<inp2:{$prefix}_InputName field='{$field}_time' input_format='1'/>" value="">
</td>
<inp2:m_RenderElement name="inp_edit_error" field="{$field}_date" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_time" class="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="{$field}_time" title="$title" is_last="$is_last"/>
<td class="control-cell">
<input type="text" name="<inp2:{$prefix}_InputName field='{$field}_time'/>" id="<inp2:{$prefix}_InputName field='{$field}_time'/>" value="<inp2:{$prefix}_Field field='{$field}_time' format='_regional_InputTimeFormat'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:{$prefix}_Format field='{$field}_time' input_format='1' edit_size='edit_size'/>" class="<inp2:m_param name='class'/>">&nbsp;
<span class="small">(<inp2:{$prefix}_Format field="{$field}_time" input_format="1" human="true"/>)</span>
<input type="hidden" name="<inp2:{$prefix}_InputName field='{$field}_date'/>" id="<inp2:{$prefix}_InputName field='{$field}_date' input_format='1'/>" value="">
</td>
<inp2:m_RenderElement name="inp_edit_error" field="{$field}_time" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_date_time" class="" is_last="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<!-- <input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' db='db'/>"> -->
<input type="text" name="<inp2:{$prefix}_InputName field='{$field}_date'/>" id="<inp2:{$prefix}_InputName field='{$field}_date'/>" value="<inp2:{$prefix}_Field field='{$field}_date' format='_regional_InputDateFormat'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:{$prefix}_Format field='{$field}_date' input_format='1' edit_size='edit_size'/>" class="<inp2:m_param name='class'/>" datepickerIcon="<inp2:m_ProjectBase/>core/admin_templates/img/calendar_icon.gif">
<img src="img/calendar_icon.gif" id="cal_img_<inp2:{$prefix}_InputName field="{$field}"/>"
style="cursor: pointer; margin-right: 5px"
title="Date selector"
/>
<span class="small">(<inp2:{$prefix}_Format field="{$field}_date" input_format="1" human="true"/>)</span>
<input type="hidden" id="full_date_<inp2:{$prefix}_InputName field='{$field}'/>" value="<inp2:{$prefix}_Field field='{$field}' format=''/>" />
<script type="text/javascript">
Calendar.setup({
inputField : "full_date_<inp2:{$prefix}_InputName field='{$field}'/>",
ifFormat : Calendar.phpDateFormat("<inp2:{$prefix}_Format field='{$field}' input_format='1'/>"),
button : "cal_img_<inp2:{$prefix}_InputName field='{$field}'/>",
align : "br",
singleClick : true,
showsTime : true,
weekNumbers : false,
firstDay : <inp2:m_GetConfig var="FirstDayOfWeek"/>,
onUpdate : function(cal) {
document.getElementById('<inp2:{$prefix}_InputName field="{$field}_date"/>').value = cal.date.print( Calendar.phpDateFormat("<inp2:{$prefix}_Format field="{$field}_date" input_format="1"/>") );
document.getElementById('<inp2:{$prefix}_InputName field="{$field}_time"/>').value = cal.date.print( Calendar.phpDateFormat("<inp2:{$prefix}_Format field="{$field}_time" input_format="1"/>") );
}
});
</script>
&nbsp;<input type="text" name="<inp2:{$prefix}_InputName field='{$field}_time'/>" id="<inp2:{$prefix}_InputName field='{$field}_time'/>" value="<inp2:{$prefix}_Field field='{$field}_time' format='_regional_InputTimeFormat'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:{$prefix}_Format field='{$field}_time' input_format='1' edit_size='edit_size'/>" class="<inp2:m_param name='class'/>"><span class="small"> (<inp2:{$prefix}_Format field="{$field}_time" input_format="1" human="true"/>)</span>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_textarea" class="" format="" edit_template="popups/editor" allow_html="allow_html" style="text-align: left; width: 100%; height: 100px;" control_options="false">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>" style="height: auto">
<td class="label-cell" onmouseover="show_form_error('<inp2:m_Param name='prefix' js_escape='1'/>', '<inp2:m_Param name='field' js_escape='1'/>')" onmouseout="hide_form_error('<inp2:m_Param name='prefix' js_escape='1'/>')" valign="top">
<span class="<inp2:m_if check='{$prefix}_HasError' field='$field'>error-cell</inp2:m_if>" >
<inp2:m_phrase label="$title"/><inp2:m_if check="{$prefix}_IsRequired" field="$field"><span class="field-required">&nbsp;*</span></inp2:m_if>:</span><br>
<inp2:m_if check="m_ParamEquals" name="allow_html" value="allow_html">
<inp2:{$prefix}_InputName field="$field" result_to_var="input_name"/>
- <a href="<inp2:m_Link template='$edit_template' TargetField='$input_name' pass_through='TargetField' pass='m,$prefix'/>" onclick="openwin(this.href, 'html_edit', 800, 575); return false;">
+ <a href="<inp2:m_Link template='$edit_template' TargetField='$input_name' pass_through='TargetField' pass='m,$prefix'/>" onclick="openSelector('<inp2:m_Param name='prefix' js_escape='1'/>', this.href, '', '800x575'); return false;">
<img src="img/icons/icon24_link_editor.gif" style="cursor: hand;" border="0">
</a>
<!--## <a href="javascript:OpenEditor('&section=in-link:editlink_general','kernel_form','<inp2:{$prefix}_InputName field="$field"/>');"><img src="img/icons/icon24_link_editor.gif" style="cursor:hand" border="0"></a> ##-->
</inp2:m_if>
</td>
<td class="control-mid">&nbsp;</td>
<script type="text/javascript">
if (typeof(fields['<inp2:m_Param name="prefix" js_escape="1"/>']) == 'undefined') {
fields['<inp2:m_Param name="prefix" js_escape="1"/>'] = new Object();
}
fields['<inp2:m_Param name="prefix" js_escape="1"/>']['<inp2:m_Param name="field" js_escape="1"/>'] = '<inp2:m_phrase label="$title" js_escape="1"/>'
</script>
<td class="control-cell">
- <textarea style="<inp2:m_Param name='style'/>" tabindex="<inp2:m_get param='tab_index'/>" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" ><inp2:{$prefix}_Field field="$field" format="$format"/></textarea>
+ <textarea style="<inp2:m_Param name='style'/>" tabindex="<inp2:m_get param='tab_index'/>" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" ><inp2:{$prefix}_Field field="$field" format="fck_ready;{$format}"/></textarea>
<script type="text/javascript">
Form.addControl('<inp2:{$prefix}_InputName field="$field"/>', <inp2:m_param name="control_options"/>);
</script>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_fck" class="" is_last="" maxlength="" bgcolor="" onblur="" size="" onkeyup="" style="" control_options="false">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='table_color1' even='table_color2'/>">
<td class="control-cell" colspan="3" onmouseover="show_form_error('<inp2:m_Param name='prefix' js_escape='1'/>', '<inp2:m_Param name='field' js_escape='1'/>')" onmouseout="hide_form_error('<inp2:m_Param name='prefix' js_escape='1'/>')">
<inp2:FCKEditor field="$field" width="100%" bgcolor="$bgcolor" height="200" late_load="1"/>
<script type="text/javascript">
if (typeof(fields['<inp2:m_Param name="prefix" js_escape="1"/>']) == 'undefined') {
fields['<inp2:m_Param name="prefix" js_escape="1"/>'] = new Object();
}
fields['<inp2:m_Param name="prefix" js_escape="1"/>']['<inp2:m_Param name="field" js_escape="1"/>'] = '<inp2:m_phrase label="$title" js_escape="1"/>'
Form.addControl('<inp2:$prefix_InputName field="$field"/>___Frame', <inp2:m_param name="control_options"/>);
</script>
</td>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_codepress" is_last="" style="width: 100%;" language="html" control_options="false">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='table_color1' even='table_color2'/>">
<td class="control-cell" colspan="3" onmouseover="show_form_error('<inp2:m_Param name='prefix' js_escape='1'/>', '<inp2:m_Param name='field' js_escape='1'/>')" onmouseout="hide_form_error('<inp2:m_Param name='prefix' js_escape='1'/>')">
<inp2:m_ifnot check="m_Get" name="codepress_included">
<script type="text/javascript" src="<inp2:m_TemplatesBase/>/themes/codepress/codepress.js"></script>
<script type="text/javascript">
CodePress.path = '<inp2:m_TemplatesBase/>/themes/codepress/'; // set path here, because script tags are not found in table cells
</script>
<inp2:m_Set codepress_included="1"/>
</inp2:m_ifnot>
<textarea id="<inp2:$prefix_InputName field='$field'/>" name="<inp2:$prefix_InputName field='$field'/>" class="codepress <inp2:m_Param name='language'/>" style="<inp2:m_Param name='style'/>"><inp2:$prefix_Field field="$field"/></textarea>
<script type="text/javascript">
Application.setHook(
new Array ('<inp2:m_Param name="prefix" js_escape="1"/>:OnPreSaveAndGoToTab', '<inp2:m_Param name="prefix" js_escape="1"/>:OnPreSaveAndGo', '<inp2:m_Param name="prefix" js_escape="1"/>:OnSave', '<inp2:m_Param name="prefix" js_escape="1"/>:OnCreate', '<inp2:m_Param name="prefix" js_escape="1"/>:OnUpdate'),
function($event) {
<inp2:m_Param name="field"/>.toggleEditor(); // enable textarea back to save data
$event.status = true;
}
);
if (typeof(fields['<inp2:m_Param name="prefix" js_escape="1"/>']) == 'undefined') {
fields['<inp2:m_Param name="prefix" js_escape="1"/>'] = new Object();
}
fields['<inp2:m_Param name="prefix" js_escape="1"/>']['<inp2:m_Param name="field" js_escape="1"/>'] = '<inp2:m_phrase label="$title" js_escape="1"/>'
Form.addControl('<inp2:$prefix_InputName field="$field"/>', <inp2:m_param name="control_options"/>);
</script>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_textarea_ml">
<inp2:m_RenderElement name="inp_edit_textarea" format="no_default" pass_params="true"/>
<!--##
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<td class="label-cell" valign="top">
<span class="<inp2:m_if check='{$prefix}_HasError' field='$field'>error-cell</inp2:m_if>" >
<inp2:m_phrase label="$title"/><inp2:m_if check="{$prefix}_IsRequired" field="$field"><span class="field-required">&nbsp;*</span></inp2:m_if>:</span><br>
<a href="javascript:OpenEditor('&section=in-link:editlink_general','kernel_form','<inp2:{$prefix}_InputName field="$field"/>');"><img src="img/icons/icon24_link_editor.gif" style="cursor:hand" border="0"></a>
<a href="javascript:PreSaveAndOpenTranslator('<inp2:m_param name="prefix"/>', '<inp2:m_param name="field"/>', 'popups/translator', 1);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand" border="0"></a>
</td>
<td class="control-mid">&nbsp;</td>
<td>
- <textarea tabindex="<inp2:m_get param='tab_index'/>" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" cols="<inp2:m_param name='cols'/>" rows="<inp2:m_param name='rows'/>" class="<inp2:m_param name='class'/>"><inp2:{$prefix}_Field field="$field"/></textarea>
+ <textarea tabindex="<inp2:m_get param='tab_index'/>" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" cols="<inp2:m_param name='cols'/>" rows="<inp2:m_param name='rows'/>" class="<inp2:m_param name='class'/>"><inp2:{$prefix}_Field field="$field" format="fck_ready,{$format}"/></textarea>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
##-->
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_user" class="" size="" is_last="" old_style="0" onkeyup="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<input type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" class="<inp2:m_param name='class'/>" onkeyup="<inp2:m_Param name='onkeyup'/>">
<inp2:m_if check="m_ParamEquals" name="old_style" value="1">
<a href="#" onclick="return OpenUserSelector('','kernel_form','<inp2:{$prefix}_InputName field="$field"/>');">
<inp2:m_else/>
<a href="javascript:openSelector('<inp2:m_param name='prefix'/>', '<inp2:m_t t='user_selector' pass='all,$prefix' escape='1'/>', '<inp2:m_param name='field'/>');">
</inp2:m_if>
<img src="img/icons/icon24_link_user.gif" style="cursor:hand;" border="0">
</a>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_category" class="" size="" is_last="" old_style="0" onkeyup="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<table cellpadding="0" cellspacing="0">
<tr>
<td id="<inp2:{$prefix}_InputName field='$field'/>_path">
<inp2:m_DefineElement name="category_caption">
<inp2:m_ifnot check="c_HomeCategory" equals_to="$cat_id">
<inp2:m_param name="separator"/>
</inp2:m_ifnot>
<inp2:m_param name="cat_name"/>
</inp2:m_DefineElement>
<inp2:$prefix_FieldCategoryPath field="$field" separator=" &gt; " render_as="category_caption"/>
<inp2:m_RenderElement name="inp_edit_hidden" pass_params="1"/>
</td>
<td valign="middle">
<img src="img/spacer.gif" width="3" height="1" alt=""/>
<a href="javascript:openSelector('<inp2:m_param name='prefix'/>', '<inp2:adm_SelectorLink prefix='$prefix' selection_mode='single' tab_prefixes='none'/>', '<inp2:m_param name='field'/>');">
<img src="img/icons/icon24_cat.gif" width="24" height="24" border="0"/>
</a>
<a href="#" onclick="disable_category('<inp2:m_Param name='field'/>'); return false;"><inp2:m_Phrase name="la_Text_Disable"/></a>
<script type="text/javascript">
function disable_category($field) {
var $field = '<inp2:{$prefix}_InputName field="#FIELD_NAME#"/>'.replace('#FIELD_NAME#', $field);
set_hidden_field($field, '');
document.getElementById($field + '_path').style.display = 'none';
}
</script>
</td>
</tr>
</table>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_option_item">
<option value="<inp2:m_param name='key'/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_option_phrase">
<option value="<inp2:m_param name='key'/>"<inp2:m_param name="selected"/>><inp2:m_phrase label="$option"/></option>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_options" is_last="" onchange="" has_empty="0" empty_value="" style="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<select tabindex="<inp2:m_get param='tab_index'/>" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" onchange="<inp2:m_Param name='onchange'/>">
<inp2:m_if check="{$prefix}_FieldOption" field="$field" option="use_phrases">
<inp2:{$prefix}_PredefinedOptions field="$field" block="inp_option_phrase" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
<inp2:m_else/>
<inp2:{$prefix}_PredefinedOptions field="$field" block="inp_option_item" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
</inp2:m_if>
</select>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_multioptions" is_last="" has_empty="0" empty_value="" style="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<select multiple tabindex="<inp2:m_get param='tab_index'/>" id="<inp2:{$prefix}_InputName field='$field'/>_select" onchange="update_multiple_options('<inp2:{$prefix}_InputName field='$field'/>');">
<inp2:m_if check="{$prefix}_FieldOption" field="$field" option="use_phrases">
<inp2:{$prefix}_PredefinedOptions field="$field" block="inp_option_phrase" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
<inp2:m_else/>
<inp2:{$prefix}_PredefinedOptions field="$field" block="inp_option_item" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
</inp2:m_if>
</select>
<input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' db='db'/>"/>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_radio_item" onclick="" onchange="">
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="<inp2:m_param name="onclick"/>" onchange="<inp2:m_param name="onchange"/>"><label for="<inp2:{$prefix}_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_radio_phrase" onclick="" onchange="">
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:{$prefix}_InputName field="$field"/>" id="<inp2:{$prefix}_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="<inp2:m_param name="onclick"/>" onchange="<inp2:m_param name="onchange"/>"><label for="<inp2:{$prefix}_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_radio" is_last="" pass_tabindex="" onclick="" onchange="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<inp2:m_if check="{$prefix}_FieldOption" field="$field" option="use_phrases">
<inp2:{$prefix}_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="inp_radio_phrase" selected="checked" onclick="$onclick" onchange="$onchange" />
<inp2:m_else />
<inp2:{$prefix}_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="inp_radio_item" selected="checked" onclick="$onclick" onchange="$onchange" />
</inp2:m_if>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_checkbox" is_last="" field_class="" onchange="" onclick="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last" NamePrefix="_cb_"/>
<td class="control-cell">
<input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' db='db'/>">
<!--<input tabindex="<inp2:m_get param='tab_index'/>" type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" <inp2:{$prefix}_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name='field_class'/>" onclick="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='$field'/>'));" onchange="<inp2:m_param name='onchange'/>">-->
<input tabindex="<inp2:m_get param='tab_index'/>" type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" <inp2:{$prefix}_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name='field_class'/>" onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='$field'/>'));<inp2:m_param name='onchange'/>" onclick="<inp2:m_param name='onclick'/>">
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><inp2:m_phrase label="$hint_label"/></inp2:m_if>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_checkbox_item">
<input type="checkbox" <inp2:m_param name='checked'/> id="<inp2:{$prefix}_InputName field='$field'/>_<inp2:m_param name='key'/>" value="<inp2:m_param name='key'/>" onclick="update_checkbox_options(/^<inp2:{$prefix}_InputName field='$field' as_preg='1'/>_([0-9A-Za-z-]+)/, '<inp2:{$prefix}_InputName field='$field'/>');"><label for="<inp2:{$prefix}_InputName field='$field'/>_<inp2:m_param name='key'/>"><inp2:m_param name="option"/></label>&nbsp;
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_checkbox_phrase">
<input type="checkbox" <inp2:m_param name='checked'/> id="<inp2:{$prefix}_InputName field='$field'/>_<inp2:m_param name='key'/>" value="<inp2:m_param name='key'/>" onclick="update_checkbox_options(/^<inp2:{$prefix}_InputName field='$field' as_preg='1'/>_([0-9A-Za-z-]+)/, '<inp2:{$prefix}_InputName field='$field'/>');"><label for="<inp2:{$prefix}_InputName field='$field'/>_<inp2:m_param name='key'/>"><inp2:m_phrase label="$option"/></label>&nbsp;
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_checkboxes" no_empty="" pass_tabindex="" is_last="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<inp2:m_if check="{$prefix}_FieldOption" field="$field" option="use_phrases">
<inp2:{$prefix}_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" block="inp_checkbox_phrase" selected="checked"/>
<inp2:m_else/>
<inp2:{$prefix}_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" block="inp_checkbox_item" selected="checked"/>
</inp2:m_if>
<inp2:m_RenderElement prefix="$prefix" name="inp_edit_hidden" field="$field" db="db"/>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_checkbox_allow_html" is_last="" field_class="" onchange="" onclick="" title="la_enable_html" hint_label="la_Warning_Enable_HTML">
<inp2:m_RenderElement name="inp_edit_checkbox" pass_params="1"/>
<!--##
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field' db='db'/>">
<input tabindex="<inp2:m_get param='tab_index'/>" type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" <inp2:{$prefix}_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name='field_class'/>" onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='$field'/>'));<inp2:m_param name='onchange'/>" onclick="<inp2:m_param name='onclick'/>">
<inp2:m_if check="{$prefix}_HasParam" name="hint_label">
<span class="hint"><inp2:m_phrase label="$hint_label"/></span>
</inp2:m_if>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
</tr>
</inp2:m_if>
##-->
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_weight" class="" is_last="" maxlength="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<inp2:m_if check="lang.current_FieldEquals" field="UnitSystem" value="1">
<input type="text" name="<inp2:{$prefix}_InputName field='$field'/>" id="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>">
<inp2:m_phrase label="la_kg" />
</inp2:m_if>
<inp2:m_if check="lang.current_FieldEquals" field="UnitSystem" value="2">
<input type="text" name="<inp2:{$prefix}_InputName field='{$field}_a'/>" id="<inp2:{$prefix}_InputName field='{$field}_a'/>" value="<inp2:{$prefix}_Field field='{$field}_a'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>">
<inp2:m_phrase label="la_lbs" />
<input type="text" name="<inp2:{$prefix}_InputName field='{$field}_b'/>" id="<inp2:{$prefix}_InputName field='{$field}_b'/>" value="<inp2:{$prefix}_Field field='{$field}_b'/>" tabindex="<inp2:m_get param='tab_index'/>" size="<inp2:m_param name='size'/>" maxlength="<inp2:m_param name='maxlength'/>" class="<inp2:m_param name='class'/>" onblur="<inp2:m_Param name='onblur'/>">
<inp2:m_phrase label="la_oz" />
</inp2:m_if>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
<inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
<inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
</inp2:m_if>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_minput" style="" format="" allow_add="1" allow_edit="1" allow_delete="1" allow_move="1" title="">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title"/>
<td class="control-cell">
<table>
<tr>
<td colspan="2">
<input type="button" class="button" style="width: 70px;" value="<inp2:m_Phrase name='la_btn_Add'/>" id="<inp2:$prefix_InputName field='$field'/>_add_button"/>
<input type="button" class="button" style="width: 70px;" value="<inp2:m_Phrase name='la_btn_Cancel'/>" id="<inp2:$prefix_InputName field='$field'/>_cancel_button"/>
</td>
</tr>
<tr>
<td valign="top">
<select multiple tabindex="<inp2:m_get param='tab_index'/>" id="<inp2:$prefix_InputName field='$field'/>_minput" style="<inp2:m_Param name='style'/>">
</select>
</td>
<td valign="top">
<inp2:m_if check="m_Param" name="allow_edit">
<input type="button" class="button" style="width: 100px;" value="<inp2:m_Phrase name='la_btn_Edit'/>" id="<inp2:$prefix_InputName field='$field'/>_edit_button"/><br />
<img src="img/spacer.gif" height="4" width="1" alt=""/><br />
</inp2:m_if>
<inp2:m_if check="m_Param" name="allow_delete">
<input type="button" class="button" style="width: 100px;" value="<inp2:m_Phrase name='la_btn_Delete'/>" id="<inp2:$prefix_InputName field='$field'/>_delete_button"/><br />
</inp2:m_if>
<inp2:m_if check="m_Param" name="allow_move">
<br /><br />
<input type="button" class="button" style="width: 100px;" value="<inp2:m_Phrase name='la_btn_MoveUp'/>" id="<inp2:$prefix_InputName field='$field'/>_moveup_button"/><br />
<img src="img/spacer.gif" height="4" width="1" alt=""/><br />
<input type="button" class="button" style="width: 100px;" value="<inp2:m_Phrase name='la_btn_MoveDown'/>" id="<inp2:$prefix_InputName field='$field'/>_movedown_button"/><br />
</inp2:m_if>
</td>
</tr>
<inp2:m_RenderElement name="inp_edit_hidden" prefix="$prefix" field="$field" db="db"/>
<script type="text/javascript">
var <inp2:m_Param name="field"/> = new MultiInputControl('<inp2:m_Param name="field"/>', '<inp2:{$prefix}_InputName field="#FIELD_NAME#"/>', fields['<inp2:m_Param name="prefix"/>'], '<inp2:m_Param name="format"/>');
<inp2:m_Param name="field"/>.ValidateURL = '<inp2:m_Link template="dummy" pass="m,$prefix" {$prefix}_event="OnValidateMInputFields" js_escape="1"/>';
<inp2:m_if check="m_Param" name="allow_add">
<inp2:m_Param name="field"/>.SetPermission('add', true);
</inp2:m_if>
<inp2:m_if check="m_Param" name="allow_edit">
<inp2:m_Param name="field"/>.SetPermission('edit', true);
</inp2:m_if>
<inp2:m_if check="m_Param" name="allow_delete">
<inp2:m_Param name="field"/>.SetPermission('delete', true);
</inp2:m_if>
<inp2:m_if check="m_Param" name="allow_move">
<inp2:m_Param name="field"/>.SetPermission('move', true);
</inp2:m_if>
<inp2:m_Param name="field"/>.InitEvents();
<inp2:m_Param name="field"/>.SetMessage('required_error', '<inp2:m_Phrase name="la_error_required" escape="1"/>');
<inp2:m_Param name="field"/>.SetMessage('unique_error', '<inp2:m_Phrase name="la_error_unique" escape="1"/>');
<inp2:m_Param name="field"/>.SetMessage('delete_confirm', '<inp2:m_Phrase label="la_Delete_Confirm" escape="1"/>');
<inp2:m_Param name="field"/>.SetMessage('add_button', '<inp2:m_Phrase name="la_btn_Add" escape="1"/>');
<inp2:m_Param name="field"/>.SetMessage('save_button', '<inp2:m_Phrase name="la_btn_Save" escape="1"/>');
</script>
</table>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_picker" is_last="" has_empty="0" empty_value="" style="width: 225px;" size="15">
<inp2:m_if check="{$prefix}_FieldVisible" field="$field">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td class="control-cell">
<table cellpadding="0" cellspacing="0">
<tr>
<td><strong><inp2:m_Phrase label="la_SelectedItems" /></strong></td>
<td>&nbsp;</td>
<td><strong><inp2:m_Phrase label="la_AvailableItems" /></strong></td>
</tr>
<tr>
<td>
<inp2:m_DefineElement name="picker_option_block">
<option value="<inp2:Field name='$key_field' />"><inp2:Field name="$value_field" /></option>
</inp2:m_DefineElement>
<select multiple id="<inp2:$prefix_InputName name='$field' />_selected" style="<inp2:m_param name='style'/>" size="<inp2:m_param name='size'/>">
<inp2:$optprefix.selected_PrintList render_as="picker_option_block" key_field="$option_key_field" value_field="$option_value_field" per_page="-1" requery="1" link_to_prefix="$prefix" link_to_field="$field"/>
</select>
</td>
<td align="center">
<img src="img/icons/icon_left.gif" id="<inp2:$prefix_InputName name="$field" />_move_left_button"/><br />
<img src="img/icons/icon_right.gif" id="<inp2:$prefix_InputName name="$field" />_move_right_button"/>
</td>
<td>
<select multiple id="<inp2:$prefix_InputName name='$field' />_available" style="<inp2:m_param name='style'/>" size="<inp2:m_param name='size'/>">
<inp2:$optprefix.available_PrintList render_as="picker_option_block" key_field="$option_key_field" value_field="$option_value_field" requery="1" per_page="-1" link_to_prefix="$prefix" link_to_field="$field"/>
</select>
</td>
</tr>
</table>
<input type="hidden" name="<inp2:$prefix_InputName name='$field' />" id="<inp2:$prefix_InputName name='$field' />" value="<inp2:$prefix_Field field='$field' db='db'/>">
<input type="hidden" name="unselected_<inp2:$prefix_InputName name='$field' />" id="<inp2:$prefix_InputName name='$field' />_available_field" value="">
<script type="text/javascript">
<inp2:m_Param name="field"/> = new EditPickerControl('<inp2:m_Param name="field"/>', '<inp2:$prefix_InputName name="$field" />');
<inp2:m_Param name="field"/>.SetMessage('nothing_selected', '<inp2:m_Phrase label="la_SelectItemToMove" escape="1"/>');
</script>
</td>
<inp2:m_RenderElement name="inp_edit_error" pass_params="1"/>
</tr>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="inp_edit_filler" control_options="false">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>" style="height: auto">
<td class="label-cell-filler" ></td>
<td class="control-mid-filler" ></td>
<td class="control-cell-filler">
<div id="form_filler" style="width: 100%; height: 5px; background-color: inherit"></div>
<script type="text/javascript">
Form.addControl('form_filler', <inp2:m_param name="control_options"/>);
</script>
</td>
</tr>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="ajax_progress_bar">
<table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableborder">
<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
<td colspan="2">
<img src="img/spacer.gif" height="10" width="1" alt="" /><br />
<!-- progress bar paddings: begin -->
<table width="90%" cellpadding="2" cellspacing="0" border="0" align="center">
<tr>
<td class="progress-text">0%</td>
<td width="100%">
<!-- progress bar: begin -->
<table cellspacing="0" cellpadding="0" width="100%" border="0" align="center" style="background-color: #FFFFFF; border: 1px solid #E6E6E6;">
<tr>
<td colspan="3"><img src="img/spacer.gif" height="2" width="1" alt="" /></td>
</tr>
<tr>
<td width="2"><img src="img/spacer.gif" height="13" width="3" alt="" /></td>
<td align="center" width="100%">
<table cellspacing="0" cellpadding="0" width="100%" border="0" style="background: url(img/progress_left.gif) repeat-x;">
<tr>
<td id="progress_bar[done]" style="background: url(img/progress_done.gif);" align="left"></td>
<td id="progress_bar[left]" align="right"><img src="img/spacer.gif" height="9" width="1" alt="" /></td>
</tr>
</table>
</td>
<td width="1"><img src="img/spacer.gif" height="13" width="3" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img src="img/spacer.gif" height="2" width="1" alt="" /></td>
</tr>
</table>
<!-- progress bar: end -->
</td>
<td class="progress-text">100%</td>
</tr>
</table>
<!-- progress bar paddings: end -->
<img src="img/spacer.gif" height="10" width="1" alt="" /><br />
</td>
</tr>
<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
<td width="50%" align="right"><inp2:m_phrase name="la_fld_PercentsCompleted"/>:</td>
<td id="progress_display[percents_completed]">0%</td>
</tr>
<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
<td align="right"><inp2:m_phrase name="la_fld_ElapsedTime"/>:</td>
<td id="progress_display[elapsed_time]">00:00</td>
</tr>
<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
<td align="right"><inp2:m_phrase name="la_fld_EstimatedTime"/>:</td>
<td id="progress_display[Estimated_time]">00:00</td>
</tr>
<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
<td align="center" colspan="2">
<input type="button" class="button" onclick="<inp2:m_param name="cancel_action"/>" value="<inp2:m_phrase name="la_Cancel"/>" />
</td>
</tr>
</table>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="edit_navigation" toolbar="a_toolbar">
<inp2:m_if check="{$prefix}_IsTopmostPrefix">
<inp2:m_if check="{$prefix}_IsSingle">
<inp2:m_param name="toolbar"/>.HideButton('prev');
<inp2:m_param name="toolbar"/>.HideButton('next');
<inp2:m_else/>
<inp2:m_if check="{$prefix}_IsLast">
<inp2:m_param name="toolbar"/>.DisableButton('next');
</inp2:m_if>
<inp2:m_if check="{$prefix}_IsFirst">
<inp2:m_param name="toolbar"/>.DisableButton('prev');
</inp2:m_if>
</inp2:m_if>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="tabs_container" tabs_render_as="">
<table cellpadding="0" style="width: 100%;" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 20px;">
<img src="<inp2:m_TemplatesBase/>/img/spacer.gif" width="20" height="0" alt=""/><br/>
<a href="#" class="scroll-left disabled"></a>
</td>
<td height="23" align="right">
<div id="tab-measure" style="display: none; width: 100%; height: 23px;">&nbsp;</div>
<div style="overflow: hidden; height: 23px;" class="tab-viewport">
<table class="tabs" cellpadding="0" cellspacing="0" height="23">
<tr>
<inp2:m_RenderElement name="$tabs_render_as" pass_params="1"/>
</tr>
</table>
</div>
</td>
<td style="width: 20px;">
<img src="<inp2:m_TemplatesBase/>/img/spacer.gif" width="20" height="0" alt=""/><br/>
<a href="#" class="scroll-right disabled"></a>
</td>
</tr>
</table>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="edit_tabs_element">
<inp2:m_DefineElement name="edit_tab">
<inp2:m_RenderElement name="tab" title="$title" t="$template" main_prefix="$PrefixSpecial"/>
</inp2:m_DefineElement>
<inp2:{$prefix}_PrintEditTabs render_as="edit_tab" preset_name="$preset_name"/>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="edit_tabs" preset_name="Default">
<inp2:m_if check="{$prefix}_HasEditTabs" preset_name="$preset_name">
<inp2:m_RenderElement name="tabs_container" tabs_render_as="edit_tabs_element" pass_params="1"/>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="ml_selector" prefix="" field="Translated">
<inp2:m_if check="lang_IsMultiLanguage">
<td align="right" style="padding-right: 5px;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="right">
<inp2:m_phrase name="la_fld_Language"/>:
<select name="language" onchange="submit_event('<inp2:m_param name='prefix'/>', 'OnPreSaveAndChangeLanguage');">
<inp2:m_DefineElement name="lang_elem">
<option value="<inp2:Field name='LanguageId'/>" <inp2:m_if check="SelectedLanguage">selected="selected"</inp2:m_if> ><inp2:Field name="LocalName" no_special='no_special' /></option>
</inp2:m_DefineElement>
<inp2:lang_PrintList render_as="lang_elem"/>
</select>
</td>
</tr>
<tr>
<td align="right">
<inp2:m_if check="lang_IsPrimaryLanguage">
<input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="1">
<input type="checkbox" disabled id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" checked="checked"/>
<inp2:m_else/>
<input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field'/>">
<input type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" <inp2:{$prefix}_Field field="$field" checked="checked"/> onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='$field'/>'));" />
</inp2:m_if>
<label for="_cb_<inp2:{$prefix}_InputName field='$field'/>"><inp2:m_Phrase label="la_Translated"/></label>
</td>
</tr>
<tr>
<td align="right" style="vertical-align: bottom; padding: 2px 0px 5px 2px;">
<span style="color: red">*</span>&nbsp;<span class="req-note"><inp2:m_Phrase name="la_text_RequiredFields"/></span>
</td>
</tr>
</table>
</td>
<inp2:m_else/>
<td align="right" style="vertical-align: bottom; padding: 2px 5px 5px 2px;">
<span style="color: red">*</span>&nbsp;<span class="req-note"><inp2:m_Phrase name="la_text_RequiredFields"/></span>
</td>
</inp2:m_if>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="form_error_warning">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="warning-table">
<tr>
<td valign="top" class="form-warning">
<inp2:m_phrase name="la_Warning_NewFormError"/><br/>
<span id="error_msg_<inp2:m_Param name='prefix'/>" style="font-weight: bold"><br/></span>
</td>
</tr>
</table>
</inp2:m_DefineElement>
Index: branches/RC/core/admin_templates/regional/email_messages_edit.tpl
===================================================================
--- branches/RC/core/admin_templates/regional/email_messages_edit.tpl (revision 11759)
+++ branches/RC/core/admin_templates/regional/email_messages_edit.tpl (revision 11760)
@@ -1,48 +1,48 @@
<inp2:adm_SetPopupSize width="827" height="400"/>
<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="lang" section="in-portal:configure_lang" title_preset="email_messages_edit"/>
<!-- 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('emailmessages','<inp2:m_if check="emailmessages_PropertyEquals" property="ID" value="0" >OnCreate<inp2:m_else/>OnUpdate</inp2:m_if>');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('emailmessages','OnCancel');
}
) );
a_toolbar.Render();
</script>
</td>
</tr>
</tbody>
</table>
<inp2:emailmessages_SaveWarning name="grid_save_warning"/>
<inp2:emailmessages_ErrorWarning name="form_error_warning"/>
<div id="scroll_container">
<table class="edit-form">
<inp2:m_RenderElement name="subsection" title="!la_section_General!"/>
<inp2:m_RenderElement name="inp_edit_hidden" prefix="emailmessages" field="LanguageId"/>
<inp2:m_RenderElement name="inp_edit_hidden" prefix="emailmessages" field="EventId"/>
<!-- <inp2:m_RenderElement name="inp_label" prefix="emailmessages" field="Type" title="!la_fld_EventType!"/> -->
<inp2:m_RenderElement name="inp_edit_box" prefix="emailmessages" field="Subject" title="!la_fld_Subject!" size="60"/>
<inp2:m_RenderElement name="inp_edit_radio" prefix="emailmessages" field="MessageType" title="!la_fld_MessageType!"/>
- <inp2:m_RenderElement name="inp_edit_textarea" prefix="emailmessages" field="Headers" title="!la_fld_ExtraHeaders!" control_options="{min_height: 100}" rows="5" cols="60"/>
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="emailmessages" field="Headers" title="!la_fld_ExtraHeaders!" allow_html="0" control_options="{min_height: 100}" rows="5" cols="60"/>
<inp2:m_RenderElement name="subsection" title="!la_section_Message!"/>
<inp2:m_RenderElement name="inp_edit_textarea" prefix="emailmessages" field="Body" title="!la_fld_MessageBody!" control_options="{min_height: 200}" rows="20" cols="85"/>
</table>
</div>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: branches/RC/core/admin_templates/regional/languages_edit.tpl
===================================================================
--- branches/RC/core/admin_templates/regional/languages_edit.tpl (revision 11759)
+++ branches/RC/core/admin_templates/regional/languages_edit.tpl (revision 11760)
@@ -1,107 +1,107 @@
<inp2:adm_SetPopupSize width="850" height="600"/>
<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="lang" section="in-portal:configure_lang" title_preset="languages_edit_general" tab_preset="Default"/>
<!-- 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('lang','<inp2:lang_SaveEvent/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('lang','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('lang', '<inp2:lang_PrevId/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
go_to_id('lang', '<inp2:lang_NextId/>');
}
) );
a_toolbar.Render();
<inp2:m_if check="lang_IsSingle" >
a_toolbar.HideButton('prev');
a_toolbar.HideButton('next');
a_toolbar.HideButton('sep1');
<inp2:m_else/>
<inp2:m_if check="lang_IsLast" >
a_toolbar.DisableButton('next');
</inp2:m_if>
<inp2:m_if check="lang_IsFirst" >
a_toolbar.DisableButton('prev');
</inp2:m_if>
</inp2:m_if>
</script>
</td>
</tr>
</tbody>
</table>
<inp2:lang_SaveWarning name="grid_save_warning"/>
<inp2:lang_ErrorWarning name="form_error_warning"/>
<div id="scroll_container">
<table class="edit-form">
<inp2:m_RenderElement name="subsection" title="!la_section_General!"/>
<inp2:m_RenderElement name="inp_id_label" prefix="lang" field="LanguageId" title="!la_fld_LanguageId!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="PackName" title="!la_fld_PackName!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="LocalName" title="!la_fld_LocalName!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="Charset" title="!la_fld_Charset!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="IconURL" title="!la_fld_IconURL!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="DateFormat" title="!la_fld_DateFormat!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="TimeFormat" title="!la_fld_TimeFormat!"/>
<inp2:m_RenderElement name="inp_edit_options" prefix="lang" field="InputDateFormat" title="!la_fld_InputDateFormat!"/>
<inp2:m_RenderElement name="inp_edit_options" prefix="lang" field="InputTimeFormat" title="!la_fld_InputTimeFormat!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="DecimalPoint" title="!la_fld_DecimalPoint!"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="ThousandSep" title="!la_fld_ThousandSep!"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="lang" field="PrimaryLang" title="!la_fld_PrimaryLang!"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="lang" field="AdminInterfaceLang" title="la_fld_AdminInterfaceLang"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="Priority" title="la_fld_Priority"/>
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="lang" field="Enabled" title="!la_fld_Enabled!"/>
<inp2:m_RenderElement name="inp_edit_options" prefix="lang" field="UnitSystem" title="!la_fld_UnitSystem!"/>
<inp2:m_RenderElement name="inp_edit_options" prefix="lang" field="Locale" title="!la_fld_Locale!"/>
- <inp2:m_RenderElement name="inp_edit_textarea" prefix="lang" field="FilenameReplacements" title="la_fld_FilenameReplacements" control_options="{min_height: 200}" cols="50" rows="10"/>
+ <inp2:m_RenderElement name="inp_edit_textarea" prefix="lang" field="FilenameReplacements" title="la_fld_FilenameReplacements" allow_html="0" control_options="{min_height: 200}" cols="50" rows="10"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="lang" field="UserDocsUrl" title="la_fld_UserDocsUrl"/>
<inp2:m_if check="lang_IsNewMode">
<inp2:m_if check="lang_FieldVisible" field="CopyLabels">
<tr class="<inp2:m_odd_even odd='edit-form-odd' even='edit-form-even'/>">
<inp2:m_inc param="tab_index" by="1"/>
<td class="label-cell">
<inp2:m_phrase name="la_fld_CopyLabels"/>:
</td>
<td class="control-mid">&nbsp;</td>
<td class="control-cell">
<input type="hidden" id="<inp2:lang_InputName field="CopyLabels"/>" name="<inp2:lang_InputName field="CopyLabels"/>" value="<inp2:lang_Field field="CopyLabels" db="db"/>">
<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_CopyLabels" name="_cb_CopyLabels" <inp2:lang_Field field="CopyLabels" checked="checked" db="db"/> onclick="update_checkbox(this, document.getElementById('<inp2:lang_InputName field="CopyLabels"/>'))">
<inp2:m_inc param="tab_index" by="1"/>
<select tabindex="<inp2:m_get param="tab_index"/>" name="<inp2:lang_InputName field="CopyFromLanguage"/>" id="<inp2:lang_InputName field="CopyFromLanguage"/>">
<option value="0">--<inp2:m_phrase name="la_prompt_Select_Source"/></option>
<inp2:lang_PredefinedOptions field="CopyFromLanguage" block="inp_option_item" selected="selected"/>
</select>
</td>
</tr>
</inp2:m_if>
</inp2:m_if>
</table>
</div>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: branches/RC/core/editor/editor/plugins/MyPreview/fckplugin.js
===================================================================
--- branches/RC/core/editor/editor/plugins/MyPreview/fckplugin.js (revision 11759)
+++ branches/RC/core/editor/editor/plugins/MyPreview/fckplugin.js (revision 11760)
@@ -1,55 +1,55 @@
var MyPreviewCommand = function()
{
this.Name = 'MyPreview' ;
}
MyPreviewCommand.prototype.Execute = function()
{
initXmlHTTP();
xmlHTTP.onreadystatechange = OnGetAnswerPost;
-
+
// the path is NOT /admin, otherwise content will be stored in admin session !
- xmlHTTP.open("POST", FCKConfig.ProjectPath+'index.php?env=-dummy:st--OnUpdatePreviewBlock---&admin=1&ajax=yes', true);
- xmlHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xmlHTTP.send("&preview_content="+escape( FCK.GetXHTML() )+"&st_event=OnUpdatePreviewBlock");
-}
+ xmlHTTP.open('POST', FCKConfig.ProjectPath+'index.php?t=dummy&events[c]=OnUpdatePreviewBlock&ajax=yes', true);
+ xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ xmlHTTP.send('&preview_content=' + encodeURIComponent(FCK.GetXHTML()));
+}
MyPreviewCommand.prototype.GetState = function()
{
return FCK_TRISTATE_OFF;
}
-
+
function initXmlHTTP(){
//if (xmlHTTP) return;
try {
xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlHTTP = false;
}
}
if (!xmlHTTP && typeof XMLHttpRequest!='undefined') {
xmlHTTP = new XMLHttpRequest();
}
}
function OnGetAnswerPost()
{
var ret = '';
if (xmlHTTP.readyState == 4) {
if (xmlHTTP.status==200) {
ret = xmlHTTP.responseText;
var iWidth = FCKConfig.ScreenWidth * 0.8 ;
var iHeight = FCKConfig.ScreenHeight * 0.7 ;
var iLeft = ( FCKConfig.ScreenWidth - iWidth ) / 2 ;
var sOpenUrl = FCKConfig.PreviewUrl+'&_editor_preview_=1';
var oWindow = window.open(sOpenUrl, null, 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + iWidth + ',height=' + iHeight + ',left=' + iLeft ) ;
}
}
}
FCKCommands.RegisterCommand( 'MyPreview', new MyPreviewCommand());
FCKToolbarItems.RegisterItem( 'MyPreview', new FCKToolbarButton( 'MyPreview' , FCKLang.PreviewLbl, FCKLang.Preview, null, false, true, 5) ) ;
Index: branches/RC/core/install/install_toolkit.php
===================================================================
--- branches/RC/core/install/install_toolkit.php (revision 11759)
+++ branches/RC/core/install/install_toolkit.php (revision 11760)
@@ -1,711 +1,718 @@
<?php
/**
* Upgrade sqls are located using this mask
*
*/
define('UPGRADES_FILE', FULL_PATH.'/%sinstall/upgrades.%s');
/**
* Prerequisit check classes are located using this mask
*
*/
define('PREREQUISITE_FILE', FULL_PATH.'/%sinstall/prerequisites.php');
/**
* Format of version identificator in upgrade files
*
*/
define('VERSION_MARK', '# ===== v ([\d]+\.[\d]+\.[\d]+) =====');
if (!defined('GET_LICENSE_URL')) {
/**
* Url used for retrieving user licenses from Intechnic licensing server
*
*/
define('GET_LICENSE_URL', 'http://www.intechnic.com/myaccount/license.php');
}
/**
* Misc functions, that are required during installation, when
*
*/
class kInstallToolkit {
/**
* Reference to kApplication class object
*
* @var kApplication
*/
var $Application = null;
/**
* Connection to database
*
* @var kDBConnection
*/
var $Conn = null;
/**
* Path to config.php
*
* @var string
*/
var $INIFile = '';
/**
* Parsed data from config.php
*
* @var Array
*/
var $systemConfig = Array ();
/**
* Installator instance
*
* @var kInstallator
*/
var $_installator = null;
function kInstallToolkit()
{
if (class_exists('kApplication')) {
// auto-setup in case of separate module install
$this->Application =& kApplication::Instance();
$this->Conn =& $this->Application->GetADODBConnection();
}
$this->INIFile = FULL_PATH . DIRECTORY_SEPARATOR . 'config.php';
$this->systemConfig = $this->ParseConfig(true);
}
/**
* Sets installator
*
* @param kInstallator $instance
*/
function setInstallator(&$instance)
{
$this->_installator =& $instance;
}
/**
* Checks prerequisities before module install or upgrade
*
* @param string $module_path
* @param string $versions
* @param string $mode upgrade mode = {install, standalone, upgrade}
*/
function CheckPrerequisites($module_path, $versions, $mode)
{
static $prerequisit_classes = Array ();
$prerequisites_file = sprintf(PREREQUISITE_FILE, $module_path);
if (!file_exists($prerequisites_file) || !$versions) {
return Array ();
}
if (!isset($prerequisit_classes[$module_path])) {
// save class name, because 2nd time
// (in after call $prerequisite_class variable will not be present)
include_once $prerequisites_file;
$prerequisit_classes[$module_path] = $prerequisite_class;
}
$prerequisite_object = new $prerequisit_classes[$module_path]();
if (method_exists($prerequisite_object, 'setToolkit')) {
$prerequisite_object->setToolkit($this);
}
// some errors possible
return $prerequisite_object->CheckPrerequisites($versions, $mode);
}
/**
* Processes one license, received from server
*
* @param string $file_data
*/
function processLicense($file_data)
{
$modules_helper =& $this->Application->recallObject('ModulesHelper');
/* @var $modules_helper kModulesHelper */
$file_data = explode('Code==:', $file_data);
$file_data[0] = str_replace('In-Portal License File - do not edit!' . "\n", '', $file_data[0]);
$file_data = array_map('trim', $file_data);
if ($modules_helper->verifyLicense($file_data[0])) {
$this->setSystemConfig('Intechnic', 'License', $file_data[0]);
if (array_key_exists(1, $file_data)) {
$this->setSystemConfig('Intechnic', 'LicenseCode', $file_data[1]);
}
else {
$this->setSystemConfig('Intechnic', 'LicenseCode');
}
$this->SaveConfig();
}
else {
// invalid license received from licensing server
$this->_installator->errorMessage = 'Invalid License File';
}
}
/**
* Saves given configuration values to database
*
* @param Array $config
*/
function saveConfigValues($config)
{
foreach ($config as $config_var => $value) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'ConfigurationValues
SET VariableValue = ' . $this->Conn->qstr($value) . '
WHERE VariableName = ' . $this->Conn->qstr($config_var);
$this->Conn->Query($sql);
}
}
/**
* Sets module version to passed
*
* @param string $module_name
* @param string $version
*/
function SetModuleVersion($module_name, $version = false)
{
if ($version === false) {
$version = $this->GetMaxModuleVersion($module_name);
}
// get table prefix from config, because application may not be available here
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
if ($module_name == 'kernel') {
$module_name = 'in-portal';
}
$sql = 'UPDATE ' . $table_prefix . 'Modules
SET Version = "' . $version . '"
WHERE LOWER(Name) = "' . strtolower($module_name) . '"';
$this->Conn->Query($sql);
}
/**
* Sets module root category to passed
*
* @param string $module_name
* @param string $category_id
*/
function SetModuleRootCategory($module_name, $category_id = 0)
{
// get table prefix from config, because application may not be available here
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
if ($module_name == 'kernel') {
$module_name = 'in-portal';
}
$sql = 'UPDATE ' . $table_prefix . 'Modules
SET RootCat = ' . $category_id . '
WHERE LOWER(Name) = "' . strtolower($module_name) . '"';
$this->Conn->Query($sql);
}
/**
* Returns maximal version of given module by scanning it's upgrade scripts
*
* @param string $module_name
* @return string
*/
function GetMaxModuleVersion($module_name)
{
$upgrades_file = sprintf(UPGRADES_FILE, mb_strtolower($module_name).'/', 'sql');
if (!file_exists($upgrades_file)) {
// no upgrade file
return '4.0.1';
}
$sqls = file_get_contents($upgrades_file);
$versions_found = preg_match_all('/'.VERSION_MARK.'/s', $sqls, $regs);
if (!$versions_found) {
// upgrades file doesn't contain version definitions
return '4.0.1';
}
return end($regs[1]);
}
/**
* Runs SQLs from file
*
* @param string $filename
* @param mixed $replace_from
* @param mixed $replace_to
*/
function RunSQL($filename, $replace_from = null, $replace_to = null)
{
if (!file_exists(FULL_PATH.$filename)) {
return ;
}
$sqls = file_get_contents(FULL_PATH.$filename);
if (!$this->RunSQLText($sqls, $replace_from, $replace_to)) {
if (is_object($this->_installator)) {
$this->_installator->Done();
}
else {
if (isset($this->Application)) {
$this->Application->Done();
}
exit;
}
}
}
/**
* Runs SQLs from string
*
* @param string $sqls
* @param mixed $replace_from
* @param mixed $replace_to
*/
function RunSQLText(&$sqls, $replace_from = null, $replace_to = null, $start_from=0)
{
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
// add prefix to all tables
if (strlen($table_prefix) > 0) {
$replacements = Array ('INSERT INTO ', 'UPDATE ', 'ALTER TABLE ', 'DELETE FROM ', 'REPLACE INTO ');
foreach ($replacements as $replacement) {
$sqls = str_replace($replacement, $replacement . $table_prefix, $sqls);
}
}
$sqls = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ' . $table_prefix, $sqls);
$sqls = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS ' . $table_prefix, $sqls);
if (isset($replace_from) && isset($replace_to)) {
// replace something additionally, e.g. module root category
$sqls = str_replace($replace_from, $replace_to, $sqls);
}
$sqls = str_replace("\r\n", "\n", $sqls); // convert to linux line endings
$sqls = preg_replace("/#([^;]*?)\n/", '', $sqls); // remove all comments
$sqls = explode(";\n", $sqls . "\n"); // ensures that last sql won't have ";" in it
$db_collation = $this->getSystemConfig('Database', 'DBCollation');
for ($i=$start_from; $i<count($sqls); $i++) {
$sql = trim($sqls[$i]);
if (!$sql) {
continue; // usually last line
}
if (substr($sql, 0, 13) == 'CREATE TABLE ' && $db_collation) {
// it is CREATE TABLE statement -> add collation
$sql .= ' COLLATE \'' . $db_collation . '\'';
}
$this->Conn->Query($sql);
if ($this->Conn->getErrorCode() != 0) {
if (is_object($this->_installator)) {
$this->_installator->errorMessage = 'Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg().'<br /><br />Last Database Query:<br /><textarea cols="70" rows="10" readonly>'.htmlspecialchars($sql).'</textarea>';
$this->_installator->LastQueryNum = $i + 1;
}
return false;
}
}
return true;
}
/**
* Performs clean language import from given xml file
*
* @param string $lang_file
* @param bool $upgrade
* @todo Import for "core/install/english.lang" (322KB) takes 18 seconds to work on Windows
*/
function ImportLanguage($lang_file, $upgrade = false)
{
$lang_file = FULL_PATH.$lang_file.'.lang';
if (!file_exists($lang_file)) {
return ;
}
$language_import_helper =& $this->Application->recallObject('LanguageImportHelper');
/* @var $language_import_helper LanguageImportHelper */
$language_import_helper->performImport($lang_file, '|0|1|2|', '', $upgrade ? LANG_SKIP_EXISTING : LANG_OVERWRITE_EXISTING);
}
/**
* Converts module version in format X.Y.Z to signle integer
*
* @param string $version
* @return int
*/
function ConvertModuleVersion($version)
{
$parts = explode('.', $version);
$bin = '';
foreach ($parts as $part) {
$bin .= str_pad(decbin($part), 8, '0', STR_PAD_LEFT);
}
return bindec($bin);
}
/**
* Returns themes, found in system
*
* @param bool $rebuild
* @return int
*/
function getThemes($rebuild = false)
{
if ($rebuild) {
$this->rebuildThemes();
}
$id_field = $this->Application->getUnitOption('theme', 'IDField');
$table_name = $this->Application->getUnitOption('theme', 'TableName');
$sql = 'SELECT Name, ' . $id_field . '
FROM ' . $table_name;
return $this->Conn->GetCol($sql, $id_field);
}
function ParseConfig($parse_section = false)
{
if (!file_exists($this->INIFile)) {
return Array();
}
if( file_exists($this->INIFile) && !is_readable($this->INIFile) ) {
die('Could Not Open Ini File');
}
$contents = file($this->INIFile);
$retval = Array();
$section = '';
$ln = 1;
$resave = false;
foreach ($contents as $line) {
if ($ln == 1 && $line != '<'.'?'.'php die() ?'.">\n") {
$resave = true;
}
$ln++;
$line = trim($line);
$line = eregi_replace(';[.]*','',$line);
if (strlen($line) > 0) {
//echo $line . " - ";
if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
//echo 'section';
$section = mb_substr($line, 1, (mb_strlen($line) - 2));
if ($parse_section) {
$retval[$section] = array();
}
continue;
} elseif (eregi('=',$line)) {
//echo 'main element';
list ($key, $val) = explode(' = ', $line);
if (!$parse_section) {
$retval[trim($key)] = str_replace('"', '', $val);
}
else {
$retval[$section][trim($key)] = str_replace('"', '', $val);
}
}
}
}
if ($resave) {
$fp = fopen($this->INIFile, 'w');
reset($contents);
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach ($contents as $line) {
fwrite($fp,"$line");
}
fclose($fp);
}
return $retval;
}
function SaveConfig($silent = false)
{
if (!is_writable($this->INIFile) && !is_writable(dirname($this->INIFile))) {
trigger_error('Cannot write to "' . $this->INIFile . '" file.', $silent ? E_USER_NOTICE : E_USER_ERROR);
return ;
}
$fp = fopen($this->INIFile, 'w');
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach ($this->systemConfig as $section_name => $section_data) {
fwrite($fp, '['.$section_name."]\n");
foreach ($section_data as $key => $value) {
fwrite($fp, $key.' = "'.$value.'"'."\n");
}
fwrite($fp, "\n");
}
fclose($fp);
}
/**
* Sets value to system config (yet SaveConfig must be called to write it to file)
*
* @param string $section
* @param string $key
* @param string $value
*/
function setSystemConfig($section, $key, $value = null)
{
if (isset($value)) {
if (!array_key_exists($section, $this->systemConfig)) {
// create section, when missing
$this->systemConfig[$section] = Array ();
}
// create key in section
$this->systemConfig[$section][$key] = $value;
return ;
}
unset($this->systemConfig[$section][$key]);
}
/**
* Returns information from system config
*
* @return string
*/
function getSystemConfig($section, $key)
{
if (!array_key_exists($section, $this->systemConfig)) {
return false;
}
if (!array_key_exists($key, $this->systemConfig[$section])) {
return false;
}
return $this->systemConfig[$section][$key] ? $this->systemConfig[$section][$key] : false;
}
/**
* Checks if system config is present and is not empty
*
* @return bool
*/
function systemConfigFound()
{
return file_exists($this->INIFile) && $this->systemConfig;
}
/**
* Checks if given section is present in config
*
* @param string $section
* @return bool
*/
function sectionFound($section)
{
return array_key_exists($section, $this->systemConfig);
}
/**
* Returns formatted module name based on it's root folder
*
* @param string $module_folder
* @return string
*/
function getModuleName($module_folder)
{
if ($module_folder == 'kernel') {
$module_folder = 'in-portal';
}
return implode('-', array_map('ucfirst', explode('-', $module_folder)));
}
/**
* Creates module root category in "Home" category using given data and returns it
*
* @param string $name
* @param string $description
* @param string $category_template
* @param string $status
* @return kDBItem
*/
function &createModuleCategory($name, $description, $category_template = null, $status = 1)
{
static $fields = null;
if (!isset($fields)) {
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
$fields['name'] = $ml_formatter->LangFieldName('Name');
$fields['description'] = $ml_formatter->LangFieldName('Description');
}
$category =& $this->Application->recallObject('c', null, Array ('skip_autoload' => true));
/* @var $category kDBItem */
$category_fields = Array (
$fields['name'] => $name, 'Filename' => $name, 'AutomaticFilename' => 1,
- $fields['description'] => $description, 'Status' => $status,
+ $fields['description'] => $description, 'Status' => $status, 'Priority' => -9999,
);
$category_fields['ParentId'] = $this->Application->findModule('Name', 'Core', 'RootCat');
if (isset($category_template)) {
$category_fields['Template'] = $category_template;
$category_fields['CachedTemplate'] = $category_template;
}
$category->Clear();
$category->SetDBFieldsFromHash($category_fields);
$category->Create();
$priority_helper =& $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$event = new kEvent('c:OnListBuild');
// ensure, that newly created category has proper value in Priority field
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $category_fields['ParentId']);
+ // update Priority field in object, becase "CategoriesItem::Update" method will be called
+ // from "kInstallToolkit::setModuleItemTemplate" and otherwise will set 0 to Priority field
+ $sql = 'SELECT Priority
+ FROM ' . $category->TableName . '
+ WHERE ' . $category->IDField . ' = ' . $category->GetID();
+ $category->SetDBField('Priority', $this->Conn->GetOne($sql));
+
return $category;
}
/**
* Sets category item template into custom field for given prefix
*
* @param kDBItem $category
* @param string $prefix
* @param string $item_template
*/
function setModuleItemTemplate(&$category, $prefix, $item_template)
{
$this->Application->removeObject('c-cdata');
// recreate all fields, because custom fields are added during install script
$category->defineFields();
$category->prepareConfigOptions(); // creates ml fields
$category->SetDBField('cust_' . $prefix .'_ItemTemplate', $item_template);
$category->Update();
}
/**
* Link custom field records with search config records + create custom field columns
*
* @param string $module_folder
* @param int $item_type
*/
function linkCustomFields($module_folder, $prefix, $item_type)
{
$module_folder = strtolower($module_folder);
$module_name = $module_folder;
if ($module_folder == 'kernel') {
$module_name = 'in-portal';
$module_folder = 'core';
}
$db =& $this->Application->GetADODBConnection();
$sql = 'SELECT FieldName, CustomFieldId
FROM ' . TABLE_PREFIX . 'CustomField
WHERE Type = ' . $item_type . ' AND IsSystem = 0'; // config is not read here yet :( $this->Application->getUnitOption('p', 'ItemType');
$custom_fields = $db->GetCol($sql, 'CustomFieldId');
foreach ($custom_fields as $cf_id => $cf_name) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'SearchConfig
SET CustomFieldId = ' . $cf_id . '
WHERE (TableName = "CustomField") AND (LOWER(ModuleName) = "' . $module_name . '") AND (FieldName = ' . $db->qstr($cf_name) . ')';
$db->Query($sql);
}
$this->Application->refreshModuleInfo(); // this module configs are now processed
// because of configs was read only from installed before modules (in-portal), then reread configs
$unit_config_reader =& $this->Application->recallObject('kUnitConfigReader');
/* @var $unit_config_reader kUnitConfigReader */
$unit_config_reader->scanModules(MODULES_PATH . DIRECTORY_SEPARATOR . $module_folder);
// create correct columns in CustomData table
$ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
$ml_helper->createFields($prefix . '-cdata', true);
}
/**
* Deletes cache, useful after separate module install and installator last step
*
*/
function deleteCache($refresh_permissions = false)
{
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Cache
WHERE VarName IN ("config_files", "configs_parsed", "sections_parsed", "cms_menu", "StructureTree")';
$this->Conn->Query($sql);
if ($refresh_permissions) {
if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) {
// refresh permission without progress bar
$updater =& $this->Application->recallObject('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
}
else {
// refresh permissions with ajax progress bar (when available)
$fields_hash = Array (
'VarName' => 'ForcePermCacheUpdate',
'Data' => 1,
);
$this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'Cache');
}
}
}
/**
* Perform redirect after separate module install
*
* @param string $module_folder
* @param bool $refresh_permissions
*/
function finalizeModuleInstall($module_folder, $refresh_permissions = false)
{
if (!$this->Application->GetVar('redirect')) {
return ;
}
$this->SetModuleVersion($module_folder);
$this->deleteCache($refresh_permissions);
$url_params = Array (
'pass' => 'm', 'admin' => 1,
'RefreshTree' => 1, 'index_file' => 'index.php',
);
$this->Application->Redirect('modules/modules_list', $url_params);
}
/**
* Performs rebuild of themes
*
*/
function rebuildThemes()
{
$this->Application->HandleEvent($themes_event, 'adm:OnRebuildThemes');
}
}
\ No newline at end of file

Event Timeline