/** * Upload Content Element to redcore media location * * @param string $option The Extension Name ex. com_redcore * @param array $files The array of Files (file descriptor returned by PHP) * * @return boolean Returns true if Upload was successful */ public static function uploadContentElement($option = 'com_redcore', $files = array()) { $uploadOptions = array('allowedFileExtensions' => 'xml', 'allowedMIMETypes' => 'application/xml, text/xml', 'overrideExistingFile' => true); return RFilesystemFile::uploadFiles($files, RTranslationContentElement::getContentElementFolderPath($option), $uploadOptions); }
/** * Upload Webservices config files to redcore media location * * @param array $files The array of Files (file descriptor returned by PHP) * * @return boolean Returns true if Upload was successful */ public static function uploadWebservice($files = array()) { $uploadOptions = array('allowedFileExtensions' => 'xml', 'allowedMIMETypes' => 'application/xml, text/xml', 'overrideExistingFile' => true); foreach ($files as $key => &$file) { $objectFile = new JObject($file); try { $content = file_get_contents($objectFile->tmp_name); $fileContent = null; if (is_string($content)) { $fileContent = new SimpleXMLElement($content); } $name = (string) $fileContent->config->name; $version = !empty($fileContent->config->version) ? (string) $fileContent->config->version : '1.0.0'; $client = self::getWebserviceClient($fileContent); $file['name'] = $client . '.' . $name . '.' . $version . '.xml'; } catch (Exception $e) { unset($files[$key]); JFactory::getApplication()->enqueueMessage(JText::_('COM_REDCORE_WEBSERVICES_WEBSERVICE_FILE_NOT_VALID'), 'message'); } } return RFilesystemFile::uploadFiles($files, self::getWebservicesPath() . '/upload', $uploadOptions); }