Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Fri, Sep 19, 4:32 AM

in-portal

Index: trunk/kernel/units/general/cat_dbitem.php
===================================================================
--- trunk/kernel/units/general/cat_dbitem.php (revision 5557)
+++ trunk/kernel/units/general/cat_dbitem.php (revision 5558)
@@ -1,361 +1,363 @@
<?php
class kCatDBItem extends kDBItem {
/**
* Category path, needed for import
*
* @var Array
*/
var $CategoryPath = Array();
/**
* Use automatic filename generation
*
* @var bool
*/
var $useFilenames = true;
function Clear()
{
parent::Clear();
$this->CategoryPath = Array();
}
function Create($force_id=false, $system_create=false)
{
if (!$this->Validate()) return false;
$this->SetDBField('ResourceId', $this->Application->NextResourceId());
$this->SetDBField('Modified', adodb_mktime() );
if ($this->mode != 't') {
$this->SetDBField('CreatedById', $this->Application->GetVar('u_id'));
}
if ($this->useFilenames) {
$this->checkFilename();
$this->generateFilename();
}
$ret = parent::Create();
if($ret)
{
if ( $this->Application->IsTempTable($this->TableName) ) {
$table = $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems');
}
else {
$table = TABLE_PREFIX.'CategoryItems';
}
$cat_id = $this->Application->GetVar('m_cat_id');
$query = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename)
VALUES ('.$cat_id.','.$this->GetField('ResourceId').',1,'.$this->Conn->qstr($this->Prefix).','.$this->Conn->qstr($this->GetDBField('Filename')).')';
$this->Conn->Query($query);
}
return $ret;
}
function Update($id=null, $system_update=false)
{
$this->VirtualFields['ResourceId'] = Array();
$this->SetDBField('Modified', adodb_mktime() );
$this->SetDBField('ModifiedById', $this->Application->GetVar('u_id'));
if ($this->useFilenames) {
$this->checkFilename();
$this->generateFilename();
}
$ret = parent::Update($id, $system_update);
if ($ret) {
$table = $this->Application->IsTempTable($this->TableName) ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems';
$this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($this->GetDBField('Filename')).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId'));
}
unset($this->VirtualFields['ResourceId']);
return $ret;
}
function checkFilename()
{
if( !$this->GetDBField('AutomaticFilename') )
{
$filename = $this->GetDBField('Filename');
$this->SetDBField('Filename', $this->stripDisallowed($filename) );
}
}
function Copy($cat_id=null)
{
if (!isset($cat_id)) $cat_id = $this->Application->GetVar('m_cat_id');
$this->NameCopy($cat_id);
return $this->Create($cat_id);
}
function NameCopy($master=null, $foreign_key=null)
{
$title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
if (!$title_field) return;
$new_name = $this->GetDBField($title_field);
$cat_id = $this->Application->GetVar('m_cat_id');
$original_checked = false;
do {
if ( preg_match('/Copy ([0-9]*) *of (.*)/', $new_name, $regs) ) {
$new_name = 'Copy '.( (int)$regs[1] + 1 ).' of '.$regs[2];
}
elseif ($original_checked) {
$new_name = 'Copy of '.$new_name;
}
$query = 'SELECT '.$title_field.' FROM '.$this->TableName.'
LEFT JOIN '.TABLE_PREFIX.'CategoryItems ON
('.TABLE_PREFIX.'CategoryItems.ItemResourceId = '.$this->TableName.'.ResourceId)
WHERE ('.TABLE_PREFIX.'CategoryItems.CategoryId = '.$cat_id.') AND '.
$title_field.' = '.$this->Conn->qstr($new_name);
$res = $this->Conn->GetOne($query);
$original_checked = true;
} while ($res !== false);
$this->SetDBField($title_field, $new_name);
}
function MoveToCat($cat_id=null)
{
// $this->NameCopy();
$cat_id = $this->Application->GetVar('m_cat_id');
// check if the product already exists in destination cat
$query = 'SELECT PrimaryCat FROM '.TABLE_PREFIX.'CategoryItems
WHERE CategoryId = '.$cat_id.' AND ItemResourceId = '.$this->GetDBField('ResourceId');
// if it's not found is_primary will be FALSE, if it's found but not primary it will be int 0
$is_primary = $this->Conn->GetOne($query);
$exists = $is_primary !== false;
if ($exists) { // if the Product already exists in destination category
if ($is_primary) return; // do nothing when we paste to primary
// if it's not primary - delete it from destination category,
// as we will move it from current primary below
$query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems
WHERE ItemResourceId = '.$this->GetDBField('ResourceId').' AND CategoryId = '.$cat_id;
$this->Conn->Query($query);
}
$query = 'UPDATE '.TABLE_PREFIX.'CategoryItems SET CategoryId = '.$cat_id.
' WHERE ItemResourceId = '.$this->GetDBField('ResourceId').' AND PrimaryCat = 1';
$this->Conn->Query($query);
$this->Update();
}
// We need to delete CategoryItems record when deleting product
function Delete($id=null)
{
if( isset($id) ) {
$this->setID($id);
}
$this->Load($this->GetID());
$ret = parent::Delete();
if ($ret) {
$query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems WHERE ItemResourceId = '.$this->GetDBField('ResourceId');
$this->Conn->Query($query);
}
return $ret;
}
/**
* Deletes item from categories
*
* @param Array $delete_category_ids
* @author Alex
*/
function DeleteFromCategories($delete_category_ids)
{
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); // because item was loaded before by ResourceId
$ci_table = $this->Application->getUnitOption($this->Prefix.'-ci', 'TableName');
$resource_id = $this->GetDBField('ResourceId');
$item_cats_sql = 'SELECT CategoryId FROM %s WHERE ItemResourceId = %s';
$delete_category_items_sql = 'DELETE FROM %s WHERE ItemResourceId = %s AND CategoryId IN (%s)';
$category_ids = $this->Conn->GetCol( sprintf($item_cats_sql, $ci_table, $resource_id) );
$cats_left = array_diff($category_ids, $delete_category_ids);
if(!$cats_left)
{
$sql = 'SELECT %s FROM %s WHERE ResourceId = %s';
$ids = $this->Conn->GetCol( sprintf($sql, $id_field, $this->TableName, $resource_id) );
$temp =& $this->Application->recallObject($this->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$temp->DeleteItems($this->Prefix, $this->Special, $ids);
}
else
{
$this->Conn->Query( sprintf($delete_category_items_sql, $ci_table, $resource_id, implode(',', $delete_category_ids) ) );
$sql = 'SELECT CategoryId FROM %s WHERE PrimaryCat = 1 AND ItemResourceId = %s';
$primary_cat_id = $this->Conn->GetCol( sprintf($sql, $ci_table, $resource_id) );
if( count($primary_cat_id) == 0 )
{
$sql = 'UPDATE %s SET PrimaryCat = 1 WHERE (CategoryId = %s) AND (ItemResourceId = %s)';
$this->Conn->Query( sprintf($sql, $ci_table, reset($cats_left), $resource_id ) );
}
}
}
/**
* replace not allowed symbols with "_" chars + remove duplicate "_" chars in result
*
* @param string $string
* @return string
*/
function stripDisallowed($filename)
{
$filenames_helper =& $this->Application->recallObject('FilenamesHelper');
- return $filenames_helper->stripDisallowed(TABLE_PREFIX.'CategoryItems', 'ItemResourceId', $this->GetDBField('ResourceId'), $filename);
+ $table = $this->mode == 't' ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems';
+
+ return $filenames_helper->stripDisallowed($table, 'ItemResourceId', $this->GetDBField('ResourceId'), $filename);
}
/* commented out because it's called only from stripDisallowed body, which is moved to helper
function checkAutoFilename($filename)
{
$filenames_helper =& $this->Application->recallObject('FilenamesHelper');
return $filenames_helper->checkAutoFilename($this->TableName, $this->IDField, $this->GetID(), $filename);
}*/
/**
* Generate item's filename based on it's title field value
*
* @return string
*/
function generateFilename()
{
if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false;
$title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
$name = $this->stripDisallowed( $this->GetDBField($title_field) );
if ( $name != $this->GetDBField('Filename') ) $this->SetDBField('Filename', $name);
}
/**
* Check if value is set for required field
*
* @param string $field field name
* @param Array $params field options from config
* @return bool
* @access private
*/
function ValidateRequired($field, $params)
{
$res = true;
$error_field = isset($params['error_field']) ? $params['error_field'] : $field;
if ( getArrayValue($params,'required') )
{
$res = ( (string) $this->FieldValues[$field] != '');
}
if (!$res) $this->FieldErrors[$error_field]['pseudo'] = 'required';
return $res;
}
/**
* Adds item to other category
*
* @param int $category_id
* @param bool $is_primary
*/
function assignToCategory($category_id, $is_primary = false)
{
$table = $this->mode == 't' ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems';
$key_clause = '(ItemResourceId = '.$this->GetDBField('ResourceId').')';
// get all cateories, where item is in
$sql = 'SELECT PrimaryCat, CategoryId FROM '.$table.' WHERE '.$key_clause;
$item_categories = $this->Conn->GetCol($sql, 'CategoryId');
if (!$item_categories) {
$item_categories = Array();
$primary_found = false;
}
// find primary category
foreach ($item_categories as $item_category_id => $primary_found) {
if ($primary_found) {
break;
}
}
if ($primary_found && ($item_category_id == $category_id) && !$is_primary) {
// want to make primary category as non-primary :(
return true;
}
else if (!$primary_found) {
$is_primary = true;
}
if ($is_primary && $item_categories) {
// reset primary mark from all other categories
$sql = 'UPDATE '.$table.' SET PrimaryCat = 0 WHERE '.$key_clause;
$this->Conn->Query($sql);
}
// UPDATE & INSERT instead of REPLACE because CategoryItems table has no primary key defined in database
if (isset($item_categories[$category_id])) {
$sql = 'UPDATE '.$table.' SET PrimaryCat = '.($is_primary ? 1 : 0).' WHERE '.$key_clause.' AND (CategoryId = '.$category_id.')';
$this->Conn->Query($sql);
}
else {
$sql = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename) VALUES (%s,%s,%s,%s,%s)';
$this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0, $this->Conn->qstr($this->Prefix), $this->Conn->qstr($this->GetDBField('Filename'))) );
}
// to ensure filename update after adding to another category
// this is critical since there may be an item with same filename in newly added category!
$this->Update();
}
/**
* Removes item from category specified
*
* @param int $category_id
*/
function removeFromCategory($category_id)
{
$sql = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems WHERE (CategoryId = %s) AND (ItemResourceId = %s)';
$this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId')) );
}
/**
* Returns list of columns, that could exist in imported file
*
* @return Array
*/
function getPossibleExportColumns()
{
static $columns = null;
if (!is_array($columns)) {
$columns = array_merge($this->Fields['AvailableColumns']['options'], $this->Fields['ExportColumns']['options']);
}
return $columns;
}
/**
* Returns item's primary image data
*
* @return Array
*/
function getPrimaryImageData()
{
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'Images
WHERE (ResourceId = '.$this->GetDBField('ResourceId').') AND (DefaultImg = 1)';
$image_data = $this->Conn->GetRow($sql);
if (!$image_data) {
// 2. no primary image, then get image with name "main"
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'Images
WHERE (ResourceId = '.$this->GetDBField('ResourceId').') AND (Name = "main")';
$image_data = $this->Conn->GetRow($sql);
}
return $image_data;
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/general/cat_dbitem.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.31
\ No newline at end of property
+1.32
\ No newline at end of property
Index: trunk/kernel/units/general/helpers/mod_rewrite_helper.php
===================================================================
--- trunk/kernel/units/general/helpers/mod_rewrite_helper.php (revision 5557)
+++ trunk/kernel/units/general/helpers/mod_rewrite_helper.php (revision 5558)
@@ -1,307 +1,338 @@
<?php
class kModRewriteHelper extends kHelper {
function kModRewriteHelper()
{
parent::kHelper();
$this->HTTPQuery =& $this->Application->recallObject('HTTPQuery');
}
- function processRewriteURL()
+ function SetDefaultValues()
{
- // directory_1_2_3/sc1/inlink/detail/3/l1_ka_asd.html
-
- $url = $this->HTTPQuery->Get('_mod_rw_url_');
- if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 );
-
- $url_parts = $url ? explode('/', $url) : Array();
-
- $process_module = true;
- if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts)
+ $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's');
+ foreach ($defaults as $default_key => $default_value)
{
- // set default values
- $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's');
- foreach ($defaults as $default_key => $default_value)
- {
- if ($this->HTTPQuery->Get($default_key) == null) {
- $this->HTTPQuery->Set($default_key, $default_value);
- }
+ if ($this->HTTPQuery->Get($default_key) == null) {
+ $this->HTTPQuery->Set($default_key, $default_value);
}
}
+ }
- if(!$url_parts)
- {
- $this->Application->Phrases = new PhrasesCache();
- $this->Application->VerifyLanguageId();
- $this->Application->Phrases->Init('phrases');
- $this->Application->VerifyThemeId();
-
- $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') );
- $this->HTTPQuery->finalizeParsing(Array('m'));
- return false;
- }
- else
- {
- $this->HTTPQuery->Set('t', '');
- }
-
+ function ProcessLanguage(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ $res = false;
$url_part = array_shift($url_parts);
- // match language
$sql = 'SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE LOWER(PackName) = '.$this->Conn->qstr($url_part).' AND Enabled = 1';
$language_id = $this->Conn->GetOne($sql);
$this->Application->Phrases = new PhrasesCache();
if($language_id)
{
$this->HTTPQuery->Set('m_lang', $language_id);
- $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing
+ $res = true;
}
$this->Application->VerifyLanguageId();
+ if (!$res) {
+ array_unshift($url_parts, $url_part);
+ }
+ return $res;
+ }
- // $this->HTTPQuery->Get('m_lang') );
+ function ProcessTheme(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ $res = false;
+ $url_part = array_shift($url_parts);
- // match theme
- if($url_part)
+ $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1';
+ $theme_id = $this->Conn->GetOne($sql);
+ if($theme_id)
{
- $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1';
- $theme_id = $this->Conn->GetOne($sql);
- if($theme_id)
- {
- $this->HTTPQuery->Set('m_theme', $theme_id);
- $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing
- }
+ $this->HTTPQuery->Set('m_theme', $theme_id);
+ $res = true;
}
$this->Application->VerifyThemeId(); // verify anyway - will set default if not found!!!
+ if (!$res) {
+ array_unshift($url_parts, $url_part);
+ }
+ return $res;
+ }
+
+ function ProcessCategory(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ $res = false;
+ $url_part = array_shift($url_parts);
- // match category
$category_id = 0;
- if($url_part)
+ $last_category_id = 0;
+ $category_path = '';
+ do
{
- $category_stack = Array();
- $category_found = false;
- $category_path = '';
- $rets = Array(); // just in case someone has used this variable before
- do
+ $category_path = trim($category_path.'/'.$url_part, '/');
+
+ if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) )
{
- $category_path = trim($category_path.'/'.$url_part, '/');
+ $category_path = $rets[1];
+ $this->HTTPQuery->Set('m_cat_page', $rets[2]);
+ }
- if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) )
- {
- $category_path = $rets[1];
- $this->HTTPQuery->Set('m_cat_page', $rets[2]);
- }
+ $category_id = $this->Conn->GetOne(
+ 'SELECT CategoryId
+ FROM '.TABLE_PREFIX.'Category
+ WHERE NamedParentPath = '.$this->Conn->qstr($category_path));
+ if ($category_id !== false) {
+ $last_category_id = $category_id;
+ $url_part = array_shift($url_parts);
+ $res = true;
+ }
+ } while ($category_id !== false && $url_part);
+ $this->HTTPQuery->Set('m_cat_id', $last_category_id);
- if ($category_path == '') {
- // this is "Home" virtual category
- array_push($category_stack, 0);
- }
- else {
- $sql = 'SELECT CategoryId
- FROM '.TABLE_PREFIX.'Category
- WHERE NamedParentPath = '.$this->Conn->qstr($category_path);
- array_push($category_stack, $this->Conn->GetOne($sql) );
- }
+ if ($url_part) {
+ array_unshift($url_parts, $url_part);
+ }
+ return $res;
+ }
- $category_found = end($category_stack);
- if ($category_found !== false) $url_part = array_shift($url_parts);
+ function ProcessModuleIndex(&$url_parts)
+ {
+ if ( count($url_parts) != 0 ) return false;
- }while ($category_found && $url_part);
+ $sql = 'SELECT CachedCategoryTemplate
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
+ $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate( $this->Conn->GetOne($sql) ) );
+ return true;
+ }
- if (count($category_stack)) {
- $category_id = array_pop($category_stack); // remove last not found category
- if($category_id === false)
- {
- $category_id = array_pop($category_stack);
- }
- if($category_id !== false)
- {
- $this->HTTPQuery->Set('m_cat_id', $category_id);
- }
- }
- elseif (!$category_found && getArrayValue($rets, 2)) {
+ function ProcessModuleItem(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ if ( count($url_parts) != 1 ) return false;
+ $url_part = array_shift($url_parts);
+
+ // match module reviews page
+ $page = 1;
+ if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) )
+ {
+ $url_part = $rets[1];
+ $page = $rets[2];
+ }
+
+ $cat_item = $this->Conn->GetRow('
+ SELECT ci.ItemPrefix, c.ParentPath, ci.CategoryId FORM '.TABLE_PREFIX.'CategoryItems AS ci
+ LEFT JOIN '.TABLE_PREFIX.'Category AS c
+ ON c.CategoryId = ci.CategoryId
+ WHERE
+ CategoryId = '.$this->Application->GetVar('m_cat_id').'
+ AND
+ Filename = '.$this->Conn->qstr($url_part));
+ if ($cat_item !== false) {
+ $module_prefix = $cat_item['ItemPrefix'];
+ $item_template = $category_data['CachedItemTemplate'];
+ if ($item_template) {
+ $url_parts = explode('/', $item_template);
+ array_push($url_parts, $url_part); // save item's filename as not processed
$url_part = array_shift($url_parts);
}
+ $this->Application->SetVar($cat_item['ItemPrefix'].'_id', $item_id);
}
- if (!$url_part) {
- // no more parts left in url
- $process_module = false;
- $sql = 'SELECT CachedCategoryTemplate
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$category_id;
- $category_template = $this->Conn->GetOne($sql);
- if ($category_template) {
- $category_template = explode('/', $category_template);
- $url_part = array_shift($category_template);
- $url_parts = $category_template;
- }
- else {
- $url_part = 'index';
+
+ $this->Application->SetVar( $event->getPrefixSpecial().'_Reviews_Page', $page);
+
+ // only filename left, no other parts
+ $process_module = false;
+ $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
+ $category_data = $this->Conn->GetRow($sql);
+
+
+
+ $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) );
+ $module_info = $this->Application->findModule('RootCat', $root_category_id);
+ if ($module_info) {
+ $module_prefix = $module_info['Var'];
+ $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) );
+ $this->Application->HandleEvent($module_event);
+
+ if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) {
+ $item_template = $category_data['CachedItemTemplate'];
+ if ($item_template) {
+ $this->HTTPQuery->Set('t', $item_template );
+ return true;
+ }
}
}
- elseif ($url_part && count($url_parts) <= 1 && $category_id) {
- // only filename left, no other parts
- $process_module = false;
- $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$category_id;
- $category_data = $this->Conn->GetRow($sql);
+ array_unshift($url_parts, $url_part);
+ return false;
+ }
- $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) );
- $module_info = $this->Application->findModule('RootCat', $root_category_id);
- if ($module_info) {
- $module_prefix = $module_info['Var'];
- $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) );
- $this->Application->HandleEvent($module_event);
+ function ProcessPhisycalTemplate(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
- if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) {
- $item_template = $category_data['CachedItemTemplate'];
- if ($item_template) {
- $url_parts = explode('/', $item_template);
- array_push($url_parts, $url_part); // save item's filename as not processed
- $url_part = array_shift($url_parts);
- }
- }
- elseif (!$module_event->getEventParam('url_parts')) {
- // parseEnv has processed that param
- $url_part = '';
- $category_template = $category_data['CachedCategoryTemplate'];
- if ($category_template) {
- $category_template = explode('/', $category_template);
- $url_part = array_shift($category_template);
- $url_parts = $category_template;
- }
- else {
- $url_part = 'index';
- }
- }
+ $remaining = array();
+ do
+ {
+ $template_path = implode('/', $url_parts);
+
+ $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path);
+ $t_parts['file'] = basename($template_path);
+
+ $sql = 'SELECT FileId
+ FROM '.TABLE_PREFIX.'ThemeFiles
+ WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')';
+
+// $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl');
+ $template_found = $this->Conn->GetOne($sql);
+ if(!$template_found)
+ {
+ array_unshift($remaining, array_pop($url_parts));
}
+ } while (!$template_found && $url_parts);
+
+ $url_parts = $remaining;
+
+ if ($template_found) {
+ $this->HTTPQuery->Set('t', $template_path );
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if whole url_parts matches a whole In-CMS page
+ *
+ * @param array $url_parts
+ * @return boolean
+ */
+ function ProcessVirtualTemplate(&$url_parts)
+ {
+ if (!isset($url_parts[0]) || !$this->Application->isModuleEnabled('In-CMS')) return false;
+
+ $template_path = implode('/', $url_parts);
+ $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p
+ LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci
+ ON ci.ItemResourceId = p.ResourceId
+ WHERE
+ Path = '.$this->Conn->qstr($template_path).'
+ AND
+ ci.PrimaryCat = 1';
+ $template_found = $this->Conn->GetRow($sql);
+
+ if ($template_found) {
+ $this->Application->SetVar('m_cat_id', $template_found['CategoryId']);
+ $this->HTTPQuery->Set('t', $template_path );
+ return true;
}
- // match module
+ return false;
+ }
+
+ function processRewriteURL()
+ {
+ $url = $this->HTTPQuery->Get('_mod_rw_url_');
+ if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 );
+ $url_parts = $url ? explode('/', $url) : Array();
+
+ $process_module = true;
+ if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts)
+ {
+ $this->SetDefaultValues();
+ }
+
+ if(!$url_parts)
+ {
+ $this->Application->Phrases = new PhrasesCache();
+ $this->Application->VerifyLanguageId();
+ $this->Application->Phrases->Init('phrases');
+ $this->Application->VerifyThemeId();
+
+ $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') );
+ $this->HTTPQuery->finalizeParsing(Array('m'));
+ return false;
+ }
+ else
+ {
+ $this->HTTPQuery->Set('t', '');
+ }
+
+ $this->ProcessLanguage($url_parts);
+ $this->ProcessTheme($url_parts);
+
+ if ( $this->ProcessVirtualTemplate($url_parts) ) {
+ return true;
+ }
+
+ $this->ProcessCategory($url_parts);
+ if ( $this->ProcessModuleIndex($url_parts) ) {
+ return ;
+ }
+ if ( $this->ProcessModuleItem($url_parts) ) {
+ return ;
+ }
+
+ /*// match module
$next_template = $this->HTTPQuery->Get('next_template');
if($url_part || $next_template)
{
if($next_template)
{
$next_template_parts = explode('/', $next_template);
$module_folder = array_shift($next_template_parts);
}
else
{
$module_folder = $url_part;
}
foreach ($this->Application->ModuleInfo as $module_name => $module_data)
{
if( trim($module_data['TemplatePath'], '/') == $module_folder )
{
$module_prefix = $module_data['Var'];
break;
}
}
- }
-
- // match template
- $template_path = '';
- $template_found = false;
- if($url_part)
- {
- // search for template in real template records
- array_unshift($url_parts, $url_part);
- $template_parts = $url_parts;
- $url_parts = Array();
- do
- {
- $template_path = implode('/', $template_parts);
-
- $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path);
- $t_parts['file'] = basename($template_path);
-
- $sql = 'SELECT FileId
- FROM '.TABLE_PREFIX.'ThemeFiles
- WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')';
-
- // $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl');
- $template_found = $this->Conn->GetOne($sql);
- if(!$template_found)
- {
- array_unshift( $url_parts, array_pop($template_parts) );
- }
-
- }while (!$template_found && $template_parts);
-
- // try to find template in virtual templates in case if such ability exists
- if ($this->Application->isModuleEnabled('In-CMS') && !$template_found) {
-
- $template_parts = $url_parts;
- $url_parts = Array();
- do
- {
- $template_path = implode('/', $template_parts);
-
- $sql = 'SELECT PageId FROM '.TABLE_PREFIX.'Pages WHERE Path = '.$this->Conn->qstr($template_path);
- $template_found = $this->Conn->GetOne($sql);
- if(!$template_found)
- {
- array_unshift( $url_parts, array_pop($template_parts) );
- }
-
- }while (!$template_found && $template_parts);
- }
- }
+ }*/
- // guess template if no existing template found
- if(!$template_found && isset($module_folder) && $module_folder)
- {
- // 1. try index template of module
- $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$module_folder.'/index.tpl');
- $template_found = $this->Conn->GetOne($sql);
- if($template_found)
- {
- $template_path = $module_folder.'/index';
- array_shift($url_parts);
- }
- else
- {
- // 2. return error template then
- $template_found = true;
- $template_path = $this->Application->ConfigValue('ErrorTemplate');
- if(!$template_path) $template_path = 'error_notfound';
-
- header('HTTP/1.0 404 Not Found');
+ if ( $this->ProcessPhisycalTemplate($url_parts) ) {
+ if (!$url_parts) {
+ return true;
}
}
- $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate($template_found ? $template_path : '') );
-
// pass params left to module
$this->Application->Phrases->Init('phrases');
$passed = Array('m');
$module_params = Array();
if ( isset($module_prefix) ) {
$passed[] = $module_prefix;
$module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) );
if ($process_module) {
$this->Application->HandleEvent($module_event);
}
$item_id = $this->HTTPQuery->Get($module_prefix.'_id');
$module_params = Array($module_prefix.'_id' => $item_id ? $item_id : '0' );
if ($module_event->status == erFAIL) {
$not_found = $this->Application->ConfigValue('ErrorTemplate');
$this->HTTPQuery->Set('t', $not_found ? $not_found : 'error_notfound' );
}
}
$this->HTTPQuery->finalizeParsing($passed, $module_params);
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/general/helpers/mod_rewrite_helper.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/kernel/admin_templates/categories/categories_edit_properties.tpl
===================================================================
--- trunk/kernel/admin_templates/categories/categories_edit_properties.tpl (revision 5557)
+++ trunk/kernel/admin_templates/categories/categories_edit_properties.tpl (revision 5558)
@@ -1,64 +1,64 @@
<inp2:m_RequireLogin permissions="CATEGORY.VIEW"/>
<inp2:m_include t="incs/header" nobody="yes"/>
<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
<inp2:m_ParseBlock name="section_header" prefix="c" icon="icon46_catalog" module="in-portal" title="!la_title_Categories!"/>
<inp2:m_include t="categories/categories_tabs"/>
-
+
<inp2:m_ParseBlock name="blue_bar" prefix="c" title_preset="categories_properties" module="in-portal" icon="icon46_catalog"/>
<!-- 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('c','<inp2:c_SaveEvent/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('c','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('c', '<inp2:c_PrevId/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
go_to_id('c', '<inp2:c_NextId/>');
}
) );
-
+
a_toolbar.Render();
-
+
<inp2:m_if check="c_IsSingle">
a_toolbar.HideButton('prev');
a_toolbar.HideButton('next');
a_toolbar.HideButton('sep1');
- <inp2:m_else/>
+ <inp2:m_else/>
<inp2:m_if check="c_IsLast">
a_toolbar.DisableButton('next');
</inp2:m_if>
<inp2:m_if check="c_IsFirst">
a_toolbar.DisableButton('prev');
</inp2:m_if>
- </inp2:m_if>
+ </inp2:m_if>
</script>
</td>
</tr>
</tbody>
</table>
<inp2:c_SaveWarning name="grid_save_warning"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
- <inp2:m_ModuleInclude template="category_items" />
+ <inp2:m_ModuleInclude template="category_properties" />
</table>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/categories/categories_edit_properties.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/admin/editor/inp_styles.xml
===================================================================
--- trunk/admin/editor/inp_styles.xml (revision 5557)
+++ trunk/admin/editor/inp_styles.xml (revision 5558)
@@ -1,29 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
- *
+ *
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
* For further information visit:
* http://www.fckeditor.net/
- *
+ *
* File Name: fckstyles.xml
* This is the sample style definitions file. It makes the styles combo
* completely customizable.
* See FCKConfig.StylesXmlPath in the configuration file.
- *
+ *
* Version: 2.0 RC3
* Modified: 2005-02-09 13:51:09
- *
+ *
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
-->
<Styles>
<Style name="Page Title" element="h1">
- </Style>
+ </Style>
<Style name="Subtitle" element="h2">
</Style>
<Style name="Caption" element="h3">
</Style>
</Styles>
\ No newline at end of file
Property changes on: trunk/admin/editor/inp_styles.xml
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/admin/editor/FCKeditor/fckeditor.php
===================================================================
--- trunk/admin/editor/FCKeditor/fckeditor.php (revision 5557)
+++ trunk/admin/editor/FCKeditor/fckeditor.php (revision 5558)
@@ -1,107 +1,107 @@
<?php
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License
* (http://www.opensource.org/licenses/lgpl-license.php)
*
- * For further information go to http://www.fredck.com/FCKeditor/
+ * For further information go to http://www.fredck.com/FCKeditor/
* or contact fckeditor@fredck.com.
*
* fckeditor.php: PHP pages integration.
*
* Authors:
* Frederico Caldeira Knabben (fckeditor@fredck.com)
*/
// The editor base path
// You have to update it with you web site configuration
// new startup: begin
define('REL_PATH', 'admin/editor/FCKEditor');
$relation_level = count( explode('/', REL_PATH) );
define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) );
require_once FULL_PATH.'/kernel/startup.php';
// new startup: end
//echo $pathtoroot;
$FCKeditorBasePath = $rootURL.$admin."/editor/FCKeditor/" ;
class FCKeditor
{
var $ToolbarSet ;
var $Value ;
var $CanUpload ;
var $CanBrowse ;
function FCKeditor()
{
$this->ToolbarSet = '' ;
$this->Value = '' ;
$this->CanUpload = 'none' ;
$this->CanBrowse = 'none' ;
}
-
+
function CreateFCKeditor($instanceName, $width, $height)
{
echo $this->ReturnFCKeditor($instanceName, $width, $height) ;
}
-
+
function ReturnFCKeditor($instanceName, $width, $height)
{
// $grstr = htmlentities( $this->Value ) ;
$grstr = htmlspecialchars( $this->Value ) ;
$strEditor = "" ;
-
+
if ( $this->IsCompatible() )
{
global $FCKeditorBasePath ;
$sLink = $FCKeditorBasePath . "fckeditor.html?FieldName=$instanceName" ;
if ( $this->ToolbarSet != '' )
$sLink = $sLink . "&Toolbar=$this->ToolbarSet" ;
if ( $this->CanUpload != 'none' )
{
if ($this->CanUpload == true)
$sLink = $sLink . "&Upload=true" ;
else
$sLink = $sLink . "&Upload=false" ;
}
if ( $this->CanBrowse != 'none' )
{
if ($this->CanBrowse == true)
$sLink = $sLink . "&Browse=true" ;
else
$sLink = $sLink . "&Browse=false" ;
}
$strEditor .= "<IFRAME src=\"$sLink\" width=\"$width\" height=\"$height\" frameborder=\"no\" scrolling=\"no\"></IFRAME>" ;
$strEditor .= "<INPUT type=\"hidden\" id=\"$instanceName\" name=\"$instanceName\" value=\"$grstr\">" ;
}
else
{
$strEditor .= "<TEXTAREA id=\"$instanceName\" name=\"$instanceName\" rows=\"4\" cols=\"40\" style=\"WIDTH: $width; HEIGHT: $height\" wrap=\"virtual\">$grstr</TEXTAREA>" ;
}
-
+
return $strEditor;
}
-
+
function IsCompatible()
{
$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
if ( is_integer( strpos($sAgent, 'MSIE') ) && is_integer( strpos($sAgent, 'Windows') ) && !is_integer( strpos($sAgent, 'Opera') ) )
{
$iVersion = (int)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 1) ;
return ($iVersion >= 5) ;
} else {
return FALSE ;
}
}
}
?>
Property changes on: trunk/admin/editor/FCKeditor/fckeditor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/admin/editor/inp_fckconfig.js
===================================================================
--- trunk/admin/editor/inp_fckconfig.js (revision 5557)
+++ trunk/admin/editor/inp_fckconfig.js (revision 5558)
@@ -1,132 +1,114 @@
/*
* Edited by Kostja
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
- *
+ *
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
- *
+ *
* For further information visit:
* http://www.fckeditor.net/
- *
+ *
* File Name: fckconfig.js
* Editor configuration settings.
* See the documentation for more info.
- *
+ *
* Version: 2.0 RC3
* Modified: 2005-02-27 21:31:48
- *
+ *
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
-FCKConfig.CustomConfigurationsPath = '' ;
+//FCKConfig.CustomConfigurationsPath = '' ;
-//FCKConfig.EditorAreaCSS = FCKConfig.ProjectPath + 'themes/site/inc/style.css' ;
+//FCKConfig.EditorAreaCSS = FCKConfig.ProjectPath + 'themes/inportal_site/inc/inportal.css' ;
FCKConfig.BaseHref = '' ;
FCKConfig.FullPage = false ;
FCKConfig.Debug = false ;
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;
FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;
// FCKConfig.Plugins.Add( 'placeholder', 'en,it' ) ;
FCKConfig.AutoDetectLanguage = true ;
FCKConfig.DefaultLanguage = 'en' ;
FCKConfig.ContentLangDirection = 'ltr' ;
FCKConfig.EnableXHTML = true ;
FCKConfig.EnableSourceXHTML = true ;
-
FCKConfig.FillEmptyBlocks = true ;
-
FCKConfig.FormatSource = true ;
FCKConfig.FormatOutput = true ;
FCKConfig.FormatIndentator = ' ' ;
-
FCKConfig.GeckoUseSPAN = true ;
FCKConfig.StartupFocus = false ;
FCKConfig.ForcePasteAsPlainText = true ;
FCKConfig.ForceSimpleAmpersand = false ;
FCKConfig.TabSpaces = 0;
-
FCKConfig.ShowBorders = true;
FCKConfig.ShowTableBorders = true;
-
FCKConfig.UseBROnCarriageReturn = false ;
FCKConfig.ToolbarStartExpanded = true ;
FCKConfig.ToolbarCanCollapse = true ;
//FCKConfig.ProjectPath = FCKConfig.BasePath.replace(/\/cmseditor\/editor\/$/,'');
FCKConfig.IconImagesUrl = FCKConfig.ProjectPath+'kernel/user_files/icons';
FCKConfig.ToolbarSets["Default"] = [
['Cut','Copy','Paste','PasteText','PasteWord','NewPage','SelectAll','-','Link','Unlink','Anchor','-','Image','SpecialChar','-','Find','Replace','-','Rule'],
['Source'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','Outdent','Indent'],
'/',
['Style','RemoveFormat']
] ;
-
FCKConfig.ToolbarSets["Advanced"] = [
['Cut','Copy','Paste','PasteText','PasteWord','-','NewPage','SelectAll','-','Find','Replace','-','Print','-','Link','Unlink','Anchor','Rule','-','Image','Document','Table','SpecialChar'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','Outdent','Indent','-','Subscript','Superscript','-','TextColor','BGColor','-','Undo','Redo'],
'/',
['Style','FontName','FontSize','RemoveFormat','-','SpellCheck','100%','|','Source']
] ;
FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About']
] ;
-
-
FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Select','Document','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','TableCell','Table','Form'] ;
-
FCKConfig.FontColors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,808080,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF' ;
-
FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
FCKConfig.FontSizes = '1/xx-small;2/x-small;3/small;4/medium;5/large;6/x-large;7/xx-large' ;
FCKConfig.FontFormats = 'p;div;pre;address;h1;h2;h3;h4;h5;h6' ;
-
FCKConfig.StylesXmlPath = '../../inp_styles.xml' ;
-
FCKConfig.SpellChecker = 'ieSpell' ; // 'ieSpell' | 'SpellerPages'
FCKConfig.IeSpellDownloadUrl = 'http://www.iespell.com/rel/ieSpellSetup211325.exe' ;
-
FCKConfig.LinkBrowser = true ;
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files' ;
FCKConfig.LinkBrowserWindowWidth = screen.width * 0.7 ; // 70%
FCKConfig.LinkBrowserWindowHeight = screen.height * 0.7 ; // 70%
-
FCKConfig.ImageBrowser = true ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Images&Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files' ;
FCKConfig.ImageBrowserWindowWidth = screen.width * 0.7 ; // 70% ;
FCKConfig.ImageBrowserWindowHeight = screen.height * 0.7 ; // 70% ;
-
FCKConfig.DocumentBrowser = true ;
FCKConfig.DocumentBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Documents&Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files' ;
FCKConfig.ImageBrowserWindowWidth = screen.width * 0.7 ; // 70% ;
FCKConfig.ImageBrowserWindowHeight = screen.height * 0.7 ; // 70% ;
FCKConfig.DocumentsServerPath = FCKConfig.ProjectPath+'kernel/user_files/Documents'
-
FCKConfig.StructureBrowser = true ;
FCKConfig.StructureBrowserURL = FCKConfig.ProjectPath+'/admin/index.php?t=structure/tree' ;
FCKConfig.StructureBrowserWindowWidth = screen.width * 0.5 ; // 50%
FCKConfig.StructureBrowserWindowHeight = screen.height * 0.7 ; // 70%
-
FCKConfig.FilesBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Files&Connector=connectors/php/connector.php&ServerPath='+FCKConfig.ProjectPath+'kernel/user_files/' ;
-
FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ;
FCKConfig.SmileyImages = ['regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ;
FCKConfig.SmileyColumns = 8 ;
FCKConfig.SmileyWindowWidth = 320 ;
FCKConfig.SmileyWindowHeight = 240 ;
FCKConfig.K4Mode = 1;
\ No newline at end of file
Property changes on: trunk/admin/editor/inp_fckconfig.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/core/units/general/cat_dbitem.php
===================================================================
--- trunk/core/units/general/cat_dbitem.php (revision 5557)
+++ trunk/core/units/general/cat_dbitem.php (revision 5558)
@@ -1,361 +1,363 @@
<?php
class kCatDBItem extends kDBItem {
/**
* Category path, needed for import
*
* @var Array
*/
var $CategoryPath = Array();
/**
* Use automatic filename generation
*
* @var bool
*/
var $useFilenames = true;
function Clear()
{
parent::Clear();
$this->CategoryPath = Array();
}
function Create($force_id=false, $system_create=false)
{
if (!$this->Validate()) return false;
$this->SetDBField('ResourceId', $this->Application->NextResourceId());
$this->SetDBField('Modified', adodb_mktime() );
if ($this->mode != 't') {
$this->SetDBField('CreatedById', $this->Application->GetVar('u_id'));
}
if ($this->useFilenames) {
$this->checkFilename();
$this->generateFilename();
}
$ret = parent::Create();
if($ret)
{
if ( $this->Application->IsTempTable($this->TableName) ) {
$table = $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems');
}
else {
$table = TABLE_PREFIX.'CategoryItems';
}
$cat_id = $this->Application->GetVar('m_cat_id');
$query = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename)
VALUES ('.$cat_id.','.$this->GetField('ResourceId').',1,'.$this->Conn->qstr($this->Prefix).','.$this->Conn->qstr($this->GetDBField('Filename')).')';
$this->Conn->Query($query);
}
return $ret;
}
function Update($id=null, $system_update=false)
{
$this->VirtualFields['ResourceId'] = Array();
$this->SetDBField('Modified', adodb_mktime() );
$this->SetDBField('ModifiedById', $this->Application->GetVar('u_id'));
if ($this->useFilenames) {
$this->checkFilename();
$this->generateFilename();
}
$ret = parent::Update($id, $system_update);
if ($ret) {
$table = $this->Application->IsTempTable($this->TableName) ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems';
$this->Conn->Query('UPDATE '.$table.' SET Filename = '.$this->Conn->qstr($this->GetDBField('Filename')).' WHERE ItemResourceId = '.$this->GetDBField('ResourceId'));
}
unset($this->VirtualFields['ResourceId']);
return $ret;
}
function checkFilename()
{
if( !$this->GetDBField('AutomaticFilename') )
{
$filename = $this->GetDBField('Filename');
$this->SetDBField('Filename', $this->stripDisallowed($filename) );
}
}
function Copy($cat_id=null)
{
if (!isset($cat_id)) $cat_id = $this->Application->GetVar('m_cat_id');
$this->NameCopy($cat_id);
return $this->Create($cat_id);
}
function NameCopy($master=null, $foreign_key=null)
{
$title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
if (!$title_field) return;
$new_name = $this->GetDBField($title_field);
$cat_id = $this->Application->GetVar('m_cat_id');
$original_checked = false;
do {
if ( preg_match('/Copy ([0-9]*) *of (.*)/', $new_name, $regs) ) {
$new_name = 'Copy '.( (int)$regs[1] + 1 ).' of '.$regs[2];
}
elseif ($original_checked) {
$new_name = 'Copy of '.$new_name;
}
$query = 'SELECT '.$title_field.' FROM '.$this->TableName.'
LEFT JOIN '.TABLE_PREFIX.'CategoryItems ON
('.TABLE_PREFIX.'CategoryItems.ItemResourceId = '.$this->TableName.'.ResourceId)
WHERE ('.TABLE_PREFIX.'CategoryItems.CategoryId = '.$cat_id.') AND '.
$title_field.' = '.$this->Conn->qstr($new_name);
$res = $this->Conn->GetOne($query);
$original_checked = true;
} while ($res !== false);
$this->SetDBField($title_field, $new_name);
}
function MoveToCat($cat_id=null)
{
// $this->NameCopy();
$cat_id = $this->Application->GetVar('m_cat_id');
// check if the product already exists in destination cat
$query = 'SELECT PrimaryCat FROM '.TABLE_PREFIX.'CategoryItems
WHERE CategoryId = '.$cat_id.' AND ItemResourceId = '.$this->GetDBField('ResourceId');
// if it's not found is_primary will be FALSE, if it's found but not primary it will be int 0
$is_primary = $this->Conn->GetOne($query);
$exists = $is_primary !== false;
if ($exists) { // if the Product already exists in destination category
if ($is_primary) return; // do nothing when we paste to primary
// if it's not primary - delete it from destination category,
// as we will move it from current primary below
$query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems
WHERE ItemResourceId = '.$this->GetDBField('ResourceId').' AND CategoryId = '.$cat_id;
$this->Conn->Query($query);
}
$query = 'UPDATE '.TABLE_PREFIX.'CategoryItems SET CategoryId = '.$cat_id.
' WHERE ItemResourceId = '.$this->GetDBField('ResourceId').' AND PrimaryCat = 1';
$this->Conn->Query($query);
$this->Update();
}
// We need to delete CategoryItems record when deleting product
function Delete($id=null)
{
if( isset($id) ) {
$this->setID($id);
}
$this->Load($this->GetID());
$ret = parent::Delete();
if ($ret) {
$query = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems WHERE ItemResourceId = '.$this->GetDBField('ResourceId');
$this->Conn->Query($query);
}
return $ret;
}
/**
* Deletes item from categories
*
* @param Array $delete_category_ids
* @author Alex
*/
function DeleteFromCategories($delete_category_ids)
{
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); // because item was loaded before by ResourceId
$ci_table = $this->Application->getUnitOption($this->Prefix.'-ci', 'TableName');
$resource_id = $this->GetDBField('ResourceId');
$item_cats_sql = 'SELECT CategoryId FROM %s WHERE ItemResourceId = %s';
$delete_category_items_sql = 'DELETE FROM %s WHERE ItemResourceId = %s AND CategoryId IN (%s)';
$category_ids = $this->Conn->GetCol( sprintf($item_cats_sql, $ci_table, $resource_id) );
$cats_left = array_diff($category_ids, $delete_category_ids);
if(!$cats_left)
{
$sql = 'SELECT %s FROM %s WHERE ResourceId = %s';
$ids = $this->Conn->GetCol( sprintf($sql, $id_field, $this->TableName, $resource_id) );
$temp =& $this->Application->recallObject($this->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$temp->DeleteItems($this->Prefix, $this->Special, $ids);
}
else
{
$this->Conn->Query( sprintf($delete_category_items_sql, $ci_table, $resource_id, implode(',', $delete_category_ids) ) );
$sql = 'SELECT CategoryId FROM %s WHERE PrimaryCat = 1 AND ItemResourceId = %s';
$primary_cat_id = $this->Conn->GetCol( sprintf($sql, $ci_table, $resource_id) );
if( count($primary_cat_id) == 0 )
{
$sql = 'UPDATE %s SET PrimaryCat = 1 WHERE (CategoryId = %s) AND (ItemResourceId = %s)';
$this->Conn->Query( sprintf($sql, $ci_table, reset($cats_left), $resource_id ) );
}
}
}
/**
* replace not allowed symbols with "_" chars + remove duplicate "_" chars in result
*
* @param string $string
* @return string
*/
function stripDisallowed($filename)
{
$filenames_helper =& $this->Application->recallObject('FilenamesHelper');
- return $filenames_helper->stripDisallowed(TABLE_PREFIX.'CategoryItems', 'ItemResourceId', $this->GetDBField('ResourceId'), $filename);
+ $table = $this->mode == 't' ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems';
+
+ return $filenames_helper->stripDisallowed($table, 'ItemResourceId', $this->GetDBField('ResourceId'), $filename);
}
/* commented out because it's called only from stripDisallowed body, which is moved to helper
function checkAutoFilename($filename)
{
$filenames_helper =& $this->Application->recallObject('FilenamesHelper');
return $filenames_helper->checkAutoFilename($this->TableName, $this->IDField, $this->GetID(), $filename);
}*/
/**
* Generate item's filename based on it's title field value
*
* @return string
*/
function generateFilename()
{
if ( !$this->GetDBField('AutomaticFilename') && $this->GetDBField('Filename') ) return false;
$title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
$name = $this->stripDisallowed( $this->GetDBField($title_field) );
if ( $name != $this->GetDBField('Filename') ) $this->SetDBField('Filename', $name);
}
/**
* Check if value is set for required field
*
* @param string $field field name
* @param Array $params field options from config
* @return bool
* @access private
*/
function ValidateRequired($field, $params)
{
$res = true;
$error_field = isset($params['error_field']) ? $params['error_field'] : $field;
if ( getArrayValue($params,'required') )
{
$res = ( (string) $this->FieldValues[$field] != '');
}
if (!$res) $this->FieldErrors[$error_field]['pseudo'] = 'required';
return $res;
}
/**
* Adds item to other category
*
* @param int $category_id
* @param bool $is_primary
*/
function assignToCategory($category_id, $is_primary = false)
{
$table = $this->mode == 't' ? $this->Application->GetTempName(TABLE_PREFIX.'CategoryItems') : TABLE_PREFIX.'CategoryItems';
$key_clause = '(ItemResourceId = '.$this->GetDBField('ResourceId').')';
// get all cateories, where item is in
$sql = 'SELECT PrimaryCat, CategoryId FROM '.$table.' WHERE '.$key_clause;
$item_categories = $this->Conn->GetCol($sql, 'CategoryId');
if (!$item_categories) {
$item_categories = Array();
$primary_found = false;
}
// find primary category
foreach ($item_categories as $item_category_id => $primary_found) {
if ($primary_found) {
break;
}
}
if ($primary_found && ($item_category_id == $category_id) && !$is_primary) {
// want to make primary category as non-primary :(
return true;
}
else if (!$primary_found) {
$is_primary = true;
}
if ($is_primary && $item_categories) {
// reset primary mark from all other categories
$sql = 'UPDATE '.$table.' SET PrimaryCat = 0 WHERE '.$key_clause;
$this->Conn->Query($sql);
}
// UPDATE & INSERT instead of REPLACE because CategoryItems table has no primary key defined in database
if (isset($item_categories[$category_id])) {
$sql = 'UPDATE '.$table.' SET PrimaryCat = '.($is_primary ? 1 : 0).' WHERE '.$key_clause.' AND (CategoryId = '.$category_id.')';
$this->Conn->Query($sql);
}
else {
$sql = 'INSERT INTO '.$table.' (CategoryId,ItemResourceId,PrimaryCat,ItemPrefix,Filename) VALUES (%s,%s,%s,%s,%s)';
$this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId'), $is_primary ? 1 : 0, $this->Conn->qstr($this->Prefix), $this->Conn->qstr($this->GetDBField('Filename'))) );
}
// to ensure filename update after adding to another category
// this is critical since there may be an item with same filename in newly added category!
$this->Update();
}
/**
* Removes item from category specified
*
* @param int $category_id
*/
function removeFromCategory($category_id)
{
$sql = 'DELETE FROM '.TABLE_PREFIX.'CategoryItems WHERE (CategoryId = %s) AND (ItemResourceId = %s)';
$this->Conn->Query( sprintf($sql, $category_id, $this->GetDBField('ResourceId')) );
}
/**
* Returns list of columns, that could exist in imported file
*
* @return Array
*/
function getPossibleExportColumns()
{
static $columns = null;
if (!is_array($columns)) {
$columns = array_merge($this->Fields['AvailableColumns']['options'], $this->Fields['ExportColumns']['options']);
}
return $columns;
}
/**
* Returns item's primary image data
*
* @return Array
*/
function getPrimaryImageData()
{
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'Images
WHERE (ResourceId = '.$this->GetDBField('ResourceId').') AND (DefaultImg = 1)';
$image_data = $this->Conn->GetRow($sql);
if (!$image_data) {
// 2. no primary image, then get image with name "main"
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'Images
WHERE (ResourceId = '.$this->GetDBField('ResourceId').') AND (Name = "main")';
$image_data = $this->Conn->GetRow($sql);
}
return $image_data;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/general/cat_dbitem.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.31
\ No newline at end of property
+1.32
\ No newline at end of property
Index: trunk/core/units/general/helpers/mod_rewrite_helper.php
===================================================================
--- trunk/core/units/general/helpers/mod_rewrite_helper.php (revision 5557)
+++ trunk/core/units/general/helpers/mod_rewrite_helper.php (revision 5558)
@@ -1,307 +1,338 @@
<?php
class kModRewriteHelper extends kHelper {
function kModRewriteHelper()
{
parent::kHelper();
$this->HTTPQuery =& $this->Application->recallObject('HTTPQuery');
}
- function processRewriteURL()
+ function SetDefaultValues()
{
- // directory_1_2_3/sc1/inlink/detail/3/l1_ka_asd.html
-
- $url = $this->HTTPQuery->Get('_mod_rw_url_');
- if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 );
-
- $url_parts = $url ? explode('/', $url) : Array();
-
- $process_module = true;
- if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts)
+ $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's');
+ foreach ($defaults as $default_key => $default_value)
{
- // set default values
- $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's');
- foreach ($defaults as $default_key => $default_value)
- {
- if ($this->HTTPQuery->Get($default_key) == null) {
- $this->HTTPQuery->Set($default_key, $default_value);
- }
+ if ($this->HTTPQuery->Get($default_key) == null) {
+ $this->HTTPQuery->Set($default_key, $default_value);
}
}
+ }
- if(!$url_parts)
- {
- $this->Application->Phrases = new PhrasesCache();
- $this->Application->VerifyLanguageId();
- $this->Application->Phrases->Init('phrases');
- $this->Application->VerifyThemeId();
-
- $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') );
- $this->HTTPQuery->finalizeParsing(Array('m'));
- return false;
- }
- else
- {
- $this->HTTPQuery->Set('t', '');
- }
-
+ function ProcessLanguage(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ $res = false;
$url_part = array_shift($url_parts);
- // match language
$sql = 'SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE LOWER(PackName) = '.$this->Conn->qstr($url_part).' AND Enabled = 1';
$language_id = $this->Conn->GetOne($sql);
$this->Application->Phrases = new PhrasesCache();
if($language_id)
{
$this->HTTPQuery->Set('m_lang', $language_id);
- $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing
+ $res = true;
}
$this->Application->VerifyLanguageId();
+ if (!$res) {
+ array_unshift($url_parts, $url_part);
+ }
+ return $res;
+ }
- // $this->HTTPQuery->Get('m_lang') );
+ function ProcessTheme(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ $res = false;
+ $url_part = array_shift($url_parts);
- // match theme
- if($url_part)
+ $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1';
+ $theme_id = $this->Conn->GetOne($sql);
+ if($theme_id)
{
- $sql = 'SELECT ThemeId FROM '.TABLE_PREFIX.'Theme WHERE LOWER(Name) = '.$this->Conn->qstr($url_part).' AND Enabled = 1';
- $theme_id = $this->Conn->GetOne($sql);
- if($theme_id)
- {
- $this->HTTPQuery->Set('m_theme', $theme_id);
- $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing
- }
+ $this->HTTPQuery->Set('m_theme', $theme_id);
+ $res = true;
}
$this->Application->VerifyThemeId(); // verify anyway - will set default if not found!!!
+ if (!$res) {
+ array_unshift($url_parts, $url_part);
+ }
+ return $res;
+ }
+
+ function ProcessCategory(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ $res = false;
+ $url_part = array_shift($url_parts);
- // match category
$category_id = 0;
- if($url_part)
+ $last_category_id = 0;
+ $category_path = '';
+ do
{
- $category_stack = Array();
- $category_found = false;
- $category_path = '';
- $rets = Array(); // just in case someone has used this variable before
- do
+ $category_path = trim($category_path.'/'.$url_part, '/');
+
+ if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) )
{
- $category_path = trim($category_path.'/'.$url_part, '/');
+ $category_path = $rets[1];
+ $this->HTTPQuery->Set('m_cat_page', $rets[2]);
+ }
- if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) )
- {
- $category_path = $rets[1];
- $this->HTTPQuery->Set('m_cat_page', $rets[2]);
- }
+ $category_id = $this->Conn->GetOne(
+ 'SELECT CategoryId
+ FROM '.TABLE_PREFIX.'Category
+ WHERE NamedParentPath = '.$this->Conn->qstr($category_path));
+ if ($category_id !== false) {
+ $last_category_id = $category_id;
+ $url_part = array_shift($url_parts);
+ $res = true;
+ }
+ } while ($category_id !== false && $url_part);
+ $this->HTTPQuery->Set('m_cat_id', $last_category_id);
- if ($category_path == '') {
- // this is "Home" virtual category
- array_push($category_stack, 0);
- }
- else {
- $sql = 'SELECT CategoryId
- FROM '.TABLE_PREFIX.'Category
- WHERE NamedParentPath = '.$this->Conn->qstr($category_path);
- array_push($category_stack, $this->Conn->GetOne($sql) );
- }
+ if ($url_part) {
+ array_unshift($url_parts, $url_part);
+ }
+ return $res;
+ }
- $category_found = end($category_stack);
- if ($category_found !== false) $url_part = array_shift($url_parts);
+ function ProcessModuleIndex(&$url_parts)
+ {
+ if ( count($url_parts) != 0 ) return false;
- }while ($category_found && $url_part);
+ $sql = 'SELECT CachedCategoryTemplate
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
+ $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate( $this->Conn->GetOne($sql) ) );
+ return true;
+ }
- if (count($category_stack)) {
- $category_id = array_pop($category_stack); // remove last not found category
- if($category_id === false)
- {
- $category_id = array_pop($category_stack);
- }
- if($category_id !== false)
- {
- $this->HTTPQuery->Set('m_cat_id', $category_id);
- }
- }
- elseif (!$category_found && getArrayValue($rets, 2)) {
+ function ProcessModuleItem(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
+ if ( count($url_parts) != 1 ) return false;
+ $url_part = array_shift($url_parts);
+
+ // match module reviews page
+ $page = 1;
+ if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) )
+ {
+ $url_part = $rets[1];
+ $page = $rets[2];
+ }
+
+ $cat_item = $this->Conn->GetRow('
+ SELECT ci.ItemPrefix, c.ParentPath, ci.CategoryId FORM '.TABLE_PREFIX.'CategoryItems AS ci
+ LEFT JOIN '.TABLE_PREFIX.'Category AS c
+ ON c.CategoryId = ci.CategoryId
+ WHERE
+ CategoryId = '.$this->Application->GetVar('m_cat_id').'
+ AND
+ Filename = '.$this->Conn->qstr($url_part));
+ if ($cat_item !== false) {
+ $module_prefix = $cat_item['ItemPrefix'];
+ $item_template = $category_data['CachedItemTemplate'];
+ if ($item_template) {
+ $url_parts = explode('/', $item_template);
+ array_push($url_parts, $url_part); // save item's filename as not processed
$url_part = array_shift($url_parts);
}
+ $this->Application->SetVar($cat_item['ItemPrefix'].'_id', $item_id);
}
- if (!$url_part) {
- // no more parts left in url
- $process_module = false;
- $sql = 'SELECT CachedCategoryTemplate
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$category_id;
- $category_template = $this->Conn->GetOne($sql);
- if ($category_template) {
- $category_template = explode('/', $category_template);
- $url_part = array_shift($category_template);
- $url_parts = $category_template;
- }
- else {
- $url_part = 'index';
+
+ $this->Application->SetVar( $event->getPrefixSpecial().'_Reviews_Page', $page);
+
+ // only filename left, no other parts
+ $process_module = false;
+ $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$this->Application->GetVar('m_cat_id');
+ $category_data = $this->Conn->GetRow($sql);
+
+
+
+ $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) );
+ $module_info = $this->Application->findModule('RootCat', $root_category_id);
+ if ($module_info) {
+ $module_prefix = $module_info['Var'];
+ $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) );
+ $this->Application->HandleEvent($module_event);
+
+ if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) {
+ $item_template = $category_data['CachedItemTemplate'];
+ if ($item_template) {
+ $this->HTTPQuery->Set('t', $item_template );
+ return true;
+ }
}
}
- elseif ($url_part && count($url_parts) <= 1 && $category_id) {
- // only filename left, no other parts
- $process_module = false;
- $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate
- FROM '.TABLE_PREFIX.'Category
- WHERE CategoryId = '.$category_id;
- $category_data = $this->Conn->GetRow($sql);
+ array_unshift($url_parts, $url_part);
+ return false;
+ }
- $root_category_id = array_shift( explode('|', substr($category_data['ParentPath'], 1, -1)) );
- $module_info = $this->Application->findModule('RootCat', $root_category_id);
- if ($module_info) {
- $module_prefix = $module_info['Var'];
- $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) );
- $this->Application->HandleEvent($module_event);
+ function ProcessPhisycalTemplate(&$url_parts)
+ {
+ if (!isset($url_parts[0])) return false;
- if ($module_event->status == erSUCCESS && $this->HTTPQuery->Get($module_prefix.'_id')) {
- $item_template = $category_data['CachedItemTemplate'];
- if ($item_template) {
- $url_parts = explode('/', $item_template);
- array_push($url_parts, $url_part); // save item's filename as not processed
- $url_part = array_shift($url_parts);
- }
- }
- elseif (!$module_event->getEventParam('url_parts')) {
- // parseEnv has processed that param
- $url_part = '';
- $category_template = $category_data['CachedCategoryTemplate'];
- if ($category_template) {
- $category_template = explode('/', $category_template);
- $url_part = array_shift($category_template);
- $url_parts = $category_template;
- }
- else {
- $url_part = 'index';
- }
- }
+ $remaining = array();
+ do
+ {
+ $template_path = implode('/', $url_parts);
+
+ $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path);
+ $t_parts['file'] = basename($template_path);
+
+ $sql = 'SELECT FileId
+ FROM '.TABLE_PREFIX.'ThemeFiles
+ WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')';
+
+// $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl');
+ $template_found = $this->Conn->GetOne($sql);
+ if(!$template_found)
+ {
+ array_unshift($remaining, array_pop($url_parts));
}
+ } while (!$template_found && $url_parts);
+
+ $url_parts = $remaining;
+
+ if ($template_found) {
+ $this->HTTPQuery->Set('t', $template_path );
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if whole url_parts matches a whole In-CMS page
+ *
+ * @param array $url_parts
+ * @return boolean
+ */
+ function ProcessVirtualTemplate(&$url_parts)
+ {
+ if (!isset($url_parts[0]) || !$this->Application->isModuleEnabled('In-CMS')) return false;
+
+ $template_path = implode('/', $url_parts);
+ $sql = 'SELECT p.PageId, ci.CategoryId FROM '.TABLE_PREFIX.'Pages AS p
+ LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci
+ ON ci.ItemResourceId = p.ResourceId
+ WHERE
+ Path = '.$this->Conn->qstr($template_path).'
+ AND
+ ci.PrimaryCat = 1';
+ $template_found = $this->Conn->GetRow($sql);
+
+ if ($template_found) {
+ $this->Application->SetVar('m_cat_id', $template_found['CategoryId']);
+ $this->HTTPQuery->Set('t', $template_path );
+ return true;
}
- // match module
+ return false;
+ }
+
+ function processRewriteURL()
+ {
+ $url = $this->HTTPQuery->Get('_mod_rw_url_');
+ if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 );
+ $url_parts = $url ? explode('/', $url) : Array();
+
+ $process_module = true;
+ if($this->HTTPQuery->Get('rewrite') == 'on' || !$url_parts)
+ {
+ $this->SetDefaultValues();
+ }
+
+ if(!$url_parts)
+ {
+ $this->Application->Phrases = new PhrasesCache();
+ $this->Application->VerifyLanguageId();
+ $this->Application->Phrases->Init('phrases');
+ $this->Application->VerifyThemeId();
+
+ $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate('') );
+ $this->HTTPQuery->finalizeParsing(Array('m'));
+ return false;
+ }
+ else
+ {
+ $this->HTTPQuery->Set('t', '');
+ }
+
+ $this->ProcessLanguage($url_parts);
+ $this->ProcessTheme($url_parts);
+
+ if ( $this->ProcessVirtualTemplate($url_parts) ) {
+ return true;
+ }
+
+ $this->ProcessCategory($url_parts);
+ if ( $this->ProcessModuleIndex($url_parts) ) {
+ return ;
+ }
+ if ( $this->ProcessModuleItem($url_parts) ) {
+ return ;
+ }
+
+ /*// match module
$next_template = $this->HTTPQuery->Get('next_template');
if($url_part || $next_template)
{
if($next_template)
{
$next_template_parts = explode('/', $next_template);
$module_folder = array_shift($next_template_parts);
}
else
{
$module_folder = $url_part;
}
foreach ($this->Application->ModuleInfo as $module_name => $module_data)
{
if( trim($module_data['TemplatePath'], '/') == $module_folder )
{
$module_prefix = $module_data['Var'];
break;
}
}
- }
-
- // match template
- $template_path = '';
- $template_found = false;
- if($url_part)
- {
- // search for template in real template records
- array_unshift($url_parts, $url_part);
- $template_parts = $url_parts;
- $url_parts = Array();
- do
- {
- $template_path = implode('/', $template_parts);
-
- $t_parts['path'] = dirname($template_path) == '.' ? '' : '/'.dirname($template_path);
- $t_parts['file'] = basename($template_path);
-
- $sql = 'SELECT FileId
- FROM '.TABLE_PREFIX.'ThemeFiles
- WHERE (FilePath = '.$this->Conn->qstr($t_parts['path']).') AND (FileName = '.$this->Conn->qstr($t_parts['file'].'.tpl').')';
-
- // $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl');
- $template_found = $this->Conn->GetOne($sql);
- if(!$template_found)
- {
- array_unshift( $url_parts, array_pop($template_parts) );
- }
-
- }while (!$template_found && $template_parts);
-
- // try to find template in virtual templates in case if such ability exists
- if ($this->Application->isModuleEnabled('In-CMS') && !$template_found) {
-
- $template_parts = $url_parts;
- $url_parts = Array();
- do
- {
- $template_path = implode('/', $template_parts);
-
- $sql = 'SELECT PageId FROM '.TABLE_PREFIX.'Pages WHERE Path = '.$this->Conn->qstr($template_path);
- $template_found = $this->Conn->GetOne($sql);
- if(!$template_found)
- {
- array_unshift( $url_parts, array_pop($template_parts) );
- }
-
- }while (!$template_found && $template_parts);
- }
- }
+ }*/
- // guess template if no existing template found
- if(!$template_found && isset($module_folder) && $module_folder)
- {
- // 1. try index template of module
- $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$module_folder.'/index.tpl');
- $template_found = $this->Conn->GetOne($sql);
- if($template_found)
- {
- $template_path = $module_folder.'/index';
- array_shift($url_parts);
- }
- else
- {
- // 2. return error template then
- $template_found = true;
- $template_path = $this->Application->ConfigValue('ErrorTemplate');
- if(!$template_path) $template_path = 'error_notfound';
-
- header('HTTP/1.0 404 Not Found');
+ if ( $this->ProcessPhisycalTemplate($url_parts) ) {
+ if (!$url_parts) {
+ return true;
}
}
- $this->HTTPQuery->Set('t', $this->HTTPQuery->getDefaultTemplate($template_found ? $template_path : '') );
-
// pass params left to module
$this->Application->Phrases->Init('phrases');
$passed = Array('m');
$module_params = Array();
if ( isset($module_prefix) ) {
$passed[] = $module_prefix;
$module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) );
if ($process_module) {
$this->Application->HandleEvent($module_event);
}
$item_id = $this->HTTPQuery->Get($module_prefix.'_id');
$module_params = Array($module_prefix.'_id' => $item_id ? $item_id : '0' );
if ($module_event->status == erFAIL) {
$not_found = $this->Application->ConfigValue('ErrorTemplate');
$this->HTTPQuery->Set('t', $not_found ? $not_found : 'error_notfound' );
}
}
$this->HTTPQuery->finalizeParsing($passed, $module_params);
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/general/helpers/mod_rewrite_helper.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/core/admin_templates/categories/categories_edit_properties.tpl
===================================================================
--- trunk/core/admin_templates/categories/categories_edit_properties.tpl (revision 5557)
+++ trunk/core/admin_templates/categories/categories_edit_properties.tpl (revision 5558)
@@ -1,64 +1,64 @@
<inp2:m_RequireLogin permissions="CATEGORY.VIEW"/>
<inp2:m_include t="incs/header" nobody="yes"/>
<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
<inp2:m_ParseBlock name="section_header" prefix="c" icon="icon46_catalog" module="in-portal" title="!la_title_Categories!"/>
<inp2:m_include t="categories/categories_tabs"/>
-
+
<inp2:m_ParseBlock name="blue_bar" prefix="c" title_preset="categories_properties" module="in-portal" icon="icon46_catalog"/>
<!-- 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('c','<inp2:c_SaveEvent/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('c','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('c', '<inp2:c_PrevId/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
go_to_id('c', '<inp2:c_NextId/>');
}
) );
-
+
a_toolbar.Render();
-
+
<inp2:m_if check="c_IsSingle">
a_toolbar.HideButton('prev');
a_toolbar.HideButton('next');
a_toolbar.HideButton('sep1');
- <inp2:m_else/>
+ <inp2:m_else/>
<inp2:m_if check="c_IsLast">
a_toolbar.DisableButton('next');
</inp2:m_if>
<inp2:m_if check="c_IsFirst">
a_toolbar.DisableButton('prev');
</inp2:m_if>
- </inp2:m_if>
+ </inp2:m_if>
</script>
</td>
</tr>
</tbody>
</table>
<inp2:c_SaveWarning name="grid_save_warning"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
- <inp2:m_ModuleInclude template="category_items" />
+ <inp2:m_ModuleInclude template="category_properties" />
</table>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: trunk/core/admin_templates/categories/categories_edit_properties.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property

Event Timeline