コード例 #1
0
 public function composeFullTitle($includeVersion = true, $includePlatformName = true)
 {
     $includeVersion = (bool) $includeVersion;
     $includeBuildId = (bool) $includeBuildId;
     $title = $this->title;
     if ($includeVersion && isset($this->version)) {
         $title .= " {$this->version}";
     }
     if ($includePlatformName && $this->platformId !== PID_ANY) {
         $plat =& BuildRepositoryPlugin::platform($this->platformId);
         $title .= ' for ' . $plat['nicename'];
     }
     return $title;
 }
コード例 #2
0
 /**
  * Parse a new BuildEvent from a SimpleXMLElement.
  *
  * @param $log_event  (Object) SimpleXMLElement node to be "parsed".
  * @return  (object) Resultant BuildEvent object.
  */
 private static function parseBuildEvent(&$log_event)
 {
     if (!$log_event instanceof SimpleXMLElement) {
         throw new Exception('Received invalid log_event');
     }
     $uniqueId = (int) $log_event->uniqueId;
     $startDate = strtotime(clean_text($log_event->startDate));
     $authorName = clean_text($log_event->authorName);
     $authorEmail = clean_text($log_event->authorEmail);
     if (!empty($log_event->releaseType)) {
         $releaseType = BuildRepositoryPlugin::parseReleaseType(clean_text($log_event->releaseType));
     } else {
         $releaseType = RT_UNSTABLE;
     }
     $event = new BuildEvent($uniqueId, $startDate, $authorName, $authorEmail, $releaseType);
     if (!empty($log_event->releaseNotes)) {
         $event->setReleaseNotesUri(clean_text($log_event->releaseNotes));
     }
     if (!empty($log_event->changeLog)) {
         $event->setReleaseChangeLogUri(clean_text($log_event->changeLog));
     }
     return $event;
 }
コード例 #3
0
 /**
  * One-time initialization of the Packages collection.
  */
 private function initPackages()
 {
     // Init the special case 'null' package.
     self::$nullPack = PackageFactory::newNullPackage();
     // Init collections.
     $this->rebuildPackages();
 }
コード例 #4
0
 public function genFancyBadge($isActive = TRUE)
 {
     $name = "Build{$this->uniqueId}";
     $releaseType = BuildRepositoryPlugin::releaseType($this->releaseTypeId);
     $isActive = (bool) $isActive;
     $cssClass = 'buildevent_badge';
     if ($this->releaseTypeId !== RT_UNKNOWN) {
         $cssClass .= " {$releaseType['name']}";
         if (!$isActive || $this->uniqueId <= 0) {
             $cssClass .= '_disabled';
         }
     }
     $html = '';
     if ($isActive && $this->uniqueId > 0) {
         $inspectBuildUri = $name;
         $inspectBuildLabel = htmlspecialchars("Read more about {$releaseType['nicename']} {$name}");
         $html .= "<a href=\"{$inspectBuildUri}\" title=\"{$inspectBuildLabel}\">";
     } else {
         $html .= "<a href=\"\\\" style=\"cursor:default;pointer-events:none\">";
     }
     $html .= "<div class=\"{$cssClass}\">" . ($this->uniqueId > 0 ? htmlspecialchars($this->uniqueId) : '&nbsp;') . "<span class=\"startdate\">" . htmlspecialchars(date('F j, Y', $this->startDate)) . '</span></div>';
     $html .= '</a>';
     return $html;
 }
コード例 #5
0
 /**
  * Parse a new Package object from a SimpleXMLElement.
  *
  * @param $log_pack  (Object) SimpleXMLElement node to be "parsed".
  * @return  (Object) Resultant Package object.
  */
 public static function newFromSimpleXMLElement(&$log_pack, $releaseType = 'unstable')
 {
     if (!$log_pack instanceof SimpleXMLElement) {
         throw new Exception('Received invalid log_pack');
     }
     $platformId = BuildRepositoryPlugin::parsePlatformId(clean_text($log_pack->platform));
     $cleanDirectDownloadUri = safe_url($log_pack->downloadUri);
     if (!empty($log_pack->downloadFallbackUri)) {
         $cleanDirectDownloadFallbackUri = safe_url($log_pack->downloadFallbackUri);
     } else {
         $cleanDirectDownloadFallbackUri = NULL;
     }
     if (!empty($log_pack->name)) {
         $name = clean_text($log_pack->name);
     } else {
         // We must resort to extracting the name from download Uri.
         $filename = basename(substr($cleanDirectDownloadUri, 0, -9));
         $filename = preg_replace(array('/-/', '/_/'), ' ', $filename);
         $words = explode(' ', substr($filename, 0, strrpos($filename, '.')));
         $name = ucwords(implode(' ', $words));
     }
     if (!empty($log_pack->version)) {
         $versionText = clean_text($log_pack->version);
         $version = Version::fromString($versionText);
     } else {
         $version = NULL;
     }
     // Determine package type.
     foreach ($log_pack->attributes() as $attrib => $value) {
         if ($attrib === 'type') {
             $type = $value;
         }
         break;
     }
     if (!isset($type)) {
         $type = 'distribution';
     }
     switch ($type) {
         case 'plugin':
             if ($releaseType === RT_STABLE) {
                 $pack = new PluginBuilderPackage($platformId, $name, $version, $cleanDirectDownloadUri, $cleanDirectDownloadFallbackUri);
             } else {
                 $pack = new PluginUnstableBuilderPackage($platformId, $name, $version, $cleanDirectDownloadUri, $cleanDirectDownloadFallbackUri);
             }
             break;
         default:
             if ($releaseType === RT_STABLE) {
                 $pack = new DistributionBuilderPackage($platformId, $name, $version, $cleanDirectDownloadUri, $cleanDirectDownloadFallbackUri);
             } else {
                 $pack = new DistributionUnstableBuilderPackage($platformId, $name, $version, $cleanDirectDownloadUri, $cleanDirectDownloadFallbackUri);
             }
             break;
     }
     if (!empty($log_pack->compileLogUri)) {
         $pack->setCompileLogUri(safe_url($log_pack->compileLogUri));
     }
     if (!empty($log_pack->compileWarnCount)) {
         $pack->setCompileWarnCount((int) $log_pack->compileWarnCount);
     }
     if (!empty($log_pack->compileErrorCount)) {
         $pack->setCompileErrorCount((int) $log_pack->compileErrorCount);
     }
     return $pack;
 }