本文整理汇总了PHP中CategoryModel::getDisplayAsOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::getDisplayAsOptions方法的具体用法?PHP CategoryModel::getDisplayAsOptions怎么用?PHP CategoryModel::getDisplayAsOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CategoryModel
的用法示例。
在下文中一共展示了CategoryModel::getDisplayAsOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeCategoryOptions
/**
*
*
* @param array $category
*/
function writeCategoryOptions($category)
{
$cdd = new DropdownModule('', '', 'dropdown-category-options', 'dropdown-menu-right');
$cdd->setTrigger(displayAsSymbol($category['DisplayAs']), 'button', 'btn');
$cdd->setView('dropdown-twbs');
$cdd->setForceDivider(true);
$cdd->addGroup('', 'edit')->addLink(t('View'), $category['Url'], 'edit.view')->addLink(t('Edit'), "/vanilla/settings/editcategory?categoryid={$category['CategoryID']}", 'edit.edit');
$cdd->addGroup(t('Display as'), 'displayas');
foreach (CategoryModel::getDisplayAsOptions() as $displayAs => $label) {
$cssClass = strcasecmp($displayAs, $category['DisplayAs']) === 0 ? 'selected' : '';
$icon = displayAsSymbol($displayAs);
$cdd->addLink(t($label), '#', 'displayas.' . strtolower($displayAs), 'js-displayas ' . $cssClass, [], ['icon' => $icon, 'attributes' => ['data-displayas' => strtolower($displayAs)]], false);
}
$cdd->addGroup('', 'actions')->addLink(t('Add Subcategory'), "/vanilla/settings/addcategory?parent={$category['CategoryID']}", 'actions.add');
$cdd->addGroup('', 'delete')->addLink(t('Delete'), "/vanilla/settings/deletecategory?categoryid={$category['CategoryID']}", 'delete.delete', 'js-modal');
echo $cdd->toString();
}
示例2: addCategory
/**
* Adding a new category.
*
* @since 2.0.0
* @access public
*/
public function addCategory($parent = '')
{
// Check permission
$this->permission(['Garden.Community.Manage', 'Garden.Settings.Manage'], false);
// Set up head
$this->addJsFile('jquery.alphanumeric.js');
$this->addJsFile('manage-categories.js');
$this->addJsFile('jquery.gardencheckboxgrid.js');
$this->title(t('Add Category'));
$this->setHighlightRoute('vanilla/settings/categories');
// Prep models
$RoleModel = new RoleModel();
$PermissionModel = Gdn::permissionModel();
$this->Form->setModel($this->CategoryModel);
// Load all roles with editable permissions.
$this->RoleArray = $RoleModel->getArray();
$this->fireAs('SettingsController');
$this->fireEvent('AddEditCategory');
$this->setupDiscussionTypes(array());
$displayAsOptions = CategoryModel::getDisplayAsOptions();
if ($this->Form->authenticatedPostBack()) {
// Form was validly submitted
$IsParent = $this->Form->getFormValue('IsParent', '0');
$this->Form->setFormValue('AllowDiscussions', $IsParent == '1' ? '0' : '1');
$this->Form->setFormValue('CustomPoints', (bool) $this->Form->getFormValue('CustomPoints'));
// Enforces tinyint values on boolean fields to comply with strict mode
$this->Form->setFormValue('HideAllDiscussions', forceBool($this->Form->getFormValue('HideAllDiscussions'), '0', '1', '0'));
$this->Form->setFormValue('Archived', forceBool($this->Form->getFormValue('Archived'), '0', '1', '0'));
$this->Form->setFormValue('AllowFileUploads', forceBool($this->Form->getFormValue('AllowFileUploads'), '0', '1', '0'));
$upload = new Gdn_Upload();
$tmpImage = $upload->validateUpload('PhotoUpload', false);
if ($tmpImage) {
// Generate the target image name
$targetImage = $upload->generateTargetName(PATH_UPLOADS);
$imageBaseName = pathinfo($targetImage, PATHINFO_BASENAME);
// Save the uploaded image
$parts = $upload->saveAs($tmpImage, $imageBaseName);
$this->Form->setFormValue('Photo', $parts['SaveName']);
}
$CategoryID = $this->Form->save();
if ($CategoryID) {
$Category = CategoryModel::categories($CategoryID);
$this->setData('Category', $Category);
if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
redirect('vanilla/settings/categories');
} elseif ($this->deliveryType() === DELIVERY_TYPE_DATA && method_exists($this, 'getCategory')) {
$this->Data = [];
$this->getCategory($CategoryID);
return;
}
} else {
unset($CategoryID);
}
} else {
if ($parent) {
$category = CategoryModel::categories($parent);
if ($category) {
$this->Form->setValue('ParentCategoryID', $category['CategoryID']);
if (val('DisplayAs', $category) === 'Flat') {
unset($displayAsOptions['Heading']);
}
}
}
$this->Form->addHidden('CodeIsDefined', '0');
}
// Get all of the currently selected role/permission combinations for this junction.
$Permissions = $PermissionModel->getJunctionPermissions(array('JunctionID' => isset($CategoryID) ? $CategoryID : 0), 'Category');
$Permissions = $PermissionModel->unpivotPermissions($Permissions, true);
if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
$this->setData('PermissionData', $Permissions, true);
}
$this->setData('Operation', 'Add');
$this->setData('DisplayAsOptions', $displayAsOptions);
$this->render('editcategory', 'vanillasettings', 'vanilla');
}