function import($tpl = null) { $id = (int) JRequest::getVar('id'); $syn = new studioSynchronizer(); $result = $syn->import($id); $app = JFactory::getApplication(); if ($result['message'] == "") { $app->enqueueMessage(JText::_($result['update'] . ' Map(s) are Updated and ' . $result['insert'] . ' Added Successfully!'), 'success'); } else { $app->enqueueMessage(JText::_($result['message']), 'error'); } $url = JRoute::_('index.php?option=com_mapfigstudio'); $app->redirect($url); }
public function refreshAction() { $id = $_GET['id']; include STUDIO_DOCROOT . "/includes/studioSynchronizer.class.php"; $studio = new studioSynchronizer(); $data = $studio->import($id); //when api key is not correct or no map exist if (!$data['success']) { header("location:" . url("mapfig-studio?msg=error")); exit; } $studioObj = $data['message']; foreach ($studioObj as $s) { $exists = $this->mStudioObj->getByStudioId($s->id); $mapfigStudio = array("studio_id" => $s->id, "width" => $s->width, "height" => $s->height, "title" => $s->title, "html" => addslashes($s->html)); if (count($exists) > 0) { $this->mStudioObj->update($mapfigStudio, $exists->id); } else { $this->mStudioObj->insert($mapfigStudio); } } header("location:" . url("mapfig-studio?msg=refresh")); exit; }