예제 #1
0
 static function getParentAnnotativeLayers(&$mvTitle)
 {
     //first check if we are in range of the cache:
     if (count(self::$annoCache) != 0) {
         foreach (self::$annoCache as $aMVD) {
             if (is_object($aMVD)) {
                 if ($aMVD->start_time <= $mvTitle->getStartTimeSeconds() && $aMVD->start_time <= $mvTitle->getEndTimeSeconds() && $aMVD->end_time >= $mvTitle->getEndTimeSeconds() && $aMVD->end_time >= $mvTitle->getEndTimeSeconds() && $aMVD->stream_id == $mvTitle->getStreamId()) {
                     //just return the cached result (faster than the set of db queries below)
                     return $aMVD;
                 }
             }
         }
     }
     $dbr = wfGetDB(DB_SLAVE);
     $from_tables = $dbr->tableName('mv_mvd_index');
     $vars = '`mv_page_id` as `id`, `wiki_title`,`mvd_type`,	`stream_id`, `start_time`,`end_time`,`view_count`';
     $cond = array('stream_id' => $mvTitle->getStreamId(), 'mvd_type' => 'Anno_en');
     $cond[] = ' `start_time` <= ' . $mvTitle->getStartTimeSeconds();
     $cond[] = ' `start_time` <= ' . $mvTitle->getEndTimeSeconds();
     $cond[] = ' `end_time` 	  >= ' . $mvTitle->getStartTimeSeconds();
     $cond[] = ' `end_time`    >= ' . $mvTitle->getEndTimeSeconds();
     $res = $dbr->select($from_tables, $vars, $cond, __METHOD__, array('LIMIT' => 1));
     //print $dbr->lastQuery();
     //die;
     $aMvd_rows = MV_Index::getMVDMeta($res, false, 'Speech_by,Bill,category');
     //returns the result in array set to current:
     $aMvd = end($aMvd_rows);
     if (!isset(self::$annoCache[$aMvd->id])) {
         self::$annoCache[$aMvd->id] = $aMvd;
     }
     return $aMvd;
 }