コード例 #1
0
ファイル: ak_tag_helper.php プロジェクト: bermi/akelos
 static function tag_options($options)
 {
     $formated_options = array();
     foreach ($options as $key => $value) {
         if (empty($value) && !is_string($value)) {
             continue;
         }
         if (!is_numeric($key) && !is_array($value) && !is_object($value)) {
             $formated_options[$key] = $key . '="' . AkTagHelper::escape_once($value) . '"';
         }
     }
     ksort($formated_options);
     return empty($formated_options) ? '' : ' ' . join(' ', $formated_options);
 }
コード例 #2
0
ファイル: ak_url_helper.php プロジェクト: bermi/akelos
 /**
  * Generates a form containing a sole button that submits to the
  * URL given by _$options_.  Use this method instead of +link_to+
  * for actions that do not have the safe HTTP GET semantics
  * implied by using a hypertext link.
  *
  * The parameters are the same as for +link_to+.  Any _html_options_
  * that you pass will be applied to the inner +input+ element.
  * In particular, pass
  * 
  *   'disabled' => true/false
  *
  * as part of _html_options_ to control whether the button is
  * disabled.  The generated form element is given the class
  * 'button-to', to which you can attach CSS styles for display
  * purposes.
  *
  * Example 1:
  *
  *   // inside of controller for "feeds"
  *   $url_helper->button_to('Edit', array('action' => 'edit', 'id' => 3));
  *
  * Generates the following HTML (sans formatting):
  *
  *   <form method="post" action="/feeds/edit/3" class="button-to">
  *     <div><input type="submit" value="Edit"  /></div>
  *   </form>
  *
  * Example 2:
  *
  *   $url_helper->button_to('Destroy', array('action' => 'destroy', 'id' => 3 , 'confirm' => 'Are you sure?'));
  *
  * Generates the following HTML (sans formatting):
  *
  *   <form method="post" action="/feeds/destroy/3" class="button-to">
  *     <div><input onclick="return confirm('Are you sure?');" value="Destroy" type="submit" /></div>
  *   </form>
  *
  * Note: This method generates HTML code that represents a form.
  * Forms are "block" content, which means that you should not try to
  * insert them into your HTML where only inline content is expected.
  * For example, you can legally insert a form inside of a <div> or
  * <td> element or in between <p> elements, but not in the middle of
  * a run of text, nor can you place a form within another form.
  * (Bottom line: Always validate your HTML before going public.)
  */
 public function button_to($name, $options = array(), $html_options = array())
 {
     $html_options = $this->_convert_boolean_attributes($html_options, 'disabled');
     if (!empty($html_options['confirm'])) {
         $html_options['onclick'] = 'return ' . $this->_confirm_javascript_function($html_options['confirm']) . ';';
         unset($html_options['confirm']);
     }
     $url = is_string($options) ? $options : $this->url_for($options);
     $name = !empty($name) ? $name : (is_string($options) ? $options : AkTagHelper::escape_once($this->url_for($options)));
     $html_options = array_merge($html_options, array('type' => 'submit', 'value' => $name));
     return '<form method="post" action="' . $url . '" class="button-to"><div>' . AkTagHelper::tag('input', $html_options) . '</div></form>';
 }
コード例 #3
0
ファイル: ak_form_helper.php プロジェクト: bermi/akelos
 public function to_text_area_tag($options = array())
 {
     $options = array_merge($this->default_text_area_options, $options);
     $this->add_default_name_and_id($options);
     return AkTagHelper::content_tag('textarea', AkTagHelper::escape_once($this->value_before_type_cast()), $options);
 }