public function filter_theme_call_header($return, $theme) { if (User::identify() != FALSE) { Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); } return $return; }
public function action_template_header($theme) { Stack::add('template_header_javascript', Site::get_url('scripts') . "/jquery.js", 'jquery'); Stack::add('template_header_javascript', Site::get_url('theme') . "/js/jquery.bigframe.js", 'jquery.bigframe', 'jquery'); Stack::add('template_header_javascript', Site::get_url('theme') . "/js/jquery.dimensions.js", 'jquery.dimensions', 'jquery'); Stack::add('template_header_javascript', Site::get_url('theme') . "/js/jquery.tooltip.js", 'jquery.tooltip', 'jquery'); }
/** * Returns all theme information -- dir, path, theme.xml, screenshot url * @return array An array of Theme data **/ public static function get_all_data() { if ( !isset( self::$all_data ) ) { foreach ( self::get_all() as $theme_dir => $theme_path ) { $themedata = array(); $themedata['dir'] = $theme_dir; $themedata['path'] = $theme_path; $themedata['theme_dir'] = $theme_path; $themedata['info'] = simplexml_load_file( $theme_path . '/theme.xml' ); if ( $themedata['info']->getName() != 'pluggable' || (string) $themedata['info']->attributes()->type != 'theme' ) { $themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png"; $themedata['info']->description = '<span class="error">' . _t( 'This theme is a legacy theme that is not compatible with Habari ' ) . Version::get_habariversion() . '. <br><br>Please update your theme.</span>'; $themedata['info']->license = ''; } else { foreach ( $themedata['info'] as $name=>$value ) { $themedata[$name] = (string) $value; } if ( $screenshot = Utils::glob( $theme_path . '/screenshot.{png,jpg,gif}', GLOB_BRACE ) ) { $themedata['screenshot'] = Site::get_url( 'habari' ) . dirname( str_replace( HABARI_PATH, '', $theme_path ) ) . '/' . basename( $theme_path ) . "/" . basename( reset( $screenshot ) ); } else { $themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png"; } } self::$all_data[$theme_dir] = $themedata; } } return self::$all_data; }
/** * Create the bookmarklet that is appropriate for the client's User Agent * * @return array The array of actions to attach to the specified $plugin_id */ private function get_bookmarklet() { $admin_url = Site::get_url('admin'); $link_name = Options::get('title'); $bookmarklet = "\n\t\t<p>Bookmark this link to leave the page when quoting:\n\t\t<a href=\"javascript:var w=window,d=document,gS='getSelection';location.href='{$admin_url}/publish?quote='+encodeURIComponent((''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text)).replace(/(^\\s+|\\s+\$)/g,''))+'&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(d.title);\">Quote on {$link_name}</a>\n\t\t<br>\n\t\tBookmark this link to open a new tab or window when quoting:\n\t\t<a href=\"javascript:var w=window,d=document,gS='getSelection';window.open('{$admin_url}/publish?quote='+encodeURIComponent((''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text)).replace(/(^\\s+|\\s+\$)/g,''))+'&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(d.title));void(0);\">Quote on {$link_name}</a>\n\t\t</p>"; return $bookmarklet; }
/** * Constructor for RenderCache * * Sets up paths and gets the list of groups from file */ public static function __static() { //Define the cache path and url self::$cache_path = HABARI_PATH . '/' . self::$rel_cache_path; self::$cache_url = Site::get_url('habari') . '/' . self::$rel_cache_path; //If the cache directory doesn't exist, make it if (!is_dir(self::$cache_path)) { mkdir(self::$cache_path, 0755); } //Enable only if the cache directory now exists and is writable self::$enabled = is_dir(self::$cache_path) && is_writeable(self::$cache_path); //Give an error if the cache directory is not writable if (!self::$enabled) { Session::error(sprintf(_t("The cache directory '%s' is not writable - the cache is disabled. The user, or group, which your web server is running as, needs to have read, write, and execute permissions on this directory."), self::$cache_path), 'RenderCache'); EventLog::log(sprintf(_t("The cache directory '%s' is not writable - the cache is disabled."), self::$cache_path), 'notice', 'RenderCache', 'habari'); return; } //Get the list of group names $group_file = self::get_group_list_file(); if (file_exists($group_file)) { self::$group_list = unserialize(file_get_contents($group_file)); } else { self::$group_list = array(); } }
private function get_incoming_links() { $links = array(); try { $search = new RemoteRequest('http://blogsearch.google.com/blogsearch_feeds?scoring=d&num=10&output=atom&q=link:' . Site::get_url('habari')); $search->set_timeout(5); $result = $search->execute(); if (Error::is_error($result)) { throw $result; } $response = $search->get_response_body(); if (mb_detect_encoding($response, 'UTF-8', true)) { $xml = new SimpleXMLElement($response); foreach ($xml->entry as $entry) { //<!-- need favicon discovery and caching here: img class="favicon" src="http://skippy.net/blog/favicon.ico" alt="favicon" / --> $links[] = array('href' => (string) $entry->link['href'], 'title' => (string) $entry->title); } } else { EventLog::log(_t('The response had non-UTF-8 characters'), 'err', 'plugin'); } } catch (Exception $e) { $links['error'] = $e->getMessage(); } return $links; }
private static function parse_data($block, $data) { // Unserialize and manipulate the data $flickrfeed = unserialize($data); $flickrfeed = array_slice($flickrfeed['items'], 0, $block->image_count); // Photo size foreach ($flickrfeed as &$image) { $image['image_sizes'] = array('thumbnail' => str_replace('_m.jpg', '_t.jpg', $image['m_url']), 'small' => $image['m_url'], 'medium' => $image['l_url'], 'medium_z' => str_replace('_m.jpg', '_z.jpg', $image['m_url']), 'large' => str_replace('_m.jpg', '_b.jpg', $image['m_url']), 'original' => $image['photo_url'], 'square' => $image['t_url'], 'default' => $image['t_url']); if (isset($image['image_sizes'][$block->image_size])) { $image['local_file'] = Site::get_dir('user', '/files/flickrfeed/' . $block->image_size . '/' . basename($image['image_sizes'][$block->image_size])); $image['local_url'] = Site::get_url('user', '/files/flickrfeed/' . $block->image_size . '/' . basename($image['image_sizes'][$block->image_size])); $image['image_url'] = $image['image_sizes'][$block->image_size]; } else { $image['local_file'] = Site::get_dir('user', '/files/flickrfeed/default/' . basename($image['image_sizes']['default'])); $image['local_url'] = Site::get_url('user', '/files/flickrfeed/default/' . basename($image['image_sizes']['default'])); $image['image_url'] = $image['image_sizes']['default']; } if ($block->cache_locally) { if (!file_exists($image['local_file'])) { if (!file_exists(dirname($image['local_file']))) { $umask = umask(0); mkdir(dirname($image['local_file']), 0777, true); umask($umask); } if (is_writable(dirname($image['local_file']))) { file_put_contents($image['local_file'], file_get_contents($image['image_url'])); } } if (file_exists($image['local_file'])) { $image['image_url'] = $image['local_url']; } } } return $flickrfeed; }
public function SitemapBuild() { //return cached sitemap if exsist if (Cache::has('sitemap')) { $xml = Cache::get('sitemap'); } else { $types = Options::get_group(__CLASS__); //..or generate a new one $xml = '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="' . $this->get_url() . '/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>'; $xml = new SimpleXMLElement($xml); if (array_key_exists('any', $types) && $types['any'] || empty($types)) { // Retrieve all published content, regardless of the type $content['any'] = Posts::get(array('content_type' => 'any', 'status' => 'published', 'nolimit' => 1)); } else { // Retreive all published content for select content types $content['posts'] = Posts::get(array('content_type' => array_keys($types, 1), 'status' => 'published', 'nolimit' => 1)); } // Add the index page first $url = $xml->addChild('url'); $url_loc = $url->addChild('loc', Site::get_url('habari')); // Generate the `<url>`, `<loc>`, `<lastmod>` markup for each post and page. foreach ($content as $entries) { foreach ($entries as $entry) { $url = $xml->addChild('url'); $url_loc = $url->addChild('loc', $entry->permalink); $url_lastmod = $url->addChild('lastmod', $entry->updated->get('c')); } } $xml = $xml->asXML(); Cache::set('sitemap', $xml); } return $xml; }
public function action_template_header($theme) { Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::add('template_header_javascript', Site::get_url('theme') . '/thickbox-compressed.js', 'thickbox'); Stack::add('template_header_javascript', Site::get_url('theme') . '/swfobject.js', 'swfobject'); Stack::add('template_header_javascript', Site::get_url('theme') . '/features.js', 'features'); Stack::add('template_stylesheet', array(Site::get_url('theme') . '/thickbox.css', 'screen'), 'thickbox'); }
public function action_init_theme_any() { if ($this->show_sudo()) { Stack::add('template_header_javascript', Site::get_url('vendor', '/jquery.js'), 'jquery'); Stack::add('template_header_javascript', Site::get_url('vendor', '/jquery-ui.min.js'), 'jquery-ui'); Stack::add('template_header_javascript', $this->get_url('/sudo.js'), 'sudo', 'jquery'); } }
public function action_template_header($theme) { // Add the stylesheets to the stack for output Stack::add('template_stylesheet', array(Site::get_url('theme') . '/style.css', 'screen')); Stack::add('template_stylesheet', array(Site::get_url('theme') . '/print.css', 'print')); Stack::add('template_header_javascript', 'jquery'); Stack::add('template_header_javascript', Site::get_url('them') . '/menu.js', 'select-menu', array('jquery')); }
public function filter_post_comments(Comments $comments, Post $post) { $url = Site::get_url('habari', true) . $post->slug; foreach (self::fetch_backtype($url) as $new) { $comments[] = $new; } return $comments; }
public function remove_template() { Post::deactivate_post_type('poll'); $this->remove_template('widget', dirname(__FILE__) . '/widget.php'); Stack::remove('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::remove('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/widget.css', 'screen'), 'pollwigitcss'); $this->remove_template('poll.single', dirname(__FILE__) . '/poll.single.php'); }
public function action_init_theme() { Stack::add('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/magicarchives.css', 'screen'), 'magicarchives'); Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::add('template_header_javascript', URL::get_from_filesystem(__FILE__) . '/magicarchives.js', 'magicarchives', array('jquery', 'ajax_manager')); Stack::add('template_header_javascript', URL::get_from_filesystem(__FILE__) . '/ajax_manager.js', 'ajax_manager', 'jquery'); Stack::add('template_header_javascript', 'magicArchives.endpoint=\'' . URL::get('ajax', array('context' => 'archive_posts')) . '\'', 'magicurl', 'magicarchives'); }
public function action_add_prettyphoto_template() { $social_string = Options::get(__CLASS__ . 'hide_social', false) ? "{social_tools:false}" : ""; Stack::add('template_header_javascript', Site::get_url('vendor') . '/jquery.js', 'jquery'); Stack::add('template_stylesheet', array($this->get_url() . '/css/prettyPhoto.css', 'screen')); Stack::add('template_header_javascript', $this->get_url() . '/js/jquery.prettyPhoto.js', 'prettyphoto', 'jquery'); $init_string = "\$(document).ready(function(){ \$(\"a[rel^='prettyPhoto']\").prettyPhoto(" . $social_string . ");});"; Stack::add('template_header_javascript', $init_string, 'prettyphoto_init', 'prettyphoto'); }
/** * Add required Javascript */ public function theme_header($theme) { // Add the jQuery library Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::add('template_header_javascript', $this->get_url() . '/instant_search.js', 'instant_search', array('jquery')); // Add the callback URL. $url = "InstantSearch.url = '" . URL::get('ajax', array('context' => 'instant_search')) . "';"; Stack::add('template_header_javascript', $url, 'instant_search_url', 'instant_search'); }
public function replace_macro($match) { $site_var = $match[1]; $map = array('SERVERNAME' => 'site'); if (isset($map[$site_var])) { $site_var = $map[$site_var]; } return Site::get_url($site_var); }
/** * Register the template. **/ function action_init() { $this->load_text_domain('commonblocks'); foreach (array_keys($this->allblocks) as $blockname) { $this->add_template("block.{$blockname}", dirname(__FILE__) . "/block.{$blockname}.php"); } $this->add_template("block.dropdown.category_archives", dirname(__FILE__) . "/block.dropdown.category_archives.php"); // This is here because you can't init a URL with dynamic values in the declaration $this->validation_urls = array(_t('XHTML 1.0 Transitional', 'commonblocks') => 'http://validator.w3.org/check?uri=referer', _t('CSS level 3', 'commonblocks') => 'http://jigsaw.w3.org/css-validator/check/referer?profile=css3', 'HTML5' => 'http://html5.validator.nu/?doc=' . Site::get_url('habari'), _t('Unicorn', 'commonblocks') => 'http://validator.w3.org/unicorn/check?ucn_task=conformance&ucn_uri=referer', _t('Feed Validator', 'commonblocks') => 'http://beta.feedvalidator.org/check.cgi?url=' . Site::get_url('habari')); }
public function action_admin_header($theme) { // This is such a hack it's not even funny // But I am laughing inside. Laughing in a bad way. Stack::remove('admin_stylesheet', 'admin'); $css = file_get_contents(Site::get_dir('admin_theme') . '/css/admin.css'); $css = preg_replace('@#page input\\[type=button\\], #page input\\[type=submit\\], #page button {([^}]+)}@', '', $css, 1); $css = preg_replace('@#page input\\[type=button\\]:hover, #page input\\[type=submit\\]:hover, #page button:hover {([^}]+)}@', '', $css, 1); Stack::add('admin_stylesheet', array(preg_replace('@../images/@', Site::get_url('admin_theme') . '/images/', $css), 'screen'), 'admin', 'jquery'); }
/** * action: init * * @access public * @return void */ public function action_init() { $this->load_text_domain('googlemaps'); $api_key = Options::get('googlemaps__api_key'); if (empty($api_key)) { return; } Stack::add('template_header_javascript', 'http://www.google.com/jsapi?key=' . $api_key); Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery'); Stack::add('template_header_javascript', $this->get_url() . '/js/googlemaps.js'); }
public function action_template_header() { Stack::add('template_stylesheet', array($this->get_url(true) . 'prettify.css', 'screen')); Stack::add('template_header_javascript', Site::get_url('scripts', true) . 'jquery.js', 'jquery'); Stack::add('template_header_javascript', $this->get_url(true) . 'prettify.js', 'prettify', 'jquery'); Stack::add('template_header_javascript', '$(function(){ $("code.prettyprint").each(function(){ l=$("br.pretty", this).length+1;oz="";for(z=1;z<=l;z++) oz+=z+"<br>"; $(this).wrap("<div class=\\"linewrapper\\"><code>").before("<code class=\\"prettylines\\">"+oz+"</code>"); }); PR_TAB_WIDTH = 2;prettyPrint()});', 'prettify_inline', array('jquery', 'prettify')); }
public function action_handler_dev_feed($handler_vars) { $rss = Plugins::get_by_interface('RSS'); if (count($rss) !== 1) { exit; } $xml = reset($rss)->create_rss_wrapper(); $connection_string = Options::get('tracfeed__connection_string'); $username = Options::get('tracfeed__username'); $password = Options::get('tracfeed__password'); $db = DatabaseConnection::ConnectionFactory($connection_string); $db->connect($connection_string, $username, $password); $times = $db->get_column('SELECT time from ticket_change group by time order by time desc limit 15;'); $mintime = array_reduce($times, 'min', reset($times)); $comments = $db->get_results("\n\t\t\tSELECT *, ticket_change.time as changetime from ticket_change \n\t\t\tINNER JOIN ticket on ticket.id = ticket_change.ticket\n\t\t\twhere \n\t\t\tchangetime >= ? and\n\t\t\tnot (field ='comment' and newvalue = '') \n\t\t\torder by ticket_change.time DESC;\n\t\t", array($mintime)); $posts = array(); foreach ($comments as $comment) { $post_id = md5($comment->ticket . ':' . $comment->changetime . ':' . $comment->author); if (!array_key_exists($post_id, $posts)) { $post = new Post(); $post->title = "Ticket #{$comment->ticket}: {$comment->summary}"; $post->content = "Changes by {$comment->author} on ticket <a href=\"http://trac.habariproject.org/habari/ticket/{$comment->ticket}\">#{$comment->ticket}</a>.\n<br>\n<br>"; $post->guid = 'tag:' . Site::get_url('hostname') . ',trac_comment,' . $post_id; $post->content_type = 'dev_feed'; $post->slug = "http://trac.habariproject.org/habari/ticket/{$comment->ticket}"; $post->pubdate = date('r', $comment->changetime); $posts[$post_id] = $post; } else { $post = $posts[$post_id]; } switch ($comment->field) { case 'comment': $content = $comment->newvalue; $content = preg_replace('/\\b(https?|ftp|file):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|]/i', '<a href="$0">[link]</a>', $content); $content = preg_replace('%\\br([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/changeset/$1">r$1</a>', $content); $content = preg_replace('%\\b#([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/ticket/$1">$1</a>', $content); $post->content .= "Comment #{$comment->oldvalue} by {$comment->author}:\n<blockquote><pre>{$content}</pre></blockquote>\n<br>"; break; default: if (trim($comment->oldvalue) == '') { $post->content .= "Set <b>{$comment->field}</b> to: {$comment->newvalue}\n<br>"; } else { $post->content .= "Changed <b>{$comment->field}</b> from: {$comment->oldvalue}\n<br> To: {$comment->newvalue}\n<br>"; } break; } } $xml = RSS::add_posts($xml, $posts); ob_clean(); header('Content-Type: application/xml'); echo $xml->asXML(); exit; }
/** * Handle register_success action */ public function action_plugin_act_register_success($handler) { if (!User::identify()->loggedin) { Utils::redirect(URL::get('register_page'), false); } $handler->theme->user = User::identify(); Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery', array('jquery')); // Stack::add( 'template_header_javascript', Site::get_url('admin_theme') . "/js/admin.js", 'admin', array('jquery', 'registration') ); Stack::add('template_header_javascript', URL::get_from_filesystem(__FILE__) . '/registration.js', 'registration', array('jquery')); Stack::add('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/registration.css', 'screen'), 'registration', array()); $handler->theme->display('registration.success'); }
/** * On plugin activation, set the default options */ public function action_plugin_activation($file) { if (realpath($file) === __FILE__) { $this->class_name = strtolower(get_class($this)); $this->cache_name = Site::get_url('host') . ':' . $this->class_name; foreach (self::default_options() as $name => $value) { $current_value = Options::get($this->class_name . '__' . $name); if (is_null($current_value)) { Options::set($this->class_name . '__' . $name, $value); } } } }
public function configure() { $ui = new FormUI('staticfront'); $page = $ui->append('select', 'page', 'staticfront__page', _t('The page to show for the home page: ', 'staticfront')); $page->options['none'] = _t('Show Normal Posts', 'staticfront'); foreach ($this->get_all_pages() as $post) { $page->options[$post->slug] = $post->title; } $blog_index = $ui->append('text', 'blog_index', 'staticfront__blog_index', sprintf(_t('Show normal posts at this URL: <b>%s</b>', 'staticfront'), Site::get_url('habari', true))); $blog_index->add_validator('validate_required'); $keep_pages = $ui->append('checkbox', 'keep_pages', 'staticfront__keep_pages', _t('Show static pages at base url: ', 'staticfront')); $ui->append('submit', 'save', _t('Save')); $ui->success(array($this, 'updated_config')); return $ui; }
/** * Creates a basic RSS-format XML structure with channel and items elements * @return SimpleXMLElement The requested RSS document */ public function create_rss_wrapper() { $xml = new SimpleXMLElement('<?xml version="1.0"?><rss></rss>'); $xml->addAttribute('version', '2.0'); $channel = $xml->addChild('channel'); $title = $channel->addChild('title', htmlspecialchars(Options::get('title'))); $link = $channel->addChild('link', Site::get_url('habari')); $tagline = Options::get('tagline', ''); // get the tagline or an empty string if it doesn't exist - the description tag is required $description = $channel->addChild('description', htmlspecialchars($tagline)); $pubDate = $channel->addChild('lastBuildDate', Post::get()->pubdate->format(DATE_RSS)); $generator = $channel->addChild('generator', 'Habari ' . Version::get_habariversion() . ' http://habariproject.org/'); Plugins::act('rss_create_wrapper', $xml); return $xml; }
/** * Register our javascript with Habari */ public function action_register_stackitems() { StackItem::register( 'multicomplete', Site::get_url( 'vendor' ) . '/multicomplete.js' )->add_dependency( 'jquery.ui' ); $url = '"' . URL::get( 'ajax', array( 'context' => 'auto_tags' ) ) . '"'; $script = <<< HEADER_JS $(document).ready(function(){ $("#tags").multicomplete({ source: $url, minLength: 2, autoFocus: true, }); }); HEADER_JS; StackItem::register( 'tags_auto', $script )->add_dependency( 'multicomplete' ); }
protected function getTemplateHelperSets() { // strip the subdirectory out of the theme path, as that will already be part of the base URL $themePath = substr(Site::get_path('theme') . '/web', strlen(Site::get_path('base'))); $sets = array(new sfTemplateHelperAssets($themePath, Site::get_url('habari')), new sfTemplateHelperJavascripts(), new sfTemplateHelperStylesheets()); $dirs = array($this->themeDirectory . '/lib/helper', dirname(__FILE__) . '/helper'); foreach ($dirs as $dir) { foreach (glob($dir . '/*.php') as $helperPath) { include_once $helperPath; $helperFilename = basename($helperPath); $className = substr($helperFilename, 0, strpos($helperFilename, '.')); $sets[] = new $className(); } } return $sets; }
/** * * Checks if files directory is usable */ private function check_files() { $user_path = HABARI_PATH . '/' . Site::get_path('user', true); $this->root = $user_path . 'files'; //Options::get('simple_file_root'); $this->url = Site::get_url('user', true) . 'files'; //Options::get('simple_file_url'); if ( !is_dir( $this->root ) ) { if ( is_writable( $user_path ) ) { mkdir( $this->root, 0755 ); } else { return false; } } return true; }
public function action_template_header() { $modified = Stack::get_sorted_stack('template_header_javascript'); foreach ($modified as $key => $value) { Stack::remove('template_header_javascript', $key); } Stack::add('template_header_javascript', Site::get_url('user') . "/files/minified.js", 'Minified'); if (!Cache::has(self::$cache_name . '_js') || !Cache::has(self::$cache_name . '_css')) { set_include_path(dirname(__FILE__) . '/min/lib' . PATH_SEPARATOR . get_include_path()); require_once 'Minify/Source.php'; require_once 'Minify/HTML.php'; require_once 'Minify/CSS.php'; require_once 'Minify/HTML.php'; require_once 'Minify.php'; require_once 'Minify/Cache/File.php'; } if (!Cache::has(self::$cache_name . '_js')) { $js_stack = array(); foreach ($modified as $js) { $js_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $js); } $options = array('files' => $js_stack, 'encodeOutput' => false, 'quiet' => true, 'maxAge' => 86400); $result = Minify::serve('Files', $options); file_put_contents(site::get_dir('user') . '/files/minified.js', $result['content']); Cache::set(self::$cache_name . '_js', 'true'); } /* CSS */ $modified = Stack::get_sorted_stack('template_stylesheet'); $tmp = array(); foreach ($modified as $key => $value) { $tmp[] = $value[0]; Stack::remove('template_stylesheet', $key); } Stack::add('template_stylesheet', array(Site::get_url('user') . "/files/minified.css", 'screen'), 'style'); if (!Cache::has(self::$cache_name . '_css')) { $css_stack = array(); foreach ($tmp as $css) { $css_stack[] = Site::get_path('base') . str_replace(Site::get_url('habari') . '/', '', $css); } $options = array('files' => $css_stack, 'encodeOutput' => false, 'quiet' => true, 'maxAge' => 86400); // handle request $result = Minify::serve('Files', $options); file_put_contents(site::get_dir('user') . '/files/minified.css', $result['content']); Cache::set(self::$cache_name . '_css', 'true'); } }