/**
  * @expectedException QueryPathException
  */
 public function testAutoloadExtensions()
 {
     // FIXME: This isn't really much of a test.
     QueryPathExtensionRegistry::autoloadExtensions(FALSE);
     try {
         qp()->stubToe();
     } catch (Exception $e) {
         QueryPathExtensionRegistry::autoloadExtensions(TRUE);
         throw $e;
     }
 }
 /**
  * Enable or disable automatic extension loading.
  *
  * If extension autoloading is disabled, then QueryPath will not 
  * automatically load all registred extensions when a new QueryPath
  * object is created using {@link qp()}.
  */
 public static function autoloadExtensions($boolean = TRUE)
 {
     self::$useRegistry = $boolean;
 }
Beispiel #3
0
            } elseif (is_array($li) || $li instanceof Traversable) {
                $q->append('<li><ul/></li>')->find('li:last > ul');
                $q = $this->listImpl($li, $type, $opts, $q);
                $q->parent();
            } else {
                $q->append('<li>' . $li . '</li>');
            }
        }
        return $q;
    }
    protected function isAssoc($array)
    {
        return count(array_diff_key($array, range(0, count($array) - 1))) != 0;
    }
}
QueryPathExtensionRegistry::extend('QPList');
interface TableAble
{
    public function getHeaders();
    public function getRows();
    public function size();
}
class QPTableData implements TableAble, IteratorAggregate
{
    protected $headers;
    protected $rows;
    protected $caption;
    protected $p = -1;
    public function setHeaders($array)
    {
        $this->headers = $array;
Beispiel #4
0
 public function __call($name, $arguments)
 {
     if (!QueryPathExtensionRegistry::$useRegistry) {
         throw new QueryPathException("No method named {$name} found (Extensions disabled).");
     }
     if (empty($this->ext)) {
         $this->ext = QueryPathExtensionRegistry::getExtensions($this);
     }
     if (!empty($this->ext) && QueryPathExtensionRegistry::hasMethod($name)) {
         $owner = QueryPathExtensionRegistry::getMethodClass($name);
         $method = new ReflectionMethod($owner, $name);
         return $method->invokeArgs($this->ext[$owner], $arguments);
     }
     throw new QueryPathException("No method named {$name} found. Possibly missing an extension.");
 }
Beispiel #5
0
     */
    public function columnBefore($columnName, $wrap = NULL)
    {
        return $this->addData($columnName, 'before', $wrap);
    }
    /**
     * Insert data from the given column(s) after each element in the QueryPath.
     *
     * This inserts data from the given columns after each element in the QueryPath
     * object. IF HTML/XML is given in the $wrap parameter, then the column data
     * will be wrapped in that markup before being inserted into the QueryPath.
     *
     * @param mixed $columnName
     *  Either a string or an array of strings. The value(s) here should match 
     *  one or more column headers from the current SQL {@link query}'s results.
     * @param string $wrap
     *  IF this is supplied, then the value or values retrieved from the database
     *  will be wrapped in this HTML/XML before being inserted into the QueryPath.
     * @see QueryPath::wrap()
     * @see QueryPath::after()
     * @see appendColumn()
     */
    public function columnAfter($columnName, $wrap = NULL)
    {
        return $this->addData($columnName, 'after', $wrap);
    }
}
// The define allows another class to extend this.
if (!defined('QPDB_OVERRIDE')) {
    QueryPathExtensionRegistry::extend('QPDB');
}
Beispiel #6
0
 /**
  * Call extension methods.
  *
  * This function is used to invoke extension methods. It searches the
  * registered extenstensions for a matching function name. If one is found,
  * it is executed with the arguments in the $arguments array.
  * 
  * @throws QueryPathException
  *  An exception is thrown if a non-existent method is called.
  */
 public function __call($name, $arguments)
 {
     if (!QueryPathExtensionRegistry::$useRegistry) {
         throw new QueryPathException("No method named {$name} found (Extensions disabled).");
     }
     // Loading of extensions is deferred until the first time a
     // non-core method is called. This makes constructing faster, but it
     // may make the first invocation of __call() slower (if there are
     // enough extensions.)
     //
     // The main reason for moving this out of the constructor is that most
     // new QueryPath instances do not use extensions. Charging qp() calls
     // with the additional hit is not a good idea.
     //
     // Also, this will at least limit the number of circular references.
     if (empty($this->ext)) {
         // Load the registry
         $this->ext = QueryPathExtensionRegistry::getExtensions($this);
     }
     // Note that an empty ext registry indicates that extensions are disabled.
     if (!empty($this->ext) && QueryPathExtensionRegistry::hasMethod($name)) {
         $owner = QueryPathExtensionRegistry::getMethodClass($name);
         $method = new ReflectionMethod($owner, $name);
         return $method->invokeArgs($this->ext[$owner], $arguments);
     }
     throw new QueryPathException("No method named {$name} found. Possibly missing an extension.");
 }
Beispiel #7
0
     *
     * @param array $array
     *  The array to test.
     * @return Boolean
     *  TRUE if this is an associative array, FALSE otherwise.
     */
    public function isAssoc($array)
    {
        $i = 0;
        foreach ($array as $k => $v) {
            if ($k !== $i++) {
                return TRUE;
            }
        }
        // If we get here, all keys passed.
        return FALSE;
    }
    /**
     * Convert a function name to a CSS class selector (e.g. myFunc becomes '.myFunc').
     * @param string $mname
     *  Method name.
     * @return string
     *  CSS 3 Class Selector.
     */
    protected function method2class($mname)
    {
        return '.' . substr($mname, 3);
    }
}
QueryPathExtensionRegistry::extend('QPTPL');