/** * Execute the Api Default Page operation. * * @return mixed RApi object with information on success, boolean false on failure. * * @since 1.2 */ public function apiDefaultPage() { // Add standard Joomla namespace as curie. $documentationCurieAdmin = new RApiHalDocumentLink('/index.php?option={rel}&format=doc&webserviceClient=administrator', 'curies', 'Documentation Admin', 'Admin', null, true); $documentationCurieSite = new RApiHalDocumentLink('/index.php?option={rel}&format=doc&webserviceClient=site', 'curies', 'Documentation Site', 'Site', null, true); // Add basic hypermedia links. $this->hal->setLink($documentationCurieAdmin, false, true); $this->hal->setLink($documentationCurieSite, false, true); $this->hal->setLink(new RApiHalDocumentLink(JUri::base(), 'base', JText::_('LIB_REDCORE_API_HAL_WEBSERVICE_DOCUMENTATION_DEFAULT_PAGE'))); $webservices = RApiHalHelper::getInstalledWebservices(); if (!empty($webservices)) { foreach ($webservices as $webserviceClient => $webserviceNames) { foreach ($webserviceNames as $webserviceName => $webserviceVersions) { foreach ($webserviceVersions as $webserviceVersion => $webservice) { if ($webservice['state'] == 1) { $documentation = $webserviceClient == 'site' ? 'Site' : 'Admin'; // Set option and view name $this->setOptionViewName($webservice['name'], $this->configuration); $webserviceUrlPath = '/index.php?option=' . $this->optionName . '&webserviceVersion=' . $webserviceVersion; if (!empty($this->viewName)) { $webserviceUrlPath .= '&view=' . $this->viewName; } // We will fetch only top level webservice $this->hal->setLink(new RApiHalDocumentLink($webserviceUrlPath . '&webserviceClient=' . $webserviceClient, $documentation . ':' . $webservice['name'], $webservice['title'])); break; } } } } } return $this; }
/** * Preforms Batch action against all Webservices * * @param string $action Action to preform * * @return boolean Returns true if Action was successful */ public function batchWebservices($action = '') { $webservices = RApiHalHelper::getWebservices(); if (!empty($webservices)) { $model = $this->getModel('webservices'); $installedWebservices = RApiHalHelper::getInstalledWebservices(); foreach ($webservices as $webserviceNames) { foreach ($webserviceNames as $webserviceVersions) { foreach ($webserviceVersions as $webservice) { $client = RApiHalHelper::getWebserviceClient($webservice); $path = $webservice->webservicePath; $name = (string) $webservice->config->name; $version = (string) $webservice->config->version; // If it is already install then we skip it if (!empty($installedWebservices[$client][$name][$version])) { continue; } switch ($action) { case 'install': $model->installWebservice($client, $name, $version, $path); break; case 'delete': $model->deleteWebservice($client, $name, $version, $path); break; } } } } } return true; }