本文整理汇总了PHP中KInflector::singularize方法的典型用法代码示例。如果您正苦于以下问题:PHP KInflector::singularize方法的具体用法?PHP KInflector::singularize怎么用?PHP KInflector::singularize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KInflector
的用法示例。
在下文中一共展示了KInflector::singularize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCommands
/**
* Get the list of commands
*
* Will attempt to use information from the xml manifest if possible
*
* @return array
*/
public function getCommands()
{
$name = $this->getController()->getIdentifier()->name;
$package = $this->_identifier->package;
$manifest = JPATH_ADMINISTRATOR.'/components/com_'.$package.'/manifest.xml';
if(file_exists($manifest))
{
$xml = simplexml_load_file($manifest);
if(isset($xml->administration->submenu))
{
foreach($xml->administration->submenu->children() as $menu)
{
$view = (string)$menu['view'];
$this->addCommand(JText::_((string)$menu), array(
'href' => JRoute::_('index.php?option=com_'.$package.'&view='.$view),
'active' => ($name == KInflector::singularize($view))
));
}
}
}
return parent::getCommands();
}
示例2: 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);
}
示例3: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param object An optional KConfig object with configuration options.
* @return void
*/
protected function _initialize(KConfig $config)
{
$package = $this->_identifier->package;
$name = KInflector::singularize($this->_identifier->name);
$config->append(array('xml_path' => JPATH_ADMINISTRATOR . '/components/com_' . $package . '/views/' . $name . '/tmpl/' . $name . '.xml'));
parent::_initialize($config);
}
示例4: humanize
public function humanize($config = array())
{
$config = new KConfig($config);
$config->append(array(
'sizes' => array('Bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb')
));
$bytes = $config->size;
$result = '';
$format = (($bytes > 1024*1024 && $bytes % 1024 !== 0) ? '%.2f' : '%d').' %s';
foreach ($config->sizes as $s) {
$size = $s;
if ($bytes < 1024) {
$result = $bytes;
break;
}
$bytes /= 1024;
}
if ($result == 1) {
$size = KInflector::singularize($size);
}
return sprintf($format, $result, JText::_($size));
}
示例5: getRow
/**
* @param array $options
* @return object
*/
public function getRow(array $options = array())
{
$identifier = clone $this->getIdentifier();
$identifier->path = array('database', 'row');
$identifier->name = 'api_' . KInflector::singularize($this->getIdentifier()->name);
return $this->getService($identifier, $options);
}
示例6: _initialize
/**
* Initializes the options for the object.
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param object An optional KConfig object with configuration options.
*/
protected function _initialize(KConfig $config)
{
$child = clone $this->_parent;
$child->name = KInflector::singularize($config->name);
$config->append(array('entityset' => 'anahita:domain.entityset.onetomany', 'cardinality' => 'many', 'child_key' => $this->_parent->name, 'parent_delete' => AnDomain::DELETE_CASCADE, 'child' => $child));
parent::_initialize($config);
}
示例7: onContentSearch
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
if ($text) {
$rows = array();
$rowset = KService::get('com://admin/kutafuta.model.terms')->type($phrase)->search($text)->getList();
foreach ($rowset as $row) {
// We have table and row.
// Row is always multiple but we check non the less.
$parts = explode('_', $row->table);
$data = KService::get('com://site/' . $parts[0] . '.model.' . KInflector::pluralize($parts[1]))->id($row->row)->getItem();
if (empty($data->id)) {
continue;
}
$result = new stdClass();
$result->title = $data->title;
$result->metadesc = $data->meta_description;
$result->metakey = $data->meta_keywords;
$result->created = $data->created_on;
$result->text = $data->introtext . $data->fulltext;
$result->href = 'index.php?option=com_' . $parts[0] . '&view=' . KInflector::singularize($parts[1]) . '&id=' . $row->row;
$rows[] = $result;
}
return $rows;
}
}
示例8: _commandNew
protected function _commandNew(KControllerToolbarCommand $command)
{
$option = $this->getIdentifier()->package;
$view = KInflector::singularize($this->getIdentifier()->name);
$section = $this->getController()->getModel()->get('section');
$command->attribs->href = JRoute::_('index.php?option=com_' . $option . '&view=' . $view . '§ion=' . $section);
}
示例9: _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'));
}
}
示例10: translations
public function translations($config = array())
{
$config = new KConfig($config);
$config->append(array('row' => null, 'table' => ''));
// First for our knowledge we get the original language (if exists.)
$original = $this->_getOriginalLanguage($config->row, $config->table);
$html = '<style src="media://com_translations/css/translations.css" />';
$view = KInflector::singularize(KRequest::get('get.view', 'string'));
foreach ($this->_getLanguages() as $language) {
$relation = $this->_getLanguage($config, $language->lang_code);
if ($language->lang_code == $original->iso_code) {
$html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-info">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
} else {
if ($relation->translated) {
$html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-success">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
} else {
if (strtotime('+ 2 weeks', strtotime($original->created_on)) > strtotime(date('d-m-Y H:i:s'))) {
$html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-warning">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
} else {
if (strtotime('+ 2 weeks', strtotime($original->created_on)) < strtotime(date('d-m-Y H:i:s'))) {
$html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-important">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
}
}
}
}
}
return $html;
}
示例11: _splitview
/**
* Generates an HTML optionlist based on the distinct data from a model column.
*
* The column used will be defined by the name -> value => column options in
* cascading order.
*
* If no 'model' name is specified the model identifier will be created using
* the helper identifier. The model name will be the pluralised package name.
*
* If no 'value' option is specified the 'name' option will be used instead.
* If no 'text' option is specified the 'value' option will be used instead.
*
* @param array An optional array with configuration options
* @return string Html
* @see __call()
*/
protected function _splitview($config = array())
{
$config = new KConfig($config);
$config->append(array('id' => 'splitview', 'name' => '', 'package' => 'com_' . $this->getIdentifier()->package))->append(array('master_view' => KInflector::pluralize($config->name), 'detail_view' => KInflector::singularize($config->name)))->append(array('options' => array('master_url' => '?option=' . $config->package . '&view=' . $config->master_view . '&format=json&sort=created_on&direction=desc', 'detail_url' => '?option=' . $config->package . '&view=' . $config->detail_view . '&format=raw', 'label' => array('empty' => JText::_('No ' . KInflector::humanize($config->master_view) . '.'), 'select' => JText::_('No ' . KInflector::humanize($config->detail_view) . ' selected.')))));
KFactory::get('admin::com.ninja.helper.default')->js('/splitview.js');
KFactory::get('admin::com.ninja.helper.default')->js("\njQuery(function(\$){\n\t\t\t\$('#" . $config->id . "').splitview(" . json_encode($config->options->toArray()) . ");\n\t\t});\n");
return '<div id="' . $config->id . '" class="splitview"></div>';
}
示例12: getOnClick
public function getOnClick()
{
$option = KRequest::get('get.option', 'cmd');
$view = KInflector::singularize(KRequest::get('get.view', 'cmd'));
$json = "{method:'get', url:'index.php', params:{option:'{$option}',view:'{$view}',id:id}}";
$msg = JText::_('Please select an item from the list');
return 'var id = Koowa.Grid.getFirstSelected();' . 'if(id){new Koowa.Form(' . $json . ').submit();} ' . 'else { alert(\'' . $msg . '\'); return false; }';
}
示例13: render
public function render()
{
$option = KRequest::get('get.option', 'cmd');
$view = KInflector::singularize(KRequest::get('get.view', 'cmd'));
$link = 'index.php?option=' . $option . '&view=' . $view;
$this->attribs->set(array('class' => 'toolbar', 'href' => $this->_parent->createRoute($link)));
return parent::render();
}
示例14: __call
/**
* Search the mixin method map and call the method or trigger an error
*
* This function check to see if the method exists in the mixing map if not
* it will call the 'listbox' function. The method name will become the 'name'
* in the config array.
*
* This can be used to auto-magically create select filters based on the
* function name.
*
* @param string The function name
* @param array The function arguments
* @throws BadMethodCallException If method could not be found
* @return mixed The result of the function
*/
public function __call($method, array $arguments)
{
if (!in_array($method, $this->getMethods())) {
$config = $arguments[0];
$config['name'] = KInflector::singularize(strtolower($method));
return $this->_listbox($config);
}
return parent::__call($method, $arguments);
}
示例15: find
/**
* Return a scope using a key or not if not found.
*
* @param string $scope
*
* @return ComSearchDomainScope
*/
public function find($scope)
{
if (strpos($scope, '.') === false) {
$scope = $scope . '.' . KInflector::singularize($scope);
}
if (isset($this[$scope])) {
return $this[$scope];
}
return;
}