示例#1
0
 /**
  * do the plug-in action
  * @param	object	parameters
  * @param	object	table model
  * @param	array	custom options
  */
 function process(&$params, &$model, $opts = array())
 {
     JLoader::import('webservice', JPATH_SITE . '/components/com_fabrik/models/');
     $params = $this->getParams();
     $fk = $params->get('webservice_foreign_key');
     $formModel = $model->getFormModel();
     $fk = $formModel->getElement($fk, true)->getElement()->name;
     $credentials = $this->getCredentials();
     $driver = $params->get('webservice_driver');
     $opts = array('driver' => $driver, 'endpoint' => $params->get('webservice_url'), 'credentials' => $credentials);
     $service = FabrikWebService::getInstance($opts);
     if (JError::isError($service)) {
         echo $service->getMessage();
         JError::raiseError(500, $service->getMessage());
         jexit();
     }
     $filters = $this->getServiceFilters($service);
     $service->setMap($this->getMap($formModel));
     $filters = array_merge($opts['credentials'], $filters);
     $method = $params->get('webservice_get_method');
     $startPoint = $params->get('webservice_start_point');
     $serviceData = $service->get($method, $filters, $startPoint, null);
     $update = (bool) $params->get('webservice_update_existing', false);
     $service->storeLocally($model, $serviceData, $fk, $update);
     $this->msg = JText::sprintf($params->get('webservice_msg'), $service->addedCount, $service->updateCount);
     return true;
 }
示例#2
0
    $modelpaths = JModel::addIncludePath(JPATH_SITE . '/plugins/fabrik_' . $type . '/' . $name . '/models');
}
$app = JFactory::getApplication();
$package = JRequest::getVar('package', 'fabrik');
$app->setUserState('com_fabrik.package', $package);
// Web service testing
JLoader::import('webservice', JPATH_SITE . '/components/com_fabrik/models/');
if (JRequest::getVar('soap') == 1) {
    $opts = array('driver' => 'soap', 'endpoint' => 'http://webservices.activetickets.com/members/ActiveTicketsMembersServices.asmx?WSDL', 'credentials' => array('Clientname' => "SPLFenix", 'LanguageCode' => "nl"));
    $service = FabrikWebService::getInstance($opts);
    $params = $opts['credentials'];
    $params['From'] = JFactory::getDate()->toISO8601();
    $params['To'] = JFactory::getDate('next year')->toISO8601();
    $params['IncludePrices'] = true;
    $params['MemberId'] = 14;
    $method = JRequest::getVar($method, 'GetProgramList');
    $program = $service->get($method, $params, '//ProgramList/Program', null);
    $listModel = JModel::getInstance('List', 'FabrikFEModel');
    $listModel->setId(7);
    $service->storeLocally($listModel, $program);
}
if (JRequest::getVar('yql') == 1) {
    $opts = array('driver' => 'yql', 'endpoint' => 'https://query.yahooapis.com/v1/public/yql');
    $service = FabrikWebService::getInstance($opts);
    $query = "select * from upcoming.events where location='London'";
    $program = $service->get($query, array(), 'event', null);
}
// End web service testing
$controller->execute($task);
// Redirect if set by the controller
$controller->redirect();
示例#3
0
 /**
  * Get an array of key/value filters to send to the web service
  *
  * @param   FabrikWebService  $service  The current web service being used
  *
  * @return  array  key/val pairs
  */
 protected function getServiceFilters($service)
 {
     $params = $this->getParams();
     $filters = json_decode($params->get('webservice_filters'));
     $return = array();
     $keys = $filters->webservice_filters_key;
     $vals = $filters->webservice_filters_value;
     $types = $filters->webservice_filters_type;
     $n = count($keys);
     for ($i = 0; $i < $n; $i++) {
         $return[$keys[$i]] = $service->getFilterValue($vals[$i], $types[$i]);
     }
     return $return;
 }