本文整理汇总了PHP中KInflector::isPlural方法的典型用法代码示例。如果您正苦于以下问题:PHP KInflector::isPlural方法的具体用法?PHP KInflector::isPlural怎么用?PHP KInflector::isPlural使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KInflector
的用法示例。
在下文中一共展示了KInflector::isPlural方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Return the views output
*
* This function will auto assign the model data to the view if the auto_assign
* property is set to TRUE.
*
* @return string The output of the view
*/
public function display()
{
if(empty($this->output))
{
$model = $this->getModel();
//Auto-assign the state to the view
$this->assign('state', $model->getState());
//Auto-assign the data from the model
if($this->_auto_assign)
{
//Get the view name
$name = $this->getName();
//Assign the data of the model to the view
if(KInflector::isPlural($name))
{
$this->assign($name, $model->getList())
->assign('total', $model->getTotal());
}
else $this->assign($name, $model->getItem());
}
}
return parent::display();
}
示例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: setDocumentTitle
/**
* Sets the document title
*/
public function setDocumentTitle()
{
if (!KInflector::isPlural($this->getName())) {
$item = $this->getModel()->getItem();
JFactory::getDocument()->setTitle($item->title);
}
}
示例4: setPermissions
/**
* Generic function for setting the permissions
*
* @return void
*/
public function setPermissions($context)
{
//Temp fix
if (KInflector::isPlural(KRequest::get('get.view', 'cmd')) || KRequest::type() == 'AJAX') {
return;
}
$model = KFactory::get($this->getModel());
$table = KFactory::tmp(KFactory::get(KFactory::get('admin::com.ninja.helper.access')->models->assets)->getTable());
$query = $table->getDatabase()->getQuery();
$item = $model->getItem();
$identifier = $this->getIdentifier();
$id = $identifier->type . '_' . $identifier->package . '.' . $identifier->name . '.' . $item->id . '.';
$permissions = (array) KRequest::get('post.permissions', 'int');
$editable = KRequest::get('post.editpermissions', 'boolean', false);
if (!$permissions && $editable) {
$query->where('tbl.name', 'LIKE', $id . '%');
$table->select($query)->delete();
}
$safe = array();
$query = $table->getDatabase()->getQuery()->where('name', 'like', $id . '%');
foreach ((array) KRequest::get('post.params.permissions', 'raw') as $group => $other) {
$safe[] = $id . $group;
}
if ($safe) {
$query->where('name', 'not in', $safe);
}
$table->select($query, KDatabase::FETCH_ROWSET)->delete();
foreach ($permissions as $usergroup => $rules) {
foreach ($rules as $name => $permission) {
KFactory::tmp(KFactory::get('admin::com.ninja.helper.access')->models->assets)->name($id . $usergroup . '.' . $name)->getItem()->setData(array('name' => $id . $usergroup . '.' . $name, 'level' => $permission))->save();
}
}
}
示例5: _actionGet
/**
* Get action.
*
* @param KCommandContext $context Context parameter
*
* @return string
*/
protected function _actionGet(KCommandContext $context)
{
$action = null;
if ($this->_request->get) {
$action = strtolower('get' . $this->_request->get);
} else {
$action = KInflector::isPlural($this->view) ? 'browse' : 'read';
}
$result = null;
if (in_array($action, $this->getActions())) {
$result = $this->execute($action, $context);
if (is_string($result) || $result === false) {
$context->response->setContent($result . ' ');
}
}
$view = $this->getView();
if (!$context->response->getContent()) {
if ($context->params) {
foreach ($context->params as $key => $value) {
$view->set($key, $value);
}
}
$content = $view->display();
//Set the data in the response
$context->response->setContent($content);
}
$context->response->setContentType($view->mimetype);
return $context->response->getContent();
}
示例6: __construct
public function __construct(KConfig $config)
{
//show only enabled posts in the posts view
if (KInflector::isPlural(KRequest::get('get.view', 'string'))) {
$config->request->enabled = 1;
}
parent::__construct($config);
}
示例7: display
public function display()
{
$name = $this->getName();
//Append enable and disbale button for all the list views
if ($name != 'dashboard' && KInflector::isPlural($name) && KRequest::type() != 'AJAX') {
KFactory::get('admin::com.error.toolbar.' . $name)->append('divider')->append('enable')->append('disable');
}
return parent::display();
}
示例8: _commandEdit
/**
* Edit Command for an entity
*
* @param LibBaseTemplateObject $command The action object
*
* @return void
*/
protected function _commandEdit($command)
{
$entity = $this->getController()->getItem();
$view = $this->getController()->getView()->getName();
$layout = pick($command->layout, 'edit');
$command->append(array('label' => JText::_('LIB-AN-ACTION-EDIT')))->href($entity->getURL() . '&layout=' . $layout);
if (KInflector::isPlural($view)) {
$command->setAttribute('data-action', 'edit');
}
}
示例9: setView
/**
* Sets the default view to the comment views.
*
* @param stirng $view
*
* @return ComBaseControllerComment
*/
public function setView($view)
{
parent::setView($view);
if (!$this->_view instanceof LibBaseViewAbstract) {
$view = KInflector::isPlural($view) ? 'comments' : 'comment';
$defaults[] = 'ComBaseView' . ucfirst($view) . ucfirst($this->_view->name);
register_default(array('identifier' => $this->_view, 'default' => $defaults));
}
return $this;
}
示例10: display
public function display()
{
$name = $this->getName();
$toolbar = KFactory::get($this->getToolbar());
$toolbar->setTitle('Jedi: ' . KInflector::humanize($this->getName()));
//Apend enable and disbale button for all the list views
if (KInflector::isPlural($name)) {
$toolbar->append('divider')->append('enable')->append('disable');
}
return parent::display();
}
示例11: display
public function display()
{
$model = $this->getModel();
if (KInflector::isPlural($this->getName())) {
$data = array('settings' => $model->getList()->toArray());
} else {
$data = $model->getItem()->toArray();
}
$this->output = $data;
return parent::display();
}
示例12: display
/**
* Return the views output
*
* If the view 'output' variable is empty the output will be generated based on
* the model data, if it set it will be returned instead.
*
* @return string The output of the view
*/
public function display()
{
if (empty($this->output)) {
$model = $this->getModel();
if (KInflector::isPlural($this->getName())) {
$data = $model->getList();
} else {
$data = $model->getItem();
}
$this->output = json_encode($data->toArray());
}
return parent::display();
}
示例13: _actionRender
/**
* Draw the toolbar
*
* @param KCommandContext $context The command context
*
* @return string
*/
protected function _actionRender(KCommandContext $context)
{
if ($context->result !== false) {
$view = $this->getController()->getView();
//Set the document mimetype
JFactory::getDocument()->setMimeEncoding($view->mimetype);
//Disabled the application menubar
if (!KInflector::isPlural($view->getName()) && !KRequest::has('get.hidemainmenu')) {
KRequest::set('get.hidemainmenu', 1);
}
}
return parent::_actionRender($context);
}
示例14: __construct
/**
* Constructor
*
* @param object An optional KConfig object with configuration options
*/
public function __construct(KConfig $config)
{
parent::__construct($config);
$app = $this->_identifier->application;
$package = $this->_identifier->package;
$name = $this->_identifier->name;
if (KInflector::isPlural($name)) {
//Create the toolbar
$this->append('new')->append('delete');
} else {
// Create the toolbar
$this->append('save')->append('apply')->append('cancel');
}
}
示例15: display
public function display()
{
$model = $this->getModel();
if(KInflector::isPlural($this->getName())) {
$data = $this->_getList($model);
} else {
$data = $this->_getItem($model);
}
$this->output = $data;
return parent::display();
}