示例#1
0
 public function getItems()
 {
     $travelTypeId = (int) $this->getUserStateFromRequest($this->context . '.filter.traveltype_id', 'filter_traveltype_id');
     //$countryId = (int) $this->getUserStateFromRequest($this->context . '.filter.country_id', 'filter_country_id');
     if ($travelTypeId) {
         require_once JPATH_COMPONENT . '/helpers/data.php';
         $keliones = new Keliones();
         $keliones->LoadCountriesListFromXMLFile();
         $keliones->LoadFromXMLFile($travelTypeId);
         return $keliones;
     } else {
         return null;
     }
 }
示例#2
0
 public static function getTravels($travelTypeId, $countryId)
 {
     require_once JPATH_COMPONENT . '/helpers/data.php';
     $file = XMLDataHelper::downloadFile('http://booking.gruda.lt/tours/api/?method=getTravels&travelType=' . $travelTypeId, "travels{$travelTypeId}.xml");
     $fullXML = simplexml_load_file($file);
     $XML = $fullXML->xpath('getTravels');
     $keliones = new Keliones();
     foreach ($XML[0] as $item) {
         if ($item->visible) {
             $keliones->addFromXML($item);
         }
     }
     return $keliones;
 }
 public function getItems()
 {
     require_once JPATH_COMPONENT . '/helpers/data.php';
     $travelTypeId = JRequest::getInt('ttid');
     $arrayTravelId = explode(',', JRequest::getString('tid'));
     $keliones = new Keliones();
     $keliones->LoadFromXMLFile($travelTypeId);
     $items = array();
     foreach ($keliones as $kelione) {
         if (in_array($kelione->id, $arrayTravelId)) {
             //atrenka tik pasirinktu kelioniu paveikslelius
             $paveiksleiai = $kelione->paveiksleliai->toArray();
             foreach ($paveiksleiai as $paveikslelis) {
                 $items[] = array('travelId' => (int) $kelione->id, 'image' => (string) $paveikslelis['byla'], 'subdir' => (string) $paveikslelis['subdir'], 'url' => base64_encode($paveikslelis['url']));
             }
         }
     }
     return $items;
 }
示例#4
0
 public function import()
 {
     $cKey = JRequest::getString('ckey');
     $parentId = JRequest::getInt('import_category_id');
     //patikriname ar pasirinkta kategorija importui
     if (!$parentId) {
         $this->setMessage('Pasirinkite kategoriją importui!', 'error');
         return $this->setRedirect(JRoute::_("index.php?option=com_kelioniuimportas&view=import&ckey={$cKey}", false));
     }
     $tid = JRequest::getVar('cid');
     //pasirinktu kelioniu ID
     $ttid = JRequest::getInt('travelTypeId');
     $params = JComponentHelper::getParams('com_kelioniuimportas');
     $appId = $params->getValue('application_id', 1);
     //importuojam keliones
     require_once JPATH_COMPONENT . '/helpers/data.php';
     $keliones = new Keliones();
     $keliones->LoadCountriesListFromXMLFile();
     $keliones->LoadFromXMLFile($ttid);
     $db = JFactory::getDbo();
     $userId = JFactory::getUser()->get('id');
     $error = array();
     $this->createSubcategories($keliones, $tid, $parentId, $appId);
     foreach ($keliones as $kelione) {
         if (in_array($kelione->id, $tid)) {
             //atrenka tik pasirinktas keliones
             $query = $db->getQuery(true);
             $query->insert('#__zoo_item');
             $cols = array();
             $vals = array();
             $cols[] = 'application_id';
             $vals[] = '1';
             $cols[] = 'type';
             $vals[] = $db->quote('kelione');
             $cols[] = 'state';
             $vals[] = '0';
             $cols[] = 'access';
             $vals[] = '1';
             $cols[] = 'created';
             $vals[] = 'NOW()';
             $cols[] = 'created_by';
             $vals[] = (int) $userId;
             $cols[] = 'modified';
             $vals[] = 'NOW()';
             $cols[] = 'modified_by';
             $vals[] = (int) $userId;
             $cols[] = 'publish_up';
             $vals[] = $db->quote('0000-00-00 00:00:00');
             $cols[] = 'publish_down';
             $vals[] = $db->quote('0000-00-00 00:00:00');
             $cols[] = 'priority';
             $vals[] = '0';
             $cols[] = 'hits';
             $vals[] = '0';
             $cols[] = 'created_by_alias';
             $vals[] = "''";
             $cols[] = 'searchable';
             $vals[] = '0';
             $cols[] = 'name';
             $vals[] = $db->quote($kelione->pavadinimas);
             $alias = $this->getUniqueAlias($kelione->pavadinimas);
             $cols[] = 'alias';
             $vals[] = $db->quote($alias);
             $cols[] = 'elements';
             $vals[] = $db->quote($kelione->Serialize());
             $arr = $kelione->salys->toArray();
             $catId = $this->getCategoryId($arr[0], $parentId);
             $paramsX = ' { "config.enable_comments": "0", "config.primary_category": "' . $catId . '" }';
             $cols[] = 'params';
             $vals[] = $db->quote($paramsX);
             $query->columns($cols);
             $query->values(implode(', ', $vals));
             $db->setQuery($query);
             if (!$db->execute()) {
                 $error[] = $db->getErrorNum() . ': Nepavyko importuoti kelionės (ID ' . $kelione->id . ').';
             } else {
                 //Iterpiam kategorijas
                 $itemId = $this->getItemIdByAlias($alias);
                 if ($itemId) {
                     $this->createSarysis($kelione->id, $itemId);
                     $this->setItemsCategories($itemId, $arr, $parentId);
                 }
             }
         }
     }
     if (!empty($error)) {
         $this->setMessage(implode('<br>', $error), 'error');
     }
     //importuojam paveikslelius
     $stid = implode(',', $tid);
     //pasirinktu kelioniu ID
     return $this->setRedirect(JRoute::_("index.php?option=com_kelioniuimportas&view=downloadimages&ckey={$cKey}&ttid={$ttid}&tid={$stid}", false));
 }
示例#5
0
 public function update()
 {
     $msg = '';
     $db = JFactory::getDbo();
     $cKey = JRequest::getString('ckey');
     $aId = JRequest::getVar('aid');
     //pasirinktu pasalinti kelioniu ID
     if (count($aId) > 0) {
         JArrayHelper::toInteger($aId, 0);
         $db->setQuery('UPDATE #__zoo_item SET state=0 WHERE id IN (' . implode(',', $aId) . ')');
         if ($db->execute()) {
             $msg .= count($aId) . ' kelionės pažymėtos neaktyviomis.<br>';
         } else {
         }
     }
     $bId = JRequest::getVar('bid');
     //pasirinktu aktyvinimui kelioniu ID
     if (count($bId) > 0) {
         JArrayHelper::toInteger($bId, 0);
         $db->setQuery('UPDATE #__zoo_item SET state=1 WHERE id IN (' . implode(',', $bId) . ')');
         if ($db->execute()) {
             $msg .= count($bId) . ' kelionės aktyvintos.<br>';
         } else {
         }
     }
     $cId = JRequest::getVar('cid');
     //pasirinktu aktyvinimui kelioniu ID
     if (count($cId) > 0) {
         JArrayHelper::toInteger($cId, 0);
         require_once JPATH_COMPONENT . '/helpers/data.php';
         $keliones = new Keliones();
         $keliones->LoadCountriesListFromXMLFile();
         $keliones->LoadAllFromXML();
         $i = 0;
         $j = 0;
         foreach ($cId as $zoo_id) {
             $db->setQuery('SELECT id FROM #__kelioniuimportas WHERE zoo_item_id = ' . (int) $zoo_id);
             $gruda_id = (int) $db->loadResult();
             if ($gruda_id) {
                 $kelione = $keliones->getByID($gruda_id);
                 if ($kelione) {
                     $db->setQuery('SELECT elements FROM #__zoo_item WHERE id = ' . (int) $zoo_id);
                     $result = $db->loadResult();
                     if ($result) {
                         $elements = json_decode($result, true);
                         $datosSer = $kelione->datos->Serialize();
                         if ($datosSer) {
                             $datosSer = str_replace('"d198fa4e-8df3-4854-a717-893281154ff8": ', '', $datosSer);
                             $datos = json_decode($datosSer, true);
                             $elements['d198fa4e-8df3-4854-a717-893281154ff8'] = $datos;
                         } else {
                             unset($elements['d198fa4e-8df3-4854-a717-893281154ff8']);
                             $j++;
                         }
                         $db->setQuery('UPDATE #__zoo_item SET elements=' . $db->quote(json_encode((object) $elements)) . ' WHERE id = ' . (int) $zoo_id);
                         if ($db->execute()) {
                             $i++;
                         } else {
                             $msg .= '<p class="error">Įvyko klaida atnaujinant kelionę ZOO_ID=' . $zoo_id . '</p><br>';
                         }
                     }
                 }
             }
         }
         if ($i > 0) {
             if ($j > 0) {
                 $msg .= (int) $i . ' kelionių atnaujintos išvykimo datos (' . $j . ' iš jų pašalintos viso išvykimo datos).<br>';
             } else {
                 $msg .= (int) $i . ' kelionių atnaujintos išvykimo datos.<br>';
             }
         }
     }
     if ($msg) {
         $this->setMessage($msg);
     }
     return $this->setRedirect(JRoute::_("index.php?option=com_kelioniuimportas&view=update&ckey={$cKey}", false));
 }