本文整理汇总了PHP中Contest::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Contest::factory方法的具体用法?PHP Contest::factory怎么用?PHP Contest::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contest
的用法示例。
在下文中一共展示了Contest::factory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->view->error_message = "You need to login to change the contest.";
return;
}
$contest = $this->_request->get("contest");
$contestM = Contest::factory($contest);
if (!$contestM->authenticateUser($auth->getIdentity())) {
$this->view->error_message = "You have not been granted access to this contest. This might be a restricted contest.";
return;
}
$session = new Zend_Session_Namespace(webconfig::$session_namespace);
$session->contestid = $contest;
$session->contestname = "Custom Contest";
$this->_redirect("/");
}
示例2: getContestState
public function getContestState($contestname)
{
$contest = Contest::factory((string) $contestname);
if (empty($contest)) {
return "before";
}
$start = $contest->getContestTime();
$end = $contest->getContestEndTime();
$current = time();
if ($current < $start) {
return "before";
}
if ($current < $end) {
return "ongoing";
}
if (!$contest->isResultDeclared()) {
return "pending_result";
}
return "after";
}
示例3: indexAction
public function indexAction()
{
$page = $this->getRequest()->get("page");
$contest = Contest::factory(webconfig::getContestId());
if (!$contest) {
return;
}
$xp = $contest->getXPath();
$res = $xp->query("/contest/frontend/page[@id='{$page}']/@href");
$href = $res->item(0)->nodeValue;
if (substr($href, 0, 5) == "http:" or substr($href, 0, 6) == "https:") {
$this->_redirect($href);
}
$file = config::getFilename("data/contests/" . $res->item(0)->nodeValue);
if (!is_file($file)) {
echo "Please edit '{$file}' to view this page.";
} else {
echo file_get_contents($file);
}
}
示例4: exit
if (!is_file(get_file_name("data/problems/{$id}/index.html"))) {
echo "data/problems/{$id}/index.html does not exist. Aborting right now.\n";
exit(1);
}
if (empty($nick)) {
$nick = readline("Enter a nickname for the problem: ");
}
$element = $dom->createComment("nickname is also stored for informative purposes only.");
$root->appendChild($element);
$element = $dom->createElement("nick", $nick);
$root->appendChild($element);
if (empty($contest)) {
$contest = 'general';
}
require_once "lib/contest.inc";
$c = Contest::factory($contest);
if (empty($c)) {
die("That contest does not exist.\n");
}
if (empty($numcases)) {
$numcases = 0 + readline("Number of testcases: ");
}
for ($i = 0; $i < $numcases; $i++) {
$testcase = $dom->createElement("test");
$def = "data/problems/{$id}/{$namespace}{$i}.in";
if (!is_file(get_file_name($def))) {
die("{$def}: not found\n");
}
$element = $dom->createElement("inputpath", $def);
$testcase->appendChild($element);
$def = "data/problems/{$id}/{$namespace}{$i}.out";