Exemplo n.º 1
0
 /**
  * Returns all the hidden fields registered in this instance
  *
  * @return String Returns a string of HTML
  */
 public function getHiddenHTML()
 {
     return implode("", \r8\ary\invoke($this->getHidden(), "__toString"));
 }
Exemplo n.º 2
0
 public function testInvoke()
 {
     $obj1 = $this->getMock('stdClass', array('get'));
     $obj1->expects($this->once())->method('get')->with()->will($this->returnValue('one'));
     $obj2 = $this->getMock('stdClass', array('get'));
     $obj2->expects($this->once())->method('get')->with()->will($this->returnValue('two'));
     $ary = array('meh' => $obj1, 0 => 5, 1 => $obj2, 5 => 'string', 8 => new stdClass());
     $this->assertSame(array('meh' => 'one', 1 => 'two'), \r8\ary\invoke($ary, 'get'));
     $obj1 = $this->getMock('stdClass', array('get'));
     $obj1->expects($this->once())->method('get')->with($this->equalTo('arg1'), $this->equalTo('arg2'))->will($this->returnValue('one'));
     $obj2 = $this->getMock('stdClass', array('get'));
     $obj2->expects($this->once())->method('get')->with($this->equalTo('arg1'), $this->equalTo('arg2'))->will($this->returnValue('two'));
     $ary = array('meh' => $obj1, 0 => 5, 1 => $obj2, 5 => 'string', 8 => new stdClass());
     $this->assertSame(array('meh' => 'one', 1 => 'two'), \r8\ary\invoke($ary, 'get', 'arg1', 'arg2'));
 }
Exemplo n.º 3
0
 /**
  * Returns the SQL this object represents
  *
  * @param \r8\iface\DB\Link $link The database link to use for escaping
  * @return String
  */
 public function toSQL(\r8\iface\DB\Link $link)
 {
     $sql = "SELECT ";
     if ($this->distinct) {
         $sql .= "DISTINCT ";
     }
     if ($this->foundRows) {
         $sql .= "SQL_CALC_FOUND_ROWS ";
     }
     if (count($this->fields) <= 0) {
         $sql .= "*";
     } else {
         $sql .= implode(", ", \r8\ary\invoke($this->fields, "toSelectSQL", $link));
     }
     if ($this->from) {
         $sql .= "\nFROM " . $this->from->toFromSQL($link);
     }
     foreach ($this->joins as $join) {
         $sql .= "\n" . $join->toJoinSQL($link);
     }
     if ($this->where) {
         $sql .= "\nWHERE " . $this->where->toWhereSQL($link);
     }
     if (count($this->order) > 0) {
         $sql .= "\nORDER BY " . implode(", ", \r8\ary\invoke($this->order, "toOrderedSQL", $link));
     }
     if (count($this->group) > 0) {
         $sql .= "\nGROUP BY " . implode(", ", \r8\ary\invoke($this->group, "toOrderedSQL", $link));
     }
     if ($this->having) {
         $sql .= "\nHAVING " . $this->having->toWhereSQL($link);
     }
     if ($this->limitExists()) {
         $sql .= "\nLIMIT " . ($this->offsetExists() ? $this->getOffset() : "0") . ", " . $this->getLimit();
     }
     return $sql;
 }
Exemplo n.º 4
0
 /**
  * Returns an HTML representation of this Head object
  *
  * Note that this does NOT include the DocType. Only the values within
  * the actual Head tag.
  *
  * @return \r8\HTML\Tag
  */
 public function getTag()
 {
     $content = array();
     if (!empty($this->title)) {
         $content[] = "<title>" . htmlspecialchars($this->title) . "</title>";
     }
     $content = array_merge($content, \r8\ary\stringize(\r8\ary\invoke($this->metatags, "getTag")), \r8\ary\stringize(\r8\ary\invoke($this->css, "getTag")), \r8\ary\stringize(\r8\ary\invoke($this->javascript, "getTag")));
     return new \r8\HTML\Tag("head", implode("\n", $content));
 }
Exemplo n.º 5
0
 /**
  * Returns a description of this option to be used in the help view
  *
  * @return String
  */
 public function describe()
 {
     $flags = array_map(function ($flag) {
         return (strlen($flag) == 1 ? "-" : "--") . $flag;
     }, $this->flags);
     return sprintf("    %s\n        %s\n", trim(implode(", ", $flags) . " " . implode(" ", \r8\ary\invoke($this->args, "describe"))), wordwrap($this->description, 72, "\n        ", TRUE));
 }
Exemplo n.º 6
0
 /**
  * Returns a description of this command form
  *
  * @param String $commandName The name of the command
  * @return String
  */
 public function describe($commandName)
 {
     $args = \r8\ary\invoke($this->args, "describe");
     if (!empty($this->options)) {
         $options = array_map(function ($opt) {
             return strlen($opt) == 1 ? '-' . $opt : '--' . $opt;
         }, array_keys($this->options));
         sort($options);
         array_unshift($args, '[' . implode(',', $options) . ']');
     }
     return trim($commandName . " " . implode(" ", $args));
 }
Exemplo n.º 7
0
 /**
  * Returns the help details for this command
  *
  * @return String
  */
 public function getHelp()
 {
     $forms = array();
     $options = array();
     foreach ($this->forms as $form) {
         $forms[] = $form->describe($this->name);
         $options = array_merge($options, $form->getOptions());
     }
     $result = "USAGE:\n" . "    " . implode("\n    ", $forms) . "\n\n" . "DESCRIPTION:\n" . "    " . wordwrap($this->description, 76, "\n    ", TRUE) . "\n\n";
     if (!empty($options)) {
         ksort($options);
         $result .= "OPTIONS:\n" . implode("", \r8\ary\invoke($options, 'describe')) . "\n";
     }
     return $result;
 }