public function categoryWidget($side_space = true)
    {
        $language_id = Zend_Registry::get('languageId');
        $cache = Zend_Registry::get('cache');
        if (($widget = $cache->load('widget_category')) === FALSE) {
            $title = $this->view->translate('culture_category');
            $tbl_category = new Model_DbTable_Category();
            $categories = $tbl_category->getAllParentCategoryIdNameByLangId($language_id)->toArray();
            $list = "<ul>";
            foreach ($categories as $category) {
                $link = $this->view->baseUrl("category/see-category/{$category['category_id']}");
                $list .= "<a href='{$link}'><li>{$category['name']}</li></a>";
            }
            $list .= "<div class='clear'></div>";
            $list .= "</ul>";
            if ($side_space) {
                $side_space_class = 'side-space';
            }
            $widget = <<<HTML
        <div class="widget-half-list {$side_space_class}">      
          <h2>{$title}</h2>            
          {$list}      
        </div>
HTML;
            $cache->save($widget);
        }
        return $widget;
    }
 /**
  * IS: Parameter id, sortby, dan sortorder terdeklarasi
  * FS: Mengirimkan ke viewer: pageTitle, category, destination, areaDb
  * Desc: Fungsi untuk menampilkan detail activity dan menampilkan destinasi2
  *       yang termasuk activity tersebut
  */
 public function detailAction()
 {
     // Set layout
     $this->_helper->layout->setLayout('kebudayaan');
     // Param
     $id = $this->_getParam('id');
     $sortBy = $this->_getParam('sortby');
     $sortOrder = $this->_getParam('sortorder', 'desc');
     $page = $this->_getParam('page');
     $title = null;
     // Model
     $categoryDb = new Model_DbTable_Category();
     $destDescDb = new Model_DbTable_DestinationDescription();
     $areaDb = new Model_DbTable_Area();
     // Data
     $destinationQuery = $destDescDb->getSearch('', '', $id, $this->_languageId, array('sort_by' => $sortBy, 'sort_order' => $sortOrder));
     $paginator = Zend_Paginator::factory($destinationQuery);
     $paginator->setItemCountPerPage(8);
     $paginator->setCurrentPageNumber($page);
     $category = $categoryDb->getByLangAndId($id, $this->_languageId);
     $this->view->headTitle()->prepend($category['name']);
     $this->view->category = $category;
     $this->view->paginator = $paginator;
     $this->view->culture_chunk = array_chunk(iterator_to_array($paginator), 2);
     $this->view->languageId = $this->_languageId;
     $this->view->languageID = $this->_languageId;
     $this->view->langId = $this->_languageId;
     $this->view->getImg = function ($file) {
         return UPLOAD_FOLDER . $FILE;
     };
     array_unshift($this->_meta, $category['name'], "kategori kebudayaan", "kategori budaya");
     $this->view->headMeta()->appendName('keywords', join(', ', $this->_meta));
     $this->view->headMeta()->appendName('description', "Kebudayaan Indonesia - Laman referensi kebudayaan Indonesia. Turut mewujudkan bangsa Indonesia yang cerdas dan berbudaya");
     $this->view->headLink()->headLink(array('rel' => 'canonical', 'href' => Zend_Controller_Front::getInstance()->getRequest()->getScheme() . '://' . Zend_Controller_Front::getInstance()->getRequest()->getHttpHost() . $this->view->url(array('id' => $category['category_id'], 'slug' => $this->view->makeUrlFormat($category['name'])), $this->_languageId == 1 ? 'subkategori' : 'subcategory', true)), 'PREPEND');
 }
 /**
  * Fungsi inisialisasi form
  */
 public function init()
 {
     parent::init();
     $langId = Zend_Registry::get('languageId');
     if ($langId == 2) {
         $textisland = 'Category';
         $textseeloc = 'See Location';
         $textselisl = 'Select Category';
     } else {
         $textisland = 'Kategori';
         $textseeloc = 'Lihat Lokasi';
         $textselisl = 'Pilih Kategori';
     }
     // Form Attribute
     $this->setMethod('post');
     $this->addAttribs(array('id' => 'mapLocationForm', 'action' => '', 'accept-charset' => 'utf-8'));
     // -> Island
     $categoryDb = new Model_DbTable_Category();
     $data = $categoryDb->getAllCategoryIdNameByLangIdForSelect($this->_languageId, $textselisl);
     $category = $this->createElement('select', 'category');
     $category->setLabel($textisland)->setMultiOptions($data)->setDecorators($this->elementDecorators);
     $this->addElement($category);
     // -> Submit
     $submit = $this->createElement('submit', 'submitcategory');
     $submit->setLabel($textseeloc)->setDecorators($this->buttonDecorators);
     $submit->setAttrib('class', 'button button-grey');
     $this->addElement($submit);
 }
 /**
  * IS: Parameter id, sortby, dan sortorder terdeklarasi
  * FS: Mengirimkan ke viewer: pageTitle, category, destination, areaDb
  * Desc: Fungsi untuk menampilkan detail activity dan menampilkan destinasi2
  *       yang termasuk activity tersebut
  */
 public function detailAction()
 {
     // Set layout
     $this->_helper->layout->setLayout('kebudayaan');
     // Param
     $id = $this->_getParam('id');
     $sortBy = $this->_getParam('sortby');
     $sortOrder = $this->_getParam('sortorder', 'desc');
     $title = null;
     // Model
     $categoryDb = new Model_DbTable_Category();
     $destDescDb = new Model_DbTable_DestinationDescription();
     $areaDb = new Model_DbTable_Area();
     // Data
     $destinationQuery = $destDescDb->getSearch('', '', $id, $this->_languageId, array('sort_by' => $sortBy, 'sort_order' => $sortOrder));
     $category = $categoryDb->getByLangAndId($id, $this->_languageId);
     $this->_generateSorter($sortBy, $sortOrder);
     // View
     $this->view->pageTitle = $category['name'];
     $this->view->category = $category;
     $this->view->count = count($destinationQuery);
     $this->view->destination = $destinationQuery;
     // $this->view->destination = parent::setPaginator($destinationQuery);
     $this->view->areaDb = $areaDb;
 }
