OSDN Git Service

BugTrack/2568 Avoid notice error bugtrack_2568_php_notice
authorhaifun <haifun@users.osdn.me>
Sun, 3 Apr 2022 05:47:29 +0000 (14:47 +0900)
committerhaifun <haifun@users.osdn.me>
Sun, 3 Apr 2022 05:47:29 +0000 (14:47 +0900)
lib/convert_html.php

index 2dba3c1..924e896 100644 (file)
@@ -39,15 +39,15 @@ class Element
        function __construct()
        {
                $this->elements = array();
-               $this->last     = $this;
+               $this->last     = $this;
        }
 
-       function setParent($parent)
+       function setParent($parent)
        {
-               $this->parent = $parent;
+               $this->parent = $parent;
        }
 
-       function & add(& $obj)
+       function add($obj)
        {
                if ($this->canContain($obj)) {
                        return $this->insert($obj);
@@ -56,15 +56,15 @@ class Element
                }
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                $obj->setParent($this);
-               $this->elements[] = $obj;
+               $this->elements[] = $obj;
 
-               return $this->last = $obj->last;
+               return $this->last = $obj->last;
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return TRUE;
        }
@@ -97,7 +97,7 @@ class Element
 }
 
 // Returns inline-related object
-function Factory_Inline($text)
+function Factory_Inline($text)
 {
        // Check the first letter of the line
        if (substr($text, 0, 1) == '~') {
@@ -107,7 +107,7 @@ function & Factory_Inline($text)
        }
 }
 
-function & Factory_DList(& $root, $text)
+function Factory_DList($root, $text)
 {
        $out = explode('|', ltrim($text), 2);
        if (count($out) < 2) {
@@ -118,7 +118,7 @@ function & Factory_DList(& $root, $text)
 }
 
 // '|'-separated table
-function & Factory_Table(& $root, $text)
+function Factory_Table($root, $text)
 {
        if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $out)) {
                return Factory_Inline($text);
@@ -128,7 +128,7 @@ function & Factory_Table(& $root, $text)
 }
 
 // Comma-separated table
-function & Factory_YTable(& $root, $text)
+function Factory_YTable($root, $text)
 {
        if ($text == ',') {
                return Factory_Inline($text);
@@ -137,7 +137,7 @@ function & Factory_YTable(& $root, $text)
        }
 }
 
-function & Factory_Div(& $root, $text)
+function Factory_Div($root, $text)
 {
        $matches = array();
 
@@ -180,13 +180,13 @@ class Inline extends Element
                        $text : make_link($text));
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                $this->elements[] = $obj->elements[0];
                return $this;
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return is_a($obj, 'Inline');
        }
@@ -197,7 +197,7 @@ class Inline extends Element
                return join(($line_break ? '<br />' . "\n" : "\n"), $this->elements);
        }
 
-       function toPara($class = '')
+       function toPara($class = '')
        {
                $obj = new Paragraph('', $class);
                $obj->insert($this);
@@ -226,7 +226,7 @@ class Paragraph extends Element
                $this->insert(Factory_Inline($text));
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return is_a($obj, 'Inline');
        }
@@ -246,11 +246,11 @@ class Heading extends Element
        var $id;
        var $msg_top;
 
-       function Heading($root, $text)
+       function Heading($root, $text)
        {
                $this->__construct($root, $text);
        }
-       function __construct($root, $text)
+       function __construct($root, $text)
        {
                parent::__construct();
 
@@ -260,13 +260,13 @@ class Heading extends Element
                $this->level++; // h2,h3,h4
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                parent::insert($obj);
-               return $this->last = $this;
+               return $this->last = $this;
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return FALSE;
        }
@@ -282,16 +282,16 @@ class Heading extends Element
 // Horizontal Rule
 class HRule extends Element
 {
-       function HRule($root, $text)
+       function HRule($root, $text)
        {
                $this->__construct($root, $text);
        }
-       function __construct($root, $text)
+       function __construct($root, $text)
        {
                parent::__construct();
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return FALSE;
        }
@@ -326,16 +326,16 @@ class ListContainer extends Element
 
                parent::insert(new ListElement($this->level, $tag2));
                if ($text != '')
-                       $this->last = $this->last->insert(Factory_Inline($text));
+                       $this->last = $this->last->insert(Factory_Inline($text));
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return (! is_a($obj, 'ListContainer')
                        || ($this->tag == $obj->tag && $this->level == $obj->level));
        }
 
-       function setParent($parent)
+       function setParent($parent)
        {
                parent::setParent($parent);
 
@@ -346,10 +346,10 @@ class ListContainer extends Element
                $this->style = sprintf(pkwk_list_attrs_template(), $this->level, $step);
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                if (! is_a($obj, get_class($this)))
-                       return $this->last = $this->last->insert($obj);
+                       return $this->last = $this->last->insert($obj);
 
                // Break if no elements found (BugTrack/524)
                if (count($obj->elements) == 1 && empty($obj->elements[0]->elements))
@@ -381,7 +381,7 @@ class ListElement extends Element
                $this->head  = $head;
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return (! is_a($obj, 'ListContainer') || ($obj->level > $this->level));
        }
@@ -397,11 +397,11 @@ class ListElement extends Element
 // - Three
 class UList extends ListContainer
 {
-       function UList($root, $text)
+       function UList($root, $text)
        {
                $this->__construct($root, $text);
        }
-       function __construct($root, $text)
+       function __construct($root, $text)
        {
                parent::__construct('ul', 'li', '-', $text);
        }
@@ -412,11 +412,11 @@ class UList extends ListContainer
 // + Three
 class OList extends ListContainer
 {
-       function OList($root, $text)
+       function OList($root, $text)
        {
                $this->__construct($root, $text);
        }
-       function __construct($root, $text)
+       function __construct($root, $text)
        {
                parent::__construct('ol', 'li', '+', $text);
        }
@@ -434,9 +434,9 @@ class DList extends ListContainer
        function __construct($out)
        {
                parent::__construct('dl', 'dt', ':', $out[0]);
-               $this->last = Element::insert(new ListElement($this->level, 'dd'));
+               $this->last = Element::insert(new ListElement($this->level, 'dd'));
                if ($out[1] != '')
-                       $this->last = $this->last->insert(Factory_Inline($out[1]));
+                       $this->last = $this->last->insert(Factory_Inline($out[1]));
        }
 }
 
@@ -446,11 +446,11 @@ class BQuote extends Element
 {
        var $level;
 
-       function BQuote($root, $text)
+       function BQuote($root, $text)
        {
                $this->__construct($root, $text);
        }
-       function __construct($root, $text)
+       function __construct($root, $text)
        {
                parent::__construct();
 
@@ -461,29 +461,29 @@ class BQuote extends Element
                if ($head == '<') { // Blockquote close
                        $level       = $this->level;
                        $this->level = 0;
-                       $this->last  = $this->end($root, $level);
+                       $this->last  = $this->end($root, $level);
                        if ($text != '')
-                               $this->last = $this->last->insert(Factory_Inline($text));
+                               $this->last = $this->last->insert(Factory_Inline($text));
                } else {
                        $this->insert(Factory_Inline($text));
                }
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return (! is_a($obj, get_class($this)) || $obj->level >= $this->level);
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                // BugTrack/521, BugTrack/545
                if (is_a($obj, 'inline'))
                        return parent::insert($obj->toPara(' class="quotation"'));
 
                if (is_a($obj, 'BQuote') && $obj->level == $this->level && count($obj->elements)) {
-                       $obj = $obj->elements[0];
+                       $obj = $obj->elements[0];
                        if (is_a($this->last, 'Paragraph') && count($obj->elements))
-                               $obj = $obj->elements[0];
+                               $obj = $obj->elements[0];
                }
                return parent::insert($obj);
        }
@@ -493,14 +493,14 @@ class BQuote extends Element
                return $this->wrap(parent::toString(), 'blockquote');
        }
 
-       function end(& $root, $level)
+       function end(& $root, $level)
        {
-               $parent = $root->last;
+               $parent = $root->last;
 
                while (is_object($parent)) {
                        if (is_a($parent, 'BQuote') && $parent->level == $level)
                                return $parent->parent;
-                       $parent = $parent->parent;
+                       $parent = $parent->parent;
                }
                return $this;
        }
@@ -553,17 +553,17 @@ class TableCell extends Element
 
                if ($text != '' && $text[0] == '#') {
                        // Try using Div class for this $text
-                       $obj = Factory_Div($this, $text);
+                       $obj = Factory_Div($this, $text);
                        if (is_a($obj, 'Paragraph'))
-                               $obj = $obj->elements[0];
+                               $obj = $obj->elements[0];
                } else {
-                       $obj = Factory_Inline($text);
+                       $obj = Factory_Inline($text);
                }
 
                $this->insert($obj);
        }
 
