本文整理汇总了PHP中PMF_Category::addCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Category::addCategory方法的具体用法?PHP PMF_Category::addCategory怎么用?PHP PMF_Category::addCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Category
的用法示例。
在下文中一共展示了PMF_Category::addCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$category->setGroups($currentAdminGroups);
$parentId = PMF_Filter::filterInput(INPUT_POST, 'parent_id', FILTER_VALIDATE_INT);
$categoryData = array('id' => PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT), 'lang' => PMF_Filter::filterInput(INPUT_POST, 'catlang', FILTER_SANITIZE_STRING), 'parent_id' => $parentId, 'name' => PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING), 'description' => PMF_Filter::filterInput(INPUT_POST, 'description', FILTER_SANITIZE_STRING), 'user_id' => PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT));
$permissions = array();
if ('all' === PMF_Filter::filterInput(INPUT_POST, 'userpermission', FILTER_SANITIZE_STRING)) {
$permissions += array('restricted_user' => array(-1));
} else {
$permissions += array('restricted_user' => array(PMF_Filter::filterInput(INPUT_POST, 'restricted_users', FILTER_VALIDATE_INT)));
}
if ('all' === PMF_Filter::filterInput(INPUT_POST, 'grouppermission', FILTER_SANITIZE_STRING)) {
$permissions += array('restricted_groups' => array(-1));
} else {
$permissions += PMF_Filter::filterInputArray(INPUT_POST, array('restricted_groups' => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY)));
}
if (!$category->checkLanguage($categoryData['id'], $categoryData['lang'])) {
if ($category->addCategory($categoryData, $parentId, $categoryData['id']) && $category->addPermission('user', array($categoryData['id']), $permissions['restricted_user']) && $category->addPermission('group', array($categoryData['id']), $permissions['restricted_groups'])) {
printf('<p class="alert alert-success">%s</p>', $PMF_LANG['ad_categ_translated']);
} else {
printf('<p class="alert alert-error">%s</p>', $faqConfig->getDb()->error());
}
} else {
if ($category->updateCategory($categoryData)) {
$category->deletePermission('user', array($categoryData['id']));
$category->deletePermission('group', array($categoryData['id']));
$category->addPermission('user', array($categoryData['id']), $permissions['restricted_user']);
$category->addPermission('group', array($categoryData['id']), $permissions['restricted_groups']);
printf('<p class="alert alert-success">%s</p>', $PMF_LANG['ad_categ_updated']);
} else {
printf('<p class="alert alert-error">%s</p>', $faqConfig->getDb()->error());
}
}
示例2: array
<?php
if ($permission['editcateg']) {
$category = new PMF_Category($faqConfig, array(), false);
$category->setUser($currentAdminUser);
$category->setGroups($currentAdminGroups);
$currentLink = $_SERVER['SCRIPT_NAME'];
$currentLanguage = $languageCodes[strtoupper($LANGCODE)];
$all_languages = array();
$all_lang = array();
$showcat = PMF_Filter::filterInput(INPUT_POST, 'showcat', FILTER_SANITIZE_STRING);
// translate an existing category
if (!is_null($showcat) && $showcat == 'yes') {
$parent_id = PMF_Filter::filterInput(INPUT_POST, 'parent_id', FILTER_VALIDATE_INT);
$category_data = array('id' => PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT), 'lang' => PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING), 'parent_id' => $parent_id, 'name' => PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING), 'description' => PMF_Filter::filterInput(INPUT_POST, 'description', FILTER_SANITIZE_STRING), 'user_id' => PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT));
// translate.category only returns non-existent languages to translate too
if ($category->addCategory($category_data, $parent_id, $category_data['id'])) {
printf('<p class="alert alert-success">%s</p>', $PMF_LANG['ad_categ_translated']);
} else {
printf('<p class="alert alert-error">%s</p>', $faqConfig->getDb()->error());
}
}
$category->getMissingCategories();
$category->buildTree();
?>
<table class="table table-striped">
<thead>
<tr>
<th><?php
print $currentLanguage;
?>
</th>
示例3: printf
printf('<p class="success">%s</p>', $PMF_LANG['ad_categ_added']);
} else {
printf('<p class="error">%s</p>', $db->error());
}
}
// Updates an existing category
if ($action == 'updatecategory') {
$category = new PMF_Category($current_admin_user, $current_admin_groups, false);
$parent_id = PMF_Filter::filterInput(INPUT_POST, 'parent_id', FILTER_VALIDATE_INT);
$category_data = array('id' => PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT), 'lang' => PMF_Filter::filterInput(INPUT_POST, 'catlang', FILTER_SANITIZE_STRING), 'parent_id' => $parent_id, 'name' => PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING), 'description' => PMF_Filter::filterInput(INPUT_POST, 'description', FILTER_SANITIZE_STRING), 'user_id' => PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT));
$userperm = PMF_Filter::filterInput(INPUT_POST, 'userpermission', FILTER_SANITIZE_STRING);
$user_allowed = 'all' == $userperm ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_users', FILTER_VALIDATE_INT);
$groupperm = PMF_Filter::filterInput(INPUT_POST, 'grouppermission', FILTER_SANITIZE_STRING);
$group_allowed = 'all' == $groupperm ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_groups', FILTER_VALIDATE_INT);
if (!$category->checkLanguage($category_data['id'], $category_data['lang'])) {
if ($category->addCategory($category_data, $parent_id, $category_data['id']) && $category->addPermission('user', array($category_data['id']), $user_allowed) && $category->addPermission('group', array($category_data['id']), $group_allowed)) {
printf('<p class="success">%s</p>', $PMF_LANG['ad_categ_translated']);
} else {
printf('<p class="error">%s</p>', $db->error());
}
} else {
if ($category->updateCategory($category_data)) {
$category->deletePermission('user', array($category_data['id']));
$category->deletePermission('group', array($category_data['id']));
$category->addPermission('user', array($category_data['id']), $user_allowed);
$category->addPermission('group', array($category_data['id']), $group_allowed);
printf('<p class="success">%s</p>', $PMF_LANG['ad_categ_updated']);
} else {
printf('<p class="error">%s</p>', $db->error());
}
}