Exemplo n.º 5
0
class MapController extends Budpar_Controller_Common
{
    /**
     * IS: -
     * FS: -
     * Desc: Fungsi inisialisasi
     */
    public function init()
    {
        parent::init();
    }
    /**
     * IS: Parameter id terdeklarasi
     * FS: Mengirimkan ke viewer: pageTitle, mapLocationForm, mapDestForm, poi,
     *     categoriesParent
     * Desc: Fungsi untuk menampilkan peta
     */
    public function indexAction()
    {
        $this->_helper->layout->setLayout('kebudayaan');
        // Param
        if ($this->_hasParam('id')) {
            $this->view->id = $this->_getParam('id');
            //echo $this->view->id . ' tes';
        }
        // Form
        $mapLocationForm = new Form_MapLocationForm();
        $mapDestForm = new Form_MapDestForm();
        $mapCategoryForm = new Form_MapCategoryForm();
Exemplo n.º 6
0
 public function setCategorySelectData($language_id = 1)
 {
     $table_category = new Model_DbTable_Category();
     $category_data = $table_category->getAllParentIdNameForSelectByLangId($language_id);
     $this->mainCategory = $this->createElement('select', 'mainCategory', $category_data);
     $this->mainCategory->removeDecorator('HtmlTag');
     $this->mainCategory->removeDecorator('DtDdWrapper');
     $this->mainCategory->removeDecorator('Label');
 }
Exemplo n.º 7
0
 public function setCategoryParent($language_id)
 {
     $tableCategory = new Model_DbTable_Category();
     $category = $tableCategory->getAllParentIdNameForSelectByLangId($language_id, TRUE, '-');
     $this->categoryParent = $this->createElement('select', 'categoryParent', $category);
     $this->categoryParent->removeDecorator('HtmlTag');
     $this->categoryParent->removeDecorator('DtDdWrapper');
     $this->categoryParent->removeDecorator('Label');
     $this->categoryParent->setAttrib('onchange', 'recommendSize();');
 }
 /**
  * Fungsi inisialisasi form
  */
 public function init()
 {
     parent::init();
     // Form Attribute
     $this->setMethod('get');
     $this->addAttribs(array('id' => 'activitySearchForm', 'action' => $this->_baseUrlHelper->baseUrl() . '/destination/search'));
     $this->setAttrib('accept-charset', 'utf-8');
     // -> Activities
     $categoryDb = new Model_DbTable_Category();
     $category = $categoryDb->getAllButNotMainCategoryForForm($this->_languageId);
     $activity = $this->createElement('select', 'destActivity');
     $activity->setLabel('Activity')->setMultiOptions($category)->setDecorators($this->elementDecorators);
     $this->addElement($activity);
 }
 public function subCategoryAction()
 {
     // AJAX
     if ($this->_request->isXmlHttpRequest()) {
         // Disable layout dan view
         $this->_helper->layout()->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $parentCategoryId = $this->_getParam('parent_category');
         $categoryDb = new Model_DbTable_Category();
         $parentCategory = $categoryDb->getAllWithDescByIdLang($parentCategoryId, $this->_languageId);
         $category = new Model_Category();
         $result = $category->getSubCategoriesForChart($parentCategoryId, $this->_languageId);
         $result['title'] = $this->view->translate('Total Culture per Sub Category') . ' ' . $parentCategory['name'];
         $result['xLabel'] = $this->view->translate('Category');
         $result['yLabel'] = $this->view->translate('Total');
         echo json_encode($result);
     }
 }
Exemplo n.º 10
0
     }
     return $result;
 }
 /**
  * Fungsi untuk menampilkan data kategori utama ke chart
  * 
  * @param int $language_id
  * @return array
  */
 public function getMainCategoriesForChart($language_id)
 {
     $categoryDb = new Model_DbTable_Category();
     $categories = $categoryDb->getMainCategoriesWithCounter($language_id)->toArray();
     return $categories;
 }
 /**
  * Fungsi untuk menampilkan data sub kategori berdasarkan parent kategori
  * 
Exemplo n.º 11
0
         }
         $result['title'] = $this->view->translate('Total Culture per Main Category');
         $result['xLabel'] = $this->view->translate('Category');
         $result['yLabel'] = $this->view->translate('Total');
         echo json_encode($result);
     }
 }
 public function subCategoryAction()
 {
     // AJAX
     if ($this->_request->isXmlHttpRequest()) {
         // Disable layout dan view
         $this->_helper->layout()->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $parentCategoryId = $this->_getParam('parent_category');
         $categoryDb = new Model_DbTable_Category();
         $parentCategory = $categoryDb->getAllWithDescByIdLang($parentCategoryId, $this->_languageId);
         $category = new Model_Category();
         $categories = $category->getSubCategoriesForChart($parentCategoryId, $this->_languageId);
         $result = array();
         foreach ($categories as $category) {
             $result['category'][] = $category['name'];
             $result['total'][] = array('', (int) $category['total_culture'], $this->view->url(array('id' => $category['category_id'], 'slug' => $this->view->makeUrlFormat($category['name'])), $this->_languageId == 1 ? 'subkategori' : 'subcategory'));
 /**
  * IS: Terdeklarasinya filter dan param di session, dan page_row
  * FS: Mengirimkan ke viewer: cleanUrl, message, filter_alert, page_row,
  *     all_category, dan paginator
  * Desc: Mengatur aksi yang dilakukan untuk halaman index event
  */
 public function indexAction()
 {
     //variable initiation and instance creation
     $this->view->cleanurl = $this->_cleanUrl;
     //get messages from CRUD process
     $message = $this->_flash->getMessages();
     if (!empty($message)) {
         $this->view->message = $message;
     }
     //create table instances
     $table_event = new Model_DbTable_Event();
     $table_category = new Model_DbTable_Category();
     //set variable initial value
     $filter = null;
     $new_search = FALSE;
     //get params for the filter
     if ($this->getRequest()->isPost()) {
         $filter = $_POST['filterPage'];
         $new_search = TRUE;
         $this->_paginator_sess->filter = $filter;
         switch ($filter) {
             case 0:
                 $param = null;
             case 1:
                 $param = $_POST['filterName'];
                 break;
             case 2:
                 $param = $_POST['filterDestination'];
                 break;
             case 3:
                 $param = $_POST['filterCategory'];
                 break;
             case 4:
                 $param = $_POST['filterDate1'];
                 $param2 = $_POST['filterDate2'];
                 break;
         }
         $this->_paginator_sess->param = $param;
     }
     //set paginator for list of destination data
     $filter = $this->_paginator_sess->filter;
     $param = $this->_paginator_sess->param;
     if (isset($param2)) {
         $select = $table_event->getQueryAllByLang($filter, $param, $param2, 2);
     } else {
         $select = $table_event->getQueryAllByLang($filter, $param, null, 2);
     }
     if ($page_row != null) {
         $paginator = parent::setPaginator($select, $page_row);
     } else {
         $paginator = parent::setPaginator($select);
     }
     //if this is a new search then return the page number back to the 1st page
     if ($new_search) {
         $paginator->setCurrentPageNumber(1);
     }
     //send data to the view
     $this->view->paginator = $paginator;
     $filter_data = $table_category->getAllParentCategoryIdNameByLangId(2);
     $this->view->all_category = $filter_data;
     /** Return alert to view on filter selected */
     switch ($filter) {
         case 0:
             $filter_alert = "Show all events";
             break;
         case 1:
             $filter_alert = "Events which name with keyword '" . $param . "'";
             break;
         case 2:
             $filter_alert = "Events that related to '" . $param . "'";
             break;
         case 3:
             foreach ($filter_data as $category) {
                 $parent[$category['category_id']] = $category['name'];
             }
             $filter_alert = "Events with '" . $parent[$param] . "' category";
             break;
         case 4:
             if (!empty($param) && !empty($param2)) {
                 $filter_alert = "Events between " . $param . " and " . $param2;
             } else {
                 if (!empty($param) && empty($param2)) {
                     $filter_alert = "Events after " . $param;
                 } else {
                     if (empty($param) && !empty($param2)) {
                         $filter_alert = "Events before " . $param2;
                     } else {
                         $filter_alert = "Show all events";
                     }
                 }
             }
             break;
     }
     $this->view->alert = $filter_alert;
 }
 /**
  * IS: Parameter id terdeklarasi
  * FS: Mengirimkan ke viewer: poi_id, form, gkey, header_image
  * Desc: Mengatur aksi yang dilakukan untuk halaman edit
  */
 public function editAction()
 {
     /*retrieving parameter and creating form*/
     $poi_id = $this->_getParam('id');
     $language_id = $this->_getParam('lang');
     //create instance of destination table and get destination data
     $table_destination = new Model_DbTable_Destination();
     $table_destination_description = new Model_DbTable_DestinationDescription();
     $table_category = new Model_DbTable_Category();
     $table_categorytopoi = new Model_DbTable_CategoryToPoi();
     $table_area = new Model_DbTable_Area();
     $table_areatopoi = new Model_DbTable_AreaToPoi();
     $table_relatedpoi = new Model_DbTable_RelatedPoi();
     $data = null;
     $form = new Admin_Form_PoiFormIndo();
     $table_related_article_poi = new Model_DbTable_RelatedArticlePoi();
     //get realated article data
     // @param =  article_id
     $ralated_poi = $table_related_article_poi->getByPoiId($poi_id, $language_id);
     $this->view->edit = 1;
     $this->view->ralated_poi = $ralated_poi;
     $this->view->poi_id = $poi_id;
     /*Update Process*/
     if ($this->getRequest()->isPost()) {
         //if the form is valid
         if ($form->isValid($_POST)) {
             //check if it is a special destination or not
             if ($language_id != 2) {
                 $indo = $table_destination_description->checkForEnglish($poi_id);
                 if (!$indo) {
                     if ($_POST['SpecialDestination'] == 1) {
                         $header_image = preg_replace("/'/", "&#39;", $_POST['HeaderImage']);
                     } else {
                         $header_image = null;
                     }
                     $PoiName = preg_replace("/'/", "&#39;", $_POST['PoiName']);
                     $PoiTagLine = preg_replace("/'/", "&#39;", $_POST['PoiTagline']);
                     $PoiInformation = preg_replace("/'/", "&#39;", $_POST['PoiInformation']);
                     $PoiHowToGetThere = preg_replace("/'/", "&#39;", $_POST['PoiHowToGetThere']);
                     $PoiHowToGetAround = preg_replace("/'/", "&#39;", $_POST['PoiHowToGetAround']);
                     $PoiWhatToDo = preg_replace("/'/", "&#39;", $_POST['PoiWhatToDo']);
                     $PoiWhereToEat = preg_replace("/'/", "&#39;", $_POST['PoiWhereToEat']);
                     $PoiWhereToStay = preg_replace("/'/", "&#39;", $_POST['PoiWhereToStay']);
                     $PoiWhatToBuy = preg_replace("/'/", "&#39;", $_POST['PoiWhatToBuy']);
                     $PoiTips = preg_replace("/'/", "&#39;", $_POST['PoiTips']);
                     $desc = array('poi_id' => $poi_id, 'language_id' => $language_id, 'name' => $PoiName, 'tagline' => $PoiTagLine, 'description' => $PoiInformation, 'howToGetThere' => $PoiHowToGetThere, 'howToGetAround' => $PoiHowToGetAround, 'whatToDo' => $PoiWhatToDo, 'whereToEat' => $PoiWhereToEat, 'whereToStay' => $PoiWhereToStay, 'whatToBuy' => $PoiWhatToBuy, 'tips' => $PoiTips, 'header_image' => $header_image);
                     //updating data to the database
                     $table_destination_description->insertPoiDescription($desc);
                 } else {
                     if ($_POST['SpecialDestination'] == 1) {
                         $header_image = preg_replace("/'/", "&#39;", $_POST['HeaderImage']);
                     } else {
                         $header_image = null;
                     }
                     $PoiName = preg_replace("/'/", "&#39;", $_POST['PoiName']);
                     $PoiTagLine = preg_replace("/'/", "&#39;", $_POST['PoiTagline']);
                     $PoiInformation = preg_replace("/'/", "&#39;", $_POST['PoiInformation']);
                     $PoiHowToGetThere = preg_replace("/'/", "&#39;", $_POST['PoiHowToGetThere']);
                     $PoiHowToGetAround = preg_replace("/'/", "&#39;", $_POST['PoiHowToGetAround']);
                     $PoiWhatToDo = preg_replace("/'/", "&#39;", $_POST['PoiWhatToDo']);
                     $PoiWhereToEat = preg_replace("/'/", "&#39;", $_POST['PoiWhereToEat']);
                     $PoiWhereToStay = preg_replace("/'/", "&#39;", $_POST['PoiWhereToStay']);
                     $PoiWhatToBuy = preg_replace("/'/", "&#39;", $_POST['PoiWhatToBuy']);
                     $PoiTips = preg_replace("/'/", "&#39;", $_POST['PoiTips']);
                     $desc = array('poi_id' => $poi_id, 'language_id' => 1, 'name' => $PoiName, 'tagline' => $PoiTagLine, 'description' => $PoiInformation, 'howToGetThere' => $PoiHowToGetThere, 'howToGetAround' => $PoiHowToGetAround, 'whatToDo' => $PoiWhatToDo, 'whereToEat' => $PoiWhereToEat, 'whereToStay' => $PoiWhereToStay, 'whatToBuy' => $PoiWhatToBuy, 'tips' => $PoiTips, 'header_image' => $header_image);
                     //updating data to the database
                     $table_destination_description->UpdatePoiDescription($desc, $poi_id, 1);
                 }
             } else {
                 if ($_POST['SpecialDestination'] == 1) {
                     //if it was a special destination but no image uploaded
                     if ($_POST['HeaderImage'] == '') {
                         $this->_flash->addMessage('3\\Warning: Data is saved without image! You should upload an image for a featured destination.');
                     } else {
                         $header_image = preg_replace("/'/", "&#39;", $_POST['HeaderImage']);
                     }
                 } else {
                     $header_image = null;
                 }
                 $PoiName = preg_replace("/'/", "&#39;", $_POST['PoiName']);
                 $PoiAddress = preg_replace("/'/", "&#39;", $_POST['PoiAddress']);
                 $PoiPhone = preg_replace("/'/", "&#39;", $_POST['PoiPhone']);
                 $PoiWebsite = preg_replace("/'/", "&#39;", $_POST['PoiWebsite']);
                 if ($_POST['SpecialDestination'] == 0) {
                     $SpecialDestination = 0;
                 } else {
                     $SpecialDestination = 1;
                 }
                 /*preparing data for Poi table*/
                 $data = array('pointX' => $_POST['pointx'], 'pointY' => $_POST['pointy'], 'address' => $PoiAddress, 'phone' => $PoiPhone, 'website' => $PoiWebsite, 'main_category' => $_POST['MainCategory'], 'popular' => $_POST['PopularSelect'], 'status' => $_POST['SaveStatus'], 'special' => $SpecialDestination, 'header_image' => ' ');
                 /*updating data to Poi table and get the last inserted poi id*/
                 $table_destination->updatePoi($data, $poi_id);
                 /*preparing data for poi description table*/
                 $PoiTagLine = preg_replace("/'/", "&#39;", $_POST['PoiTagline']);
                 $PoiInformation = preg_replace("/'/", "&#39;", $_POST['PoiInformation']);
                 $PoiHowToGetThere = preg_replace("/'/", "&#39;", $_POST['PoiHowToGetThere']);
                 $PoiHowToGetAround = preg_replace("/'/", "&#39;", $_POST['PoiHowToGetAround']);
                 $PoiWhatToDo = preg_replace("/'/", "&#39;", $_POST['PoiWhatToDo']);
                 $PoiWhereToEat = preg_replace("/'/", "&#39;", $_POST['PoiWhereToEat']);
                 $PoiWhereToStay = preg_replace("/'/", "&#39;", $_POST['PoiWhereToStay']);
                 $PoiWhatToBuy = preg_replace("/'/", "&#39;", $_POST['PoiWhatToBuy']);
                 $PoiTips = preg_replace("/'/", "&#39;", $_POST['PoiTips']);
                 $desc = array('poi_id' => $poi_id, 'language_id' => 2, 'name' => $PoiName, 'tagline' => $PoiTagLine, 'description' => $PoiInformation, 'howToGetThere' => $PoiHowToGetThere, 'howToGetAround' => $PoiHowToGetAround, 'whatToDo' => $PoiWhatToDo, 'whereToEat' => $PoiWhereToEat, 'whereToStay' => $PoiWhereToStay, 'whatToBuy' => $PoiWhatToBuy, 'tips' => $PoiTips, 'header_image' => $header_image);
                 //updating data to the database
                 $table_destination_description->UpdatePoiDescription($desc, $poi_id, 2);
                 /*preparing data for categorytopoi table
                  *Get category count and data*/
                 $category_count = $this->_getParam('MaxCategory');
                 $category_stack = array();
                 for ($i = 0; $i <= $category_count; $i++) {
                     if (!empty($_POST['catValue' . $i])) {
                         array_push($category_stack, $_POST['catValue' . $i]);
                     }
                 }
                 /*inserting data for categorytopoi table*/
                 $category_list = $table_categorytopoi->getCategoryIdByPoiId($poi_id);
                 /*convert to non associative array*/
                 $saved_category = array();
                 foreach ($category_list as $temp_cat) {
                     array_push($saved_category, $temp_cat['category_id']);
                 }
                 /*processing the data
                   if the posted data not found on saved category id list then insert the data */
                 foreach ($category_stack as $category_new) {
                     if (!in_array($category_new, $saved_category)) {
                         $category_poi = array('category_id' => $category_new, 'poi_id' => $poi_id);
                         $table_categorytopoi->insertCategoryToPoi($category_poi, 2);
                     }
                 }
                 /*complement check, if the data on saved category list not found on posted category
                   then delete that data on the database*/
                 foreach ($saved_category as $old_category) {
                     if (!in_array($old_category, $category_stack)) {
                         $table_categorytopoi->deleteCategoryToPoi($old_category, $poi_id);
                     }
                 }
                 /* We do it the same way for processing the area data
                  * First, we obtain the data from the database and then convert it
                  * to a non assoc. array*/
                 $areatopoi_list = $table_areatopoi->getPoiAreaId($poi_id);
                 $saved_area = array();
                 foreach ($areatopoi_list as $temp_area) {
                     array_push($saved_area, $temp_area['area_id']);
                 }
                 /* Obtain the list of the new area data posted from the form*/
                 $area_count = $this->_getParam('MaxArea');
                 $area_stack = array();
                 for ($i = 0; $i <= $area_count; $i++) {
                     if (!empty($_POST['areaValue' . $i])) {
                         array_push($area_stack, $_POST['areaValue' . $i]);
                     }
                 }
                 /* Compare the new area list with the old area list
                  *  if its not in the old area list then insert to the database*/
                 foreach ($area_stack as $new_area) {
                     if (!in_array($new_area, $saved_area)) {
                         $area_poi = array('area_id' => $new_area, 'poi_id' => $poi_id);
                         $table_areatopoi->insertAreaToPoi($area_poi);
                     }
                 }
                 /* Now we do the complement action
                  * compare the old list with the new list,
                  * delete if not found on the new list*/
                 foreach ($saved_area as $old_area) {
                     if (!in_array($old_area, $area_stack)) {
                         $table_areatopoi->deleteAreaToPoi($old_area, $poi_id);
                     }
                 }
                 /*related poi data processing*/
                 $relpoi_stack = array();
                 $relCtr = $_POST['relPoi_counter'];
                 for ($i = 0; $i <= $relCtr; $i++) {
                     if (!empty($_POST['relpoi' . $i])) {
                         array_push($relpoi_stack, $_POST['relpoi' . $i]);
                     }
                 }
                 $saved_relpoi = $table_relatedpoi->getAllRelatedByPoiIdLangId($poi_id, $language_id);
                 $old_relpoi = array();
                 if (sizeof($saved_relpoi) > 0) {
                     foreach ($saved_relpoi as $value) {
                         array_push($old_relpoi, $value['related_poi']);
                     }
                 }
                 foreach ($relpoi_stack as $value) {
                     if (!in_array($value, $old_relpoi)) {
                         $data = array('poi_id' => $poi_id, 'related_poi' => $value);
                         $table_relatedpoi->insertRelatedPoi($data);
                     }
                 }
                 foreach ($old_relpoi as $value) {
                     if (!in_array($value, $relpoi_stack)) {
                         $table_relatedpoi->deleteSpecificRelatedPoi($poi_id, $value);
                     }
                 }
             }
             ////$this->_helper->layout()->disableLayout();
             ////$this->_helper->viewRenderer->setNoRender(true);
             /* update related article */
             //param
             // this part add related
             if ($_POST['counterRelated'] > 0) {
                 $counter = $_POST['counterRelated'];
                 for ($i = 1; $i <= $counter; $i++) {
                     //echo $_POST['link'.$i];
                     //cek existing label and link in database
                     // if $cek having value = false, then data will be saved
                     if (isset($_POST['label' . $i])) {
                         $cek = $table_related_article_poi->cek_existing($_POST['label' . $i], $_POST['link' . $i]);
                         if (!$cek or $cek == false) {
                             $data = array('poi_id' => $poi_id, 'label' => $_POST['label' . $i], 'link' => $_POST['link' . $i], 'language_id' => $language_id);
                             $table_related_article_poi->insertRelated($data);
                         }
                     }
                 }
             }
             //bagian untuk menghapus data related artikel
             if ($_POST['counterDel'] > 0) {
                 $counterDel = $_POST['counterDel'];
                 for ($i = 1; $i <= $counterDel; $i++) {
                     //cek existing label and link in database
                     // if found, data will be removed
                     if (isset($_POST['labeldel' . $i])) {
                         $cek = $table_related_article_poi->cek_existing_forDel($_POST['labeldel' . $i], $_POST['linkdel' . $i]);
                     }
                 }
             }
             //Send a success message via flashmessenger
             $this->loggingaction('destination', 'edit', $poi_id, $language_id);
             $this->_flash->addMessage('1\\Destination English Update Success!');
             //redirect to the destination list page
             $this->_redirect($this->view->rootUrl('/admin/destinationindo/'));
         }
     }
     /*load data from the database preparing for view process*/
     if ($language_id == 2) {
         $data = $table_destination->getAllByIdLangForIndo($poi_id, $language_id);
         $parent_category = $table_category->getparentCategoryId($data['main_category']);
         $parent_area = $table_areatopoi->getPoiAreaId($poi_id);
     } else {
         $indo = $table_destination_description->checkForEnglish($poi_id);
         if ($indo) {
             $data = $table_destination->getAllByIdLangForIndo($poi_id, $language_id);
         }
     }
     $tesheader = $table_destination_description->getheaderimagebyid2($poi_id, $language_id);
     /*Set every element Value*/
     if ($data != null) {
         $form->Poi_Name->setValue($this->view->HtmlDecode($data['name']));
         $form->Popular_Select->setValue($this->view->HtmlDecode($data['popular']));
         $form->Poi_Address->setValue($this->view->HtmlDecode(strip_tags($data['address'])));
         $form->Poi_Website->setValue($data['website']);
         $form->Poi_Phone->setValue($data['phone']);
         $form->Poi_TagLine->setValue($this->view->HtmlDecode($data['tagline']));
         $form->Poi_Information->setValue($this->view->HtmlDecode($data['description']));
         $form->Poi_HowToGetThere->setValue($this->view->HtmlDecode($data['howToGetThere']));
         $form->Poi_HowToGetAround->setValue($this->view->HtmlDecode($data['howToGetAround']));
         $form->Poi_WhatToDo->setValue($this->view->HtmlDecode($data['whatToDo']));
         $form->Poi_WhereToEat->setValue($this->view->HtmlDecode($data['whereToEat']));
         $form->Poi_WhereToStay->setValue($this->view->HtmlDecode($data['whereToStay']));
         $form->Poi_WhatToBuy->setValue($this->view->HtmlDecode($data['whatToBuy']));
         $form->Poi_Tips->setValue($this->view->HtmlDecode($data['tips']));
         $form->Poi_x->setValue($data['pointX']);
         $form->Poi_y->setValue($data['pointY']);
         $form->HeaderImage->setValue($tesheader['header_image']);
     }
     /*check if this is a special destination, if it is, then checkbox value to true*/
     if ($table_destination->checkSpecialDestination($poi_id)) {
         $form->SpecialDestination->setChecked(true);
         $this->view->state_special = TRUE;
     } else {
         $form->SpecialDestination->setChecked(false);
         $this->view->state_special = FALSE;
     }
     /*send data image filename to the view*/
     $this->view->header_image = $data['header_image'];
     /*set another value to the form element*/
     $area_amount = $table_areatopoi->countAreaByPoiId($poi_id);
     $category_amount = $table_categorytopoi->countCategoryByPoiId($poi_id);
     $main_category = $table_destination->getMainCategoryById($poi_id);
     $form->Category_counter->setValue($category_amount);
     $form->Count_category->setValue($category_amount);
     $form->Main_category->setValue($main_category['main_category']);
     $form->Area_counter->setValue($area_amount);
     $form->Count_area->setValue($area_amount);
     /*send form to view class*/
     $this->view->poi_id = $poi_id;
     $this->view->form = $form;
     $this->view->language_id = $language_id;
     /*get google map key from zend registry and send it to the view*/
 }
 /**
  * IS: Parameter id terdeklarasi
  * FS: Mengirimkan ke viewer: poi_id, form, gkey, header_image
  * Desc: Mengatur aksi yang dilakukan untuk halaman edit
  */
 public function editAction()
 {
     $culture_id = $this->_getParam('id');
     $language_id = $this->_getParam('lang');
     $table_destination = new Model_DbTable_Destination();
     $table_destination_description = new Model_DbTable_DestinationDescription();
     $table_category = new Model_DbTable_Category();
     $table_categorytopoi = new Model_DbTable_CategoryToPoi();
     $table_areatopoi = new Model_DbTable_AreaToPoi();
     $table_relatedpoi = new Model_DbTable_RelatedPoi();
     $this->table_cultureVideo = new Model_DbTable_CultureVideo();
     $form = new Admin_Form_PoiForm();
     $culture = null;
     $table_file = new Model_DbTable_FileAttachments();
     $table_gallery = new Model_DbTable_Image();
     $table_related_article_poi = new Model_DbTable_RelatedArticlePoi();
     // get realated article data
     // untuk menampilkan related link pada destinasi yang bersangkutan
     $ralated_poi = $table_related_article_poi->getByPoiId($culture_id, $language_id);
     $cultureVideos = $this->table_cultureVideo->findByCultureId($culture_id);
     $this->view->ralated_poi = $ralated_poi;
     $this->view->poi_id = $culture_id;
     $this->view->ralated_news = $ralated_poi;
     $this->view->cultureVideos = $cultureVideos;
     $this->view->files = $table_file->getByPoiId($culture_id);
     $this->view->images = $table_gallery->getByPoiId($culture_id);
     /* Update Process */
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $status = Model_DbTable_Destination::DRAFT;
             if (isset($_POST['Submit'])) {
                 if ($this->_userInfo->canApprove) {
                     $status = Model_DbTable_Destination::PUBLISH;
                 } else {
                     $status = Model_DbTable_Destination::PENDING;
                 }
             }
             $culture = array('pointX' => $_POST['pointx'], 'pointY' => $_POST['pointy'], 'main_category' => $_POST['MainCategory'], 'featured' => $_POST['Featured'], 'status' => $status);
             if ($form->header_image->isUploaded()) {
                 $file = pathinfo($form->header_image->getFileName());
                 $form->header_image->addFilter('Rename', UPLOAD_FOLDER . 'culture/' . $file['filename'] . '_' . time() . '.' . $file['extension']);
                 if ($form->header_image->receive()) {
                     $culture['image'] = $form->header_image->getValue();
                 }
             }
             $table_destination->updatePoi($culture, $culture_id);
             $culture_description = array('poi_id' => $culture_id, 'name' => $_POST['Name'], 'description' => $_POST['Description'], 'updated_by' => $this->_userInfo->id, 'updated_at' => Date('Y-m-d H:i:s'));
             $table_destination_description->UpdatePoiDescription($culture_description, $culture_id, 1);
             /* preparing data for categorytopoi table
              * Get category count and data */
             $category_count = $this->_getParam('MaxCategory');
             $category_stack = array();
             for ($i = 0; $i <= $category_count; $i++) {
                 if (!empty($_POST['catValue' . $i])) {
                     array_push($category_stack, $_POST['catValue' . $i]);
                 }
             }
             /* inserting data for categorytopoi table */
             $category_list = $table_categorytopoi->getCategoryIdByPoiId($culture_id);
             /* convert to non associative array */
             $saved_category = array();
             foreach ($category_list as $temp_cat) {
                 array_push($saved_category, $temp_cat['category_id']);
             }
             /* processing the data
             
                       if the posted data not found on saved category id list then insert the data */
             foreach ($category_stack as $category_new) {
                 if (!in_array($category_new, $saved_category)) {
                     $category_poi = array('category_id' => $category_new, 'poi_id' => $culture_id);
                     $table_categorytopoi->insertCategoryToPoi($category_poi);
                 }
             }
             /* complement check, if the data on saved category list not found on posted category
             
                       then delete that data on the database */
             foreach ($saved_category as $old_category) {
                 if (!in_array($old_category, $category_stack)) {
                     $table_categorytopoi->deleteCategoryToPoi($old_category, $culture_id);
                 }
             }
             /* We do it the same way for processing the area data
              * First, we obtain the data from the database and then convert it
              * to a non assoc. array */
             $areatopoi_list = $table_areatopoi->getPoiAreaId($culture_id);
             $saved_area = array();
             foreach ($areatopoi_list as $temp_area) {
                 array_push($saved_area, $temp_area['area_id']);
             }
             /* Obtain the list of the new area data posted from the form */
             $area_count = $this->_getParam('MaxArea');
             $area_stack = array();
             for ($i = 0; $i <= $area_count; $i++) {
                 if (!empty($_POST['areaValue' . $i])) {
                     array_push($area_stack, $_POST['areaValue' . $i]);
                 }
             }
             /* Compare the new area list with the old area list
              *  if its not in the old area list then insert to the database */
             foreach ($area_stack as $new_area) {
                 if (!in_array($new_area, $saved_area)) {
                     $area_poi = array('area_id' => $new_area, 'poi_id' => $culture_id);
                     $table_areatopoi->insertAreaToPoi($area_poi);
                 }
             }
             /* Now we do the complement action
              * compare the old list with the new list,
              * delete if not found on the new list */
             foreach ($saved_area as $old_area) {
                 if (!in_array($old_area, $area_stack)) {
                     $table_areatopoi->deleteAreaToPoi($old_area, $culture_id);
                 }
             }
             /* related poi data processing */
             $relpoi_stack = array();
             $relCtr = $_POST['relPoi_counter'];
             for ($i = 0; $i <= $relCtr; $i++) {
                 if (!empty($_POST['relpoi' . $i])) {
                     array_push($relpoi_stack, $_POST['relpoi' . $i]);
                 }
             }
             $saved_relpoi = $table_relatedpoi->getAllRelatedByPoiIdLangId($culture_id, $language_id);
             $old_relpoi = array();
             if (sizeof($saved_relpoi) > 0) {
                 foreach ($saved_relpoi as $value) {
                     array_push($old_relpoi, $value['related_poi']);
                 }
             }
             foreach ($relpoi_stack as $value) {
                 if (!in_array($value, $old_relpoi)) {
                     $data = array('poi_id' => $culture_id, 'related_poi' => $value);
                     $table_relatedpoi->insertRelatedPoi($data);
                 }
             }
             foreach ($old_relpoi as $value) {
                 if (!in_array($value, $relpoi_stack)) {
                     $table_relatedpoi->deleteSpecificRelatedPoi($culture_id, $value);
                 }
             }
             ////$this->_helper->layout()->disableLayout();
             ////$this->_helper->viewRenderer->setNoRender(true);
             /* update related article */
             // this part add related
             if ($_POST['counterRelated'] > 0) {
                 $counter = $_POST['counterRelated'];
                 for ($i = 1; $i <= $counter; $i++) {
                     //cek existing data ke database
                     // if jika data link dan label yang dikirim dari viwer
                     // blm ada di database, maka akan di simpan
                     if (isset($_POST['label' . $i])) {
                         $cek = $table_related_article_poi->cek_existing($_POST['label' . $i], $_POST['link' . $i]);
                         if (!$cek or $cek == false) {
                             $data = array('poi_id' => $culture_id, 'label' => $_POST['label' . $i], 'link' => $_POST['link' . $i], 'language_id' => $language_id);
                             $table_related_article_poi->insertRelated($data);
                         }
                     }
                 }
             }
             $this->handleInsertVideoLink($culture_id);
             $upload_dir = UPLOAD_FOLDER . 'documents/';
             $upload_image_dir = UPLOAD_FOLDER . 'culture/';
             $upload = new Zend_File_Transfer_Adapter_Http();
             $files = $upload->getFileInfo();
             $i = 0;
             $j = 0;
             echo "<pre>" . print_r($files, true) . "</pre>";
             foreach ($files as $file => $info) {
                 $info['destination'] = $upload_image_dir;
                 if (strstr($file, 'files')) {
                     $file = array('poi_id' => $culture_id, 'title' => $_POST['titles'][$i], 'name' => $info['name'], 'size' => $info['size']);
                     $table_file->insert($file);
                     $upload->setDestination($upload_dir);
                     $i++;
                 } else {
                     if (strstr($file, 'images')) {
                         $image = array('poi_id' => $culture_id, 'source' => $info['name'], 'name' => $_POST['imageTitles'][$j]);
                         $table_gallery->insert($image);
                         $upload->setDestination($upload_image_dir);
                         $j++;
                     }
                 }
                 $upload->receive($info['name']);
             }
             if (isset($_POST['existingFiles'])) {
                 $existingFiles = $_POST['existingFiles'];
                 foreach ($existingFiles as $id => $file) {
                     $data = array('title' => $file['title']);
                     $table_file->update($data, "id = {$id}");
                 }
             }
             if (isset($_POST['existingImages'])) {
                 $existingImages = $_POST['existingImages'];
                 foreach ($existingImages as $id => $image) {
                     $data = array('name' => $image['name']);
                     $table_gallery->update($data, "gallery_id = {$id}");
                 }
             }
             // part untuk menghapus data dari database
             // bagian ini akan dijalankan apabila ada triger hapus
             // delete dari viewer
             if ($_POST['counterDel'] > 0) {
                 $counterDel = $_POST['counterDel'];
                 for ($i = 1; $i <= $counterDel; $i++) {
                     //cek existing label and link in database
                     // if found, data will be removed
                     if (isset($_POST['labeldel' . $i])) {
                         $cek = $table_related_article_poi->cek_existing_forDel($_POST['labeldel' . $i], $_POST['linkdel' . $i]);
                     }
                 }
             }
             //Send a success message via flashmessenger
             $this->loggingaction('destination', 'edit', $culture_id, $language_id);
             $this->_flash->addMessage('Sunting Kebudayaan Berhasil!');
             //redirect to the destination list page
             $this->_redirect($this->view->rootUrl('/admin/culture/'));
         }
     }
     /* load data from the database preparing for view process */
     if (!$this->_userInfo->canApprove) {
         $form->submit->setLabel('Sunting Untuk Pratinjau');
         $form->draft->setLabel('Jadikan Sebagai Draft');
     } else {
         $form->submit->setLabel('Sunting');
     }
     if ($language_id == 1) {
         $culture = $table_destination->getAllByIdLang($culture_id, $language_id, false);
         $parent_category = $table_category->getparentCategoryId($culture['main_category']);
         $parent_area = $table_areatopoi->getPoiAreaId($culture_id);
         $related_poi = $table_relatedpoi->getAllRelatedByPoiIdLangId($culture_id, $language_id);
     } else {
         $indo = $table_destination_description->checkForIndo($culture_id);
         if ($indo) {
             $culture = $table_destination->getAllByIdLang($culture_id, $language_id);
         }
     }
     $checkSpecial = $table_destination->checkDestSpecialById($culture_id);
     $this->view->destSpecial = $checkSpecial;
     //    $tesheader               = $table_destination_description->getheaderimagebyid2($culture_id, $language_id);
     if ($culture != null) {
         $form->name->setValue($this->view->HtmlDecode($culture['name']));
         $form->description->setValue($this->view->HtmlDecode($culture['description']));
         $form->Poi_x->setValue($culture['pointX']);
         $form->Poi_y->setValue($culture['pointY']);
         $form->featured->setChecked($culture['featured']);
         $this->view->header_image = $table_destination->find($culture_id)->current()->image;
     }
     /* check if this is a special destination, if it is, then checkbox value to true */
     //    if ($table_destination->checkSpecialDestination($poi_id)) {
     //      $form->SpecialDestination->setChecked(true);
     //      $this->view->state_special = TRUE;
     //    } else {
     //      $form->SpecialDestination->setChecked(false);
     //      $this->view->state_special = FALSE;
     //    }
     /* send data image filename to the view */
     //    /* set another value to the form element */
     $area_amount = $table_areatopoi->countAreaByPoiId($culture_id);
     $category_amount = $table_categorytopoi->countCategoryByPoiId($culture_id);
     $main_category = $table_destination->getMainCategoryById($culture_id);
     $form->Category_counter->setValue($category_amount);
     $form->Count_category->setValue($category_amount);
     $form->Main_category->setValue($main_category['main_category']);
     $form->Area_counter->setValue($area_amount);
     $form->Count_area->setValue($area_amount);
     /* send form to view class */
     $this->view->userCanApprove = $this->_userInfo->canApprove;
     $this->view->poi_id = $culture_id;
     $this->view->form = $form;
     $this->view->language_id = $language_id;
 }
 public function getAllByCategoryList($categoryId, $languageId)
 {
     $categoryDb = new Model_DbTable_Category();
     // Cek apakah si kategori punya sub kategori, jika tidak maka set
     // isinya ke kategori dia sendiri
     $childList = $categoryDb->getCategoryChildListForForm($categoryId, $languageId);
     if (empty($childList)) {
         $childList = $categoryId;
     }
     $query = $this->select()->setIntegrityCheck(false)->from($this->_name, array('poi_id', 'poi_name' => 'name', 'description'))->join($this->_desti, "{$this->_desti}.poi_id = {$this->_name}.poi_id", array('pointX', 'pointY', 'special'))->join($this->_cattopoi, "{$this->_cattopoi}.poi_id = {$this->_name}.poi_id", array(''))->where("{$this->_name}.language_id = ?", $languageId)->where("{$this->_cattopoi}.category_id = ? ", $categoryId)->group("{$this->_name}.poi_id");
     //echo $query->__toString();
     $data = $this->fetchAll($query);
     if (count($data)) {
         return $data->toArray();
     } else {
         return array();
     }
 }
