• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Category类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Category的典型用法代码示例。如果您正苦于以下问题:PHP Category类的具体用法?PHP Category怎么用?PHP Category使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Category类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('product');
     $product_name = new Zend_Form_Element_Text('product_name');
     $product_name->setLabel('Product Name: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $id = new Zend_Form_Element_Hidden('id');
     $ProductIdExists = new Zend_Validate_Db_NoRecordExists(array('table' => 'products', 'field' => 'product_id'));
     $ProductIdExists->setMessage('This Product ID is already taken');
     $product_id = new Zend_Form_Element_Text('product_id');
     $product_id->setLabel('Product ID: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator($ProductIdExists)->addValidator('NotEmpty');
     $category = new Category();
     $categoriesList = $category->getCategoriesList();
     $category_id = new Zend_Form_Element_Select('category_id');
     $category_id->setLabel('Category: ')->addMultiOptions($categoriesList)->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $product_desc = new Zend_Form_Element_Text('product_desc');
     $product_desc->setLabel('Description ')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
     $product_img = new Zend_Form_Element_File('product_image');
     $product_img->setLabel('Upload an image:')->setDestination(PUBLIC_PATH . '/images');
     // ensure only 1 file
     $product_img->addValidator('Count', false, 1);
     // limit to 100K
     $product_img->addValidator('Size', false, 102400);
     // only JPEG, PNG, and GIFs
     $product_img->addValidator('Extension', false, 'jpg,png,gif');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton');
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->addElements(array($product_name, $product_id, $product_desc, $product_img, $id, $category_id, $submit));
 }
开发者ID:ashikkalavadiya,项目名称:zendapp,代码行数:30,代码来源:ProductForm.php


示例2: testNestedCategories

 public function testNestedCategories()
 {
     $category = new Category('Root');
     $child1 = $category->addChild('Child 1');
     $child2 = $child1->addChild('Child 2');
     $this->dm->persist($category);
     $this->dm->flush();
     $this->dm->clear();
     $category = $this->dm->find(__NAMESPACE__ . '\\Category', $category->getId());
     $this->assertNotNull($category);
     $category->setName('Root Changed');
     $children = $category->getChildren();
     $children[0]->setName('Child 1 Changed');
     $children[0]->getChild('Child 2')->setName('Child 2 Changed');
     $category->addChild('Child 2');
     $this->dm->flush();
     $this->dm->clear();
     $category = $this->dm->find(__NAMESPACE__ . '\\Category', $category->getId());
     $children = $category->getChildren();
     $this->assertEquals('Child 1 Changed', $children[0]->getName());
     $this->assertEquals('Child 2 Changed', $children[0]->getChild(0)->getName());
     $this->assertEquals('Root Changed', $category->getName());
     $this->assertEquals(2, count($category->getChildren()));
     $test = $this->dm->getDocumentCollection(__NAMESPACE__ . '\\Category')->findOne();
     $this->assertFalse(isset($test['children'][0]['children'][0]['children']));
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:26,代码来源:NestedDocumentsTest.php


示例3: OnPageLoad

    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete category: ' . $this->data_object->GetName()));
        if ($this->deleted) {
            ?>
			<p>The category has been deleted.</p>
			<p><a href="/yesnosorry/categorylist.php">View all categories</a></p>
			<?php 
        } else {
            if ($this->has_permission) {
                ?>
				<p>Deleting a category cannot be undone.</p>
				<ul>
					<li>Its competitions will not be listed in a category</li>
				</ul> 
					
				<p>Are you sure you want to delete this category?</p>
				<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteCategoryUrl());
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete category" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this category.</p>
				<p><a href="/yesnosorry/categorylist.php">Go back to the list of categories</a></p>
				<?php 
            }
        }
    }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:35,代码来源:categorydelete.php


