Exemplo n.º 1
0
 /**
  * Initializes a new module in the current project directory
  *
  * @see "silversmith help"	 
  * @param The parameters, e.g. from the command line
  */
 public static function init_module($params = array())
 {
     if (!isset($params[2]) || empty($params[2])) {
         fail("Please specify a module name.");
     }
     $d = SilverSmithUtil::proper_form($params[2]);
     if (is_dir($d)) {
         fail("Module {$d} already exists.");
     }
     mkdir($d);
     say($d);
     mkdir("{$d}/code");
     say("{$d}/code");
     mkdir("{$d}/css");
     say("{$d}/css");
     mkdir("{$d}/javascript");
     say("{$d}/javascript");
     mkdir("{$d}/templates");
     say("{$d}/templates");
     mkdir("{$d}/templates/Layout");
     say("{$d}/templates/Layout");
     mkdir("{$d}/templates/Includes");
     say("{$d}/templates/Includes");
     $fh = fopen("{$d}/_config.php", "w");
     fwrite($fh, "<?php\n");
     fclose($fh);
     say("{$d}/_config.php");
     mkdir("{$d}/_config");
     say("{$d}/_config");
     $fh = fopen("{$d}/_config/_config.yml", "w");
     fwrite($fh, "---\nName: {$d}\nAfter: 'framework/*','cms/*'\n");
     fclose($fh);
     say("{$d}/_config/_config.yml");
 }
Exemplo n.º 2
0
 /**
  * Singularize a string
  *
  * Note: English biased
  *
  * @param string The word to singularize
  * @return string
  */
 public static function singularize($str)
 {
     $name = SilverSmithUtil::proper_form($str);
     if (substr($name, -1, 3) == "ies") {
         return substr_replace($name, "y", -1, 3);
     } else {
         if (substr($name, -1, 1) == "s") {
             return substr_replace($name, "", -1, 3);
         }
     }
     return $str;
 }