本文整理汇总了PHP中KInflector::underscore方法的典型用法代码示例。如果您正苦于以下问题:PHP KInflector::underscore方法的具体用法?PHP KInflector::underscore怎么用?PHP KInflector::underscore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KInflector
的用法示例。
在下文中一共展示了KInflector::underscore方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(KConfig $options)
{
parent::__construct($options);
$this->_name = KInflector::underscore($options->text);
$img = KFactory::get('admin::com.ninja.helper.default')->img('/32/' . $this->_name . '.png');
if ($img) {
KFactory::get('admin::com.ninja.helper.default')->css('.toolbar .' . $options->icon . ' { background-image: url(' . $img . '); }');
}
if (!isset($this->_options['x'])) {
$this->_options['x'] = 720;
}
if (!isset($this->_options['y'])) {
$this->_options['y'] = 'window.getSize().size.y-80';
}
if (!isset($this->_options['handler'])) {
$this->_options['handler'] = 'iframe';
}
if (!isset($this->_options['ajaxOptions'])) {
$this->_options['ajaxOptions'] = '{}';
}
}
示例2: displayMenubar
public function displayMenubar()
{
$name = KInflector::underscore($this->_mixer->getName());
$subview = array();
foreach ($this->_views->menu as $view) {
$title = (string) $view;
$link = (string) $view['view'];
$component = $this->_mixer->getIdentifier()->package;
$active = $link == $name;
if ((bool) $this->_views->{KInflector::underscore((string) $view)}) {
$subview[] = ' <strong>▾</strong></a><ul>';
foreach ($this->_views->{KInflector::underscore((string) $view)}->children() as $subviews) {
//This subview is named the same as the view
$isIdentical = (string) $subviews['view'] === (string) $view['view'];
//Current view is active
$viewActive = (string) $view['view'] === $name;
$subviewActive = (string) $subviews['view'] === $name;
$subviewarr = (array) $this->_views->{KInflector::underscore((string) $view)};
if (!$subviewActive) {
$subview[] = '<li><a href="index.php?option=com_' . $component . '&view=' . $subviews['view'] . '">';
$subview[] = JText::_((string) $subviews);
$subview[] = '</a></li>';
} else {
$title = (string) $subviews;
$link = (string) $subviews['view'];
$active = true;
$subview[] = '<li class="disabled"><a>▸ ';
$subview[] = JText::_((string) $subviews);
$subview[] = '</a></li>';
}
}
$subview[] = '</ul><a style="display:none;">';
}
JSubMenuHelper::addEntry(JText::_($title) . implode($subview), 'index.php?option=com_' . $component . '&view=' . $link, $active);
$subview = array();
}
}
示例3: defined
<?php
defined('KOOWA') or die('Restricted access');
?>
<?php
/* Prepare the batch of css classes we wrap our posts with */
$class[] = 'ninjaboard-post';
$class[] = $params['style']['posts_wrap_style'] == 'extra' ? 'ninjaboard-block' : '';
$class[] = @id();
$class[] = 'poster-rank-' . @escape(KInflector::underscore($post->rank_title));
foreach ($post->usergroups as $usergroup) {
$class[] = 'poster-usergroup-' . @escape(KInflector::underscore($usergroup->title));
}
if ($topic->started_by == $post->created_by) {
$class[] = 'poster-is-topic-creator';
}
?>
<div class="<?php
echo implode(' ', $class);
?>
" id="<?php
echo @id('post-' . $post->id);
?>
">
<a name="p<?php
echo @$post->id;
?>
"></a>
<?php
示例4: testClassifyToUnderscore
/**
* @dataProvider provideNames
*/
public function testClassifyToUnderscore($classified, $separator, $split, $exploded, $camelized, $underscored)
{
$this->assertEquals(KInflector::underscore($classified), $underscored);
}
示例5: _belongsTo
/**
* Creates a belongs to relationship (many to one).
*
* @param KConfig $config Relationship options
*
* @return AnDomainRelationshipManytoone
*/
protected static function _belongsTo(KConfig $config)
{
$description = $config['description'];
$config['child'] = $description->getEntityIdentifier();
$config->append(array('type_column' => KInflector::underscore($config->name) . '_type', 'child_column' => KInflector::underscore($config->name) . '_id'));
if (is_string($config->type_column)) {
$config->type_column = $description->getRepository()->getResources()->getColumn($config->type_column);
}
if (is_string($config->child_column)) {
$config->child_column = $description->getRepository()->getResources()->getColumn($config->child_column);
}
if (!$config->child_column) {
throw new AnDomainPropertyException('The ' . $config->name . ' belongs to relationship is missing a child column');
}
//if the relationship is not polymorphic the we need to set
//a parent if none is set
if (!$config->polymorphic && !$config['parent']) {
$parent = clone $description->getEntityIdentifier();
$parent->name = $config['name'];
$config->append(array('parent' => $parent));
}
if (is_string($config->parent) && strpos($config->parent, '.') === false) {
$parent = clone $description->getEntityIdentifier();
$parent->name = $config->parent;
$config->parent = $parent;
}
$relationship = AnDomainPropertyAbstract::getInstance('relationship.manytoone', $config);
if ($config->inverse) {
if (is_bool($config->inverse)) {
$config['inverse'] = array();
}
$relationship->setInverse($config->inverse);
}
return $relationship;
}
示例6: __call
/**
* Supports a simple form Fluent Interfaces. Allows you to set states by
* using the state name as the method name.
*
* For example : $model->sort('name')->limit(10)->getList();
*
* @param string Method name
* @param array Array containing all the arguments for the original call
* @return KModelAbstract
*
* @see http://martinfowler.com/bliki/FluentInterface.html
*/
public function __call($method, $args)
{
if (count($args) > 0) {
$this->__set(KInflector::underscore($method), $args[0]);
return $this;
}
throw new BadMethodCallException('Call to undefined method :' . $method);
}
示例7: defined
<?php
defined('KOOWA') or die('Restricted access');
?>
<?php
if ($usergroups) {
?>
<ul class="person-usergroups">
<?php
foreach ($usergroups as $group) {
?>
<?php
$alias = KInflector::underscore($group->title);
?>
<li class="usergroup-<?php
echo $alias;
?>
">
<?php
$icon = @$img('/usergroup/' . $alias . '.png');
?>
<?php
if ($icon) {
?>
<img src="<?php
echo $icon;
?>
" title="<?php
echo @escape($group->title);
?>
示例8: __call
/**
* If a proeprty is used then it will be used as condition. For example $query->id(10) create
* $query->where('id','=',10).
*
* If a method is format of fetch|select[Function Name]Value(s)(property). This will be translated in to
* fetchValue('{Function Name}(property)'). For example fetchCount => fetchValue('COUNT({property}')
*
* If not of the above then KInflector::underscore($method) will be inserted as a state
*/
public function __call($method, $arguments = array())
{
$match = array();
//only do condition chaining if it's a real property
//don't check the parent property
if ($this->getRepository()->getDescription()->getProperty($method)) {
$constraint = isset($arguments[1]) ? $arguments[1] : '=';
$condition = isset($arguments[2]) ? $arguments[2] : 'AND';
$this->where($method, $constraint, $arguments[0], $condition);
} elseif (preg_match('/(fetch|select)(\\w+)/', $method, $match)) {
deprecated('use ' . $match[1] . '(FUNC) instead');
$column = isset($arguments[0]) ? $arguments[0] : '*';
$property = $this->getRepository()->getDescription()->getProperty($column);
if ($property) {
$column = '@col(' . $column . ')';
}
if ($match[1] == 'select') {
$method = 'columns';
} elseif (KInflector::isPlural($match[2])) {
$method = 'fetchValues';
} else {
$method = 'fetchValue';
}
$function = strtoupper($match[2]) . '(' . $column . ')';
return $this->{$method}($function);
} elseif (count($arguments) > 0) {
$this->__set(KInflector::underscore($method), $arguments[0]);
} else {
throw new BadMethodCallException('Call to undefined method :' . $method);
}
return $this;
}
示例9: __call
/**
* Supports a simple form Fluent Interfaces. Allows you to set the request
* properties by using the request property name as the method name.
*
* For example : $controller->view('name')->limit(10)->browse();
*
* @param string Method name
* @param array Array containing all the arguments for the original call
*
* @return KControllerBread
*
* @see http://martinfowler.com/bliki/FluentInterface.html
*/
public function __call($method, $args)
{
//omit anything that starts with underscore
if (strpos($method, '_') === false) {
if (count($args) == 1 && !isset($this->_mixed_methods[$method]) && !in_array($method, $this->getActions())) {
$this->{KInflector::underscore($method)} = $args[0];
return $this;
}
} elseif (strpos($method, '_action') === 0) {
//if the missing method is _action[Name] but
//method exists, then that means the action
//has been called on the object parent i.e.
//parent::_action[Name] but since the parent is
//not implementing the action it falls back to
//__call.
//we need to check if a behavior implement this
//method
if (method_exists($this, $method)) {
$action = strtolower(substr($method, 7));
if (isset($this->_mixed_methods[$action])) {
return $this->_mixed_methods[$action]->execute('action.' . $action, isset($args[0]) ? $args[0] : null);
} else {
//we need to throw this
//because if it goes to parent::__call it will causes
//infinite recursion
throw new BadMethodCallException('Call to undefined method :' . $method);
}
}
}
return parent::__call($method, $args);
}
示例10: __call
/**
* Supports a simple form of Fluent Interfaces. Allows you to assign variables to the view
* by using the variable name as the method name. If the method name is a setter method the
* setter will be called instead.
*
* For example : $view->layout('foo')->title('name')->display().
* It also supports using name method setLayout($layout) which will be translated to set('layout', $layout)
*
* @param string Method name
* @param array Array containing all the arguments for the original call
* @return LibBaseViewAbstract
*
* @see http://martinfowler.com/bliki/FluentInterface.html
*/
public function __call($method, $args)
{
//If one argument is passed we assume a setter method is being called
if (!isset($this->_mixed_methods[$method]) && count($args) == 1) {
$this->set(KInflector::underscore($method), $args[0]);
return $this;
}
return parent::__call($method, $args);
}
示例11: _createButton
protected function _createButton($url, $name, $button)
{
$html = array();
$var = KInflector::underscore($button);
$href = new KObject();
$href->set(array_merge($url->get(), array('view' => $var)));
$attr = current((array) $button->attributes());
if ($attr['view'] == KRequest::get('get.view', 'cmd', 'dashboard')) {
return false;
}
$img = isset($attr['img']) ? $attr['img'] : null;
$attr['img'] = null;
if (!empty($attr)) {
$href->set($attr);
}
$html[] = '<div><div class="dashboard-button">';
$html[] = '<a href="' . JRoute::_('index.php?' . http_build_query($href->get())) . '"><img src="' . KFactory::get('admin::com.ninja.helper.default')->img('/48/' . JFile::stripExt(basename($img)) . '.png') . '" alt="' . $button . '"/><span>' . JText::_($button) . '</span></a>';
$html[] = '</div></div>';
return implode($html);
}
示例12: sort
public function sort($config = array())
{
$config = new KConfig($config);
//Set defaults
$config->append(array('title' => 'Title'));
//Set more defaults
$config->append(array('order' => KInflector::underscore($config->title), 'icon' => JHTML::_('image.administrator', 'sort_' . $config->direction . '.png', 'images/', NULL, NULL)));
$img = '';
if ($sortables = $this->sortables) {
$sortables = 'ordering';
}
//$model = $model->getModel()->getState();
//$selected = $model->selected ? $model->selected : 0;
// only for the current sorting
if ($config->sort === $config->order) {
$img = $config->icon;
$config->direction = $config->direction == 'desc' ? 'asc' : 'desc';
// toggle
}
// modify url
$url = clone KRequest::url();
$query = $url->getQuery(1);
$query['sort'] = $config->order;
$query['direction'] = $config->direction;
$url->setQuery($query);
// render html
$html = '<a href="' . JRoute::_($url) . '" title="' . JText::_('Click to sort by this column') . '" class="grid-sort">';
$html .= JText::_($config->title) . $img;
$html .= '</a>';
return $html;
}
示例13:
if ($post->rank_title && $post->rank_icon && @$img('/rank/' . $post->rank_icon)) {
?>
<strong class="rank"><?php
echo @$post->rank_title;
?>
</strong>
<div class="rank_icon"><img src="<?php
echo @$img('/rank/' . @$post->rank_icon);
?>
" /></div>
<?php
}
?>
<p class="posts"><strong><?php
echo @text('Posts:');
?>
</strong> <?php
echo $post->person_posts;
?>
</p>
<!--<img src="<?php
echo @$img('/usergroup/' . KInflector::underscore($post->usertype) . '.png');
?>
" />
<img src="<?php
echo @$img('/usergroup/' . KInflector::underscore($post->usertype) . '.png');
?>
" />-->
</div>
</div>
示例14: foreach
<?php
foreach (@$forums as $forum) {
?>
<li class="row forum <?php
echo $forum->new && $forum->unread ? 'unread' : '';
?>
<?php
echo !$forum->unread ? 'read' : '';
?>
">
<?php
$icon = isset($forum->params['customization']['icon']) ? $forum->params['customization']['icon'] : 'default.png';
?>
<?php
$iconclass = 'forum-icon-' . KInflector::underscore(str_replace('.', '', $icon));
?>
<style type="text/css">.row .<?php
echo $iconclass;
?>
{background-image: url(<?php
echo @$img('/forums/' . $icon);
?>
);}</style>
<dl class="icon <?php
echo $iconclass;
?>
">
<dt>
<span class="unread-indicator" title="<?php