Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Wed, Jun 25, 3:56 AM

in-portal

Index: branches/unlabeled/unlabeled-1.12.8/core/kernel/processors/tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.12.8/core/kernel/processors/tag_processor.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.12.8/core/kernel/processors/tag_processor.php (revision 6100)
@@ -0,0 +1,174 @@
+<?php
+
+ class TagProcessor extends kBase {
+
+ /**
+ * Processes tag
+ *
+ * @param Tag $tag
+ * @return string
+ * @access public
+ */
+ function ProcessTag(&$tag)
+ {
+ return $this->ProcessParsedTag($tag->Tag, $tag->NP, $tag->getPrefixSpecial());
+
+ /*$Method=$tag->Tag;
+ if(method_exists($this, $Method))
+ {
+ //echo htmlspecialchars($tag->GetFullTag()).'<br>';
+ return $this->$Method($tag->NP);
+ }
+ else
+ {
+ if ($this->Application->hasObject('TagsAggregator')) {
+ $aggregator =& $this->Application->recallObject('TagsAggregator');
+ $tag_mapping = $aggregator->GetArrayValue($tag->Prefix, $Method);
+ if ($tag_mapping) {
+
+ $mapped_tag =& new Tag('', $this->Application->Parser);
+ $mapped_tag->CopyFrom($tag);
+ $mapped_tag->Processor = $tag_mapping[0];
+ $mapped_tag->Tag = $tag_mapping[1];
+ $mapped_tag->NP['PrefixSpecial'] = $tag->getPrefixSpecial();
+ $mapped_tag->RebuildTagData();
+ return $mapped_tag->DoProcessTag();
+ }
+ }
+ trigger_error('Tag '.$Method.' Undefined in '.get_class($this).'[Agregated Tag]:<br><b>'.$tag->RebuildTagData().'</b>',E_USER_WARNING);
+ return false;
+ }*/
+ }
+
+ function ProcessParsedTag($tag, $params, $prefix)
+ {
+ $Method = $tag;
+ if(method_exists($this, $Method))
+ {
+ if ($this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS')) {
+ $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix);
+ }
+
+ // pass_params for non ParseBlock tags :)
+ if (isset($params['pass_params']) && $params['pass_params']) {
+ $params = array_merge_recursive2($this->Application->Parser->Params, $params);
+ unset($params['pass_params']);
+ }
+
+ $backup_prefix = $this->Prefix;
+ $backup_special = $this->Special;
+
+ $ret = $this->$Method($params);
+
+ $this->Prefix = $backup_prefix;
+ $this->Special = $backup_special;
+
+ if (isset($params['js_escape']) && $params['js_escape']) {
+ $ret = str_replace('\'', '&#39;', $ret);
+ $ret = addslashes($ret);
+ $ret = str_replace(Array("\r", "\n"), Array('\r', '\n'), $ret);
+ }
+ if (isset($params['result_to_var'])) {
+ $this->Application->Parser->SetParam($params['result_to_var'], $ret);
+ $ret = '';
+ }
+ return $ret;
+ }
+ else
+ {
+ if ($this->Application->hasObject('TagsAggregator')) {
+ $aggregator =& $this->Application->recallObject('TagsAggregator');
+ $tmp = $this->Application->processPrefix($prefix);
+ $tag_mapping = $aggregator->GetArrayValue($tmp['prefix'], $Method);
+ if ($tag_mapping) {
+ $tmp = $this->Application->processPrefix($tag_mapping[0]);
+ $__tag_processor = $tmp['prefix'].'_TagProcessor';
+ $processor =& $this->Application->recallObject($__tag_processor);
+ $processor->Prefix = $tmp['prefix'];
+ $processor->Special = getArrayValue($tag_mapping, 2) ? $tag_mapping[2] : $tmp['special'];
+ $params['PrefixSpecial'] = $prefix;
+ $ret = $processor->ProcessParsedTag($tag_mapping[1], $params, $prefix);
+ if (isset($params['result_to_var'])) {
+ $this->Application->Parser->SetParam($params['result_to_var'], $ret);
+ $ret = '';
+ }
+ return $ret;
+ }
+ trigger_error('Tag <b>'.$Method.'</b> Undefined in '.get_class($this).'[Agregated Tag]:<br><b>'.$tag.'</b>', E_USER_WARNING);
+ }
+ trigger_error('Tag Undefined:<br><b>'.$prefix.':'.$tag.'</b>',E_USER_WARNING);
+ return false;
+ }
+ }
+
+
+ /**
+ * Not tag, method for parameter
+ * selection from list in this TagProcessor
+ *
+ * @param Array $params
+ * @param string $possible_names
+ * @return string
+ * @access public
+ */
+ function SelectParam($params, $possible_names)
+ {
+ if (!is_array($params)) return;
+ if (!is_array($possible_names))
+
+ $possible_names = explode(',', $possible_names);
+ foreach ($possible_names as $name)
+ {
+ if( isset($params[$name]) ) return $params[$name];
+ }
+ return false;
+ }
+ }
+
+/*class ProcessorsPool {
+ var $Processors = Array();
+ var $Application;
+ var $Prefixes = Array();
+ var $S;
+
+ function ProcessorsPool()
+ {
+ $this->Application =& KernelApplication::Instance();
+ $this->S =& $this->Application->Session;
+ }
+
+ function RegisterPrefix($prefix, $path, $class)
+ {
+ // echo " RegisterPrefix $prefix, $path, $class <br>";
+ $prefix_item = Array(
+ 'path' => $path,
+ 'class' => $class
+ );
+ $this->Prefixes[$prefix] = $prefix_item;
+ }
+
+ function CreateProcessor($prefix, &$tag)
+ {
+ // echo " prefix : $prefix <br>";
+ if (!isset($this->Prefixes[$prefix]))
+ $this->Application->ApplicationDie ("<b>Filepath and ClassName for prefix $prefix not defined while processing ".htmlspecialchars($tag->GetFullTag())."!</b>");
+ include_once($this->Prefixes[$prefix]['path']);
+ $ClassName = $this->Prefixes[$prefix]['class'];
+ $a_processor =& new $ClassName($prefix);
+ $this->SetProcessor($prefix, $a_processor);
+ }
+
+ function SetProcessor($prefix, &$a_processor)
+ {
+ $this->Processors[$prefix] =& $a_processor;
+ }
+
+ function &GetProcessor($prefix, &$tag)
+ {
+ if (!isset($this->Processors[$prefix]))
+ $this->CreateProcessor($prefix, $tag);
+ return $this->Processors[$prefix];
+ }
+}*/
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.12.8/core/kernel/processors/tag_processor.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.12
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline