summaryrefslogtreecommitdiff
path: root/ext/tidy/examples
diff options
context:
space:
mode:
authorJohn Coggeshall <john@php.net>2004-08-28 18:10:21 +0000
committerJohn Coggeshall <john@php.net>2004-08-28 18:10:21 +0000
commit2f4ca9a2d45377317b55b6add11da69b8a2194cb (patch)
tree3287f9c0a828ff749b72e0d538a260985ea11f5c /ext/tidy/examples
parent52d6a64efa7d568496e1947c9a7b76cae60f762f (diff)
downloadphp-git-2f4ca9a2d45377317b55b6add11da69b8a2194cb.tar.gz
Removed examples which don't actually work anymore for PHP 4, and
updated those that do for PHP 5.
Diffstat (limited to 'ext/tidy/examples')
-rw-r--r--ext/tidy/examples/cleanhtml5.php4
-rw-r--r--ext/tidy/examples/dumpit.php93
-rw-r--r--ext/tidy/examples/dumpit5.php4
-rw-r--r--ext/tidy/examples/urlgrab.php62
-rw-r--r--ext/tidy/examples/urlgrab5.php2
5 files changed, 5 insertions, 160 deletions
diff --git a/ext/tidy/examples/cleanhtml5.php b/ext/tidy/examples/cleanhtml5.php
index c31e36f1f2..4dfd7643e1 100644
--- a/ext/tidy/examples/cleanhtml5.php
+++ b/ext/tidy/examples/cleanhtml5.php
@@ -23,10 +23,10 @@
$tidy->cleanRepair();
- if(!empty($tidy->error_buf)) {
+ if(!empty($tidy->errorBuffer)) {
echo "\n\nThe following errors or warnings occured:\n";
- echo "{$tidy->error_buf}\n";
+ echo "{$tidy->errorBuffer}\n";
}
diff --git a/ext/tidy/examples/dumpit.php b/ext/tidy/examples/dumpit.php
deleted file mode 100644
index e77b7b9323..0000000000
--- a/ext/tidy/examples/dumpit.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
- /*
- * dumpit.php
- *
- * a command-line script which dumps the given HTML, PHP, ASP, XHTML, etc.
- * file as it is represented in the document model.
- *
- * By: John Coggeshall <john@php.net>
- *
- * Usage; php dumpit.php <filename>
- */
-
- tidy_parse_file($_SERVER['argv'][1]);
-
- /* Optionally you can do this here if you want to fix up the document */
-
- /* tidy_clean_repair(); */
-
- $tree = tidy_get_root();
- dump_tree($tree);
- echo "\n";
-
- function node_type($type) {
-
- switch($type) {
-
- case TIDY_NODETYPE_ROOT: return "Root Node";
- case TIDY_NODETYPE_DOCTYPE: return "DocType Node";
- case TIDY_NODETYPE_COMMENT: return "Comment Node";
- case TIDY_NODETYPE_PROCINS: return "ProcIns Node";
- case TIDY_NODETYPE_TEXT: return "Text Node";
- case TIDY_NODETYPE_START: return "Start Node";
- case TIDY_NODETYPE_END: return "End Node";
- case TIDY_NODETYPE_STARTEND: return "Start/End Node";
- case TIDY_NODETYPE_CDATA: return "CDATA Node";
- case TIDY_NODETYPE_SECTION: return "Section Node";
- case TIDY_NODETYPE_ASP: return "ASP Source Code Node";
- case TIDY_NODETYPE_PHP: return "PHP Source Code Node";
- case TIDY_NODETYPE_JSTE: return "JSTE Source Code";
- case TIDY_NODETYPE_XMLDECL: return "XML Declaration Node";
- default: return "Unknown Node";
- }
- }
-
- function do_leaf($string, $indent) {
- for($i = 0; $i < $indent; $i++) {
- echo " ";
- }
- echo $string;
- }
-
- function dump_tree($node, $indent = 0) {
- if($node) {
- /* Put something there if the node name is empty */
- $nodename = trim(strtoupper($node->name));
- $nodename = (empty($nodename)) ? "[EMPTY]" : $nodename;
-
- /* Generate the Node, and a pretty name for it */
- do_leaf(" + $nodename (".node_type($node->type).")\n", $indent);
-
- /* Check to see if this node is a text node. Text nodes are
- generated by start/end tags and contain the text in between.
- i.e. <B>foo</B> will create a text node with $node->value
- equal to 'foo' */
- if($node->type == TIDY_NODETYPE_TEXT) {
- do_leaf(" |\n", $indent);
- do_leaf(" +---- Value: '{$node->value}'\n", $indent);
- }
-
- /* Any attributes on this node? */
- if(count($node->attributes())) {
- do_leaf(" |\n", $indent);
- do_leaf(" +---- Attributes\n", $indent);
-
- /* Cycle through the attributes and display them and their values. */
- foreach($node->attributes() as $attrib) {
- do_leaf(" +--{$attrib->name}\n", $indent);
- do_leaf(" | +-- Value: {$attrib->value}\n", $indent);
- }
- }
-
- /* Recurse along the children to generate the remaining nodes */
- if($node->has_children()) {
- foreach($node->children() as $child) {
- dump_tree($child, $indent + 3);
- }
- }
- }
- }
-
- echo tidy_get_output();
-
-?> \ No newline at end of file
diff --git a/ext/tidy/examples/dumpit5.php b/ext/tidy/examples/dumpit5.php
index ad9157f6ad..d7aee2d652 100644
--- a/ext/tidy/examples/dumpit5.php
+++ b/ext/tidy/examples/dumpit5.php
@@ -51,7 +51,7 @@
echo $string;
}
- function dump_tree(tidy_node $node, $indent = 0) {
+ function dump_tree(tidyNode $node, $indent = 0) {
/* Put something there if the node name is empty */
$nodename = trim(strtoupper($node->name));
@@ -80,7 +80,7 @@
}
/* Recurse along the children to generate the remaining nodes */
- if($node->has_children()) {
+ if($node->hasChildren()) {
foreach($node->child as $child) {
dump_tree($child, $indent + 3);
}
diff --git a/ext/tidy/examples/urlgrab.php b/ext/tidy/examples/urlgrab.php
deleted file mode 100644
index 9ec4c42bab..0000000000
--- a/ext/tidy/examples/urlgrab.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
- /*
- * urlgrab.php
- *
- * A simple command-line utility to extract all of the URLS contained
- * within <A HREF> tags from a document.
- *
- * NOTE: Only works with tidy for PHP 4.3.x, please see urlgrab5.php for tidy for PHP 5
- *
- * By: John Coggeshall <john@php.net>
- *
- * Usage: php urlgrab.php <file>
- *
- */
-
- /* Parse the document */
- tidy_parse_file($_SERVER['argv'][1]);
-
- /* Fix up the document */
- tidy_clean_repair();
-
- /* Get an object representing everything from the <HTML> tag in */
- $html = tidy_get_html();
-
- /* Traverse the document tree */
- print_r(get_links($html));
-
- function get_links($node) {
- $urls = array();
-
- /* Check to see if we are on an <A> tag or not */
- if($node->id == TIDY_TAG_A) {
- /* If we are, find the HREF attribute */
- $attrib = $node->get_attr(TIDY_ATTR_HREF);
- if($attrib) {
- /* Add the value of the HREF attrib to $urls */
- $urls[] = $attrib->value;
- }
-
- }
-
- /* Are there any children? */
- if($node->has_children()) {
-
- /* Traverse down each child recursively */
- foreach($node->children() as $child) {
-
- /* Append the results from recursion to $urls */
- foreach(get_links($child) as $url) {
-
- $urls[] = $url;
-
- }
-
- }
- }
-
- return $urls;
- }
-
-?> \ No newline at end of file
diff --git a/ext/tidy/examples/urlgrab5.php b/ext/tidy/examples/urlgrab5.php
index 8e08322a14..875baf0cf9 100644
--- a/ext/tidy/examples/urlgrab5.php
+++ b/ext/tidy/examples/urlgrab5.php
@@ -12,7 +12,7 @@
* Usage: php urlgrab5.php <file>
*
*/
- function dump_nodes(tidy_node $node, &$urls = NULL) {
+ function dump_nodes(tidyNode $node, &$urls = NULL) {
$urls = (is_array($urls)) ? $urls : array();