当前位置: 首页>>代码示例>>PHP>>正文


PHP FileManager::writeFile方法代码示例

本文整理汇总了PHP中FileManager::writeFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::writeFile方法的具体用法?PHP FileManager::writeFile怎么用?PHP FileManager::writeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileManager的用法示例。


在下文中一共展示了FileManager::writeFile方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the import command.
  */
 function execute()
 {
     $importer =& new ImportOJS1();
     if ($importer->import($this->journalPath, $this->importPath, $this->options)) {
         $redirects = $importer->getRedirects();
         $conflicts = $importer->getConflicts();
         // Generate redirect files if redirect option enabled
         $redirectResults = $redirectSummary = '';
         if (in_array('redirect', $this->options) && !empty($redirects)) {
             $redirectFilesDir = Config::getVar('files', 'files_dir') . DIRECTORY_SEPARATOR . 'redirect' . DIRECTORY_SEPARATOR . $this->journalPath;
             $redirectSummary = "\n\nRedirect PHP files have been created in the following directory:\n\n{$redirectFilesDir}\n\nTo enable redirection, these files will need to be moved to either the OJS 1 filesystem path, or, for single journal installations, to the OJS 2 filesystem path. Once these files are moved, you can safely delete the redirect directory ({$redirectFilesDir}) created by this tool.\n\nSee {$redirectFilesDir}" . DIRECTORY_SEPARATOR . "README for more information.\n";
             $redirectReadme = "To enable redirection, the following files will need to be moved to either the OJS 1 filesystem path, or, for single journal installations, to the OJS 2 filesystem path. Once these files are moved, you can safely delete the redirect directory ({$redirectFilesDir}).\n\n";
             reset($redirects);
             $errors = false;
             while (list($key, $redirect) = each($redirects)) {
                 $redirectFile = $redirect[0];
                 $redirectDescKey = $redirect[1];
                 $redirectContents = $redirect[2];
                 $redirectFilePath = $redirectFilesDir . DIRECTORY_SEPARATOR . $redirectFile;
                 if (FileManager::writeFile($redirectFilePath, $redirectContents) !== false) {
                     $redirectReadme .= "{$redirectFile}\n";
                     $redirectReadme .= "-- " . Locale::translate($redirectDescKey) . "\n\n";
                 } else {
                     $errors = true;
                     $redirectSummary .= "\n\nError writing {$redirectFilePath}. Please ensure that the user running this script has write permission to the OJS 2 files directory.";
                 }
             }
             if (!$errors) {
                 FileManager::writeFile($redirectFilesDir . DIRECTORY_SEPARATOR . 'README', $redirectReadme);
             }
         }
         // Get conflicts from user import
         $conflictSummary = '';
         if (!empty($conflicts)) {
             $conflictSummary = "\n\n" . Locale::translate('admin.journals.importOJS1.conflict.desc') . "\n";
             while (list($key, $conflict) = each($conflicts)) {
                 $firstUser = $conflict[0];
                 $secondUser = $conflict[1];
                 $conflictSummary .= "\n* " . Locale::translate('admin.journals.importOJS1.conflict', array("firstUsername" => $firstUser->getUsername(), "firstName" => $firstUser->getFullName(), "secondUsername" => $secondUser->getUsername(), "secondName" => $secondUser->getFullName()));
             }
         }
         printf("Import completed\n" . "Users imported:     %u\n" . "Issues imported:    %u\n" . "Articles imported:  %u\n" . "%s\n", $importer->userCount, $importer->issueCount, $importer->articleCount, $redirectSummary . $conflictSummary);
     } else {
         printf("Import failed!\nERROR: %s\n", $importer->error());
     }
 }
开发者ID:LiteratimBi,项目名称:jupitertfn,代码行数:49,代码来源:migrate.php

