Example #1
0
 public static function optimize_and_save(array $files)
 {
     self::init();
     $cache_file = md5(serialize($files)) . '.js';
     $cache_file = self::$cache_folder . DS . $cache_file;
     if (!joosFile::exists($cache_file)) {
         foreach ($files as $file) {
             $file = explode('?', $file);
             $file = $file[0];
             $file = str_replace(JPATH_SITE, JPATH_BASE, $file);
             $file = str_replace('\\', '/', $file);
             self::$data[] = joosFile::exists($file) ? joosFile::get_content($file) : die($file);
         }
         $content = JSMin::minify(implode("\n;", self::$data));
         joosFile::create($cache_file, $content);
     }
     $cache_file_live = str_replace(JPATH_BASE, JPATH_SITE, $cache_file);
     $cache_file_live = str_replace('\\', '/', $cache_file_live);
     return array('live' => $cache_file_live, 'base' => $cache_file);
 }
 public function codegenerator()
 {
     $template_vars_default = array('component_title' => '', 'component_name' => '', 'component_description' => '', 'component_author' => 'Joostina Team', 'component_authoremail' => '*****@*****.**', 'component_copyright' => '(C) 2007-2012 Joostina Team');
     $template_vars = array();
     foreach ($template_vars_default as $var => $default_value) {
         $value = joosRequest::post($var, false);
         $template_vars[':' . $var] = $value ? $value : $default_value;
     }
     $template_vars[':component_name_camelcase'] = joosInflector::camelize($template_vars[':component_name']);
     $template_path_root = JPATH_BASE . DS . 'app' . DS . 'components' . DS . 'coder' . DS . 'templates' . DS . 'component' . DS;
     $template_files = array('controller.component_name', 'controller.component_name.ajax', 'controller.admin.component_name', 'controller.admin.component_name.ajax');
     $return = array();
     $create_files = array();
     foreach ($template_files as $template_file) {
         $template_body = joosFile::get_content($template_path_root . $template_file);
         $file_body = strtr($template_body, $template_vars);
         $file_name = str_replace('component_name', $template_vars[':component_name'], $template_file);
         $return[$template_file] = sprintf('%s.php<br /><textarea class="span10" rows="10">%s</textarea>', $file_name, $file_body);
         $create_files[$file_name] = $file_body;
     }
     return array('success' => true, 'body' => implode("\n", $return), 'component_name' => $template_vars[':component_name'], 'files_body' => $create_files);
 }