Beispiel #1
0
 private function _getHistoryBuilds(Xinc_Project $project, $start, $limit = null)
 {
     /**$statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir();
             $historyFile = $statusDir . DIRECTORY_SEPARATOR . $project->getName() . '.history';
     
             $buildHistoryArr = unserialize(file_get_contents($historyFile));
             $totalCount = count($buildHistoryArr);
             if ($limit==null) {
                 $limit = $totalCount;
             }
             /**
              * turn it upside down so the latest builds appear first
              */
     /**
             $buildHistoryArr = array_reverse($buildHistoryArr, true);
             $buildHistoryArr = array_slice($buildHistoryArr, $start, $limit, true);*/
     $buildHistoryArr = Xinc_Build_History::getFromTo($project, $start, $limit);
     $totalCount = Xinc_Build_History::getCount($project);
     $builds = array();
     foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) {
         try {
             //$buildObject = Xinc_Build::unserialize($project,
             //                                       $buildTimestamp,
             //                                       Xinc_Gui_Handler::getInstance()->getStatusDir());
             $buildObject = Xinc_Build_Repository::getBuild($project, $buildTimestamp);
             $builds[] = array('number' => $buildObject->getNumber(), 'y' => $buildObject->getStatistics()->get('build.duration'), 'xlabel' => $buildObject->getNumber());
         } catch (Exception $e) {
             // TODO: Handle
         }
     }
     $builds = array_reverse($builds, true);
     return $builds;
 }
Beispiel #2
0
 public function handleEvent($eventId)
 {
     switch ($eventId) {
         case Xinc_Gui_Event::PAGE_LOAD:
             $query = urldecode($_SERVER['REQUEST_URI']);
             $this->features = $this->extensions['PROJECT_FEATURE'];
             $handler = Xinc_Gui_Handler::getInstance();
             $statusDir = $handler->getStatusDir();
             $dir = opendir($statusDir);
             while ($file = readdir($dir)) {
                 $project = array();
                 $fullfile = $statusDir . DIRECTORY_SEPARATOR . $file;
                 if (!in_array($file, array('.', '..')) && is_dir($fullfile)) {
                     $project['name'] = $file;
                     $statusfile = $fullfile . DIRECTORY_SEPARATOR . 'build.ser';
                     //$xincProject = $fullfile . DIRECTORY_SEPARATOR . '.xinc';
                     if (file_exists($statusfile)) {
                         //$ini = parse_ini_file($statusfile, true);
                         $project = new Xinc_Project();
                         $project->setName($file);
                         try {
                             $object = Xinc_Build_Repository::getLastBuild($project);
                             $this->builds->add($object);
                         } catch (Exception $e) {
                         }
                     } else {
                         if (file_exists($xincProject)) {
                             $project['build.status'] = -10;
                             $project['build.time'] = 0;
                             $project['build.label'] = '';
                             $this->projects[] = $project;
                         }
                     }
                     $this->menu = '';
                     if (isset($this->extensions['MAIN_MENU'])) {
                         if (is_array($this->extensions['MAIN_MENU'])) {
                             foreach ($this->extensions['MAIN_MENU'] as $extension) {
                                 $this->menu .= call_user_func_array($extension, array($this, 'Dashboard'));
                             }
                         }
                     }
                 }
             }
             if (preg_match('/\\/dashboard\\/projects.*/', $query)) {
                 include_once Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'projects.phtml');
             }
             break;
         default:
             break;
     }
     /**
      * restore to system timezone
      */
     $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone');
     if ($xincTimezone !== null) {
         Xinc_Timezone::set($xincTimezone);
     } else {
         Xinc_Timezone::reset();
     }
 }
