示例#1
0
文件: Skel.plugin.php 项目: davbfr/cf
 public function skelUpdate()
 {
     Cli::enableHelp();
     Cli::pinfo("Update CF project");
     $srcdir = $this->getDir() . DIRECTORY_SEPARATOR . "project";
     $dstdir = ROOT_DIR;
     foreach (array("index.php", "setup", "README.md", ".htaccess", ".gitignore", "www/index.php", "www/.htaccess") as $file) {
         copy($srcdir . DIRECTORY_SEPARATOR . $file, $dstdir . DIRECTORY_SEPARATOR . $file);
     }
     $this->updateFiles();
     chmod(getcwd() . DIRECTORY_SEPARATOR . "setup", 0755);
     System::ensureDir(DATA_DIR);
     Cli::update();
 }
示例#2
0
 public static function minify_images()
 {
     $path = Cli::addOption("path", WWW_PATH, "Path where to find images");
     $norun = Cli::addSwitch("n", "Do not run the scripts, only print files to process");
     Cli::enableHelp();
     Cli::pinfo("Minify images");
     foreach (self::globRecursive($path . "/*.[pP][nN][gG]", GLOB_NOSORT) as $png) {
         Cli::pinfo(" * {$png}");
         $output = "";
         $return_var = -1;
         $cmd = "pngcrush -ow -brute -reduce {$png}";
         if ($norun) {
             Logger::Debug("   > {$cmd}");
         } else {
             exec("{$cmd} 2>& 1", $output, $return_var);
             if ($return_var != 0) {
                 Cli::perr(implode($output, "\n"));
             } else {
                 Logger::Debug(implode($output, "\n"));
             }
         }
     }
     foreach (self::globRecursive($path . "/{*.[jJ][pP][gG], *.[jJ][pP][eE][gG]}", GLOB_BRACE | GLOB_NOSORT) as $jpg) {
         Cli::pinfo(" * {$jpg}");
         $output = "";
         $return_var = -1;
         $cmd = "jpegoptim -s -v -v {$jpg}";
         if ($norun) {
             Logger::Debug("   > {$cmd}");
         } else {
             exec("{$cmd} 2>& 1", $output, $return_var);
             if ($return_var != 0) {
                 Cli::perr(implode($output, "\n"));
             } else {
                 Logger::Debug(implode($output, "\n"));
             }
         }
     }
 }
示例#3
0
文件: Bdd.class.php 项目: davbfr/cf
 public static function cliImport($args)
 {
     $files = Cli::getInputs("files", "file names to import");
     Cli::enableHelp();
     $bdd = self::getInstance();
     foreach ($files as $filename) {
         Cli::pinfo("Import {$filename} in database");
         $data = json_decode(file_get_contents($filename));
         $bdd->import($data);
     }
 }