/** * @param string $arg current path * @return string whether the current li is active or not */ protected function active($arg) { $active = true; $level = count(explode('/', URLs::getInstance()->root())) - 2; $regexp = '/' . str_replace('/', '\\/', URLs::getInstance()->root()) . '/'; foreach (explode('/', preg_replace($regexp, '', $arg, 1)) as $module) { $active &= URLs::getInstance()->module($level) == $module; $level++; } return $active ? 'class="active"' : ''; }
protected function prefix($anchor) { $root = URLs::getInstance()->root(); if ($anchor && URLs::getInstance()->isRoot()) { $prefix = '#'; } else { if ($anchor || URLs::getInstance()->isRaw() && $anchor) { $prefix = $root . '#'; } else { $prefix = $root; } } return $prefix; }
protected function actionListener() { try { $module = URLs::getInstance()->module(); $config = Config::getInstance()->hasPlugin($module) ? Config::getInstance()->getPlugin($module) : Config::getInstance()->getConfig(); $this->model = new Container($config); $this->addModel($this->model, $config); $this->navigation = new $this->view($this->model, $config); } catch (ErrorException $e) { $this->model = new Container([]); // TODO } catch (Exception $e) { $this->model = new Container([]); // TODO } }
private function __construct() { $this->config = Config::getInstance()->getGeneralArray('head'); self::setTitle($this->config['title'] . ' - ' . URLs::getInstance()->module()); // default meta tags self::addMeta('description', $this->config['description']); if (isset($this->config['meta'])) { foreach ($this->config['meta'] as $k => $v) { self::addMeta($k, $v); } } // default og tags $title = $this->config['title'] . ' - ' . URLs::getInstance()->module(); self::addOg('title', $title); self::addOg('description', $this->config['description']); self::addOg('url', 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); self::addOg('image', $this->config['image']); self::addOg('type', 'website'); }
protected function actionListener() { try { $this->root = Config::getInstance()->getGeneral('general', 'app_root'); $module = URLs::getInstance()->module(); if (Config::getInstance()->hasPlugin($module)) { // if the module part of the URI may be a plugin $config = Config::getInstance()->getPlugin($module); $this->root .= $module . '/'; } else { $config = Config::getInstance()->getConfig(); } $this->model = new Container($config); foreach ($config as $key => $value) { $this->model->addModel(parent::evaluateModel($value), $key); } } catch (ErrorException $e) { $this->model = new Container(array()); // TODO } catch (Exception $e) { $this->model = new Container(array()); // TODO } }
protected function resolveURL($config, $level) { if ($value = URLs::getInstance()->level($level)) { // if a dropdown is present if (array_key_exists($value, $config)) { $config = self::resolveURL($config[$value], $level + 1); } else { if (array_key_exists('path', $config)) { // if URL points to static link $config['path'] = $config['path'] . $value . $config['type']::MIME; } else { throw new Exception('The requested URL is not available.'); } } } return $config; }
protected function pager($count, $limit) { $pager = ''; if (!is_null($limit)) { $prev = isset($_GET['page']) ? $_GET['page'] - 1 : 0; $next = isset($_GET['page']) ? $_GET['page'] + 1 : 2; $self = URLs::getInstance()->getURI() . '?' . QueryString::remove('page', $_SERVER['QUERY_STRING']) . '&page='; $self = Config::getInstance()->app_root . $self; if ($prev > 0) { $pager = '<li class="previous"><a href="' . $self . $prev . '">← Newer</a></li>'; } if ($next <= ceil($count / $limit)) { $pager .= '<li class="next"><a href="' . $self . $next . '">Older →</a></li>'; } $pager = '<ul class="pager">' . $pager . '</ul>'; $pager = '<div class="row"><div class="col-md-12">' . $pager . '</div></div>'; } return $pager; }
$config = Config::getInstance()->getGeneralArray('general'); if (isset($config['highlight']) && $config['highlight']) { $style = isset($config['scheme']) ? $config['scheme'] : 'default.css'; Head::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/css/' . $style); Script::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/js/prism.js'); } if (array_key_exists('img_resize', $config) && $config['img_resize']) { Script::getInstance()->link('image.js'); } Head::getInstance()->link(PUBLIC_LIB_DIR . 'bootstrap/css/bootstrap.min.css'); Head::getInstance()->link(PUBLIC_LIB_DIR . 'font-awesome/css/font-awesome.min.css'); // Add jquery and bootstrap into header so included HTML pages can use the libs Head::getInstance()->linkScript(PUBLIC_LIB_DIR . 'jquery/js/jquery.min.js'); Head::getInstance()->linkScript(PUBLIC_LIB_DIR . 'bootstrap/js/bootstrap.min.js'); // Onepager or not if (URLs::getInstance()->isPlugin()) { // plugin $layout = Config::getInstance()->getGeneral('general', 'plugin_layout'); } else { $layout = Config::getInstance()->getGeneral('general', 'page_layout'); } switch ($layout) { case "floating": $container = new FloatingController(); $navigation = new NavigationController("FloatingNavigationView"); break; case "stacked": default: $container = new StackedController(); $navigation = new NavigationController("StackedNavigationView"); }
* You should have received a copy of the GNU General Public License * along with the project. if not, write to the Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ include_once '../src/config.php'; include_once LIB_DIR . 'Autoload.php'; include_once LIB_DIR . 'ScanDir.php'; ini_set('display_errors', 1); $src = Autoload::getInstance(SRC_DIR, false)->getClasses(); $lib = Autoload::getInstance(LIB_DIR, false)->getClasses(); $classes = array_merge($src, $lib); set_error_handler("error_handler", E_ALL); /** * Parse REQUEST_URI to enable pretty URLS */ URLs::getInstance()->parseURI(); /** * setup page and load provided business-casual.php */ $config = Config::getInstance()->getGeneralArray('general'); if (isset($config['highlight']) && $config['highlight']) { $style = isset($config['scheme']) ? $config['scheme'] : 'default.css'; Head::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/css/' . $style); Script::getInstance()->link(PUBLIC_LIB_DIR . 'prismjs/js/prism.js'); } if (array_key_exists('img_resize', $config) && $config['img_resize']) { Script::getInstance()->link('image.js'); } Head::getInstance()->link(PUBLIC_LIB_DIR . 'bootstrap/css/bootstrap.min.css'); Head::getInstance()->link(PUBLIC_LIB_DIR . 'font-awesome/css/font-awesome.min.css'); // Add jquery and bootstrap into header so included HTML pages can use the libs
protected function pager($model) { $pager = ''; if (!array_key_exists('paging', $model->config) || $model->config['paging']) { if (!is_null($model->limit)) { $prev = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] - 1 : 0; $next = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] + 1 : 2; $self = URLs::getInstance()->getURI() . '?' . QueryString::remove('page', $_SERVER['QUERY_STRING']) . '&page='; $self = Config::getInstance()->app_root . $self; if ($prev > 0) { $pager = '<li class="previous"><a href="' . $self . $prev . '"><i class="fa fa-chevron-left"></i> Newer</a></li>'; } if ($next <= ceil($model->count / $model->limit)) { $pager .= '<li class="next"><a href="' . $self . $next . '">Older <i class="fa fa-chevron-right"></i></a></li>'; } $pager = '<ul class="pager">' . $pager . '</ul>'; $pager = '<div class="row"><div class="col-md-12">' . $pager . '</div></div>'; } } return $pager; }
protected function raw($view) { $raw = URLs::getInstance()->getURI(); if (URLs::getInstance()->isRaw() && is_file($raw)) { switch (pathinfo($raw, PATHINFO_EXTENSION)) { case 'html': $config = ['key' => 'raw', 'name' => 'raw', 'path' => $raw, 'subtitle' => false]; $model = new HyperTextMarkup($config); break; case 'php': $config = ['key' => 'raw', 'name' => 'raw', 'path' => $raw, 'subtitle' => false]; $model = new HypertextPreprocessor($config); break; default: throw new Exception('The requested URL is not available.'); } $this->view = new $view($model, $config); } else { throw new Exception('The requested URL is not available.'); } }