/**
  * Allows a user to view the list of workshop categories
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('add' => $this->_helper->hasAccess('add'), 'edit' => $this->_helper->hasAccess('edit'));
     $category = new Category();
     $categories = $category->fetchAll(null, 'name');
     $this->view->categories = $categories;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->_helper->pageTitle('workshop-category-index:title');
 }
Example #2
0
 /**
  * The main workshop page.  It has the list of all the workshops that are 
  * available in the system.
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('workshopList' => $this->_helper->hasAccess('workshop-list'));
     $get = Zend_Registry::get('getFilter');
     $form = new Zend_Form();
     $form->setAttrib('id', 'workshopForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form'));
     $searchField = $form->createElement('text', 'search', array('label' => 'workshop-index-index:searchWorkshops'));
     $searchField->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($get->search) ? $get->search : '');
     $category = new Category();
     $categoryList = $category->fetchAll(null, 'name');
     $categories = $form->createElement('select', 'categoryId');
     $categories->addMultiOption('', '-- Search By Category -- ');
     foreach ($categoryList as $c) {
         $categories->addMultiOption($c['categoryId'], $c['name']);
     }
     $categories->setValue(isset($get->categoryId) ? $get->categoryId : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'workshop-index-index:search'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $form->addElements(array($searchField, $categories));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit));
     $this->view->form = $form;
     $searchTerm = new Search_Term();
     $workshops = array();
     if ($get->search != '' || $get->categoryId != 0) {
         $workshop = new Workshop();
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         if ($get->search != '') {
             $query->addTerm(new Zend_Search_Lucene_Index_Term($get->search), true);
         }
         if ($get->categoryId != 0) {
             $query->addTerm(new Zend_Search_Lucene_Index_Term($get->categoryId, 'categoryId'), true);
         }
         $workshops = $workshop->search($query);
         $searchTerm->increment($get->search);
         $this->view->searchTerm = $get->search;
     }
     $this->view->workshops = $workshops;
     $this->view->topTerms = $searchTerm->getTopSearchTerms(10);
     $this->view->layout()->setLayout('search');
     $this->view->layout()->rightContent = $this->view->render('index/top-terms.phtml');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css');
     $this->_helper->pageTitle("workshop-index-index:title");
 }
 public function getAction()
 {
     $this->file_name = FTP_PATH . "/sitemap";
     $c_count = 1000;
     $Product = new Product();
     $Category = new Category();
     $i = 0;
     $Tempval = new Tempval();
     $last_update = $Tempval->get('last-update');
     $last_update = $last_update['val'];
     $last_update = $last_update ? $last_update : time() - 24 * 60 * 60;
     $res = '';
     /*$res .= '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';*/
     // ------------------- TOYS -------------------------------
     $off = 0;
     do {
         $toys = $Product->fetchAll(null, null, $c_count, $off)->toArray();
         $i += count($toys);
         $off += $c_count;
         foreach ($toys as $toy) {
             $this->make_res(array('loc' => DOMAIN_PATH . '/toy/detail/toy_id/' . $toy['id'], 'lastmod' => date('Y-m-d', $last_update), 'priority' => '0.8'));
             /*
             $res .= '<url>';
             $res .= '<loc>'.DOMAIN_PATH.'/toy/detail/toy_id/'.$toy['id'].'/</loc>';
             $res .= '<lastmod>'.date('Y-m-d',$last_update).'</lastmod>';
             $res .= '<changefreq>weekly</changefreq>';
             $res .= '<priority>0.8</priority>';
             $res .= '</url>';
             */
         }
     } while (count($toys) > 0);
     // ----------------------------------------------------------
     // ------------------ CATEGORIES ----------------------------
     $off = 0;
     do {
         $cats = $Category->fetchAll(null, null, $c_count, $off)->toArray();
         $off += $c_count;
         foreach ($cats as $cat) {
             $this->make_res(array('loc' => DOMAIN_PATH . '/category/detail-list/cat_id/' . $cat['id'], 'lastmod' => date('Y-m-d', $last_update), 'priority' => '0.5'));
             /*
             $res .= '<url>';
             $res .= '<loc>'.DOMAIN_PATH.'/category/detail-list/cat_id/'.$cat['id'].'/</loc>';
             $res .= '<lastmod>'.date('Y-m-d',$last_update).'</lastmod>';
             $res .= '<changefreq>weekly</changefreq>';
             $res .= '<priority>0.5</priority>';
             $res .= '</url>';
             */
         }
     } while (count($cats) > 0);
     // ----------------------------------------------------------
     // ----------- MAIN PAGE ------------------------------------
     $this->make_res(array('loc' => DOMAIN_PATH, 'lastmod' => date('Y-m-d', $last_update), 'priority' => '0.9'), true);
     /*
     $res .= '<url>';
     $res .= '<loc>'.DOMAIN_PATH.'/</loc>';
     $res .= '<lastmod>'.date('Y-m-d',$last_update).'</lastmod>';
     $res .= '<changefreq>weekly</changefreq>';
     $res .= '<priority>0.9</priority>';
     $res .= '</url>';
     */
     // ----------------------------------------------------------
     //$res .='</urlset>';
     /*
     $f = fopen(FTP_PATH.'/sitemap.xml','wb');
     fwrite($f,$res);
     fclose($f);
     */
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     print_r('OK');
 }