Exemplo n.º 16
0
 public function init()
 {
     $tableArea = new Model_DbTable_Area();
     $tableCategory = new Model_DbTable_Category();
     $dateValidator = new Zend_Validate_Date();
     $this->name = new Zend_Form_Element_Text('Name');
     $this->name->setRequired(true)->setAttrib('class', 'span7')->setAttrib('placeholder', 'Masukan Nama Kebudayaan Disini...')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->featured = new Zend_Form_Element_Checkbox('Featured');
     $this->featured->setAttrib('class', 'checkbox')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->description = new Zend_Form_Element_Textarea('Description');
     $this->description->setAttrib('style', 'width:100%')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->header_image = new Zend_Form_Element_File('Header_image');
     $this->header_image->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label');
     $this->submit = new Zend_Form_Element_Submit('Submit');
     $this->submit->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setAttribs(array('class' => 'btn btn-success', 'id' => 'submit-btn'));
     $this->draft = new Zend_Form_Element_Submit('Draft');
     $this->draft->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setAttribs(array('class' => 'btn', 'id' => 'draft-btn'));
     $this->videos = new Zend_Form_SubForm();
     $category = $tableCategory->getAllParentIdNameForSelectByLangId(1);
     $this->Category_Select = $this->createElement('select', 'CategorySelect', $category);
     $this->Category_Select->removeDecorator('HtmlTag');
     $this->Category_Select->removeDecorator('DtDdWrapper');
     $this->Category_Select->removeDecorator('Label');
     $this->Category_Select->setAttrib('onchange', 'getChildCategory(this.value);');
     $category_child = $tableCategory->getAllChildIdNameByParentIdLangId();
     $this->Category_Child = $this->createElement('select', 'CategoryChild', $category_child);
     $this->Category_Child->removeDecorator('HtmlTag');
     $this->Category_Child->removeDecorator('DtDdWrapper');
     $this->Category_Child->removeDecorator('Label');
     $data = $tableArea->setAreaForSelectElement(1);
     $temp = array(0 => 'Pilih Area');
     $area_data = $temp + $data;
     $data = array("multiOptions" => $area_data);
     $this->Island_Select = $this->createElement('select', 'IslandListOptions', $data);
     $this->Island_Select->removeDecorator('HtmlTag');
     $this->Island_Select->removeDecorator('DtDdWrapper');
     $this->Island_Select->removeDecorator('Label');
     $this->Island_Select->setAttrib('onchange', 'getAreaList(this.value,0);');
     $this->Poi_x = $this->createElement('hidden', 'pointx');
     $this->Poi_x->removeDecorator('HtmlTag');
     $this->Poi_x->setAttrib('class', 'required');
     $this->Poi_x->removeDecorator('DtDdWrapper');
     $this->Poi_x->removeDecorator('Label');
     $this->Poi_x->setAttrib('onkeyup', 'updatePosition();');
     $this->Poi_x->setAttrib('class', 'smallele');
     $this->Poi_x->setRequired(TRUE);
     $this->Poi_y = $this->createElement('hidden', 'pointy');
     $this->Poi_y->removeDecorator('HtmlTag');
     $this->Poi_y->setAttrib('class', 'required');
     $this->Poi_y->removeDecorator('DtDdWrapper');
     $this->Poi_y->removeDecorator('Label');
     $this->Poi_y->setAttrib('onkeyup', 'updatePosition();');
     $this->Poi_y->setAttrib('class', 'smallele');
     $this->Poi_y->setRequired(TRUE);
     /* hidden element */
     $this->relPoi_counter = $this->createElement('hidden', 'relPoi_counter');
     $this->relPoi_counter->removeDecorator('HtmlTag');
     $this->relPoi_counter->removeDecorator('DtDdWrapper');
     $this->relPoi_counter->removeDecorator('Label');
     $this->relPoi_counter->setValue(0);
     $this->SaveStatus = $this->createElement('hidden', 'SaveStatus');
     $this->SaveStatus->removeDecorator('HtmlTag');
     $this->SaveStatus->removeDecorator('DtDdWrapper');
     $this->SaveStatus->removeDecorator('Label');
     $this->SaveStatus->setValue(1);
     /**
      * This element will be used for maximum area counter storage, 
      * when you remove an area this counter number wont be decreased
      */
     $this->Count_area = $this->createElement('hidden', 'MaxArea');
     $this->Count_area->removeDecorator('HtmlTag');
     $this->Count_area->removeDecorator('DtDdWrapper');
     $this->Count_area->removeDecorator('Label');
     $this->Count_area->setValue(0);
     /**
      * This element will be used for maximum category counter storage, 
      * when you remove a category this counter number wont be decreased
      */
     $this->Count_category = $this->createElement('hidden', 'MaxCategory');
     $this->Count_category->removeDecorator('HtmlTag');
     $this->Count_category->removeDecorator('DtDdWrapper');
     $this->Count_category->removeDecorator('Label');
     $this->Count_category->setValue(0);
     $this->Area_counter = $this->createElement('hidden', 'AreaCounter');
     $this->Area_counter->removeDecorator('HtmlTag');
     $this->Area_counter->removeDecorator('DtDdWrapper');
     $this->Area_counter->removeDecorator('Label');
     $this->Area_counter->setValue(0);
     $this->Category_counter = $this->createElement('hidden', 'CategoryCounter');
     $this->Category_counter->removeDecorator('HtmlTag');
     $this->Category_counter->removeDecorator('DtDdWrapper');
     $this->Category_counter->removeDecorator('Label');
     $this->Category_counter->setValue(0);
     $this->Main_category = $this->createElement('hidden', 'MainCategory');
     $this->Main_category->removeDecorator('HtmlTag');
     $this->Main_category->removeDecorator('DtDdWrapper');
     $this->Main_category->removeDecorator('Label');
     $this->Main_category->setValue(0);
 }
 /**
  * IS: Parameter id terdeklarasi
  * FS: Mengirimkan ke viewer: form, parent
  * Desc: Mengatur aksi yang dilakukan untuk halaman edit
  */
 public function editAction()
 {
     $language_id = $this->_getParam('lang');
     $activity_id = $this->_getParam('id');
     $form = new Admin_Form_ActivityForm();
     $form->setCategoryParent($language_id);
     $table_category = new Model_DbTable_Category();
     $table_category_desc = new Model_DbTable_CategoryDescription();
     $table_categorytopoi = new Model_DbTable_CategoryToPoi();
     //if this is a POST request
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             if ($language_id != 1) {
                 $indo = $table_category_desc->checkForIndo($activity_id);
                 if ($indo) {
                     $data = array('category_id' => $activity_id, 'name' => $_POST['categoryName'], 'description' => $_POST['categoryDescription']);
                     $table_category_desc->updateCategory($data, $activity_id, 2);
                 } else {
                     $data = array('category_id' => $activity_id, 'language_id' => $language_id, 'name' => $_POST['categoryName'], 'description' => $_POST['categoryDescription']);
                     $table_category_desc->insertCategory($data);
                 }
             } else {
                 $data = array('parent_id' => $_POST['categoryParent'], 'image' => $_POST['categoryPicture']);
                 $table_category->updateCategory($data, $activity_id);
                 $data2 = array('category_id' => $activity_id, 'name' => $_POST['categoryName'], 'description' => $_POST['categoryDescription']);
                 $table_category_desc->updateCategory($data2, $activity_id, 1);
             }
             $this->loggingaction('activity', 'edit', $activity_id, $language_id);
             $this->_flash->addMessage('1\\Activity Update Success!');
             $this->_redirect($this->view->rootUrl('/admin/activity/'));
         }
     }
     //get the activity data
     if ($language_id != 1) {
         $indo = $table_category_desc->checkForIndo($activity_id);
         if ($indo) {
             $category_data = $table_category->getAllWithDescByIdLang($activity_id, $language_id);
         }
     } else {
         $category_data = $table_category->getAllWithDescByIdLang($activity_id, $language_id);
     }
     //set element value
     $form->categoryParent->setValue($category_data['parent_id']);
     $form->categoryName->setValue($category_data['name']);
     $form->categoryPicture->setValue($category_data['image']);
     $form->categoryDescription->setValue($category_data['description']);
     //send variables to the view
     $this->view->parent = $category_data['parent_id'];
     $this->view->form = $form;
     $this->view->langId = $language_id;
 }
 protected function randomActivity()
 {
     // Model
     $categoryDb = new Model_DbTable_Category();
     // Data
     $activities = $categoryDb->randomCategory(3, $this->_languageId);
     return $activities;
 }