示例4: action

 function action()
 {
     $category = new Category();
     $kdgs = new Kdgs();
     $album = new Album();
     $story_url = new StoryUrl();
     $category_list = $category->get_list("`res_name`='kdgs' and `s_id`='0'");
     foreach ($category_list as $k => $v) {
         $page = 1;
         while (true) {
             $album_list = $kdgs->get_children_category_album_list($v['s_p_id'], $page);
             if (!$album_list) {
                 break;
             }
             foreach ($album_list as $k2 => $v2) {
                 $exists = $album->check_exists("`link_url` = '{$v2['url']}'");
                 if ($exists) {
                     continue;
                 }
                 $album_id = $album->insert(array('title' => $v2['title'], 'min_age' => $v2['min_age'], 'max_age' => $v2['max_age'], 'intro' => '', 's_cover' => $v2['cover'], 'link_url' => $v2['url'], 'add_time' => date('Y-m-d H:i:s')));
                 $story_url->insert(array('res_name' => 'album', 'res_id' => $album_id, 'field_name' => 'cover', 'source_url' => $v2['cover'], 'source_file_name' => ltrim(strrchr($v2['cover'], '/'), '/'), 'add_time' => date('Y-m-d H:i:s')));
             }
             $page++;
         }
     }
 }
开发者ID:huqq1987,项目名称:clone-lemon,代码行数:26,代码来源:kdgs_album.php


