public function parseURL() { $this->question = FALSE; if (arg(1) == 'person') { if (!arg(2)) { return FALSE; } $this->person = new DbPerson(arg(2)); $this->itsme = arg(3) == 'itsme'; return TRUE; } elseif (arg(1) == 'question') { if (!arg(3)) { return FALSE; } $tournament = DbPackage::newFromDb(arg(2)); if (!$tournament) { return FALSE; } $this->question = $tournament->getQuestion(arg(3)); $this->question->setForSearch(); return TRUE; } else { return FALSE; } }
public function getQuestionFromTextId($textId) { if (preg_match('/^unsorted(\\d+)(?:[.](\\d+))*-(\\d+)/', $textId, $matches)) { return $this->getUnsortedQuestion($matches[1], $matches[2], $matches[3]); } $textId = str_replace('/', '-', $textId); $arr = explode('-', $textId); $number = array_pop($arr); $tour = implode('-', $arr); $tournament = DbPackage::newFromDb($tour); if ($tournament instanceof DbPackageError) { return FALSE; } $question = $tournament->getQuestion($number); $isQuestion = $question->exists(); if (!$question->exists()) { return FALSE; } else { return $question; } }
public function setParent($parent = FALSE) { if ($parent) { $this->parent = $parent; } elseif ($this->tour->ParentId) { $this->parent = DbPackage::newFromDb($this->tour->ParentId); } elseif ($this->tour->ParentId === '0') { $this->parent = DbPackage::newRoot(); } }