Exemplo n.º 19
0
 public function init()
 {
     $tableArea = new Model_DbTable_Area();
     $tableCategory = new Model_DbTable_Category();
     $this->Poi_Name = $this->createElement('text', 'PoiName');
     $this->Poi_Name->removeDecorator('HtmlTag');
     $this->Poi_Name->removeDecorator('DtDdWrapper');
     $this->Poi_Name->removeDecorator('Label');
     $this->Poi_Name->setRequired(TRUE);
     $this->Poi_Name->setAttrib('class', 'mediumele');
     $popular = array("multiOptions" => array(0 => "No", 1 => "Yes"));
     $this->Popular_Select = $this->createElement('select', 'PopularSelect', $popular);
     $this->Popular_Select->removeDecorator('HtmlTag');
     $this->Popular_Select->removeDecorator('DtDdWrapper');
     $this->Popular_Select->removeDecorator('Label');
     $this->Poi_TagLine = $this->createElement('text', 'PoiTagline');
     $this->Poi_TagLine->removeDecorator('HtmlTag');
     $this->Poi_TagLine->removeDecorator('DtDdWrapper');
     $this->Poi_TagLine->removeDecorator('Label');
     $this->Poi_TagLine->setAttrib('class', 'mediumele');
     $this->Poi_Address = $this->createElement('text', 'PoiAddress');
     $this->Poi_Address->setAttrib('class', 'tableFormInputLong');
     $this->Poi_Address->removeDecorator('HtmlTag');
     $this->Poi_Address->removeDecorator('DtDdWrapper');
     $this->Poi_Address->removeDecorator('Label');
     $this->Poi_Address->setAttrib('class', 'mediumele');
     $this->Poi_Phone = $this->createElement('text', 'PoiPhone');
     $this->Poi_Phone->removeDecorator('HtmlTag');
     $this->Poi_Phone->removeDecorator('DtDdWrapper');
     $this->Poi_Phone->removeDecorator('Label');
     $this->Poi_Phone->setAttrib('class', 'mediumele');
     $this->Poi_Website = $this->createElement('text', 'PoiWebsite');
     $this->Poi_Website->removeDecorator('HtmlTag');
     $this->Poi_Website->removeDecorator('DtDdWrapper');
     $this->Poi_Website->removeDecorator('Label');
     $this->Poi_Website->setAttrib('class', 'mediumele');
     $this->SpecialDestination = $this->createElement('checkbox', 'SpecialDestination');
     $this->SpecialDestination->removeDecorator('HtmlTag');
     $this->SpecialDestination->removeDecorator('DtDdWrapper');
     $this->SpecialDestination->removeDecorator('Label');
     $this->SpecialDestination->setCheckedValue(1);
     $this->SpecialDestination->setUncheckedValue(0);
     $this->SpecialDestination->setAttrib('onclick', 'showHeaderImage($(this));');
     $this->HeaderImage = $this->createElement('text', 'HeaderImage');
     $this->HeaderImage->removeDecorator('HtmlTag');
     $this->HeaderImage->removeDecorator('DtDdWrapper');
     $this->HeaderImage->removeDecorator('Label');
     $this->HeaderImage->setAttrib('class', 'disabled');
     $category = $tableCategory->getAllParentIdNameForSelectByLangId(2);
     $this->Category_Select = $this->createElement('select', 'CategorySelect', $category);
     $this->Category_Select->removeDecorator('HtmlTag');
     $this->Category_Select->removeDecorator('DtDdWrapper');
     $this->Category_Select->removeDecorator('Label');
     $this->Category_Select->setAttrib('onchange', 'getChildCategoryIndo(this.value);');
     $category_child = $tableCategory->getAllChildIdNameByParentIdLangId(null, 2);
     $this->Category_Child = $this->createElement('select', 'CategoryChild', $category_child);
     $this->Category_Child->removeDecorator('HtmlTag');
     $this->Category_Child->removeDecorator('DtDdWrapper');
     $this->Category_Child->removeDecorator('Label');
     $data = $tableArea->setAreaForSelectElement(1);
     $temp = array(0 => 'select Island');
     $area_data = $temp + $data;
     $data = array("multiOptions" => $area_data);
     $this->Island_Select = $this->createElement('select', 'IslandListOptions', $data);
     $this->Island_Select->removeDecorator('HtmlTag');
     $this->Island_Select->removeDecorator('DtDdWrapper');
     $this->Island_Select->removeDecorator('Label');
     $this->Island_Select->setAttrib('onchange', 'getAreaList(this.value,0);');
     $this->Poi_x = $this->createElement('text', 'pointx');
     $this->Poi_x->removeDecorator('HtmlTag');
     $this->Poi_x->setAttrib('class', 'required');
     $this->Poi_x->removeDecorator('DtDdWrapper');
     $this->Poi_x->removeDecorator('Label');
     $this->Poi_x->setAttrib('onkeyup', 'UpdatePosition();');
     $this->Poi_x->setAttrib('class', 'smallele');
     $this->Poi_x->setRequired(TRUE);
     $this->Poi_y = $this->createElement('text', 'pointy');
     $this->Poi_y->removeDecorator('HtmlTag');
     $this->Poi_y->setAttrib('class', 'required');
     $this->Poi_y->removeDecorator('DtDdWrapper');
     $this->Poi_y->removeDecorator('Label');
     $this->Poi_y->setAttrib('onkeyup', 'UpdatePosition();');
     $this->Poi_y->setAttrib('class', 'smallele');
     $this->Poi_y->setRequired(TRUE);
     $this->Poi_Information = $this->createElement('textarea', 'PoiInformation');
     $this->Poi_Information->removeDecorator('HtmlTag');
     $this->Poi_Information->removeDecorator('DtDdWrapper');
     $this->Poi_Information->removeDecorator('Label');
     $this->Poi_Information->setAttribs(array('cols' => 5, 'rows' => 5));
     $this->Poi_HowToGetThere = $this->createElement('textarea', 'PoiHowToGetThere');
     $this->Poi_HowToGetThere->removeDecorator('HtmlTag');
     $this->Poi_HowToGetThere->removeDecorator('DtDdWrapper');
     $this->Poi_HowToGetThere->removeDecorator('Label');
     $this->Poi_HowToGetAround = $this->createElement('textarea', 'PoiHowToGetAround');
     $this->Poi_HowToGetAround->removeDecorator('HtmlTag');
     $this->Poi_HowToGetAround->removeDecorator('DtDdWrapper');
     $this->Poi_HowToGetAround->removeDecorator('Label');
     $this->Poi_WhatToDo = $this->createElement('textarea', 'PoiWhatToDo');
     $this->Poi_WhatToDo->removeDecorator('HtmlTag');
     $this->Poi_WhatToDo->removeDecorator('DtDdWrapper');
     $this->Poi_WhatToDo->removeDecorator('Label');
     $this->Poi_WhereToEat = $this->createElement('textarea', 'PoiWhereToEat');
     $this->Poi_WhereToEat->removeDecorator('HtmlTag');
     $this->Poi_WhereToEat->removeDecorator('DtDdWrapper');
     $this->Poi_WhereToEat->removeDecorator('Label');
     $this->Poi_WhereToStay = $this->createElement('textarea', 'PoiWhereToStay');
     $this->Poi_WhereToStay->removeDecorator('HtmlTag');
     $this->Poi_WhereToStay->removeDecorator('DtDdWrapper');
     $this->Poi_WhereToStay->removeDecorator('Label');
     $this->Poi_WhatToBuy = $this->createElement('textarea', 'PoiWhatToBuy');
     $this->Poi_WhatToBuy->removeDecorator('HtmlTag');
     $this->Poi_WhatToBuy->removeDecorator('DtDdWrapper');
     $this->Poi_WhatToBuy->removeDecorator('Label');
     $this->Poi_Tips = $this->createElement('textarea', 'PoiTips');
     $this->Poi_Tips->removeDecorator('HtmlTag');
     $this->Poi_Tips->removeDecorator('DtDdWrapper');
     $this->Poi_Tips->removeDecorator('Label');
     /*hidden element*/
     $this->relPoi_counter = $this->createElement('hidden', 'relPoi_counter');
     $this->relPoi_counter->removeDecorator('HtmlTag');
     $this->relPoi_counter->removeDecorator('DtDdWrapper');
     $this->relPoi_counter->removeDecorator('Label');
     $this->relPoi_counter->setValue(0);
     $this->SaveStatus = $this->createElement('hidden', 'SaveStatus');
     $this->SaveStatus->removeDecorator('HtmlTag');
     $this->SaveStatus->removeDecorator('DtDdWrapper');
     $this->SaveStatus->removeDecorator('Label');
     $this->SaveStatus->setValue(1);
     /**
      * This element will be used for maximum area counter storage, 
      * when you remove an area this counter number wont be decreased
      */
     $this->Count_area = $this->createElement('hidden', 'MaxArea');
     $this->Count_area->removeDecorator('HtmlTag');
     $this->Count_area->removeDecorator('DtDdWrapper');
     $this->Count_area->removeDecorator('Label');
     $this->Count_area->setValue(0);
     /**
      * This element will be used for maximum category counter storage, 
      * when you remove a category this counter number wont be decreased
      */
     $this->Count_category = $this->createElement('hidden', 'MaxCategory');
     $this->Count_category->removeDecorator('HtmlTag');
     $this->Count_category->removeDecorator('DtDdWrapper');
     $this->Count_category->removeDecorator('Label');
     $this->Count_category->setValue(0);
     $this->Area_counter = $this->createElement('hidden', 'AreaCounter');
     $this->Area_counter->removeDecorator('HtmlTag');
     $this->Area_counter->removeDecorator('DtDdWrapper');
     $this->Area_counter->removeDecorator('Label');
     $this->Area_counter->setValue(0);
     $this->Category_counter = $this->createElement('hidden', 'CategoryCounter');
     $this->Category_counter->removeDecorator('HtmlTag');
     $this->Category_counter->removeDecorator('DtDdWrapper');
     $this->Category_counter->removeDecorator('Label');
     $this->Category_counter->setValue(0);
     $this->Main_category = $this->createElement('hidden', 'MainCategory');
     $this->Main_category->removeDecorator('HtmlTag');
     $this->Main_category->removeDecorator('DtDdWrapper');
     $this->Main_category->removeDecorator('Label');
     $this->Main_category->setValue(0);
 }
Exemplo n.º 20
0
     } elseif ($ext == 'gif') {
         imagegif($virtual_image, $dest);
     } elseif ($ext == 'png') {
         imagepng($virtual_image, $dest);
     }
 }
 /**
  * IS:
  * FS:
  * Desc:
  */
 public function poirelatedeventAction()
 {