/**
  * Download and parse the data from the specified endpoint using an HTTP GET.
  * @param mixed $cache_for An expression of time (e.g., 10 minutes), or 0 to cache forever, or FALSE to flush the cache, or -1 to skip over all caching (the default)
  * @param string One of clApi::METHOD_GET or clApi::METHOD_POST, or null
  * @param string (optional) Force the node type, ignoring content type signals and auto-detection
  * @return clNode if parsing succeeds; otherwise FALSE.
  * @see http://php.net/manual/en/function.strtotime.php
  */
 function &parse($cache_for = -1, $override_method = null, $node_type = null)
 {
     $node = false;
     if (is_null($this->download)) {
         $this->download = $this->download(false, $cache_for, $override_method);
     }
     // if the download succeeded
     if ($this->download->is2__()) {
         if ($node_type) {
             $node = clNode::getNodeFor($this->download->getContent(), $node_type);
         } else {
             if ($this->download->isXml()) {
                 $node = clNode::getNodeFor($this->download->getContent(), 'xml');
             } else {
                 if ($this->download->isJson()) {
                     $node = clNode::getNodeFor($this->download->getContent(), 'json');
                 } else {
                     throw new clException("Unable to determine content type. You can force a particular type by passing a third argument to clApi->parse(\$cache_for = -1, \$override_method = null, \$node_type = null).");
                 }
             }
         }
     }
     return $node;
 }
Beispiel #2
0
        } else {
            if (is_array($node)) {
                foreach ($node as $instance) {
                    self::blockquote($name, $instance);
                }
            }
        }
    }
    function __get($name)
    {
        $sxml = $this->__value;
        return $sxml->{$name};
    }
    function __toString()
    {
        $this->blockquote();
        return '';
    }
}
$node = new clNode($root);
?>

<?php 
foreach ($node->get('entry[0]/category') as $category) {
    ?>
	<?php 
    echo $category->info();
}
?>

    function info($path = null, $limit = null, $source = null)
    {
        if (!self::$jqueryOut) {
            ?>
	
				<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
				<script type="text/javascript">
					jQuery.noConflict();
					function coreylib_toggle(a) {
						a = jQuery(a);
						a.parent().children('blockquote').toggle();
						if (a.hasClass('open')) {
							a.children('span:first').text('+'); 
							a.removeClass('open');
						}
						else {
							a.children('span:first').text('-');
							a.addClass('open');
						}
					}
				</script>
				<style>
					.coreylib blockquote {
						background-color:#fff; color:black; border:1px solid black; padding: 10px; margin: 0px 0px 10px 0px;
					}
					.coreylib blockquote a {
						font-weight:bold; text-decoration:none;
					}
					.coreylib blockquote blockquote {
						padding: 0;
						border: none;
					}
					.coreylib blockquote blockquote.hide {
						display:none; margin: 0px 0px 0px 15px
					}
					.coreylib blockquote blockquote.show {
						color:black; background-color:#fff; border: 1px solid black; padding:10px; margin:0px 0px 10px 0px;
					}
					.coreylib blockquote blockquote a {
						width:20px;
					}
					.coreylib .att {
						font-weight:bold; color:purple;
					}
				</style>
			<?php 
            self::$jqueryOut = true;
        }
        if ($source) {
            echo '<div class="coreylib"><blockquote><a href="javascript:;" onclick="coreylib_toggle(this);">[<span>+</span>]</a> ' . $source;
        }
        $node = $this->get($path, $limit);
        if (is_array($node)) {
            foreach ($node as $n) {
                self::blockquote($n->__name, $n);
            }
        } else {
            if (is_object($node)) {
                self::blockquote($node->__name, $node, $source);
            } else {
                if ($node !== null) {
                    echo "{$path}: {$node}";
                }
            }
        }
        if ($source) {
            echo '</blockquote></div>';
        }
        return '';
    }
Beispiel #4
0
    function info($path = null, $limit = null, $source = null)
    {
        if (!self::$jqueryOut) {
            ?>
	
				<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
				<script type="text/javascript">
					function coreylib_toggle(a) {
						$(a).parent().children('blockquote').toggle();
						if ($(a).children('img').attr('src').match(/add.png$/))
							$(a).children('img').attr('src', 'http://coreylib.googlecode.com/svn/trunk/docs/delete.png');
						else if ($(a).children('img').attr('src').match(/delete.png$/))
							$(a).children('img').attr('src', 'http://coreylib.googlecode.com/svn/trunk/docs/add.png');
					}
				</script>
			<?php 
            self::$jqueryOut = true;
        }
        if ($source) {
            echo '<blockquote style="background-color:#fff; color:black; border:1px solid black; padding: 10px; margin: 0px 0px 10px 0px;"><a style="font-weight:bold; text-decoration:none;" href="javascript:;" onclick="coreylib_toggle(this);"><img src="http://coreylib.googlecode.com/svn/trunk/docs/add.png" border="0" /></a> ' . $source;
        }
        $node = $this->get($path, $limit);
        if (is_array($node)) {
            foreach ($node as $n) {
                self::blockquote($n->__name, $n);
            }
        } else {
            if (is_object($node)) {
                self::blockquote($node->__name, $node, $source);
            } else {
                if ($node !== null) {
                    echo "{$path}: {$node}";
                }
            }
        }
        if ($source) {
            echo '</blockquote>';
        }
        return '';
    }