示例2: saveLocaleFile

 function saveLocaleFile($args)
 {
     $this->validate();
     $plugin =& PluginRegistry::getPlugin('generic', 'CustomLocalePlugin');
     $this->setupTemplate($plugin, true);
     $locale = array_shift($args);
     if (!Locale::isLocaleValid($locale)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'index');
         Request::redirect(null, null, null, $path);
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!CustomLocaleAction::isLocaleFile($locale, $filename)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'edit', $locale);
         Request::redirect(null, null, null, $path);
     }
     $journal =& Request::getJournal();
     $journalId = $journal->getId();
     $changes = Request::getUserVar('changes');
     $customFilesDir = Config::getVar('files', 'public_files_dir') . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale;
     $customFilePath = $customFilesDir . DIRECTORY_SEPARATOR . $filename;
     // Create empty custom locale file if it doesn't exist
     import('file.FileManager');
     import('file.EditableLocaleFile');
     if (!FileManager::fileExists($customFilePath)) {
         $numParentDirs = substr_count($customFilePath, DIRECTORY_SEPARATOR);
         $parentDirs = '';
         for ($i = 0; $i < $numParentDirs; $i++) {
             $parentDirs .= '..' . DIRECTORY_SEPARATOR;
         }
         $newFileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $newFileContents .= '<!DOCTYPE locale SYSTEM "' . $parentDirs . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'dtd' . DIRECTORY_SEPARATOR . 'locale.dtd' . '">' . "\n";
         $newFileContents .= '<locale name="' . $locale . '">' . "\n";
         $newFileContents .= '</locale>';
         FileManager::writeFile($customFilePath, $newFileContents);
     }
     $file = new EditableLocaleFile($locale, $customFilePath);
     while (!empty($changes)) {
         $key = array_shift($changes);
         $value = $this->correctCr(array_shift($changes));
         if (!empty($value)) {
             if (!$file->update($key, $value)) {
                 $file->insert($key, $value);
             }
         } else {
             $file->delete($key);
         }
     }
     $file->write();
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
开发者ID:philschatz,项目名称:ojs,代码行数:50,代码来源:CustomLocaleHandler.inc.php

示例3: import

 /**
  * Register objects
  * @param $objects array
  * @param $filter string
  * @param $journal Journal
  * @param $objectsFileNamePart string
  */
 function _registerObjects($objects, $filter, $journal, $objectsFileNamePart)
 {
     $plugin = $this->_plugin;
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     // export XML
     $exportXml = $plugin->exportXML($objects, $filter, $journal);
     // Write the XML to a file.
     $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectFileNamePart, $journal, '.xml');
     $fileManager->writeFile($exportFileName, $exportXml);
     // Deposit the XML file.
     $result = $plugin->depositXML($objects, $journal, $exportFileName);
     if ($result !== true) {
         $this->_addLogEntry($result);
     }
     // Remove all temporary files.
     $fileManager->deleteFile($exportFileName);
 }
开发者ID:pkp,项目名称:ojs,代码行数:25,代码来源:MedraInfoSender.inc.php

示例4: import

 /**
  * Register objects
  * @param $objects array
  * @param $filter string
  * @param $journal Journal
  * @param $objectsFileNamePart string
  */
 function _registerObjects($objects, $filter, $journal, $objectsFileNamePart)
 {
     $plugin = $this->_plugin;
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     foreach ($objects as $object) {
         // export XML
         $exportXml = $plugin->exportXML($object, $filter, $journal);
         // Write the XML to a file.
         // export file name example: datacite-20160723-160036-articles-1-1.xml
         $objectFileNamePart = $objectsFileNamePart . '-' . $object->getId();
         $exportFileName = $plugin->getExportFileName($plugin->getExportPath(), $objectFileNamePart, $journal, '.xml');
         $fileManager->writeFile($exportFileName, $exportXml);
         // Deposit the XML file.
         $result = $plugin->depositXML($object, $journal, $exportFileName);
         if ($result !== true) {
             $this->_addLogEntry($result);
         }
         // Remove all temporary files.
         $fileManager->deleteFile($exportFileName);
     }
 }
开发者ID:pkp,项目名称:ojs,代码行数:29,代码来源:DataciteInfoSender.inc.php

