作者:EtienneBruine
项目:redaxscrip
/**
* 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;
}
}
作者:amanpreetsinghmalhotr
项目:redaxscrip
/**
* 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;
}
作者:stefanoss
项目:redaxscrip
/**
* 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;
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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');
}
}
作者:amanpreetsinghmalhotr
项目:redaxscrip
/**
* 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;
}
}
作者:redaxmedi
项目:redaxscrip
/**
* @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);
}
作者:redaxmedi
项目:redaxscrip
/**
* 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];
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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();
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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();
}
作者:EtienneBruine
项目:redaxscrip
/**
* 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;
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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);
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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');
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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');
}
}
作者:joergsteinhaue
项目:redaxscrip
/**
* 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;
}
}
作者:stefanoss
项目:redaxscrip
/**
* 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';
}
}
作者:EtienneBruine
项目:redaxscrip
/**
* 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;
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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');
}
}
作者:redaxmedi
项目:redaxscrip
/**
* 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_');
}
作者:joergsteinhaue
项目:redaxscrip
/**
* 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';
}
}
作者:joergsteinhaue
项目:redaxscrip
/**
* 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;
}