Esempio n. 1
0
 /**
  * Check to see if we need to include a prompt.
  *
  * @return string
  * @author Justin Palmer
  **/
 protected function preparePrompt($options)
 {
     $prompt = OptionsParser::findAndDestroy('prompt', $options);
     if ($prompt != false) {
         $this->display .= new Option($prompt, '');
     }
     return OptionsParser::getOptions();
 }
Esempio n. 2
0
 /**
  * Return the path for the given named route
  *
  * @param string $name 
  * @param string $options 
  * @return string
  * @author Justin Palmer
  */
 public static function path($name, $options = null)
 {
     $app_path = Registry::get('pr-install-path');
     $args = OptionsParser::toArray($options);
     $path = preg_replace('/{([a-zA-Z\\_\\-])*}/i', '%s', self::$Hash->get($name, 'path'));
     $match = preg_match('/(\\%s)/', $path);
     if ($match && empty($args)) {
         throw new Exception("The path '{$name}' should be passed some arguments.");
     }
     return vsprintf(rtrim($app_path, '/') . $path, $args);
 }
Esempio n. 3
0
 /**
  * Add the type to the stack for us to build the query
  *
  * @return void
  * @author Justin Palmer
  **/
 private function add($datatype, $name, $options, $invalid = array())
 {
     //Get the options ready
     if (!empty($invalid)) {
         $invalid = array_combine(array_values($invalid), array_values($invalid));
     }
     $options = OptionsParser::toArray($options);
     $options = array_intersect_key($options, $this->valid_options);
     $options = array_diff_key($options, $invalid);
     //array('limit'=>'', 'null'=>false, , 'default'=>'', 'after'=>false);
     //'primary'=>false, 'index'=>false, 'unique'=>false
     //Add to the string the bits needed.
     $bit = "`{$name}` {$datatype}";
     if (isset($options['limit'])) {
         $bit .= "(" . $options['limit'] . ")";
     } elseif ($datatype == 'VARCHAR') {
         $bit .= "(255)";
     }
     if (isset($options['null'])) {
         $options['null'] ? $bit .= ' NULL' : ($bit .= ' NOT NULL');
     } else {
         $bit .= ' NULL';
     }
     if (isset($options['default'])) {
         $bit .= " DEFAULT '" . $options['default'] . "'";
     }
     if (isset($options['auto'])) {
         $bit .= " AUTO_INCREMENT PRIMARY KEY";
     }
     if (isset($options['after'])) {
         $bit .= " AFTER `" . $options['after'] . "`";
     }
     if (isset($options['primary']) && $options['primary'] == 'true' && !isset($options['auto'])) {
         $this->primary($this->table, $name);
     }
     $this->stack[] = $bit . "\n\t";
 }
Esempio n. 4
0
 /**
  * Constructor for the Tag class
  *
  * @return Tag
  * @author Justin Palmer
  **/
 public function __construct($options = null)
 {
     $this->options = OptionsParser::toHtmlProperties($this->addOptions($options));
 }
Esempio n. 5
0
 /**
  * @test
  */
 public function Convert_toArray()
 {
     $this->assertType('array', OptionsParser::toArray($this->s));
 }
Esempio n. 6
0
 /**
  * Destroy an option
  *
  * @return void
  * @author Justin Palmer
  **/
 public static function destroy($key, $options)
 {
     $array = self::toArray($options);
     if (array_key_exists($key, $array)) {
         unset($array[$key]);
     }
     self::$options = self::toStringFromArray($array);
     return self::$options;
 }