示例#1
0
 public function testArrayPeek()
 {
     $array = ['test1', 'test2', 'test3'];
     // test array integrity
     $this->assertEquals('test3', array_peek($array));
     $this->assertEquals('test1', current($array));
 }
示例#2
0
/**
 * The parse_args() function pulls arguments out of the provided $argv
 * array and returns a more useful PHP array representation.
 *
 * @param array $argv to parse arguments from
 * @return array of arguments parsed from $argv
 */
function parse_args(&$argv)
{
    /**
     * @var array of "flag" names, that is arguments that just represent a toggle
     */
    $flags = array();
    /**
     * @var array of arguments passed to the script
     */
    $argv = (array) $argv;
    /**
     * @var array of "sanitized", collected arguments
     */
    $args = array();
    /**
     * Until we run out of $argv's...
     */
    while (current($argv) !== false) {
        /**
         * @var string $current argument
         */
        $current = current($argv);
        /**
         * If the $current argument is an attribute indicator, then the
         * proceeding argument should be the associated value, unless
         * its one of the $flags...
         */
        if (preg_match('/^--?/', $current)) {
            $next = array_peek($argv);
            if ($next === false or preg_match('/^--?/', array_peek($argv))) {
                array_push($flags, $current);
            }
            $value = in_array($current, $flags) ? true : next($argv);
            if (!is_bool($value) and isset($args[$current])) {
                $args[$current] = (array) $args[$current];
                array_push($args[$current], $value);
            } else {
                $args[$current] = $value;
            }
        } else {
            array_push($args, $current);
        }
        /**
         * Don't forget to advance your iterator...
         */
        next($argv);
    }
    // END while ($current)
    return $args;
}
 public function endVisitSet(SetCommand $x, Context $ctx)
 {
     try {
         $f = $x->getFieldDeclClass()->getField($x->getField());
         //$count = count($this->values);
         $value = array_pop($this->values);
         $instance = array_peek($this->values);
         //echo 'value = ' . var_export($value, true) . ' &instance = ' . var_export($instance, true) . '<br />';
         // TODO CommandSerializationUtil.getAccessor
         //assert($value != null);
         //echo 'end value (count=' . $count .')<br />';
         //Accessors::get($f->getType())->set($instance, $f, $value);
         $f->setValue($instance, $value);
         return;
     } catch (Exception $e) {
         throw new SerializationException('Unable to set field value ' . $e);
     }
 }
示例#4
0
 /**
  * Standard PHP XML parser function.
  *
  * @param  object			The parser object (same as 'this')
  */
 function endElement($parser)
 {
     $text = str_replace('\\n', chr(10), $this->text_so_far);
     $tag = array_pop($this->tag_stack);
     $attributes = array_pop($this->attribute_stack);
     switch (strtolower($tag)) {
         case 'qualify':
             array_pop($this->field_qualification_stack);
             break;
         case 'filter':
             break;
         default:
             if ($this->levels_from_filtered == 0) {
                 global $FIELD_RESTRICTIONS;
                 $qualifier = array_peek($this->field_qualification_stack);
                 if (!array_key_exists($qualifier, $FIELD_RESTRICTIONS)) {
                     $FIELD_RESTRICTIONS[$qualifier] = array();
                 }
                 $FIELD_RESTRICTIONS[$qualifier][] = array($tag, array_merge(array('embed' => $text), $attributes));
             }
             break;
     }
     if ($this->levels_from_filtered != 0) {
         $this->levels_from_filtered--;
     }
 }
示例#5
0
/**
 * XHTML-aware substring extraction. Note that it will strip images, linebreaks, rules, etc - it's intended really for inline XHTML.
 *
 * @param  string			The text to perform on.
 * @param  integer		The start position of the cut (HTML tags will be taken from before this though).
 * @param  ?integer		The length you want the concatenated text to be (NULL: go to end).
 * @param  boolean		Whether to do a substr based on literal position in XHTML, rather than based on number of visible characters.
 * @param  boolean		Whether to add ellipses.
 * @param  float			A fraction of the length we may exceed by in order to maintain grammar tolerance (finish sentences, finish paragraphs, finish the whole thing).
 * @return string			The result.
 */
