Пример #1
0
 public function init()
 {
     //get user lsit
     $userM = new Application_Model_User();
     $usersArr = $userM->getUsersList(null, '--- Select Author ---');
     $this->addElement('select', 'userId', array('label' => 'Author:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select author.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $usersArr));
     $categories = new Application_Model_Category();
     $categoriesArr = $categories->getCategory("--- Select Category ---", "advice");
     $this->addElement('select', 'categoryId', array('label' => 'Category:', 'style' => 'width: 313px;', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select advice category.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $categoriesArr));
     $this->addElement('text', 'title', array('label' => 'Title :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice title')))), 'decorators' => $this->elementDecorators));
     $this->addElement('text', 'identifire', array('label' => 'URL Re-write :', 'class' => 'title-input-box', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the advice URL Re-write')))), 'decorators' => $this->elementDecorators));
     // Add an body element
     $this->addElement('textarea', 'content', array('label' => 'Content:', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page content')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     // Add an body element
     $this->addElement('textarea', 'synopsis', array('label' => 'Synopsis:', 'required' => false, 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the synopsis')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'metaTitle', array('label' => 'Meta Title :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter the page identifire')))), 'decorators' => $this->elementDecorators));
     $this->addElement('textarea', 'metaKeyword', array('label' => 'Meta Keyword :', 'cols' => '50', 'rows' => '3', 'class' => 'title-input-box', 'required' => false, 'decorators' => $this->elementDecorators));
     $this->addElement('textarea', 'metaDescription', array('label' => 'Meta Description :', 'class' => 'title-input-box', 'cols' => '50', 'rows' => '3', 'required' => false, 'decorators' => $this->elementDecorators));
     $Name = new Zend_Form_Element_File('name');
     $Name->setLabel('Upload an image:')->setRequired(false)->addValidator('Extension', false, 'jpg,png,gif')->clearDecorators()->addDecorators($this->fileDecorators);
     $this->addElements(array($Name));
     $this->addElement('submit', 'savePublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Publish', 'label' => 'Save and Publish', 'decorators' => $this->buttonDecorators));
     $this->addElement('submit', 'saveUnpublish', array('required' => false, 'ignore' => true, 'title' => 'Save and Unpublish', 'label' => 'Save and Unpublish', 'decorators' => $this->buttonDecorators));
     $this->addElement('submit', 'previewPage', array('required' => false, 'ignore' => true, 'title' => 'Preview Page', 'label' => 'Preview Page', 'decorators' => $this->buttonDecorators));
 }
Пример #2
0
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     $category_model = new Application_Model_Category();
     $delete = $category_model->deleteCategory($id);
     $this->redirect('category/list');
 }
Пример #3
0
 public function indexAction()
 {
     $id_category = $this->_getParam('type');
     $categorie = new Application_Model_Category();
     $produit = $categorie->getArticleByCategory($id_category);
     $produit = $categorie->convertImageSousRubrique($produit);
     $this->view->produit = $produit;
 }
Пример #4
0
 public function find($id)
 {
     $rowSet = $this->getDbTable()->find($id);
     $row = $rowSet->current();
     $category = new Application_Model_Category();
     $category->setId($row->c_id);
     $category->setLabel($row->c_label);
     return $category;
 }
Пример #5
0
 public function init()
 {
     $this->addElement('text', 'title', array('label' => 'Title :', 'class' => '', 'decorators' => $this->elementDecorators));
     $categories = new Application_Model_Category();
     $categoriesArr = $categories->getCategory("--- Select Category ---", "advice");
     $this->addElement('select', 'category_id', array('label' => 'Category:', 'style' => 'width: 250px;', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $categoriesArr));
     $this->addElement('radio', 'status', array('label' => 'Staus: ', 'value' => '', 'multiOptions' => array('1' => "Published", '0' => "Unpublished", '' => "All"), 'decorators' => $this->elementDecorators));
     $this->getElement('status')->setSeparator('');
     $this->addElement('submit', 'submit', array('required' => false, 'ignore' => true, 'label' => 'Search', 'decorators' => $this->buttonDecorators));
 }
Пример #6
0
 public function init()
 {
     $user_model = new Application_Model_Category();
     $allcats = $user_model->listCategory();
     for ($i = 0; $i < count($allcats); $i++) {
         $name = $allcats[$i]['name'];
         $id = $allcats[$i]['id'];
         $this->addMultiOption($id, $name);
     }
 }
Пример #7
0
 public function deleteAction()
 {
     // action body
     $id = $this->_request->getParam('id');
     if (!empty($id)) {
         $cat_model = new Application_Model_Category();
         $cat_model->deleteCat($id);
     }
     $this->redirect('/Category');
 }
 public function find($id)
 {
     $result = $this->getDbTable()->find($id);
     if (0 == count($result)) {
         return;
     }
     $row = $result->current();
     $category = new Application_Model_Category();
     $category->setId($row->id);
     $category->setName($row->name);
     return $category;
 }
Пример #9
0
 public function getList()
 {
     $rowSet = $this->getDbTable()->fetchAll();
     $categories = array();
     foreach ($rowSet as $row) {
         $category = new Application_Model_Category();
         $category->setId($row->c_id);
         //$category->setProducts($row->findDependentRowset('Application_Model_DbTable_Product'));
         $category->setLabel($row->c_label);
         $categories[] = $category;
     }
     return $categories;
 }
Пример #10
0
 public function getCategoriesArray()
 {
     $cat_id = array();
     $cat_name = array();
     $category_model = new Application_Model_Category();
     $cat_info = $category_model->listCategory();
     for ($i = 0; $i < count($cat_info); $i++) {
         foreach ($cat_info[$i] as $key => $value) {
             if ($key == "id") {
                 array_push($cat_id, $value);
             } elseif ($key == "name") {
                 array_push($cat_name, $value);
             }
         }
     }
     $cat_arr = array_combine($cat_id, $cat_name);
     return $cat_arr;
 }
Пример #11
0
 public function categoryAction()
 {
     $modelTransaction = new Application_Model_Transaction();
     $modelCategory = new Application_Model_Category();
     $this->view->categories = $modelCategory->getAll();
     if ($this->getRequest()->isPost()) {
         $category = $this->getRequest()->getPost('category', null);
         $this->view->category = $category;
         $this->view->sumCategory = $modelTransaction->getForGraphByCategory($category, date("Y"));
         $budgetCategory = $modelTransaction->getBudgetForGraphByCategory($category, date("Y"));
         $budgetCategoryFormated = array_fill(1, 12, 0);
         foreach ($budgetCategory as $category) {
             $budgetCategoryFormated[$category->month] = $category->maximum;
         }
         $this->view->budgetCategory = $budgetCategoryFormated;
         $this->view->months = array(1 => 'Janvier', 2 => 'Février', 3 => 'Mars', 4 => 'Avril', 5 => 'Mai', 6 => 'Juin', 7 => 'Juillet', 8 => 'Août', 9 => 'Septembre', 10 => 'Octobre', 11 => 'Novembre', 12 => 'Décembre');
     }
 }
Пример #12
0
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->addElementPrefixPath('Base_Validate', 'Base/Validate/', 'validate');
     $arrWeight = array();
     $arrWeight[0] = "--Select--";
     for ($i = 1; $i <= 50; $i++) {
         $arrWeight[$i] = $i;
     }
     // Add an email element
     $this->addElement('text', 'title', array('label' => 'Enter title', 'required' => true, 'class' => "form", 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Post title can not be left blank.'))), array('Alphachar', true, array('messages' => array('alnumStringNotValid' => 'Please remove special characters.'))))));
     //default selected Status option as per permission settings
     $userNs = new Zend_Session_Namespace('members');
     $userId = $userNs->userId;
     $where = "user_id='{$userId}' AND permission_id=4";
     $user_permission = new Application_Model_UserPermission();
     $user_permission = $user_permission->fetchRow($where);
     $savedUserPermission = $user_permission->getFriendGroupId();
     $selectedPermission = "public";
     if ($savedUserPermission == 4) {
         $selectedPermission = "private";
     }
     $arrStatus = array("public" => "Public", "private" => "Just Me");
     //get user permission and create new dropdwon, added by Mahipal Adhikari on 28-Mar-2011
     $group = new Application_Model_FriendGroup();
     $arrStatus = $group->getFriendGroup('--select--', null);
     $selectedPermission = $savedUserPermission;
     $this->addElement('select', 'status', array('label' => 'Permissions', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select journal post permission.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'value' => $selectedPermission, 'MultiOptions' => $arrStatus));
     //$arrStatus=Array("Public"=>"Public(Default)", "friends"=>"Friends and Family","travel"=>"Travel Mates","family"=>"Friends Family And Mates");
     $category = new Application_Model_Category();
     $arrCategory = $category->getCategory("-- Select Category --", "blog");
     $this->addElement('select', 'categoryId', array('label' => 'Choose post category', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the category.')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrCategory));
     $this->addElement('text', 'location', array('label' => 'Enter destination', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Destination can not be left blank.'))))));
     $this->addElement('textarea', 'tags', array('label' => 'Tag your post', 'required' => false, 'class' => 'blog_tag_textarea', 'rows' => '4', 'cols' => '40', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('textarea', 'content', array('label' => 'Edit your post', 'required' => true, 'rows' => '8', 'cols' => '80', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array("messages" => array('isEmpty' => 'Journal entry can not be left blank.'))))));
     $this->addElement('radio', 'comment', array('label' => 'Enable Comments ', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enable comment.')))), 'multiOptions' => array('yes' => "Yes", 'no' => "No"), 'separator' => "  ", 'decorators' => $this->elementDecorators, 'value' => 'yes'));
     $this->addElement('radio', 'publish', array('label' => 'Publish Settings', 'required' => true, 'multiOptions' => array('published' => "Publish Live", 'draft' => "Save for Later"), 'value' => 'published', 'separator' => "  ", 'decorators' => $this->elementDecorators));
     $this->addElement('select', 'weight', array('label' => 'Weight', 'class' => 'form', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the status')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrWeight));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Create Post', 'decorators' => $this->buttonDecorators));
 }
Пример #13
0
 public function editAction()
 {
     $id = $this->_request->getParam("id");
     $form = new Application_Form_Category();
     $form->getElement("picture")->setRequired(false);
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getParams())) {
             $info = $form->getValues();
             $category_model = new Application_Model_Category();
             $category_model->editCategory($info);
             $this->redirect("category/list");
         }
     }
     if (!empty($id)) {
         $category_model = new Application_Model_Category();
         $cat = $category_model->getCategoryById($id);
         $form->populate($cat[0]);
     }
     $this->view->form = $form;
     $this->render('add');
 }
Пример #14
0
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     // Add an email element
     $this->addElement('text', 'name', array('label' => 'Album Name', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the album name.'))))));
     $this->addElement('text', 'datepicker', array('label' => 'Album Date', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the album date.'))))));
     $this->addElement('hidden', 'date', array('label' => 'Date', 'filters' => array('StringTrim')))->clearDecorators();
     $arrStatus = array("public" => "Public(Default)", "private" => "Private");
     $this->addElement('select', 'status', array('label' => 'Album Status', 'class' => 'form', 'TABINDEX' => '6', 'class' => "form", 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the status')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrStatus));
     $category = new Application_Model_Category();
     $arrCategory = $category->getCategory("--Category--");
     $this->addElement('select', 'categoryId', array('label' => 'Category', 'class' => 'form', 'TABINDEX' => '6', 'class' => "form", 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the category')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'MultiOptions' => $arrCategory));
     $this->addElement('text', 'location', array('label' => 'Location', 'class' => "form", 'required' => true, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select the location'))))));
     $this->addElement('textarea', 'description', array('label' => 'Description', 'required' => false, 'rows' => '4', 'cols' => '40', 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('text', 'tags', array('label' => 'Tags', 'class' => "form", 'required' => false, 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim')));
     $this->addElement('radio', 'enableComments', array('label' => 'Enable Comments ', 'required' => true, 'TABINDEX' => '14', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'please enable comment')))), 'multiOptions' => array('yes' => "Yes", 'no' => "No"), 'separator' => "  ", 'decorators' => $this->elementDecorators, 'value' => 'yes'));
     $this->addElement('radio', 'enableLikes', array('label' => 'Enable Likes', 'required' => true, 'TABINDEX' => '14', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'please enable comment')))), 'multiOptions' => array('yes' => "Yes", 'no' => "No"), 'separator' => "  ", 'decorators' => $this->elementDecorators, 'value' => 'yes'));
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Save', 'decorators' => $this->buttonDecorators));
 }
Пример #15
0
 public function editAction()
 {
     $modelCategory = new Application_Model_Category();
     $this->view->categories = $modelCategory->getAll();
     $id = $this->getRequest()->getParam("id");
     $date = $this->getRequest()->getParam("date");
     $modelUserCategory = new Application_Model_UserCategory();
     $session = new Zend_Session_Namespace('Zend_auth');
     if (isset($id) && isset($date)) {
         $this->view->category = $modelUserCategory->getByUserCategoryDate($session->user, $id, $date);
     }
     if ($this->getRequest()->isPost()) {
         $category = $this->getRequest()->getPost('category', null);
         $maximum = $this->getRequest()->getPost('maximum', null);
         $date = $this->getRequest()->getPost('date', date('Y-m-t'));
         if ($maximum == 0) {
             $this->view->error = "Le montant de la transaction est vide";
         }
         if (!isset($this->view->error)) {
             $data_transaction = array('maximum' => $maximum, 'date' => $date, 'id_category' => $category, 'id_user' => $session->user);
             if (!isset($id)) {
                 $verifyCategory = $modelUserCategory->getById($session->user, $category, $date);
                 if (!isset($verifyCategory->id_user)) {
                     $modelUserCategory->insertUserCategory($data_transaction);
                 } else {
                     if ($verifyCategory->is_deleted == 1) {
                         $data_transaction['is_deleted'] = 0;
                         $modelUserCategory->updateUserCategory($data_transaction, $session->user, $category, $date);
                     } else {
                         $this->view->error = "Un budget pour cette catégorie est déjà existant.";
                     }
                 }
             } else {
                 $modelUserCategory->updateUserCategory($data_transaction, $session->user, $id, $date);
             }
             $this->_redirect('budget/');
         }
     }
 }
Пример #16
0
 /**
  * @Created By	: Mahipal Singh Adhikari
  * @Created On	: 30-Dec-2010
  * @Description	: Get blog category from blog ID
  * @Param		: int - blogID
  * @Return		: array if found category else return false
  */
 public function getBlogCategory($blogID)
 {
     $blogCategory = "";
     if (!is_null($blogID) && is_numeric($blogID)) {
         $blogRes = $this->find($blogID);
         if (false !== $blogRes) {
             $category_id = $blogRes->getCategoryId();
             $categoryM = new Application_Model_Category();
             $whereCond = "id={$category_id} AND type='blog'";
             $categoryRes = $categoryM->fetchRow($whereCond);
             if (false !== $categoryRes) {
                 $blogCategory = array("category_id" => $categoryRes->getId(), "category_name" => $categoryRes->getName());
                 //print_r($blogCategory);
             }
         }
     } else {
         $blogCategory = false;
     }
     return $blogCategory;
 }
Пример #17
0
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Admin_Form_Articles();
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     $model = new Application_Model_Articles();
     $page_id = $this->_getParam('id');
     $this->view->msg = "";
     if ($this->_getParam('m') == 's') {
         $this->view->msg = "Article has been saved successfully.";
     }
     //select logged in user as default seleted for Author
     $usersNs = new Zend_Session_Namespace("members");
     $author = array('userId' => $usersNs->userId);
     $form->populate($author);
     /*-----------------------------------------*/
     if ($this->getRequest()->isPost()) {
         $options = $request->getPost();
         if (trim($options['identifire']) == "") {
             $options['identifire'] = $options['title'];
         }
         if (trim($options['identifire']) != "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $sanitize->clearInputs($options['identifire']);
             $options['identifire'] = $sanitize->sanitize($options['identifire']);
         }
         if ($form->isValid($options)) {
             /*------------------------------Image Upload ---------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             $target_file_name = "";
             if ($upload->isValid()) {
                 $upload->setDestination("images/articles/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "art_" . time() . ".{$ext}";
                 $targetPath = 'images/articles/' . $target_file_name;
                 $targetPathThumb = 'images/articles/thumb_' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 64);
                 $thumb->save($targetPathThumb);
             }
             //end if
             /*------------------------------Image Upload ---------------------------*/
             $params = $options;
             $params['status'] = 1;
             if ($options["savePublish"] != "Save and Publish") {
                 $params['status'] = 0;
             }
             //commented by mahipal on 29-dec-2010 and replaced with user dropdown list
             //$usersNs = new Zend_Session_Namespace("members");
             //$params['userId']		=	$usersNs->userId;
             $params['image'] = $target_file_name;
             // file name
             $model = new Application_Model_Articles($params);
             $id = $page_id = $model->save();
             $seo_url_title = $options['identifire'];
             $articleM = new Application_Model_Articles();
             $article = $articleM->find($id);
             $seo_url = "";
             $actual_url = "/work-study-volunteer/article-detail/id/{$id}";
             if (false !== $article) {
                 $sanitizeM = new Base_Sanitize();
                 $category_id = $article->getCategoryId();
                 $categoryM = new Application_Model_Category();
                 $category = $categoryM->find($category_id);
                 if (false !== $category) {
                     //$seo_url="/work-study-volunteer/".$category->getType()."/".$sanitizeM->sanitize($category->getName())."/".$seo_url_title;
                     $seo_url = "/work-study-volunteer/" . $sanitizeM->sanitize($category->getName()) . "/" . $seo_url_title;
                 }
             }
             $seoUrlM = new Application_Model_SeoUrl();
             $seoUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
             if (false !== $seoUrl) {
                 if ($seo_url != "") {
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             } else {
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
             //$this->_helper->redirector('add','articles','admin',array('id'=>$page_id,'m'=>'s'));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Article has been saved & published successfully.";
                 $this->_helper->redirector('index', 'articles', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Article has been saved successfully.";
                     $this->_helper->redirector('index', 'articles', 'admin');
                 } else {
                     $this->_helper->redirector('edit', 'articles', 'admin', array('id' => $page_id, 'preview' => 'true'));
                 }
             }
         }
         //end if
     }
     //end if
     $this->view->form = $form;
 }
Пример #18
0
 public function seggessionPopupAction()
 {
     $this->_helper->layout->disableLayout();
     $catid = $this->_getParam('category');
     $category = "";
     $category_id = 0;
     if ($catid > 0) {
         $Category = new Application_Model_Category();
         $object = $Category->find($catid);
         if ($object) {
             $category = $object->getName();
             $category_id = $object->getId();
         }
     }
     $this->view->category = $category;
     $this->view->catid = $category_id;
     $this->view->search1 = ucwords($this->_getParam('search1'));
 }
 public function articleDetailAction()
 {
     //$this->_helper->viewRenderer->setNoRender(true);
     $blockM = new Base_View_Block();
     $path = "/layouts/scripts/page/blocks/work-study-volunteer";
     $blockM->removeBlock("work-study-volunteer-categories", 'work-study-volunteer');
     $params = $this->getRequest()->getParams();
     $article_id = $params['id'];
     $preview = false;
     $preview = $this->_getParam("preview");
     $categoryM = new Application_Model_Category();
     $articleM = new Application_Model_Articles();
     $data = $articleM->find($article_id);
     if (false != $data) {
         $this->view->article = $data;
         $this->view->preview = $preview;
         $this->view->categoryId = $categoryId = $data->getCategoryId();
         $this->view->categoryM = $categoryM->find($categoryId);
         $allarticles = $articleM->fetchAll("category_id = {$categoryId} and id != {$article_id}");
         /**
          * @Added By: Mahipal Adhikari
          * @Added On: 29-Dec-2010
          * @Description: get Article user information to display as Author
          */
         $userM = new Application_Model_User();
         $userRes = $userM->find($data->getUserId());
         $Author = "Admin";
         if (false !== $userRes) {
             $Author = $userRes->getFirstName() . " " . $userRes->getLastName();
             $this->view->author = $Author;
             $this->view->author_username = $userRes->getUsername();
         }
         if (count($allarticles) > 0) {
             $this->view->allarticles = $allarticles;
             $blocks = array("name" => "work-study-volunteer-articles", "order" => "8", "path" => $path);
             $blockM->addBlock($blocks, 'work-study-volunteer');
         }
     }
 }
Пример #20
0
 public function is_valid_categories($value)
 {
     $key = "left(soundex( name ),4)";
     $value = "left(soundex( '{$value}' ),4)";
     $conditionoperator = " = ";
     $Category = new Application_Model_Category();
     $object = $Category->fetchRow("{$key} {$conditionoperator} {$value}");
     //$query = "SELECT catid FROM #__sobi2_categories WHERE $key $conditionoperator $value";
     if (!empty($object)) {
         return true;
     } else {
         return false;
     }
 }
Пример #21
0
 public function fetchAll()
 {
     $resultSet = $this->getDbTable()->fetchAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Application_Model_Category();
         $entry->setId($row->id)->setAccountId($row->account_id)->setNickname($row->cate);
         $entries[] = $entry;
     }
     return $entries;
 }
Пример #22
0
 /**
  * @Created By : Mahipal Singh Adhikari
  * @Created On : 5-Jan-2011
  * @Description: This function used to delete user(simply change user status as 'deleted')
  */
 public function deleteAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     $catM = new Application_Model_Category();
     //$catM->delete("id={$id}");
     $catRes = $catM->find($id);
     if ($catRes) {
         $catRes->setStatus('deleted');
         $catRes->save();
         //delete all data associated with category
         $catM->deleteCategoryData($id);
         //set message
         $msg = "Category has been deleted successfully!";
     } else {
         $msg = "Invalid request, no category found!";
     }
     //set mesage in session and redirect user to index
     $_SESSION['errorMsg'] = $msg;
     $this->_helper->redirector('index', 'category', "admin", array('type' => $type));
 }
Пример #23
0
 public function categoryAction()
 {
     $session = new Zend_Session_Namespace('Zend_auth');
     $user = $session->user;
     $modelCategory = new Application_Model_Category();
     $this->view->categories = $modelCategory->getAll();
     $modelTransaction = new Application_Model_Transaction();
     $category = $this->getRequest()->getPost('category', null);
     if ($category != null) {
         $transactions = $modelTransaction->getByCategory($category, $user);
         $this->view->transactions = $transactions;
         $this->view->category = $category;
     }
 }
Пример #24
0
 public function editAction()
 {
     $id = $this->_getParam('id');
     $preview = false;
     $preview = $this->_getParam('preview');
     //echo "diana==>".base64_encode(85);
     $this->view->id = $id;
     $this->view->preview = $preview;
     $page = new Application_Model_Advice();
     $page = $page->find($id);
     $options = array('categoryId' => $page->getCategoryId(), 'title' => $page->getTitle(), 'identifire' => $page->getIdentifire(), 'name' => $page->getName(), 'content' => $page->getContent(), 'synopsis' => $page->getSynopsis(), 'metaTitle' => $page->getMetaTitle(), 'metaDescription' => $page->getMetaDescription(), 'metaKeyword' => $page->getMetaKeyword(), 'status' => $page->getStatus(), 'name' => $page->getName(), 'userId' => $page->getUserId());
     $request = $this->getRequest();
     $form = new Admin_Form_Advice();
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     //$this->view->type = $page->getType();
     $this->view->imgName = $page->getName();
     $form->populate($options);
     if ($request->isPost()) {
         $options = $request->getPost();
         if (trim($options['identifire']) == "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $options['title'];
         }
         if (trim($options['identifire']) != "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $sanitize->clearInputs($options['identifire']);
             $options['identifire'] = $sanitize->sanitize($options['identifire']);
             //update seo url table
             $seo_url_title = $options['identifire'];
             $adviceM = new Application_Model_Advice();
             $advice = $adviceM->find($id);
             $seo_url = "";
             $actual_url = "/advice/detail/id/{$id}";
             if (false !== $advice) {
                 $sanitizeM = new Base_Sanitize();
                 //$category_id	=	$advice->getCategoryId();
                 $category_id = $options['categoryId'];
                 $categoryM = new Application_Model_Category();
                 $category = $categoryM->find($category_id);
                 if (false !== $category) {
                     $seo_url = "/advice/" . $sanitizeM->sanitize($category->getName()) . "/" . $seo_url_title;
                 }
             }
             $seoUrlM = new Application_Model_SeoUrl();
             $soeUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
             if (false !== $soeUrl) {
                 if ($seo_url != "") {
                     $soeUrl->setSeoUrl($seo_url);
                     $soeUrl->save();
                 }
             } else {
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
         }
         //save data
         if ($form->isValid($options)) {
             //set previous image name if not uploaded new one
             $options['name'] = $page->getName();
             /*------------------------------ Image Upload START ---------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid()) {
                 $upload->setDestination("images/advice/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 //unlink previous uploaded image files
                 unlink("images/advice/" . $page->getName());
                 unlink("images/advice/thumb_" . $page->getName());
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('name');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "advice_" . time() . ".{$ext}";
                 $targetPath = 'images/advice/' . $target_file_name;
                 $targetPathThumb = 'images/advice/thumb_' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(128, 84);
                 $thumb->save($targetPathThumb);
                 // file name
                 $options['name'] = $target_file_name;
             }
             /*------------------------------ Image Upload END ---------------------------*/
             $options['status'] = $page->getStatus();
             if ($options["saveUnpublish"] == "Save and Unpublish") {
                 $options['status'] = 0;
             }
             if ($options["savePublish"] == "Save and Publish") {
                 $options['status'] = 1;
             }
             $page->setOptions($options);
             $page->save();
             //return $this->_helper->redirector('index','advice',"admin",Array('msg'=>base64_encode("'{$page->getTitle()}' has been updated successfully!")));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Article has been saved & published successfully.";
                 $this->_helper->redirector('index', 'advice', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Article has been saved successfully.";
                     $this->_helper->redirector('index', 'advice', 'admin');
                 } else {
                     $this->_helper->redirector('edit', 'advice', 'admin', array('id' => $id, 'preview' => 'true'));
                 }
             }
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Пример #25
0
 public function articleAction()
 {
     $ns = new Zend_Session_Namespace('user');
     $sell = new Application_Model_Sell();
     $images = new Application_Model_Image();
     if (empty($ns->data)) {
         $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'error', 'type' => 'page'), null, true));
     }
     if ($this->_request->isPost()) {
         if ($this->_getParam('type') == 'ajout') {
             $title = $_POST['productTitle'];
             // image data
             $image = @file_get_contents($_FILES['image']['tmp_name']);
             $nameImage = $_FILES['image']['name'];
             // sell data
             $quantity = $_POST['productQuantite'];
             $category = $_POST['sous-rubrique-hidden'];
             $price = $_POST['productPrix'];
             $descritptionCourt = $_POST['productDescritptionCourte'];
             $descritption = $_POST['descritption'];
             $idUser = $ns->data['id_user'];
             // recuperation de idSell après insertion
             $idSell = $sell->addSell($title, $quantity, $category, $price, $descritptionCourt, $descritption, $idUser);
             // insertion de l'image grace a l'idSell
             $ResultImage = $images->addImage($idSell, $image, $nameImage);
             if ($ResultImage == true) {
                 $this->_redirect($this->view->url(array('controller' => 'user', 'action' => 'article', 'message' => 'done'), null, true));
             }
         }
         if ($this->_getParam('type') == 'update') {
             $idSell = $_POST['idSell'];
             $quantity = $_POST['quantity'];
             $price = $_POST['price'];
             $sell->updatePriceQuantity($quantity, $price, $idSell);
             $this->view->message = "Modification(s) sauvegard�(s)";
         }
     }
     $commande = new Application_Model_Command();
     $commandeline = new Application_Model_Commandline();
     //Les produits de l'utilisateur achetés par d'autre clients.
     //$this->view->commande = $commande->getIdCommand($ns->data['id_user']);
     // Achat du client
     $tabCommand = $commande->getIdCommand($ns->data['id_user']);
     $this->view->command = $tabCommand;
     $this->view->commandeLine = $commandeline->getCommmandLine($tabCommand);
     //var_dump($this->view->commandeLine); die;
     $sell = new Application_Model_Sell();
     $images = new Application_Model_Image();
     $categorys = new Application_Model_Category();
     $user = new Application_Model_User();
     //Historique des vente effectué par un vendeur : Visualisation des commandes des clients
     $idProduct = $sell->getIdProductBySeller($ns->data['id_user']);
     $Commande = $commandeline->getCommandLineByArrayIdProduct($idProduct, true);
     $detailCommand = $commandeline->getCommandLineByArrayIdProduct($idProduct);
     $this->view->commandVente = $Commande;
     $complementCommand = $commandeline->getCommandLineByArrayIdProduct($idProduct);
     $this->view->complementCommande = $complementCommand;
     $this->view->detailCommand = $detailCommand;
     $infoUser = $user->getUserByCommandLine($Commande);
     $this->view->infoBuyer = $infoUser;
     $this->view->category = $categorys->getRubrique();
     $this->view->souscategory = $categorys->getSousRubrique();
     $table = $sell->getUserSell($ns->data['id_user']);
     foreach ($table as &$value) {
         $value['image'] = base64_encode($value['image']);
         $value['name_image'] = pathinfo($table['name_image'], PATHINFO_EXTENSION);
     }
     $this->view->articles = $table;
 }
Пример #26
0
 public function modifyAction()
 {
     $ns = new Zend_Session_Namespace('user');
     if (empty($ns->data)) {
         $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'error', 'type' => 'page'), null, true));
     }
     $fiche = $this->_getParam('fiche');
     $article = new Application_Model_Sell();
     $ns = new Zend_Session_Namespace('user');
     $sell = new Application_Model_Sell();
     $images = new Application_Model_Image();
     $categorys = new Application_Model_Category();
     $this->view->souscategory = $categorys->getSousRubrique();
     $this->view->category = $categorys->getRubrique();
     $sousRubriqueChoisi = $categorys->getSousRubrique();
     $produit = $article->getArticle($fiche);
     foreach ($sousRubriqueChoisi as $s) {
         if ($produit[0]['id_category'] == $s['id_category']) {
             $sr = $s['label_category'];
         }
     }
     $this->view->sr = $sr;
     if ($this->_request->isPost()) {
         $title = $_POST['title'];
         if ($title == "") {
             $title = $produit[0]['title'];
         }
         // image data
         $image = @file_get_contents($_FILES['image']['tmp_name']);
         $nameImage = $_FILES['image']['name'];
         // sell data
         $quantity = $_POST['quantity'];
         $category = $_POST['category'];
         $price = $_POST['price'];
         $descritptionCourt = $_POST['description_courte'];
         $description = $_POST['description'];
         $idUser = $ns->data['id_user'];
         $sousrubrique = $_POST['sous-rubrique-hidden'];
         if ($sousrubrique == "") {
             $sousrubrique = $produit[0]['id_category'];
         }
         // recuperation de idSell après modification
         $sell->updateSell($title, $image, $quantity, $price, $descritptionCourt, $description, $fiche, $sousrubrique);
         // insertion de l'image grace a l'idSell
         $produit = $article->getArticle($fiche);
         if ($nameImage != '') {
             $ResultImage = $images->updateImage($produit[0]['id_image'], $image, $nameImage);
         }
         if ($ResultImage == true) {
             $this->_redirect($this->view->url(array('controller' => 'article', 'action' => 'modify', 'fiche' => $fiche, 'message' => 'done'), null, true));
         }
     }
     $this->view->produit = $produit;
     foreach ($this->view->produit as &$p) {
         $p['img64'] = base64_encode($p['image']);
         $p['type'] = pathinfo($p['name_image'], PATHINFO_EXTENSION);
     }
 }
Пример #27
0
 public function indexAction()
 {
     $this->_helper->layout->setLayout('journal-layout-2column');
     $userNs = new Zend_Session_Namespace('members');
     $this->view->userId = $loggedin_id = $userNs->userId;
     $settings = new Admin_Model_GlobalSettings();
     $page_size = $settings->settingValue('journal_page_size');
     $blogm = new Application_Model_Blog();
     $params = $this->getRequest()->getParams();
     //print_r($params);
     /*
     //Display only Public & Published journals
     $where = "publish='published' AND status='public' ";
     
     //search by Keyword
     if(isset($params['search-jrnl']) && $params['search-jrnl']!='Search by Keyword')
     {
     	$searchkey = $params['search-jrnl'];
     	$where .= " AND (title LIKE '%$searchkey%' OR tags LIKE '%$searchkey%' OR content LIKE '%$searchkey%' ";
     	$this->view->searchjrnl = $searchkey;
     	
     	//search by Author as well while searching by keyword
     	$user_where_sql  = "status='active'";
     	$user_where_sql .= " AND (username like '%$searchkey%' OR CONCAT(first_name,' ',last_name ) LIKE '%$searchkey%')";
     	$UserM	=	new Admin_Model_User();
     	$UserM	=	$UserM->fetchAll($user_where_sql);
     	if(false!==$UserM)
     	{
     		if(count($UserM)>0)
     		{
     			foreach($UserM as $userrow)
     			{
     				$userarray[] = $userrow->getId();
     			}
     			$userstr  = implode(',',$userarray);
     			$where .= " OR user_id IN ($userstr)";
     		}				 
     	}
     	$where .= ")";
     }
     
     //search by Location
     if(isset($params['search-city']) && $params['search-city']!='In City / Place')
     {
     	$searchcity = $params['search-city'];
     	$where .= " AND location LIKE '%$searchcity%'";
     	$this->view->searchcity  = $searchcity;
     }
     
     //search by Category
     if(isset($params['search-filtr']) && $params['search-filtr']!='')
     {
     	$searchfiltr = $params['search-filtr'];
     	$where .= " AND category_id = '$searchfiltr'";
     	$this->view->searchfiltr  = $searchfiltr;
     }
     
     //search by Tag cloud
     if(isset($params['search-cloud']) && $params['search-cloud']!='')
     {
     	$searchcloud = $params['search-cloud'];
     	$where .= " AND tags LIKE '%$searchcloud%'";
     	$this->view->searchcloud  = $searchcloud;
     }
     $data	=	$blogm->fetchAll($where, "addedon DESC",$page_size);
     */
     //search by Keyword
     $whereSearchSQL = "";
     if (isset($params['search-jrnl']) && $params['search-jrnl'] != 'Search by Keyword') {
         $searchkey = $params['search-jrnl'];
         $whereSearchSQL .= " AND (b.title LIKE '%{$searchkey}%' OR b.tags LIKE '%{$searchkey}%' OR b.content LIKE '%{$searchkey}%' ";
         $this->view->searchjrnl = $searchkey;
         //search by Author as well while searching by keyword
         $user_where_sql = "status='active'";
         $user_where_sql .= " AND (username like '%{$searchkey}%' OR CONCAT(first_name,' ',last_name ) LIKE '%{$searchkey}%')";
         $UserM = new Admin_Model_User();
         $UserM = $UserM->fetchAll($user_where_sql);
         if (false !== $UserM) {
             if (count($UserM) > 0) {
                 foreach ($UserM as $userrow) {
                     $userarray[] = $userrow->getId();
                 }
                 $userstr = implode(',', $userarray);
                 $whereSearchSQL .= " OR b.user_id IN ({$userstr})";
             }
         }
         $whereSearchSQL .= ")";
     }
     //search by Location
     if (isset($params['search-city']) && $params['search-city'] != 'In City / Place') {
         $searchcity = $params['search-city'];
         $whereSearchSQL .= " AND b.location LIKE '%{$searchcity}%'";
         $this->view->searchcity = $searchcity;
     }
     //search by Category
     if (isset($params['search-filtr']) && $params['search-filtr'] != '') {
         $searchfiltr = $params['search-filtr'];
         $whereSearchSQL .= " AND b.category_id = '{$searchfiltr}'";
         $this->view->searchfiltr = $searchfiltr;
     }
     //search by Tag cloud
     if (isset($params['search-cloud']) && $params['search-cloud'] != '') {
         $searchcloud = $params['search-cloud'];
         $whereSearchSQL .= " AND b.tags LIKE '%{$searchcloud}%'";
         $this->view->searchcloud = $searchcloud;
     }
     $sSQL = "SELECT b.* FROM blog AS b";
     $sSQL .= " JOIN journal AS j ON j.user_id = b.user_id";
     //$sSQL .= " WHERE b.publish='published' AND b.status=5";
     $sSQL .= " WHERE b.publish='published'";
     $sSQL .= " AND j.publish='published' AND j.status='public'";
     if ($whereSearchSQL != "") {
         $sSQL .= $whereSearchSQL;
     }
     $sSQL .= " ORDER BY b.addedon DESC";
     //echo "<br />".$sSQL;exit;
     $page = $this->_getParam('page', 1);
     $pageObj = new Base_Paginator();
     //$data	=	$pageObj->fetchPageDataRaw($sSQL, $page, $page_size);
     $data = $pageObj->fetchBlogData($sSQL, $page, $page_size);
     $this->view->data = $data;
     /******* Featured blog post START ********/
     //$where_fea = "publish='published' AND status=5 AND featured=1";
     $where_fea = "publish='published' AND featured=1";
     $data_fea = $blogm->fetchAll($where_fea, "updatedon DESC");
     $this->view->data_fea = $data_fea;
     /******* Featured blog post END ********/
     //Get Jouranl Post Category
     $categoryM = new Application_Model_Category();
     $this->view->journalCategory = $categoryM->getJournalCategory();
 }
Пример #28
0
 public function getWorkCategories($option = null)
 {
     $obj = new Application_Model_Category();
     $entries = $obj->fetchAll();
     $arrContinent = array();
     if (!is_null($option)) {
         $arrContinent[''] = $option;
     }
     foreach ($entries as $entry) {
         $arrContinent[$entry->getId()] = $entry->getName();
     }
     return $arrContinent;
 }
Пример #29
0
 /**
  * @Created By : Mahipal Singh Adhikari
  * @Created On : 10-Feb-2011
  * Description : Search advice
  */
 public function searchAction()
 {
     $params = $this->getRequest()->getParams();
     $where = "status='1'";
     $order = "addedon DESC";
     $categoryM = new Application_Model_Category();
     //search by keyword
     if (isset($params['search-strg'])) {
         if ($params['search-strg'] != '' && $params['search-strg'] != 'Search by Keyword') {
             $keyword = $params['search-strg'];
             $where .= " AND (title LIKE '%{$keyword}%' OR content LIKE '%{$keyword}%' OR synopsis LIKE '%{$keyword}%')";
             $this->view->searchstr = $keyword;
         }
     }
     //search by category
     if (isset($params['category_id']) && $params['category_id'] != '') {
         $this->view->category_id = $category_id = $params['category_id'];
         $categorydata = $categoryM->find($category_id);
         $category_id = $categorydata->getId();
         $this->view->categoryName = $categorydata->getName();
         $where .= " AND category_id = {$category_id}";
     }
     $adviceM = new Application_Model_Advice();
     //$settings	=	new Admin_Model_GlobalSettings();
     //$page_size	=	$settings->settingValue('pagination_size');
     //$page_size	=	1;
     //$page		=	$this->_getParam('page',1);
     //$pageObj	=	new Base_Paginator();
     //$paginator	=	$pageObj->fetchPageData($adviceM, $page, $page_size, $where);
     //$this->view->total		=	$pageObj->getTotalCount();
     //$this->view->advices	=	$paginator;
     $adviceRes = $adviceM->fetchAll($where, $order);
     $this->view->total = count($adviceRes);
     $this->view->advices = $adviceRes;
     $this->view->categoryM = $categoryM;
 }