コード例 #1
0
ファイル: page.php プロジェクト: BGCX262/zwf-svn-to-git
 /**
  * @abstract Uses a variable function list and a selected value to build a list of <option>'s.
  * Pipes, "|", are used to seperate parameters within individual option arguments, and an argument 
  * with no pipes will set the value and title to the whole argument.
  *
  * Example:
  *   echo generateSelectOptions('1', 'One|1', 'Two|2', '3');
  *
  * Would produce:
  *   <option value="1" title="One" selected>One</option>
  *   <option value="2" title="Two" >Two</option>
  *   <option value="3" title="3" >3</option>
  * 
  * @param string $selected The value to flag as selected in the generated <option>'s.
  * 
  * @return string Returns the generated <option> list markup.
  */
 public static function generateSelectOptions($selected = '')
 {
     $args = func_get_args();
     $numArgs = func_num_args();
     $response = $title = $value = $class = '';
     $parts = array();
     for ($i = 1; $i < $numArgs; ++$i) {
         $parts = explode('|', $args[$i], 4);
         $title = isset($parts[0]) ? $parts[0] : '';
         $value = isset($parts[1]) ? $parts[1] : $title;
         $class = isset($parts[2]) ? $parts[2] : '';
         $response .= HTMLElement::build('option', $title, array('value' => $value, 'title' => $title, 'class' => $class), array('selected' => $selected == $value)) . "\n";
     }
     return $response;
 }
コード例 #2
0
ファイル: html.php プロジェクト: BGCX262/zwf-svn-to-git
 /**
  * @abstract Generates the formatted HTML for this element
  * @return string An XHTML string as formatted by HTMLElement::build().
  * @see HTMLElement::build()
  */
 public function __toString()
 {
     return HTMLElement::build($this->tagName, $this->innerHTML, $this->attributes, $this->flags);
 }