本文整理汇总了PHP中ItemList::display方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemList::display方法的具体用法?PHP ItemList::display怎么用?PHP ItemList::display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::display方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: availablePlugins
/**
* Display the list of available plugins on the file system
*/
public function availablePlugins()
{
$plugins = Plugin::getAll(false, true);
$api = new HawkApi();
try {
$updates = $api->getPluginsAvailableUpdates(array_map(function ($plugin) {
return $plugin->getDefinition('version');
}, $plugins));
} catch (\Hawk\HawkApiException $e) {
$updates = array();
}
$list = new ItemList(array('id' => 'available-plugins-list', 'reference' => 'name', 'action' => App::router()->getUri('plugins-list'), 'data' => $plugins, 'controls' => array(array('icon' => 'plus', 'class' => 'btn-success', 'label' => Lang::get($this->_plugin . '.new-plugin-btn'), 'href' => App::router()->getUri('create-plugin'), 'target' => 'dialog')), 'fields' => array('controls' => array('display' => function ($value, $field, $plugin) use($updates) {
$buttons = array();
$installer = $plugin->getInstallerInstance();
if (!$plugin->isInstalled()) {
// the plugin is not installed
$buttons = array(ButtonInput::create(array('title' => Lang::get($this->_plugin . '.install-plugin-button'), 'icon' => 'upload', 'class' => 'install-plugin', 'href' => App::router()->getUri('install-plugin', array('plugin' => $plugin->getName())))), !$plugin->isMandatoryDependency() ? ButtonInput::create(array('title' => Lang::get($this->_plugin . '.delete-plugin-button'), 'icon' => 'trash', 'class' => 'btn-danger delete-plugin', 'href' => App::router()->getUri('delete-plugin', array('plugin' => $plugin->getName())))) : '');
$status = Lang::get($this->_plugin . '.plugin-uninstalled-status');
} else {
if (!$plugin->isActive()) {
// The plugin is installed but not activated
$buttons = array(ButtonInput::create(array('title' => Lang::get($this->_plugin . '.activate-plugin-button'), 'class' => 'btn-success activate-plugin', 'icon' => 'check', 'href' => App::router()->getUri('activate-plugin', array('plugin' => $plugin->getName())))), method_exists($installer, 'settings') ? ButtonInput::create(array('icon' => 'cogs', 'title' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info')) : '', !$plugin->isMandatoryDependency() ? ButtonInput::create(array('title' => Lang::get($this->_plugin . '.uninstall-plugin-button'), 'class' => 'btn-danger uninstall-plugin', 'icon' => 'chain-broken', 'href' => App::router()->getUri('uninstall-plugin', array('plugin' => $plugin->getName())))) : '');
$status = Lang::get($this->_plugin . '.plugin-inactive-status');
} else {
// The plugin is installed and active
$buttons = array(method_exists($installer, 'settings') ? ButtonInput::create(array('icon' => 'cogs', 'title' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info')) : '', ButtonInput::create(array('title' => Lang::get($this->_plugin . '.deactivate-plugin-button'), 'class' => 'btn-warning deactivate-plugin', 'icon' => 'ban', 'href' => App::router()->getUri('deactivate-plugin', array('plugin' => $plugin->getName())))));
$status = Lang::get($this->_plugin . '.plugin-active-status');
}
}
if (isset($updates[$plugin->getName()])) {
array_unshift($buttons, ButtonInput::create(array('icon' => 'refresh', 'class' => 'btn-info update-plugin', 'title' => Lang::get($this->_plugin . '.update-plugin-button'), 'href' => App::router()->getUri('update-plugin', array('plugin' => $plugin->getName())))));
}
return View::make(Plugin::current()->getView('plugin-list-controls.tpl'), array('plugin' => $plugin, 'status' => $status, 'buttons' => $buttons));
}, 'label' => Lang::get($this->_plugin . '.plugins-list-controls-label'), 'search' => false, 'sort' => false), 'description' => array('search' => false, 'sort' => false, 'label' => Lang::get($this->_plugin . '.plugins-list-description-label'), 'display' => function ($value, $field, $plugin) {
return View::make(Plugin::current()->getView("plugin-list-description.tpl"), $plugin->getDefinition());
}))));
return $list->display();
}
示例2: search
/**
* Search themes on the remote platform
*/
public function search()
{
$api = new HawkApi();
$search = App::request()->getParams('search');
// Search themes on the API
try {
$themes = $api->searchThemes($search);
} catch (\Hawk\HawkApiException $e) {
$themes = array();
}
// Remove the plugins already downloaded on the application
foreach ($themes as &$theme) {
$installed = Theme::get($theme['name']);
$theme['installed'] = $installed !== null;
if ($installed) {
$theme['currentVersion'] = $installed->getDefinition('version');
}
}
$list = new ItemList(array('id' => 'search-themes-list', 'data' => $themes, 'resultTpl' => Plugin::current()->getView('theme-search-list.tpl'), 'fields' => array()));
if ($list->isRefreshing()) {
return $list->display();
} else {
$this->addCss(Plugin::current()->getCssUrl('themes.less'));
$this->addJavaScript(Plugin::current()->getJsUrl('themes.js'));
return LeftSidebarTab::make(array('page' => array('content' => $list->display()), 'sidebar' => array('widgets' => array(new SearchThemeWidget())), 'icon' => 'picture-o', 'title' => Lang::get($this->_plugin . '.search-theme-result-title', array('search' => $search))));
}
}
示例3: listQuestions
/**
* Display the list of the profile questions
*/
public function listQuestions()
{
// Get all ProfileQuestions
$questions = ProfileQuestion::getAll();
// Get all Roles
$roles = Role::getAll();
// Create parameters for form
$param = array('id' => 'display-questions-form', 'action' => App::router()->getUri('profile-questions'), 'fieldsets' => array('form' => array(), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new ButtonInput(array('name' => 'new-question', 'value' => Lang::get($this->_plugin . '.new-question-btn'), 'class' => 'btn-success', 'href' => App::router()->getUri('edit-profile-question', array('name' => '_new')), 'target' => 'dialog', 'icon' => 'plus')))));
// For each ProfileQuestion add roles, displayInRegister and displayInProfile
foreach ($questions as $question) {
// Add the input to display in register form
$param['fieldsets']['form'][] = new CheckboxInput(array('name' => "register-display-{$question->name}", 'default' => $question->displayInRegister, 'nl' => false));
// Add the input to display in the user profile
$param['fieldsets']['form'][] = new CheckboxInput(array('name' => "profile-display-{$question->name}", 'default' => $question->displayInProfile, 'nl' => false));
// Get roles associate to this ProfileQuestion in json parameters
$attributesRoles = ProfileQuestion::getByName($question->name)->getRoles();
// For each roles create a Checkbox
foreach ($roles as $role) {
// Add the input to display in the user profile
$param['fieldsets']['form'][] = new CheckboxInput(array('name' => "role-{$role->name}-question-{$question->name}", 'default' => in_array($role->id, $attributesRoles) ? 1 : 0, 'nl' => false));
}
}
// Create form
$form = new Form($param);
// Create parameters for the list to display
$paramList = array('id' => 'profile-questions-list', 'model' => 'ProfileQuestion', 'action' => App::router()->getUri('profile-questions'), 'lines' => 'all', 'navigation' => false, 'sort' => array('order' => DB::SORT_ASC), 'fields' => array('name' => array('hidden' => true), 'editable' => array('hidden' => true), 'actions' => array('independant' => true, 'display' => function ($value, $field, $line) {
if ($line->editable) {
return Icon::make(array('icon' => 'pencil', 'class' => 'text-info', 'href' => App::router()->getUri('edit-profile-question', array('name' => $line->name)), 'target' => 'dialog', 'title' => Lang::get($this->_plugin . '.edit-profile-question'))) . Icon::make(array('icon' => 'times', 'class' => 'text-danger delete-question', 'data-question' => $line->name, 'title' => Lang::get($this->_plugin . '.delete-profile-question')));
} else {
return '';
}
}, 'sort' => false, 'search' => false), 'label' => array('independant' => true, 'display' => function ($value, $field, $line) {
return Lang::get($this->_plugin . ".profile-question-{$line->name}-label") . " ( {$line->name} )";
}, 'sort' => false, 'search' => false), 'displayInRegister' => array('label' => Lang::get($this->_plugin . ".list-questions-register-visible-label"), 'sort' => false, 'search' => false, 'display' => function ($value, $field, $line) use($form) {
return $form->inputs["register-display-{$line->name}"];
}), 'displayInProfile' => array('label' => Lang::get($this->_plugin . '.list-questions-profile-visible-label'), 'sort' => false, 'search' => false, 'display' => function ($value, $field, $line) use($form) {
return $form->inputs["profile-display-{$line->name}"];
})));
// For each roles create a checkbox by line profileQuestion!
foreach ($roles as $role) {
// Add the input to display in register form
$paramList['fields'][$role->name] = array('independant' => true, 'label' => Lang::get("roles.role-{$role->id}-label"), 'search' => false, 'sort' => false, 'display' => function ($value, $field, $line) use($form) {
return $form->inputs["role-{$field->name}-question-{$line->name}"];
});
}
// Create List
$list = new ItemList($paramList);
if (!$form->submitted()) {
if ($list->isRefreshing()) {
return $list->display();
}
$this->addKeysToJavaScript($this->_plugin . ".confirm-delete-question");
$content = View::make(Plugin::current()->getView("questions-list.tpl"), array('list' => $list, 'form' => $form));
return $form->wrap($content);
}
// Extract from form, all infos abour roles associate to ProfileQuestion
$listRoles = array();
$roles = Role::getAll('name');
$save = array();
foreach ($form->inputs as $name => $field) {
// Manage displayInRegister and displayInProfile
if (preg_match("/^(register|profile)\\-display\\-(\\w+)\$/", $name, $match)) {
$qname = $match[2];
$func = $match[1] == "register" ? 'displayInRegister' : 'displayInProfile';
if (!isset($save[$qname])) {
$save[$qname] = new ProfileQuestion();
$save[$qname]->set('name', $qname);
}
$save[$qname]->set($func, (int) App::request()->getBody($name));
} else {
if (preg_match("/^role\\-(\\w+)\\-question\\-(\\w+)\$/", $name, $match)) {
$qname = $match[2];
$roleName = $match[1];
// If tab doesn't exit create it to avoid exception
if (!isset($listRoles[$qname])) {
$listRoles[$qname] = array();
}
$role = $roles[$roleName];
// If checkbox is tag, add roleId
if ($field->dbvalue()) {
array_push($listRoles[$qname], intval($role->id));
}
}
}
}
foreach ($save as $question) {
$question->update();
}
// Save each ProfileQuestions
foreach ($questions as $question) {
$params = json_decode($question->parameters, true);
$params['roles'] = $listRoles[$question->name];
$question->set('parameters', json_encode($params));
$question->update();
}
return $form->response(Form::STATUS_SUCCESS);
}
示例4: listUsers
/**
* Display the list of the users
*/
public function listUsers()
{
$example = array('id' => array('$ne' => User::GUEST_USER_ID));
$filters = UserFilterWidget::getInstance()->getFilters();
if (isset($filters['status']) && $filters['status'] != -1) {
$example['active'] = $filters['status'];
}
$param = array('id' => 'admin-users-list', 'model' => 'User', 'action' => App::router()->getUri('list-users'), 'reference' => 'id', 'filter' => new DBExample($example), 'controls' => array(array('icon' => 'plus', 'label' => Lang::get($this->_plugin . '.new-user-btn'), 'class' => 'btn-success', 'href' => App::router()->getUri("edit-user", array('username' => '_new')), 'target' => 'dialog')), 'fields' => array('actions' => array('independant' => true, 'display' => function ($value, $field, $user) {
$return = Icon::make(array('icon' => 'pencil', 'class' => 'text-primary', 'href' => App::router()->getUri('edit-user', array('username' => $user->username)), 'target' => 'dialog'));
if ($user->isRemovable()) {
$return .= Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-user', 'data-user' => $user->username));
$return .= $user->active ? Icon::make(array('icon' => 'lock', 'class' => 'text-warning lock-user', 'data-user' => $user->username)) : Icon::make(array('icon' => 'unlock', 'class' => 'text-success unlock-user', 'data-user' => $user->username));
}
return $return;
}, 'search' => false, 'sort' => false), 'username' => array('label' => Lang::get($this->_plugin . '.users-list-username-label')), 'email' => array('label' => Lang::get($this->_plugin . '.users-list-email-label')), 'roleId' => array('label' => Lang::get($this->_plugin . '.users-list-roleId-label'), 'sort' => false, 'search' => array('type' => 'select', 'options' => call_user_func(function () {
$options = array();
foreach (Role::getAll('id', array('id')) as $id => $role) {
$options[$id] = Lang::get('roles.role-' . $id . '-label');
}
return $options;
}), 'invitation' => Lang::get($this->_plugin . '.user-filter-status-all')), 'display' => function ($value) {
return Lang::get('roles.role-' . $value . '-label');
}), 'active' => array('label' => Lang::get($this->_plugin . '.users-list-active-label'), 'search' => false, 'sort' => false, 'class' => function ($value) {
return 'bold ' . ($value ? 'text-success' : 'text-danger');
}, 'display' => function ($value) {
return $value ? Lang::get($this->_plugin . '.users-list-active') : Lang::get($this->_plugin . '.users-list-inactive');
}), 'createTime' => array('label' => Lang::get($this->_plugin . '.users-list-createTime-label'), 'search' => false, 'display' => function ($value) {
return date(Lang::get('main.date-format'), $value);
})));
$list = new ItemList($param);
if (App::request()->getParams('refresh')) {
return $list->display();
} else {
$this->addKeysToJavaScript("admin.user-delete-confirmation");
return View::make(Plugin::current()->getView("users-list.tpl"), array('list' => $list));
}
}