Beispiel #3
0
 protected function _generateChildren()
 {
     $builds = new Xinc_Build_Iterator();
     $handler = Xinc_Gui_Handler::getInstance();
     $statusDir = $handler->getStatusDir();
     $dir = opendir($statusDir);
     while ($file = readdir($dir)) {
         $fullfile = $statusDir . DIRECTORY_SEPARATOR . $file;
         if (!in_array($file, array('.', '..')) && is_dir($fullfile)) {
             $statusfile = $fullfile . DIRECTORY_SEPARATOR . 'build.ser';
             if (file_exists($statusfile)) {
                 $project = new Xinc_Project();
                 $project->setName($file);
                 try {
                     $object = Xinc_Build_Repository::getLastBuild($project);
                     $builds->add($object);
                 } catch (Exception $e) {
                 }
             }
         }
     }
     $projects = array();
     while ($builds->hasNext()) {
         $build = $builds->next();
         /**
          * Do we have children?
          */
         $children = array();
         foreach ($this->_subMenus as $subExtension) {
             $item = $subExtension->getItem($build->getProject());
             if (!$item instanceof Xinc_Plugin_Repos_Gui_Menu_Extension_Item) {
                 continue;
             }
             $children[] = $item->generate();
         }
         $item = new Xinc_Plugin_Repos_Gui_Menu_Extension_Item('project-' . $build->getProject()->getName() . '-' . $build->getBuildTime(), $build->getLabel() . ' - ' . $build->getProject()->getName(), './dashboard/detail?project=' . $build->getProject()->getName() . '&timestamp=' . $build->getBuildTime(), $build->getProject()->getName(), '', false, count($children) > 0 ? false : true, $children);
         $projects[] = $item->generate();
     }
     return implode(',', $projects);
 }
 /**
  * Load the requested artifacts file and output it to the browser
  *
  * @param array $params
  */
 private function _getDeliverableFile($params)
 {
     /**$projectName = $params['p'];
        $buildTime = $params['buildtime'];
        $file = $params['file'];*/
     $query = urldecode($_SERVER['REQUEST_URI']);
     preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*)/", $query, $matches);
     if (count($matches) != 8) {
         echo "Could not find deliverable";
         die;
     }
     $projectName = $matches[5];
     $buildTime = $matches[6];
     // if buildtime==latest, get latest build
     // latest
     // Xinc_Build_History::get()
     $file = $matches[7];
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         /**$build = Xinc_Build::unserialize($project,
            $buildTime,
            Xinc_Gui_Handler::getInstance()->getStatusDir());*/
         if ($buildTime == 'latest-successful') {
             $build = Xinc_Build_Repository::getLastSuccessfulBuild($project);
             $statusDir = Xinc_Build_History::getLastSuccessfulBuildDir($project);
         } else {
             if ($buildTime == 'latest') {
                 $build = Xinc_Build_Repository::getLastBuild($project);
                 $statusDir = Xinc_Build_History::getLastBuildDir($project);
             } else {
                 $build = Xinc_Build_Repository::getBuild($project, $buildTime);
                 $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime);
             }
         }
         $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Deliverable::DELIVERABLE_DIR . DIRECTORY_SEPARATOR;
         /**
          * Replace multiple / slashes with just one
          */
         $fileName = $statusDir . $file;
         $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName);
         $realfile = realpath($fileName);
         if ($realfile != $fileName) {
             // check if we have an alias name
             $deliverables = $build->getInternalProperties()->get('deliverables');
             if (is_array($deliverables)) {
                 $aliasTest = basename($file);
                 if (isset($deliverables['aliases']) && isset($deliverables['aliases'][$aliasTest])) {
                     $aliasFile = $deliverables['deliverables'][$deliverables['aliases'][$aliasTest]];
                     if (file_exists($aliasFile) && is_file($aliasFile)) {
                         return $this->_outputDeliverable($aliasFile);
                     }
                 }
             }
             echo "Could not find artifact";
             die;
         } else {
             if (file_exists($fileName) && is_file($realfile)) {
                 return $this->_outputDeliverable($fileName);
             } else {
                 echo "Could not find deliverable";
                 die;
             }
         }
     } catch (Exception $e) {
         echo "Could not find any deliverable";
         die;
     }
 }
 /**
  * Load the requested artifacts file and output it to the browser
  *
  * @param array $params
  */
 private function _getDocumentationFile($params)
 {
     /**$projectName = $params['p'];
        $buildTime = $params['buildtime'];
        $file = $params['file'];*/
     $query = urldecode($_SERVER['REQUEST_URI']);
     preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*)/", $query, $matches);
     if (count($matches) != 8) {
         echo "Could not find documentation 1";
         die;
     }
     $projectName = $matches[5];
     $buildTime = $matches[6];
     // if buildtime==latest, get latest build
     // latest
     // Xinc_Build_History::get()
     $file = $matches[7];
     //$file = urldecode($file);
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         /**$build = Xinc_Build::unserialize($project,
            $buildTime,
            Xinc_Gui_Handler::getInstance()->getStatusDir());*/
         if ($buildTime == 'latest-successful') {
             $build = Xinc_Build_Repository::getLastSuccessfulBuild($project);
             $statusDir = Xinc_Build_History::getLastSuccessfulBuildDir($project);
         } else {
             if ($buildTime == 'latest') {
                 $build = Xinc_Build_Repository::getLastBuild($project);
                 $statusDir = Xinc_Build_History::getLastBuildDir($project);
             } else {
                 $build = Xinc_Build_Repository::getBuild($project, $buildTime);
                 $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime);
             }
         }
         $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Documentation::DOCUMENTATION_DIR . DIRECTORY_SEPARATOR;
         /**
          * Replace multiple / slashes with just one
          */
         $fileName = $statusDir . $file;
         $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName);
         $realfile = realpath($fileName);
         if ($realfile != $fileName) {
             echo "Could not find documentation 2";
             die;
         } else {
             if (file_exists($fileName) && is_file($realfile)) {
                 return $this->_outputDoc($fileName);
             } else {
                 echo "Could not find documentation 3";
                 die;
             }
         }
     } catch (Exception $e) {
         echo "Could not find any documentation";
         die;
     }
 }
