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


PHP UI::redirectToURL方法代码示例

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


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

示例1: exportRepository

 /**
  * Exports the given repository and creates a ZIP file containing XML output files
  *
  * @param Repository $repository the Repository instance to export
  * @param string $filename the output file name inside each language folder
  * @param int $groupID the group to get the output for (or Phrase::GROUP_ALL)
  * @param int $format the format (constant) to use for this export
  * @param int $minCompletion the minimum percentage of completion for languages to be eligible for exporting
  * @param bool $ignoreIfSameAsDefault ignore phrases which are the same as the default language
  * @throws Exception if the repository could not be exported
  */
 public static function exportRepository($repository, $filename, $groupID, $format, $minCompletion = 0, $ignoreIfSameAsDefault = false)
 {
     if (self::isFilenameValid($filename)) {
         if ($repository instanceof Repository) {
             $exportSuccess = true;
             $randomDir = mt_rand(1000000, 9999999);
             $savePath = URL::getTempPath(false) . URL::encodeID($repository->getID());
             self::deleteDirectoryRecursively($savePath);
             // delete all old output files from output directory first
             $savePath .= '/' . $randomDir;
             // navigate to random directory inside output folder
             if (mkdir($savePath, 0755, true)) {
                 // if output folder could be created
                 $languages = Language::getList();
                 $defaultLanguageObject = $repository->getLanguage($repository->getDefaultLanguage());
                 foreach ($languages as $language) {
                     $languageObject = $repository->getLanguage($language);
                     $languageKeys = $languageObject->getKeys();
                     $ignorePhrasesSameAsDefault = $ignoreIfSameAsDefault && $repository->getDefaultLanguage() != $language;
                     if ($format == self::FORMAT_ANDROID_XML_ESCAPED_HTML) {
                         $languageOutput = $languageObject->outputAndroidXMLEscapedHTML($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
                         $fileExtension = '.xml';
                     } elseif ($format == self::FORMAT_JSON) {
                         $languageOutput = $languageObject->outputJSON($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
                         $fileExtension = '.json';
                     } elseif ($format == self::FORMAT_PLAINTEXT) {
                         $languageOutput = $languageObject->outputPlaintext($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
                         $fileExtension = '.txt';
                     } else {
                         $languageOutput = $languageObject->outputAndroidXML($groupID, $ignorePhrasesSameAsDefault, $defaultLanguageObject);
                         $fileExtension = '.xml';
                     }
                     if ($languageOutput->getCompleteness() >= $minCompletion) {
                         foreach ($languageKeys as $languageKey) {
                             if (mkdir($savePath . '/' . $languageKey . '/', 0755, true)) {
                                 if (file_put_contents($savePath . '/' . $languageKey . '/' . $filename . $fileExtension, $languageOutput->getContent()) !== false) {
                                     $exportSuccess = true;
                                 } else {
                                     // output file could not be written
                                     $exportSuccess = false;
                                 }
                             } else {
                                 // sub-directory for language could not be created
                                 $exportSuccess = false;
                             }
                         }
                     }
                 }
             } else {
                 // output folder could not be created
                 $exportSuccess = false;
             }
             if ($exportSuccess) {
                 $outputPath = URL::getTempPath(true) . URL::encodeID($repository->getID()) . '/' . $randomDir;
                 if (self::zipFolder($savePath, $savePath . '/Export.zip')) {
                     UI::redirectToURL($outputPath . '/Export.zip');
                 }
             }
         } else {
             throw new Exception('The repository must be an instance of class Repository');
         }
     } else {
         throw new Exception('Invalid filename: ' . $filename);
     }
 }
开发者ID:jeckel420,项目名称:Localize,代码行数:76,代码来源:File_IO.php

示例2: getPage_Invitations

 public static function getPage_Invitations($contents, $containers)
 {
     $repositoryID = self::validateID(self::getDataGET('project'), true);
     $repositoryData = Database::getRepositoryData($repositoryID);
     if (empty($repositoryData)) {
         self::addBreadcrumbItem(URL::toProject($repositoryID), 'Project not found');
         self::setTitle('Project not found');
         $contents[] = new UI_Heading('Project not found', true);
         $contents[] = new UI_Paragraph('We\'re sorry, but we could not find the project that you requested.');
         $contents[] = new UI_Paragraph('Please check if you have made any typing errors.');
     } else {
         if (Authentication::getUserID() <= 0) {
             self::setTitle($repositoryData['name']);
             $contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
             $contents[] = self::getLoginForm();
         } elseif (!Repository::hasUserPermissions(Authentication::getUserID(), $repositoryID, $repositoryData, Repository::ROLE_ADMINISTRATOR)) {
             self::setTitle($repositoryData['name']);
             $contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
             $contents[] = new UI_Paragraph('Only administrators of this project are allowed to review invitation requests.');
         } else {
             $currentPageURL = URL::toInvitations($repositoryID);
             self::addBreadcrumbItem($currentPageURL, 'Invitations');
             self::setTitle('Invitations');
             $contents[] = new UI_Heading('Invitations', true);
             $invitationData = Database::getInvitationByRepository($repositoryID);
             if (empty($invitationData)) {
                 // no invitations available for review (anymore)
                 UI::redirectToURL(URL::toDashboard());
             } else {
                 // edits available to review
                 Time::init();
                 $form = new UI_Form(htmlspecialchars($currentPageURL), false);
                 $table = new UI_Table(array('', ''));
                 $table->setColumnPriorities(6, 6);
                 $buttonAccept = new UI_Form_Button('Accept', UI_Link::TYPE_SUCCESS, UI_Form_Button::ACTION_SUBMIT, 'invitations[accept]', Repository::INVITATION_ACCEPTED);
                 $buttonDecline = new UI_Form_Button('Decline', UI_Link::TYPE_WARNING, UI_Form_Button::ACTION_SUBMIT, 'invitations[accept]', Repository::INVITATION_DECLINED);
                 $actionButtons = new UI_Form_ButtonGroup(array($buttonAccept, $buttonDecline), true);
                 $invitationRoleSelect = new UI_Form_Select('', 'invitations[role]', '', false, '', '', '', true);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_CONTRIBUTOR), Repository::ROLE_CONTRIBUTOR);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_MODERATOR), Repository::ROLE_MODERATOR);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_DEVELOPER), Repository::ROLE_DEVELOPER);
                 $invitationRoleSelect->addOption(Repository::getRoleName(Repository::ROLE_ADMINISTRATOR), Repository::ROLE_ADMINISTRATOR);
                 $table->addRow(array('<strong>Assigned role</strong>', $invitationRoleSelect->getHTML()));
                 $table->addRow(array('<strong>Username</strong>', htmlspecialchars($invitationData[0]['username'])));
                 $table->addRow(array('<strong>Real name</strong>', empty($invitationData[0]['real_name']) ? '&mdash;' : htmlspecialchars($invitationData[0]['real_name'])));
                 $table->addRow(array('<strong>Country</strong>', empty($invitationData[0]['localeCountry']) ? '&mdash;' : Time::getCountryName($invitationData[0]['localeCountry'], '&mdash;')));
                 $table->addRow(array('<strong>Request date</strong>', date('d.m.Y H:i', $invitationData[0]['request_time'])));
                 $table->addRow(array('<strong>Sign-up date</strong>', date('d.m.Y H:i', $invitationData[0]['join_date'])));
                 $table->addRow(array('<strong>Last sign-in</strong>', date('d.m.Y H:i', $invitationData[0]['last_login'])));
                 $form->addContent(new UI_Form_Hidden('invitations[userID]', URL::encodeID($invitationData[0]['userID'])));
                 $form->addContent($actionButtons);
                 $form->addContent($table);
                 $form->addContent($actionButtons);
                 $contents[] = $form;
             }
         }
     }
     $cell = new UI_Cell($contents);
     $row = new UI_Row(array($cell));
     $containers[] = new UI_Container(array($row));
     return new UI_Group($containers);
 }
开发者ID:jeckel420,项目名称:Localize,代码行数:62,代码来源:UI.php


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