function get_slug($id = 0) { if ($id == 0) { $app = Slim\Slim::getInstance(); return $app->request()->getResourceUri(); } $page = api\Controller\PageController::getPage($id); return $page->slug; }
public function search($id, $meta) { if ($id != 0 && ($page = PageController::getPage($id))) { $share = $page->as_array(); if (array_key_exists($meta, $share)) { return $share[$meta]; } else { return $this->search($share['parent'], $meta); } } else { return !isset($this->settings->meta) ? 'no value' : $this->settings->meta; } }
try { if (is_readable($path = __ROOT__ . 'public/themes/' . $themeconfig['theme'] . DS . 'functions.php')) { require $path; } } catch (\PDOException $e) { $app->getLog()->error($e->getMessage()); } $app->hook('slim.before.dispatch', function () use($app) { $iscms = (bool) strpos($_SERVER['REQUEST_URI'], 'cms'); $isapi = (bool) preg_match('|/api/v.*$|', $_SERVER['REQUEST_URI']); if (!$iscms && !$isapi) { $app->applyHook('before.page'); $resource = ltrim($app->request()->getResourceUri(), '/'); $param = explode('/', $resource); // get Page $home = \api\Controller\PageController::getPage($app->config('theme')->home)->slug; $uri = $param[0] != '' ? $param : explode('/', $home); $app->page = \api\Controller\PageController::slug($uri); $app->applyHook('after.page'); } }); $app->hook('slim.before.dispatch', function () use($app) { // get Template $templateData = (object) array('body_classes' => 'page ', 'page' => new \helpers\Page(), 'site' => $app->config('theme'), 'loc' => array('url' => $app->request()->getUrl() . $app->request()->getScriptName() . '/' . $app->config('language') . $app->request()->getResourceUri(), 'host' => $app->request()->getUrl(), 'hostname' => $app->request()->getHost(), 'root' => __ROOT__ . 'public/', 'path' => $app->request()->getScriptName(), 'theme' => __ROOT__ . 'public/themes/' . $app->config('theme')->theme . DS), 'lang' => $app->config('language'), 'get' => $_GET, 'post' => $_POST, 'cookie' => $_COOKIE, 'session' => $_SESSION, 'production' => !HTML5_DEBUG); $app->applyHook('data', $templateData); $app->view()->appendData((array) $templateData); }); function require_all($mod) { $fi = new FilesystemIterator($mod, FilesystemIterator::SKIP_DOTS); foreach ($fi as $file) {
private static function _findPage($id) { $p = PageController::getPage($id); if ($p) { return $p; } return null; }