本文整理汇总了PHP中Model_Category类的典型用法代码示例。如果您正苦于以下问题:PHP Model_Category类的具体用法?PHP Model_Category怎么用?PHP Model_Category使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model_Category类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
$category = new Model_Category('tree');
$data['categories'] = $category->getTree();
if (isset($_POST['btnsubmit'])) {
$categoryName = Arr::get($_POST, 'categoryName', '');
$parentId = Arr::get($_POST, 'parentId', '');
$url = Arr::get($_POST, 'url', '');
$categoryimage = Arr::get($_POST, 'categoryimage', '');
$res = $category->catInsert($parentId, array('name' => $categoryName, 'url' => $url, 'icon_url' => $categoryimage));
if ($res) {
//Request::initial()->redirect('admin');
HTTP::redirect('admin');
} else {
$data['errors'] = $category->getErrors();
}
}
if (isset($_POST['materialsavebtn'])) {
$categoryId = Arr::get($_POST, 'categoryId', '');
$content = Arr::get($_POST, 'content', '');
$name = Arr::get($_POST, 'name');
$material_image = Arr::get($_POST, 'material_image');
$material = ORM::factory('Material');
$material->addMaterial($categoryId, $content, $name, $material_image);
HTTP::redirect('admin');
}
$this->template->content = View::factory('adminview', $data);
}
开发者ID:robotkos,项目名称:kohana-book-catalog,代码行数:28,代码来源:Main.php
示例2: getPath
public function getPath($dir)
{
//первым делом ищем в структуре
$category = new Model_Category('tree');
$categoryId = $category->getCategoryIdByUrl($dir);
if ($categoryId) {
$dirs = [];
$categoryData = $category->getCategory($categoryId);
$parents = $category->getParents($categoryId);
foreach ($parents as $parent) {
if ($parent['level'] > 1 && $parent['url'] != 'glavnaya') {
$dirs[] = $parent['url'];
}
}
return array('name' => $categoryData['name'], 'path' => implode('/', $dirs));
}
//теперь ищем в материалах
$materials = new Model_Material('group');
$materialUrl = str_replace('.html', '', $dir);
$materialId = $materials->getMaterialIdByUrl($materialUrl);
if ($materialId) {
$materialData = $materials->getMaterial($materialId);
$categoryId = $materials->getTreeIdByMid($materialId);
$categoryData = $category->getCategory($categoryId);
return array('name' => $materialData['name'], 'path' => $categoryData['url'] . '/' . $dir);
} else {
return FALSE;
}
}
开发者ID:chernogolov,项目名称:blank,代码行数:29,代码来源:Breadcrumb.php
示例3: action_create
public function action_create()
{
if (Auth::is_admin_signed_in() === true) {
$view = View::factory('acp/categories/create');
$categories = new Model_Category();
if ($this->request->method() === Request::POST) {
$name = $this->request->post('name');
$slug = $this->request->post('slug');
$token = $this->request->param('id');
if (!Security::check($token)) {
$this->request->redirect('acp/categories/create');
}
if (empty($slug)) {
$slug = URL::title($name, '_');
}
if (empty($name) && empty($slug)) {
$this->request->redirect('acp/categories/create');
}
$categories = new Model_Category();
$create_category = $categories->create_category($name, $slug);
if (!$create_category) {
$this->request->redirect('acp/categories/create');
}
$this->request->redirect('acp/categories');
}
$this->template->content = $view->render();
} else {
$this->request->redirect('acp');
}
}
开发者ID:raku,项目名称:My-iShop,代码行数:30,代码来源:categories.php
示例4: action_create
public function action_create()
{
if (Auth::is_admin_signed_in() === true) {
$view = View::factory('acp/create/product');
$categories = new Model_Category();
$view->categories = $categories->get_list_of_categories();
if ($this->request->method() === Request::POST) {
$name = $this->request->post('name');
$valute = $this->request->post('valute');
$category = $this->request->post('category');
$description = $this->request->post('description');
$price = $this->request->post('price');
$img_url = $this->request->post('img_url');
$count = $this->request->post('count');
$price = Currency::to_database($price, $valute);
if (empty($name) && empty($category) && empty($description) && empty($price)) {
throw new Exception("Please do not make empty fields!");
}
$products = new Model_Product();
$data = array('image_url' => $img_url, 'name' => $name, 'category' => $category, 'description' => $description, 'price' => $price, 'count' => $count);
$create_new_product = $products->create_new_product($data);
if (!$create_new_product) {
throw new Exception("Error! Please check for DB settings!");
}
$this->request->redirect('acp/products');
}
$this->template->content = $view->render();
} else {
$this->request->redirect('acp');
}
}
开发者ID:raku,项目名称:My-iShop,代码行数:31,代码来源:products.php
示例5: addeditAction
public function addeditAction()
{
// action body
$oCategoryForm = new Application_Form_Category();
$this->view->categoryform = $oCategoryForm;
if ($this->getRequest()->isPost()) {
if ($oCategoryForm->isValid($this->getRequest()->getPost())) {
$saFormDetails = $oCategoryForm->getValues();
$oCategoryExist = Doctrine::getTable('Model_Category')->checkCategoryExist($saFormDetails['id_users']);
if (count($oCategoryExist) > 0 && $this->getRequest()->getParam('id_category') == "") {
$this->view->errorMessage = "This category is already exist.";
} elseif ($this->getRequest()->getParam('id_category') != "" && isset($oCategoryExist[0]) && $oCategoryExist[0]['id_category'] != $this->getRequest()->getParam('id_category')) {
$this->view->errorMessage = "This category is already exist.";
} else {
$oCategory = new Model_Category();
$snIdUser = $oCategory->saveAndUpdateCategoryDetails($oCategory, $saFormDetails, $this->getRequest()->getParam('id_category') != 0 ? $this->getRequest()->getParam('id_category') : '');
$this->_redirect('/admin/category/list');
}
}
} elseif ($this->getRequest()->getParam('id') != '') {
$oCategory = Doctrine::getTable('Model_Category')->getCategoryDetailById($this->getRequest()->getParam('id'));
$oCategoryForm->populate($oCategory[0]);
}
$this->view->param = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '';
}
开发者ID:nainit-virtueinfo,项目名称:zend-rest,代码行数:25,代码来源:CategoryController.php
示例6: action_index
public function action_index()
{
$this->template->page_title = 'Главная страница';
//$this->template->block_center = array($block_center);
$category = new Model_Category('tree');
$categoryName = $this->request->param('category');
$categoryId = $category->getCategoryIdByUrl('glavnaya');
//ВИДЖЕТЫ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ
$widgets = $category->getWidgets($categoryId);
$this->styles = array();
$wdgtarr = array();
// if($this->template->block_center!=NULL)
// {
// $oldWidgets = $this->template->block_center;
// foreach ($oldWidgets as $oldWidget)
// array_push($wdgtarr['block_center'], $oldWidget);
// }
$widgets = $this->getWidgets($categoryId);
if (is_array($widgets)) {
foreach ($widgets as $position => $widget) {
$this->template->{$position} = $widget;
}
}
$old_styles = $this->template->styles;
array_unique($this->styles);
$new_styles = array_merge($this->styles, $old_styles);
$this->template->styles = $new_styles;
}
开发者ID:chernogolov,项目名称:blank,代码行数:28,代码来源:Index_OLD.php
示例7: configure
public function configure()
{
// Init category
$category = new Model_Category(Conf::get('MAIN_CATEGORY'));
if ($category->getQuestionsTotal(true, true) == 0) {
return;
}
// Get questions
$questions = $category->getQuestions('latest', $this->page, true, true);
if ($category->getQuestionsTotal(true, true) <= ($this->page + 1) * Conf::get('QUESTION_PER_PAGE')) {
header('X-JSON: (Question.setEndReached())');
}
$colors = Conf::get('GRAPH_COLORS');
// Loop through all questions
foreach ($questions as $key => $question) {
// Get question's answers
$answers = $question->getAnswers();
$data = array();
foreach (array_reverse($answers) as $key => $answer) {
$data[] = array('value' => $answer->getPercentResultsMatching() / 100, 'color' => $colors[$key]);
}
// Assign question infos
Globals::$tpl->assignLoopVar('question_archive', array('id' => $question->getId(), 'label' => $question->getLabel(), 'guid' => Tool::makeGuid($question->getLabel()), 'data' => json_encode($data), 'time' => Tool::timeWarp($question->getEndDate())));
// Assign answers infos
foreach ($answers as $key => $answer) {
Globals::$tpl->assignLoopVar('question_archive.answer', array('percentFormated' => round($answer->getPercentResultsMatching()), 'label' => $answer->getLabel(), 'key' => $key));
}
}
}
开发者ID:xpac27,项目名称:Opipop,代码行数:29,代码来源:Archive.php
示例8: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$cat = new Model_Category();
// loaded category
if (Controller::$category !== NULL) {
if (Controller::$category->loaded()) {
$category = Controller::$category->id_category;
// id_category
//list of children of current category
// if list_cat dosent have siblings take brothers
$list_cat = $cat->where('id_category_parent', '=', $category)->order_by('order', 'asc')->cached()->find_all();
if (count($list_cat) == 0) {
$list_cat = $cat->where('id_category_parent', '=', Controller::$category->id_category_parent)->order_by('order', 'asc')->cached()->find_all();
}
//parent of current category
$cat_parent_deep = $cat->where('id_category', '=', Controller::$category->id_category_parent)->limit(1)->find();
// array with name and seoname of a category and his parent. Is to build breadcrumb in widget
$current_and_parent = array('name' => Controller::$category->name, 'id' => Controller::$category->id_category, 'seoname' => Controller::$category->seoname, 'parent_name' => $cat_parent_deep->name, 'id_parent' => $cat_parent_deep->id_category_parent, 'parent_seoname' => $cat_parent_deep->seoname);
}
} else {
$list_cat = $cat->where('id_category_parent', '=', 1)->order_by('order', 'asc')->cached()->find_all();
$current_and_parent = NULL;
}
$this->cat_items = $list_cat;
$this->cat_breadcrumb = $current_and_parent;
$this->loc_seoname = NULL;
if (Controller::$location !== NULL) {
if (Controller::$location->loaded()) {
if (Controller::$location->id_location != 1) {
$this->loc_seoname = Controller::$location->seoname;
}
}
}
}
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:40,代码来源:categories.php
示例9: getMaterialsByTeacher
public function getMaterialsByTeacher($pagination, $teacher_id = NULL, $node_id = NULL, $filter = NULL)
{
$cat = new Model_Category();
$qry = DB::select('materials.*', array('users.name', 'name'))->join('users', 'left')->on('users.id', '=', 'materials.teacher_id')->from('materials');
if ($teacher_id) {
$qry->where('teacher_id', '=', $teacher_id);
}
if ($node_id) {
$qry->where('node_id', '=', $node_id);
}
if (isset($filter['FIO']) && $filter['FIO'] != '') {
$qry->where('name', 'like', '%' . $filter['FIO'] . '%');
}
if (!$teacher_id) {
$qry->order_by('users.name', 'asc');
}
if ($pagination) {
$data = $qry->order_by('subjectName', 'asc')->order_by('ctime', 'asc')->limit($pagination->items_per_page)->offset($pagination->offset)->execute()->as_array();
} else {
$data = $qry->order_by('subjectName', 'asc')->order_by('ctime', 'asc')->execute()->as_array();
}
foreach ($data as $key => $item) {
$data[$key]['path'] = $cat->getPath($item['node_id']);
$data[$key]['isLeaf'] = $cat->isLeaf($item['node_id']);
$data[$key]['link'] = $this->getLink($item);
}
return $data;
}
开发者ID:reznikds,项目名称:Reznik,代码行数:28,代码来源:material.php
示例10: getCart
public function getCart($userId)
{
$result = DB::select()->from($this->tableName)->where('user', '=', $userId)->group_by('mid')->execute()->as_array();
$material = new Model_Material('groups');
$category = new Model_Category('tree');
$base = new Model_Base();
$arr = array();
foreach ($result as $item) {
//var_dump($item);
//название модели
$materialData = $material->getMaterial($item['mid']);
$arr[$item['mid']]['name'] = $materialData['name'];
$arr[$item['mid']]['mid'] = $item['mid'];
//url модели
$categoryName = $category->getNode($material->getTreeIdByMid($item['mid']));
$categoryName = $base->str2url($categoryName['name']);
$arr[$item['mid']]['url'] = $categoryName . '/' . $materialData['url'] . '.html';
//Изображение
$fields = $material->getFields($item['mid'], true);
$arr[$item['mid']]['img'] = $fields['Photos'][0];
//количество
$arr[$item['mid']]['count'] = $this->getCartCount($userId, $item['mid']);
//сумма
$arr[$item['mid']]['sum'] = $this->getCartPrice($userId, $item['mid']);
//размер
$arr[$item['mid']]['size'] = $item['size'];
//цвет
$arr[$item['mid']]['color'] = $item['color'];
}
return $arr;
}
开发者ID:chernogolov,项目名称:blank,代码行数:31,代码来源:Cart.php
示例11: action_new
public function action_new()
{
if (Auth::instance()->logged_in()) {
$view = View::factory('topic/new');
$category = new Model_Category();
$category_id = $this->request->param('id');
$view->categories = $category->find_all();
$user_id = Auth::instance()->get_user()->pk();
$view->role_id = ORM::factory('Roles_User')->get_last_role_id($user_id);
$user_id = Auth::instance()->get_user()->pk();
$users = ORM::factory('User')->get_data($user_id);
$this->template->content = $view->render();
if ($this->request->method() === Request::POST) {
if (!Security::check($this->request->param('id'))) {
throw new Exception("Bad token!");
}
$title = $this->request->post('title');
$category_id = $this->request->post('category_id');
$author = $user_id;
$content = $this->request->post('content');
if (empty($title) or empty($category_id) or empty($author) or empty($content)) {
throw new Exception("Fields cannot be empty!");
}
$data = array('title' => $title, 'category_id' => $category_id, 'author_id' => $author, 'content' => $content, 'published' => time());
$topic = new Model_Topic();
$publish_topic = $topic->publish($data);
if (!$publish_topic) {
throw new Exception("Cannot publish your topic!");
}
$this->request->redirect('category/index/' . $category_id);
}
} else {
$this->redirect('');
}
}
开发者ID:reGative,项目名称:Phorumph,代码行数:35,代码来源:Topic.php
示例12: displayArchives
private function displayArchives()
{
if (!isset($this->displayArchives)) {
$category = new Model_Category(Conf::get('MAIN_CATEGORY'));
$this->displayArchives = $category->getQuestionsTotal(true, true) == 0 ? false : true;
}
return $this->displayArchives;
}
开发者ID:xpac27,项目名称:Opipop,代码行数:8,代码来源:Homepage.php
示例13: action
public function action()
{
$model = new Model_Category();
$valuesMain['catList'] = $model->getCategoryAll();
$view = new View();
$view->addBufferMain('layout', $valuesMain);
$view->addBuffers('contactus');
$view->renderBuffer();
}
开发者ID:anton-phpcurs,项目名称:mvc,代码行数:9,代码来源:controller_contactus.php
示例14: action_delete
public function action_delete()
{
$url = $this->request->param('id');
if ($url != NULL) {
$category = new Model_Category('tree');
$result = $category->deleteCategory($category->getCategoryIdByUrl($url));
Controller::redirect('admin');
}
}
开发者ID:chernogolov,项目名称:blank,代码行数:9,代码来源:Index.php
示例15: configure
public function configure()
{
// Init category
$category = new Model_Category(Conf::get('MAIN_CATEGORY'));
if ($category->getQuestionsTotal(true) == 0) {
return;
}
// Get logged user if there is one
$user = Model_User::getLoggedUser();
// Get questions
$questions = $category->getQuestions('latest', $this->page, 1);
// Loop through all questions
foreach ($questions as $question) {
Globals::$tpl->assignLoopVar('question', array('id' => $question->getId(), 'label' => $question->getLabel(), 'image' => $question->getImageURL('medium'), 'label_urlencoded' => urlencode($question->getLabel()), 'time' => Tool::timeWarp($question->getEndDate())));
// Get answers
$answers = $question->getAnswers();
$friendsVotedId = array();
if ($user) {
$userResult = $user->getResult($question);
$userGuess = $user->getGuess($question);
}
// Loop through all answers
foreach ($answers as $answer) {
Globals::$tpl->assignLoopVar('question.answer', array('id' => $answer->getId(), 'label' => $answer->getLabel()));
if ($user && $userResult && $answer->getId() == $userResult->getAnswer()->getId()) {
Globals::$tpl->assignLoopVar('question.answer.user', array('class' => 'vote', 'label' => 'Mon opinion', 'id' => $user->getId(), 'login' => $user->getLogin(), 'image' => $user->getAvatarURL('small')));
}
if ($user && $userGuess && $answer->getId() == $userGuess->getAnswer()->getId()) {
Globals::$tpl->assignLoopVar('question.answer.user', array('class' => 'guess', 'label' => 'Mon pronostic', 'id' => $user->getId(), 'login' => $user->getLogin(), 'image' => 'media/layout/icon24x24/map_mini.png'));
}
if ($user) {
foreach ($user->getFriendGuesses($question) as $friendGuess) {
if ($answer->getId() == $friendGuess->getAnswer()->getId()) {
Globals::$tpl->assignLoopVar('question.answer.friend', array('class' => 'friend', 'userId' => $user->getId(), 'id' => $friendGuess->getFriend()->getId(), 'login' => $friendGuess->getFriend()->getLogin(), 'avatar' => $friendGuess->getFriend()->getAvatarURL('small')));
$friendsVotedId[] = $friendGuess->getFriend()->getId();
}
}
}
}
if ($user && !$userResult) {
Globals::$tpl->assignLoopVar('question.pendingUser', array('class' => 'vote', 'label' => 'Mon opinion', 'id' => $user->getId(), 'login' => $user->getLogin(), 'avatar' => $user->getAvatarURL('small')));
}
if ($user && !$userGuess) {
Globals::$tpl->assignLoopVar('question.pendingUser', array('class' => 'guess', 'label' => 'Mon pronostic', 'id' => $user->getId(), 'login' => $user->getLogin(), 'avatar' => $user->getAvatarURL('small')));
}
if ($user) {
// Construct unvoted friends list
foreach ($user->getFriends() as $friend) {
if (!in_array($friend->getId(), $friendsVotedId)) {
Globals::$tpl->assignLoopVar('question.pendingFriend', array('class' => 'friend', 'userId' => $user->getId(), 'id' => $friend->getId(), 'login' => $friend->getLogin(), 'avatar' => $friend->getAvatarURL('small')));
}
}
}
}
}
开发者ID:xpac27,项目名称:Opipop,代码行数:55,代码来源:Active.php
示例16: save
public function save(Model_Category $category)
{
if ($category->id) {
$where[] = 'id = ' . $category->id;
$this->_db->update('categories', $category->toArray(), $where);
} else {
$this->_db->insert('categories', $category->toArray());
$category->id = $this->_db->lastInsertId();
}
return $category;
}
开发者ID:kminkov,项目名称:Blog,代码行数:11,代码来源:Category.php
示例17: actionSettings
public function actionSettings()
{
//Log::sendToScreen(__FILE__, __LINE__, 'Получить настройки из modelUsers (session_user_id)');
//Log::sendToScreen(__FILE__, __LINE__, 'View -> render');
$model = new Model_Category();
$valuesMain['catList'] = $model->getCategoryAll();
$view = new View();
$view->addBufferMain('layout', $valuesMain);
$view->addBuffers('settings');
$view->renderBuffer();
}
开发者ID:anton-phpcurs,项目名称:mvc,代码行数:11,代码来源:controller_user.php
示例18: action_index
public function action_index()
{
$articles = array();
// подключаем БД
$article = new Model_Category();
//считываем оттуда массив данных
$articles = $article->get_all();
// подключаем шаблон и отправляем туда переменные
$content = View::factory('/pages/template')->bind('articles', $articles);
$this->template->content = $content;
$this->template->title = 'Профи-суши';
$this->template->styles = array('bootstrap.min', 'backet', 'main', 'main-page');
}
开发者ID:piotrazsko,项目名称:sushi,代码行数:13,代码来源:Page.php
示例19: action_index
public function action_index()
{
$category_id = $this->request->param('id');
if (empty($category_id)) {
throw new Exception("Category ID must not be empty!");
}
$topic = new Model_Topic();
$category = new Model_Category();
$view = View::factory('categories/main');
$view->topics = $topic->get_topics_by_id($category_id);
$view->category = $category->get_name($category_id);
$this->template->content = $view->render();
}
开发者ID:reGative,项目名称:Phorumph,代码行数:13,代码来源:Category.php
示例20: before
/**
* Initialize properties before running the controller methods (actions),
* so they are available to our action.
*/
public function before($template = NULL)
{
parent::before();
Theme::checker();
$this->maintenance();
/**
* selected category
*/
if ($this->request->param('category', NULL) != 'all') {
$slug_cat = new Model_Category();
$seo_cat = $slug_cat->where('seoname', '=', $this->request->param('category'))->limit(1)->cached()->find();
if ($seo_cat->loaded()) {
self::$category = $seo_cat;
}
}
/**
* selected location
*/
if ($this->request->param('location', NULL) != NULL || $this->request->param('location') != 'all') {
$slug_loc = new Model_Location();
$seo_loc = $slug_loc->where('seoname', '=', $this->request->param('location'))->limit(1)->cached()->find();
if ($seo_loc->loaded()) {
self::$location = $seo_loc;
}
}
if ($this->auto_render === TRUE) {
// Load the template
if ($template !== NULL) {
$this->template = $template;
}
$this->template = View::factory($this->template);
// Initialize template values
$this->template->title = core::config('general.site_name');
$this->template->meta_keywords = '';
$this->template->meta_description = '';
$this->template->meta_copywrite = 'Open Classifieds ' . Core::version;
$this->template->content = '';
$this->template->styles = array();
$this->template->scripts = array();
//we can not cache this view since theres dynamic parts
//$this->template->header = View::factory('header');
//setting inner views try to get from fragment
// if (Auth::instance()->logged_in())
// $this->template->header = View::fragment('header_front_login','header');
// else
$this->template->header = View::factory('header');
// $this->template->header = View::fragment('header_front','header');
//no fragment since CSRF gets cached :(
$this->template->footer = View::fragment('footer_front', 'footer');
}
}
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:55,代码来源:controller.php
注:本文中的Model_Category类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论