/** * scriptsStart * * @since 2.2.0 */ public static function scriptsStart() { if (Registry::get('loggedIn') === Registry::get('token') && Registry::get('firstParameter') === 'admin') { $output = '<script src="//google-analytics.com/ga.js"></script>'; echo $output; } }
/** * render * * @since 2.2.0 * * @param mixed $src * @param array $options * * @return string */ public static function render($src = null, $options = array()) { $output = null; /* device related images */ if (is_array($src)) { /* process source */ foreach ($src as $key => $value) { if (in_array($key, self::$_config['device']) && Registry::get('my' . ucfirst($key))) { $src = $value; } } } /* collect output */ if (file_exists($src)) { $imageElement = new Html\Element(); $imageElement->init('img', array('alt' => $options['alt'], 'class' => self::$_config['className']['image'] . ' ' . $options['className'], 'src' => self::$_config['placeholder'])); /* collect output */ $output = $imageElement->copy()->attr('data-src', $src); /* placeholder */ if (self::$_config['placeholder']) { /* calculate image ratio */ $imageDimensions = getimagesize($src); $imageRatio = $imageDimensions[1] / $imageDimensions[0] * 100; /* placeholder */ $placeholderElement = new Html\Element(); $placeholderElement->init('div', array('class' => self::$_config['className']['placeholder'], 'style' => 'padding-bottom:' . $imageRatio . '%')); /* collect output */ $output = $placeholderElement->html($output); } /* noscript fallback */ $output .= '<noscript>' . $imageElement . '</noscript>'; } return $output; }
/** * centerStart * * @since 2.2.0 */ public static function centerStart() { if (Registry::get('firstParameter') === 'qunit') { $output = '<div id="qunit" class="wrapper_qunit"></div><div id="qunit-fixture"></div>'; echo $output; } }
/** * renderStart * * @since 3.0.0 */ public static function renderStart() { if (Registry::get('loggedIn') === Registry::get('token') && Registry::get('firstParameter') === 'admin') { $script = Head\Script::getInstance(); $script->init('foot')->appendFile('//google-analytics.com/analytics.js')->appendFile('modules/CallHome/assets/scripts/init.js')->appendFile('modules/CallHome/assets/scripts/call_home.js'); } }
/** * scriptEnd * * @since 2.6.0 */ public static function scriptEnd() { if (Registry::get('loggedIn') === Registry::get('token')) { $output = '<script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.js"></script>'; echo $output; } }
/** * @param object $categories * @param object $articles * * @return string */ protected static function _writeXML($categories = null, $articles = null) { $writer = new XMLWriter(); $writer->openMemory(); $writer->setIndent(true); $writer->setIndentString(' '); $writer->startDocument('1.0', Db::getSetting('charset')); $writer->startElement('urlset'); $writer->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $writer->startElement('url'); $writer->writeElement('loc', Registry::get('root')); $writer->endElement(); /* process categories */ foreach ($categories as $value) { $writer->startElement('url'); $writer->writeElement('loc', Registry::get('root') . Registry::get('parameterRoute') . build_route('categories', $value->id)); $writer->writeElement('lastmod', date('c', strtotime($value->date))); $writer->endElement(); } /* process articles */ foreach ($articles as $value) { $writer->startElement('url'); $writer->writeElement('loc', Registry::get('root') . Registry::get('parameterRoute') . build_route('articles', $value->id)); $writer->writeElement('lastmod', date('c', strtotime($value->date))); $writer->endElement(); } $writer->endElement(); $writer->endDocument(); return $writer->outputMemory(true); }
/** * renderTemplate * * @since 3.0.0 * * @return mixed */ public static function renderTemplate() { $registry = Registry::getInstance(); $request = Request::getInstance(); $language = Language::getInstance(); /* handle notification */ if (!is_dir(self::$_configArray['directory']) && !mkdir(self::$_configArray['directory'])) { self::setNotification('error', $language->get('directory_not_found') . $language->get('colon') . ' ' . self::$_configArray['directory'] . $language->get('point')); } /* prevent as needed */ if ($request->getPost() || $registry->get('noCache')) { return false; } /* cache as needed */ $cache = new Cache(); $cache->init(self::$_configArray['directory'], self::$_configArray['extension']); $fullRoute = $registry->get('fullRoute'); /* load from cache */ if ($cache->validate($fullRoute, self::$_configArray['lifetime'])) { $raw = $cache->retrieve($fullRoute); $content = preg_replace('/' . self::$_configArray['tokenPlaceholder'] . '/', $registry->get('token'), self::_uncompress($raw)); return ['header' => function_exists('gzdeflate') ? 'content-encoding: deflate' : null, 'content' => self::_compress($content)]; } else { $raw = Template\Tag::partial('templates/' . $registry->get('template') . '/index.phtml'); $content = preg_replace('/' . $registry->get('token') . '/', self::$_configArray['tokenPlaceholder'], $raw); $cache->store($fullRoute, self::_compress($content)); return ['content' => $raw]; } }
/** * renderStart * * @since 3.0.0 */ public static function renderStart() { if (Registry::get('firstParameter') === 'tinymce' && Registry::get('secondParameter') === 'upload' && Registry::get('lastParameter') === Registry::get('token')) { Registry::set('renderBreak', true); echo self::_upload(); } }
/** * setUp * * @since 3.0.0 */ public function setUp() { $this->_registry = Registry::getInstance(); $this->_request = Request::getInstance(); $this->_config = Config::getInstance(); $this->_configArray = $this->_config->get(); }
/** * scriptsEnd * * @since 2.2.0 */ public static function scriptsEnd() { if (!Registry::get('adminParameter')) { $output = '<script src="' . self::$_config['apiUrl'] . '?key=' . self::$_config['apiKey'] . '&sensor=' . self::$_config['sensor'] . '"></script>'; echo $output; } }
/** * contentFragmentEnd * * @since 3.0.0 */ public static function contentFragmentEnd() { if (Registry::get('lastTable') === 'articles') { $url = Registry::get('root') . Registry::get('parameterRoute') . Registry::get('fullRoute'); return self::render($url); } }
/** * renderStart * * @since 3.0.0 */ public static function renderStart() { if (Registry::get('loggedIn') !== Registry::get('token')) { $script = Head\Script::getInstance(); $script->init('foot')->appendFile('//google-analytics.com/analytics.js')->appendFile('modules/Analytics/assets/scripts/init.js')->appendFile('modules/Analytics/assets/scripts/analytics.js'); } }
/** * renderStart * * @since 3.0.0 */ public static function renderStart() { if (Registry::get('loggedIn') !== Registry::get('token')) { $script = Head\Script::getInstance(); $script->init('foot')->appendFile('//google-analytics.com/cx/api.js?experiment=' . self::$_configArray['id'])->appendFile('modules/Experiments/assets/scripts/init.js')->appendFile('modules/Experiments/assets/scripts/experiments.js'); } }
/** * scriptStart * * @since 2.2.0 */ public static function scriptStart() { if (Registry::get('loggedIn') !== Registry::get('token')) { $output = '<script src="//google-analytics.com/ga.js"></script>'; echo $output; } }
/** * renderStart * * @since 2.2.0 */ public static function renderStart() { if (Registry::get('firstParameter') === 'manifest_webapp') { Registry::set('renderBreak', true); header('content-type: application/x-web-app-manifest+json'); include_once 'modules/WebApp/files/manifest.json'; } }
/** * articleEnd * * @since 2.2.0 */ public static function articleEnd() { if (Registry::get('lastTable') === 'articles') { $url = Registry::get('root') . '/' . Registry::get('rewriteRoute') . Registry::get('fullRoute'); $output = self::render($url); return $output; } }
/** * renderStart * * @since 2.2.0 */ public static function renderStart() { if (Registry::get('articleId')) { Registry::set('commentReplace', true); /* script */ $script = Head\Script::getInstance(); $script->init('foot')->appendFile(self::$_configArray['url'])->appendFile('modules/Disqus/assets/scripts/init.js'); } }
/** * setUp * * @since 3.0.0 */ public function setUp() { $this->_registry = Registry::getInstance(); $this->_language = Language::getInstance(); $this->_request = Request::getInstance(); $this->_config = Config::getInstance(); $this->_configArray = $this->_config->get(); $this->_config->set('dbPrefix', 'controller_'); }
/** * loaderStart * * @since 2.2.0 */ public static function loaderStart() { if (Registry::get('firstParameter') !== 'admin') { global $loader_modules_styles, $loader_modules_scripts; $loader_modules_styles[] = 'modules/Validator/styles/validator.css'; $loader_modules_scripts[] = 'modules/Validator/scripts/init.js'; $loader_modules_scripts[] = 'modules/Validator/scripts/validator.js'; } }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = null; $outputItem = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', array('class' => self::$_config['className']['title'])); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* fetch articles */ $articles = Db::forTablePrefix('articles')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('category')->findArray(); /* process articles */ if (!$articles) { $error = Language::get('article_no') . Language::get('point'); } else { $accessValidator = new Validator\Access(); $accessDeny = 0; $lastCategory = 0; foreach ($articles as $value) { if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) { $currentCategory = $value['category']; /* collect output */ if ($lastCategory != $currentCategory) { if ($lastCategory > 0) { $output .= $listElement->html($outputItem); $outputItem = null; } $output .= $titleElement->text($currentCategory < 1 ? Language::get('uncategorized') : Db::forTablePrefix('categories')->whereIdIs($currentCategory)->findOne()->title); } /* collect item output */ $outputItem .= '<li>'; $outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']); $outputItem .= '</li>'; /* collect list output */ if (end($articles) === $value) { $output .= $listElement->html($outputItem); $outputItem = null; } $lastCategory = $currentCategory; } else { $accessDeny++; } } /* handle access */ if (count($articles) === $accessDeny) { $error = Language::get('access_no') . Language::get('point'); } } /* handle error */ if ($error) { $output = $listElement->html('<li>' . $error . '</li>'); } return $output; }
/** * renderStart * * @since 3.0.0 */ public static function renderStart() { if (Registry::get('loggedIn') === Registry::get('token')) { /* link */ $link = Head\Link::getInstance(); $link->init()->appendFile('modules/Ace/assets/styles/ace.css'); /* script */ $script = Head\Script::getInstance(); $script->init('foot')->appendFile('//cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js')->appendFile('modules/Ace/assets/scripts/init.js')->appendFile('modules/Ace/assets/scripts/ace.js'); } }
/** * renderStart * * @since 3.0.0 */ public static function renderStart() { if (!Registry::get('adminParameter')) { /* link */ $link = Head\Link::getInstance(); $link->init()->appendFile('modules/Maps/assets/styles/maps.css'); /* script */ $script = Head\Script::getInstance(); $script->init('foot')->appendFile(self::$_configArray['apiUrl'] . '?key=' . self::$_configArray['apiKey'])->appendFile('modules/Maps/assets/scripts/init.js')->appendFile('modules/Maps/assets/scripts/maps.js'); } }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = ''; $outputItem = ''; /* html elements */ $titleElement = new Element('h3', array('class' => self::$_config['className']['title'])); $linkElement = new Element('a'); $listElement = new Element('ul', array('class' => self::$_config['className']['list'])); /* fetch articles */ $articles = Db::forTablePrefix('articles')->selectExpr('*, YEAR(date) as year, MONTH(date) as month')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('date')->findArray(); /* process articles */ if (empty($articles)) { $error = Language::get('article_no') . Language::get('point'); } else { $accessValidator = new Validator\Access(); $accessDeny = 0; $lastDate = 0; foreach ($articles as $value) { if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) { $currentDate = $value['month'] + $value['year']; /* collect output */ if ($lastDate != $currentDate) { if ($lastDate > 0) { $output .= $listElement->html($outputItem); $outputItem = ''; } $output .= $titleElement->text(Language::get($value['month'] - 1, '_month') . ' ' . $value['year']); } /* collect item output */ $outputItem .= '<li>'; $outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']); $outputItem .= '</li>'; /* collect list output */ if (end($articles) === $value) { $output .= $listElement->html($outputItem); $outputItem = ''; } $lastDate = $currentDate; } else { $accessDeny++; } } /* handle access */ if (count($articles) === $accessDeny) { $error = Language::get('access_no') . Language::get('point'); } } /* handle error */ if ($error) { $output = $listElement->html('<li>' . $error . '</li>'); } return $output; }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', ['class' => self::$_configArray['className']['title']]); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* query articles */ $articles = Db::forTablePrefix('articles')->where('status', 1)->whereLanguageIs(Registry::get('language'))->orderByDesc('date')->findMany(); /* process articles */ if (!$articles) { $error = Language::get('article_no') . Language::get('point'); } else { $accessValidator = new Validator\Access(); $accessDeny = 0; $lastDate = 0; foreach ($articles as $value) { if ($accessValidator->validate($value->access, Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) { $month = date('n', strtotime($value->date)); $year = date('Y', strtotime($value->date)); $currentDate = $month + $year; /* collect output */ if ($lastDate != $currentDate) { $output .= $titleElement->text(Language::get($month - 1, '_month') . ' ' . $year); } $lastDate = $currentDate; /* collect item output */ $outputItem = '<li>'; $outputItem .= $linkElement->attr(['href' => Registry::get('parameterRoute') . build_route('articles', $value->id), 'title' => $value->description ? $value->description : $value->title])->text($value->title); $outputItem .= '</li>'; /* collect list output */ $output .= $listElement->html($outputItem); } else { $accessDeny++; } } /* handle access */ if (count($articles) === $accessDeny) { $error = Language::get('access_no') . Language::get('point'); } } /* handle error */ if ($error) { $output = $listElement->html('<li>' . $error . '</li>'); } return $output; }
/** * log * * @since 2.2.0 * * @return array */ protected static function _log() { $root = Registry::get('root'); $fullRoute = Registry::get('fullRoute'); $recentView = Request::getSession($root . '/recent_view'); /* handle recent view */ if ($fullRoute && current($recentView) !== $fullRoute) { if (!is_array($recentView)) { $recentView = array(); } array_unshift($recentView, $fullRoute); Request::setSession($root . '/recent_view', $recentView); } $output = $recentView; return $output; }
/** * adminPanelNotification * * @since 3.0.0 * * @return array */ public static function adminPanelNotification() { /* load result */ $urlBase = self::$_configArray['url'] . Registry::get('root') . '/' . Registry::get('parameterRoute') . Registry::get('fullRoute'); $urlXML = $urlBase . '&out=xml'; $reader = new Reader(); $result = $reader->loadXML($urlXML)->getObject(); /* process result */ foreach ($result as $value) { $type = $value->attributes()->type ? (string) $value->attributes()->type : $value->getName(); if (in_array($type, self::$_configArray['typeArray'])) { $message = ['text' => (string) $value->message, 'attr' => ['href' => $urlBase, 'target' => '_blank']]; self::setNotification($type, $message); } } return self::getNotification(); }
/** * render * * @since 2.2.0 * * @param $alias * @param $path * * @return string */ protected static function _render($alias = null, $path = null) { /* collect title output */ $output = '<h2 class="title_content" title="' . $alias . '">' . PHP_EOL; if (Registry::get('secondParameter') === $alias) { $output .= $alias; } else { $output .= '<a href="preview/' . $alias . '" title="' . $alias . '">' . $alias . '</a>' . PHP_EOL; } $output .= '</h2>' . PHP_EOL; /* collect content output */ if (file_exists($path)) { ob_start(); include_once $path; $output .= ob_get_clean(); } return $output; }
/** * login * * @since 2.2.0 */ protected static function _login() { $root = Registry::get('root'); $token = Registry::get('token'); /* session values */ Request::setSession($root . '/logged_in', $token); Request::setSession($root . '/my_name', 'Anonymous'); Request::setSession($root . '/my_user', 'demo'); Request::setSession($root . '/my_email', '*****@*****.**'); Request::setSession($root . '/categories_new', 1); Request::setSession($root . '/categories_edit', 1); Request::setSession($root . '/articles_new', 1); Request::setSession($root . '/articles_edit', 1); Request::setSession($root . '/comments_new', 1); Request::setSession($root . '/comments_edit', 1); Request::setSession($root . '/settings_edit', 1); Request::setSession($root . '/filter', 1); /* notification */ notification(l('welcome'), l('logged_in'), l('continue'), 'admin'); }
/** * adminPanelNotification * * @since 3.0.0 * * @return array */ public static function adminPanelNotification() { if (Registry::get('firstParameter') !== 'admin') { /* load result */ $urlBase = self::$_configArray['url'] . Registry::get('root') . '/' . Registry::get('parameterRoute') . Registry::get('fullRoute'); $urlJSON = $urlBase . '&out=json'; $reader = new Reader(); $result = $reader->loadJSON($urlJSON)->getArray(); /* process result */ if ($result['messages']) { foreach ($result['messages'] as $value) { if (in_array($value['type'], self::$_configArray['typeArray'])) { $message = ['text' => $value['message'], 'attr' => ['href' => $urlBase, 'target' => '_blank']]; self::setNotification($value['type'], $message); } } } else { self::setNotification('success', Language::get('documentValidate', '_validator') . Language::get('point')); } return self::getNotification(); } }
/** * login * * @since 2.4.0 */ protected static function _login() { $root = Registry::get('root'); $token = Registry::get('token'); $tableArray = array('categories', 'articles', 'extras', 'comments', 'groups', 'users'); /* session values */ Request::setSession($root . '/logged_in', $token); Request::setSession($root . '/my_name', 'Demo'); Request::setSession($root . '/my_user', 'demo'); Request::setSession($root . '/my_email', 'demo@localhost'); foreach ($tableArray as $value) { Request::setSession($root . '/' . $value . '_new', 1); Request::setSession($root . '/' . $value . '_edit', 1); Request::setSession($root . '/' . $value . '_delete', 1); } Request::setSession($root . '/modules_install', 0); Request::setSession($root . '/modules_edit', 0); Request::setSession($root . '/modules_uninstall', 0); Request::setSession($root . '/settings_edit', 1); Request::setSession($root . '/filter', 1); /* notification */ notification(Language::get('welcome'), Language::get('logged_in'), Language::get('continue'), 'admin'); }