Beispiel #6
0
 /**
  * Load the requested artifacts file and output it to the browser
  *
  * @param array $params
  */
 private function _getArtifactFile($params)
 {
     /**$projectName = $params['p'];
        $buildTime = $params['buildtime'];
        $file = $params['file'];*/
     $query = urldecode($_SERVER['REQUEST_URI']);
     preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/([\\w\\-\\.\\/]+[^#?]+)/", $query, $matches);
     if (count($matches) != 8) {
         echo "Could not find artifact";
         die;
     }
     $projectName = $matches[5];
     $buildTime = $matches[6];
     // if buildtime==latest, get latest build
     // latest
     // Xinc_Build_History::get()
     $file = $matches[7];
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         /**$build = Xinc_Build::unserialize($project,
            $buildTime,
            Xinc_Gui_Handler::getInstance()->getStatusDir());*/
         if ($buildTime == 'latest-successful') {
             $build = Xinc_Build_Repository::getLastSuccessfulBuild($project);
             $statusDir = Xinc_Build_History::getLastSuccessfulBuildDir($project);
         } else {
             if ($buildTime == 'latest') {
                 $build = Xinc_Build_Repository::getLastBuild($project);
                 $statusDir = Xinc_Build_History::getLastBuildDir($project);
             } else {
                 $build = Xinc_Build_Repository::getBuild($project, $buildTime);
                 $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime);
             }
         }
         $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Artifacts::ARTIFACTS_DIR . DIRECTORY_SEPARATOR;
         /**
          * Replace multiple / slashes with just one
          */
         $fileName = $statusDir . $file;
         $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName);
         $realfile = realpath($fileName);
         if ($realfile != $fileName) {
             echo "Could not find artifact";
             die;
         } else {
             if (file_exists($fileName) && is_file($realfile)) {
                 //echo "here";
                 $contentType = $this->mime_content_type2($fileName);
                 if (!empty($contentType)) {
                     header("Content-Type: " . $contentType);
                 }
                 readfile($fileName);
                 die;
             } else {
                 echo "Could not find artifact";
                 die;
             }
         }
     } catch (Exception $e) {
         echo "Could not find any artifacts";
         die;
     }
 }
Beispiel #7
0
 private function _getHistoryBuilds($projectName, $start, $limit = null)
 {
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         $buildHistoryArr = Xinc_Build_History::getFromTo($project, $start, $limit);
         $totalCount = Xinc_Build_History::getCount($project);
         $builds = array();
         foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) {
             try {
                 //echo $buildTimestamp . ' - '. $buildFileName . "<br>";
                 //Xinc_Build_Repository::getBuild($project, $buildTimestamp);
                 //$buildObject = Xinc_Build::unserialize($project,
                 //                                       $buildTimestamp,
                 //                                       Xinc_Gui_Handler::getInstance()->getStatusDir());
                 $buildObject = Xinc_Build_Repository::getBuild($project, $buildTimestamp);
                 $timezone = $buildObject->getConfigDirective('timezone');
                 if ($timezone !== null) {
                     Xinc_Timezone::set($timezone);
                 }
                 $builds[] = array('buildtime' => date('Y-m-d H:i:s', $buildObject->getBuildTime()), 'timezone' => Xinc_Timezone::get(), 'buildtimeRaw' => $buildObject->getBuildTime(), 'label' => $buildObject->getLabel(), 'status' => $buildObject->getStatus());
                 /**
                  * restore to system timezone
                  */
                 $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone');
                 if ($xincTimezone !== null) {
                     Xinc_Timezone::set($xincTimezone);
                 } else {
                     Xinc_Timezone::reset();
                 }
             } catch (Exception $e) {
                 // TODO: Handle
             }
         }
         //$builds = array_reverse($builds);
     } catch (Exception $e) {
         $builds = array();
         $totalCount = 0;
     }
     $object = new stdClass();
     $object->totalcount = $totalCount;
     $object->builds = $builds;
     //return new Xinc_Build_Iterator($builds);
     return $object;
 }