Index: trunk/core/kernel/processors/tag_processor.php
===================================================================
diff -u -r7933 -r8358
--- trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 7933)
+++ trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 8358)
@@ -147,7 +147,7 @@
}
return false;
}
- }
+}
/*class ProcessorsPool {
var $Processors = Array();
Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -r8178 -r8358
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8178)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8358)
@@ -1881,6 +1881,11 @@
return $this->Application->ProcessParsedTag('m', 't', $params);
}
+
+ function PresetFormFields($params)
+ {
+ $this->Application->HandleEvent( new kEvent($this->getPrefixSpecial().':OnNew') );
+ }
}
?>
\ No newline at end of file
Index: trunk/core/kernel/parser/template_parser.php
===================================================================
diff -u -r7635 -r8358
--- trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 7635)
+++ trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 8358)
@@ -27,6 +27,8 @@
var $DataExists = false;
+ var $FromPreParseCache = false;
+
function TemplateParser()
{
parent::kBase();
@@ -105,6 +107,7 @@
{
$this->Params[strtolower($name)] = $value;
$this->AddParam('/[{]{0,1}\$'.$name.'[}]{0,1}/i', $value, $this->FromPreParseCache);
+ $this->ParamsStack[$this->ParamsRecursionIndex][$name] = $value;
}
function SetBuffer($body)
@@ -639,7 +642,11 @@
if( !isset($pass_params['PrefixSpecial']) && isset($pass_params['prefix']) ) $pass_params['PrefixSpecial'] = $pass_params['prefix'];
$ret = $f($pass_params);
-
+
+ if (isset($params['return_params']) && $params['return_params']) {
+ $this->ParamsStack[$this->ParamsRecursionIndex - 1] = array_merge($this->ParamsStack[$this->ParamsRecursionIndex - 1], $this->ParamsStack[$this->ParamsRecursionIndex]);
+ }
+
unset($this->ParamsStack[$this->ParamsRecursionIndex--]);
$this->Params = $this->ParamsStack[$this->ParamsRecursionIndex];
$this->MainParser = true;
@@ -674,8 +681,10 @@
$template_name
);
}
+
$this->Application->Parser =& $this;
$this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
+
return $o;
}
Index: trunk/core/kernel/db/dbitem.php
===================================================================
diff -u -r8104 -r8358
--- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 8104)
+++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 8358)
@@ -939,9 +939,9 @@
$this->Fields[$field]['required'] = $is_required;
}
- function Clear()
+ function Clear($new_id = null)
{
- $this->setID(null);
+ $this->setID($new_id);
$this->Loaded = false;
$this->FieldValues = Array();
$this->SetDefaultValues();
Index: trunk/core/units/categories/categories_config.php
===================================================================
diff -u -r8082 -r8358
--- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 8082)
+++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 8358)
@@ -18,7 +18,7 @@
'QueryString' => Array(
1 => 'id',
- 2 => 'page',
+ 2 => 'Page',
3 => 'event',
4 => 'mode',
),
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r8178 -r8358
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8178)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8358)
@@ -1006,7 +1006,9 @@
function OnNew(&$event)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
- $object->setID(0);
+ /* @var $object kDBItem */
+
+ $object->Clear(0);
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
$table_info = $object->getLinkedInfo();
Index: trunk/themes/default2007/index.tpl
===================================================================
diff -u -r8249 -r8358
--- trunk/themes/default2007/index.tpl (.../index.tpl) (revision 8249)
+++ trunk/themes/default2007/index.tpl (.../index.tpl) (revision 8358)
@@ -1 +1,15 @@
-index page
\ No newline at end of file
+
+
+
+
+
+ Index Page
+
+
+
+
\ No newline at end of file
Index: trunk/core/units/categories/categories_tag_processor.php
===================================================================
diff -u -r7855 -r8358
--- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 7855)
+++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 8358)
@@ -4,14 +4,20 @@
function SubCatCount($params)
{
- $cat_object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
- $sql = ' SELECT COUNT(*) - 1
- FROM '.$cat_object->TableName.'
- WHERE ParentPath LIKE "'.$cat_object->GetDBField('ParentPath').'%"';
- if (isset($params['today'])) {
- $sql .= ' AND CreatedOn > '.(adodb_mktime()-86400);
+ $object =& $this->getObject($params);
+
+ $sql = 'SELECT COUNT(*)
+ FROM '.$object->TableName.'
+ WHERE ParentPath LIKE "'.$object->GetDBField('ParentPath').'%"';
+
+ if (isset($params['today']) && $params['today']) {
+ $sql .= ' AND CreatedOn > '.(adodb_mktime() - 86400);
}
- return $this->Conn->GetOne($sql);
+
+ if (!$this->Application->IsAdmin()) {
+ $sql .= ' AND Status = '.STATUS_ACTIVE;
+ }
+ return $this->Conn->GetOne($sql) - 1;
}
function IsNew($params)
@@ -510,10 +516,21 @@
function IsActive($params)
{
- $cat_id = $this->Application->GetVar('c_id');
- $current_cat = $this->getObject($params);
- $current_path = $current_cat->GetDBField('ParentPath');
+ $cat_id = isset($params['cat_id']) && $params['cat_id'] ? $params['cat_id'] : false;
+ if ($cat_id === false) {
+ // category not supplied -> get current from PrintList
+ $cat_id = $this->Application->GetVar($this->getPrefixSpecial().'_id');
+ $current_cat =& $this->getObject($params);
+ }
+ else {
+ if ("$cat_id" == 'Root') {
+ $cat_id = $this->Application->findModule('Name', $params['module'], 'RootCat');
+ }
+ $current_cat =& $this->Application->recallObject($this->Prefix.'.-c'.$cat_id, $this->Prefix, Array ('skip_autoload' => true));
+ $current_cat->Load($cat_id);
+ }
+ $current_path = $current_cat->GetDBField('ParentPath');
static $parent_path = null;
if (!isset($parent_path)) {
$parent_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId = '.$this->Application->GetVar('m_cat_id'));
Index: trunk/core/kernel/processors/main_processor.php
===================================================================
diff -u -r8178 -r8358
--- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 8178)
+++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 8358)
@@ -42,6 +42,15 @@
}
else {
$path = substr(THEMES_PATH, 1);
+ $module = isset($params['module']) ? $params['module'] : 'core';
+
+ if (strtolower($module) == 'in-portal') {
+ $module_folder = 'platform';
+ }
+ else {
+ $module_folder = $this->Application->findModule('Name', $module, 'TemplatePath');
+ }
+ $path .= '/'.trim($module_folder, '/').'/';
}
return $this->Application->BaseURL().$path;
}
@@ -547,6 +556,8 @@
function MyInclude($params)
{
$BlockParser =& $this->Application->makeClass('TemplateParser');
+ /* @var $BlockParser TemplateParser */
+
// $BlockParser->SetParams($params);
$parser =& $this->Application->Parser;
$this->Application->Parser =& $BlockParser;
@@ -563,21 +574,38 @@
trigger_error('Template name not specified in <inp2:m_include .../> tag', E_USER_ERROR);
}
- $res = $BlockParser->ParseTemplate( $t, 1, $params, isset($params['is_silent']) ? 1 : 0 );
-
+ if (isset($this->Application->PreParsedBlocks[$t]) ) {
+ $params['name'] = $t;
+ $res = $this->Application->ParseBlock($params);
+ }
+ else {
+ $res = $BlockParser->ParseTemplate($t, 1, $params, isset($params['is_silent']) ? 1 : 0 );
+ }
+
if ( !$BlockParser->DataExists && (isset($params['data_exists']) || isset($params['block_no_data'])) ) {
if ($block_no_data = getArrayValue($params, 'block_no_data')) {
- $res = $BlockParser->Parse(
- $this->Application->TemplatesCache->GetTemplateBody($block_no_data, getArrayValue($params, 'is_silent') ),
- $t
- );
+ if (isset($this->Application->PreParsedBlocks[$block_no_data]) ) {
+ // block_no_data is another block name
+ $res = $this->Application->ParseBlock(Array('name' => $block_no_data));
+ }
+ else {
+ // block_no_data is template name (only looks through real templates)
+ $res = $BlockParser->ParseTemplate($block_no_data, 1, Array(), getArrayValue($params, 'is_silent'));
+ }
}
else {
$res = '';
}
}
+
$this->Application->Parser =& $parser;
$this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
+
+ if (isset($params['return_params']) && $params['return_params']) {
+ $new_params = array_merge($this->Application->Parser->Params, $BlockParser->ParamsStack[0]);
+ $this->Application->Parser->SetParams($new_params, false);
+ }
+
return $res;
}
@@ -591,10 +619,10 @@
$module_key = strtolower($module_name);
if ($module_name == 'In-Portal') {
- $module_prefix = $this->Application->IsAdmin() ? 'in-portal/' : '';
+ $module_prefix = $this->Application->IsAdmin() ? 'in-portal/' : $module_data['TemplatePath'];
}
else {
- $module_prefix = $this->Application->IsAdmin() ? $module_key.'/' : $module_data['TemplatePath'].'/';
+ $module_prefix = $this->Application->IsAdmin() ? $module_key.'/' : rtrim($module_data['TemplatePath'], '/').'/';
}
$block_params['t'] = $module_prefix.$this->SelectParam($params, $module_key.'_template,'.$module_key.'_t,template,t');
@@ -689,15 +717,35 @@
function RenderElement($params)
{
+ if (isset($params['design']) && $params['design']) {
+ $block_name = $params['name'];
+ if ($block_name != '__this__') {
+ $block_params['name'] = $block_name;
+ $block_params['content'] = $this->MyInclude( Array('template' => $params['name'], 'return_params' => 1, 'strip_nl' => 2) );
+
+ if ( !$this->Application->Parser->DataExists && (isset($params['data_exists']) || isset($params['block_no_data'])) ) {
+ if ($block_no_data = getArrayValue($params, 'block_no_data')) {
+ $block_params['content'] = $this->MyInclude(Array('template' => $block_no_data));
+ }
+ else {
+ return '';
+ }
+ }
+ }
+
+ $block_params['name'] = $params['design'];
+ return $this->Application->ParseBlock($block_params, 1);
+ }
+
return $this->ParseBlock($params);
}
function RenderElements($params)
{
if (!isset($params['elements']) || !$params['elements']) return;
- $elements = explode(',',$params['elements']);
+ $elements = explode(',', $params['elements']);
if (isset($params['skip']) && $params['skip']) {
- $tmp_skip = explode(',',$params['skip']);
+ $tmp_skip = explode(',', $params['skip']);
foreach ($tmp_skip as $elem) {
$skip[] = trim($elem);
}
@@ -710,10 +758,10 @@
foreach ($elements as $an_element)
{
$cur = trim($an_element);
- if (in_array($cur,$skip)) continue;
+ if (in_array($cur,$skip) || !$cur) continue;
$pass_params = $params;
$pass_params['name'] = $cur;
- $o .= $this->ParseBlock($pass_params);
+ $o .= $this->RenderElement($pass_params);
}
return $o;
Index: trunk/core/kernel/parser/template.php
===================================================================
diff -u -r7635 -r8358
--- trunk/core/kernel/parser/template.php (.../template.php) (revision 7635)
+++ trunk/core/kernel/parser/template.php (.../template.php) (revision 8358)
@@ -39,7 +39,7 @@
function LoadTemplate($silent = 0)
{
$filename = $this->GetFullPath();
- if(file_exists($filename)) {
+ if (file_exists($filename)) {
if (filesize ($filename) == 0) {
trigger_error("Template file size is 0: $filename", ($silent ? E_USER_NOTICE : E_USER_ERROR) );
}
@@ -52,12 +52,12 @@
return true;
}
else {
- if ($silent != 2) {
+ if (($silent != 2) && !$silent) {
$application =& kApplication::Instance();
if ($application->isDebugMode()) {
$application->Debugger->appendTrace();
}
- trigger_error("File or block not found: $filename at ".$application->Parser->TemplateName, ($silent ? E_USER_NOTICE : E_USER_ERROR) );
+ trigger_error('File or block not found: '.$filename.' at '.$application->Parser->TemplateName, E_USER_ERROR);
}
return false;
}