Beispiel #1
0
 /**
  * Method to save the form data to XML file.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success, False on error.
  *
  * @throws  RuntimeException
  *
  * @since   1.4
  */
 public function saveXml($data)
 {
     $dataRegistry = new JRegistry($data);
     $item = null;
     if (empty($data['main']['name'])) {
         $this->setError(JText::_('COM_REDCORE_WEBSERVICE_NAME_FIELD_CANNOT_BE_EMPTY'));
         return false;
     }
     if (!empty($data['main']['id'])) {
         $item = $this->getItem($data['main']['id']);
     }
     $client = $dataRegistry->get('main.client', 'site');
     $name = $dataRegistry->get('main.name', '');
     $version = $dataRegistry->get('main.version', '1.0.0');
     $folder = $dataRegistry->get('main.path', '');
     $folder = !empty($folder) ? JPath::clean('/' . $folder) : '';
     if (!JFolder::exists(RApiHalHelper::getWebservicesPath() . $folder)) {
         JFolder::create(RApiHalHelper::getWebservicesPath() . $folder);
     }
     $fullPath = JPath::clean(RApiHalHelper::getWebservicesPath() . $folder . '/' . $client . '.' . $name . '.' . $version . '.xml');
     $xml = new SimpleXMLElement('<?xml version="1.0"?><apiservice client="' . $client . '"></apiservice>');
     $xml->addChild('name', $dataRegistry->get('main.title', $name));
     $xml->addChild('author', $dataRegistry->get('main.author', ''));
     $xml->addChild('copyright', $dataRegistry->get('main.copyright', ''));
     $xml->addChild('description', $dataRegistry->get('main.description', ''));
     $configXml = $xml->addChild('config');
     $configXml->addChild('name', $dataRegistry->get('main.name', ''));
     $configXml->addChild('version', $version);
     $configXml->addChild('authorizationAssetName', $dataRegistry->get('main.authorizationAssetName', ''));
     $operationsXml = $xml->addChild('operations');
     $readXml = null;
     $taskXml = null;
     foreach ($data as $operationName => $operation) {
         if ($operationName != 'main') {
             if (empty($operation['isEnabled'])) {
                 continue;
             }
             $operationNameSplit = explode('-', $operationName);
             if ($operationNameSplit[0] == 'read' && count($operationNameSplit) > 1) {
                 if (is_null($readXml)) {
                     $readXml = $operationsXml->addChild('read');
                 }
                 $operationXml = $readXml->addChild($operationNameSplit[1]);
             } elseif ($operationNameSplit[0] == 'task' && count($operationNameSplit) > 1) {
                 if (is_null($taskXml)) {
                     $taskXml = $operationsXml->addChild('task');
                 }
                 $operationXml = $taskXml->addChild($operationNameSplit[1]);
             } else {
                 $operationXml = $operationsXml->addChild($operationNameSplit[0]);
             }
             $this->getOperationAttributesFromPost($operationXml, $data, $operationName);
             $this->getFieldsFromPost($operationXml, $data, $operationName);
             $this->getResourcesFromPost($operationXml, $data, $operationName);
         }
     }
     // Needed for formatting
     $dom = dom_import_simplexml($xml)->ownerDocument;
     $dom->preserveWhiteSpace = false;
     $dom->formatOutput = true;
     if ($dom->save($fullPath)) {
         if (!empty($item->id)) {
             $folder = !empty($item->path) ? '/' . $item->path : '';
             $oldPath = JPath::clean(RApiHalHelper::getWebservicesPath() . $folder . '/' . $item->xmlFile);
             if ($oldPath != $fullPath) {
                 if (JFile::exists($oldPath)) {
                     JFile::delete($oldPath);
                 }
             }
         }
         $wsdl = RApiSoapHelper::generateWsdl($xml);
         $fullWsdlPath = substr($fullPath, 0, -4) . '.wsdl';
         return RApiSoapHelper::saveWsdlContentToPath($wsdl, $fullWsdlPath);
     }
     return false;
 }
Beispiel #2
0
								<td style="word-wrap:break-word;">
									<?php 
        $folder = !empty($item->path) ? '/' . $item->path : '';
        ?>
									<?php 
        echo RApiHalHelper::getWebservicesRelativePath();
        ?>
									<strong><?php 
        echo $folder;
        ?>
/<span class="lc-webservice-file"><?php 
        echo $item->xmlFile;
        ?>
</span></strong>
									<?php 
        if (!JFile::exists(RApiHalHelper::getWebservicesPath() . $folder . '/' . $item->xmlFile)) {
            ?>
										<span class="label label-danger"><?php 
            echo JText::_('COM_REDCORE_WEBSERVICES_XML_MISSING');
            ?>
</span>
									<?php 
        } elseif ($item->xmlHashed != md5($item->xml)) {
            ?>
										<span class="label label-warning"><?php 
            echo JText::_('COM_REDCORE_WEBSERVICES_XML_CHANGED');
            ?>
</span>
									<?php 
        } else {
            ?>
Beispiel #3
0
 /**
  * Uninstall the webservices
  *
  * @param   JInstallerAdapter  $parent  class calling this method
  *
  * @return  boolean
  */
 protected function uninstallWebservices($parent)
 {
     // Required objects
     $manifest = $this->getManifest($parent);
     if (!$manifest) {
         return false;
     }
     // We will use webservices removal function to remove webservice files
     $element = $manifest->webservices;
     if (!$element || !count($element->children())) {
         // Either the tag does not exist or has no children therefore we return zero files processed.
         return true;
     }
     $returnValue = true;
     // Get the array of file nodes to process
     $files = $element->children();
     $source = RApiHalHelper::getWebservicesPath();
     // Process each file in the $files array (children of $tagName).
     foreach ($files as $file) {
         $path = $source . '/' . $file;
         // Actually delete the files/folders
         if (is_dir($path)) {
             $val = JFolder::delete($path);
         } else {
             $val = JFile::delete($path);
         }
         if ($val === false) {
             JLog::add(JText::sprintf('LIB_REDCORE_INSTALLER_ERROR_FAILED_TO_DELETE', $path), JLog::WARNING, 'jerror', JLog::WARNING, 'jerror');
             $returnValue = false;
         }
     }
     return $returnValue;
 }