示例5: display

 /**
  * Display the plugin.
  * @param $args array
  * @param $request PKPRequest
  */
 function display($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $press = $request->getPress();
     parent::display($args, $request);
     $templateMgr->assign('plugin', $this);
     switch (array_shift($args)) {
         case 'index':
         case '':
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
         case 'uploadImportXML':
             $user = $request->getUser();
             import('lib.pkp.classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
             if ($temporaryFile) {
                 $json = new JSONMessage(true);
                 $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
             } else {
                 $json = new JSONMessage(false, __('common.uploadFailed'));
             }
             return $json->getString();
         case 'importBounce':
             $json = new JSONMessage(true);
             $json->setEvent('addTab', array('title' => __('plugins.importexport.native.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId')))));
             return $json->getString();
         case 'import':
             AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
             $temporaryFileId = $request->getUserVar('temporaryFileId');
             $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
             $user = $request->getUser();
             $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
             if (!$temporaryFile) {
                 $json = new JSONMessage(true, __('plugins.inportexport.native.uploadFile'));
                 return $json->getString();
             }
             $temporaryFilePath = $temporaryFile->getFilePath();
             $deployment = new NativeImportExportDeployment($press, $user);
             libxml_use_internal_errors(true);
             $submissions = $this->importSubmissions(file_get_contents($temporaryFilePath), $deployment);
             $templateMgr->assign('submissions', $submissions);
             $validationErrors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR ||  $a->level == LIBXML_ERR_FATAL;'));
             $templateMgr->assign('validationErrors', $validationErrors);
             libxml_clear_errors();
             // Are there any submissions import errors
             $processedSubmissionsIds = $deployment->getProcessedObjectsIds(ASSOC_TYPE_SUBMISSION);
             if (!empty($processedSubmissionsIds)) {
                 $submissionsErrors = array_filter($processedSubmissionsIds, create_function('$a', 'return !empty($a);'));
                 if (!empty($submissionsErrors)) {
                     $templateMgr->assign('submissionsErrors', $processedSubmissionsIds);
                 }
             }
             // If there are any submissions or validataion errors
             // delete imported submissions.
             if (!empty($submissionsErrors) || !empty($validationErrors)) {
                 // remove all imported sumissions
                 $deployment->removeImportedObjects(ASSOC_TYPE_SUBMISSION);
             }
             // Display the results
             $json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl'));
             return $json->getString();
         case 'export':
             $exportXml = $this->exportSubmissions((array) $request->getUserVar('selectedSubmissions'), $request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.FileManager');
             $fileManager = new FileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'monographs', $press, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
开发者ID:NateWr,项目名称:omp,代码行数:81,代码来源:NativeImportExportPlugin.inc.php

示例6: execute

 /**
  * Save settings. 
  */
 function execute()
 {
     $plugin =& $this->plugin;
     $journalId = $this->journalId;
     $css = '';
     // Header and footer colours
     $customThemeHeaderColour = $this->getData('customThemeHeaderColour');
     $plugin->updateSetting($journalId, 'customThemeHeaderColour', $customThemeHeaderColour, 'string');
     $css .= "#header {background-color: {$customThemeHeaderColour};}\n";
     $css .= "#footer {background-color: {$customThemeHeaderColour};}\n";
     $css .= "table.listing tr.fastTracked {background-color: {$customThemeHeaderColour};}\n";
     // Link colours
     $customThemeLinkColour = $this->getData('customThemeLinkColour');
     $plugin->updateSetting($journalId, 'customThemeLinkColour', $customThemeLinkColour, 'string');
     $css .= "a {color: {$customThemeLinkColour};}\n";
     $css .= "a:link {color: {$customThemeLinkColour};}\n";
     $css .= "a:active {color: {$customThemeLinkColour};}\n";
     $css .= "a:visited {color: {$customThemeLinkColour};}\n";
     $css .= "a:hover {color: {$customThemeLinkColour};}\n";
     $css .= "input.defaultButton {color: {$customThemeLinkColour};}\n";
     // Background colours
     $customThemeBackgroundColour = $this->getData('customThemeBackgroundColour');
     $plugin->updateSetting($journalId, 'customThemeBackgroundColour', $customThemeBackgroundColour, 'string');
     $css .= "body {background-color: {$customThemeBackgroundColour};}\n";
     $css .= "input.defaultButton {background-color: {$customThemeBackgroundColour};}\n";
     // Foreground colours
     $customThemeForegroundColour = $this->getData('customThemeForegroundColour');
     $plugin->updateSetting($journalId, 'customThemeForegroundColour', $customThemeForegroundColour, 'string');
     $css .= "body {color: {$customThemeForegroundColour};}\n";
     $css .= "input.defaultButton {color: {$customThemeForegroundColour};}\n";
     import('file.FileManager');
     FileManager::writeFile(dirname(__FILE__) . '/custom.css', $css);
 }
开发者ID:Jouper,项目名称:jouper,代码行数:36,代码来源:CustomThemeSettingsForm.inc.php

示例7: display

 /**
  * Display the plugin.
  * @param $args array
  * @param $request PKPRequest
  */
 function display($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $press = $request->getPress();
     parent::display($args, $request);
     $templateMgr->assign('plugin', $this);
     switch (array_shift($args)) {
         case 'index':
         case '':
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
         case 'export':
             $exportXml = $this->exportSubmissions((array) $request->getUserVar('selectedSubmissions'), $request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.FileManager');
             $fileManager = new FileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'monographs', $press, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
开发者ID:PublishingWithoutWalls,项目名称:omp,代码行数:30,代码来源:Onix30ExportPlugin.inc.php

示例8: executeExportAction

 /**
  * @copydoc PubObjectsExportPlugin::executeExportAction()
  */
 function executeExportAction($request, $objects, $filter, $tab, $objectsFileNamePart)
 {
     $context = $request->getContext();
     $path = array('plugin', $this->getName());
     if ($request->getUserVar(EXPORT_ACTION_DEPOSIT)) {
         assert($filter != null);
         // Get the XML
         $exportXml = $this->exportXML($objects, $filter, $context);
         // Write the XML to a file.
         // export file name example: crossref-20160723-160036-articles-1.xml
         import('lib.pkp.classes.file.FileManager');
         $fileManager = new FileManager();
         $exportFileName = $this->getExportFileName($this->getExportPath(), $objectsFileNamePart, $context, '.xml');
         $fileManager->writeFile($exportFileName, $exportXml);
         // Deposit the XML file.
         $result = $this->depositXML($objects, $context, $exportFileName);
         // send notifications
         if ($result === true) {
             $this->_sendNotification($request->getUser(), $this->getDepositSuccessNotificationMessageKey(), NOTIFICATION_TYPE_SUCCESS);
         } else {
             if (is_array($result)) {
                 foreach ($result as $error) {
                     assert(is_array($error) && count($error) >= 1);
                     $this->_sendNotification($request->getUser(), $error[0], NOTIFICATION_TYPE_ERROR, isset($error[1]) ? $error[1] : null);
                 }
             }
         }
         // Remove all temporary files.
         $fileManager->deleteFile($exportFileName);
         // redirect back to the right tab
         $request->redirect(null, null, null, $path, null, $tab);
     }
     parent::executeExportAction($request, $objects, $filter, $tab, $objectsFileNamePart);
 }
开发者ID:pkp,项目名称:ojs,代码行数:37,代码来源:DOIPubIdExportPlugin.inc.php

示例9: executeCLICommand

 /**
  * @copydoc PKPImportExportPlugin::executeCLI()
  */
 function executeCLICommand($scriptName, $command, $context, $outputFile, $objects, $filter, $objectsFileNamePart)
 {
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     switch ($command) {
         case 'export':
             $result = $this->_checkForTar();
             if ($result === true) {
                 $exportedFiles = array();
                 foreach ($objects as $object) {
                     // Get the XML
                     $exportXml = $this->exportXML($object, $filter, $context);
                     // Write the XML to a file.
                     // export file name example: datacite-20160723-160036-articles-1-1.xml
                     $objectFileNamePart = $objectsFileNamePart . '-' . $object->getId();
                     $exportFileName = $this->getExportFileName($this->getExportPath(), $objectFileNamePart, $context, '.xml');
                     $fileManager->writeFile($exportFileName, $exportXml);
                     $exportedFiles[] = $exportFileName;
                 }
                 // If we have more than one export file we package the files
                 // up as a single tar before going on.
                 assert(count($exportedFiles) >= 1);
                 if (count($exportedFiles) > 1) {
                     // tar file name: e.g. datacite-20160723-160036-articles-1.tar.gz
                     $finalExportFileName = $this->getExportFileName($this->getExportPath(), $objectFileNamePart, $context, '.tar.gz');
                     $finalExportFileType = DATACITE_EXPORT_FILE_TAR;
                     $this->_tarFiles($this->getExportPath(), $finalExportFileName, $exportedFiles);
                 } else {
                     $finalExportFileName = array_shift($exportedFiles);
                     $finalExportFileType = DATACITE_EXPORT_FILE_XML;
                 }
                 $outputFileExtension = $finalExportFileType == DATACITE_EXPORT_FILE_TAR ? '.tar.gz' : '.xml';
                 if (substr($outputFile, -strlen($outputFileExtension)) != $outputFileExtension) {
                     $outputFile .= $outputFileExtension;
                 }
                 $fileManager->copyFile($finalExportFileName, $outputFile);
                 foreach ($exportedFiles as $exportedFile) {
                     $fileManager->deleteFile($exportedFile);
                 }
                 $fileManager->deleteFile($finalExportFileName);
             } else {
                 echo __('plugins.importexport.common.cliError') . "\n";
                 echo __('manager.plugins.tarCommandNotFound') . "\n\n";
                 $this->usage($scriptName);
             }
             break;
         case 'register':
             $resultErrors = array();
             foreach ($objects as $object) {
                 // Get the XML
                 $exportXml = $this->exportXML($object, $filter, $context);
                 // Write the XML to a file.
                 // export file name example: datacite-20160723-160036-articles-1-1.xml
                 $objectFileNamePart = $objectsFileNamePart . '-' . $object->getId();
                 $exportFileName = $this->getExportFileName($this->getExportPath(), $objectFileNamePart, $context, '.xml');
                 $fileManager->writeFile($exportFileName, $exportXml);
                 // Deposit the XML file.
                 $result = $this->depositXML($object, $context, $exportFileName);
                 if (is_array($result)) {
                     $resultErrors[] = $result;
                 }
                 // Remove all temporary files.
                 $fileManager->deleteFile($exportFileName);
             }
             if (empty($resultErrors)) {
                 echo __('plugins.importexport.common.register.success') . "\n";
             } else {
                 echo __('plugins.importexport.common.cliError') . "\n";
                 foreach ($resultErrors as $errors) {
                     foreach ($errors as $error) {
                         assert(is_array($error) && count($error) >= 1);
                         $errorMessage = __($error[0], array('param' => isset($error[1]) ? $error[1] : null));
                         echo "*** {$errorMessage}\n";
                     }
                 }
                 echo "\n";
                 $this->usage($scriptName);
             }
             break;
     }
 }
开发者ID:pkp,项目名称:ojs,代码行数:84,代码来源:DataciteExportPlugin.inc.php

示例10: saveLocaleFile

 function saveLocaleFile($args, &$request)
 {
     $this->validate();
     $plugin =& $this->plugin;
     $this->setupTemplate($request, $plugin, true);
     $locale = array_shift($args);
     if (!AppLocale::isLocaleValid($locale)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'index');
         $request->redirect(null, null, null, null, $path);
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!CustomLocaleAction::isLocaleFile($locale, $filename)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'edit', $locale);
         $request->redirect(null, null, null, null, $path);
     }
     $conference =& $request->getConference();
     $conferenceId = $conference->getId();
     $changes = $request->getUserVar('changes');
     $customFilesDir = Config::getVar('files', 'public_files_dir') . DIRECTORY_SEPARATOR . 'conferences' . DIRECTORY_SEPARATOR . $conferenceId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale;
     $customFilePath = $customFilesDir . DIRECTORY_SEPARATOR . $filename;
     // Create empty custom locale file if it doesn't exist
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     import('classes.i18n.EditableLocaleFile');
     if (!$fileManager->fileExists($customFilePath)) {
         $numParentDirs = substr_count($customFilePath, DIRECTORY_SEPARATOR);
         $parentDirs = '';
         for ($i = 0; $i < $numParentDirs; $i++) {
             $parentDirs .= '..' . DIRECTORY_SEPARATOR;
         }
         $newFileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $newFileContents .= '<!DOCTYPE locale SYSTEM "' . $parentDirs . 'locale' . DIRECTORY_SEPARATOR . 'locale.dtd' . '">' . "\n";
         $newFileContents .= '<locale name="' . $locale . '">' . "\n";
         $newFileContents .= '</locale>';
         $fileManager->writeFile($customFilePath, $newFileContents);
     }
     $file = new EditableLocaleFile($locale, $customFilePath);
     while (!empty($changes)) {
         $key = array_shift($changes);
         $value = $this->correctCr(array_shift($changes));
         if (!empty($value)) {
             if (!$file->update($key, $value)) {
                 $file->insert($key, $value);
             }
         } else {
             $file->delete($key);
         }
     }
     $file->write();
     $request->redirectUrl($request->getUserVar('redirectUrl'));
 }
开发者ID:artkuo,项目名称:ocs,代码行数:51,代码来源:CustomLocaleHandler.inc.php

示例11: display

 /**
  * Display the plugin.
  * @param $args array
  * @param $request PKPRequest
  */
 function display($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $context = $request->getContext();
     parent::display($args, $request);
     $templateMgr->assign('plugin', $this);
     switch (array_shift($args)) {
         case 'index':
         case '':
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
         case 'uploadImportXML':
             $user = $request->getUser();
             import('lib.pkp.classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
             if ($temporaryFile) {
                 $json = new JSONMessage(true);
                 $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
             } else {
                 $json = new JSONMessage(false, __('common.uploadFailed'));
             }
             return $json->getString();
         case 'importBounce':
             $json = new JSONMessage(true);
             $json->setEvent('addTab', array('title' => __('plugins.importexport.users.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId')))));
             return $json->getString();
         case 'import':
             $temporaryFileId = $request->getUserVar('temporaryFileId');
             $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
             $user = $request->getUser();
             $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
             if (!$temporaryFile) {
                 $json = new JSONMessage(true, __('plugins.importexport.users.uploadFile'));
                 return $json->getString();
             }
             $temporaryFilePath = $temporaryFile->getFilePath();
             libxml_use_internal_errors(true);
             $users = $this->importUsers(file_get_contents($temporaryFilePath), $context, $user);
             $validationErrors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR ||  $a->level == LIBXML_ERR_FATAL;'));
             $templateMgr->assign('validationErrors', $validationErrors);
             libxml_clear_errors();
             $templateMgr->assign('users', $users);
             $json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl'));
             return $json->getString();
         case 'export':
             $exportXml = $this->exportUsers((array) $request->getUserVar('selectedUsers'), $request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.FileManager');
             $fileManager = new FileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         case 'exportAllUsers':
             $exportXml = $this->exportAllUsers($request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.TemporaryFileManager');
             $fileManager = new TemporaryFileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
开发者ID:pkp,项目名称:pkp-lib,代码行数:73,代码来源:PKPUserImportExportPlugin.inc.php

示例12: save

 function save()
 {
     global $settings, $rules;
     $hasLeaguePref = mysql_fetch_object(mysql_query("SELECT f_lid from league_prefs where f_lid={$this->lid}"));
     if ($hasLeaguePref) {
         $query = "UPDATE league_prefs SET prime_tid={$this->p_tour}, league_name='" . mysql_real_escape_string($this->league_name) . "', forum_url='" . mysql_real_escape_string($this->forum_url) . "' , welcome='" . mysql_real_escape_string($this->welcome) . "' , rules='" . mysql_real_escape_string($this->rules) . "'  WHERE f_lid={$this->lid}";
     } else {
         $query = "INSERT INTO league_prefs (f_lid, prime_tid, second_tid, league_name, forum_url, welcome, rules) VALUE ({$this->lid}, {$this->p_tour}, {$this->s_tour}, '" . mysql_real_escape_string($this->league_name) . "', '" . mysql_real_escape_string($this->forum_url) . "', '" . mysql_real_escape_string($this->welcome) . "', '" . mysql_real_escape_string($this->rules) . "')";
     }
     FileManager::writeFile(FileManager::getCssDirectoryName() . "/league_override_{$this->lid}.css", $this->theme_css);
     $settingsFileContents = FileManager::readFile(FileManager::getSettingsDirectoryName() . "/settings_{$this->lid}.php");
     $settingsFileContents = preg_replace("/settings\\['stylesheet'\\]\\s*=\\s['A-Za-z0-9_]+/", "settings['stylesheet'] = {$this->core_theme_id}", $settingsFileContents);
     $settingsFileContents = preg_replace("/settings\\['lang'\\]\\s*=\\s['A-Za-z0-9_\\-]+/", "settings['lang'] = '{$this->language}'", $settingsFileContents);
     $settingsFileContents = preg_replace("/rules\\['initial_treasury'\\]\\s*=\\s['A-Za-z0-9_]+/", "rules['initial_treasury'] = {$this->tv}", $settingsFileContents);
     $settingsFileContents = preg_replace("/settings\\['core_rules_file'\\]\\s*=\\s[\\.\\/'A-Za-z0-9_]+/", "settings['core_rules_file'] = '{$this->core_rules_file}'", $settingsFileContents);
     FileManager::writeFile(FileManager::getSettingsDirectoryName() . "/settings_{$this->lid}.php", $settingsFileContents);
     $settings['stylesheet'] = $this->core_theme_id;
     $settings['lang'] = $this->language;
     $rules['initial_treasury'] = $this->tv;
     $settings['core_rules_file'] = $this->core_rules_file;
     return mysql_query($query);
 }
开发者ID:TheNAF,项目名称:naflm,代码行数:22,代码来源:class_league_pref.php

示例13: executeCLICommand

 /**
  * Execute the CLI command
  * @param $scriptName The name of the command-line script (displayed as usage info)
  * @param $command string (export or register)
  * @param $context Context
  * @param $outputFile string Path to the file where the exported XML should be saved
  * @param $objects array Objects to be exported or registered
  * @param $filter string Filter to use
  * @param $objectsFileNamePart string Export file name part for this kind of objects
  */
 function executeCLICommand($scriptName, $command, $context, $outputFile, $objects, $filter, $objectsFileNamePart)
 {
     $exportXml = $this->exportXML($objects, $filter, $context);
     if ($command == 'export' && $outputFile) {
         file_put_contents($outputFile, $exportXml);
     }
     if ($command == 'register') {
         import('lib.pkp.classes.file.FileManager');
         $fileManager = new FileManager();
         $exportFileName = $this->getExportFileName($this->getExportPath(), $objectsFileNamePart, $context, '.xml');
         $fileManager->writeFile($exportFileName, $exportXml);
         $result = $this->depositXML($objects, $context, $exportFileName);
         if ($result === true) {
             echo __('plugins.importexport.common.register.success') . "\n";
         } else {
             echo __('plugins.importexport.common.cliError') . "\n";
             if (is_array($result)) {
                 foreach ($result as $error) {
                     assert(is_array($error) && count($error) >= 1);
                     $errorMessage = __($error[0], array('param' => isset($error[1]) ? $error[1] : null));
                     echo "*** {$errorMessage}\n";
                 }
                 echo "\n";
             } else {
                 echo __('plugins.importexport.common.register.error.mdsError', array('param' => ' - ')) . "\n\n";
             }
             $this->usage($scriptName);
         }
         $fileManager->deleteFile($exportFileName);
     }
 }
开发者ID:pkp,项目名称:ojs,代码行数:41,代码来源:PubObjectsExportPlugin.inc.php


注:本文中的FileManager::writeFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。