public function __construct() { parent::__construct(); $this->_loaded = false; $smarty = CmsApp::get_instance()->GetSmarty(); if (!$smarty) { return; } $smarty->register_modifier('markdown', array($this, 'exec_parser')); }
/** * @ignore */ public static function reset_states() { $db = \CmsApp::get_instance()->GetDb(); $query = 'TRUNCATE TABLE ' . CGEXTENSIONS_TABLE_STATES; $db->Execute($query); $fn = cms_join_path(dirname(__DIR__), 'states.txt'); $raw_states = @file($fn); $query = 'INSERT INTO ' . CGEXTENSIONS_TABLE_STATES . ' (code,name,sorting) VALUES (?,?,?)'; $n = 1; foreach ($raw_states as $one) { list($acronym, $state_name) = explode(',', $one); $acronym = trim($acronym); $state_name = trim($state_name); $db->Execute($query, array($acronym, $state_name, $n++)); } }
/** * Updates the hierarchy position of all items * * @internal * @return void */ function SetAllHierarchyPositions() { // load some data about all pages into memory... and convert into a hash. $db = CmsApp::get_instance()->GetDb(); $sql = 'SELECT content_id, parent_id, item_order, content_alias AS alias, hierarchy, id_hierarchy, hierarchy_path FROM ' . cms_db_prefix() . 'content ORDER BY hierarchy'; $list = $db->GetArray($sql); if (!count($list)) { // nothing to do, get outa here. return; } $hash = array(); foreach ($list as $row) { $hash[$row['content_id']] = $row; } unset($list); // would be nice to use a transaction here. $usql = "UPDATE " . cms_db_prefix() . "content SET hierarchy = ?, id_hierarchy = ?, hierarchy_path = ? WHERE content_id = ?"; foreach ($hash as $content_id => $row) { $changed = $this->_set_hierarchy_position($content_id, $hash); if (is_array($changed)) { $db->Execute($usql, array($changed['hierarchy'], $changed['id_hierarchy'], $changed['hierarchy_path'], $changed['content_id'])); } } // clear the content cache again. cms_content_cache::clear(); }
public static function expand_events($eventids, $returnid, $parameters, $limit = 10000, $startoffset = 0) { if (!is_array($eventids) || count($eventids) < 1) { return FALSE; } $module = cge_utils::get_module(MOD_CGCALENDAR); $gCms = CmsApp::get_instance(); $db = $gCms->GetDb(); $events_to_categories_table_name = $module->events_to_categories_table_name; $categories_table_name = $module->categories_table_name; $event_field_values_table_name = $module->event_field_values_table_name; $userops = $gCms->GetUserOperations(); $tmp = $userops->LoadUsers(); $users = array(); foreach ($tmp as $oneuser) { $users[$oneuser->id] = $oneuser; } $query = 'SELECT * FROM ' . $module->events_table_name . ' WHERE event_id IN (' . implode(',', $eventids) . ') ORDER BY event_date_start ASC'; $rs = $db->SelectLimit($query, $limit, $startoffset); $feu_users = array(); while (!$rs->EOF()) { $row = $rs->fields; $uid = $row['event_created_by']; if ($uid < 1 && !in_array($uid, $feu_users)) { $feu_users[] = $uid; } $rs->MoveNext(); } debug_display($feu_users); die; $rs->MoveFirst(); $events = array(); while ($rs && ($row = $rs->FetchRow())) { $titleSEO = munge_string_to_url($row['event_title']); $destpage = $module->GetPreference('defaultcalendarpage', -1); $destpage = $destpage > 0 ? $destpage : $returnid; //$destpage =$detailpage!=''?$detailpage:$destpage; $prefix = $module->GetPreference('url_prefix'); if (!$prefix) { $prefix = 'calendar'; } $prettyurl = sprintf($prefix . "/%d/%d-%s", $destpage, $row['event_id'], $titleSEO); $parms = array(); $parms['event_id'] = $row['event_id']; $parms['display'] = 'event'; if (isset($parameters['eventtemplate'])) { $parms['eventtemplate'] = $parameters['eventtemplate']; } $url = $module->CreateLink('cntnt01', 'default', $destpage, $contents = '', $parms, '', true, '', '', '', $prettyurl); $row['url'] = $url; $row['author'] = $users[$row['event_created_by']]->username; $row['authorname'] = $users[$row['event_created_by']]->firstname . ' ' . $users[$row['event_created_by']]->lastname; // Build the sql to retrieve the categories for this event. $sql = "SELECT category_name FROM {$events_to_categories_table_name}\n\t INNER JOIN {$categories_table_name} ON {$events_to_categories_table_name}.category_id = {$categories_table_name}.category_id\n\t WHERE event_id = ?"; $crs = $db->Execute($sql, array($row['event_id'])); // Get the field values $categories = array(); $categories_temp = array(); if ($crs) { // make sure there are results and assign to the $categories array $categories_temp = $crs->GetArray(); foreach ($categories_temp as $category) { $category_name = $category['category_name']; $categories[$category_name] = '1'; } } // Attach the custom fields to the event $row['categories'] = $categories; // Build the sql to retrieve the field values for this event. $sql = "SELECT field_name,field_value FROM {$event_field_values_table_name} WHERE event_id = ?"; $frs = $db->Execute($sql, array($row['event_id'])); // Get the field values $fields = array(); $fields_temp = array(); if ($frs) { // make sure there are results and assign to the $fields array $fields_temp = $frs->GetArray(); foreach ($fields_temp as $field) { $field_name = $field['field_name']; $field_value = $field['field_value']; $fields[$field_name] = $field_value; } } // Attach the custom fields to the event $row['fields'] = $fields; // End custom fields retrieval // and add it to the list of completed, expanded events. $events[] = $row; } if ($rs) { $rs->Close(); } return $events; }
function DisplayImage($image, $alt = '', $class = '', $width = '', $height = '', $id = '') { $config = cms_config::get_instance(); if (!$class && !CmsApp::get_instance()->is_frontend_request()) { $class = 'systemicon'; } $img1 = basename($image); // check image_directories first if (isset($this->_module->_image_directories) && !empty($this->_module->_image_directories)) { foreach ($this->_module->_image_directories as $dir) { $url = "{$dir}/{$img1}"; $path = cms_join_path($config['root_path'], $url); if (is_readable($path)) { if (!\CmsApp::get_instance()->is_frontend_request()) { $url = "../{$url}"; } else { $url = $config['root_url'] . "/{$url}"; } return $this->_module->CreateImageTag($url, $alt, $width, $height, $class); } } } $theme = cms_utils::get_theme_object(); if (is_object($theme)) { // we're in the admin $txt = $theme->DisplayImage($image, $alt, $width, $height, $class); } else { // frontend $txt = $this->CreateImageTag($image, $alt, $width, $height, $class); } return $txt; }
# Made simple that does not indicate clearly and obviously in its admin # section that the site was built with CMS Made simple. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Or read it online: http://www.gnu.org/licenses/licenses.html#GPL # #------------------------------------------------------------------------- #END_LICENSE cge_headers::output_headers(); $config = \CmsApp::get_instance()->GetConfig(); if ($config['debug']) { return; } $pretty_html = \cge_param::get_bool($config, 'cge_prettyhtml', false); $min_html = \cge_param::get_bool($config, 'cge_minhtml', false); if (!$pretty_html && !$min_html) { return; } // do nothin $in = $params['content']; if (strpos('</body>', $in) === FALSE) { $in = str_replace('</html>', '</body></html>', $in); } $the_head_parm = -1; $the_body_parm = -1;
exit; } } if (!is_writable(TMP_TEMPLATES_C_LOCATION) || !is_writable(TMP_CACHE_LOCATION)) { echo '<html><title>Error</title></head><body>'; echo '<p>The following directories must be writable by the web server:<br />'; echo 'tmp/cache<br />'; echo 'tmp/templates_c<br /></p>'; echo '<p>Please correct by executing:<br /><em>chmod 777 tmp/cache<br />chmod 777 tmp/templates_c</em><br />or the equivilent for your platform before continuing.</p>'; echo '</body></html>'; exit; } require_once $dirname . '/include.php'; @ob_start(); // initial setup $_gCms = CmsApp::get_instance(); $params = array_merge($_GET, $_POST); $smarty = $_gCms->GetSmarty(); $smarty->params = $params; $page = get_pageid_or_alias_from_url(); $contentops = $_gCms->GetContentOperations(); $contentobj = ''; $trycount = 0; while ($trycount < 2) { $trycount++; try { if (!is_object($contentobj)) { if ($page == '__CMS_PREVIEW_PAGE__' && isset($_SESSION['cms_preview'])) { $tpl_name = trim($_SESSION['cms_preview']); $fname = ''; if (is_writable($config["previews_path"])) {
/** * Given a page alias resolve it to a page id. * * @param mixed $txt The page alias to resolve. If an integer page id is passed in that is acceptable as well. * @param int $dflt The default page id to return if no match can be found * @return int */ function resolve_alias_or_id($txt, $dflt = null) { $txt = trim($txt); if (!$txt) { return $dflt; } $manager = CmsApp::get_instance()->GetHierarchyManager(); $node = null; if (is_numeric($txt) && (int) $txt > 0) { $node = $manager->find_by_tag('id', (int) $txt); } else { $node = $manager->find_by_tag('alias', $txt); } if ($node) { return (int) $node->get_tag('id'); } return $dflt; }
public static function cge_content_type($params, $smarty) { $type = \cge_utils::get_param($params, 'type'); if ($type) { if (version_compare(CMS_VERSION, '1.99-alpha0') < 1) { CmsApp::get_instance()->set_variable('content-type', $type); } else { CmsApp::get_instance()->set_content_type($type); } } }
/** * Return the global cmsms() object * * @since 1.7 * @return object */ function &cmsms() { return CmsApp::get_instance(); }
/** * Redirect to the same URL but substitute the http url with the https url * If the URL is not specified the current url is used. * * @param string $url * @param bool $force Absolutely force the url to be https. */ public static function redirect_http($url = '', $force = false) { if (empty($url)) { $url = cge_url::current_url(); } if (startswith($url, 'http:')) { // nothing to do. return; } $config = CmsApp::get_instance()->GetConfig(); if ($force) { $new_url = str_replace('https:', 'http:', $url); redirect($new_url); } else { if (startswith($url, $config['ssl_url']) && isset($config['ssl_url'])) { $new_url = str_replace($config['ssl_url'], $config['root_url'], $url); redirect($new_url); } } }
public static function get_parallel_page($new_root, $current_page = null, $assign = null) { $gCms = CmsApp::get_instance(); $smarty = $gCms->GetSmarty(); $contentops = $gCms->GetContentOperations(); if (empty($new_root)) { return; } if (empty($current_page)) { $current_page = $smarty->get_template_vars('page_alias'); } $cur_content = $contentops->LoadContentFromAlias($current_page); if (!is_object($cur_content)) { return; } $tmp = self::get_root_alias($new_root); // make sure we go to the root if ($tmp) { $new_root = $tmp; } $new_root_content = $contentops->LoadContentFromAlias($new_root); if (!is_object($new_root_content)) { return; } $hier1 = $cur_content->Hierarchy(); $hier2 = $new_root_content->Hierarchy(); if ($hier1 == '' || $hier2 == '') { return; } $a_hier1 = explode('.', $hier1); $a_hier2 = explode('.', $hier2); $a_hier1[0] = $a_hier2[0]; $hier3 = implode('.', $a_hier1); // we have the new hierarchy... just gotta find the right page for it. $new_pageid = $contentops->GetPageIDFromHierarchy($hier3); if (!$new_pageid) { return; } $newcontent = $contentops->LoadContentFromAlias($new_pageid); if (!is_object($newcontent)) { return; } // oops. if ($assign) { $smarty->assign($assign, $newcontent->Alias()); return; } return $newcontent->Alias(); }
/** * Convert a filename to a URL. * If an absolute path is specified tests are done to compare the input to the image uploads path, the uploads path or the root path of the system. * If a relative URL path is passed a file relative to the root url is assumed. * * @param string $file the filename to convert to a URL * @param bool $force_ssl Force the output url to use HTTPS * @return string */ public static function file_to_url($file, $force_ssl = FALSE) { $config = CmsApp::get_instance()->GetConfig(); $url = null; if (!file_exists($file)) { return $url; } if (startswith($file, $config['image_uploads_path'])) { $url = str_replace($config['image_uploads_path'], $config['image_uploads_url'], $file); } else { if (startswith($file, $config['uploads_path'])) { if (self::ssl_request() || $force_ssl) { $url = str_replace($config['uploads_path'], $config['ssl_uploads_url'], $file); } else { $url = str_replace($config['uploads_path'], $config['uploads_url'], $file); } } else { if (startswith($file, $config['root_path'])) { if (self::ssl_request() || $force_ssl) { $url = str_replace($config['root_path'], $config['ssl_url'], $file); } else { $url = str_replace($config['root_path'], $config['root_url'], $file); } } } } return $url; }
/** * Render the output javascript and stylesheets into cachable files * and output the appropriate HTML tags. * * @param array $opts Options for this method (for further reference, see the {cgjs_render} smarty tag. * @return string HTML output code. */ public static function render($opts = null) { if (count(self::$_rlibs) == 0 && count(self::$_required) == 0) { return; } // nothing to do. // process options $options = array(); $options['excludes'] = array(); if (!cmsms()->is_frontend_request()) { // the cmsms admin console includes versions of these. $excludes = array(); $excludes[] = 'jquery'; $excludes[] = 'ui'; $excludes[] = 'fileupload'; $options['excludes'] = $excludes; } if (is_array($opts)) { $options = array_merge_recursive($options, $opts); } if (isset($options['no_jquery']) && !in_array('jquery', $options['excludes'])) { $options['excludes'][] = 'jquery'; } if (isset($options['excludes']) && count($options['excludes'])) { // clean up the excludes $out = array(); foreach ($options['excludes'] as &$str) { $str = strtolower(trim($str)); if (!$str) { continue; } if (!in_array($str, $out)) { $out[] = $str; } } $options['excludes'] = $out; } $options['lang'] = \CmsNlsOperations::get_current_language(); // expand some options to simple variables. $config = \cms_config::get_instance(); $cache_lifetime = isset($options['cache_lifetime']) ? (int) $options['cache_lifetime'] : 24; $cache_lifetime = (int) \cge_utils::get_param($config, 'cgejs_cachelife', $cache_lifetime); $cache_lifetime = max($cache_lifetime, 1); $nocache = isset($options['no_cache']) ? TRUE : FALSE; $nocache = \cge_utils::get_param($config, 'cgejs_nocache', $nocache); $nominify = isset($options['nominify']) ? TRUE : FALSE; // overrides anything in libs. $nominify = \cge_utils::get_param($config, 'cgejs_nominify', $nominify); $nocsssmarty = isset($options['nocsssmarty']) || $nominify ? TRUE : $nocache; $addkey = \cge_utils::get_param($options, 'addkey', ''); $do_js = isset($options['no_js']) ? FALSE : TRUE; $do_css = isset($options['no_css']) ? FALSE : TRUE; $js_fmt = '<script type="text/javascript" src="%s"></script>'; $css_fmt = '<link type="text/css" rel="stylesheet" href="%s"/>'; if ($nocache) { $nominify = true; } if (!$nominify) { require_once dirname(__DIR__) . '/jsmin.php'; } $get_relative_url = function ($filename) { $config = \cms_config::get_instance(); $relative_url = ''; if (startswith($filename, $config['root_path'])) { $relative_url = str_replace($config['root_path'], $config['root_url'], dirname($filename)); if (!endswith($relative_url, '/')) { $relative_url .= '/'; } if (startswith($relative_url, 'http:')) { $relative_url = substr($relative_url, 5); } if (startswith($relative_url, 'https:')) { $relative_url = substr($relative_url, 6); } } return $relative_url; }; $fix_css_urls = function ($css, $url_prefix) { $css_search = '#url\\(\\s*[\'"]?(.*?)[\'"]?\\s*\\)#'; $css_url_fix = function ($matches) use($url_prefix) { if (startswith($matches[1], 'data:')) { return $matches[0]; } if (startswith($matches[1], 'http:')) { return $matches[0]; } if (startswith($matches[1], 'https:')) { return $matches[0]; } if (startswith($matches[1], '//')) { return $matches[0]; } //$str = substr($matches[1],0,-1); $str = $matches[1]; return "url('{$url_prefix}{$str}')"; }; $out = preg_replace_callback($css_search, $css_url_fix, $css); return $out; }; $get_code = function ($rec, $type) use(&$get_relative_url, &$fix_css_urls) { $config = \cms_config::get_instance(); if ($type == "js") { $js = null; if (isset($rec->jsfile)) { $jsfile = $rec->jsfile; if (!is_array($jsfile)) { $jsfile = array($jsfile); } $js = null; foreach ($jsfile as $one_file) { $one_file = self::_expand_filename($one_file); $js .= "/* jsloader // javascript file {$one_file} */\n"; if (is_file($one_file)) { $js .= @file_get_contents($one_file); } } } else { if (isset($rec->jsurl)) { // cache this for at least 24 hours if (startswith($rec->jsurl, $config['root_url'])) { $fn = str_replace($config['root_url'], $config['root_path'], $rec->jsurl); if (is_file($fn)) { if (!endswith($js, "\n")) { $js .= "\n"; } $js .= "/* jsloader // javascript local file from url {$fn} */\n"; $js .= file_get_contents($fn); } } else { $crf = new \cge_cached_remote_file($rec->jsurl, 48 * 60); if ($crf->size()) { if (!endswith($js, "\n")) { $js .= "\n"; } $js .= "/* jsloader // javascript remote {$rec->jsurl} */\n"; $js .= $crf->file_get_contents(); } } } else { if (isset($rec->code)) { $js .= "/* jsloader // javascript inline code */\n"; $js .= $rec->code; } } } return $js; } else { // css $css = null; if (isset($rec->cssfile)) { $cssfile = $rec->cssfile; if (!is_array($cssfile)) { $cssfile = array($cssfile); } foreach ($cssfile as $one_file) { $one_file = self::_expand_filename($one_file); $tmp = file_get_contents($one_file); $css .= "/* jsloader//css file: {$one_file} */\n"; $relative_url = $get_relative_url($one_file); $tmp = $fix_css_urls($tmp, $relative_url); $css .= $tmp; } } else { if (isset($rec->cssname)) { if (version_compare(CMS_VERSION, '1.99-alpha0') < 0) { $query = 'SELECT css_id, css_name, css_text FROM ' . cms_db_prefix() . 'css WHERE css_name = ?'; $db = CmsApp::get_instance()->GetDb(); $row = $db->GetRow($query, array($rec->cssname)); if (!is_array($row)) { return; } $css = trim($row['css_text']); } else { $css = CmsLayoutStylesheet::load($rec->cssname)->get_content(); } } else { if (isset($rec->cssurl)) { if (startswith($rec->cssurl, $config['root_url'])) { $fn = str_replace($config['root_url'], $config['root_path'], $rec->cssurl); if (is_file($fn)) { $relative_url = $get_relative_url($fn); $tmp .= file_get_contents($fn); $tmp = $fix_css_urls($tmp, $relative_url); if (!endswith($css, "\n")) { $css .= "\n"; } $css .= "/* jsloader //css local file from url {$fn} */\n"; $css .= $tmp; } } else { $crf = new \cge_cached_remote_file($rec->cssurl, 48 * 60); if ($crf->size()) { if (!endswith($css, "\n")) { $css .= "\n"; } $css .= "/* jsloader//css remote {$rec->cssurl} */\n"; $css .= $crf->file_get_contents(); } } } else { if (isset($rec->styles)) { $css .= "/* jsloader//css inline code */\n"; $css .= $rec->styles; } } } } return $css; } }; $get_minified_code = function ($rec, $type) use(&$get_code) { /* check for a cached version of this code */ $fn = TMP_CACHE_LOCATION . '/cgejs_' . md5(__FILE__ . serialize($rec) . $type) . '.cache'; if (is_file($fn)) { return file_get_contents($fn); } // not in cache // calculate a prefix to go on top of the cache file, and test if we are really minifying $code = $prefix = null; $do_minify = TRUE; if ($type == 'js') { if (isset($rec->js_nominify) && $rec->js_nominify) { $do_minify = FALSE; } if ($do_minify && isset($rec->jsfile)) { $jsfile = $rec->jsfile; if (!is_array($jsfile)) { $jsfile = array($jsfile); } foreach ($jsfile as $one) { if (strpos($one, '.min') !== FALSE || strpos($one, '.pack') !== FALSE) { $do_minify = FALSE; break; } } } if ($do_minify && isset($rec->jsurl)) { if (strpos($rec->jsurl, '.min') !== FALSE || strpos($rec->jsurl, '.pack') !== FALSE) { $do_minify = FALSE; } } $prefix = "/* jsloader // cached javascript // "; if (isset($rec->name)) { $prefix .= $rec->name; } else { if (isset($rec->jsfile)) { if (is_string($rec->jsfile)) { $prefix .= $rec->jsfile; } else { $prefix .= $rec->jsfile[0]; } } else { if (isset($rec->code)) { $prefix .= 'inline code'; } } } $prefix .= " */\n"; } else { // CSS if (isset($rec->css_nominify) && $rec->css_nominify) { $do_minify = FALSE; } if ($do_minify && isset($rec->cssfile)) { $cssfile = $rec->cssfile; if (!is_array($cssfile)) { $cssfile = array($cssfile); } foreach ($cssfile as $one) { if (strpos($one, '.min') !== FALSE || strpos($one, '.pack') !== FALSE) { $do_minify = FALSE; break; } } } if ($do_minify && isset($rec->cssurl)) { if (strpos($rec->cssurl, '.min') !== FALSE || strpos($rec->cssurl, '.pack') !== FALSE) { $do_minify = FALSE; } } $prefix = "/* jsloader // cached css // "; if (isset($rec->name)) { $prefix .= $rec->name; } else { if (isset($rec->cssfile)) { if (is_string($rec->cssfile)) { $prefix .= $rec->cssfile; } else { $prefix .= $rec->cssfile[0]; } } else { $prefix .= 'inline code'; } } $prefix .= " */\n"; } // get the code. $code = $get_code($rec, $type); if ($code) { // got code... are we minifying and caching it? if ($do_minify) { $code = \JSMin::minify($code); $code = $prefix . $code; file_put_contents($fn, $code); } return $code; } }; // determine if we have to process all this cruft (which could potentially be very expensive) $sig = md5(serialize(self::$_rlibs) . serialize(self::$_required) . serialize($options) . $nocache . $nominify . $cache_lifetime); $cache_js = TMP_CACHE_LOCATION . "/cgejs_{$sig}.js"; $cache_css = TMP_CACHE_LOCATION . "/cgejs_{$sig}.css"; $do_js_tag = $do_css_tag = FALSE; $do_js2 = $do_css2 = FALSE; $do_processing = TRUE; if ($nocache) { // forced to rejenerate. $do_js2 = $do_css2 = TRUE; } else { /* we can cache */ $etime = time() - $cache_lifetime * 3600; if (is_file($cache_js)) { $mtime1 = @filemtime($cache_js); $do_js_tag = TRUE; if ($mtime1 < $etime) { // cache too olo, forced to rebuild $do_js2 = FALSE; } } else { // no file, gotta process. $do_js2 = TRUE; } if (is_file($cache_css)) { $mtime2 = @filemtime($cache_css); $do_css_tag = TRUE; if ($mtime2 < $etime) { // cache too old, forced to rebuild $do_css2 = FALSE; } } else { // no file, gotta process. $do_css2 = TRUE; } } if ($do_js2 || $do_css2) { // okay, we have work to do. static $list = null; if (is_null($list)) { // now expand all our dependencies. $list_0 = array(); $required = array_merge(self::$_rlibs, self::$_required); foreach ($required as $rec) { if (isset($rec->depends)) { self::_resolve_dependencies($rec, $list_0, $options['excludes']); } else { $sig = md5(serialize($rec)); $list_0[$sig] = $rec; } } // now check for callback items // and get their code... this may be an expensive process // note: may also have dependencies $list = array(); foreach ($list_0 as $rec) { if (isset($rec->callback)) { $tmp = call_user_func($rec->callback, $rec->name); if (is_object($tmp) && (isset($tmp->code) || isset($tmp->styles))) { $list[] = $tmp; } } else { $list[] = $rec; } } unset($required, $list_0); } // // process js // if ($do_js && $do_js2 && $list && count($list)) { $txt = null; foreach ($list as $rec) { if ($nominify) { $txt .= $get_code($rec, 'js'); } else { $txt .= $get_minified_code($rec, 'js'); } } if ($txt) { $do_js_tag = TRUE; file_put_contents($cache_js, $txt); } } // // process css // if ($do_css && $do_css2 && $list && count($list)) { $txt = null; foreach ($list as $rec) { if ($nominify) { $txt .= $get_code($rec, 'css'); } else { $txt .= $get_minified_code($rec, 'css'); } } if ($txt) { $do_css_tag = TRUE; file_put_contents($cache_css, $txt); } } // do_css } // do processing // do the output. if ($nocache) { $cache_js .= '?_t=' . time(); $cache_css .= '?_t=' . time(); } $out = null; if ($do_js_tag) { $cache_url = $config['root_url'] . '/tmp/cache/' . basename($cache_js); $out .= trim(sprintf($js_fmt, $cache_url)) . "\n"; } if ($do_css_tag) { $cache_url = $config['root_url'] . '/tmp/cache/' . basename($cache_css); $out .= trim(sprintf($css_fmt, $cache_url)) . "\n"; } // all freaking done return $out; }