本文整理汇总了PHP中inflector::underscore方法的典型用法代码示例。如果您正苦于以下问题:PHP inflector::underscore方法的具体用法?PHP inflector::underscore怎么用?PHP inflector::underscore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inflector
的用法示例。
在下文中一共展示了inflector::underscore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render(&$render_variables, $errors = array())
{
$result = parent::render($render_variables, $errors);
// Clean attributes
$id = $this->_clean_attributes($result['attributes'], 'id');
$buffer = array();
foreach ($this->options as $value => $title) {
if ($this->value == $value) {
$buffer[inflector::underscore($title)] = form::radio($result['attributes'], $value, TRUE);
} else {
$buffer[inflector::underscore($title)] = form::radio($result['attributes'], $value);
}
}
$result['template']->element = $buffer;
return (string) $result['template']->render();
}
示例2: _cellToAnchor
/**
*
* This function takes the result cell, the link parameters, and the result row
* and puts it all together to wrap a cell in a appropriate link!
*
* @return string HTML of cell wrapped in link
* @param string $cell The current value of the cell (to be wrapped)
* @param array $link The link parameter array
* @param array $result The current result row
*/
private function _cellToAnchor($cell, $link, $result, $reqAllArgs = false)
{
// Ensure there is something for a url
if (!empty($link['link'])) {
$url = $link['link'];
} elseif (is_string($link)) {
$url = $link;
} else {
$url = '';
}
$cell = self::_i18n($cell);
// Ensure attributes and arguments are set so we are not dealing with unset vars
$attributes = empty($link['attributes']) ? '' : $link['attributes'];
$arguments = array();
// This ensures there is a title tag on the link
if (empty($attributes['title'])) {
$attributes['title'] = inflector::underscore($cell);
}
// Tack on any argumnets
if (!empty($link['arguments'])) {
// Standardize strings as arrays
$link['arguments'] = is_array($link['arguments']) ? $link['arguments'] : array($link['arguments']);
foreach ($link['arguments'] as $argument) {
extract(self::_splitPath($argument));
// If we can not fulfill the arguments (ie there was no result for an argument)
// and we are required to do so then return false
if (!isset($result[$hydrateName]) && $reqAllArgs) {
return false;
}
// This looks for the optional passAsSegments parameter for a column link
if (!isset($link['passAsSegments']) || $link['passAsSegments'] == true) {
// If the args are passed as segments then we need to maintain the total count and order
$arguments[] = isset($result[$hydrateName]) ? $result[$hydrateName] : '';
} else {
// If we are passing these args a GETs then we only need to do those that are set
if (isset($result[$hydrateName])) {
$arguments[] = $column . '=' . $result[$hydrateName];
}
}
}
}
// If arguments are passed as segments then the seperator is / and there will ALWAYS be a set amount
if (!isset($link['passAsSegments']) || $link['passAsSegments'] == true) {
$url = rtrim($url, '/') . '/' . rawurlencode(self::_implode($arguments, '/'));
} else {
// If the arguments are GETs then join on &, if there are any
if ($args = self::_implode($arguments, '&')) {
$url .= '?' . $args;
}
}
$cell = htmlspecialchars($cell);
// Wrap the cell results in a anchor tag
return html::anchor($url, $cell, $attributes);
}
示例3: title_slug
/**
* Returns a URL Safe Title Slug, limited to the specified characters
*
* @param string title
* @param int limit (default 25)
* @return string url safe slug
*/
public static function title_slug($title, $limit = 25)
{
return preg_replace("/([_+]|_)\$/", "", str::limit_chars(inflector::underscore(str::strip_all_but(strtolower($title), "a-z0-9 \\_")), $limit, ""));
}
示例4: get_path
public function get_path()
{
return url::site() . 'themes/' . inflector::underscore($this->name) . '/';
}