示例5: Page

 function Page()
 {
     parent::BasePage();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents();
     $menu = new Menu();
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category();
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
开发者ID:ehsanguru,项目名称:nnplus,代码行数:33,代码来源:page.php


示例6: index

 function index()
 {
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'webboard_quizs' and parents <> 0")->order_by('orderlist', 'asc')->get_page();
     $data['categories']->webboard_quiz->order_by("id", "desc")->get();
     $this->template->build('webboard_index', $data);
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:7,代码来源:webboards.php


示例7: processPost

 function processPost($formvalues)
 {
     $session = SessionWrapper::getInstance();
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('parentid', $formvalues)) {
         unset($formvalues['parentid']);
     }
     if (isArrayKeyAnEmptyString('sectorid', $formvalues)) {
         unset($formvalues['sectorid']);
         if (!isEmptyString($formvalues['parentid'])) {
             $category = new Category();
             $category->populate($formvalues['parentid']);
             $formvalues['sectorid'] = $category->getSectorID();
         }
     }
     if (isArrayKeyAnEmptyString('level', $formvalues)) {
         unset($formvalues['level']);
     }
     if (isArrayKeyAnEmptyString('type', $formvalues)) {
         unset($formvalues['type']);
     }
     if (isArrayKeyAnEmptyString('status', $formvalues)) {
         unset($formvalues['status']);
     }
     if (isArrayKeyAnEmptyString('uneditable', $formvalues)) {
         unset($formvalues['uneditable']);
     }
     if (isArrayKeyAnEmptyString('sortorder', $formvalues)) {
         if (!isEmptyString($formvalues['parentid']) && !isEmptyString($formvalues['sectorid'])) {
             $formvalues['sortorder'] = $this->getNextSortOrder($formvalues['sectorid'], $formvalues['parentid']);
         }
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:35,代码来源:Category.php


示例8: load

 public function load(ObjectManager $manager)
 {
     $category = new Category();
     $category->setName("Category Name");
     $manager->persist($category);
     $manager->flush();
 }
开发者ID:codeedu,项目名称:zendexpr-doctrine-fixture,代码行数:7,代码来源:CategoryFixtureLoader.php


示例9: insertCategoryFormSucceeded

 public function insertCategoryFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $category = new Category($this->database);
     $category->setCategory($form->values->title, $form->values->parent_id);
     $redirectTo = $this->presenter->getName();
     $this->presenter->redirect(":" . $redirectTo . ":default", array("id" => $form->values->parent_id));
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:7,代码来源:AdminBarControl.php


示例10: widget_categories

 /**
  * Displays categories as a tree
  *
  * @param mixed $args
  *
  * This isn't a plugin hook, but a public function call created in the Sidebar plugin.
  */
 public function widget_categories($h)
 {
     $sql = "SELECT * FROM " . TABLE_CATEGORIES . " ORDER BY category_order ASC";
     $the_cats = $h->db->get_results($h->db->prepare($sql));
     require_once LIBS . 'Category.php';
     $catObj = new Category();
     echo "<h2 class='widget_head'>" . $h->lang["categories"] . "</h2>";
     echo "<div class='widget_body'>\n";
     echo "<ul class='categories_widget'>\n";
     foreach ($the_cats as $cat) {
         $cat_level = 1;
         // top level category.
         if ($cat->category_safe_name != "all") {
             echo "<li>";
             if ($cat->category_parent > 1) {
                 $depth = $catObj->getCatLevel($h, $cat->category_id, $cat_level, $the_cats);
                 for ($i = 1; $i < $depth; $i++) {
                     echo "--- ";
                 }
             }
             $category = stripslashes(html_entity_decode(urldecode($cat->category_name), ENT_QUOTES, 'UTF-8'));
             echo "<a href='" . $h->url(array('category' => $cat->category_id)) . "'>";
             echo $category . "</a></li>\n";
         }
     }
     echo "</ul></div>\n";
 }
开发者ID:shibuya246,项目名称:Hotaru-Plugins,代码行数:34,代码来源:categories_widget.php


示例11: postCategory

 public function postCategory()
 {
     $category = new Category();
     $category->name = Input::get('name');
     $category->save();
     return Response::json($category);
 }
开发者ID:saifurrahman,项目名称:dev,代码行数:7,代码来源:CategoryController.php


示例12: testCategory

 public function testCategory()
 {
     $category = new Category();
     $category->setDomain('http://do.main')->setTitle('News')->setDomain('https://www.example.com');
     $this->assertEquals('News', $category->getTitle());
     $this->assertEquals('https://www.example.com', $category->getDomain());
 }
开发者ID:marcw,项目名称:rss-writer,代码行数:7,代码来源:CategoryTest.php


示例13: store

 public function store()
 {
     $validator = Validator::make(Input::all(), Issue::$rules, Issue::$messages);
     //if($validator->passes()){
     $issue = new Issue();
     $issue->summary = Input::get('summary');
     $issue->detail = Input::get('detail');
     $issue->budget = 0.0;
     $issue->currentState = "TO-DO";
     $issue->points = Input::get('points');
     $issue->labels = Input::get('labels');
     $issue->iterationid = Input::get('iterationid');
     $categoryId = Input::get('categoryid');
     if ($categoryId == 0) {
         //crear categoria
         $category = new Category();
         $category->name = Input::get('category_name');
         $category->save();
         $issue->categoryid = $category->id;
     } else {
         $issue->categoryid = $categoryId;
     }
     $issue->save();
     return Redirect::to('/iterations/' . $issue->iterationid)->with('message', 'Historia creada con exito');
     /*}else{
     			return Redirect::to('iterations/'. Input::get('iterationid'))
     			->with('error', 'Ocurrieron los siguientes errores')
     			->withErrors($validator)
     			->withInput();
     		}*/
 }
开发者ID:josimarjimenez,项目名称:architects,代码行数:31,代码来源:IssueController.php


示例14: buildDomainObject

 /**
  * Creates an Article object based on a DB row.
  *
  * @param array $row The DB row containing Article data.
  * @return \GoodieSotre\Domain\Categorie
  */
 protected function buildDomainObject($row)
 {
     $category = new Category();
     $category->set_cat_id($row['cat_id']);
     $category->set_cat_name($row['cat_name']);
     return $category;
 }
开发者ID:a-lefe,项目名称:MyMovies,代码行数:13,代码来源:CategoryDAO.php


示例15: categories

 public function categories($option = 'all')
 {
     if (!($categories = Cache::read('receivable_categories_' . $this->key, 'expenses'))) {
         $category = new Category();
         $categories = $category->find('all', array('conditions' => array('or' => array('Category.user_id' => $this->Authorization->User->id(), 'Category.team_id' => $this->Authorization->User->Team->id()), 'Category.parent_id' => null, 'Category.type' => 'receivables'), 'order' => 'Category.order'));
         Cache::write('receivable_categories_' . $this->key, $categories, 'expenses');
     }
     switch ($option) {
         case 'list':
             $list = array();
             foreach ($categories as $category) {
                 $list[$category['Category']['name']] = array();
                 if (sizeof($category['ChildCategory'])) {
                     foreach ($category['ChildCategory'] as $cildCategory) {
                         $list[$category['Category']['name']][$cildCategory['id']] = $cildCategory['name'];
                     }
                 } else {
                     $list[$category['Category']['name']][$category['Category']['id']] = '&nbsp;' . $category['Category']['name'];
                 }
             }
             return $list;
             break;
         default:
             return $categories;
     }
 }
开发者ID:riverans,项目名称:manage-expenses,代码行数:26,代码来源:ReceivableComponent.php


示例16: renderContent

 public function renderContent($setting)
 {
     $t = array('list_type' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200');
     $products = array();
     $setting = array_merge($t, $setting);
     switch ($setting['list_type']) {
         case 'newest':
             $products = Product::getNewProducts($this->lang_id, 0, (int) $setting['limit']);
             break;
         case 'featured':
             $category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id);
             $nb = (int) $setting['limit'];
             $products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
             break;
         case 'bestseller':
             $products = ProductSale::getBestSalesLight((int) $this->lang_id, 0, (int) $setting['limit']);
             break;
         case 'special':
             $products = Product::getPricesDrop($this->lang_id, 0, (int) $setting['limit']);
             break;
     }
     $setting['products'] = $products;
     $output = array('type' => 'productlist', 'data' => $setting);
     return $output;
 }
开发者ID:vuduykhuong1412,项目名称:GitHub,代码行数:25,代码来源:productlist.php


示例17: loadCategory

function loadCategory($ext_id)
{
    global $db;
    $category = new Category($db);
    $category->loadByExtId($ext_id);
    return $category;
}
开发者ID:lotcz,项目名称:zshop,代码行数:7,代码来源:cube.j.php


示例18: category

 public function category()
 {
     $col_name = "placement_category_id";
     $category = null;
     if (isset($this->{$col_name}) && is_numeric($this->{$col_name})) {
         $category_id = $this->{$col_name};
         $entry = $this->entry();
         if (empty($entry)) {
             return null;
         }
         if ($entry->class === 'entry') {
             require_once 'class.mt_category.php';
             $category = new Category();
             $loaded = $category->Load("category_id = {$category_id}");
         } else {
             require_once 'class.mt_folder.php';
             $category = new Folder();
             $loaded = $category->Load("category_id = {$category_id}");
         }
         if (!$loaded) {
             $category = null;
         }
     }
     return $category;
 }
开发者ID:OCMO,项目名称:movabletype,代码行数:25,代码来源:class.mt_placement.php


示例19: delete

 function delete($id = FALSE)
 {
     $c = new Category($id);
     $c->delete();
     $this->session->set_flashdata('msg', '<div class="alert alert-success">Category was succesfully deleted.</div>');
     redirect($this->agent->referrer());
 }
开发者ID:ricardocasares,项目名称:Eventor,代码行数:7,代码来源:categories.php


示例20: actionDelete

 /**
  * 删除
  */
 public function actionDelete($id)
 {
     $id = (int) $id;
     $Category = new Category();
     $Category->delete(array('cid' => $id));
     WaveCommon::exportResult(true, '成功!');
 }
开发者ID:xpmozong,项目名称:wavephp2_demos,代码行数:10,代码来源:CategoriesController.php



注:本文中的Category类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CategoryModel类代码示例发布时间:2022-05-20
下一篇:
PHP CategoriesHelper类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap