Lines Matching refs:this

138 		$this->dom = $dom;
139 $dom->nodes[] = $this;
143 $this->clear();
147 return $this->outertext();
151 $this->dom = null;
152 $this->nodes = null;
153 $this->parent = null;
154 $this->children = null;
158 echo str_repeat("\t", $depth) . $this->tag;
160 if ($show_attr && count($this->attr) > 0) {
162 foreach ($this->attr as $k => $v) {
170 if ($this->nodes) {
171 foreach ($this->nodes as $node) {
178 $string = $this->tag;
180 if (count($this->attr) > 0) {
182 foreach ($this->attr as $k => $v) {
188 if (count($this->_) > 0) {
190 foreach ($this->_ as $k => $v) {
204 if (isset($this->text)) {
205 $string .= " text: ({$this->text})";
216 $string .= ' children: ' . count($this->children);
217 $string .= ' nodes: ' . count($this->nodes);
218 $string .= ' tag_start: ' . $this->tag_start;
234 $this->parent = $parent;
235 $this->parent->nodes[] = $this;
236 $this->parent->children[] = $this;
239 return $this->parent;
243 return !empty($this->children);
248 return $this->children;
251 if (isset($this->children[$idx])) {
252 return $this->children[$idx];
259 if (count($this->children) > 0) {
260 return $this->children[0];
266 if (count($this->children) > 0) {
267 return end($this->children);
273 if ($this->parent === null) {
277 $idx = array_search($this, $this->parent->children, true);
279 if ($idx !== false && isset($this->parent->children[$idx + 1])) {
280 return $this->parent->children[$idx + 1];
287 if ($this->parent === null) {
291 $idx = array_search($this, $this->parent->children, true);
294 return $this->parent->children[$idx - 1];
306 if ($this->parent === null) {
310 $ancestor = $this->parent;
328 if (isset($this->_[HDOM_INFO_INNER])) {
329 return $this->_[HDOM_INFO_INNER];
332 if (isset($this->_[HDOM_INFO_TEXT])) {
333 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
338 foreach ($this->nodes as $n) {
351 if ($this->tag === 'text') {
352 if (!empty($this->text)) {
353 $text = ' with text: ' . $this->text;
357 $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
360 if ($this->tag === 'root') {
361 return $this->innertext();
365 if ($this->dom && $this->dom->callback !== null) {
366 call_user_func_array($this->dom->callback, array($this));
369 if (isset($this->_[HDOM_INFO_OUTER])) {
370 return $this->_[HDOM_INFO_OUTER];
373 if (isset($this->_[HDOM_INFO_TEXT])) {
374 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
379 if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) {
380 $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
383 if (isset($this->_[HDOM_INFO_INNER])) {
385 if ($this->tag !== 'br') {
386 $ret .= $this->_[HDOM_INFO_INNER];
388 } elseif ($this->nodes) {
389 foreach ($this->nodes as $n) {
390 $ret .= $this->convert_text($n->outertext());
394 if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) {
395 $ret .= '</' . $this->tag . '>';
402 if (isset($this->_[HDOM_INFO_INNER])) {
403 return $this->_[HDOM_INFO_INNER];
406 switch ($this->nodetype) {
408 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
415 if (strcasecmp($this->tag, 'script') === 0) {
418 if (strcasecmp($this->tag, 'style') === 0) {
429 if (!is_null($this->nodes)) {
430 foreach ($this->nodes as $n) {
436 $ret .= $this->convert_text($n->text());
442 $ret .= $this->dom->default_span_text;
450 $ret = $this->innertext();
458 if (isset($this->_[HDOM_INFO_TEXT])) {
459 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
462 $ret = '<' . $this->tag;
465 foreach ($this->attr as $key => $val) {
473 $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
479 switch ($this->_[HDOM_INFO_QUOTE][$i]) {
491 . $this->_[HDOM_INFO_SPACE][$i][1]
493 . $this->_[HDOM_INFO_SPACE][$i][2]
500 $ret = $this->dom->restore_noise($ret);
501 return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
505 $selectors = $this->parse_selector($selector);
519 if (!isset($this->_[HDOM_INFO_BEGIN])) {
523 $head = array($this->_[HDOM_INFO_BEGIN] => 1);
531 $n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k];
552 $found[] = $this->dom->nodes[$k];
576 $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
578 $parent = $this->parent;
587 $nodes_start = $this->_[HDOM_INFO_BEGIN] + 1;
589 $nodes = array_slice($this->dom->nodes, $nodes_start, $nodes_count, true);
591 $nodes = $this->children;
593 && $this->parent
594 && in_array($this, $this->parent->children)) { // Next-Sibling Combinator
595 $index = array_search($this, $this->parent->children, true) + 1;
596 if ($index < count($this->parent->children))
597 $nodes[] = $this->parent->children[$index];
599 && $this->parent
600 && in_array($this, $this->parent->children)) { // Subsequent Sibling Combinator
601 $index = array_search($this, $this->parent->children, true);
602 $nodes = array_slice($this->parent->children, $index);
618 $ret[array_search($node, $this->dom->nodes, true)] = 1;
754 $check = $this->match(
761 $check = $this->match(
915 if ($this->dom->lowercase) {
991 if (isset($this->attr[$name])) {
992 return $this->convert_text($this->attr[$name]);
996 return $this->outertext();
998 return $this->innertext();
1000 return $this->text();
1002 return $this->xmltext();
1004 return array_key_exists($name, $this->attr);
1016 return $this->_[HDOM_INFO_OUTER] = $value;
1018 if (isset($this->_[HDOM_INFO_TEXT])) {
1019 return $this->_[HDOM_INFO_TEXT] = $value;
1021 return $this->_[HDOM_INFO_INNER] = $value;
1024 if (!isset($this->attr[$name])) {
1025 $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
1026 $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
1029 $this->attr[$name] = $value;
1042 return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
1046 if (isset($this->attr[$name])) {
1047 unset($this->attr[$name]);
1062 if ($this->dom) {
1063 $sourceCharset = strtoupper($this->dom->_charset);
1064 $targetCharset = strtoupper($this->dom->_target_charset);
1081 && ($this->is_utf8($text))) {
1147 if ($this->tag !== 'img') {
1152 if (isset($this->attr['width'])) {
1153 $width = $this->attr['width'];
1156 if (isset($this->attr['height'])) {
1157 $height = $this->attr['height'];
1161 if (isset($this->attr['style'])) {
1167 $this->attr['style'],
1226 $ret = $this->outertext();
1242 if (isset($this->class)) {
1243 if ($this->hasClass($c)) {
1246 $this->class .= ' ' . $c;
1249 $this->class = $c;
1261 if (isset($this->class)) {
1262 return in_array($class, explode(' ', $this->class), true);
1274 if (!isset($this->class)) {
1279 $this->removeAttribute('class');
1288 $class = array_diff(explode(' ', $this->class), $class);
1290 $this->removeAttribute('class');
1292 $this->class = implode(' ', $class);
1298 return $this->attr;
1302 return $this->__get($name);
1306 $this->__set($name, $value);
1310 return $this->__isset($name);
1314 $this->__set($name, null);
1318 if ($this->parent) {
1319 $this->parent->removeChild($this);
1324 $nidx = array_search($node, $this->nodes, true);
1325 $cidx = array_search($node, $this->children, true);
1326 $didx = array_search($node, $this->dom->nodes, true);
1344 unset($this->nodes[$nidx]);
1345 unset($this->children[$cidx]);
1346 unset($this->dom->nodes[$didx]);
1354 return $this->find("#$id", 0);
1358 return $this->find("#$id", $idx);
1362 return $this->find($name, 0);
1366 return $this->find($name, $idx);
1370 return $this->parent();
1374 return $this->children($idx);
1378 return $this->first_child();
1382 return $this->last_child();
1386 return $this->next_sibling();
1390 return $this->prev_sibling();
1394 return $this->has_child();
1398 return $this->tag;
1402 $node->parent($this);
1490 $this->load_file($str);
1492 $this->load(
1505 $this->optional_closing_array = array();
1508 $this->_target_charset = $target_charset;
1512 $this->clear();
1525 $this->prepare($str, $lowercase, $defaultBRText, $defaultSpanText);
1530 $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
1531 $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
1535 $this->doc = str_replace("\r", ' ', $this->doc);
1536 $this->doc = str_replace("\n", ' ', $this->doc);
1539 $this->size = strlen($this->doc);
1543 $this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
1545 $this->remove_noise("'<!--(.*?)-->'is");
1547 $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
1548 $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
1550 $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
1552 $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
1555 $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
1559 $this->parse();
1561 $this->root->_[HDOM_INFO_END] = $this->cursor;
1562 $this->parse_charset();
1565 return $this;
1572 $this->load($doc, true);
1579 $this->callback = $function_name;
1583 $this->callback = null;
1587 $ret = $this->root->innertext();
1595 return $this->root->find($selector, $idx, $lowercase);
1599 if (isset($this->nodes)) {
1600 foreach ($this->nodes as $n) {
1609 if (isset($this->children)) {
1610 foreach ($this->children as $n) {
1616 if (isset($this->parent)) {
1617 $this->parent->clear();
1618 unset($this->parent);
1621 if (isset($this->root)) {
1622 $this->root->clear();
1623 unset($this->root);
1626 unset($this->doc);
1627 unset($this->noise);
1631 $this->root->dump($show_attr);
1638 $this->clear();
1640 $this->doc = trim($str);
1641 $this->size = strlen($this->doc);
1642 $this->original_size = $this->size; // original size of the html
1643 $this->pos = 0;
1644 $this->cursor = 1;
1645 $this->noise = array();
1646 $this->nodes = array();
1647 $this->lowercase = $lowercase;
1648 $this->default_br_text = $defaultBRText;
1649 $this->default_span_text = $defaultSpanText;
1650 $this->root = new simple_html_dom_node($this);
1651 $this->root->tag = 'root';
1652 $this->root->_[HDOM_INFO_BEGIN] = -1;
1653 $this->root->nodetype = HDOM_TYPE_ROOT;
1654 $this->parent = $this->root;
1655 if ($this->size > 0) {
1656 $this->char = $this->doc[0];
1664 if (($s = $this->copy_until_char('<')) === '') {
1665 if ($this->read_tag()) {
1673 $node = new simple_html_dom_node($this);
1674 ++$this->cursor;
1676 $this->link_nodes($node, false);
1701 $el = $this->root->find('meta[http-equiv=Content-Type]', 0, true);
1739 if ($meta = $this->root->find('meta[charset]', 0)) {
1766 $this->doc,
1775 if (!@iconv('CP1252', 'UTF-8', $this->doc)) {
1814 return $this->_charset = $charset;
1819 if ($this->char !== '<') {
1820 $this->root->_[HDOM_INFO_END] = $this->cursor;
1824 $begin_tag_pos = $this->pos;
1825 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1828 if ($this->char === '/') {
1829 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1832 $this->skip($this->token_blank);
1833 $tag = $this->copy_until_char('>');
1840 $parent_lower = strtolower($this->parent->tag);
1848 if (isset($this->optional_closing_tags[$parent_lower])
1849 && isset($this->block_tags[$tag_lower])) {
1851 $this->parent->_[HDOM_INFO_END] = 0;
1852 $org_parent = $this->parent;
1856 while (($this->parent->parent)
1857 && strtolower($this->parent->tag) !== $tag_lower
1859 $this->parent = $this->parent->parent;
1863 if (strtolower($this->parent->tag) !== $tag_lower) {
1864 $this->parent = $org_parent; // restore origonal parent
1866 if ($this->parent->parent) {
1867 $this->parent = $this->parent->parent;
1870 $this->parent->_[HDOM_INFO_END] = $this->cursor;
1871 return $this->as_text_node($tag);
1873 } elseif (($this->parent->parent)
1874 && isset($this->block_tags[$tag_lower])
1878 $this->parent->_[HDOM_INFO_END] = 0; // No end tag
1879 $org_parent = $this->parent;
1883 while (($this->parent->parent)
1884 && strtolower($this->parent->tag) !== $tag_lower
1886 $this->parent = $this->parent->parent;
1890 if (strtolower($this->parent->tag) !== $tag_lower) {
1891 $this->parent = $org_parent; // restore origonal parent
1892 $this->parent->_[HDOM_INFO_END] = $this->cursor;
1893 return $this->as_text_node($tag);
1895 } elseif (($this->parent->parent)
1896 && strtolower($this->parent->parent->tag) === $tag_lower
1898 $this->parent->_[HDOM_INFO_END] = 0;
1899 $this->parent = $this->parent->parent;
1901 return $this->as_text_node($tag);
1906 $this->parent->_[HDOM_INFO_END] = $this->cursor;
1908 if ($this->parent->parent) {
1909 $this->parent = $this->parent->parent;
1912 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1917 $node = new simple_html_dom_node($this);
1918 $node->_[HDOM_INFO_BEGIN] = $this->cursor;
1919 ++$this->cursor;
1920 $tag = $this->copy_until($this->token_slash); // Get tag name
1928 $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1938 if ($this->char === '>') {
1942 $this->link_nodes($node, true);
1943 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1952 $this->link_nodes($node, false);
1953 $this->char = $this->doc[--$this->pos]; // prev
1959 $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1962 if ($this->char === '<') {
1963 $this->link_nodes($node, false);
1968 if ($this->char === '>') {
1971 $this->link_nodes($node, false);
1972 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1979 $node->tag = ($this->lowercase) ? $tag_lower : $tag;
1982 if (isset($this->optional_closing_tags[$tag_lower])) {
1984 while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) {
1985 $this->parent->_[HDOM_INFO_END] = 0;
1986 $this->parent = $this->parent->parent;
1988 $node->parent = $this->parent;
1994 $space = array($this->copy_skip($this->token_blank), '', '');
1999 $name = $this->copy_until($this->token_equal);
2001 if ($name === '' && $this->char !== null && $space[0] === '') {
2005 if ($guard === $this->pos) { // Escape infinite loop
2006 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2010 $guard = $this->pos;
2014 if ($this->pos >= $this->size - 1 && $this->char !== '>') {
2019 $this->link_nodes($node, false);
2025 if ($this->doc[$this->pos - 1] == '<') {
2031 $this->doc,
2033 $this->pos - $begin_tag_pos - 1
2035 $this->pos -= 2;
2036 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2037 $this->link_nodes($node, false);
2043 $space[1] = $this->copy_skip($this->token_blank);
2045 $name = $this->restore_noise($name); // might be a noisy name
2047 if ($this->lowercase) {
2051 if ($this->char === '=') { // attribute with value
2052 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2053 $this->parse_attr($node, $name, $space); // get attribute value
2058 if ($this->char != '>') {
2059 $this->char = $this->doc[--$this->pos];
2067 $this->copy_skip($this->token_blank),
2074 } while ($this->char !== '>' && $this->char !== '/'); // go until the tag ended
2076 $this->link_nodes($node, true);
2080 if ($this->copy_until_char('>') === '/') {
2085 if (!isset($this->self_closing_tags[strtolower($node->tag)])) {
2086 $this->parent = $node;
2090 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2096 $node->_[HDOM_INFO_INNER] = $this->default_br_text;
2106 $space[2] = $this->copy_skip($this->token_blank);
2108 switch ($this->char) {
2111 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2112 $value = $this->copy_until_char('"');
2113 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2117 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2118 $value = $this->copy_until_char('\'');
2119 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2123 $value = $this->copy_until($this->token_attr);
2126 $value = $this->restore_noise($value);
2146 $node->parent = $this->parent;
2147 $this->parent->nodes[] = $node;
2149 $this->parent->children[] = $node;
2154 $node = new simple_html_dom_node($this);
2155 ++$this->cursor;
2157 $this->link_nodes($node, false);
2158 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2163 $this->pos += strspn($this->doc, $chars, $this->pos);
2164 $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2168 $pos = $this->pos;
2169 $len = strspn($this->doc, $chars, $pos);
2170 $this->pos += $len;
2171 $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2175 return substr($this->doc, $pos, $len);
2179 $pos = $this->pos;
2180 $len = strcspn($this->doc, $chars, $pos);
2181 $this->pos += $len;
2182 $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2183 return substr($this->doc, $pos, $len);
2187 if ($this->char === null) {
2191 if (($pos = strpos($this->doc, $char, $this->pos)) === false) {
2192 $ret = substr($this->doc, $this->pos, $this->size - $this->pos);
2193 $this->char = null;
2194 $this->pos = $this->size;
2198 if ($pos === $this->pos) {
2202 $pos_old = $this->pos;
2203 $this->char = $this->doc[$pos];
2204 $this->pos = $pos;
2205 return substr($this->doc, $pos_old, $pos - $pos_old);
2216 $this->doc,
2222 $key = '___noise___' . sprintf('% 5d', count($this->noise) + 1000);
2229 $this->noise[$key] = $matches[$i][$idx][0];
2230 …$this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0])…
2234 $this->size = strlen($this->doc);
2236 if ($this->size > 0) {
2237 $this->char = $this->doc[0];
2266 if (isset($this->noise[$key])) {
2268 . $this->noise[$key]
2294 foreach ($this->noise as $noiseElement) {
2302 return $this->root->innertext();
2308 return $this->root->innertext();
2310 return $this->root->innertext();
2312 return $this->root->text();
2314 return $this->_charset;
2316 return $this->_target_charset;
2321 return $this->root->childNodes($idx);
2325 return $this->root->first_child();
2329 return $this->root->last_child();
2341 return $this->find("#$id", 0);
2345 return $this->find("#$id", $idx);
2349 return $this->find($name, 0);
2353 return $this->find($name, $idx);
2358 $this->load_file($args);