/** * Prints the HTML for CSS resources * * @param string $collectionName the name of the collection * * @return string the result of the collection **/ public function outputCss($collectionName = null) { $collection = $this->collection($collectionName); if ($collection->getJoin()) { $filename = $collection->getTargetPath(); if (file_exists($filename)) { $time = 0; foreach ($collection->getResources() as $resource) { $tmp = filemtime($resource->getRealTargetPath()); if ($tmp > $time) { $time = $tmp; } } // If created if (filemtime($filename) > $time) { $collection->setTargetUri($collection->getTargetUri() . '?' . filemtime($filename)); return Tag::stylesheetLink($collection->getTargetUri()); } } // Else CREATE $res = parent::outputCss($collectionName); return $res; } return parent::outputCss($collectionName); }
/** * Registers common function in Twig * * @param \Phalcon\Mvc\ViewInterface $view * @param \Phalcon\DiInterface $di * @param array $userFunctions */ protected function registryFunctions($view, DiInterface $di, $userFunctions = array()) { $options = array('is_safe' => array('html')); $functions = array(new \Twig_SimpleFunction('content', function () use($view) { return $view->getContent(); }, $options), new \Twig_SimpleFunction('partial', function ($partialPath) use($view) { return $view->partial($partialPath); }, $options), new \Twig_SimpleFunction('linkTo', function ($parameters, $text = null) { return \Phalcon\Tag::linkTo($parameters, $text); }, $options), new \Twig_SimpleFunction('textField', function ($parameters) { return \Phalcon\Tag::textField($parameters); }, $options), new \Twig_SimpleFunction('passwordField', function ($parameters) { return \Phalcon\Tag::passwordField($parameters); }, $options), new \Twig_SimpleFunction('hiddenField', function ($parameters) { return \Phalcon\Tag::hiddenField($parameters); }, $options), new \Twig_SimpleFunction('fileField', function ($parameters) { return \Phalcon\Tag::fileField($parameters); }, $options), new \Twig_SimpleFunction('checkField', function ($parameters) { return \Phalcon\Tag::checkField($parameters); }, $options), new \Twig_SimpleFunction('radioField', function ($parameters) { return \Phalcon\Tag::radioField($parameters); }, $options), new \Twig_SimpleFunction('submitButton', function ($parameters) { return \Phalcon\Tag::submitButton($parameters); }, $options), new \Twig_SimpleFunction('selectStatic', function ($parameters, $data = array()) { return \Phalcon\Tag::selectStatic($parameters, $data); }, $options), new \Twig_SimpleFunction('select', function ($parameters, $data = array()) { return \Phalcon\Tag::select($parameters, $data); }, $options), new \Twig_SimpleFunction('textArea', function ($parameters) { return \Phalcon\Tag::textArea($parameters); }, $options), new \Twig_SimpleFunction('form', function ($parameters = array()) { return \Phalcon\Tag::form($parameters); }, $options), new \Twig_SimpleFunction('endForm', function () { return \Phalcon\Tag::endForm(); }, $options), new \Twig_SimpleFunction('getTitle', function () { return \Phalcon\Tag::getTitle(); }, $options), new \Twig_SimpleFunction('stylesheetLink', function ($parameters = null, $local = true) { return \Phalcon\Tag::stylesheetLink($parameters, $local); }, $options), new \Twig_SimpleFunction('javascriptInclude', function ($parameters = null, $local = true) { return \Phalcon\Tag::javascriptInclude($parameters, $local); }, $options), new \Twig_SimpleFunction('image', function ($parameters) { return \Phalcon\Tag::image($parameters); }, $options), new \Twig_SimpleFunction('friendlyTitle', function ($text, $separator = null, $lowercase = true) { return \Phalcon\Tag::friendlyTitle($text, $separator, $lowercase); }, $options), new \Twig_SimpleFunction('getDocType', function () { return \Phalcon\Tag::getDocType(); }, $options), new \Twig_SimpleFunction('getSecurityToken', function () use($di) { return $di->get("security")->getToken(); }, $options), new \Twig_SimpleFunction('getSecurityTokenKey', function () use($di) { return $di->get("security")->getTokenKey(); }, $options), new \Twig_SimpleFunction('url', function ($route) use($di) { return $di->get("url")->get($route); }, $options)); if (!empty($userFunctions)) { $functions = array_merge($functions, $userFunctions); } foreach ($functions as $function) { $this->twig->addFunction($function); } }
/** * Import CodeMirror resources * * @return void */ public static function importResources() { echo Tag::javascriptInclude('js/codemirror/lib/codemirror.js'); echo Tag::javascriptInclude('js/codemirror/mode/clike/clike.js'); echo Tag::javascriptInclude('js/codemirror/mode/xml/xml.js'); echo Tag::javascriptInclude('js/codemirror/mode/css/css.js'); echo Tag::javascriptInclude('js/codemirror/mode/php/php.js'); echo Tag::javascriptInclude('js/codemirror/lib/codephalcon.js'); echo Tag::stylesheetLink('css/codemirror/codemirror.css'); echo Tag::stylesheetLink('css/codemirror/codephalcon.css'); }
/** * Registers common function in Twig * * @param \Phalcon\Mvc\ViewInterface $view */ private function registryFunctions($view) { $options = array('is_safe' => array('html')); $functions = array(new \Twig_SimpleFunction('content', function () use($view) { return $view->getContent(); }, $options), new \Twig_SimpleFunction('partial', function ($partialPath) use($view) { return $view->partial($partialPath); }, $options), new \Twig_SimpleFunction('linkTo', function ($parameters, $text = null) { return \Phalcon\Tag::linkTo($parameters, $text); }, $options), new \Twig_SimpleFunction('textField', function ($parameters) { return \Phalcon\Tag::textField($parameters); }, $options), new \Twig_SimpleFunction('passwordField', function ($parameters) { return \Phalcon\Tag::passwordField($parameters); }, $options), new \Twig_SimpleFunction('hiddenField', function ($parameters) { return \Phalcon\Tag::hiddenField($parameters); }, $options), new \Twig_SimpleFunction('fileField', function ($parameters) { return \Phalcon\Tag::fileField($parameters); }, $options), new \Twig_SimpleFunction('checkField', function ($parameters) { return \Phalcon\Tag::checkField($parameters); }, $options), new \Twig_SimpleFunction('radioField', function ($parameters) { return \Phalcon\Tag::radioField($parameters); }, $options), new \Twig_SimpleFunction('submitButton', function ($parameters) { return \Phalcon\Tag::submitButton($parameters); }, $options), new \Twig_SimpleFunction('selectStatic', function ($parameters, $data = []) { return \Phalcon\Tag::selectStatic($parameters, $data); }, $options), new \Twig_SimpleFunction('select', function ($parameters, $data = []) { return \Phalcon\Tag::select($parameters, $data); }, $options), new \Twig_SimpleFunction('textArea', function ($parameters) { return \Phalcon\Tag::textArea($parameters); }, $options), new \Twig_SimpleFunction('form', function ($parameters = []) { return \Phalcon\Tag::form($parameters); }, $options), new \Twig_SimpleFunction('endForm', function () { return \Phalcon\Tag::endForm(); }, $options), new \Twig_SimpleFunction('getTitle', function () { return \Phalcon\Tag::getTitle(); }, $options), new \Twig_SimpleFunction('getTitle', function () { return \Phalcon\Tag::getTitle(); }, $options), new \Twig_SimpleFunction('stylesheetLink', function ($parameters = null, $local = true) { return \Phalcon\Tag::stylesheetLink($parameters, $local); }, $options), new \Twig_SimpleFunction('javascriptInclude', function ($parameters = null, $local = true) { return \Phalcon\Tag::javascriptInclude($parameters, $local); }, $options), new \Twig_SimpleFunction('image', function ($parameters) { return \Phalcon\Tag::image($parameters); }, $options), new \Twig_SimpleFunction('friendlyTitle', function ($text, $separator = null, $lowercase = true) { return \Phalcon\Tag::friendlyTitle($text, $separator, $lowercase); }, $options), new \Twig_SimpleFunction('getDocType', function () { return \Phalcon\Tag::getDocType(); }, $options)); foreach ($functions as $function) { $this->_twig->addFunction($function); } }
public function testIssue1486() { $di = new Phalcon\DI\FactoryDefault(); $di->getshared('url')->setBaseUri('/'); \Phalcon\Tag::setDI($di); $html = \Phalcon\Tag::stylesheetLink('css/phalcon.css'); $this->assertEquals($html, '<link rel="stylesheet" href="/css/phalcon.css" type="text/css" />' . PHP_EOL); $html = \Phalcon\Tag::stylesheetLink(array('css/phalcon.css')); $this->assertEquals($html, '<link rel="stylesheet" href="/css/phalcon.css" type="text/css" />' . PHP_EOL); $html = \Phalcon\Tag::javascriptInclude('js/phalcon.js'); $this->assertEquals($html, '<script src="/js/phalcon.js" type="text/javascript"></script>' . PHP_EOL); $html = \Phalcon\Tag::javascriptInclude(array('js/phalcon.js')); $this->assertEquals($html, '<script src="/js/phalcon.js" type="text/javascript"></script>' . PHP_EOL); }
/** * Import CodeMirror resources * * @return void */ public static function importResources() { echo Tag::stylesheetLink('css/codemirror/ambiance.css'); echo Tag::stylesheetLink('css/codemirror/codemirror.css'); echo Tag::javascriptInclude('js/codemirror/lib/codemirror.js'); echo Tag::javascriptInclude('js/codemirror/addon/edit/matchbrackets.js'); echo Tag::javascriptInclude('js/codemirror/addon/selection/active-line.js'); echo Tag::javascriptInclude('js/codemirror/mode/clike/clike.js'); echo Tag::javascriptInclude('js/codemirror/mode/htmlmixed/htmlmixed.js'); echo Tag::javascriptInclude('js/codemirror/mode/xml/xml.js'); echo Tag::javascriptInclude('js/codemirror/mode/css/css.js'); echo Tag::javascriptInclude('js/codemirror/mode/php/php.js'); echo Tag::javascriptInclude('js/codemirror/lib/codephalcon.js'); echo Tag::stylesheetLink('css/codemirror/codephalcon.css'); }
/** * Prints the HTML for CSS resources. * * @param string $collectionName the name of the collection * * @return string **/ public function outputCss($collectionName = self::DEFAULT_COLLECTION_CSS) { $remote = $this->_config->application->assets->get('remote'); $collection = $this->collection($collectionName); if (!$remote && $collection->getJoin()) { $local = $this->_config->application->assets->get('local'); $lifetime = $this->_config->application->assets->get('lifetime', 0); $filepath = $local . self::GENERATED_STORAGE_PATH . ($filename = $filename = $this->getCollectionFileName($collection, self::FILENAME_PATTERN_CSS)); $collection->setTargetPath($filepath)->setTargetUri($filepath); if ($this->_cache->exists($filename)) { return Tag::stylesheetLink($collection->getTargetUri()); } $res = parent::outputCss($collectionName); $this->_cache->save($filename, true, $lifetime); return $res; } return parent::outputCss($collectionName); }
<?php // Generate <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Rosario" type="text/css"> echo \Phalcon\Tag::stylesheetLink("http://fonts.googleapis.com/css?family=Rosario", false); // Generate <link rel="stylesheet" href="/your-app/css/styles.css" type="text/css"> echo \Phalcon\Tag::stylesheetLink("css/styles.css");
public static function stylesheetLink($parameters = null, $local = true) { return parent::stylesheetLink($parameters, $local); }
function builderStyle() { echo '<style> .dropzone-dashboard { background-color: #ffffff; min-height: 55px; float: left; margin-bottom: 5px; margin-top: 5px; opacity: 0.9; padding: 0; position: relative; transition: opacity 200ms ease; width: 100%; -webkit-transition: all 0.2s ease; -moz-transition: all 0.2s ease; -o-transition: all 0.2s ease; -ms-transition: all 0.2s ease; transition: all 0.2s ease; } .dropzone-dashboard.active { opacity: 1; } .hover { background: #EEE; margin:8px; min-height: 45px; position: relative; width: 100%; -webkit-transition: opacity 0.2s ease; -moz-transition: opacity 0.2s ease; -o-transition: opacity 0.2s ease; -ms-transition: opacity 0.2s ease; transition: opacity 0.2s ease; } </style>'; echo '<style> .dropzone-portlet { background-color: #ffffff; min-height: 55px; float: left; margin-bottom: 5px; margin-top: 5px; opacity: 0.9; padding: 0; position: relative; transition: opacity 200ms ease; width: 100%; -webkit-transition: all 0.2s ease; -moz-transition: all 0.2s ease; -o-transition: all 0.2s ease; -ms-transition: all 0.2s ease; transition: all 0.2s ease; } .dropzone-portlet.active { opacity: 1; } .hover { background: #EEE; margin:8px; min-height: 45px; position: relative; width: 100%; -webkit-transition: opacity 0.2s ease; -moz-transition: opacity 0.2s ease; -o-transition: opacity 0.2s ease; -ms-transition: opacity 0.2s ease; transition: opacity 0.2s ease; } </style>'; echo \Phalcon\Tag::javascriptInclude('assets/global/plugins/jquery-ui/jquery-ui-droppable-iframe-fix.js'); echo \Phalcon\Tag::stylesheetLink("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css"); }
/** * Tests stylesheetLink with a string as the second parameter - remote link * * @author Nikos Dimopoulos <*****@*****.**> * @since 2012-10-26 */ public function testStylesheetLinkWithStringAsSecondParameterRemoteXHTML() { \Phalcon\Tag::setDoctype(\Phalcon\Tag::XHTML10_STRICT); $options = 'http://fonts.googleapis.com/css?family=Rosario'; $expected = '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Rosario" />' . PHP_EOL; $actual = \Phalcon\Tag::stylesheetLink($options, '0'); $this->assertEquals($expected, $actual, sprintf($this->message, 'StylesheetLink remote with string as second parameter')); }
public function testIssue2142() { $di = new Phalcon\DI\FactoryDefault(); $di->getshared('url')->setBaseUri('/'); \Phalcon\Tag::setDI($di); $html = \Phalcon\Tag::stylesheetLink(array('css/phalcon.css', 'rel' => 'stylesheet/less')); $this->assertEquals($html, '<link rel="stylesheet/less" type="text/css" href="/css/phalcon.css" />' . PHP_EOL); }
public static function stylesheetLink($parameters = null, $local = null) { return Tag::stylesheetLink($parameters, $local); }