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;
     }
 }
Example #2
0
 private function loadTours()
 {
     $res = $this->db->editorToursRes($this->id);
     $this->tours = array();
     while ($tourRow = db_fetch_object($res)) {
         $this->tours[] = DbPackage::newFromRow($tourRow);
     }
 }
Example #3
0
 private function getPublishedPackage()
 {
     if (NULL === $this->publishedPackage) {
         $db = new DbDatabase();
         $t = $db->getTournamentByTextId($this->getPublishedTextId());
         if ($t) {
             $this->publishedPackage = DbPackage::newFromRow($t);
         } else {
             $this->publishedPackage = FALSE;
         }
     }
     return $this->publishedPackage;
 }
Example #4
0
 function getDayNumbers()
 {
     if (!isset($this->dayNumbers)) {
         $instance = new DbDatabase();
         $res = $instance->getLastTournamentsRes(50000);
         for ($date = $this->getFirstDate(); $date <= $this->getLastDate(); $date = date('Y-m-d', strtotime($date . ' +1 days'))) {
             $this->dayNumbers[$date] = 0;
         }
         while ($row = $instance->fetch_row($res)) {
             $package = DbPackage::newFromRow($row);
             $this->dayNumbers[$package->getCreatedAt()] += $package->getQuestionsNumber();
         }
     }
     return $this->dayNumbers;
 }
 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 delete()
 {
     $this->loadTours();
     foreach ($this->tours as $tour) {
         $tour->delete();
     }
     parent::delete();
 }
Example #7
0
 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();
     }
 }
 public function getEditors()
 {
     if ($this->editors === NULL) {
         $this->editors = parent::getEditors();
         if (!$this->editors && $this->getEditor() == $this->getParentEditor()) {
             $this->editors = $this->getParent()->getEditors();
         }
     }
     return $this->editors;
 }
Example #9
0
 public function getTour()
 {
     if (!$this->tour) {
         $row = $this->db->getTournament($this->question->ParentId);
         $this->tour = DbPackage::newFromRow($row);
     }
     return $this->tour;
 }
 protected function makeTournamentsResults()
 {
     $factory = new DbQuestionFactory();
     $this->results = array();
     $words = $this->words;
     #      $s = "~([^a-zA-Zа-яА-Я_0-9])(".implode('|', $words).")~iu";
     while ($row = db_fetch_object($this->mysqlRes)) {
         $t = DbPackage::newFromRow($row);
         #        $title = preg_replace($s, '$1<strong class="highlight">$2</strong>', $t->getTitle());
         $title = $t->getTitle();
         $date = $t->getPlayedAtDate();
         $snippet = '';
         $snippetArray = array();
         if ($date) {
             $snippetArray[] = '<strong>Дата:</strong> ' . $date;
         }
         $editor = $t->getEditorHtml();
         if ($editor) {
             $snippetArray[] = "<p>{$editor}</p>";
         }
         $snippet = implode('<br/>', $snippetArray);
         $this->results[] = array('link' => url($t->getLink()), 'title' => $title, 'snippet' => "<br/>{$snippet}");
     }
 }