本文整理汇总了PHP中Category::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getName方法的具体用法?PHP Category::getName怎么用?PHP Category::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Delete category
*
* @param void
* @return null
*/
function delete_category()
{
if ($this->active_category->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if ($this->request->isSubmitted()) {
$delete = $this->active_category->delete();
if ($delete && !is_error($delete)) {
if ($this->request->getFormat() == FORMAT_HTML) {
flash_success('Category :category_name has been deleted', array('category_name' => $this->active_category->getName()));
$this->redirectToUrl($this->smarty->get_template_vars('categories_url'));
} else {
$this->serveData($this->active_category, 'category');
}
// if
} else {
if ($this->request->getFormat() == FORMAT_HTML) {
flash_error('Failed to delete :category_name', array('category_name' => $this->active_category->getName()));
$this->redirectToUrl($this->smarty->get_template_vars('categories_url'));
} else {
$this->serveData($delete);
}
// if
}
// if
} else {
$this->httpError(HTTP_ERR_BAD_REQUEST);
}
// if
}
示例2: Category
function test_getName()
{
$name = "Work stuff";
$test_Category = new Category($name);
$result = $test_Category->getName();
$this->assertEquals($name, $result);
}
示例3: index
public function index()
{
$type = Param::get('type', self::TYPE_THREAD);
$query = trim_collapse(Param::get('query'));
$page = Param::get('page', 1);
$pagination = new SimplePagination($page, self::RESULTS_PERPAGE);
if (!$query) {
redirect(APP_URL);
}
$results = new stdClass();
switch ($type) {
case self::TYPE_THREAD:
$results = Thread::search($query, $pagination->start_index - 1, $pagination->count + 1);
// Get other info for each thread
foreach ($results->result as $thread) {
$thread->creator = User::getByID($thread->user_id);
$thread->category = Category::getName($thread->category_id);
$thread->replies_count = Comment::countAll($thread->id);
}
break;
case self::TYPE_COMMENT:
$results = Comment::search($query, $pagination->start_index - 1, $pagination->count + 1);
break;
case self::TYPE_USER:
$results = User::search($query, $pagination->start_index - 1, $pagination->count + 1);
break;
default:
throw new PageNotFoundException();
break;
}
$pagination->checkLastPage($results->result);
$pages = ceil($results->total_result / self::RESULTS_PERPAGE);
$title = "Search: '{$query}'";
$this->set(get_defined_vars());
}
示例4: getAllCategoriesFromDatabase
public static function getAllCategoriesFromDatabase($dbConn)
{
$categoryIds = readFromDatabase::readEntireColumnFromTable($dbConn, array(self::ID_COLUMN_NAME), self::TABLE_NAME);
$categories = array();
foreach ($categoryIds as $categoryId) {
$category = new Category($dbConn, $categoryId[self::ID_COLUMN_NAME]);
$categories[$category->getId()] = $category->getName();
}
return $categories;
}
示例5: modify
protected function modify(Category $category)
{
$q = $this->dao->prepare('UPDATE ' . $this->table() . ' SET NAME = :name, DESCRIPTION = :description, PARENT_CATEGORY_ID = :parentCategoryId, IS_ROOT = :isRoot WHERE ID = :id');
$q->bindValue(':name', $category->getName());
$q->bindValue(':description', $category->getDescription());
$q->bindValue(':parentCategoryId', $category->getParentCategoryId());
$q->bindValue(':isRoot', $category->getIsRoot());
$q->bindValue(':id', $category->id(), PDO::PARAM_INT);
$q->execute();
}
示例6: Category
function action_category()
{
if (isset($_GET['id']) && $_GET['id'] > 0) {
$id = DB::esc(intval($_GET['id']));
$category = new Category($id, $this->model);
$this->view->setData(array("category" => $category));
$this->view->setTitle($category->getName());
$this->view->display('category_view.php');
} else {
$this->action_404();
}
}
示例7: edit
public function edit(User $currentUser, Category $category)
{
$id = intval($category->getId());
$name = $this->database->quote($category->getName());
$description = $this->database->quote($category->getDescription());
$query = "UPDATE category SET name = '" . $name . "', description = '" . $description . "' WHERE id = " . $id;
$result = $this->database->exec($query);
if ($result) {
return true;
} else {
throw new Exception("Catastrophe base de données.");
}
}
示例8: testUpdate
function testUpdate()
{
//Arrange
$name = "Work stuff";
$id = 1;
$test_category = new Category($name, $id);
$test_category->save();
$new_name = "Home stuff";
//Act
$test_category->update($new_name);
//Assert
$this->assertEquals("Home stuff", $test_category->getName());
}
示例9: getItemsCollection
/**
* @param Category $category
* @return WikiaMobileCategoryViewer
*/
public function getItemsCollection(Category $category)
{
$this->wf->profileIn(__METHOD__);
$cacheKey = $this->getItemsCollectionCacheKey($category->getName());
$contents = $this->wg->memc->get($cacheKey);
if (empty($contents)) {
/**
* @var $wikiaMobileCategoryViewer WikiaMobileCategoryViewer
*/
$wikiaMobileCategoryViewer = F::build('WikiaMobileCategoryViewer', array($category));
$contents = $wikiaMobileCategoryViewer->getContents();
$this->wg->memc->set($cacheKey, $contents, self::CACHE_TTL_ITEMSCOLLECTION);
}
$this->wf->profileOut(__METHOD__);
return $contents;
}
示例10: getCategoryArray
protected function getCategoryArray($id_product)
{
/*
$controlFraude = new TPProductoControlFraude($id_product);
return $controlFraude->codigo_producto;
*/
$controlFraude = new Product($id_product);
$categories = $controlFraude->getDefaultCategory();
$category_id = $categories[0];
$category = new Category($category_id);
$name = $category->getName();
if (empty($name)) {
return "default";
}
return $name;
}
示例11: create
public function create($name, $description, $img)
{
$category = new Category($this->db);
$errors = array();
try {
$category->setName($name);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
try {
$category->setDescription($description);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
try {
$category->setImg($img);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) == 0) {
$name = $this->db->quote($category->getName());
$description = $this->db->quote($category->getDescription());
$img = $this->db->quote($category->getImg());
$query = "INSERT INTO category (name, description, img) VALUES(" . $name . "," . $description . "," . $img . ")";
$res = $this->db->exec($query);
if ($res) {
$id = $this->db->lastInsertId();
if ($id) {
return $this->findById($id);
} else {
$errors[] = "Category not found";
return $errors;
}
} else {
$errors[] = "Internal server error";
return $errors;
}
} else {
return $errors;
}
}
示例12: findAllCategories
static function findAllCategories()
{
$default_category = new Category('default');
$categories = array();
foreach (Project::findAllProjects() as $project) {
if ($name = $project->getCategory()) {
if (!isset($categories[$name])) {
$category = new Category($name);
$categories[$name] = $category;
} else {
$category = $categories[$name];
}
} else {
$categories[$default_category->getName()] = $default_category;
$category = $default_category;
}
$category->addProject($project);
}
ksort($categories);
return array_values($categories);
}
示例13: index
public function index()
{
$page = Param::get('page', 1);
$filter = Param::get('filter');
// pagination
$pagination = new SimplePagination($page, self::THREADS_PERPAGE);
$threads = Thread::getAll($pagination->start_index - 1, $pagination->count + 1, $filter);
$pagination->checkLastPage($threads);
$total = Thread::countAll($filter);
$pages = ceil($total / self::THREADS_PERPAGE);
// Get other info for each thread
foreach ($threads as $thread) {
$thread->creator = User::getByID($thread->user_id);
$thread->category = Category::getName($thread->category_id);
$thread->replies_count = Comment::countAll($thread->id);
}
// get other variables needed by the view
$title = 'All Threads';
$auth_user = User::getAuthenticated();
$categories = Category::getAll();
$trending = Thread::getTrending(self::TRENDING_LIMIT);
$this->set(get_defined_vars());
}
示例14: itemExportCategories
protected function itemExportCategories($row, $product)
{
// Url in 1.5.2.0 wrong (thickbox_default)
//Categories
$category = new Category($product->id_category_default);
$row['categories'] = $category->getName($this->id_lang);
return $row;
}
示例15: select
$t->is(count($category), 0, 'findOne() called after select(array) returns an empty array if no record is found');
$category1 = new Category();
$category1->setName('cat1');
$category1->save();
$category2 = new Category();
$category2->setName('cat2');
$category2->save();
$finder = sfPropelFinder::from('Category')->
select(array('Id','Name'), sfModelFinder::ASSOCIATIVE);
$category = $finder->findOne();
$t->isa_ok($category, 'array', 'The row returned by findOne() called after select(array) is an array');
$t->is_deeply(array_keys($category), array('Id', 'Name'), 'The row returned by findOne() called after select(array, sfModelFinder::ASSOCIATIVE) is an associative array where the keys are the requested column names');
$t->is($category['Id'], $category1->getId(), 'The row returned by findOne() called after select(array, sfModelFinder::ASSOCIATIVE) is an associative array where the values are the requested column values');
$t->is($category['Name'], $category1->getName(), 'The row returned by findOne() called after select(array, sfModelFinder::ASSOCIATIVE) is an associative array where the values are the requested column values');
$finder = sfPropelFinder::from('Category')->
select(array('Id','Name'), sfModelFinder::SIMPLE);
$category = $finder->findOne();
$t->is_deeply(array_keys($category), array(0, 1), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array with numeric keys');
$t->is($category[0], $category1->getId(), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array where the values are the requested column values');
$t->is($category[1], $category1->getName(), 'The row returned by findOne() called after select(array, sfModelFinder::SIMPLE) is an array where the values are the requested column values');
/*********************************************/
/* sfPropelFinder::select() and withColumn() */
/*********************************************/
$t->diag('sfPropelFinder::select() and withColumn()');
ArticlePeer::doDeleteAll();