function xhtml_substr($html, $from, $length = NULL, $literal_pos = false, $ellipses = false, $grammar_completeness_tolerance = 0.0)
{
    /* TESTS
    	$out='';
    	$out.=xhtml_substr('test',0,NULL).chr(10); //=test
    	$out.=xhtml_substr('test',0,4).chr(10); //=test
    	$out.=xhtml_substr('test',0,3).chr(10); //=tes
    	$out.=xhtml_substr('test',1,3).chr(10); //=est
    	$out.=xhtml_substr('test',1,2).chr(10); //=es
    	$out.=xhtml_substr('test',-3).chr(10); //=est
    	$out.=xhtml_substr('test',-2).chr(10); //=st
    	$out.=xhtml_substr('<i>test</i>',0,NULL).chr(10); //=<i>test</i>
    	$out.=xhtml_substr('<i>test</i>',0,4).chr(10); //=<i>test</i>
    	$out.=xhtml_substr('<i>test</i>',0,3).chr(10); //=<i>tes</i>
    	$out.=xhtml_substr('<i>test</i>',1,3).chr(10); //=<i>est</i>
    	$out.=xhtml_substr('<i>test</i>',1,2).chr(10); //=<i>es</i>
    	$out.=xhtml_substr('<i>test</i>',-3).chr(10); //=<i>est</i>
    	$out.=xhtml_substr('<i>test</i>',-2).chr(10); //=<i>st</i>
    	$out.=xhtml_substr('<a><br /><x><i foo="bar">test</i>',-2).chr(10); //=<a><x><i foo="bar">st</i></x></a>
    */
    $html = preg_replace('#<\\!--.*($|-->)#Us', '', $html);
    // Strip comments
    // Sort out the negative offset possibility
    if ($from < 0) {
        $from = strlen(strip_tags($html)) + $from;
        // Not perfectly accurate using strip_tags as it's a different algorithm - but close enough, considering all our XHTML is well formed anyway
    }
    $tag_stack = array();
    // A stack of simple tags (opening only, just the names), that we can search
    $current_tag = '';
    $in_tag = false;
    $in_entity = false;
    $in_tag_type = '';
    $real_from = 0;
    $_html_buildup = '';
    $html_buildup = array();
    // A stack of HTML tags we need from before we start our portion, to move us into the right tag context. None tags are thrown out.
    // Reset the character counter and pass through (part of) the entire text
    $c = 0;
    $total_length = strlen($html);
    $total_length_minus_one = $total_length - 1;
    $end_pos = is_null($length) ? $total_length : $from + $length;
    for ($i = 0; $i < $total_length; $i++) {
        // Load the current character and the next one if the string has not arrived at the last character
        $current_char = $html[$i];
        $next_char = $i < $total_length - 1 ? $html[$i + 1] : '';
        if ($in_entity) {
            if ($current_char == ';') {
                $in_entity = false;
            } else {
                if (preg_match('#[\\#\\w]#', $current_char) == 0) {
                    $in_entity = false;
                    $_html_buildup = preg_replace('#(.*)&#s', '${1}&amp;', $_html_buildup);
                    $i--;
                    continue;
                }
            }
            if (($literal_pos ? $i : $c) < $from || $real_from == 0 && $from != 0) {
                $_html_buildup .= $current_char;
            }
        } elseif ($in_tag) {
            if ($current_char == '/' && ($next_char == '>' || $current_tag == '')) {
                if ($current_tag == '') {
                    $in_tag_type = 'CLOSE';
                } else {
                    $in_tag_type = 'SELF_CLOSE';
                }
            } elseif ($current_char == '>') {
                $in_tag = false;
                if ($in_tag_type == 'OPEN' || $in_tag_type == '') {
                    if ($current_tag != '!--') {
                        if ($grammar_completeness_tolerance != 0.0 && _smart_grammar_says_futile($end_pos, $grammar_completeness_tolerance, $i + 1, $html, $length)) {
                            // Force termination
                            $length = 0;
                            $end_pos = 0;
                        }
                        if ($current_tag != 'br' && $current_tag != 'img' && $current_tag != 'hr') {
                            // A little sanity checking, for HTML used as XHTML
                            $tag_stack[] = $current_tag;
                        }
                    }
                } elseif ($in_tag_type == 'CLOSE') {
                    if (@$tag_stack[count($tag_stack) - 1] == $current_tag) {
                        array_pop($tag_stack);
                    } else {
                        $reverse_tag_stack = array_reverse($tag_stack);
                        foreach ($reverse_tag_stack as $rti => $rtt) {
                            if ($rtt == $current_tag) {
                                unset($reverse_tag_stack[$rti]);
                                $tag_stack = array_reverse($reverse_tag_stack);
                                break;
                            }
                        }
                    }
                } elseif ($in_tag_type == 'SELF_CLOSE') {
                    if ($grammar_completeness_tolerance != 0.0 && _smart_grammar_says_futile($end_pos, $grammar_completeness_tolerance, $i + 1, $html, $length)) {
                        // Force termination
                        $length = 0;
                        $end_pos = 0;
                    }
                }
            } elseif (trim($current_char) == '') {
                $in_tag_type = 'OPEN';
            } elseif ($in_tag_type == '' || $in_tag_type == 'CLOSE') {
                $current_tag .= $current_char;
            }
            if (($literal_pos ? $i : $c) < $from || $real_from == 0 && $from != 0) {
                $_html_buildup .= $current_char;
                if (!$in_tag) {
                    if ($in_tag_type == 'CLOSE' && @$html_buildup[count($html_buildup) - 1][0] == $current_tag) {
                        array_pop($html_buildup);
                    } elseif ($in_tag_type != 'SELF_CLOSE') {
                        $html_buildup[] = array($current_tag, $_html_buildup);
                    }
                }
            }
        } else {
            if ($current_char == '&') {
                $in_entity = true;
                $_html_buildup = '';
                if (($literal_pos ? $i : $c) < $from || $real_from == 0 && $from != 0) {
                    $_html_buildup .= $current_char;
                }
                $c++;
            } elseif ($current_char == '<' && $next_char == '!' && substr($html, $i, 9) == '<![CDATA[') {
                $close = strpos($html, '//]]>', $i);
                if ($close !== false) {
                    $i = $close + 4;
                } else {
                    $i = $total_length;
                }
            } elseif ($current_char == '<') {
                $in_tag = true;
                $in_tag_type = '';
                $current_tag = '';
                $_html_buildup = '';
                if (($literal_pos ? $i : $c) < $from || $real_from == 0 && $from != 0) {
                    $_html_buildup .= $current_char;
                }
            } else {
                if ($real_from == 0) {
                    if ($literal_pos) {
                        // Optimisation: jump forwards as far as non-interesting
                        $jump_max_a = strpos($html, '<', $i);
                        if ($jump_max_a === false) {
                            $jump_max_a = $from;
                        } else {
                            $jump_max_a--;
                        }
                        $jump_max_b = strpos($html, '&', $i);
                        if ($jump_max_b === false) {
                            $jump_max_b = $from;
                        } else {
                            $jump_max_b--;
                        }
                        $jump_max_c = $from;
                        $min = min($jump_max_a, $jump_max_b, $jump_max_c);
                        $dif = $min - $i;
                        if ($dif > 0) {
                            $i = $min;
                            $c += $dif;
                        }
                    }
                    // We've not reached our length yet but we have JUST reached a usable from. Set real_from  (by doing it here we make sure we don't crop from inside an entity or tag)
                    if (($literal_pos ? $i : $c) >= $from && $from != 0) {
                        $real_from = $i;
                    }
                }
                $c++;
            }
        }
        // Check if the counter has reached the minimum length yet, then wait for the tag_counter to become 0, and chop the string there
        $ord = ord($current_char);
        if (!$in_tag && !$in_entity && !($ord >= 192 && $ord <= 223) && ($literal_pos ? $i : $c) >= $end_pos && ($grammar_completeness_tolerance == 0.0 || !_smart_grammar_says_continue($end_pos, $grammar_completeness_tolerance, $i, $html, $length)) || $i == $total_length_minus_one) {
            $entity = '&hellip;';
            if (function_exists('ocp_mark_as_escaped')) {
                ocp_mark_as_escaped($entity);
            }
            if ($real_from == 0 && $from != 0) {
                $html_buildup = array();
            }
            $new_html = '';
            if ($ellipses) {
                $start_ellipses = $from > 0 ? $entity : '';
            } else {
                $start_ellipses = '';
            }
            if ($ellipses) {
                $end_ellipses = !is_null($length) && $end_pos < $total_length - 1 ? $entity : '';
            } else {
                $end_ellipses = '';
            }
            $no_text_inside = array('tr', 'thead', 'colgroup', 'table', 'ul', 'ol', 'dl', 'dir', 'menu', 'applet', 'param', 'embed', 'object', 'legend', 'select', 'tfoot', 'ruby');
            if (in_array(array_peek($tag_stack), $no_text_inside)) {
                $new_html = rtrim($new_html) . $start_ellipses;
                $start_ellipses = '';
            }
            foreach ($html_buildup as $details) {
                $new_html .= $details[1];
            }
            $new_html = rtrim($new_html) . $start_ellipses;
            $main_portion = substr($html, $real_from, $i - $real_from + 1);
            $new_html .= $main_portion;
            if (!in_array(array_peek($tag_stack), $no_text_inside)) {
                $new_html = rtrim($new_html) . $end_ellipses;
                $end_ellipses = '';
            }
            foreach (array_reverse($tag_stack) as $tag) {
                $new_html .= '</' . $tag . '>';
            }
            // Shall we back-track a bit to stop cutting up a word?
            $backtrack = strrpos($new_html, ' ');
            $backtrack_safety = strrpos($new_html, '>');
            if ($current_char != ' ' && $grammar_completeness_tolerance != 0.0 && $backtrack !== false && floatval(strlen($new_html) - $backtrack) < $grammar_completeness_tolerance * strlen($new_html) && ($backtrack_safety === false || $backtrack > $backtrack_safety)) {
                $new_html = substr($new_html, 0, $backtrack);
            }
            $new_html = rtrim($new_html) . $end_ellipses;
            $new_html = preg_replace('#<!--.*(-->|$)#Us', '', $new_html);
            // Our algorithm doesn't handle comments so we need to be slightly clever about it
            $new_html = preg_replace('#<script.*</script>#Us', '', $new_html);
            // ... and also script/CDATA stuff, due to problems in XHTML/HTML incompatibility bypass techniques that use character data (which we skip)
            // Remove some empty tags that shouldn't be empty (e.g. td)
            $may_not_be_empty = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote', 'pre', 'br', 'hr', 'fieldset', 'address', 'noscript', 'table', 'tbody', 'tfoot', 'thead', 'tr', 'dd', 'dt', 'dl', 'li', 'ol', 'ul', 'rbc', 'rtc', 'rb', 'rt', 'rp', 'span', 'abbr', 'acronym', 'cite', 'code', 'dfn', 'em', 'strong', 'kbd', 'q', 'samp', 'var', 'sub', 'sup', 'tt', 'del', 'ruby', 'bdo', 'img', 'ins', 'param', 'input', 'select', 'object', 'caption', 'label', 'b', 'i', 'small', 'big', 'base', 'body', 'col', 'colgroup', 'map', 'optgroup', 'option', 'legend', 'area', 'form');
            foreach ($may_not_be_empty as $t) {
                $new_html = preg_replace('#<' . $t . '>\\s*</' . $t . '>#', '', $new_html);
            }
            if ($ellipses) {
                $new_html = str_replace(array('</p>' . $entity, '</div>' . $entity), array($entity . '</p>', $entity . '</div>'), $new_html);
            }
            return $new_html;
        }
    }
    return $html;
    // Should never get here
}
示例#6
0
 private function processToken($token)
 {
     if ($token === '') {
         return '';
     }
     $nest_lang = array_peek($this->_states);
     if (array_key_exists($nest_lang, $this->_postProcessors)) {
         return $this->_postProcessors[$nest_lang]->render($token);
     } else {
         #return self::htmlentities($token);
         return htmlspecialchars($token, ENT_NOQUOTES);
     }
 }
 private function commit(RpcCommand $x, $send = true)
 {
     if (array_pop($this->stack) !== $x) {
         throw new IllegalStateException('Did not pop expected command');
     }
     $x->clear();
     $sb = $this->commandBuffers->remove($x);
     assert(!is_null($sb));
     if (!empty($this->stack)) {
         $this->currentBuffer = $this->commandBuffers->get(array_peek($this->stack));
         assert(!is_null($this->currentBuffer));
     } else {
         $this->currentBuffer = null;
     }
     if ($send) {
         try {
             $this->parent->send($sb);
         } catch (SerializationException $e) {
             error_log($e->getMessage());
             exit(-1);
         }
     } else {
         $this->pushBuffer($sb);
     }
 }
