本文整理汇总了PHP中_tag_options函数的典型用法代码示例。如果您正苦于以下问题:PHP _tag_options函数的具体用法?PHP _tag_options怎么用?PHP _tag_options使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_tag_options函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: content_tag
function content_tag($name, $content = '', $options = array())
{
if (!$name) {
return '';
}
return '<' . $name . _tag_options($options) . '>' . $content . '</' . $name . '>';
}
示例2: link_to
/**
*
* 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::Base#url_for. It's also possible to pass a string instead of an options hash to
* get a link tag that just points without consideration. If nil 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:
* link_to "Delete this page", { :action => "destroy", :id => @page.id }, :confirm => "Are you sure?"
* link_to "Help", { :action => "help" }, :popup => true
* link_to "Busy loop", { :action => "busy" }, :popup => ['new_window', 'height=300,width=600']
* link_to "Destroy account", { :action => "destroy" }, :confirm => "Are you sure?", :post => true
*/
function link_to( $name, $options = array(), $html_options = false )
{
$arg = func_get_args();
if ( $html_options )
{
//convert_options_to_javascript( $html_options );
$tag_options = _tag_options( $html_options );
}
else
{
$tag_options = null;
}
$url = is_string( $options ) ? $options : url_for( $options, $arg );
return "<a href=\"$url\"$tag_options>".( $name ? $name : $url )."</a>";
}
示例3: _auto_link_urls
/**
* Turns all urls into clickable links.
*/
function _auto_link_urls($text, $href_options = array(), $truncate = false, $truncate_len = 40, $pad = '...')
{
$href_options = _tag_options($href_options);
$callback_function = '
if (preg_match("/<a\\s/i", $matches[1]))
{
return $matches[0];
}
';
if ($truncate) {
$callback_function .= '
else if (strlen($matches[2].$matches[3]) > ' . $truncate_len . ')
{
return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"' . $href_options . '>\'.substr($matches[2].$matches[3], 0, ' . $truncate_len . ').\'' . $pad . '</a>\'.$matches[4];
}
';
}
$callback_function .= '
else
{
return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"' . $href_options . '>\'.$matches[2].$matches[3].\'</a>\'.$matches[4];
}
';
return preg_replace_callback(SF_AUTO_LINK_RE, create_function('$matches', $callback_function), $text);
}
示例4: _op_auto_links_outer_urls
function _op_auto_links_outer_urls($text, $href_options = array(), $truncate = false, $truncate_len = 40, $pad = '...')
{
$request = sfContext::getInstance()->getRequest();
$href_options = _tag_options($href_options);
$proxyAction = $request->getUriPrefix() . $request->getRelativeUrlRoot() . '/proxy';
$callback_function = '
if (preg_match("/<a\\s/i", $matches[1]))
{
return $matches[0];
}
';
if ($truncate) {
$callback_function .= '
else if (strlen($matches[2].$matches[3]) > ' . $truncate_len . ')
{
return $matches[1].\'<a href="' . $proxyAction . '?url=\'.urlencode(($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3]).\'"' . $href_options . '>\'.substr($matches[2].$matches[3], 0, ' . $truncate_len . ').\'' . $pad . '</a>\'.$matches[4];
}
';
}
$callback_function .= '
else
{
return $matches[1].\'<a href="' . $proxyAction . '?url=\'.urlencode(($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3]).\'"' . $href_options . '>\'.$matches[2].$matches[3].\'</a>\'.$matches[4];
}
';
return preg_replace_callback(SF_AUTO_LINK_RE, create_function('$matches', $callback_function), $text);
}
示例5: render_image
function render_image($source, $dir, $options = array())
{
$options['src'] = get_image_path($source, $dir);
return '<img' . _tag_options($options) . ' />';
}
示例6: _convertMenuData
/**
* Converts the array from ioMenuItem::fromArray() to a format suitable
* for importing into Doctrine_Record::fromArray().
*
* @param array $data The data array from an ioMenuItem object
* @return array
*/
protected function _convertMenuData(array $data)
{
// turn the attributes array into a class="name" styled string
sfApplicationConfiguration::getActive()->loadHelpers('Tag');
$data['attributes'] = trim(_tag_options($data['attributes']));
// convert labels into i18n format
if ($this->getTable()->isI18n()) {
$data['Translation'] = array();
// if a label is set on the menu, set it on the Translation for the default culture
if (isset($data['label'])) {
$defaultCulture = sfConfig::get('sf_default_culture');
$data['Translation'][$defaultCulture]['label'] = $data['label'];
unset($data['label']);
}
// process any actual i18n labels if any are set
if (isset($data['i18n_labels'])) {
foreach ($data['i18n_labels'] as $culture => $label) {
$data['Translation'][$culture]['label'] = $label;
}
unset($data['i18n_labels']);
}
}
return $data;
}
示例7: renderChild
/**
* Called by the parent menu item to render this menu.
*
* This renders the li tag to fit into the parent ul as well as its
* own nested ul tag if this menu item has children
*
* @param integer $depth The depth each child should render
* @return string
*/
public function renderChild($depth = null)
{
// if we don't have access or this item is marked to not be shown
if (!$this->shouldBeRendered()) {
return;
}
// explode the class string into an array of classes
$class = $this->getAttribute('class') ? explode(' ', $this->getAttribute('class')) : array();
if ($this->isCurrent()) {
$class[] = 'current';
} elseif ($this->isCurrentAncestor($depth)) {
$class[] = 'current_ancestor';
}
if ($this->actsLikeFirst()) {
$class[] = 'first';
}
if ($this->actsLikeLast()) {
$class[] = 'last';
}
// retrieve the attributes and put the final class string back on it
$attributes = $this->getAttributes();
if (count($class) > 0) {
$attributes['class'] = implode(' ', $class);
}
// opening li tag
$html = $this->_format('<li' . _tag_options($attributes) . '>', 'li');
// render the text/link inside the li tag
$html .= $this->_format(null !== $this->_route ? $this->renderLink() : $this->renderLabel(), 'link');
// renders the embedded ul if there are visible children
$html .= $this->render($depth, true);
// closing li tag
$html .= $this->_format('</li>', 'li');
return $html;
}
示例8: _auto_link_urls
/**
* Turns all urls into clickable links.
*/
function _auto_link_urls($text, $href_options = array())
{
$href_options = _tag_options($href_options);
return preg_replace_callback(SF_AUTO_LINK_RE, create_function('$matches', '
if (preg_match("/<a\\s/i", $matches[1]))
{
return $matches[0];
}
else
{
return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"' . $href_options . '>\'.$matches[2].$matches[3].\'</a>\'.$matches[4];
}
'), $text);
}
示例9: renderChild
public function renderChild($depth = null)
{
$attributes['class'] = $this->_itemListClass;
$html = '<li'._tag_options($attributes).'>';
$html .= $this->renderComment();
$html .= $this->render($depth);
$html .= '</li>';
return $html;
}
示例10: moo_btn_to1
function moo_btn_to1($name, $internal_uri, $options = array())
{
$html_options = _parse_attributes($options);
//$html_options = _convert_options_to_javascript($html_options);
$absolute = false;
if (isset($html_options['absolute_url'])) {
$html_options['absolute'] = $html_options['absolute_url'];
unset($html_options['absolute_url']);
}
if (isset($html_options['absolute'])) {
$absolute = (bool) $html_options['absolute'];
unset($html_options['absolute']);
}
$html_options['href'] = url_for($internal_uri, $absolute);
//echo '<b style="font-size: 8px; color: #F00">'.$html_options['href'].'</b>';
if (isset($html_options['query_string'])) {
$html_options['href'] .= '?' . $html_options['query_string'];
unset($html_options['query_string']);
}
if (isset($html_options['anchor'])) {
$html_options['href'] .= '#' . $html_options['anchor'];
unset($html_options['anchor']);
}
if (is_object($name)) {
if (method_exists($name, '__toString')) {
$name = $name->__toString();
} else {
throw new sfException(sprintf('Object of class "%s" cannot be converted to string (Please create a __toString() method).', get_class($name)));
}
}
if (!strlen($name)) {
$name = $html_options['href'];
}
$tag = 'div';
if (isset($html_options['htmlTag'])) {
$tag = $html_options['htmlTag'];
unset($html_options['htmlTag']);
}
if (!isset($html_options['class'])) {
$html_options['class'] = 'btn110';
}
if (isset($html_options['tagHref'])) {
$html_options[$html_options['tagHref']] = $html_options['href'];
unset($html_options['tagHref']);
unset($html_options['href']);
}
if (isset($html_options['addNodeIcn'])) {
$tagIcn = $html_options['addNodeIcn'];
$icnClass = 'icn';
unset($html_options['addNodeIcn']);
if (isset($html_options['icnClass'])) {
$icnClass .= ' ' . $html_options['icnClass'];
unset($html_options['icnClass']);
}
return '<' . $tag . _tag_options($html_options) . '><' . $tagIcn . ' class="' . $icnClass . '"></' . $tagIcn . '>' . $name . '</' . $tag . '>';
} else {
return '<' . $tag . _tag_options($html_options) . '>' . $name . '</' . $tag . '>';
}
}
示例11: content_tag
/**
* Examples:
* * <tt>content_tag("p", "Hello world!") => <p>Hello world!</p></tt>
* * <tt>content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") => </tt>
* <tt><div class="strong"><p>Hello world!</p></div></tt>
*/
function content_tag( $name, $content, $options = false )
{
return "<".$name._tag_options( $options ).">".$content."</".$name.">";
}
示例12: render
/**
* Renders the button
*
* @return string
*
*/
public function render()
{
// Disable the button if a reference to current user has been passed and
// the user has not the required credentials to use that button
$hasCredentials = true;
if (isset($this->currentUser) && isset($this->requiredCredentials) && !$this->currentUser->hasCredential($this->requiredCredentials)) {
$hasCredentials = false;
$this->enabled = false;
}
// Sets the image
$this->image = $this->enabled ? $this->image : ($this->imageDisabled != '' ? $this->imageDisabled : $this->image);
if ($this->image != '') {
$image = sprintf('<img src="%s" %s />', $this->image, _tag_options($this->imageParams));
} else {
// No image specified, configuring a text button
$image = '';
$this->imageTextRelation = 4;
}
// action
if ($this->action != '') {
if (!$this->enabled) {
$this->action = 'alert(\'You don\\\'t have the require credentials for this function\')';
$this->actionParams = $this->actionDisabledParams;
}
$function = substr($this->action, 1, 2) != 'on' ? sprintf('onclick="%s return false;"', w3sCommonFunctions::checkLastDirSeparator($this->action, ';')) : $this->action;
} else {
$function = '';
}
return sprintf($this->buttonSkeleton(), $this->linkedTo, $function, _tag_options($this->actionParams), $image, $this->caption);
}