/** * Creates a link tag of the given +name+ using an URL created by the set of +options+. See the valid options in * the documentation for ActionController::urlFor. It's also possible to pass a string instead of an array of options * to get a link tag that just points without consideration. If null is passed as a name, the link itself will become * the name. * * The html_options has three special features. One for creating javascript confirm alerts where if you pass * 'confirm' => 'Are you sure?', the link will be guarded with a JS popup asking that question. * If the user accepts, the link is processed, otherwise not. * * Another for creating a popup window, which is done by either passing 'popup' with true or the options of the window in * Javascript form. * * And a third for making the link do a POST request (instead of the regular GET) through a dynamically added form * element that is instantly submitted. Note that if the user has turned off Javascript, the request will fall back on * the GET. So its your responsibility to determine what the action should be once it arrives at the controller. * The POST form is turned on by passing 'post' as true. Note, it's not possible to use POST requests and popup targets * at the same time (an exception will be thrown). * * Examples: * $url_helper->link_to('Delete this page', array('action' => 'destroy', 'id' => $page->id ), array('confirm' => 'Are you sure?')); * $url_helper->link_to('Help', array('action' => 'help'), array('popup' => true)); * $url_helper->link_to('Busy loop', array('action' => 'busy'), array('popup' => array('new_window', 'height=300,width=600'))); * $url_helper->link_to('Destroy account', array('action' => 'destroy'), array('confirm' => 'Are you sure?'), array('post' => true)); */ public function link_to($name = null, $options = array(), $html_options = array(), $parameters_for_method_reference = null) { if (!empty($html_options)) { $this->convert_options_to_javascript($html_options); $tag_options = AkTagHelper::tag_options($html_options); } else { $tag_options = null; } $url = is_string($options) ? $options : $this->url_for($options, $parameters_for_method_reference); $name = empty($name) ? $url : $name; return "<a href=\"{$url}\"{$tag_options}>{$name}</a>"; }
public function to_boolean_select_tag($options = array()) { $this->add_default_name_and_id($options); return '<select' . AkTagHelper::tag_options($options) . '><option value="false"' . ($this->getValue() == false ? ' selected' : '') . '>' . Ak::t('False', array(), 'helpers/form') . '</option><option value="true"' . ($this->getValue() ? ' selected' : '') . '>' . Ak::t('True', array(), 'helpers/form') . '</option></select>'; }
/** * Turns all urls into clickable links. * * Example: * <?=$text_helper->auto_link_urls($post->body, array('all', 'target' => '_blank'));?> */ static function auto_link_urls($text, $href_options = array()) { $extra_options = AkTagHelper::tag_options($href_options); $extra_options_array = var_export($extra_options, true); return preg_replace_callback(AK_AUTO_LINK_REGEX, create_function('$matched', 'return AkTextHelper::_replace_url_with_link_callback($matched,' . $extra_options_array . ');'), $text); }
/** * Returns an HTML block tag of type *name* surrounding the *content*. Add * HTML attributes by passing an attributes array to *options*. For attributes * with no value like (disabled and readonly), give it a value of true in * the *options* array. You can use symbols or strings for the attribute names. * * <%= content_tag 'p', 'Hello world!' %> * # => <p>Hello world!</p> * <%= content_tag('div', content_tag('p', "Hello world!"), :class => "strong") %> * # => <div class="strong"><p>Hello world!</p></div> * <%= content_tag("select", options, :multiple => true) %> * # => <select multiple="multiple">...options...</select> */ static function content_tag($name, $content, $options = null) { return '<' . $name . (!empty($options) ? AkTagHelper::tag_options($options) : '') . '>' . $content . '</' . $name . '>'; }