本文整理汇总了PHP中KInflector::pluralize方法的典型用法代码示例。如果您正苦于以下问题:PHP KInflector::pluralize方法的具体用法?PHP KInflector::pluralize怎么用?PHP KInflector::pluralize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KInflector
的用法示例。
在下文中一共展示了KInflector::pluralize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display()
{
$targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData();
$thing = reset($targets);
$string = substr($thing['title'], 3);
$option = strtolower(substr($string, 0, stripos($string, 'controller')));
$view = strtolower(substr($string, stripos($string, 'controller') + 10));
$model = KInflector::pluralize($view);
$list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->getList()->getData();
$array = array();
foreach ($list as $item) {
$array[] = $item['id'];
}
//Get the list of posts
$activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList();
$myactivities = array();
foreach (@$activities as $activity) {
if (!in_array($activity->parent_target_id, $array)) {
continue;
} else {
$myactivities[] = $activity;
}
}
$this->assign('myactivities', $myactivities);
$this->assign('pagination', KFactory::get($this->getModel())->getState()->pagination);
return parent::display();
}
示例2: setModel
public function setModel($model)
{
$model = parent::setModel($model);
$model->package = KInflector::pluralize($this->_identifier->name);
return $model;
}
示例3: _pathFromIdentifier
/**
* Get the path based on an identifier
*
* @param object An Identifier object - com:[//application/]component.view.[.path].name
* @return string|false Returns the path on success FALSE on failure
*/
protected function _pathFromIdentifier($identifier)
{
$path = false;
if($identifier->type == 'yaml')
{
$parts = $identifier->path;
$component = 'com_'.strtolower($identifier->package);
//Store the basepath for re-use
if($identifier->basepath) {
$this->_basepath = $identifier->basepath;
}
if(!empty($identifier->name))
{
if(count($parts))
{
$path = KInflector::pluralize(array_shift($parts));
$path .= count($parts) ? '/'.implode('/', $parts) : '';
$path .= '/'.strtolower($identifier->name);
}
else $path = strtolower($identifier->name);
}
$path = $this->_basepath.'/components/'.$component.'/'.$path.'.yaml';
}
return $path;
}
示例4: getCommands
/**
* Get the list of commands
*
* Prepending a special command not found in the manifest.xml
*
* @return array
*/
public function getCommands()
{
$option = $this->getController()->getRequest()->option;
//@TODO figure out why option=com_installer&view=components sets $request->option to NULL
$active = !$option || $option == 'com_installer';
$view = $active ? 'components' : KInflector::pluralize($this->getController()->getIdentifier()->name);
$this->addCommand('Install/Uninstall', array(
'href' => JRoute::_('index.php?option=com_installer&view='.$view),
'active' => $active
));
$commands = parent::getCommands();
//If the com_installer command is active, then following commands cannot be active
if($commands['Install/Uninstall']->active)
{
foreach($commands as $key => $command)
{
if($key != 'Install/Uninstall') $command->active = false;
}
}
return $commands;
}
示例5: _initialize
/**
* Initializes the default configuration for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param KConfig $config An optional KConfig object with configuration options.
*
* @return void
*/
protected function _initialize(KConfig $config)
{
$package = KInflector::humanize($this->getIdentifier()->package);
$name = KInflector::humanize(KInflector::pluralize($this->getName()));
$config->append(array('title' => $package . ' - ' . $name));
parent::_initialize($config);
}
示例6: _beforeTableDelete
/**
* Deletes dependent rows.
*
* This performs an intelligent delete
*
* @return KDatabaseRowAbstract
*/
protected function _beforeTableDelete(KCommandContext $context)
{
$result = true;
$section = $this->section;
if (is_numeric($section) || !$section) {
$section = 'com_articles';
}
$parts = explode('_', $section);
//@TODO : Remove when refactoring is completed
switch ($parts[1]) {
case 'contact':
$name = 'contacts';
$package = 'contact';
break;
default:
$name = KInflector::pluralize($parts[1]);
$package = $name;
}
$identifier = 'com://admin/' . $package . '.model.' . $name;
$rowset = $this->getService($identifier)->category($this->id)->getList();
if ($rowset->count()) {
$result = $rowset->delete();
}
return $result;
}
示例7: _buildQueryJoins
/**
* @param KDatabaseQuery $query
*/
protected function _buildQueryJoins(KDatabaseQuery $query)
{
$state = $this->_state;
parent::_buildQueryJoins($query);
$iso_code = substr(JFactory::getLanguage()->getTag(), 0, 2);
if ($iso_code != 'en') {
$prefix = $iso_code . '_';
}
if (is_array($state->type)) {
$subquery = '(';
$i = 1;
foreach ($state->type as $type) {
$subquery .= 'SELECT ' . KInflector::pluralize($type) . '_' . KInflector::singularize($type) . '_id AS id, LOWER("' . strtoupper(KInflector::pluralize($type)) . '_' . strtoupper(KInflector::pluralize($type)) . '") AS test FROM #__' . $prefix . KInflector::pluralize($type) . '_' . KInflector::pluralize($type) . ' AS ' . KInflector::pluralize($type) . '
WHERE enabled = 1 AND frontpage = 1';
if (KInflector::singularize($type) == 'event') {
$subquery .= ' AND start_date >= CURDATE()';
}
if ($i < count($state->type)) {
$subquery .= ' UNION ALL ';
}
$i++;
}
$subquery .= ')';
$query->join[] = array('type' => 'INNER', 'table' => $subquery . 'AS b', 'condition' => array('tbl.row = b.id AND tbl.table = b.test'));
}
}
示例8: id
/**
* Helper for creating DOM element ids used by javascript behaviors
*
* If no type and package identifiers were supplied,
* uses the current option $_GET variable, and changing com_foo_bar to com-foo_bar.
* '-' are used as separators, and in our javascript used to parse identifier strings.
* If a form got the id com-foo_bar-people,
* then we can assume that the toolbar will have the id toolbar-people,
*
* @author Stian Didriksen <stian@ninjaforge.com>
* @param array | int $parts
* @return string
*/
public function id($parts = array())
{
if (!is_array($parts) && is_int($parts)) {
$parts['id'] = (int) $parts;
}
// If we pass a string, set $parts back as an array in order to proceed.
if (!is_array($parts)) {
settype($parts, 'array');
}
// Set the defaults, if needed
$defaults = array();
if (!isset($parts['type.package'])) {
// We only want to replace the first underscore, not the rest.
$defaults['type_package'] = str_replace('com_', 'com-', KRequest::get('get.option', 'cmd'));
}
if (!isset($parts['view'])) {
$view = KRequest::get('get.view', 'cmd');
// The view part always needs to be plural to allow ajax BREAD.
if (KInflector::isSingular($view)) {
$view = KInflector::pluralize($view);
}
$defaults['view'] = $view;
}
if (!isset($parts['id']) && KRequest::has('get.id', 'int')) {
$defaults['id'] = KRequest::get('get.id', 'int');
}
// Filter away parts that are unset on purpose using a null value, or a negative boolean.
return implode('-', array_filter(array_merge($defaults, $parts)));
}
示例9: findPath
/**
* Get the path based on a class name
*
* @param string The class name
* @return string|false Returns the path on success FALSE on failure
*/
public function findPath($classname, $basepath = null)
{
$path = false;
if (strpos($classname, $this->_prefix) === 0) {
$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $classname));
$parts = explode('_', $word);
if (array_shift($parts) == 'tmpl') {
$name = array_shift($parts);
$file = array_pop($parts);
if (count($parts)) {
if ($parts[0] != 'view') {
foreach ($parts as $key => $value) {
$parts[$key] = KInflector::pluralize($value);
}
} else {
$parts[0] = KInflector::pluralize($parts[0]);
}
$path = implode('/', $parts) . '/' . $file;
} else {
$path = $file;
}
$path = $this->_basepath . '/templates/' . $name . '/' . $path . '.php';
}
}
return $path;
}
示例10: render
public function render()
{
$name = $this->getName();
$img = KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.img', '/32/' . $name . '.png');
if ($img) {
KTemplateAbstract::loadHelper('admin::com.ninja.helper.default.css', '.toolbar .icon-32-' . $name . ' { background-image: url(' . $img . '); }');
}
$text = JText::_($this->_options['text']);
$view = KRequest::get('get.view', 'cmd');
$link = ' href="' . JRoute::_($this->getLink()) . '"';
$html = array();
// Sanitize the url since we can't trust the server var
$url = KFactory::get('lib.koowa.filter.url')->sanitize($this->getLink());
// Create the URI object
$uri = KFactory::tmp('lib.koowa.http.uri', array('uri' => $url));
$query = $uri->getQuery(1);
$html[] = '<td class="button" id="' . $this->getId() . '">';
$active = $view == KInflector::variablize(KInflector::pluralize($query['view'])) || $view == KInflector::variablize(KInflector::singularize($query['view']));
$hide = !KInflector::isPlural($view);
if ($active || $hide || !$this->modal) {
$html[] = '<a class="toolbar inactive">';
} else {
$html[] = '<a' . $link . ' onclick="' . $this->getOnClick() . '" class="toolbar">';
}
$html[] = '<span class="' . $this->getClass() . '" title="' . $text . '">';
$html[] = '</span>';
$html[] = $text;
if (!$active && !$hide || $this->modal) {
$html[] = '</a>';
} else {
$html[] = '</a>';
}
$html[] = '</td>';
return implode(PHP_EOL, $html);
}
示例11: _updateLanguages
public function _updateLanguages($id, $items)
{
foreach ($items as $language => $item) {
$model_identifier = clone $item->getIdentifier();
$model_identifier->path = array('model');
$model_identifier->name = KInflector::pluralize($model_identifier->name);
// Original Data
$data = $item->getData();
unset($data['id']);
if (isset($data['featured'])) {
unset($data['featured']);
}
$this->_checkName($item, false);
$title = $item->title . ' (' . $this->count . ')';
$slug = $item->slug . '-' . $this->count;
JFactory::getLanguage()->setLanguage($language);
$row = $this->getService($model_identifier)->id($id)->getItem();
$row->setData($data);
$row->title = $title;
$row->enabled = 0;
$row->slug = $slug;
$row->translated = 0;
if ($row->isRelationable()) {
$row->setData(json_decode($row->ancestors));
$row->setData(json_decode($row->descendants));
}
$row->save();
}
}
示例12: loadClass
/**
* Load the file for a class
*
* @param string $class The class that will be loaded
* @return boolean True on success
*/
public static function loadClass($class)
{
// pre-empt further searching for the named class or interface.
// do not use autoload, because this method is registered with
// spl_autoload already.
if (class_exists($class, false) || interface_exists($class, false)) {
return;
}
// if class start with a 'Nooku' it is a Nooku class.
// create the path and register it with the loader.
switch (substr($class, 0, 6)) {
case 'Picman':
$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', substr_replace($class, '', 0, 6)));
$parts = explode('_', $word);
if (count($parts) > 1) {
$path = KInflector::pluralize(array_shift($parts)) . DS . implode(DS, $parts);
} else {
$path = $word;
}
if (is_file(dirname(__FILE__) . DS . $path . '.php')) {
KLoader::register($class, dirname(__FILE__) . DS . $path . '.php');
}
break;
}
$classes = KLoader::register();
if (array_key_exists(strtolower($class), $classes)) {
include $classes[strtolower($class)];
return true;
}
return false;
}
示例13: _commandDelete
/**
* Delete Command for an entity.
*
* @param LibBaseTemplateObject $command The action object
*/
protected function _commandDelete($command)
{
$entity = $this->getController()->getItem();
$name = KInflector::pluralize($this->getController()->getIdentifier()->name);
$redirect = 'option=com_' . $this->getIdentifier()->package . '&view=' . $name;
$command->append(array('label' => JText::_('LIB-AN-ACTION-DELETE')))->href(JRoute::_($entity->getURL()))->setAttribute('data-action', 'delete')->setAttribute('data-redirect', JRoute::_($redirect))->class('action-delete');
}
示例14: order
public function order($config = array())
{
$config = new KConfig($config);
$config->append(array(
'name' => 'order',
'state' => null,
'attribs' => array(),
'model' => null,
'package' => $this->getIdentifier()->package,
'selected' => 0
));
//@TODO can be removed when name collisions fixed
$config->name = 'order';
$app = $this->getIdentifier()->application;
$identifier = 'com://'.$app.'/'.$config->package.'.model.'.($config->model ? $config->model : KInflector::pluralize($config->package));
$list = KFactory::get($identifier)->limit(0)->set($config->filter)->getList();
$options = array();
foreach($list as $item) {
$options[] = $this->option(array('text' => $item->ordering, 'value' => $item->ordering - $config->ordering));
}
$list = $this->optionlist(array(
'options' => $options,
'name' => $config->name,
'attribs' => $config->attribs,
'selected' => $config->selected
));
return $list;
}
示例15: findPath
/**
* Get the path based on a class name
*
* @param string The class name
* @return string|false Returns the path on success FALSE on failure
*/
public function findPath($classname, $basepath = null)
{
$path = false;
$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
$parts = explode(' ', $word);
if (array_shift($parts) == 'com') {
//Switch the basepath
if (!empty($basepath)) {
$this->_basepath = $basepath;
}
$component = 'com_' . strtolower(array_shift($parts));
$file = array_pop($parts);
if (count($parts)) {
if ($parts[0] != 'view') {
foreach ($parts as $key => $value) {
$parts[$key] = KInflector::pluralize($value);
}
} else {
$parts[0] = KInflector::pluralize($parts[0]);
}
$path = implode('/', $parts);
$path = $path . '/' . $file;
} else {
$path = $file;
}
$path = $this->_basepath . '/components/' . $component . '/' . $path . '.php';
}
return $path;
}