Inheritance: extends CI_Controller
Exemple #1
0
 public function __construct($options = null)
 {
     $baseDir = $options['baseDir'];
     $pageID = $options['pageID'];
     parent::__construct($options);
     /****************************************/
     // PARAMETERS
     /****************************************/
     // select box category (Parameter #1)
     $blockCategory = new Zend_Form_Element_Select('Param1');
     $blockCategory->setLabel($this->getView()->getCibleText('form_gallery_blockCategory_label'))->setAttrib('class', 'largeSelect')->setOrder(11);
     $categories = new Categories();
     $select = $categories->select()->setIntegrityCheck(false)->from('Categories')->join('CategoriesIndex', 'C_ID = CI_CategoryID')->where('C_ModuleID = ?', 9)->where('CI_LanguageID = ?', Zend_Registry::get("languageID"))->order('CI_Title');
     $categoriesArray = $categories->fetchAll($select);
     foreach ($categoriesArray as $category) {
         $blockCategory->addMultiOption($category['C_ID'], $category['CI_Title']);
     }
     $this->addElement($blockCategory);
     $blockGallery = new Zend_Form_Element_Select('Param2');
     $blockGallery->setLabel($this->getView()->getCibleText('form_gallery_blockGallerey_label'))->setAttrib('class', 'largeSelect')->setOrder(12);
     $galleries = new Galleries();
     $selectG = $galleries->select()->setIntegrityCheck(false)->from('Galleries')->join('GalleriesIndex', 'G_ID = GI_GalleryID')->where('G_Online = 1')->where('GI_LanguageID = ?', Zend_Registry::get("languageID"))->order('GI_Title');
     $galleriesArray = $galleries->fetchAll($selectG);
     //echo $selectG;
     $blockGallery->addMultiOption('0', $this->getView()->getCibleText('form_gallery_blockGallerey_None'));
     foreach ($galleriesArray as $gallery) {
         $blockGallery->addMultiOption($gallery['GI_GalleryID'], $gallery['GI_Title']);
     }
     $this->addElement($blockGallery);
     $this->removeDisplayGroup('parameters');
     $this->addDisplayGroup(array('Param999', 'Param1', 'Param2'), 'parameters');
     $parameters = $this->getDisplayGroup('parameters');
 }
Exemple #2
0
 public static function Tree($level)
 {
     // call this function    with level depth u want
     $cate = Categories::with(implode('.', array_fill(0, $level, 'children')))->whereparent_id(0)->get();
     $new = new Categories();
     return $new->treeBuild($cate);
 }
Exemple #3
0
 public function __construct($options = null)
 {
     $baseDir = $options['baseDir'];
     $pageID = $options['pageID'];
     parent::__construct($options);
     /****************************************/
     // PARAMETERS
     /****************************************/
     // select box category (Parameter #1)
     $blockCategory = new Zend_Form_Element_Select('Param1');
     $blockCategory->setLabel('Catégorie d\'évènement de ce bloc')->setAttrib('class', 'largeSelect');
     $categories = new Categories();
     $select = $categories->select()->setIntegrityCheck(false)->from('Categories')->join('CategoriesIndex', 'C_ID = CI_CategoryID')->where('C_ModuleID = ?', 7)->where('CI_LanguageID = ?', Zend_Registry::get("languageID"))->order('CI_Title');
     $categoriesArray = $categories->fetchAll($select);
     foreach ($categoriesArray as $category) {
         $blockCategory->addMultiOption($category['C_ID'], $category['CI_Title']);
     }
     // number of news to show in front-end (Parameter #2)
     $at_least_one = new Zend_Validate_GreaterThan('0');
     $at_least_one->setMessage('Vous devez afficher au moins un événement.');
     $not_null = new Zend_Validate_NotEmpty();
     $not_null->setMessage($this->getView()->getCibleText('validation_message_empty_field'));
     $blockNewsMax = new Zend_Form_Element_Text('Param2');
     $blockNewsMax->setLabel('Nombre d\'évènement à afficher')->setRequired(true)->setValue('1')->addValidator($not_null, true)->addValidator($at_least_one, true)->setAttrib('class', 'smallTextInput');
     // show the breif text in front-end (Parameter #3)
     $blockShowBrief = new Zend_Form_Element_Checkbox('Param3');
     $blockShowBrief->setLabel('Afficher le texte bref');
     $blockShowBrief->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     $this->addElements(array($blockCategory, $blockNewsMax, $blockShowBrief));
     $this->removeDisplayGroup('parameters');
     $this->addDisplayGroup(array('Param999', 'Param1', 'Param2', 'Param3'), 'parameters');
     $parameters = $this->getDisplayGroup('parameters');
     //$parameters->setLegend($this->_view->getCibleText('form_parameters_fieldset'));
 }
 function getAllNewsletterCategories()
 {
     $categoriesSelect = new Categories();
     $select = $categoriesSelect->select()->setIntegrityCheck(false);
     $select->from('Categories')->join('CategoriesIndex', ' CI_CategoryID = C_ID')->where('CI_LanguageID = ?', Zend_Registry::get("languageID"))->where('C_ModuleID = 8')->order('CI_Title');
     $categoriesData = $categoriesSelect->fetchAll($select);
     return $categoriesData;
 }
