/** * * @return string $viewTemplatePath */ public function render() { $viewTemplatePath = $this->app->getConfig('app.path') . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $this->name . '.btmp'; if (!file_exists($viewTemplatePath)) { $this->app->log("ViewTemplateDoesNotExistException thrown\n\tThe template {$this->name} does not exist or is not readable", 'cache'); throw new bikes_ViewTemplateDoesNotExistException('The template ' . $this->name . ' does not exist or is not readable'); } return $viewTemplatePath; }
/** * * @static * @access public * @return unknown_type */ public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(bikes_App::getInstance()); } return self::$instance; }
/** * Grabs the URI Parameters from the router. * * @access protected * @return void */ protected function getUriParams() { $route = $this->app->getRouter()->getMatch(); if (isset($route['controller'])) { unset($route['controller']); } if (isset($route['action'])) { unset($route['action']); } return $route; }
public function connect($host = null, $port = null) { $this->memcache = new Memcache(); if (!empty($host)) { if (!empty($port)) { $this->memcache->connect($host, $port); } else { $this->memcache->connect($host); } } else { $memcacheHosts = $this->app->getConfig('memcache.host'); if (empty($memcacheHosts)) { throw new Exception('If there are no memecache servers set in your config.ini, you must pass one into the bikes_Cache_Adapter_Memcache::__construct'); } foreach ($this->app->getConfig('memcache.host') as $hostPort) { $server = explode(':', $hostPort); $this->memcache->addServer($server[0], $server[1]); } } }
/** * _loadBy * * @param mixed $column * @param array $ids * @access protected * @return void */ protected function _loadBy($column, $ids) { $column = strtolower($column); if (empty($ids)) { return false; } $db = $this->app->getDb(); $query = 'SELECT * FROM `' . $this->table . '` WHERE `' . $column . '` in('; foreach ($ids as $id) { $query .= ':' . $id . ','; } $query = trim($query, ','); $query .= ');'; $statement = $db->prepare($query); foreach ($ids as $id) { $statement->bindValue(':' . $id, $id); } $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); return $this->indexIds($results, $this->getMasterColumn(), $this->getSlaveColumn()); }
/** * Turns on output buffering, loads the main template into the buffer and iterates * through the views and renders them. Each rendered view is stored in an output buffer, * then the main template buffer regions are string replaced with the view content. * * @return string $layoutBuffer */ public function render() { $bikesFlash = $this->app->getFlash(); $title = $this->pageTitle; $this->loadHelpers(); if (!empty($this->loadedHelpers)) { foreach (array_keys($this->loadedHelpers) as $helper) { $helper_lower = strtolower($helper); ${$helper_lower} = $this->loadedHelpers[$helper]; } } $this->startOutputBuffer(); if (empty($this->useLayout)) { $templateName = $this->app->getConfig('layout.default'); } else { $templateName = $this->useLayout . '.btmp'; } $template = $this->app->getConfig('app.path') . DS . 'templates' . DS . $templateName; if (!file_exists($template)) { $this->app->log("Template is not readable or the file does not exist.\n\tPlease set a correct template name in the config.ini value `layout.default`", 'cache'); throw new bikes_TemplateIsNotThereException('Template ' . $templateName . ' does not exist.'); } include $template; $layoutBuffer = $this->getAndCleanOutputBuffer(); if (!empty($this->viewData)) { extract($this->viewData); } foreach ($this->views as $region => $view) { include $view->render(); $viewBuffer = $this->getAndCleanOutputBuffer(); $layoutBuffer = str_replace('<--{' . $region . '}-->', $viewBuffer, $layoutBuffer); unset($content); } $this->endOutputBuffer(); return $layoutBuffer; }
/** * Returns the core Acl object. * * @access public * @return void */ public function getAcl() { if (!$this->acl instanceof bikes_Acl) { $this->acl = new bikes_Acl(bikes_App::getInstance()); } return $this->acl; }
/** * Fetches database results into a model-collection object. * * @param PDOStatement $pdo * @access public * @return bikes_Collection_Abstract */ public function fetchIntoCollection(PDOStatement $pdo) { $vo = PROJECT . '_VO_' . ucwords($this->name); $collection = PROJECT . '_Collection_' . ucwords($this->name); $collection = new $collection(bikes_App::getInstance()); $pdo->setFetchMode(PDO::FETCH_CLASS, $vo); while ($v = $pdo->fetch()) { $collection->addVo($v->id, $v); } $this->collection = $collection; return $this->collection; }