protected function getTag($group, $condition) { $url = Nano::config('assets')->url . '/scripts/' . $this->getBase() . '/' . $group . '.js'; $time = fileMTime($this->files->get($this, DS . 'input') . DS . 'file1'); $template = '%s<script type="text/javascript" src="%s"></script>%s'; return sprintf($template, $condition ? '<!--[if ' . $condition . ']>' : null, $url . '?' . $time, $condition ? '<![endif]-->' : null); }
protected function getTag($name, $media, $condition) { $url = Nano::config('assets')->url . '/styles/' . $this->getBase() . '/' . $name . '.css'; $time = fileMTime($this->files->get($this, DS . 'input') . DS . 'file1'); $template = '%s<link rel="stylesheet" type="text/css" href="%s" %s/>%s'; return sprintf($template, $condition ? '<!--[if ' . $condition . ']>' : null, $url . '?' . $time, $media ? 'media="' . $media . '" ' : null, $condition ? '<![endif]-->' : null); }
public final function __construct(Nano_Dispatcher $dispatcher) { $this->dispatcher = $dispatcher; $this->helper = Nano::helper(); $this->plugins = new SplObjectStorage(); $this->plugins->addAll(Nano::config('plugins')); }
protected static function getConfig($name) { $config = Nano::config('db'); if (!array_key_exists($name, $config)) { throw new RuntimeException('Unknow database ' . $name); } return $config[$name]; }
public function testParameters() { $route = new Nano_Route_Subdomain('(?P<p1>some)', '(?P<p2>some)'); $_SERVER['HTTP_HOST'] = 'some.' . Nano::config('web')->domain; self::assertTrue($route->match('some')); self::assertArrayHasKey('p1', $route->matches()); self::assertArrayHasKey('p2', $route->matches()); }
/** * @return Assets_Scripts */ public static function script() { if (null === self::$script) { self::$script = new Assets_Scripts(); self::$script->setOutput(Nano::config('assets')->path); } return self::$script; }
/** * @return Nano_Message * @param boolean $reset */ public static function instance($reset = false) { if (null == self::$instance || true === $reset) { self::$instance = new self(); if (isset(Nano::config('web')->lang)) { self::$instance->lang(Nano::config('web')->lang); } } return self::$instance; }
<?php error_reporting(E_ALL); ini_set('error_log', dirName(__FILE__) . '/reports/error.log'); define('TESTING', true); require dirName(__FILE__) . '/../library/Nano.php'; Nano::instance(); Nano::config('selenium'); Nano_Db::setDefault('test');
protected function handleError(Exception $error) { if ($this->throw) { throw $error; } $className = Nano::config('web')->error; if (!$className) { throw $error; } $controller = new $className($this); /* @var $controller Nano_C */ $action = 'e404'; if (self::ERROR_NOT_FOUND != $error->getCode()) { $action = 'e500'; } $controller->error = $error; echo $controller->run($action); }
public function testFileName() { self::assertEquals(Nano::config('log'), Nano_Log::getFile()); }
define('PACK', ROOT . DS . 'packages'); define('APP', ROOT . DS . 'application'); define('SETTINGS', APP . DS . 'settings'); define('CONTROLLERS', APP . DS . 'controllers'); define('MODELS', APP . DS . 'models'); define('LAYOUTS', APP . DS . 'layouts'); define('VIEWS', APP . DS . 'views'); define('HELPERS', APP . DS . 'helpers'); define('PLUGINS', APP . DS . 'plugins'); define('APP_LIB', APP . DS . 'library'); define('MESSAGES', APP . DS . 'messages'); define('PUBLIC', ROOT . DS . 'public'); define('TESTS', ROOT . DS . 'tests'); define('ENV', Nano::config('env')); define('WEB_ROOT', Nano::config('web')->root); define('WEB_URL', Nano::config('web')->url); require LIB . DS . 'Nano' . DS . 'Loader.php'; final class Nano { /** * @var Nano */ private static $instance = null; /** * @var Nano_Dispatcher */ private $dispatcher; /** * @var Nano_Routes */ private $routes;
/** * @return string * @param string $base * @param string $group */ protected function getGroupUrl($base, $group) { return Nano::config('assets')->url . '/' . $this->type . '/' . $base . '/' . $group . '.' . $this->ext . '?' . $this->getGroupTime($base, $group); }
/** * @return string */ protected function getSubDomain() { $result = preg_replace('/\\.' . preg_quote(Nano::config('web')->domain, '/') . '$/i', '', $_SERVER['HTTP_HOST']); $result = strToLower($result); return $result; }