示例#8
0
 /**
  * Parse the complete text of the inside of the tag.
  *
  * @param  object			The parser object (same as 'this')
  * @param  string			The text
  */
 function trueStartText($parser, $data)
 {
     unset($parser);
     $prelast_tag = array_peek($this->tag_stack, 2);
     $last_tag = array_peek($this->tag_stack);
     $attributes = array_peek($this->attribute_stack);
     switch ($this->type) {
         case 'RSS':
             switch ($prelast_tag) {
                 case 'CHANNEL':
                     switch ($last_tag) {
                         // dc namespace
                         case 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/:PUBLISHER':
                             $this->gleamed_feed['author'] = $data;
                             break;
                         case 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/:CREATOR':
                             $this->gleamed_feed['author_email'] = $data;
                             break;
                         case 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/:RIGHTS':
                             $this->gleamed_feed['copyright'] = $data;
                             break;
                         case 'TITLE':
                             $this->gleamed_feed['title'] = $data;
                             break;
                         case 'LINK':
                             $this->gleamed_feed['url'] = $data;
                             break;
                         case 'DESCRIPTION':
                             if ($this->version == '0.90' || $this->version == '0.91' || $this->version == '0.94' && $attributes['type'] != 'text/html') {
                                 $data = str_replace("\n", '<br />', escape_html($data));
                             }
                             $this->gleamed_feed['description'] = $data;
                             break;
                         case 'COPYRIGHT':
                             if (strpos($data, '(C)') !== false) {
                                 $data2 = preg_replace_callback('(http://[^, \\)]+[^\\. ])', 'extract_plain_links', escape_html($data));
                                 $data2 = str_replace('(C)', '&copy;', $data2);
                             } else {
                                 $data2 = $data;
                             }
                             $this->gleamed_feed['copyright'] = $data2;
                             break;
                         case 'MANAGINGEDITOR':
                             $bracket = strpos($data, '(');
                             if ($bracket !== false) {
                                 $bracket2 = strrpos(substr($data, $bracket), ')') + $bracket;
                                 if ($bracket2 === false) {
                                     $bracket2 = $bracket;
                                 }
                                 $this->gleamed_feed['author'] = substr($data, $bracket + 1, $bracket2 - $bracket - 1);
                                 $this->gleamed_feed['author_email'] = substr($data, 0, $bracket);
                             } else {
                                 $this->gleamed_feed['author_email'] = $data;
                             }
                             break;
                         case 'CLOUD':
                             $cloud = array();
                             $cloud['domain'] = $attributes['DOMAIN'];
                             $cloud['port'] = $attributes['PORT'];
                             $cloud['path'] = $attributes['PATH'];
                             $cloud['registerProcedure'] = $attributes['REGISTERPROCEDURE'];
                             $cloud['protocol'] = $attributes['PROTOCOL'];
                             $this->gleamed_feed['cloud'] = $cloud;
                             break;
                     }
                     break;
                 case 'ITEM':
                     $current_item =& $this->gleamed_items[count($this->gleamed_items) - 1];
                     switch ($last_tag) {
                         // dc namespace
                         case 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/:CREATOR':
                             $current_item['author'] = $data;
                             break;
                         case 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/:SUBJECT':
                             $current_item['category'] = $data;
                             break;
                         case 'HTTP://PURL.ORG/DC/ELEMENTS/1.1/:DATE':
                             $a = cleanup_date($data);
                             $current_item['add_date'] = $a[0];
                             if (array_key_exists(1, $a)) {
                                 $current_item['clean_add_date'] = $a[1];
                             }
                             break;
                         case 'HTTP://PURL.ORG/RSS/1.0/MODULES/CONTENT/:ENCODED':
                             $current_item['news'] = $data;
                             if (preg_match('#[<>]#', $current_item['news']) == 0 && preg_match('#[<>]#', html_entity_decode($current_item['news'], ENT_QUOTES)) != 0) {
                                 // Double escaped HTML
                                 $current_item['news'] = @html_entity_decode($current_item['news'], ENT_QUOTES);
                             } elseif (preg_match('#&(?!amp;)#', $current_item['news']) == 0 && preg_match('#&#', html_entity_decode($current_item['news'], ENT_QUOTES)) != 0) {
                                 // Double escaped HTML
                                 $current_item['news'] = @html_entity_decode($current_item['news'], ENT_QUOTES);
                             }
                             if (preg_match('#^http://ocportal.com/#', $this->feed_url) == 0) {
                                 require_code('xhtml');
                                 $current_item['news'] = xhtmlise_html($current_item['news']);
                             }
                             break;
                             // slash namespace
                         // slash namespace
                         case 'HTTP://PURL.ORG/RSS/1.0/modules/slash:SECTION':
                             $current_item['category'] = $data;
                             break;
                         case 'TITLE':
                             $current_item['title'] = $data;
                             if (preg_match('#[<>]#', $current_item['title']) == 0 && preg_match('#[<>]#', html_entity_decode($current_item['title'], ENT_QUOTES)) != 0) {
                                 // Double escaped HTML
                                 $current_item['title'] = @html_entity_decode($current_item['title'], ENT_QUOTES);
                             } elseif (preg_match('#&(?!amp;)#', $current_item['title']) == 0 && preg_match('#&#', html_entity_decode($current_item['title'], ENT_QUOTES)) != 0) {
                                 // Double escaped HTML
                                 $current_item['title'] = @html_entity_decode($current_item['title'], ENT_QUOTES);
                             }
                             if (preg_match('#^http://ocportal.com/#', $this->feed_url) == 0) {
                                 require_code('xhtml');
                                 $current_item['title'] = xhtmlise_html($current_item['title']);
                             }
                             break;
                         case 'DESCRIPTION':
                             //echo "here";exit();
                             $current_item['news'] = $data;
                             if (preg_match('#[<>]#', $current_item['news']) == 0 && preg_match('#[<>]#', html_entity_decode($current_item['news'], ENT_QUOTES)) != 0) {
                                 // Double escaped HTML
                                 $current_item['news'] = @html_entity_decode($current_item['news'], ENT_QUOTES);
                             } elseif (preg_match('#&(?!amp;)#', $current_item['news']) == 0 && preg_match('#&#', html_entity_decode($current_item['news'], ENT_QUOTES)) != 0) {
                                 // Double escaped HTML
                                 $current_item['news'] = @html_entity_decode($current_item['news'], ENT_QUOTES);
                             } elseif (strpos($current_item['news'], '>') === false) {
                                 $current_item['news'] = nl2br(escape_html($current_item['news']));
                             }
                             if (preg_match('#^http://ocportal.com/#', $this->feed_url) == 0) {
                                 require_code('xhtml');
                                 $current_item['news'] = xhtmlise_html($current_item['news']);
                             }
                             break;
                         case 'PUBDATE':
                             $a = cleanup_date($data);
                             $current_item['add_date'] = $a[0];
                             if (array_key_exists(1, $a)) {
                                 $current_item['clean_add_date'] = $a[1];
                             }
                             break;
                         case 'LINK':
                             $current_item['full_url'] = $data;
                             break;
                         case 'AUTHOR':
                             $bracket = strpos($data, '(');
                             if ($bracket !== false) {
                                 $bracket2 = strpos($data, ')', $bracket);
                                 $current_item['author'] = substr($data, $bracket + 1, $bracket2 - $bracket - 1);
                                 $current_item['author_email'] = rtrim(substr($data, 0, $bracket));
                             } else {
                                 $current_item['author_email'] = $data;
                             }
                             if ($current_item['author_email'] == get_option('staff_address')) {
                                 unset($current_item['author_email']);
                             }
                             break;
                         case 'CATEGORY':
                             $current_item['category'] = $data;
                             break;
                         case 'SOURCE':
                             $current_item['author'] = $data;
                             break;
                         case 'COMMENTS':
                             $current_item['comment_url'] = $data;
                             break;
                         case 'GUID':
                             if (!array_key_exists('ISPERMALINK', $attributes) || $attributes['ISPERMALINK'] == 'true') {
                                 $current_item['guid'] = $data;
                             }
                             break;
                     }
                     break;
             }
             break;
         case 'ATOM':
             if (array_key_exists('TYPE', $attributes)) {
                 $type = str_replace('text/', '', $attributes['TYPE']);
             } else {
                 $type = 'plain';
             }
             if (array_key_exists('MODE', $attributes)) {
                 $mode = $attributes['MODE'];
             } else {
                 $mode = 'xml';
             }
             if ($mode == 'BASE64') {
                 $data = base64_decode($data);
             }
             if (function_exists('xml_set_start_namespace_decl_handler')) {
                 $prefix = 'HTTP://PURL.ORG/ATOM/NS#:';
             } else {
                 $prefix = '';
             }
             if (!is_null($prelast_tag)) {
                 $prelast_tag = str_replace('HTTP://WWW.W3.ORG/2005/ATOM:', $prefix, $prelast_tag);
             }
             $last_tag = str_replace('HTTP://WWW.W3.ORG/2005/ATOM:', $prefix, $last_tag);
             switch ($prelast_tag) {
                 case $prefix . 'AUTHOR':
                     $preprelast_tag = array_peek($this->tag_stack, 3);
                     switch ($preprelast_tag) {
                         case $prefix . 'FEED':
                             switch ($last_tag) {
                                 case $prefix . 'NAME':
                                     $this->gleamed_feed['author'] = $data;
                                     break;
                                 case $prefix . 'URL':
                                     $this->gleamed_feed['author_url'] = $data;
                                     break;
                                 case $prefix . 'EMAIL':
                                     $this->gleamed_feed['author_email'] = $data;
                                     break;
                             }
                             break;
                         case $prefix . 'ENTRY':
                             $current_item =& $this->gleamed_items[count($this->gleamed_items) - 1];
                             switch ($last_tag) {
                                 case $prefix . 'NAME':
                                     $current_item['author'] = $data;
                                     break;
                                 case $prefix . 'URL':
                                     $current_item['author_url'] = $data;
                                     break;
                                 case $prefix . 'EMAIL':
                                     $current_item['author_email'] = $data;
                                     break;
                             }
                             break;
                     }
                 case $prefix . 'FEED':
                     switch ($last_tag) {
                         case $prefix . 'TITLE':
                             $this->gleamed_feed['title'] = $data;
                             break;
                         case $prefix . 'LINK':
                             $rel = array_key_exists('REL', $attributes) ? $attributes['REL'] : 'alternate';
                             if ($rel == 'alternate') {
                                 $this->gleamed_feed['url'] = array_key_exists('HREF', $attributes) ? $attributes['HREF'] : $data;
                             }
                             break;
                         case $prefix . 'UPDATED':
                             $a = cleanup_date($data);
                             $current_item['edit_date'] = $a[0];
                             if (array_key_exists(1, $a)) {
                                 $current_item['clean_edit_date'] = $a[1];
                             }
                             break;
                         case $prefix . 'MODIFIED':
                             $a = cleanup_date($data);
                             $current_item['edit_date'] = $a[0];
                             if (array_key_exists(1, $a)) {
                                 $current_item['clean_edit_date'] = $a[1];
                             }
                             break;
                         case $prefix . 'RIGHTS':
                             $this->gleamed_feed['copyright'] = $data;
                             break;
                         case $prefix . 'COPYRIGHT':
                             $this->gleamed_feed['copyright'] = $data;
                             break;
                         case $prefix . 'SUBTITLE':
                             $this->gleamed_feed['description'] = $data;
                             break;
                         case $prefix . 'TAGLINE':
                             $this->gleamed_feed['description'] = $data;
                             break;
                     }
                     break;
                 case $prefix . 'ENTRY':
                     $current_item =& $this->gleamed_items[count($this->gleamed_items) - 1];
                     switch ($last_tag) {
                         case $prefix . 'TITLE':
                             $current_item['title'] = $data;
                             break;
                         case $prefix . 'LINK':
                             if (!array_key_exists('REL', $attributes) || $attributes['REL'] == 'alternate') {
                                 $current_item['full_url'] = array_key_exists('HREF', $attributes) ? $attributes['HREF'] : $data;
                             }
                             break;
                         case $prefix . 'MODIFIED':
                         case $prefix . 'UPDATED':
                             $a = cleanup_date($data);
                             $current_item['edit_date'] = $a[0];
                             if (array_key_exists(1, $a)) {
                                 $current_item['clean_edit_date'] = $a[1];
                             }
                             break;
                         case $prefix . 'PUBLISHED':
                         case $prefix . 'ISSUED':
                             $a = cleanup_date($data);
                             $current_item['add_date'] = $a[0];
                             if (array_key_exists(1, $a)) {
                                 $current_item['clean_add_date'] = $a[1];
                             }
                             break;
                         case $prefix . 'ID':
                             $current_item['guid'] = $data;
                             break;
                         case $prefix . 'SUMMARY':
                             if ($type != 'html') {
                                 $data = str_replace("\n", '<br />', $data);
                             }
                             $current_item['news'] = $data;
                             if (preg_match('#^http://ocportal.com/#', $this->feed_url) == 0) {
                                 require_code('xhtml');
                                 $current_item['news'] = xhtmlise_html($current_item['news']);
                             }
                             break;
                         case $prefix . 'CONTENT':
                             if ($type != 'html') {
                                 $data = str_replace("\n", '<br />', $data);
                             }
                             $current_item['news_article'] = $data;
                             if (preg_match('#^http://ocportal.com/#', $this->feed_url) == 0) {
                                 require_code('xhtml');
                                 $current_item['news_article'] = xhtmlise_html($current_item['news_article']);
                             }
                             break;
                         case $prefix . 'CATEGORY':
                             if ($data == '' && array_key_exists('TERM', $attributes)) {
                                 $data = $attributes['TERM'];
                             }
                             if ($data != '' && strpos($data, '#') === false) {
                                 if (array_key_exists('category', $current_item)) {
                                     if (!array_key_exists('extra_categories', $current_item)) {
                                         $current_item['extra_categories'] = array();
                                     }
                                     $current_item['extra_categories'][] = $data;
                                 } else {
                                     $current_item['category'] = $data;
                                 }
                             }
                             if (array_key_exists('TERM', $attributes) && strpos($attributes['TERM'], 'post') === false && strpos($attributes['TERM'], '://') !== false) {
                                 $current_item['bogus'] = true;
                             }
                             break;
                         case 'HTTP://SEARCH.YAHOO.COM/MRSS/:THUMBNAIL':
                             if (array_key_exists('URL', $attributes)) {
                                 $current_item['rep_image'] = $attributes['URL'];
                             }
                             break;
                     }
                     break;
             }
             break;
     }
 }
 /**
  * Insert closing tags until a tag with the specified name is encountered.
  * If the given tag is not found at all then all tags will be closed.
  *
  * The follwing $options are available:
  * - __excludeTag:__ do not close the given tag itself (default: false)
  * - __maxCount:__ close at most this number of tags (default: PHP_INT_MAX)
  *
  * __Examples__:
  *
  *     $builder = new SimpleHTMLBuilder();
  *     $builder->body()->div()->closeUntil('body');
  *     // <body><div></div></body>
  *
  *     $builder = new SimpleHTMLBuilder();
  *     $builder->body()->div()->closeUntil('body', array('excludeTag' => true));
  *     // <body><div></div>
  *
  *     $builder = new SimpleHTMLBuilder();
  *     $builder->body()->div()->div()->closeUntil('body', array('maxCount' => 2));
  *     // <body><div><div></div></div>
  *
  *     $builder = new SimpleHTMLBuilder();
  *     $builder->body()->div()->closeUntil('html');
  *     // <body><div></div></body>
  *
  * @returns reference to $this
  */
 public function &closeUntil($tagName, $options = array())
 {
     static $defaultOptions = array('excludeTag' => false, 'maxCount' => PHP_INT_MAX);
     $options = array_merge($defaultOptions, $options);
     $numClosed = 0;
     $maxCount = $options['maxCount'];
     while (count($this->elementStack) > 0 && $numClosed < $maxCount && array_peek($this->elementStack)['name'] != $tagName) {
         $this->closeSingle();
         $numClosed++;
     }
     if (!$options['excludeTag'] && $numClosed < $maxCount && array_peek($this->elementStack)['name'] == $tagName) {
         $this->closeSingle();
     }
     return $this;
 }
