コード例 #1
0
 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;
     }
 }
コード例 #2
0
ファイル: DbPerson.class.php プロジェクト: chgk/db.chgk.info
 private function loadTours()
 {
     $res = $this->db->editorToursRes($this->id);
     $this->tours = array();
     while ($tourRow = db_fetch_object($res)) {
         $this->tours[] = DbPackage::newFromRow($tourRow);
     }
 }
コード例 #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;
 }
コード例 #4
0
ファイル: DbStat.class.php プロジェクト: chgk/db.chgk.info
 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;
 }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
 public function delete()
 {
     $this->loadTours();
     foreach ($this->tours as $tour) {
         $tour->delete();
     }
     parent::delete();
 }
コード例 #7
0
ファイル: DbPackage.class.php プロジェクト: chgk/db.chgk.info
 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();
     }
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 public function getTour()
 {
     if (!$this->tour) {
         $row = $this->db->getTournament($this->question->ParentId);
         $this->tour = DbPackage::newFromRow($row);
     }
     return $this->tour;
 }
コード例 #10
0
 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}");
     }
 }