-       function setStyle($style)
+       function setStyle($style)
        {
                foreach ($style as $key=>$value)
                        if (! isset($this->style[$key]))
@@ -616,12 +616,12 @@ class Table extends Element
                $this->elements[] = $row;
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return is_a($obj, 'Table') && ($obj->col == $this->col);
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                $this->elements[] = $obj->elements[0];
                $this->types[]    = $obj->type;
@@ -636,7 +636,7 @@ class Table extends Element
                for ($ncol = 0; $ncol < $this->col; $ncol++) {
                        $rowspan = 1;
                        foreach (array_reverse(array_keys($this->elements)) as $nrow) {
-                               $row = $this->elements[$nrow];
+                               $row = $this->elements[$nrow];
                                if ($row[$ncol]->rowspan == 0) {
                                        ++$rowspan;
                                        continue;
@@ -652,9 +652,9 @@ class Table extends Element
                // Set colspan and style
                $stylerow = NULL;
                foreach (array_keys($this->elements) as $nrow) {
-                       $row = $this->elements[$nrow];
+                       $row = $this->elements[$nrow];
                        if ($this->types[$nrow] == 'c')
-                               $stylerow = $row;
+                               $stylerow = $row;
                        $colspan = 1;
                        foreach (array_keys($row) as $ncol) {
                                if ($row[$ncol]->colspan == 0) {
@@ -680,7 +680,7 @@ class Table extends Element
                        foreach (array_keys($this->elements) as $nrow) {
                                if ($this->types[$nrow] != $type)
                                        continue;
-                               $row        = $this->elements[$nrow];
+                               $row        = $this->elements[$nrow];
                                $row_string = '';
                                foreach (array_keys($row) as $ncol)
                                        $row_string .= $row[$ncol]->toString();
@@ -755,12 +755,12 @@ class YTable extends Element
                $this->elements[] = implode('', $str);
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return is_a($obj, 'YTable') && ($obj->col == $this->col);
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                $this->elements[] = $obj->elements[0];
                return $this;
@@ -794,12 +794,12 @@ class Pre extends Element
                        (! $preformat_ltrim || $text == '' || $text[0] != ' ') ? $text : substr($text, 1));
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return is_a($obj, 'Pre');
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
                $this->elements[] = $obj->elements[0];
                return $this;
@@ -827,7 +827,7 @@ class Div extends Element
                list(, $this->name, $this->param) = array_pad($out, 3, '');
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return FALSE;
        }
@@ -854,7 +854,7 @@ class Align extends Element
                $this->align = $align;
        }
 
-       function canContain($obj)
+       function canContain($obj)
        {
                return is_a($obj, 'Inline');
        }
@@ -891,13 +891,13 @@ class Body extends Element
        {
                $this->id            = $id;
                $this->contents      = new Element();
-               $this->contents_last = $this->contents;
+               $this->contents_last = $this->contents;
                parent::__construct();
        }
 
        function parse(& $lines)
        {
-               $this->last = $this;
+               $this->last = $this;
                $matches = array();
 
                while (! empty($lines)) {
@@ -908,7 +908,7 @@ class Body extends Element
 
                        if (preg_match('/^(LEFT|CENTER|RIGHT):(.*)$/', $line, $matches)) {
                                // <div style="text-align:...">
-                               $this->last = $this->last->add(new Align(strtolower($matches[1])));
+                               $this->last = $this->last->add(new Align(strtolower($matches[1])));
                                if ($matches[2] == '') continue;
                                $line = $matches[2];
                        }
@@ -917,7 +917,7 @@ class Body extends Element
 
                        // Empty
                        if ($line == '') {
-                               $this->last = $this;
+                               $this->last = $this;
                                continue;
                        }
 
@@ -954,7 +954,7 @@ class Body extends Element
 
                        // Pre
                        if ($head == ' ' || $head == "\t") {
-                               $this->last = $this->last->add(new Pre($this, $line));
+                               $this->last = $this->last->add(new Pre($this, $line));
                                continue;
                        }
 
@@ -965,19 +965,19 @@ class Body extends Element
                        // Other Character
                        if (isset($this->classes[$head])) {
                                $classname  = $this->classes[$head];
-                               $this->last = $this->last->add(new $classname($this, $line));
+                               $this->last = $this->last->add(new $classname($this, $line));
                                continue;
                        }
 
                        // Other Character
                        if (isset($this->factories[$head])) {
                                $factoryname = 'Factory_' . $this->factories[$head];
-                               $this->last  = $this->last->add($factoryname($this, $line));
+                               $this->last  = $this->last->add($factoryname($this, $line));
                                continue;
                        }
 
                        // Default
-                       $this->last = $this->last->add(Factory_Inline($line));
+                       $this->last = $this->last->add(Factory_Inline($line));
                }
        }
 
@@ -1000,14 +1000,14 @@ class Body extends Element
                }
                $text = trim($text);
                // Add 'page contents' link to its heading
-               $this->contents_last = $this->contents_last->add(new Contents_UList($text, $level, $id));
+               $this->contents_last = $this->contents_last->add(new Contents_UList($text, $level, $id));
                // Add heding
                return array($text . $anchor, $this->count > 1 ? "\n" . $top : '', $autoid);
        }
 
-       function & insert(& $obj)
+       function insert($obj)
        {
-               if (is_a($obj, 'Inline')) $obj = $obj->toPara();
+               if (is_a($obj, 'Inline')) $obj = $obj->toPara();
                return parent::insert($obj);
        }
 
@@ -1050,7 +1050,7 @@ class Contents_UList extends ListContainer
                $this->insert(Factory_Inline($text));
        }
 
-       function setParent($parent)
+       function setParent($parent)
        {
                parent::setParent($parent);
                $step   = $this->level;