コード例 #1
0
 public function postBuild()
 {
     SystemEvent::raise(SystemEvent::DEBUG, "Called.", __METHOD__);
     if (!@copy($this->getPtrProjectBuild()->getPtrProject()->getReportsWorkingDir() . CINTIENT_PHPCODESNIFFER_REPORT_XML_FILE, $this->getPtrProjectBuild()->getBuildDir() . $this->getReportXmlFilename())) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not backup original XML report file. [PID={$this->getProjectId()}] [BUILD={$this->getProjectBuildId()}]", __METHOD__);
     }
     $reportFullFile = $this->getPtrProjectBuild()->getBuildDir() . $this->getReportFullFilename();
     if (!@copy($this->getPtrProjectBuild()->getPtrProject()->getReportsWorkingDir() . CINTIENT_PHPCODESNIFFER_REPORT_FULL_FILE, $reportFullFile)) {
         SystemEvent::raise(SystemEvent::ERROR, "Could not backup original Full report file. [PID={$this->getProjectId()}] [BUILD={$this->getProjectBuildId()}]", __METHOD__);
     }
     // Clean up the direct to user report file, so we don't have to do it
     // each time on getViewData()
     $fd = fopen($reportFullFile, 'r');
     $originalFile = fread($fd, filesize($reportFullFile));
     fclose($fd);
     // Pretty dummy replacement of the path before the sources dir, trying
     // to hide as much as possible from the user (readibility purposes)
     $treatedFile = str_replace($this->getPtrProjectBuild()->getPtrProject()->getScmLocalWorkingCopy(), '', $originalFile);
     $treatedFile = Framework_SmartyPlugin::raw2html($treatedFile);
     file_put_contents($reportFullFile, $treatedFile);
     //
     // TODO: Process the XML report file, store for history purposes
     // TODO2: Also create an HTML file, with results, for direct inclusion by Smarty?
     //
     return true;
 }
コード例 #2
0
ファイル: webHandler.php プロジェクト: rasismeiro/cintient
$GLOBALS['user'] = isset($_SESSION['userId']) ? User::getById($_SESSION['userId']) : null;
$GLOBALS['project'] = (!empty($_SESSION['projectId']) || !empty($_GET['pid'])) && !empty($GLOBALS['user']) ? Project::getById($GLOBALS['user'], !empty($_GET['pid']) ? $_GET['pid'] : $_SESSION['projectId']) : null;
$_SESSION['projectId'] = $GLOBALS['project'] instanceof Project ? $GLOBALS['project']->getId() : null;
//
// Smarty
//
$GLOBALS['smarty'] = new Smarty();
$GLOBALS['smarty']->setAllowPhpTag(true);
$GLOBALS['smarty']->setCacheLifetime(0);
$GLOBALS['smarty']->setDebugging(SMARTY_DEBUG);
$GLOBALS['smarty']->setForceCompile(SMARTY_FORCE_COMPILE);
$GLOBALS['smarty']->setCompileCheck(SMARTY_COMPILE_CHECK);
$GLOBALS['smarty']->setTemplateDir(SMARTY_TEMPLATE_DIR);
$GLOBALS['smarty']->setCompileDir(SMARTY_COMPILE_DIR);
$GLOBALS['smarty']->error_reporting = error_reporting();
Framework_SmartyPlugin::init($GLOBALS['smarty']);
/* +----------------------------------------------------------------+ *\
|* | POST-SETUP                                                     | *|
\* +----------------------------------------------------------------+ */
if ($GLOBALS['settings'][SystemSettings::INTERNAL_BUILDER_ACTIVE]) {
    include 'src/handlers/buildHandler.php';
}
/* +----------------------------------------------------------------+ *\
|* | URL HANDLING                                                   | *|
\* +----------------------------------------------------------------+ */
if (preg_match('/^\\/(?:([\\w-]+)\\/(?:([\\w-]+)\\/)?)?$/', $GLOBALS['uri'], $matches)) {
    if (count($matches) == 1) {
        $GLOBALS['section'] = 'default';
        $GLOBALS['subSection'] = 'dashboard';
    } elseif (count($matches) == 2) {
        $GLOBALS['section'] = 'default';
コード例 #3
0
ファイル: AjaxManager.php プロジェクト: rasismeiro/cintient
 /**
  *
  */
 public static function project_history()
 {
     SystemEvent::raise(SystemEvent::DEBUG, "Called.", __METHOD__);
     if (empty($GLOBALS['project']) || !$GLOBALS['project'] instanceof Project || empty($_GET['bid'])) {
         $msg = 'Invalid request';
         SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__);
         echo json_encode(array('success' => false, 'error' => $msg));
         exit;
     }
     //
     // Viewing project build details
     //
     $build = null;
     // It's possible that no build was triggered yet.
     if (isset($_GET['bid']) && !empty($_GET['bid'])) {
         $build = Project_Build::getById($_GET['bid'], $GLOBALS['project'], $GLOBALS['user']);
     }
     if (!$build instanceof Project_Build) {
         $msg = 'Invalid request';
         SystemEvent::raise(SystemEvent::INFO, $msg, __METHOD__);
         echo json_encode(array('success' => false, 'error' => $msg));
         exit;
     }
     //
     // We need to process a Smarty file...
     // TODO: Centralize this
     //
     require_once CINTIENT_SMARTY_INCLUDE;
     $smarty = new Smarty();
     $smarty->setAllowPhpTag(true);
     $smarty->setCacheLifetime(0);
     $smarty->setDebugging(SMARTY_DEBUG);
     $smarty->setForceCompile(SMARTY_FORCE_COMPILE);
     $smarty->setCompileCheck(SMARTY_COMPILE_CHECK);
     $smarty->setTemplateDir(SMARTY_TEMPLATE_DIR);
     $smarty->setCompileDir(SMARTY_COMPILE_DIR);
     $smarty->error_reporting = error_reporting();
     Framework_SmartyPlugin::init($smarty);
     //
     // Special tasks. This is post build, so we're fetching an existing special task (never creating it)
     //
     $specialTasks = $build->getSpecialTasks();
     $smarty->assign('project_specialTasks', $specialTasks);
     if (!empty($specialTasks)) {
         foreach ($specialTasks as $task) {
             if (!class_exists($task)) {
                 SystemEvent::raise(SystemEvent::ERROR, "Unexisting special task. [PID={$GLOBALS['project']->getId()}] [BUILD={$build->getId()}] [TASK={$task}]", __METHOD__);
                 continue;
             }
             $o = $task::getById($build, $GLOBALS['user'], Access::READ);
             //$smarty->assign($task, $o); // Register for s
             if (!$o instanceof Build_SpecialTaskInterface) {
                 SystemEvent::raise(SystemEvent::ERROR, "Unexisting special task ID. [PID={$GLOBALS['project']->getId()}] [BUILD={$build->getId()}] [TASK={$task}] [TASKID={$build->getId()}]", __METHOD__);
                 continue;
             }
             $viewData = $o->getViewData();
             if (is_array($viewData)) {
                 foreach ($viewData as $key => $value) {
                     $smarty->assign($key, $value);
                 }
             }
             $o = null;
             unset($o);
         }
     }
     // Last assignments
     $smarty->assign('project_build', $build);
     $smarty->display('includes/buildHistoryRev.inc.tpl');
 }