function __construct($action = null, $method = 'POST') { $this->form = new Element('form', compact('action', 'method'), array()); $args = func_get_args(); if (count($args) == 0) { return; } if (!is_string($args[0])) { $handler = $args[0]; foreach (\Radical\Core\Libraries::get('Web\\Form\\Builder\\Adapter\\*') as $class) { if ($class::is($handler)) { $this->handler = new $class($handler); unset($args[0]); //slice break; } } } }
protected static function getClasses() { return \Radical\Core\Libraries::get(\Radical\Core\Libraries::getProjectSpace('DB\\*')); }
static function register_expr($expr) { foreach (\Radical\Core\Libraries::get($expr) as $class) { self::register($class); } }
private function action_functor($data) { if (is_string($data)) { $len = strlen($data); if ($len == 0) { throw new \InvalidArgumentException('String must be more than 0B'); } $class = $data; if ($data[0] != '\\') { $class_expr = '\\*\\Web\\Page\\Controller\\' . $data; $class = null; foreach (\Radical\Core\Libraries::get($class_expr) as $class) { //$class set break; } if ($class === null) { return null; } } return function ($data) use($class) { return new $class($data); }; } else { if (is_callable($data)) { return $data; } } throw new \InvalidArgumentException("Invalid argument type:" . gettype($data)); }
static function getTypes() { static $cache = null; if ($cache === null) { $cache = \Radical\Core\Libraries::get('Radical\\Database\\SQL\\Parse\\Types\\*'); } return $cache; }
static function get($fromType) { foreach (\Radical\Core\Libraries::get(self::TYPES_EXPR) as $class) { if ($class::is($fromType)) { return new $class($fromType); } } }
/** * Calls the init functions for all the error modules */ function __construct() { //Itterate all error trackers foreach (\Radical\Core\Libraries::get(self::ERRORS_EXPR) as $class) { $class::Init(); } parent::__construct(); }
private function make_object($http_method, $type) { //Find Class $c = $this->classPrefix . $this->module; $classes = Libraries::get($c); if (!count($classes)) { return null; } $c = $classes[0]; return new $c($this->query, $type, $http_method); }
static function find($library, $version = null) { $library = strtolower($library); $libs = Libraries::get('Web\\Resource\\Javascript\\Libraries\\*'); foreach ($libs as $l) { $ll = strtolower(array_pop(explode('\\', $l))); if ($ll == $library) { return new $l($version); } } }
private function getClass() { $ns = $this->ns; if ($this->ns === null) { $ns = '*'; } $class = '\\' . $ns . '\\CLI\\Daemon\\Module\\' . $this->module; if ($this->ns === null) { $classes = \Radical\Core\Libraries::get($class); if ($classes) { return $classes[0]; } return null; } return $class; }
function __construct($class) { if ($class instanceof ITable) { $class = get_class($class); } else { if (!class_exists($class)) { $class2 = \Radical\Core\Libraries::getProjectSpace('DB\\' . $class); if (class_exists($class2)) { $class = $class2; } else { throw new \Exception($class . ' class does not exist'); } } if (!CoreInterface::oneof($class, '\\Radical\\Database\\Model\\ITable')) { throw new \Exception($class . ' is not a Database Table object'); } } $this->class = $class; }
private function getClass() { $ns = $this->ns; if ($this->ns === null) { $ns = '*'; } $class = '\\' . $ns . '\\CLI\\Cron\\Jobs\\' . $this->job; if ($this->ns === null) { $classes = \Radical\Core\Libraries::get($class); if (empty($classes)) { throw new \Exception("No class found matching: " . $class); } if ($classes) { return $classes[0]; } return null; } return $class; }
static function recognise(URL $url) { $path = $url->getPath()->getPath(true); $match = null; foreach (static::$match as $expr => $class) { $matches = Format::consumeRegex($path, $expr, $match); if ($matches) { if (is_array($class) || is_string($class)) { if (is_array($class)) { $data = isset($class['data']) ? $class['data'] : $match; $class = $class['class']; } else { $data = $match; //matched but no data if ($data === true) { $data = array(); } } if (is_string($class)) { if ($class[0] != '\\') { $class_expr = '\\*\\Web\\Page\\Controller\\' . $class; $class = null; foreach (\Radical\Core\Libraries::get($class_expr) as $class) { //$class set break; } if ($class === null) { return null; } } return new $class($data); } } return $class; } } }
/** * Return all Adapters * * @return array */ static function adapters() { return \Radical\Core\Libraries::get('Radical\\Web\\Templates\\Adapter\\*'); }
static function getAll() { return \Radical\Core\Libraries::get(static::CLASS_BASE . '\\*'); }
/** * Gets the static and dynamic dependencies for a class or group of classes. * * @param mixed $classes Either a string specifying a class, or a numerically indexed array * of classes * @param array $options * @return array An array of the static and dynamic class dependencies * @todo Document valid options */ public static function dependencies($classes, array $options = array()) { $defaults = array('type' => null); $options += $defaults; $static = $dynamic = array(); $trim = function ($c) { return trim(trim($c, '\\')); }; $join = function ($i) { return join('', $i); }; foreach ((array) $classes as $class) { $data = explode("\n", file_get_contents(\Radical\Core\Libraries::path($class))); $data = "<?php \n" . join("\n", preg_grep('/^\\s*use /', $data)) . "\n ?>"; $classes = array_map($join, Parser::find($data, 'use *;', array('return' => 'content', 'lineBreaks' => true, 'startOfLine' => true, 'capture' => array('T_STRING', 'T_NS_SEPARATOR')))); if ($classes) { $static = array_unique(array_merge($static, array_map($trim, $classes))); } $classes = static::info($class . '::$_classes', array('value')); if (isset($classes['value'])) { $dynamic = array_merge($dynamic, array_map($trim, array_values($classes['value']))); } } if (empty($options['type'])) { return array_unique(array_merge($static, $dynamic)); } $type = $options['type']; return isset(${$type}) ? ${$type} : null; }
protected function _getModule($module, $ns = 'DB') { return \Radical\Core\Libraries::getProjectSpace($ns . '\\' . ucfirst($module)); }
static function objectify($object, $data = null) { $class = \Radical\Core\Libraries::getProjectOrCommon('*\\Web\\Page\\Controller\\' . $object); if (!$class) { return null; } return new $class($data); }