Exemple #5
0
 public function post()
 {
     $name = $this->request->getPost('name');
     if (empty($name)) {
         return false;
     }
     $this->category->name = $name;
     $this->category->put();
     return "/admin/categories/{$this->category->id}";
 }
 private function buildCategories($xml)
 {
     $categories = new Categories();
     $categoryArray = array();
     foreach ($xml->Category as $category) {
         array_push($categoryArray, (string) $category);
     }
     $categories->setCategory($categoryArray);
     return $categories;
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new Categories('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Categories'])) {
         $model->attributes = $_GET['Categories'];
     }
     $model->pageSize = 25;
     $this->render('index', array('model' => $model));
 }
 private function insertRel($value)
 {
     try {
         $this->log->addInfo("Inicia funcion MainProject::insertRel() ");
         $categories = new Categories();
         $rel = array(0, "lkp_projects", $value->id);
         $categories->insert($rel);
     } catch (\Excetion $e) {
         $this->log->addError($e->getMessage(), array(basename(__FILE__) . "::" . __LINE__));
     }
 }
Exemple #9
0
 public function addCategory($attr)
 {
     $model = new Categories();
     $model->setAttributes($attr);
     $model->status = 1;
     $model->created_at = time();
     $model->updated_at = time();
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
Exemple #10
0
 public function post()
 {
     include_once 'application/models/Categories.php';
     $name = $this->request->getPost('name');
     if (empty($name)) {
         return false;
     }
     $category = new Categories();
     $category->name = $name;
     $category->put();
     return "/admin/categories/{$category->id}";
 }
 public function getForm($id = null)
 {
     $dataAdmin = new PrProviders();
     $modelProviders = new PrTypes();
     $modelCategories = new Categories();
     $listProviders = $modelProviders->where('flagactive', PrTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listProviders = [null => 'Select un tipo'] + $listProviders;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     if (!is_null($id)) {
         $dataAdmin = PrProviders::find($id);
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataAdmin', 'listProviders'), ['listCategories' => $listCategories, 'listCategories' => $listCategories]);
 }
function testFindByParentId()
{
    global $success, $failure;
    $category = new Categories();
    if (!isset($category)) {
        print "Category is not set";
        $failure++;
    }
    if (($rs = $category->findFindByParentId(0)) === false) {
        $failure++;
    } else {
        rs2html($rs);
        $success++;
    }
}
	private function setCategoryTitleSmall($categoryID = 0)
	{
		$category = Categories::findFirst($categoryID);		
		$this->view->h1_small = $category->title;		
		
		$this->view->categoryID = $categoryID;
	}
/**
 * Render select page control
 * 
 * Parameters:
 * 
 * - project - Parent project
 * - value - ID of selected page
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_page($params, &$smarty)
{
    $project = array_var($params, 'project', null, true);
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, '$project is expected to be an instance of Project class', true);
    }
    // if
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('user', $user, '$user is exepcted to be an instance of User class', true);
    }
    // if
    $options = array();
    $value = array_var($params, 'value', null, true);
    $skip = array_var($params, 'skip');
    $categories = Categories::findByModuleSection($project, PAGES_MODULE, 'pages');
    if (is_foreachable($categories)) {
        foreach ($categories as $category) {
            $option_attributes = $category->getId() == $value ? array('selected' => true) : null;
            $options[] = option_tag($category->getName(), $category->getId(), $option_attributes);
            $pages = Pages::findByCategory($category, STATE_VISIBLE, $user->getVisibility());
            if (is_foreachable($pages)) {
                foreach ($pages as $page) {
                    smarty_function_select_page_populate_options($page, $value, $user, $skip, $options, '- ');
                }
                // foreach
            }
            // if
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
Exemple #15
0
 public static function getCategoryRoute($catid)
 {
     if ($catid instanceof CategoryNode) {
         $id = $catid->id;
         $category = $catid;
     } else {
         $id = (int) $catid;
         $category = Categories::getInstance('JFoobars')->get($id);
     }
     if ($id < 1) {
         $link = '';
     } else {
         $needles = array('category' => array($id));
         if ($item = self::_findItem($needles)) {
             $link = 'index.php?Itemid=' . $item;
         } else {
             //Create the link
             $link = 'index.php?option=com_jfoobars&view=category&id=' . $id;
             if ($category) {
                 $catids = array_reverse($category->getPath());
                 $needles = array('category' => $catids, 'categories' => $catids);
                 if ($item = self::_findItem($needles)) {
                     $link .= '&Itemid=' . $item;
                 } elseif ($item = self::_findItem()) {
                     $link .= '&Itemid=' . $item;
                 }
             }
         }
     }
     return $link;
 }
function loadApi($action)
{
    switch ($action) {
        case 'insert':
            if (!isset($_COOKIE['groupid'])) {
                throw new Exception("You must be login.");
            }
            try {
                if (!($id = Categories::insert(Request::make('send')))) {
                    throw new Exception("Error. " . Database::$error);
                }
                return json_encode(array('error' => 'no'));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'get':
            try {
                $data = Categories::get();
                return json_encode($data);
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
    }
}
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     switch ($_GET['s']) {
         case 'Author':
             $prof = Profile::model()->with('user', 'AuthAssignment')->findAll();
             $cat = Categories::model()->findAll();
             foreach ($cat as $key => $val) {
                 $rescat[$val->getAttributes()['id']] = $val->getAttributes()['cat_name'];
             }
             foreach ($prof as $key => $val) {
                 $res = $val->getAttributes();
                 $res1 = $val->AuthAssignment->getAttributes();
                 //---<<
                 $resuser = $val->user->getAttributes();
                 if ($res['discipline'] != '') {
                     $res['cat_name'] = implode(',', array_intersect_key($rescat, array_flip(explode(',', $res['discipline']))));
                 }
                 if ($res1['itemname'] == 'Author') {
                     $itog[$key] = array_merge($res, $resuser);
                 }
             }
             $dataProvider = new CArrayDataProvider($itog, array('pagination' => array('pageSize' => Yii::app()->controller->module->user_page_size)));
             break;
         default:
             $dataProvider = new CActiveDataProvider('User', array('criteria' => array('condition' => 'status>' . User::STATUS_BANNED, 'with' => array('AuthAssignment' => array('condition' => 'itemname="Customer"', 'together' => true))), 'pagination' => array('pageSize' => Yii::app()->controller->module->user_page_size)));
             break;
     }
     $this->render('/user/index', array('dataProvider' => $dataProvider));
 }
 public function actionIndex()
 {
     $male_cats = Categories::model()->getMaleCategory();
     $female_cats = Categories::model()->getFemaleCategory();
     $other_cats = Categories::model()->getOtherCategory();
     $this->render('index', array('male_cats' => $male_cats, 'female_cats' => $female_cats, 'other_cats' => $other_cats));
 }
/**
 * Render select category control
 * 
 * Supported paramteres:
 * 
 * - all HTML attributes
 * - project - Parent project, required
 * - module - Module
 * - controller - Controller name
 * - value - ID of selected category
 * - optional - If false there will be no -- none -- option
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_category($params, &$smarty)
{
    static $ids = array();
    $project = array_var($params, 'project', null, true);
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, 'Project parameter is required for select category helper and it needs to be an instance of Project class', true);
    }
    // if
    $user = array_var($params, 'user', null, true);
    $module = trim(array_var($params, 'module', null, true));
    if ($module == '') {
        return new InvalidParamError('module', $module, 'Module parameter is required for select category helper', true);
    }
    // if
    $controller = trim(array_var($params, 'controller', null, true));
    if ($controller == '') {
        return new InvalidParamError('controller', $controller, 'Controller parameter is required for select category helper', true);
    }
    // if
    $id = array_var($params, 'id', null, true);
    if (empty($id)) {
        $counter = 1;
        do {
            $id = "select_category_{$counter}";
            $counter++;
        } while (in_array($id, $ids));
    }
    // if
    $params['id'] = $id;
    $value = array_var($params, 'value', null, true);
    $optional = array_var($params, 'optional', true, true);
    $options = array();
    if ($optional) {
        $options[] = option_tag(lang('-- None --'), '');
    }
    // if
    $categories = Categories::findByModuleSection($project, $module, $controller);
    if (is_foreachable($categories)) {
        foreach ($categories as $category) {
            $option_attributes = array('class' => 'object_option');
            if ($category->getId() == $value) {
                $option_attributes['selected'] = true;
            }
            // if
            $options[] = option_tag($category->getName(), $category->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    if (instance_of($user, 'User') && Category::canAdd($user, $project)) {
        $params['add_object_url'] = Category::getQuickAddUrl($project, $controller, $module);
        $params['object_name'] = 'category';
        $params['add_object_message'] = lang('Please insert new category name');
        $options[] = option_tag('', '');
        $options[] = option_tag(lang('New Category...'), '', array('class' => 'new_object_option'));
    }
    // if
    return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
 /**
  * list categories
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // process all items in the list
     $items = array();
     $total = 0;
     $minimum = 10000;
     $maximum = 0;
     while ($item = SQL::fetch($result)) {
         // this will be sorted alphabetically
         $items[$item['title']] = array('importance' => (int) $item['importance'], 'href' => Categories::get_permalink($item));
         // assess the scope
         if ($minimum > (int) $item['importance']) {
             $minimum = (int) $item['importance'];
         }
         if ($maximum < (int) $item['importance']) {
             $maximum = (int) $item['importance'];
         }
     }
     // end of processing
     SQL::free($result);
     // sort the array alphabetically
     ksort($items);
     // scale items
     $text = '';
     foreach ($items as $title => $item) {
         switch ((string) ceil((1 + $item['importance'] - $minimum) * 6 / (1 + $maximum - $minimum))) {
             default:
             case 1:
                 $item['style'] = 'font-size: 0.8em';
                 break;
             case 2:
                 $item['style'] = 'font-size: 0.9em';
                 break;
             case 3:
                 $item['style'] = 'font-size: 1.3em';
                 break;
             case 4:
                 $item['style'] = 'font-size: 1.5em';
                 break;
             case 5:
                 $item['style'] = 'font-size: 1.7em';
                 break;
             case 6:
                 $item['style'] = 'font-size: 2em';
                 break;
         }
         $text .= '<span style="' . $item['style'] . '">' . Skin::build_link($item['href'], $title, 'basic') . '</span> ';
     }
     // final packaging
     $text = '<p class="cloud">' . rtrim($text) . '</p>';
     // return by reference
     return $text;
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     //Categories::truncate();
     for ($i = 0; $i < 10; $i++) {
         $category = Categories::create(array('name' => $faker->word, 'description' => $faker->text));
     }
 }
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 4;
     $criteria->order = 'RAND()';
     $model = Categories::model()->findAll($criteria);
     $this->render('categoriesLanding', array('model' => $model));
 }
Exemple #23
0
 /**
  * funkce vylistuje kategorie
  * @param int $distributor_id optional
  * @param bool $count optional
  * @return array
  */
 public function categoriesList($distributor_id = null, $count = false)
 {
     try {
         return Categories::categoriesList($distributor_id, $count);
     } catch (Exception $e) {
         throw new RPCFault($e->getMessage(), $e->getCode(), $e->getCode());
     }
 }
 /**
  * Constructor
  */
 public function __construct($version, $file, $dir)
 {
     $this->version = $version;
     $this->file = $file;
     $this->dir = $dir;
     if (defined('WPKB_POST_TYPE_SLUG')) {
         $this->post_type_slug = WPKB_POST_TYPE_SLUG;
     }
     $this->options = $this->load_options();
     // init categories
     $this->categories = new Categories(self::POST_TYPE_NAME, $this->post_type_slug);
     $this->categories->add_hooks();
     if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
         $admin = new Admin();
         $admin->add_hooks();
     }
 }
 public function getIndex()
 {
     $categories = array();
     foreach (Categories::all() as $category) {
         $categories[$category->id] = $category->name;
     }
     return View::make('product.index')->with('product', Product::all())->with('categories', $categories);
 }
 public function actionAddPost()
 {
     $male_cats = Categories::model()->getMaleCategory();
     $female_cats = Categories::model()->getFemaleCategory();
     $other_cats = Categories::model()->getOtherCategory();
     $celebs = Celebrities::model()->findAll();
     $this->render('addPost', array('celebs' => $celebs, 'male_cats' => $male_cats, 'female_cats' => $female_cats, 'other_cats' => $other_cats));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Categories::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function saveCategory($data)
 {
     if ($data['catId']) {
         $category = $this->em->getRepository('Api\\Model\\Categories')->find($data['catId']);
     } else {
         $category = new Categories();
     }
     if ($category) {
         $category->setCatName($data['catName']);
         $category->setCatStatus($data['catStatus']);
         $this->em->persist($category);
         $this->em->flush();
         return true;
     } else {
         return false;
     }
 }
Exemple #29
0
 public function authentificateAction()
 {
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('index');
     }
     $form = $this->getForm();
     if (!$form->isValid($_POST)) {
         $this->view->form = $form;
         return $this->render('index');
     } else {
         $values = $form->getValues();
         $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('database'));
         $authAdapter->setTableName('users');
         $authAdapter->setIdentityColumn('Login');
         $authAdapter->setCredentialColumn('Password');
         $authAdapter->setIdentity($values['Login']);
         $authAdapter->setCredential($values['Password']);
         $select = $authAdapter->getDbSelect();
         $select->where('Active = 1');
         if ($authAdapter->authenticate()->getCode() == Zend_Auth_Result::SUCCESS) {
             $databaseTable = $authAdapter->getResultRowObject();
             Zend_Registry::get('database')->query('UPDATE users SET LastConnection = NOW() WHERE Id = "' . $databaseTable->Id . '"');
             $session = $this->session;
             if (isset($_COOKIE['PreviousCategory'])) {
                 $table = new Categories();
                 $row = $table->find($_COOKIE['PreviousCategory'])->current();
                 if (isset($row->Id)) {
                     $session->category = $row->Id;
                     $session->categoryName = $row->Name;
                 }
             }
             $session->access = true;
             $session->id = $databaseTable->Id;
             $session->lastName = $databaseTable->LastName;
             $session->firstName = $databaseTable->FirstName;
             $session->rights = new UsersRights($databaseTable->Status);
             $this->view->access = true;
             $this->_forward('home');
         } else {
             $this->view->message = '<div class="error">Identification incorrect : mauvais nom d\'utilisateur et/ou mot de passe.</div>';
             $this->view->form = $form;
             return $this->render('index');
         }
     }
 }
 public function indexAction()
 {
     if ($this->request->hasPost('od') && $this->request->getPost('od') == 'y') {
         $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     }
     $zap = '';
     if ($this->request->hasPost('cat_id') && $this->request->isAjax()) {
         $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
         $cat_id = $this->request->getPost('cat_id');
         if (isset($cat_id) && is_numeric($cat_id)) {
             if ($this->request->hasPost('sub-cat')) {
                 $zap = "id = {$cat_id}";
                 $c_cat = 1;
             } else {
                 $zap = "id = {$cat_id} or id_sub = {$cat_id}";
                 $c_cat = 1;
             }
             foreach (Categories::find(array("{$zap}")) as $csv) {
                 $c_cat = $c_cat + $csv->proposal->count();
             }
             if ($c_cat == 1) {
                 $this->view->disable();
                 echo 1;
                 die;
             }
         }
     }
     ///////////////// Пагинация
     if (!empty($_POST['page'])) {
         $currentPage = $_POST["page"];
     } else {
         $currentPage = 1;
     }
     // Chat::find(array('order' => 'creation_date DESC'))
     if (empty($zap)) {
         $zaps = '';
     } else {
         $query = $this->modelsManager->createQuery("SELECT id FROM Categories WHERE " . $zap)->execute()->toArray();
         foreach ($query as $f) {
             $cats_id[] = $f['id'];
         }
         // $this->elements->var_print($cats_id);
         $sre = implode(" ,", $cats_id);
         $zaps = " category_id IN ({$sre})";
         // echo $zaps;
     }
     $bield = $this->modelsManager->createBuilder()->from('Proposal')->where($zaps)->orderBy('creation_date DESC');
     $paginator = new Phalcon\Paginator\Adapter\QueryBuilder(array("builder" => $bield, "limit" => 10, "page" => $currentPage));
     $page = $paginator->getPaginate();
     foreach ($page->items as $prop) {
         foreach ($prop->dannproposal as $dann) {
             $props[$prop->id][$dann->fieldtype->id] = $dann->dann;
             $props[$prop->id]['cat'] = $prop->categories->name;
         }
     }
     $this->view->setVars(array('cl' => count($page->items), 'prop' => $props = isset($props) ? $props : false, 'page_num' => $page->current, 'page_total' => $page->total_pages));
 }