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


PHP Repository::getID方法代码示例

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


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

示例1: history

 /**
  * Repository history
  *
  * @return void
  * @author Chris Conover
  **/
 function history()
 {
     $page = intval(array_var($_GET, 'page')) > 0 ? array_var($_GET, 'page') : 1;
     $branch_tag = strval(array_var($_GET, 'branch_tag')) != '' ? array_var($_GET, 'branch_tag') : 'master';
     js_assign('commit_filepath_url', assemble_url('github_commit_filepaths', array('project_id' => $this->active_project->getId(), 'github_repository_id' => $this->active_repository->getID())));
     $commits = $this->active_repository->getBranchTagCommits($branch_tag, $page);
     // Group commits by days
     $grouped_commits = array();
     $date_format = 'F j. Y';
     foreach ($commits as $commit) {
         $commit->short_id = substr($commit->id, 0, 9) . '...' . substr($commit->id, -9);
         $commit->message = $this->analyzeCommitMessage($commit->message);
         $commit_formatted_date = date($date_format, strtotime($commit->committed_date));
         if (count($grouped_commits) == 0 || !isset($grouped_commits[$commit_formatted_date])) {
             $grouped_commits[$commit_formatted_date] = array($commit);
         } else {
             array_push($grouped_commits[$commit_formatted_date], $commit);
         }
     }
     $this->smarty->assign(array('path_info' => strval(array_var($_GET, 'path_info')), 'page' => $page, 'next_page' => $page + 1, 'prev_page' => $page > 1 ? $page - 1 : null, 'branches' => $this->active_repository->getBranches(), 'tags' => $this->active_repository->getTags(), 'commits' => $grouped_commits, 'user' => $this->active_repository->getUserName(), 'repo' => $this->active_repository->getRepoName(), 'branch_tag' => $branch_tag));
 }
开发者ID:hutbert,项目名称:ActiveCollab-Github-Module,代码行数:27,代码来源:GithubController.class.php

示例2: 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


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