Lines Matching refs:this

142 		$this->dom = $dom;
143 $dom->nodes[] = $this;
148 $this->clear();
153 return $this->outertext();
158 $this->dom = null;
159 $this->nodes = null;
160 $this->parent = null;
161 $this->children = null;
166 echo str_repeat("\t", $depth) . $this->tag;
168 if ($show_attr && count($this->attr) > 0) {
170 foreach ($this->attr as $k => $v) {
178 if ($this->nodes) {
179 foreach ($this->nodes as $node) {
187 $string = $this->tag;
189 if (count($this->attr) > 0) {
191 foreach ($this->attr as $k => $v) {
197 if (count($this->_) > 0) {
199 foreach ($this->_ as $k => $v) {
213 if (isset($this->text)) {
214 $string .= " text: ({$this->text})";
225 $string .= ' children: ' . count($this->children);
226 $string .= ' nodes: ' . count($this->nodes);
227 $string .= ' tag_start: ' . $this->tag_start;
240 // I am SURE that this doesn't work properly.
244 $this->parent = $parent;
245 $this->parent->nodes[] = $this;
246 $this->parent->children[] = $this;
249 return $this->parent;
254 return !empty($this->children);
260 return $this->children;
263 if (isset($this->children[$idx])) {
264 return $this->children[$idx];
272 if (count($this->children) > 0) {
273 return $this->children[0];
280 if (count($this->children) > 0) {
281 return end($this->children);
288 if ($this->parent === null) {
292 $idx = array_search($this, $this->parent->children, true);
294 if ($idx !== false && isset($this->parent->children[$idx + 1])) {
295 return $this->parent->children[$idx + 1];
303 if ($this->parent === null) {
307 $idx = array_search($this, $this->parent->children, true);
310 return $this->parent->children[$idx - 1];
321 if ($this->parent === null) {
325 $ancestor = $this->parent;
344 if (isset($this->_[HDOM_INFO_INNER])) {
345 return $this->_[HDOM_INFO_INNER];
348 if (isset($this->_[HDOM_INFO_TEXT])) {
349 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
354 foreach ($this->nodes as $n) {
368 if ($this->tag === 'text') {
369 if (!empty($this->text)) {
370 $text = ' with text: ' . $this->text;
374 $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
377 if ($this->tag === 'root') {
378 return $this->innertext();
381 // todo: What is the use of this callback? Remove?
382 if ($this->dom && $this->dom->callback !== null) {
383 call_user_func_array($this->dom->callback, array($this));
386 if (isset($this->_[HDOM_INFO_OUTER])) {
387 return $this->_[HDOM_INFO_OUTER];
390 if (isset($this->_[HDOM_INFO_TEXT])) {
391 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
396 if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) {
397 $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
400 if (isset($this->_[HDOM_INFO_INNER])) {
402 if ($this->tag !== 'br') {
403 $ret .= $this->_[HDOM_INFO_INNER];
405 } elseif ($this->nodes) {
406 foreach ($this->nodes as $n) {
407 $ret .= $this->convert_text($n->outertext());
411 if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) {
412 $ret .= '</' . $this->tag . '>';
420 if (isset($this->_[HDOM_INFO_INNER])) {
421 return $this->_[HDOM_INFO_INNER];
424 switch ($this->nodetype) {
425 case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
430 if (strcasecmp($this->tag, 'script') === 0) { return ''; }
431 if (strcasecmp($this->tag, 'style') === 0) { return ''; }
436 // for some span tags, and some p tags) $this->nodes is set to NULL.
439 // WHY is this happening?
440 if (!is_null($this->nodes)) {
441 foreach ($this->nodes as $n) {
447 $ret .= $this->convert_text($n->text());
449 // If this node is a span... add a space at the end of it so
453 $ret .= $this->dom->default_span_text;
462 $ret = $this->innertext();
471 if (isset($this->_[HDOM_INFO_TEXT])) {
472 return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
475 $ret = '<' . $this->tag;
478 foreach ($this->attr as $key => $val) {
484 $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
490 switch ($this->_[HDOM_INFO_QUOTE][$i])
498 . $this->_[HDOM_INFO_SPACE][$i][1]
500 . $this->_[HDOM_INFO_SPACE][$i][2]
507 $ret = $this->dom->restore_noise($ret);
508 return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
513 $selectors = $this->parse_selector($selector);
523 if (!isset($this->_[HDOM_INFO_BEGIN])) { return array(); }
525 $head = array($this->_[HDOM_INFO_BEGIN] => 1);
533 $n = ($k === -1) ? $this->dom->root : $this->dom->nodes[$k];
534 //PaperG - Pass this optional parameter on to the seek function.
554 $found[] = $this->dom->nodes[$k];
574 $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
576 $parent = $this->parent;
585 $nodes_start = $this->_[HDOM_INFO_BEGIN] + 1;
587 $nodes = array_slice($this->dom->nodes, $nodes_start, $nodes_count, true);
589 $nodes = $this->children;
591 && $this->parent
592 && in_array($this, $this->parent->children)) { // Next-Sibling Combinator
593 $index = array_search($this, $this->parent->children, true) + 1;
594 if ($index < count($this->parent->children))
595 $nodes[] = $this->parent->children[$index];
597 && $this->parent
598 && in_array($this, $this->parent->children)) { // Subsequent Sibling Combinator
599 $index = array_search($this, $this->parent->children, true);
600 $nodes = array_slice($this->parent->children, $index);
603 // Go throgh each element starting at this element until the end tag
604 // Note: If this element is a void tag, any previous void element is
616 $ret[array_search($node, $this->dom->nodes, true)] = 1;
698 // If this is the correct node, continue with next
721 // If they have told us that this is a "plaintext"
746 $check = $this->match(
753 $check = $this->match(
779 // It's passed by reference so this is actually what this function returns.
841 * Note: if you try to look at this attribute, you MUST use getAttribute
848 * is required to determine of this should be documented or removed.
850 * Matches selectors in this order:
902 if ($this->dom->lowercase) {
971 if (isset($this->attr[$name])) {
972 return $this->convert_text($this->attr[$name]);
975 case 'outertext': return $this->outertext();
976 case 'innertext': return $this->innertext();
977 case 'plaintext': return $this->text();
978 case 'xmltext': return $this->xmltext();
979 default: return array_key_exists($name, $this->attr);
989 case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
991 if (isset($this->_[HDOM_INFO_TEXT])) {
992 return $this->_[HDOM_INFO_TEXT] = $value;
994 return $this->_[HDOM_INFO_INNER] = $value;
997 if (!isset($this->attr[$name])) {
998 $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
999 $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
1002 $this->attr[$name] = $value;
1013 return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
1018 if (isset($this->attr[$name])) { unset($this->attr[$name]); }
1031 if ($this->dom) {
1032 $sourceCharset = strtoupper($this->dom->_charset);
1033 $targetCharset = strtoupper($this->dom->_target_charset);
1050 && ($this->is_utf8($text))) {
1105 if ($this->tag !== 'img') {
1110 if (isset($this->attr['width'])) {
1111 $width = $this->attr['width'];
1114 if (isset($this->attr['height'])) {
1115 $height = $this->attr['height'];
1119 if (isset($this->attr['style'])) {
1120 // Thanks to user gnarf from stackoverflow for this regular expression.
1125 $this->attr['style'],
1165 // Look at all the parent tags of this image to see if they specify a
1167 // Note that in this case, the class or id will have the img subselector
1185 $ret = $this->outertext();
1202 if (isset($this->class)) {
1203 if ($this->hasClass($c)) {
1206 $this->class .= ' ' . $c;
1209 $this->class = $c;
1222 if (isset($this->class)) {
1223 return in_array($class, explode(' ', $this->class), true);
1236 if (!isset($this->class)) {
1241 $this->removeAttribute('class');
1250 $class = array_diff(explode(' ', $this->class), $class);
1252 $this->removeAttribute('class');
1254 $this->class = implode(' ', $class);
1261 return $this->attr;
1266 return $this->__get($name);
1271 $this->__set($name, $value);
1276 return $this->__isset($name);
1281 $this->__set($name, null);
1286 if ($this->parent) {
1287 $this->parent->removeChild($this);
1293 $nidx = array_search($node, $this->nodes, true);
1294 $cidx = array_search($node, $this->children, true);
1295 $didx = array_search($node, $this->dom->nodes, true);
1313 unset($this->nodes[$nidx]);
1314 unset($this->children[$cidx]);
1315 unset($this->dom->nodes[$didx]);
1324 return $this->find("#$id", 0);
1329 return $this->find("#$id", $idx);
1334 return $this->find($name, 0);
1339 return $this->find($name, $idx);
1344 return $this->parent();
1349 return $this->children($idx);
1354 return $this->first_child();
1359 return $this->last_child();
1364 return $this->next_sibling();
1369 return $this->prev_sibling();
1374 return $this->has_child();
1379 return $this->tag;
1384 $node->parent($this);
1476 $this->load_file($str);
1478 $this->load(
1491 $this->optional_closing_array = array();
1494 $this->_target_charset = $target_charset;
1499 $this->clear();
1513 $this->prepare($str, $lowercase, $defaultBRText, $defaultSpanText);
1518 $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
1519 $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
1523 $this->doc = str_replace("\r", ' ', $this->doc);
1524 $this->doc = str_replace("\n", ' ', $this->doc);
1527 $this->size = strlen($this->doc);
1531 $this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
1533 $this->remove_noise("'<!--(.*?)-->'is");
1535 $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
1536 $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
1538 $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
1540 $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
1543 $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
1547 $this->parse();
1549 $this->root->_[HDOM_INFO_END] = $this->cursor;
1550 $this->parse_charset();
1553 return $this;
1561 $this->load($doc, true);
1569 $this->callback = $function_name;
1574 $this->callback = null;
1579 $ret = $this->root->innertext();
1586 return $this->root->find($selector, $idx, $lowercase);
1591 if (isset($this->nodes)) {
1592 foreach ($this->nodes as $n) {
1601 if (isset($this->children)) {
1602 foreach ($this->children as $n) {
1608 if (isset($this->parent)) {
1609 $this->parent->clear();
1610 unset($this->parent);
1613 if (isset($this->root)) {
1614 $this->root->clear();
1615 unset($this->root);
1618 unset($this->doc);
1619 unset($this->noise);
1624 $this->root->dump($show_attr);
1632 $this->clear();
1634 $this->doc = trim($str);
1635 $this->size = strlen($this->doc);
1636 $this->original_size = $this->size; // original size of the html
1637 $this->pos = 0;
1638 $this->cursor = 1;
1639 $this->noise = array();
1640 $this->nodes = array();
1641 $this->lowercase = $lowercase;
1642 $this->default_br_text = $defaultBRText;
1643 $this->default_span_text = $defaultSpanText;
1644 $this->root = new simple_html_dom_node($this);
1645 $this->root->tag = 'root';
1646 $this->root->_[HDOM_INFO_BEGIN] = -1;
1647 $this->root->nodetype = HDOM_TYPE_ROOT;
1648 $this->parent = $this->root;
1649 if ($this->size > 0) { $this->char = $this->doc[0]; }
1657 if (($s = $this->copy_until_char('<')) === '') {
1658 if($this->read_tag()) {
1666 $node = new simple_html_dom_node($this);
1667 ++$this->cursor;
1669 $this->link_nodes($node, false);
1695 $el = $this->root->find('meta[http-equiv=Content-Type]', 0, true);
1733 if ($meta = $this->root->find('meta[charset]', 0)) {
1760 $this->doc,
1769 if (!@iconv('CP1252', 'UTF-8', $this->doc)) {
1808 return $this->_charset = $charset;
1814 if ($this->char !== '<') {
1815 $this->root->_[HDOM_INFO_END] = $this->cursor;
1819 $begin_tag_pos = $this->pos;
1820 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1823 if ($this->char === '/') {
1824 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1827 $this->skip($this->token_blank);
1828 $tag = $this->copy_until_char('>');
1835 $parent_lower = strtolower($this->parent->tag);
1843 if (isset($this->optional_closing_tags[$parent_lower])
1844 && isset($this->block_tags[$tag_lower])) {
1846 $this->parent->_[HDOM_INFO_END] = 0;
1847 $org_parent = $this->parent;
1851 while (($this->parent->parent)
1852 && strtolower($this->parent->tag) !== $tag_lower
1854 $this->parent = $this->parent->parent;
1858 if (strtolower($this->parent->tag) !== $tag_lower) {
1859 $this->parent = $org_parent; // restore origonal parent
1861 if ($this->parent->parent) {
1862 $this->parent = $this->parent->parent;
1865 $this->parent->_[HDOM_INFO_END] = $this->cursor;
1866 return $this->as_text_node($tag);
1868 } elseif (($this->parent->parent)
1869 && isset($this->block_tags[$tag_lower])
1873 $this->parent->_[HDOM_INFO_END] = 0; // No end tag
1874 $org_parent = $this->parent;
1878 while (($this->parent->parent)
1879 && strtolower($this->parent->tag) !== $tag_lower
1881 $this->parent = $this->parent->parent;
1885 if (strtolower($this->parent->tag) !== $tag_lower) {
1886 $this->parent = $org_parent; // restore origonal parent
1887 $this->parent->_[HDOM_INFO_END] = $this->cursor;
1888 return $this->as_text_node($tag);
1890 } elseif (($this->parent->parent)
1891 && strtolower($this->parent->parent->tag) === $tag_lower
1893 $this->parent->_[HDOM_INFO_END] = 0;
1894 $this->parent = $this->parent->parent;
1896 return $this->as_text_node($tag);
1901 $this->parent->_[HDOM_INFO_END] = $this->cursor;
1903 if ($this->parent->parent) {
1904 $this->parent = $this->parent->parent;
1907 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1912 $node = new simple_html_dom_node($this);
1913 $node->_[HDOM_INFO_BEGIN] = $this->cursor;
1914 ++$this->cursor;
1915 $tag = $this->copy_until($this->token_slash); // Get tag name
1923 $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1933 if ($this->char === '>') { $node->_[HDOM_INFO_TEXT] .= '>'; }
1935 $this->link_nodes($node, true);
1936 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1945 $this->link_nodes($node, false);
1946 $this->char = $this->doc[--$this->pos]; // prev
1952 $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1955 if ($this->char === '<') {
1956 $this->link_nodes($node, false);
1961 if ($this->char === '>') { $node->_[HDOM_INFO_TEXT] .= '>'; }
1962 $this->link_nodes($node, false);
1963 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
1970 $node->tag = ($this->lowercase) ? $tag_lower : $tag;
1973 if (isset($this->optional_closing_tags[$tag_lower])) {
1975 while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) {
1976 $this->parent->_[HDOM_INFO_END] = 0;
1977 $this->parent = $this->parent->parent;
1979 $node->parent = $this->parent;
1985 $space = array($this->copy_skip($this->token_blank), '', '');
1990 $name = $this->copy_until($this->token_equal);
1992 if ($name === '' && $this->char !== null && $space[0] === '') {
1996 if ($guard === $this->pos) { // Escape infinite loop
1997 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2001 $guard = $this->pos;
2005 if ($this->pos >= $this->size - 1 && $this->char !== '>') {
2010 $this->link_nodes($node, false);
2016 if ($this->doc[$this->pos - 1] == '<') {
2022 $this->doc,
2024 $this->pos - $begin_tag_pos - 1
2026 $this->pos -= 2;
2027 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2028 $this->link_nodes($node, false);
2032 if ($name !== '/' && $name !== '') { // this is a attribute name
2034 $space[1] = $this->copy_skip($this->token_blank);
2036 $name = $this->restore_noise($name); // might be a noisy name
2038 if ($this->lowercase) { $name = strtolower($name); }
2040 if ($this->char === '=') { // attribute with value
2041 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2042 $this->parse_attr($node, $name, $space); // get attribute value
2047 if ($this->char != '>') { $this->char = $this->doc[--$this->pos]; } // prev
2054 $this->copy_skip($this->token_blank),
2061 } while ($this->char !== '>' && $this->char !== '/'); // go until the tag ended
2063 $this->link_nodes($node, true);
2067 if ($this->copy_until_char('>') === '/') {
2072 if (!isset($this->self_closing_tags[strtolower($node->tag)])) {
2073 $this->parent = $node;
2077 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2081 // since a br tag never has sub nodes, this works well.
2083 $node->_[HDOM_INFO_INNER] = $this->default_br_text;
2094 $space[2] = $this->copy_skip($this->token_blank);
2096 switch ($this->char) {
2099 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2100 $value = $this->copy_until_char('"');
2101 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2105 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2106 $value = $this->copy_until_char('\'');
2107 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2111 $value = $this->copy_until($this->token_attr);
2114 $value = $this->restore_noise($value);
2120 if($this->stripRNAttrValues) {
2125 // PaperG: If this is a "class" selector, lets get rid of the preceeding
2139 $node->parent = $this->parent;
2140 $this->parent->nodes[] = $node;
2142 $this->parent->children[] = $node;
2148 $node = new simple_html_dom_node($this);
2149 ++$this->cursor;
2151 $this->link_nodes($node, false);
2152 $this->char = (++$this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2158 $this->pos += strspn($this->doc, $chars, $this->pos);
2159 $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2164 $pos = $this->pos;
2165 $len = strspn($this->doc, $chars, $pos);
2166 $this->pos += $len;
2167 $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2169 return substr($this->doc, $pos, $len);
2174 $pos = $this->pos;
2175 $len = strcspn($this->doc, $chars, $pos);
2176 $this->pos += $len;
2177 $this->char = ($this->pos < $this->size) ? $this->doc[$this->pos] : null; // next
2178 return substr($this->doc, $pos, $len);
2183 if ($this->char === null) { return ''; }
2185 if (($pos = strpos($this->doc, $char, $this->pos)) === false) {
2186 $ret = substr($this->doc, $this->pos, $this->size - $this->pos);
2187 $this->char = null;
2188 $this->pos = $this->size;
2192 if ($pos === $this->pos) { return ''; }
2194 $pos_old = $this->pos;
2195 $this->char = $this->doc[$pos];
2196 $this->pos = $pos;
2197 return substr($this->doc, $pos_old, $pos - $pos_old);
2207 $this->doc,
2213 $key = '___noise___' . sprintf('% 5d', count($this->noise) + 1000);
2220 $this->noise[$key] = $matches[$i][$idx][0];
2221 $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
2225 $this->size = strlen($this->doc);
2227 if ($this->size > 0) {
2228 $this->char = $this->doc[0];
2256 if (isset($this->noise[$key])) {
2258 . $this->noise[$key]
2261 // do this to prevent an infinite loop.
2283 foreach($this->noise as $noiseElement) {
2292 return $this->root->innertext();
2299 return $this->root->innertext();
2301 return $this->root->innertext();
2303 return $this->root->text();
2305 return $this->_charset;
2307 return $this->_target_charset;
2313 return $this->root->childNodes($idx);
2318 return $this->root->first_child();
2323 return $this->root->last_child();
2338 return $this->find("#$id", 0);
2343 return $this->find("#$id", $idx);
2348 return $this->find($name, 0);
2353 return $this->find($name, $idx);
2359 $this->load_file($args);