// TL register it's own autoload() in common.php // // If PHPExcel require is done AFTER common.php // things does not work. // --------------------------------------------------------------------- require_once '../../third_party/codeplex/PHPExcel.php'; // Must be included BEFORE common.php require_once 'common.php'; require_once "lang_api.php"; require_once 'results.class.php'; require_once 'displayMgr.php'; testlinkInitPage($db); $templateCfg = templateConfiguration(); $args = init_args(); checkRights($db, $_SESSION['currentUser'], $args); $labels = getLabels(); $tplan_mgr = new testPlanUrgency($db); list($tproject_info, $tplan_info) = getAncestorsInfo($db, $tplan_mgr, $args->tproject_id, $args->tplan_id); $gui = initializeGui($args, $tplan_mgr, $tproject_info, $tplan_info); if (is_null($args->doReport) || is_null($args->build_id)) { $smarty = new TLSmarty(); $smarty->assign('gui', $gui); $smarty->display($templateCfg->template_dir . $templateCfg->default_template); exit; // Not needed just to remember that execution will not continue } $cfg = getCfg($gui); $not_run_label = lang_get($cfg['results']['status_label']['not_run']); $i18n = array(lang_get($cfg['results']['status_label']['failed']) => PHPExcel_Style_Color::COLOR_RED, lang_get($cfg['results']['status_label']['passed']) => PHPExcel_Style_Color::COLOR_GREEN); $testCaseCfg = config_get('testcase_cfg'); $testCasePrefix = $tproject_info['prefix'] . $testCaseCfg->glue_character;
function sanitizeLabel($string) { return preg_replace('/[^\w\s-]+/', '-', trim($string)); } function getLabels() { global $curl, $labels, $githubRepoOwner, $githubRepo; curl_setopt($curl, CURLOPT_URL, "https://api.github.com/repos/$githubRepoOwner/$githubRepo/labels"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); // or POST curl_setopt($curl, CURLOPT_POSTFIELDS, ''); $labelData = json_decode(curl_exec($curl)); foreach ($labelData as $label) { $labels[] = $label->name; } } getLabels(); function createLabel($name) { global $curl, $labels, $githubRepoOwner, $githubRepo; curl_setopt($curl, CURLOPT_URL, "https://api.github.com/repos/$githubRepoOwner/$githubRepo/labels"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); // or POST curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode( array( 'name'=> $name, 'color'=> '000000' ))); $labels[] = $name; echo 'Creating label: "' . $name . "\"\n"; return json_decode(curl_exec($curl)); } function createIssue($array) { global $curl, $labels, $githubRepoOwner, $githubRepo; foreach ($array['labels'] as $label) { if (!in_array($label, $labels)) createLabel($label);
} if ($status < 5 && !$row->canceled) { $list .= "<h4>unknown shows:</h4><ul>"; $status = 5; } elseif ($status < 6 && $row->canceled) { if ($status == 5) { $list .= "</ul>"; } $list .= "<h4>canceled shows (by last episode):</h4><ul>"; $status = 6; } } } } } $list .= "<li" . ($status == 3 && $lastDate && date("d.m.Y", $lastDate + $userInfo->gmt_diff) != date("d.m.Y", $row->next_episode + $userInfo->gmt_diff) && $userInfo->list_day_margin ? " style='margin-top:" . $userInfo->list_day_margin . "px'" : "") . ">" . ($row->next_episode && !$row->new_episodes ? date("d.m" . ($row->next_episode > $timeToComp + 300 * DAY ? ".Y" : ""), $row->next_episode + $userInfo->gmt_diff) . ($row->next_episode < $timeToComp + $userInfo->list_days * DAY ? ", " . substr(date("l", $row->next_episode + $userInfo->gmt_diff), 0, 100) : "") . ": " : "") . ($status == 6 ? ($row->last_episode ? date("d.m.Y", $row->last_episode + $userInfo->gmt_diff) : "never aired") . ": " : "") . "<a href='" . ($user ? $address . showNameForUrl($row->n_show) : "") . "' id='showL" . $row->id_show . "'>" . $row->n_show . ($userInfo->show_flags && $row->country ? " <img src='" . $cdnaddress . "flags/" . strtolower(substr($row->country, 0, 2)) . ".png' alt='" . $row->country . "' /> " : "") . ($user ? getLabels($row) : ""); $newComments[0] += $row->new_comments; $newComments[$status] += $row->new_comments; if ($userInfo->list_show_last_episode && !$row->canceled && $status < 5 && (!$row->next_episode || ($row->left_episodes ? $row->left_episodes : 0) == 1)) { if ($status != 3 || $row->next_episode < time() + 3 * DAY) { $list .= " <i class='glyphicon glyphicon-step-forward'></i>"; } else { $q = query("SELECT Count(*)/" . ($row->c_season - 1) . " as c FROM shows_episodes WHERE id_show=" . $row->id_show . " AND season<" . $row->c_season . " GROUP BY id_show")->fetch_object(); if ($q) { if ($q->c - 1 <= $row->c_episode) { $list .= " <i class='glyphicon glyphicon-step-forward'></i>"; } } } } $list .= ($row->id_show_tvmaze == 0 ? " <i class='glyphicon glyphicon-alert'></i>" : "") . ($row->canceled && $status != 6 ? " <i class='glyphicon glyphicon-remove'></i>" : "") . "</a>" . (($status == 2 || $status == 4) && $row->new_episodes > 1 ? " (" . $row->new_episodes . " episodes)" : "") . (($row->new_episodes == 1 && $status < 3 || $status == 3) && $userInfo->list_show_titles && $row->next_title ? " (" . $row->next_title . ")" : "") . "</li>";