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


PHP Context::reinitializeI18n方法代码示例

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


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

示例1: processCommit

 public static function processCommit(\thebuggenie\core\entities\Project $project, $commit_msg, $old_rev, $new_rev, $date = null, $changed, $author, $branch = null, \Closure $callback = null)
 {
     $output = '';
     framework\Context::setCurrentProject($project);
     if ($project->isArchived()) {
         return;
     }
     if (Commits::getTable()->isProjectCommitProcessed($new_rev, $project->getID())) {
         return;
     }
     try {
         framework\Context::getI18n();
     } catch (\Exception $e) {
         framework\Context::reinitializeI18n(null);
     }
     // Is VCS Integration enabled?
     if (framework\Settings::get('vcs_mode_' . $project->getID(), 'vcs_integration') == self::MODE_DISABLED) {
         $output .= '[VCS ' . $project->getKey() . '] This project does not use VCS Integration' . "\n";
         return $output;
     }
     // Parse the commit message, and obtain the issues and transitions for issues.
     $parsed_commit = \thebuggenie\core\entities\Issue::getIssuesFromTextByRegex($commit_msg);
     $issues = $parsed_commit["issues"];
     $transitions = $parsed_commit["transitions"];
     // Build list of affected files
     $file_lines = preg_split('/[\\n\\r]+/', $changed);
     $files = array();
     foreach ($file_lines as $aline) {
         $action = mb_substr($aline, 0, 1);
         if ($action == "A" || $action == "U" || $action == "D" || $action == "M") {
             $theline = trim(mb_substr($aline, 1));
             $files[] = array($action, $theline);
         }
     }
     // Find author of commit, fallback is guest
     /*
      * Some VCSes use a different format of storing the committer's name. Systems like bzr, git and hg use the format
      * Joe Bloggs <me@example.com>, instead of a classic username. Therefore a user will be found via 4 queries:
      * a) First we extract the email if there is one, and find a user with that email
      * b) If one is not found - or if no email was specified, then instead test against the real name (using the name part if there was an email)
      * c) the username or full name is checked against the friendly name field
      * d) and if we still havent found one, then we check against the username
      * e) and if we STILL havent found one, we use the guest user
      */
     // a)
     $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($author);
     if (!$user instanceof \thebuggenie\core\entities\User && preg_match("/(?<=<)(.*)(?=>)/", $author, $matches)) {
         $email = $matches[0];
         // a2)
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByEmail($email);
         if (!$user instanceof \thebuggenie\core\entities\User) {
             // Not found by email
             preg_match("/(?<=^)(.*)(?= <)/", $author, $matches);
             $author = $matches[0];
         }
     }
     // b)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByRealname($author);
     }
     // c)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByBuddyname($author);
     }
     // d)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = \thebuggenie\core\entities\tables\Users::getTable()->getByUsername($author);
     }
     // e)
     if (!$user instanceof \thebuggenie\core\entities\User) {
         $user = framework\Settings::getDefaultUser();
     }
     framework\Context::setUser($user);
     framework\Settings::forceSettingsReload();
     framework\Context::cacheAllPermissions();
     $output .= '[VCS ' . $project->getKey() . '] Commit to be logged by user ' . $user->getName() . "\n";
     if ($date == null) {
         $date = NOW;
     }
     // Create the commit data
     $commit = new Commit();
     $commit->setAuthor($user);
     $commit->setDate($date);
     $commit->setLog($commit_msg);
     $commit->setPreviousRevision($old_rev);
     $commit->setRevision($new_rev);
     $commit->setProject($project);
     if ($branch !== null) {
         $data = 'branch:' . $branch;
         $commit->setMiscData($data);
     }
     if ($callback !== null) {
         $commit = $callback($commit);
     }
     $commit->save();
     $output .= '[VCS ' . $project->getKey() . '] Commit logged with revision ' . $commit->getRevision() . "\n";
     // Iterate over affected issues and update them.
     foreach ($issues as $issue) {
         $inst = new IssueLink();
         $inst->setIssue($issue);
//.........这里部分代码省略.........
开发者ID:AzerothShard,项目名称:thebuggenie,代码行数:101,代码来源:Vcs_integration.php

示例2: runInstallStep4

 /**
  * Runs the action for the fourth step of the installation
  * where it loads fixtures and saves settings for url
  *
  * @param framework\Request $request The request object
  *
  * @return null
  */
 public function runInstallStep4(framework\Request $request)
 {
     try {
         framework\Logging::log('Initializing language support');
         framework\Context::reinitializeI18n('en_US');
         framework\Logging::log('Loading fixtures for default scope');
         $scope = new \thebuggenie\core\entities\Scope();
         $scope->addHostname('*');
         $scope->setName('The default scope');
         $scope->setEnabled(true);
         framework\Context::setScope($scope);
         $scope->save();
         framework\Settings::saveSetting('language', 'en_US', 'core', 1);
         \thebuggenie\core\entities\Module::installModule('publish');
         \thebuggenie\core\entities\Module::installModule('agile');
         \thebuggenie\core\entities\Module::installModule('mailing');
         \thebuggenie\core\entities\Module::installModule('vcs_integration');
         $this->htaccess_error = false;
         $this->htaccess_ok = (bool) $request['apache_autosetup'];
         if ($request['apache_autosetup']) {
             if (!is_writable(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/') || file_exists(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess') && !is_writable(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess')) {
                 $this->htaccess_error = 'Permission denied when trying to save the [main folder]/' . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess';
             } else {
                 $content = str_replace('###PUT URL SUBDIRECTORY HERE###', $request['url_subdir'], file_get_contents(THEBUGGENIE_CORE_PATH . '/templates/htaccess.template'));
                 file_put_contents(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess', $content);
                 if (file_get_contents(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.htaccess') != $content) {
                     $this->htaccess_error = true;
                 }
             }
             if (!is_writable(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/') || file_exists(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.user.ini') && !is_writable(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.user.ini')) {
                 $this->htaccess_error = 'Permission denied when trying to save the [main folder]/' . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.user.ini';
             } else {
                 $content = file_get_contents(THEBUGGENIE_CORE_PATH . '/templates/user.ini.template');
                 file_put_contents(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.user.ini', $content);
                 if (file_get_contents(THEBUGGENIE_PATH . THEBUGGENIE_PUBLIC_FOLDER_NAME . '/.user.ini') != $content) {
                     $this->htaccess_error = true;
                 }
             }
         }
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
         throw $e;
     }
 }
开发者ID:JonathanRH,项目名称:thebuggenie,代码行数:52,代码来源:Main.php

示例3: do_execute


//.........这里部分代码省略.........
                     $this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.user.ini\n", 'red', 'bold');
                     $this->cliEcho("You will have to set up the .user.ini file yourself. See the README file for more information.\n", 'white', 'bold');
                     $this->cliEcho('Please note: ', 'white', 'bold');
                     $this->cliEcho("If you're using PHP-FPM, The Bug Genie might not function properly until the .user.ini file is properly set up\n");
                 } else {
                     $content = file_get_contents(THEBUGGENIE_CORE_PATH . 'templates/htaccess.template');
                     file_put_contents(THEBUGGENIE_PATH . 'thebuggenie/.user.ini', $content);
                     if (file_get_contents(THEBUGGENIE_PATH . 'thebuggenie/.user.ini') != $content) {
                         $this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.user.ini\n", 'red', 'bold');
                         $this->cliEcho("You will have to set up the .user.ini file yourself. See the README file for more information.\n", 'white', 'bold');
                         $this->cliEcho('Please note: ', 'white', 'bold');
                         $this->cliEcho("If you're using PHP-FPM, The Bug Genie might not function properly until the .user.ini file is properly set up\n");
                     } else {
                         $this->cliEcho("The .user.ini file was successfully set up...\n", 'green', 'bold');
                     }
                 }
             } else {
                 $this->cliEcho("Skipping .htaccess and .user.ini auto-setup.");
             }
             if ($this->getProvidedArgument('setup_htaccess') != 'yes') {
                 $this->cliEcho("Press ENTER to continue ... ");
                 $this->pressEnterToContinue();
                 $this->cliEcho("\n");
             }
             $this->cliEcho("\n");
             $this->cliEcho("Creating tables ...\n", 'white', 'bold');
             $b2db_entities_path = THEBUGGENIE_CORE_PATH . 'entities' . DS . 'tables' . DS;
             $tables_created = array();
             foreach (scandir($b2db_entities_path) as $tablefile) {
                 if (in_array($tablefile, array('.', '..'))) {
                     continue;
                 }
                 if (($tablename = mb_substr($tablefile, 0, mb_strpos($tablefile, '.'))) != '') {
                     $tablename = "\\thebuggenie\\core\\entities\\tables\\{$tablename}";
                     $reflection = new \ReflectionClass($tablename);
                     $docblock = $reflection->getDocComment();
                     $annotationset = new \b2db\AnnotationSet($docblock);
                     if ($annotationset->hasAnnotation('Table')) {
                         \b2db\Core::getTable($tablename)->create();
                         \b2db\Core::getTable($tablename)->createIndexes();
                         $tables_created[] = $tablename;
                     }
                 }
             }
             $this->cliEcho("\n");
             $this->cliEcho("All tables successfully created...\n\n", 'green', 'bold');
             $this->cliEcho("Setting up initial scope... \n", 'white', 'bold');
             \thebuggenie\core\framework\Context::reinitializeI18n('en_US');
             $scope = new \thebuggenie\core\entities\Scope();
             $scope->setName('The default scope');
             $scope->addHostname('*');
             $scope->setEnabled();
             \thebuggenie\core\framework\Context::setScope($scope);
             $scope->save();
             \thebuggenie\core\framework\Settings::saveSetting('language', 'en_US');
             $this->cliEcho("Initial scope setup successfully... \n\n", 'green', 'bold');
             $this->cliEcho("Setting up modules... \n", 'white', 'bold');
             try {
                 foreach (array('publish', 'mailing', 'vcs_integration') as $module) {
                     $this->cliEcho("Installing {$module}... \n");
                     \thebuggenie\core\entities\Module::installModule($module);
                 }
                 $this->cliEcho("\n");
                 $this->cliEcho("All modules installed successfully...\n", 'green', 'bold');
                 $this->cliEcho("\n");
                 $this->cliEcho("Finishing installation... \n", 'white', 'bold');
                 $installed_string = \thebuggenie\core\framework\Settings::getMajorVer() . '.' . \thebuggenie\core\framework\Settings::getMinorVer() . ', installed ' . date('d.m.Y H:i');
                 if (file_exists(THEBUGGENIE_PATH . 'installed') && !is_writable(THEBUGGENIE_PATH . 'installed') || !file_exists(THEBUGGENIE_PATH . 'installed') && !is_writable(THEBUGGENIE_PATH)) {
                     $this->cliEcho("\n");
                     $this->cliEcho("Could not create the 'installed' file.\n", 'red', 'bold');
                     $this->cliEcho("Please create the file ");
                     $this->cliEcho(THEBUGGENIE_PATH . "installed\n", 'white', 'bold');
                     $this->cliEcho("with the following line inside:\n");
                     $this->cliEcho($installed_string, 'blue', 'bold');
                     $this->cliEcho("\n");
                     $this->cliEcho("This can be done by running the following command when installation has finished:\n");
                     $this->cliEcho('echo "' . $installed_string . '" > ' . THEBUGGENIE_PATH . 'installed', 'white', 'bold');
                     $this->cliEcho("\n");
                     $this->cliEcho("Press ENTER to continue ... ");
                     $this->pressEnterToContinue();
                     $this->cliEcho("\n");
                     $this->cliEcho("\n");
                 } else {
                     file_put_contents(THEBUGGENIE_PATH . 'installed', $installed_string);
                 }
                 $this->cliEcho("The installation was completed successfully!\n", 'green', 'bold');
                 $this->cliEcho("\nTo use The Bug Genie, access http://example.com" . $url_subdir . "index.php with a web-browser.\n");
                 $this->cliEcho("The default username is ") . $this->cliEcho('Administrator') . $this->cliEcho(' and the password is ') . $this->cliEcho('admin');
                 $this->cliEcho("\n\nFor support, please visit ") . $this->cliEcho('http://www.thebuggenie.com/', 'blue', 'underline');
                 $this->cliEcho("\n");
             } catch (\Exception $e) {
                 throw new \Exception("Could not install the {$module} module:\n" . $e->getMessage());
             }
         }
     } catch (\Exception $e) {
         $this->cliEcho("\n\nThe installation was interrupted\n", 'red');
         $this->cliEcho($e->getMessage() . "\n");
     }
     $this->cliEcho("\n");
 }
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:101,代码来源:Install.php


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