Index: trunk/core/kernel/processors/main_processor.php
===================================================================
diff -u -N
--- trunk/core/kernel/processors/main_processor.php (revision 8924)
+++ trunk/core/kernel/processors/main_processor.php (revision 0)
@@ -1,1084 +0,0 @@
-Application->recallObject('kActions');
- $actions->Set('t', $this->Application->GetVar('t'));
- $actions->Set('sid', $this->Application->GetSID());
- $actions->Set('m_opener', $this->Application->GetVar('m_opener') );
- }
-
- /**
- * Used to handle calls where tag name
- * match with existing php function name
- *
- * @param Tag $tag
- * @return string
- */
- function ProcessTag(&$tag)
- {
- if ($tag->Tag=='include') $tag->Tag='MyInclude';
- return parent::ProcessTag($tag);
- }
-
- /**
- * Base folder for all template includes
- *
- * @param Array $params
- * @return string
- */
- function TemplatesBase($params)
- {
- if ($this->Application->IsAdmin()) {
- $module = isset($params['module']) ? $params['module'] : 'core';
- if ($module == 'in-portal') {
- $module = 'kernel';
- }
- $path = preg_replace('/\/(.*?)\/(.*)/', $module.'/\\2', THEMES_PATH); // remove leading slash + substitute module
- }
- 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;
- }
-
- /**
- * Creates
";
- }
- else
- echo "Object $name does not exist in the appliaction
";
- }*/
-
- /**
- * Tag, that always returns true.
- * For parser testing purposes
- *
- * @param Array $params
- * @return bool
- * @access public
- */
- function True($params)
- {
- return true;
- }
-
- /**
- * Tag, that always returns false.
- * For parser testing purposes
- *
- * @param Array $params
- * @return bool
- * @access public
- */
- function False($params)
- {
- return false;
- }
-
- /**
- * Returns block parameter by name
- *
- * @param Array $params
- * @return stirng
- * @access public
- */
- function Param($params)
- {
- //$parser =& $this->Application->recallObject('TemplateParser');
- $name = $params['name'];
- if (isset($this->Application->LateParsed[$name])) {
- $f = $this->Application->PreParsedBlocks['capture_'.$name.$this->Application->LateParsed[$name]];
- $this->Application->Parser->SetParam($name, $f(array()));
- }
-
- $res = $this->Application->Parser->GetParam($params['name']);
- if ($res === false) $res = '';
- if (isset($params['plus']))
- $res += $params['plus'];
- return $res;
- }
-
- function DefaultParam($params)
- {
- foreach ($params as $key => $val) {
- if ($this->Application->Parser->GetParam($key) === false) {
- $this->Application->Parser->SetParam($key, $val);
- }
- }
- }
-
- /**
- * Gets value of specified field from specified prefix_special and set it as parser param
- *
- * @param Array $params
- */
- /*function SetParam($params)
- {
- //
";
- $name = $params['name'];
- $value = $params['value'];
- $this->Application->StoreVar($name,$value);
- }
-
- /**
- * Sets application variable value(-s)
- *
- * @param Array $params
- * @access public
- */
- function Set($params)
- {
- foreach ($params as $param => $value) {
- $this->Application->SetVar($param, $value);
- }
- }
-
- /**
- * Increment application variable
- * specified by number specified
- *
- * @param Array $params
- * @access public
- */
- function Inc($params)
- {
- $this->Application->SetVar($params['param'], $this->Application->GetVar($params['param']) + $params['by']);
- }
-
- /**
- * Retrieves application variable
- * value by name
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function Get($params)
- {
- $ret = $this->Application->GetVar($this->SelectParam($params, 'name,var,param'), '');
- return getArrayValue($params, 'htmlchars') ? htmlspecialchars($ret) : $ret;
- }
-
- /**
- * Retrieves application constant
- * value by name
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function GetConst($params)
- {
- return defined($this->SelectParam($params, 'name,const')) ? constant($this->SelectParam($params, 'name,const,param')) : '';
- }
-
- /**
- * Retrieves configuration variable value by name
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function GetConfig($params)
- {
- $config_name = $this->SelectParam($params, 'name,var');
- $ret = $this->Application->ConfigValue($config_name);
- if( getArrayValue($params, 'escape') ) $ret = addslashes($ret);
- return $ret;
- }
-
- function ConfigEquals($params)
- {
- $option = $this->SelectParam($params, 'name,option,var');
- return $this->Application->ConfigValue($option) == getArrayValue($params, 'value');
- }
-
- /**
- * Creates all hidden fields
- * needed for kernel_form
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function DumpSystemInfo($params)
- {
- $actions =& $this->Application->recallObject('kActions');
- $actions->Set('t', $this->Application->GetVar('t') );
-
- $params = $actions->GetParams();
- $o='';
- foreach ($params AS $name => $val)
- {
- $o .= "\n";
- }
- return $o;
- }
-
- /**
- * Used for search sidebox on front-end only
- *
- * @param Array $params
- * @return string
- * @author Alex
- */
- function GetFormHiddens($params)
- {
- $t = $this->SelectParam($params, 'template,t');
- unset($params['template']);
-
- $form_fields = Array ();
- if ($this->Application->RewriteURLs()) {
- $session =& $this->Application->recallObject('Session');
- if ($session->NeedQueryString()) {
- $form_fields['sid'] = $this->Application->GetSID();
- }
- }
- else {
- $form_fields['env'] = $this->Application->BuildEnv($t, $params, 'm', null, false);
- }
-
- if ($this->Application->GetVar('admin') == 1) {
- $form_fields['admin'] = 1;
- }
-
- $ret = '';
- $field_tpl = ''."\n";
- foreach ($form_fields as $form_field => $field_value) {
- $ret .= sprintf($field_tpl, $form_field, $field_value);
- }
-
- return $ret;
- }
-
- function Odd_Even($params)
- {
- $odd = $params['odd'];
- $even = $params['even'];
- if (!isset($params['var'])) {
- $var = 'odd_even';
- }
- else {
- $var = $params['var'];
- }
-
- if ($this->Application->GetVar($var) == 'even') {
- if (!isset($params['readonly']) || !$params['readonly']) {
- $this->Application->SetVar($var, 'odd');
- }
- return $even;
- }
- else {
- if (!isset($params['readonly']) || !$params['readonly']) {
- $this->Application->SetVar($var, 'even');
- }
- return $odd;
- }
- }
-
- /**
- * Returns phrase translation by name
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function Phrase($params)
- {
- // m:phrase name="phrase_name" default="Tr-alala" updated="2004-01-29 12:49"
- if (array_key_exists('default', $params)) return $params['default']; //backward compatibility
- $translation = $this->Application->Phrase($this->SelectParam($params, 'label,name,title'));
-
- if (isset($params['escape']) && $params['escape']) {
- $translation = htmlspecialchars($translation, ENT_QUOTES);
- $translation = addslashes($translation);
- }
- return $translation;
- }
-
- // for tabs
- function is_active($params)
- {
- $test_templ = $this->SelectParam($params, 'templ,template,t');
- if ( !getArrayValue($params,'allow_empty') )
- {
- $if_true=getArrayValue($params,'true') ? $params['true'] : 1;
- $if_false=getArrayValue($params,'false') ? $params['false'] : 0;
- }
- else
- {
- $if_true=$params['true'];
- $if_false=$params['false'];
- }
-
- if ( preg_match("/^".str_replace('/', '\/', $test_templ)."/i", $this->Application->GetVar('t'))) {
- return $if_true;
- }
- else {
- return $if_false;
- }
- }
-
- function IsNotActive($params)
- {
- return !$this->is_active($params);
- }
-
- function IsActive($params)
- {
- return $this->is_active($params);
- }
-
- function is_t_active($params)
- {
- return $this->is_active($params);
- }
-
- function CurrentTemplate($params)
- {
- return $this->is_active($params);
- }
-
- /**
- * Checks if session variable
- * specified by name value match
- * value passed as parameter
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function RecallEquals($params)
- {
- $name = $this->SelectParam($params, 'name,var');
- $value = $params['value'];
- return ($this->Application->RecallVar($name) == $value);
- }
-
- /**
- * Checks if application variable
- * specified by name value match
- * value passed as parameter
- *
- * @param Array $params
- * @return bool
- * @access public
- */
- function GetEquals($params)
- {
- $name = $this->SelectParam($params, 'var,name,param');
- $value = $params['value'];
- if ($this->Application->GetVar($name) == $value) {
- return 1;
- }
- }
-
- /**
- * Includes template
- * and returns it's
- * parsed version
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function MyInclude($params)
- {
- if (defined('NPARSER') && NPARSER) {
- return $this->Application->Parser->IncludeTemplate($params, isset($params['is_silent']) ? 1 : 0);
- }
-
- $BlockParser =& $this->Application->makeClass('TemplateParser');
- /* @var $BlockParser TemplateParser */
-
-// $BlockParser->SetParams($params);
- $parser =& $this->Application->Parser;
- $this->Application->Parser =& $BlockParser;
-
- // this is for the parser to know the master template in case an error occurs,
- // ParseTemplate will reset it anyway, but this will allow error handler to display the tempalte
- // which tries to include missing template for example
- $this->Application->Parser->TemplateName = $parser->TemplateName;
-
- $t = $this->SelectParam($params, 't,template,block,name');
- $t = eregi_replace("\.tpl$", '', $t);
-
- if (!$t) {
- trigger_error('Template name not specified in <inp2:m_include .../> tag', E_USER_ERROR);
- }
-
- 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']) && $params['data_exists']) || isset($params['block_no_data']))) {
- if ($block_no_data = getArrayValue($params, 'block_no_data')) {
- 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;
- }
-
- function ModuleInclude($params)
- {
- $ret = '';
- $block_params = array_merge($params, Array('is_silent' => 2)); // don't make fatal errors in case if template is missing
- $current_template = $this->Application->GetVar('t');
- $skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array();
- foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
- $module_key = strtolower($module_name);
-
- if ($module_name == 'In-Portal') {
- $module_prefix = $this->Application->IsAdmin() ? 'in-portal/' : $module_data['TemplatePath'];
- }
- else {
- $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');
- if ($block_params['t'] == $current_template || in_array($module_data['Var'], $skip_prefixes)) continue;
-
- $no_data = $this->SelectParam($params, $module_key.'_block_no_data,block_no_data');
- if ($no_data) {
- $block_params['block_no_data'] = $module_prefix.'/'.$no_data;
- }
- $ret .= $this->MyInclude($block_params);
- }
- return $ret;
- }
-
- function ModuleEnabled($params)
- {
- return $this->Application->isModuleEnabled( $params['module'] );
- }
-
- /*function Kernel_Scripts($params)
- {
- return '';
- }*/
-
-
- /*function GetUserPermission($params)
- {
- // echo"GetUserPermission $params[name]";
- if ($this->Application->RecallVar('user_type') == 1)
- return 1;
- else {
- $perm_name = $params[name];
- $aPermissions = unserialize($this->Application->RecallVar('user_permissions'));
- if ($aPermissions)
- return $aPermissions[$perm_name];
- }
- }*/
-
-
- /**
- * Set's parser block param value
- *
- * @param Array $params
- * @access public
- */
- function AddParam($params)
- {
- $parser =& $this->Application->Parser; // recallObject('TemplateParser');
- foreach ($params as $param => $value) {
- $this->Application->SetVar($param, $value);
- $parser->SetParam($param, $value);
- $parser->AddParam('/\$'.$param.'/', $value);
- }
- }
-
- /*function ParseToVar($params)
- {
- $var = $params['var'];
- $tagdata = $params['tag'];
- $parser =& $this->Application->Parser; //recallObject('TemplateParser');
- $res = $this->Application->ProcessTag($tagdata);
-
- $parser->SetParam($var, $res);
- $parser->AddParam('/\$'.$var.'/', $res);
- return '';
- }*/
-
- /*function TagNotEmpty($params)
- {
- $tagdata = $params['tag'];
- $res = $this->Application->ProcessTag($tagdata);
- return $res != '';
- }*/
-
- /*function TagEmpty($params)
- {
- return !$this->TagNotEmpty($params);
- }*/
-
- /**
- * Parses block and returns result
- *
- * @param Array $params
- * @return string
- * @access public
- */
- function ParseBlock($params)
- {
- $parser =& $this->Application->Parser; // recallObject('TemplateParser');
- return $parser->ParseBlock($params);
- }
-
- function RenderElement($params)
- {
- if (isset($params['design']) && $params['design']) {
- $block_name = $params['name'];
- if ($block_name != '__this__') {
- // prepare content
- $block_params = $params;
- $block_params['template'] = $block_name;
- $block_params['return_params'] = 1;
- $block_params['strip_nl'] = 2;
- $block_content = $this->MyInclude($block_params);
-
- if (isset($params['data_exists']) && $params['data_exists'] && !$block_content) {
- return '';
- }
-
- // prepare design
- $block_params = Array (
- 'content' => $block_content,
- );
- }
-
- $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']);
- if (isset($params['skip']) && $params['skip']) {
- $tmp_skip = explode(',', $params['skip']);
- foreach ($tmp_skip as $elem) {
- $skip[] = trim($elem);
- }
- }
- else {
- $skip = array();
- }
- unset($params['elements']);
- $o = '';
- foreach ($elements as $an_element)
- {
- $cur = trim($an_element);
- if (in_array($cur,$skip) || !$cur) continue;
- $pass_params = $params;
- $pass_params['name'] = $cur;
- $o .= $this->RenderElement($pass_params);
- }
- return $o;
-
- }
-
- /**
- * Checks if debug mode is on
- *
- * @return bool
- * @access public
- */
- function IsDebugMode()
- {
- return $this->Application->isDebugMode();
- }
-
- function MassParse($params)
- {
- $qty = $params['qty'];
- $block = $params['block'];
- $mode = $params['mode'];
-
- $o = '';
- if ($mode == 'func') {
- $func = create_function('$params', '
- $o = \'