Example #4
0
 public function oldgetAction()
 {
     $c_count = 1000;
     $Product = new Product();
     $Category = new Category();
     $i = 0;
     $Tempval = new Tempval();
     $last_update = $Tempval->get('last-update');
     $last_update = $last_update['val'];
     $last_update = $last_update ? $last_update : time() - 24 * 60 * 60;
     $res = '';
     $res .= '<?xml version="1.0" encoding="windows-1251"?><!DOCTYPE yml_catalog SYSTEM "shops.dtd">';
     $res .= '<yml_catalog date="' . date('Y-m-d H:i', $last_update) . '">';
     $res .= '<shop>';
     $res .= '<name>Интернет-магазин Игрушки деткам.РУ</name>';
     $res .= '<url>http://igrushki-detkam.ru</url>';
     // ------------------- CURRENCY ----------------------------------------
     $res .= '<currencies><currency id="RUR" rate="1"/></currencies>';
     // ------------------ CATEGORIES ---------------------------------------
     $res .= '<categories>';
     $cats = $Category->fetchAll(null, null)->toArray();
     foreach ($cats as $cat) {
         $res .= '<category id="' . $cat['id'] . '"' . ($cat['parentId'] ? ' parentId="' . $cat['parentId'] . '"' : '') . '>' . $cat['name'] . '</category>';
     }
     $res .= '</categories>';
     // ---------------------------------------------------------------------
     // ------------------- OFFERS ------------------------------------------
     $res .= '<offers>';
     $st = $Product->get_all_by_fetch_each();
     while ($toy = $st->fetch()) {
         $res .= '<offer id="' . $toy['id'] . '" type="vendor.model" available="true">';
         $res .= '<url>' . DOMAIN_PATH . '/toy/detail/toy_id/' . $toy['id'] . '/</url>';
         $res .= '<price>' . $toy['price'] . '</price>';
         $res .= '<currencyId>RUR</currencyId>';
         $res .= '<categoryId>' . $toy['categoryId'] . '</categoryId>';
         $res .= '<picture>' . $toy['picture'] . '</picture>';
         $res .= '<vendor><![CDATA[' . $toy['producer'] . ']]></vendor>';
         $res .= '<model><![CDATA[' . $toy['name'] . ']]></model>';
         $res .= '<description><![CDATA[' . $toy['description'] . ']]></description>';
         $res .= '</offer>';
     }
     $res .= '</offers>';
     // ----------------------------------------------------------
     $res .= '</shop>';
     $res .= '</yml_catalog>';
     $f = fopen(FTP_PATH . '/ymlcatalog.xml', 'wb');
     fwrite($f, $res);
     fclose($f);
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     print_r('OK');
 }
Example #5
0
 /**
  * Gets the form for adding and editing a location
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     require_once APPLICATION_PATH . '/models/Workshop/Category.php';
     $form = new Zend_Form();
     $form->setAttrib('id', 'workshopForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $title = $form->createElement('text', 'title', array('label' => 'Workshop Title:'));
     $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['title']) ? $values['title'] : '');
     $group = $form->createElement('select', 'group', array('label' => 'Offered By:'));
     $group->addMultiOption('groupId1', 'Test Group1');
     $group->addMultiOption('groupId2', 'Test Group2');
     $group->setValue(isset($values['group']) ? $values['group'] : null);
     //TODO: change this to add all the enabled groups in the database
     $tags = $form->createElement('text', 'tags', array('label' => 'Tags:'));
     $tags->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['tags']) ? implode(', ', $values['tags']) : '');
     $status = $form->createElement('select', 'status', array('label' => 'Status:'));
     $status->addMultiOption('enabled', 'Enabled');
     $status->addMultiOption('disabled', 'Disabled');
     $status->setValue(isset($values['status']) ? $values['status'] : 'enabled');
     $category = new Category();
     $categoryList = $category->fetchAll(null, 'name');
     $categories = $form->createElement('select', 'categoryId', array('label' => 'Worshop Category: '));
     $categories->setRequired(true);
     foreach ($categoryList as $category) {
         $categories->addMultiOption($category->categoryId, $category->name);
     }
     $categories->setValue(isset($values['categoryId']) ? $values['categoryId'] : '');
     $prerequisites = $form->createElement('textarea', 'prerequisites', array('label' => 'workshop-index-add:preRequisites'));
     $prerequisites->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['prerequisites']) ? $values['prerequisites'] : '');
     $featured = $form->createElement('checkbox', 'features', array('label' => 'Featured?'));
     $featured->setValue(isset($values['featured']) ? $values['featured'] : null);
     $description = $form->createElement('textarea', 'description', array('label' => 'Description:'));
     $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['description']) ? $values['description'] : '');
     $editors = $form->createElement('multiselect', 'editors', array('label' => 'Workshop Editors:'));
     $editors->setRequired(false)->setAttrib('size', '10');
     $account = new Ot_Account();
     $accounts = $account->fetchAll(null, array('lastName', 'firstName'));
     foreach ($accounts as $a) {
         $editors->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')');
     }
     $editors->setValue(isset($values['editors']) ? $values['editors'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($status, $title, $categories, $group, $tags, $description, $prerequisites, $editors));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     if (isset($values['workshopId'])) {
         $workshopId = $form->createElement('hidden', 'workshopId');
         $workshopId->setValue($values['workshopId']);
         $workshopId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($workshopId);
     }
     return $form;
 }