示例#10
0
 /**
  * Parse the complete text of the inside of the tag.
  *
  * @param  object			The parser object (same as 'this')
  * @param  tempcode		Tempcode from child elements
  * @param  array			A map containing arrays of tempcode from child elements indexed under element name
  * @return array			A pair: The resultant tempcode. Whether the resultant tempcode is aggregated with neighbours.
  */
 function convertFinalisedElement($parser, $child_tempcode, $special_child_elements)
 {
     $this->marker = xml_get_current_byte_index($parser);
     global $VALID_COMCODE_TAGS, $COMCODE_XML_PARAM_RENAMING, $COMCODE_XML_SWITCH_AROUND;
     $conflict_tags = array('br', 'hr', 'table', 'tr', 'th', 'td');
     $aux_tags = array('html_wrap', 'comcode', 'br', 'hr', 'table', 'tr', 'th', 'td', 'float', 'fh', 'fd', 'emoticon', 'member', 'cedi', 'list', 'list_element', 'concepts', 'show_concept', 'block', 'block_param', 'random', 'random_target', 'jumping', 'jumping_target', 'shocker', 'shocker_left', 'shocker_right', 'directive', 'language', 'symbol', 'directive_param', 'language_param', 'symbol_param', 'attachment', 'attachment_description', 'hide', 'hide_title', 'tooltip', 'tooltip_message');
     // Tidy up tag name
     $namespace = array_peek($this->namespace_stack);
     if (is_null($namespace)) {
         $namespace = '';
     }
     $tag = array_peek($this->tag_stack);
     $colon_pos = strrpos($tag, ':');
     if ($colon_pos !== false) {
         $namespace = substr($tag, 0, $colon_pos);
         $tag = substr($tag, $colon_pos + 1);
     }
     $tag = from_camelCase($tag);
     // Tidy up attributes
     $attributes = array_peek($this->attribute_stack);
     foreach ($COMCODE_XML_PARAM_RENAMING as $_tag => $comcode_xml_name) {
         if ($tag == $_tag && isset($attributes[$comcode_xml_name])) {
             $attributes['param'] = $attributes[$comcode_xml_name];
             unset($attributes[$comcode_xml_name]);
         }
     }
     foreach ($attributes as $key => $val) {
         unset($attributes[$key]);
         $attributes[from_camelCase($key)] = $val;
     }
     // Do any switching around (Comcode has different embed vs attribute semantics to XML)
     foreach (array_merge($COMCODE_XML_SWITCH_AROUND, array('email')) as $_tag) {
         if ($tag == $_tag) {
             $x = 'param';
             if ($tag == 'reference') {
                 $x = 'title';
             }
             $temp = array_key_exists($x, $attributes) ? $attributes[$x] : '';
             $attributes[$x] = $child_tempcode->evaluate();
             $child_tempcode = make_string_tempcode($temp);
         }
     }
     $tempcode = new ocp_tempcode();
     $aggregate = true;
     $is_html = false;
     if (in_array($tag, $conflict_tags)) {
         if (strpos($namespace, 'html') !== false) {
             $is_html = true;
         }
     } elseif (strpos($namespace, 'html') !== false) {
         if (!isset($VALID_COMCODE_TAGS[$tag]) && !in_array($tag, $aux_tags)) {
             $is_html = true;
         }
     }
     if ($is_html) {
         $tempcode->attach('<' . $tag);
         foreach ($attributes as $key => $val) {
             $tempcode->attach(' ' . $key . '="' . escape_html($val) . '"');
         }
         $tempcode->attach('>');
         $tempcode->attach($child_tempcode);
         $tempcode->attach('</' . $tag . '>');
     } else {
         if (in_array($tag, $aux_tags)) {
             switch ($tag) {
                 case 'comcode':
                     $tempcode = $child_tempcode;
                     break;
                 case 'html_wrap':
                     $tempcode = $child_tempcode;
                     break;
                 case 'br':
                     $tempcode = make_string_tempcode('<br />');
                     break;
                 case 'hr':
                     $tempcode = do_template('COMCODE_TEXTCODE_LINE');
                     break;
                 case 'table':
                     $tempcode = new ocp_tempcode();
                     if (isset($attributes['summary'])) {
                         $tempcode->attach('<table summary="' . escape_html($attributes['summary']) . '">');
                     } else {
                         $tempcode->attach('<table>');
                     }
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('</table>');
                     break;
                 case 'tr':
                     $tempcode->attach('<tr>');
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('</tr>');
                     break;
                 case 'th':
                     $tempcode->attach('<th style="vertical-align: top">');
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('</th>');
                     break;
                 case 'td':
                     $tempcode->attach('<td style="vertical-align: top">');
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('</td>');
                     break;
                 case 'float':
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('<br style="clear: both" />');
                     break;
                 case 'fh':
                     // Limited due to limitation of XML
                     $i_dir_1 = 'left';
                     $i_dir_2 = 'right';
                     $tempcode->attach('<div style="padding-' . $i_dir_2 . ': 30px; float: ' . $i_dir_1 . '">');
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('</th>');
                     break;
                 case 'fd':
                     $tempcode->attach('<div class="inline">');
                     $tempcode->attach($child_tempcode);
                     $tempcode->attach('</div>');
                     break;
                 case 'emoticon':
                     $smilies = $GLOBALS['FORUM_DRIVER']->find_emoticons();
                     // Sorted in descending length order
                     require_code('comcode_text');
                     $_child_tempcode = $child_tempcode->evaluate();
                     foreach ($smilies as $code => $imgcode) {
                         if ($_child_tempcode == $code) {
                             $eval = do_emoticon($imgcode);
                             $tempcode = $eval;
                             break;
                         }
                     }
                     break;
                 case 'directive':
                     if (!isset($special_child_elements['directiveParam'])) {
                         $special_child_elements['directiveParam'] = array();
                     }
                     $tempcode = directive_tempcode($attributes['type'], $child_tempcode, $special_child_elements['directiveParam']);
                     break;
                 case 'language':
                     if (!isset($special_child_elements['languageParam'])) {
                         $special_child_elements['languageParam'] = array();
                     }
                     $a = array_shift($special_child_elements['languageParam']);
                     $b = array_shift($special_child_elements['languageParam']);
                     $symbol_params = array();
                     foreach ($special_child_elements['languageParam'] as $val) {
                         $symbol_params[] = $val->evaluate();
                     }
                     $tempcode = do_lang_tempcode($child_tempcode->evaluate(), $a, $b, $symbol_params);
                     break;
                 case 'symbol':
                     if (!isset($special_child_elements['symbolParam'])) {
                         $special_child_elements['symbolParam'] = array();
                     }
                     $symbol_params = array();
                     foreach ($special_child_elements['symbolParam'] as $val) {
                         $symbol_params[] = $val->evaluate();
                     }
                     $tempcode = symbol_tempcode($child_tempcode->evaluate(), $symbol_params);
                     break;
                 case 'hide_title':
                 case 'attachment_description':
                 case 'tooltip_message':
                 case 'list_element':
                 case 'show_concept':
                 case 'block_param':
                 case 'random_target':
                 case 'jumping_target':
                 case 'shocker_left':
                 case 'shocker_right':
                 case 'directive_param':
                 case 'language_param':
                 case 'symbol_param':
                     $tempcode = make_string_tempcode(serialize(array($attributes, $child_tempcode)));
                     $aggregate = false;
                     break;
                 case 'member':
                     $username = $child_tempcode->evaluate();
                     $username_info = isset($attributes['boxed']) && $attributes['boxed'] == '1';
                     $this_member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username);
                     if (!is_null($this_member_id)) {
                         $poster_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($this_member_id, false, true);
                         if (get_forum_type() == 'ocf' && $username_info) {
                             require_lang('ocf');
                             require_code('ocf_members2');
                             $details = ocf_show_member_box($this_member_id);
                             $tempcode = do_template('HYPERLINK_TOOLTIP', array('_GUID' => 'f7b65418616787b0f732c32486b63f4e', 'TOOLTIP' => $details, 'CAPTION' => $username, 'URL' => $poster_url, 'NEW_WINDOW' => false));
                         } else {
                             $tempcode = hyperlink($poster_url, $username);
                         }
                     }
                     break;
                 case 'cedi':
                     $cedi_page_name = $child_tempcode->evaluate();
                     if (isset($attributes['anchor'])) {
                         $jump_to = $attributes['anchor'];
                     } else {
                         $jump_to = '';
                     }
                     $cedi_page_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'find' => $cedi_page_name), get_module_zone('cedi'));
                     if ($jump_to != '') {
                         $cedi_page_url->attach('#' . $jump_to);
                     }
                     $tempcode = do_template('COMCODE_CEDI_LINK', array('_GUID' => '770ac8741e9b0fc2697d1ee3d7ec3b38', 'URL' => $cedi_page_url, 'TEXT' => $cedi_page_name));
                     break;
                 case 'list':
                     if (!isset($special_child_elements['listElement'])) {
                         $special_child_elements['listElement'] = array();
                     }
                     $my_list = array();
                     foreach ($special_child_elements['listElement'] as $val) {
                         $bits = unserialize($val->evaluate());
                         $my_list[] = $bits[1]->evaluate();
                     }
                     $tempcode = _do_tags_comcode($tag, $attributes, $my_list, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'concepts':
                     if (!isset($special_child_elements['showConcept'])) {
                         $special_child_elements['showConcept'] = array();
                     }
                     $new_attributes = array();
                     foreach ($special_child_elements['showConcept'] as $i => $val) {
                         $bits = unserialize($val->evaluate());
                         $new_attributes['key_' . strval($i)] = isset($bits[0]['key']) ? $bits[0]['key'] : '';
                         $new_attributes['val_' . strval($i)] = isset($bits[0]['key']) ? $bits[0]['value'] : '';
                     }
                     $tempcode = _do_tags_comcode($tag, $new_attributes, $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'block':
                     if (!isset($special_child_elements['blockParam'])) {
                         $special_child_elements['blockParam'] = array();
                     }
                     $new_attributes = array();
                     foreach ($special_child_elements['blockParam'] as $i => $val) {
                         $bits = unserialize($val->evaluate());
                         $new_attributes[isset($bits[0]['key']) ? $bits[0]['key'] : 'param'] = isset($bits[0]['value']) ? $bits[0]['value'] : '';
                     }
                     $tempcode = _do_tags_comcode($tag, $new_attributes, $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'random':
                     if (!isset($special_child_elements['randomTarget'])) {
                         $special_child_elements['randomTarget'] = array();
                     }
                     $new_attributes = array();
                     foreach ($special_child_elements['randomTarget'] as $i => $val) {
                         $bits = unserialize($val->evaluate());
                         $new_attributes[isset($bits[0]['pickIfAbove']) ? $bits[0]['pickIfAbove'] : '0'] = $bits[1];
                     }
                     $tempcode = _do_tags_comcode($tag, $new_attributes, $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'jumping':
                     if (!isset($special_child_elements['jumpingTarget'])) {
                         $special_child_elements['jumpingTarget'] = array();
                     }
                     $new_attributes = array();
                     foreach ($special_child_elements['jumpingTarget'] as $i => $val) {
                         $bits = unserialize($val->evaluate());
                         $new_attributes[strval($i)] = $bits[1];
                         if (is_object($new_attributes[strval($i)])) {
                             $new_attributes[strval($i)] = $new_attributes[strval($i)]->evaluate();
                         }
                     }
                     $tempcode = _do_tags_comcode($tag, $new_attributes, $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'shocker':
                     if (!isset($special_child_elements['shockerLeft'])) {
                         $special_child_elements['shockerLeft'] = array();
                     }
                     $new_attributes = array();
                     foreach ($special_child_elements['shockerLeft'] as $i => $val) {
                         $bits = unserialize($val->evaluate());
                         $new_attributes['left_' . strval($i)] = $bits[1];
                         if (is_object($new_attributes['left_' . strval($i)])) {
                             $new_attributes['left_' . strval($i)] = $new_attributes['left_' . strval($i)]->evaluate();
                         }
                     }
                     foreach ($special_child_elements['shockerRight'] as $i => $val) {
                         $bits = unserialize($val->evaluate());
                         $new_attributes['right_' . strval($i)] = $bits[1];
                         if (is_object($new_attributes['right_' . strval($i)])) {
                             $new_attributes['right_' . strval($i)] = $new_attributes['right_' . strval($i)]->evaluate();
                         }
                     }
                     $tempcode = _do_tags_comcode($tag, $new_attributes, $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'attachment':
                     $description = '';
                     if (isset($special_child_elements['attachmentDescription'])) {
                         $bits = unserialize($special_child_elements['attachmentDescription'][0]->evaluate());
                         $title = is_object($bits[1]) ? $bits[1]->evaluate() : $bits[1];
                     }
                     $tempcode = _do_tags_comcode($tag, array_merge($attributes, array('description' => $description)), $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'hide':
                     $title = '';
                     if (isset($special_child_elements['hideTitle'])) {
                         $bits = unserialize($special_child_elements['hideTitle'][0]->evaluate());
                         $title = is_object($bits[1]) ? $bits[1]->evaluate() : $bits[1];
                     }
                     $tempcode = _do_tags_comcode($tag, array_merge($attributes, array('param' => $title)), $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
                 case 'tooltip':
                     $title = '';
                     if (isset($special_child_elements['tooltipMessage'])) {
                         $bits = unserialize($special_child_elements['tooltipMessage'][0]->evaluate());
                         $title = is_object($bits[0]) ? $bits[0]->evaluate() : $bits[0];
                     }
                     $tempcode = _do_tags_comcode($tag, array_merge($attributes, array('param' => $title)), $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
                     break;
             }
         } elseif (isset($VALID_COMCODE_TAGS[$tag])) {
             $tempcode = _do_tags_comcode($tag, $attributes, $child_tempcode, true, $this->pass_id, $this->marker, $this->source_member, true, $this->connection, $this->comcode, $this->wml, $this->structure_sweep, $this->semiparse_mode, NULL, $this->on_behalf_of_member);
         }
         // Else, it is simply unknown and hence skipped
     }
     return array($tempcode, $aggregate);
 }