/** * Get a new watermarker object filled with module preferences. * * @return cge_watermark */ public static function &get_watermarker() { $mod = cge_utils::get_cge(); $txt = $mod->GetPreference('watermark_text'); $img = $mod->GetPreference('watermark_file'); $obj = new \CGExtensions\watermarker(); if (!empty($img)) { $config = cms_config::get_instance(); $obj->set_watermark_image($config['uploads_path'] . '/' . $img); } else { if (!empty($txt)) { $obj->set_watermark_text($txt); $font = $mod->GetPreference('watermark_font'); $obj->set_font($font); $obj->set_text_size($mod->GetPreference('watermark_textsize')); $obj->set_text_angle($mod->GetPreference('watermark_textangle')); $tmp = $mod->GetPreference('watermark_textcolor'); $r = hexdec(substr($tmp, 1, 2)); $g = hexdec(substr($tmp, 3, 2)); $b = hexdec(substr($tmp, 5, 2)); $obj->set_text_color($r, $g, $b); $tmp = $mod->GetPreference('watermark_bgcolor'); $r = hexdec(substr($tmp, 1, 2)); $g = hexdec(substr($tmp, 3, 2)); $b = hexdec(substr($tmp, 5, 2)); $obj->set_background_color($r, $g, $b, $mod->GetPreference('watermark_transparent', 1)); } } $obj->set_alignment($mod->GetPreference('watermark_alignment')); $obj->set_translucency($mod->GetPreference('watermark_translucency', 100)); return $obj; }
/** * @ignore */ private static function __make() { if (is_null(self::$_store)) { self::$_store = new cge_datastore(self::$_timeout); self::$_key = md5(__FILE__); $config = cms_config::get_instance(); $key = md5(__FILE__ . $config['root_url'] . $config['root_path'] . getenv('REMOTE_ADDR')); self::$_enckey = $key; } }
public static function load($libname) { $mod = cms_utils::get_module(MOD_CGEXTENSIONS); if ($libname == 'cg_cmsms') { // gotta return code. $config = cms_config::get_instance(); $tpl = $mod->CreateSmartyTemplate('jquery.cg_cmsms.tpl'); $tpl->assign('mod', $mod); $tpl->assign('config', $config); $code = $tpl->fetch(); $obj = new StdClass(); $obj->code = $code; return $obj; } }
function cge_CreateInputSubmit(&$mod, $id, $name, $value = '', $addtext = '', $image = '', $confirmtext = '', $class = '', $alt = '', $elid = '') { $real_image = ''; if (!empty($image)) { $config = cms_config::get_instance(); // check image_directories first if (isset($mod->_image_directories) && !empty($mod->_image_directories)) { foreach ($mod->_image_directories as $dir) { $url = cms_join_path($dir, $image); $path = cms_join_path($config['root_path'], $url); if (is_readable($path)) { $real_image = $url; } } } $theme = cms_utils::get_theme_object(); if (empty($real_image)) { $path = $config['root_path'] . '/' . $config['admin_dir'] . '/themes/' . $theme->themeName . '/images/'; if (file_exists($path . $image)) { // its a theme image $real_image = $config['admin_dir'] . "/themes/" . $theme->themeName . '/images/' . $image; } } if (empty($real_image)) { if (is_object($theme)) { // we're in the admin if (!$alt) { $alt = $value; } $txt = $theme->DisplayImage($image, $alt, '', '', $class); $real_image = $theme->imageLink[$image]; } } $addtext .= ' title="' . $value . '"'; } if (!empty($class)) { $addtext .= ' class="' . $class . '"'; } return $mod->CreateInputSubmit($id, $name, $value, $addtext, $real_image, $confirmtext); }
$smarty->assign('input_text', $this->CreateInputText($id, 'watermark_text', $this->GetPreference('watermark_text', get_site_preference('sitename', 'CMSMS Site')), 50, 255)); $opts = array(); for ($i = 1; $i < 72; $i++) { $opts[$i] = $i; } $smarty->assign('input_textsize', $this->CreateInputDropdown($id, 'watermark_textsize', $opts, -1, $this->GetPreference('watermark_textsize', 12))); $smarty->assign('input_textangle', $this->CreateInputText($id, 'watermark_angle', $this->GetPreference('watermark_textangle', '0'), 3, 3)); // font list $list = array(); $dir1 = dirname(__FILE__) . '/fonts'; $list1 = cge_dir::file_list_regexp($dir1, '[Tt][Tt][Ff]$'); foreach ($list1 as $one) { $list[$one] = $dir1 . '/' . $one; } // todo, make this configurable $config = cms_config::get_instance(); $dir2 = $config['uploads_path']; $list2 = cge_dir::file_list_regexp($dir2, '[Tt][Tt][Ff]$'); if (!empty($list2)) { foreach ($list2 as $one) { $list[$one] = $dir2 . '/' . $one; } } $smarty->assign('input_font', $this->CreateInputDropdown($id, 'watermark_font', $list, -1, $this->GetPreference('watermark_font'))); $smarty->assign('input_textcolor', $this->CreateColorDropdown($id, 'watermark_textcolor', $this->GetPreference('watermark_textcolor', '#00FFFF'))); $smarty->assign('input_bgcolor', $this->CreateColorDropdown($id, 'watermark_bgcolor', $this->GetPreference('watermark_bgcolor', '#FFFFFF'))); $smarty->assign('input_transparent', $this->CreateInputYesNoDropdown($id, 'watermark_transparent', $this->GetPreference('watermark_transparent', 1))); $smarty->assign('input_image', $this->CreateFileDropdown($id, 'watermark_file', $this->GetPreference('watermark_file'), '', 'jpg,jpeg,png,gif', '1')); $nums = array(); for ($i = 100; $i > 0; $i--) { $nums[$i] = $i;
public static function get_upload_location() { $mod = \cms_utils::get_module(MOD_CGCALENDAR); $config = \cms_config::get_instance(); $dir = $mod->GetPreference('uploaddirectory', $config['uploads_path']); if (is_dir($dir)) { $rp1 = realpath($config['root_path']); $rp2 = realpath($dir); if (startswith($rp2, $rp1)) { $url = str_replace($config['root_path'], $config['root_url'], $dir); return $url; } } }
function __CreatePrettyLink($id, $action, $returnid = '', $contents = '', $params = array(), $warn_message = '', $onlyhref = false, $inline = false, $addtext = '', $targetcontentonly = false, $prettyurl = '') { $config = cms_config::get_instance(); $pretty = false; if ($config['assume_mod_rewrite'] === true || $config['internal_pretty_urls'] === true) { $pretty = true; } $method_exists = method_exists($this->_module, 'CreatePrettyLink'); if ($pretty && $returnid != '' && $method_exists) { // pretty urls are configured, we're not in an admin action // and the CreatePrettyLink method has been found. return $this->_module->CreatePrettyLink($id, $action, $returnid, $contents, $params, $warn_message, $onlyhref, $inline, $addtext, $targetcontentonly, $prettyurl); } else { return $this->_module->CreateLink($id, $action, $returnid, $contents, $params, $warn_message, $onlyhref, $inline, $addtext, $targetcontentonly, $prettyurl); } }
public function WYSIWYGGenerateHeader($selector = null, $cssname = null) { if ($this->_loaded) { return; } if (!$selector) { $selector = 'textarea.Parser'; } $config = cms_config::get_instance(); $dirlist = array(); $dirlist[] = $config['root_path'] . "/module_custom/" . $this->GetName() . '/templates'; $dirlist[] = __DIR__ . '/templates'; $fn = ''; foreach ($dirlist as $dir) { $fn = "{$dir}/wysiwyg.tpl"; if (is_file($fn)) { break; } } $out = str_replace('{root_url}', $config['root_url'], file_get_contents($fn)); $this->_loaded = true; return $out; }
/** * @ignore */ public function generate_ga() { // generate analytics stuff $property_id = \cge_param::get_string($this->_config, 'cghm_ga_propertyid'); if (!$property_id) { return; } $linkdomains = \cge_param::get_string($this->_config, 'cghm_ga_linkdomains'); if ($linkdomains) { $linkdomains = $this->str_to_array($linkdomains); } $subdomains = \cge_param::get_bool($this->_config, 'cghm_ga_subdomains'); $domain = \cge_param::get_string($this->_config, 'cghm_ga_domain'); if ($subdomains && !$domain) { $sysconfig = \cms_config::get_instance(); $url = new \cms_url($sysconfig['root_url']); $domain = $url->get_host(); } $tpl = $this->CreateSmartyTemplate('google_analytics.tpl'); $tpl->assign('content_obj', \cms_utils::get_current_content()); $tpl->assign('config', $this->_config); $tpl->assign('domain', $domain); if (count($linkdomains)) { $tpl->assign('linkdomains', $linkdomains); } return $tpl->fetch(); }
/** * Given a filename, convert it to a URL * * @param string $filename The input filename * @return string */ public static function filename_to_url($filename) { if (!$filename) { return; } if (!is_readable($filename)) { return; } $config = cms_config::get_instance(); if (!startswith($filename, $config['root_path'])) { return; } return str_replace($config['root_path'], $config['root_url'], $filename); }
/** * This method tests if an item can be stored in the cache for a request. * This is because at certain times (i.e: during module installation, or in a stylesheet request) * it may be inappropriate or unable to store data as the cache would be invalidated * by a higher level function. * * @return bool */ public static final function can_cache() { global $CMS_ADMIN_PAGE; global $CMS_INSTALL_PAGE; global $CMS_MODULE_PAGE; global $CMS_STYLESHEET; if (isset($CMS_INSTALL_PAGE)) { return FALSE; } if (isset($CMS_ADMIN_PAGE)) { return FALSE; } if (isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { return FALSE; } $config = cms_config::get_instance(); if (isset($config['debug']) && $config['debug'] == true) { return FALSE; } $uid = get_userid(false); if ($uid) { return FALSE; } // caching disabled for logged in administrators return TRuE; }
/** * Get a handle to the global CMS config. This is mostly values that are * defined in config.php * * @final * @return mixed an associative array of configuration values */ public function &GetConfig() { return cms_config::get_instance(); }
/** * Get a list of module files matching a specified pattern in a specified module subdirectory. * This method can be used for finding a list of files matching a pattern (i.e a list of classes, or even a list of templates). * This method will search for files in a matching directory in the module_custom directory (if one exists) and in the module directory. * i.e: $this->get_module_files('templates','summary*tpl'); * * @param string $dirname The directory name (relative to the module directory) to search in. * @param string $pattern An optional pattern, if no pattern is specified, *.* is assumed. * @return string[] */ public function get_module_files($dirname, $pattern = null) { if (!$dirname) { return; } $tmp = realpath($dirname); if (file_exists($dirname)) { return; } // absolute paths not accepted. if (!$pattern) { $pattern = '*.*'; } $config = cms_config::get_instance(); $files = array(); $dirlist = array(); $dirlist[] = $config['root_path'] . "/module_custom/" . $this->GetName(); $dirlist[] = $this->GetModulePath(); foreach ($dirlist as $dir) { $fn = "{$dir}/{$dirname}"; if (!is_dir($fn)) { continue; } $_list = glob("{$fn}/{$pattern}"); if (!count($_list)) { continue; } $files = array_merge($files, $_list); } if (count($files)) { return $files; } }
/** * */ function cms_get_jquery($exclude = '', $ssl = false, $cdn = false, $append = '', $custom_root = '') { $config = cms_config::get_instance(); $scripts = array(); $basePath = $custom_root != '' ? trim($custom_root, '/') : ($ssl ? $config['ssl_url'] : $config['root_url']); // Scripts to include $scripts['jquery.min.js'] = '<script type="text/javascript" src="' . ($cdn ? 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' : $basePath . '/lib/jquery/js/jquery-1.7.2.min.js') . '"></script>' . "\n"; $scripts['jquery-ui.min.js'] = '<script type="text/javascript" src="' . ($cdn ? 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js' : $basePath . '/lib/jquery/js/jquery-ui-1.8.21.custom.min.js') . '"></script>' . "\n"; $scripts['jquery.ui.nestedSortable.js'] = '<script type="text/javascript" src="' . $basePath . '/lib/jquery/js/jquery.ui.nestedSortable-1.3.4.js"></script>' . "\n"; $scripts['jquery.json.min.js'] = '<script type="text/javascript" src="' . $basePath . '/lib/jquery/js/jquery.json-2.3.min.js"></script>' . "\n"; // Check if we need exclude some script if (!empty($exclude)) { $exclude_list = explode(",", trim(str_replace(' ', '', $exclude))); foreach ($exclude_list as $one) { if ($one == 'jquery-1.6.2.min.js') { $one = 'jquery.min.js'; } if ($one == 'jquery-ui-1.8.14.min.js') { $one = 'jquery-ui.min.js'; } if ($one == 'jquery.json-2.2.js') { $one = 'jquery.json.min.js'; } if ($one == 'jquery.ui.nestedSortable-1.3.4.js') { $one = 'jquery.ui.nestedSortable.js'; } unset($scripts[$one]); } } // let them add scripts to the end ie: a jQuery plugin if (!empty($append)) { $append_list = explode(",", trim(str_replace(' ', '', $append))); foreach ($append_list as $key => $item) { $scripts['user_' + $key] = '<script type="text/javascript" src="' . $item . '"></script>' . "\n"; } } // Output $output = ''; foreach ($scripts as $script) { $output .= $script; } return $output; }
/** * Retrieve the global instance of the cms_config class * This method will instantiate the object if necessary * * @return object */ public static function &get_instance() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); // now load the config self::$_instance->load_config(); } return self::$_instance; }
/** * 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; }