/** * * @param unknown $params */ public function __invoke($params) { if (count($params) != 2) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s DELIVERY_URI OUTPUT_FILE', __CLASS__)); } $deliveryUri = array_shift($params); $delivery = new \core_kernel_classes_Resource($deliveryUri); if (!$delivery->exists()) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Delivery \'%s\' not found', $deliveryUri)); } $file = array_shift($params); \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); $tmpFile = Assembler::exportCompiledDelivery($delivery); \tao_helpers_File::move($tmpFile, $file); return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exported %1$s to %2$s', $delivery->getLabel(), $file)); }
/** * (non-PHPdoc) * @see \oat\oatbox\action\Action::__invoke() */ public function __invoke($params) { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); if (count($params) != 2) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s DELIVERY_CLASS_URI OUTPUT_DIRECTORY', __CLASS__)); } $deliveryClassUri = array_shift($params); $deliveryClass = new \core_kernel_classes_Class($deliveryClassUri); $dir = array_shift($params); if (!file_exists($dir) && !mkdir($dir)) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Directory %s doesn\'t exist', $dir)); } $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exporting %s', $deliveryClass->getLabel())); foreach ($deliveryClass->getInstances(true) as $delivery) { $destFile = $dir . \tao_helpers_File::getSafeFileName($delivery->getLabel()) . '.zip'; $tmpFile = Assembler::exportCompiledDelivery($delivery); \tao_helpers_File::move($tmpFile, $destFile); $report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exported %1$s to %2$s', $delivery->getLabel(), $destFile))); } return $report; }
* modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; under version 2 * of the License (non-upgradable). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2); * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER); * 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV); * */ require_once dirname(__FILE__) . '/../includes/raw_start.php'; $parms = $argv; $script = array_shift($parms); if (count($parms) != 2) { echo "Usage: " . $script . " DELIVERY_URI OUTPUT_FILE\n"; } else { $deliveryUri = array_shift($parms); $file = array_shift($parms); $delivery = new core_kernel_classes_Resource($deliveryUri); $tmpFile = taoDelivery_models_classes_import_Assembler::exportCompiledDelivery($delivery); tao_helpers_File::move($tmpFile, $file); echo "Done"; }
/** * Return a valid uploaded file * * @return string * @throws \common_Exception * @throws \common_exception_Error * @throws \common_exception_MissingParameter * @throws \common_exception_BadRequest * @throws \oat\tao\helpers\FileUploadException */ protected function getUploadedPackage() { if (!$this->hasRequestParameter(self::RESTITEM_PACKAGE_NAME)) { throw new \common_exception_MissingParameter(self::RESTITEM_PACKAGE_NAME, __CLASS__); } $file = \tao_helpers_Http::getUploadedFile(self::RESTITEM_PACKAGE_NAME); if (!in_array($file['type'], self::$accepted_types)) { throw new \common_exception_BadRequest('Uploaded file has to be a valid archive.'); } $pathinfo = pathinfo($file['tmp_name']); $destination = $pathinfo['dirname'] . DIRECTORY_SEPARATOR . $file['name']; \tao_helpers_File::move($file['tmp_name'], $destination); return $destination; }
/** * * @access * @author "Lionel Lecaque, <*****@*****.**>" * @param unknown $ext * @return boolean */ public function unShield($ext) { $extFolder = ROOT_PATH . DIRECTORY_SEPARATOR . $ext; if (!is_file($extFolder . '/htaccess.1')) { common_Logger::d('Previous lock, ' . $extFolder . '/htaccess.1 do not exits something may have go wrong, please check'); return false; } if (unlink($extFolder . '/.htaccess')) { return tao_helpers_File::move($extFolder . '/htaccess.1', $extFolder . '/.htaccess', true, false); } else { common_Logger::i('Fail to remove htaccess in ' . $ext . ' . You may copy by hand file htaccess.1'); return false; } }