public function getContent(Xinc_Build_Interface $build) { $deliverableLinkTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'documentation-link.phtml'); $deliverableLinkTemplate = file_get_contents($deliverableLinkTemplateFile); $getDeliverableUrl = './api/documentation/get/file/' . $build->getProject()->getName() . '/' . $build->getBuildTime() . '/'; $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); $subDir = $build->getStatusSubDir(); $docDir = $statusDir . DIRECTORY_SEPARATOR . $subDir . DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Documentation::DOCUMENTATION_DIR; $deliverableLinks = array(); $docs = $build->getInternalProperties()->get('documentation'); if (!is_array($docs)) { return false; } foreach ($docs as $alias => $array) { $publicName = $alias; $dirName = dirname($array['file']); $indexFile = preg_replace('/\\/+/', '/', $array['index']); $myDocDir = $docDir . DIRECTORY_SEPARATOR . $publicName; $myDocDir = preg_replace('/\\/+/', '/', $myDocDir); $indexFile = str_replace($myDocDir, '', $indexFile); $link = $getDeliverableUrl . $publicName . '/' . $indexFile; $link = preg_replace('/\\/+/', '/', $link); $deliverableLinks[] = call_user_func_array('sprintf', array($deliverableLinkTemplate, $link, $publicName)); } return implode(', ', $deliverableLinks); }
/** * Get an instance of the Data Repository * * @return Xinc_Data_Repository */ public static function getInstance() { if (!Xinc_Data_Repository::$instance) { Xinc_Data_Repository::$instance = new Xinc_Data_Repository(); } return Xinc_Data_Repository::$instance; }
public function handleEvent($eventId) { if (isset($_REQUEST['project'])) { $this->projectName = $_REQUEST['project']; } // TODO Cleanup this $path = $_SERVER['REDIRECT_URL']; $path = preg_replace('#^' . dirname($_SERVER['PHP_SELF']) . '#', '', $path); $path = '/' . ltrim($path, '/'); switch ($path) { case '/statistics/graph/': $graphName = $_REQUEST['name']; header('Content-Type: image/svg+xml'); header('Content-Disposition: inline; filename=' . $graphName); $content = $this->loadGraph($graphName); header('Content-Length: ' . strlen($content)); echo $content; break; case '/statistics/': default: ob_start(); include Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'statistics' . DIRECTORY_SEPARATOR . 'graphbase.phtml'); ob_end_flush(); break; } }
public function getContent(Xinc_Build_Interface $build) { $allBuildsTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'allBuildsJs.phtml'); $allBuildsTemplate = file_get_contents($allBuildsTemplateFile); $content = str_replace(array('{projectname}', '{buildtime}'), array($build->getProject()->getName(), $build->getBuildTime()), $allBuildsTemplate); return $content; }
public function handleEvent($eventId) { switch ($eventId) { case Xinc_Gui_Event::PAGE_LOAD: // Build Main Menu include Xinc_Data_Repository::getInstance()->getWeb('templates/index/index.phtml'); break; default: break; } }
public function getContent(Xinc_Build_Interface $build) { $changeSet = $build->getProperties()->get('changeset'); if ($changeSet instanceof Xinc_Plugin_Repos_ModificationSet_Result) { if (!$changeSet->isChanged()) { return false; } $templateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'modifications.phtml'); $templateContent = file_get_contents($templateFile); $templateContent = str_replace(array('{previous_revision}', '{current_revision}', '{files_modified}', '{files_added}', '{files_deleted}', '{files_merged}', '{files_conflicted}'), array($changeSet->getLocalRevision(), $changeSet->getRemoteRevision(), count($changeSet->getUpdatedResources()), count($changeSet->getNewResources()), count($changeSet->getDeletedResources()), count($changeSet->getMergedResources()), count($changeSet->getConflictResources())), $templateContent); return $templateContent; } else { return false; } }
protected function _generateAllExtensions(Xinc_Build_Interface $build) { $overviewTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'overview-extension.phtml'); $overviewTemplate = file_get_contents($overviewTemplateFile); $contentParts = array(); foreach ($this->_extensions as $ext) { $extContent = $ext->getContent($build); if ($extContent === false) { continue; } $content = call_user_func_array('sprintf', array($overviewTemplate, $ext->getTitle(), $extContent)); $contentParts[] = $content; } return implode("\n", $contentParts); }
public function getContent(Xinc_Build_Interface $build) { $changeSet = $build->getProperties()->get('changeset'); if ($changeSet instanceof Xinc_Plugin_Repos_ModificationSet_Result) { $logMessageTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'modification_log_row.phtml'); $logMessageTemplateContent = file_get_contents($logMessageTemplateFile); $logMessagesArr = array(); $logMessages = $changeSet->getLogMessages(); if (count($logMessages) == 0) { return false; } foreach ($logMessages as $log) { $xpandable = ''; $logMessageString = $log['message']; $newLogString = ''; for ($i = 0; $i < strlen($logMessageString); $i = $i + 60) { $newLogString .= substr($logMessageString, $i, 60) . "<br/>"; } $logMessageString = $newLogString; if (strlen($logMessageString) > 80) { $xpandable = 'expandable'; $logMessageDiv = '<div class="mdesc"> <div class="short">' . substr($logMessageString, 0, 60) . ' ...</div> <div class="long">'; $logMessageDiv .= $logMessageString; $logMessageDiv .= '</div> </div>'; } else { $logMessageDiv = '<div class="mdesc">'; $logMessageDiv .= $logMessageString; $logMessageDiv .= '</div>'; } $logContent = str_replace(array('{author}', '{revision}', '{message}', '{expandable}'), array($log['author'], $log['revision'], $logMessageDiv, $xpandable), $logMessageTemplateContent); $logMessagesArr[] = $logContent; } $templateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'modification_log.phtml'); $templateContent = file_get_contents($templateFile); $templateContent = str_replace(array('{logmessages}'), array(implode('', $logMessagesArr)), $templateContent); return $templateContent; } else { return false; } }
public function getContent(Xinc_Build_Interface $build) { $deliverableLinkTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'deliverable-link.phtml'); $deliverableLinkTemplate = file_get_contents($deliverableLinkTemplateFile); $getDeliverableUrl = './api/deliverable/get/download/' . $build->getProject()->getName() . '/' . $build->getBuildTime() . '/'; $deliverableLinks = array(); $deliverables = $build->getInternalProperties()->get('deliverables'); if (!isset($deliverables['deliverables'])) { return false; } foreach ($deliverables['deliverables'] as $fileName => $fileLocation) { $publicName = $fileName; foreach ($deliverables['aliases'] as $alias => $realName) { if ($realName == $publicName) { $publicName = $alias; break; } } $link = $getDeliverableUrl . $publicName; $deliverableLinks[] = call_user_func_array('sprintf', array($deliverableLinkTemplate, $link, $publicName)); } return implode(', ', $deliverableLinks); }
public function handleEvent($eventId) { $this->projectName = $_GET['project']; if (isset($_GET['timestamp'])) { $this->buildTimeStamp = $_GET['timestamp']; } $this->project = new Xinc_Project(); $this->project->setName($this->projectName); switch ($eventId) { case Xinc_Gui_Event::PAGE_LOAD: $handler = Xinc_Gui_Handler::getInstance(); $statusDir = $handler->getStatusDir(); if ($this->buildTimeStamp != null) { $fullStatusDir = Xinc_Build_History::getBuildDir($this->project, $this->buildTimeStamp); } else { $fullStatusDir = Xinc_Build_History::getLastBuildDir($this->project); $this->buildTimeStamp = Xinc_Build_History::getLastBuildTime($this->project); } //$statusFile = $fullStatusDir . DIRECTORY_SEPARATOR . 'build.ser'; $this->build = Xinc_Build::unserialize($this->project, $this->buildTimeStamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $timezone = $this->build->getConfigDirective('timezone'); if ($timezone !== null) { Xinc_Timezone::set($timezone); } $detailDir = $fullStatusDir; /** * get History Builds */ //$this->historyBuilds = $this->getHistoryBuilds($statusDir); /** * Generate the build selector on the right */ $this->_generateBuildsView(); /** * Overview info tab */ $this->_generateSummaryView(); /** * Generate the tab for the log messages */ $this->_generateLogView(); /** * Generate the external tabs that were registered through a hook */ $this->_generateExternalExtensions(); include Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'projectDetail.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(); } }
private function _getTemplateFileName($type = 'line') { $base = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'statistics'); switch ($type) { case 'line': default: return $base . DIRECTORY_SEPARATOR . 'linegraph.phtml'; break; } }
public function getArtifacts(Xinc_Build_Interface $build) { $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); $projectName = $build->getProject()->getName(); $buildTimestamp = $build->getBuildTime(); $buildLabel = $build->getLabel(); $templateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'artifactsJs.phtml'); $template = file_get_contents($templateFile); $content = str_replace(array('{projectname}', '{buildtime}', '{buildlabel}'), array($projectName, $buildTimestamp, $buildLabel), $template); return $content; }
public function getTestResults(Xinc_Build_Interface $build) { require_once 'PEAR/Config.php'; $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); $projectName = $build->getProject()->getName(); $buildTimestamp = $build->getBuildTime(); $buildLabel = $build->getLabel(); $templateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'phpunit-summary.phtml'); $template = file_get_contents($templateFile); $url = '/phpunit/results/?project=' . $projectName . '&buildtime=' . $buildTimestamp . '&f=results.html'; $sourceFile = $build->getInternalProperties()->get('phpunit.file'); if ($sourceFile != null && file_exists($sourceFile) && class_exists('XSLTProcessor')) { $xslFile = Xinc_Data_Repository::getInstance()->getPlugins('resources' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'summary.xsl'); try { $outputFileName = Xinc_Ini::getInstance()->get('tmp_dir', 'xinc') . DIRECTORY_SEPARATOR . 'phpunit_summary_' . $projectName . '_' . $buildTimestamp; } catch (Exception $e) { Xinc_Logger::getInstance()->error('Cannot get xinc.ini configuration'); $outputFileName = 'phpunit_summary_' . $projectName . '_' . $buildTimestamp; } if (file_exists($outputFileName)) { $summary = file_get_contents($outputFileName); } else { $summary = $this->_transformResults($sourceFile, $xslFile, $outputFileName); } //$click = 'openMenuTab(\'phpunit-'.$projectName.'-'.$buildTimestamp.'\',\'PHPUnit - '.$projectName.'\',\''.$url.'\',null,false,false,\'auto\');'; $detailsLink = '<a href="' . $url . '">Details</a>'; $content = str_replace(array('{detailsLink}', '{summary}'), array($detailsLink, $summary), $template); } else { $content = false; } return $content; }
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(); } }