function get_stream_cmml( $inline = false, $force_track = null ) { $dbr = wfGetDB( DB_SLAVE ); // set cmml name space if inline: $ns = ( $inline ) ? 'cmml:':''; $ns = ''; $encap = false;// if we should have a parent cmml tag if ( !$force_track ) { // check the request to get trac set: $mvcp = new MV_Component(); $mvcp->procMVDReqSet(); $tracks = $mvcp->mvd_tracks; if ( count( $mvcp->mvd_tracks ) > 1 )$encap = true; } else { $tracks = $force_track; $encap = false; } // get the stream title $streamTitle = new MV_Title( $this->stream_name . '/' . $this->req_time ); $wgTitle = Title::newFromText( $this->stream_name . '/' . $this->req_time, MV_NS_STREAM ); // do mvd_index query: $mvd_rows = MV_Index::getMVDInRange( $streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), $tracks, $getText = false, 'Speech_by,Bill,category' ); // get the stream stream req if ( $this->output_xml_header ) header( 'Content-Type: text/xml' ); // print the header: if ( !$inline )print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"; // if(!$inline)print '<!DOCTYPE cmml SYSTEM "http://svn.annodex.net/standards/cmml_2_0.dtd">'."\n"; $tracks = array(); if ( count( $mvd_rows ) != 0 ) { global $wgOut; $MV_Overlay = new MV_Overlay(); foreach ( $mvd_rows as $mvd ) { if ( !isset( $tracks[$mvd->mvd_type] ) )$tracks[$mvd->mvd_type] = ''; $tracks[$mvd->mvd_type] .= ' <' . $ns . 'clip id="mvd_' . htmlentities( $mvd->id ) . '" start="npt:' . htmlentities( seconds2npt( $mvd->start_time ) ) . '" end="npt:' . htmlentities( seconds2npt( $mvd->end_time ) ) . '"> <' . $ns . 'img src="' . htmlentities( $streamTitle->getFullStreamImageURL( null, seconds2npt( $mvd->start_time ) ) ) . '"/>'; // output all metadata @@todo we should generalize the semantic properties. $tracks[$mvd->mvd_type] .= ( isset( $mvd->Speech_by ) && trim( $mvd->Speech_by ) != '' ) ? '<meta name="Speech_by" content="' . htmlentities ( $mvd->Speech_by ) . '"/>':''; $tracks[$mvd->mvd_type] .= ( isset( $mvd->Bill ) && trim( $mvd->Bill ) != '' ) ? '<meta name="Bill" content="' . htmlentities( $mvd->Bill ) . '"/>':''; // add in categories as "keywords" if ( count( $mvd->category ) != 0 ) { $tracks[$mvd->mvd_type] .= '<meta name="keywords" content="'; $coma = ''; foreach ( $mvd->category as $cat ) { $tracks[$mvd->mvd_type] .= $coma . htmlentities( $cat ); $coma = ','; } $tracks[$mvd->mvd_type] .= '"/>'; } $tracks[$mvd->mvd_type] .= '<' . $ns . 'body><![CDATA[ ' . $MV_Overlay->getMVDhtml( $mvd, $absolute_links = true ). ' ]]></' . $ns . 'body> </' . $ns . 'clip>'; // clear wgOutput } } if ( $encap )print '<cmml_set>'; // based on: http://trac.annodex.net/wiki/CmmlChanges foreach ( $tracks as $role => $body_string ) { $ns = htmlentities( $ns ); ?> <cmml lang="en" id="<?php echo htmlentities($role); ?> " role="<?php echo wfMsg($role); ?> " xmlns="http://svn.annodex.net/standards/cmml_2_0.dtd"> <<?php echo $ns; ?> head> <<?php echo $ns; ?> title> <?php echo wfMsg($role); ?> </<?php echo $ns; ?> title> <<?php echo $ns; ?> meta name="description" content="<?php echo htmlentities(wfMsg($role . '_desc')); ?> "></<?php echo $ns; ?> meta> </<?php echo $ns; ?> head> <?php echo $body_string; ?> </cmml> <? } if ( $encap )print '</cmml_set>'; }
function get_stream_cmml($inline=false, $force_track=null){ $dbr =& wfGetDB(DB_SLAVE); //set cmml name space if inline: $ns = ($inline)?'cmml:':''; $ns=''; $encap=false;//if we should have a parent cmml tag if(!$force_track){ //check the request to get trac set: $mvcp = new MV_Component(); $mvcp->procMVDReqSet(); $tracks = $mvcp->mvd_tracks; if(count($mvcp->mvd_tracks)>1)$encap=true; }else{ $tracks = $force_track; $encap=false; } //get the stream title $streamTitle = new MV_Title($this->stream_name.'/'.$this->req_time); $wgTitle = Title::newFromText($this->stream_name.'/'.$this->req_time, MV_NS_STREAM); //do mvd_index query: $mvd_res = MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), $tracks); //get the stream stream req if(!$inline)header('Content-Type: text/xml'); //print the header: if(!$inline)print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"; //if(!$inline)print '<!DOCTYPE cmml SYSTEM "http://svn.annodex.net/standards/cmml_2_0.dtd">'."\n"; $tracks=array(); if(count($dbr->numRows($mvd_res))!=0){ global $wgOut; $MV_Overlay = new MV_Overlay(); while($mvd = $dbr->fetchObject($mvd_res)){ if(!isset($tracks[$mvd->mvd_type]))$tracks[$mvd->mvd_type]=''; $tracks[$mvd->mvd_type].=' <'.$ns.'clip id="mvd_'.$mvd->id.'" start="ntp:'.seconds2ntp($mvd->start_time).'" end="ntp:'.seconds2ntp($mvd->end_time).'"> <'.$ns.'img src="'.htmlentities($streamTitle->getFullStreamImageURL(null, seconds2ntp($mvd->start_time))).'"/> <'.$ns.'body><![CDATA[ '. $MV_Overlay->getMVDhtml($mvd, $absolute_links=true).' ]]></'.$ns.'body> </'.$ns.'clip>'; //clear wgOutput } } if($encap)print '<cmml_set>'; //based on: http://trac.annodex.net/wiki/CmmlChanges foreach($tracks as $role=>$body_string){ ?> <cmml lang="en" id="<?=$role?>" role="<?=wfMsg($role)?>" xmlns="http://svn.annodex.net/standards/cmml_2_0.dtd"> <<?=$ns?>head> <<?=$ns?>title><?=wfMsg($role)?></<?=$ns?>title> <<?=$ns?>description><?=htmlentities(wfMsg($role.'_desc'))?></<?=$ns?>description> </<?=$ns?>head> <?=$body_string?> </cmml> <? } if($encap)print '</cmml_set>'; }
function update_index_page(&$article, &$text) { global $mvgIP, $mvIndexTableName; //check static or $this usage context //use mv title to split up the values: $mvTitle = new MV_Title($article->mTitle->getDBkey()); //print "Wiki title: " . $mvTitle->getWikiTitle(); //fist check if an mvd entry for this stream already exists: $mvd_row = MV_Index::getMVDbyTitle($mvTitle->getWikiTitle()); //set up the insert values: $insAry = array('mv_page_id' => $article->mTitle->getArticleID(), 'wiki_title' => $mvTitle->getWikiTitle(), 'mvd_type' => $mvTitle->getTypeMarker(), 'stream_id' => $mvTitle->getStreamId(), 'start_time' => $mvTitle->getStartTimeSeconds(), 'end_time' => $mvTitle->getEndTimeSeconds()); $dbw =& wfGetDB(DB_WRITE); if (count($mvd_row) == 0) { return $dbw->insert($mvIndexTableName, $insAry); } else { $dbw->update($mvIndexTableName, $insAry, array('mv_page_id' => $mvd_row->mv_page_id)); } }
function parsePlaylist() { global $wgParser, $wgOut; //valid playlist in-line-attributes: $mvInlineAttr = array('wClip', 'mvClip', 'title', 'linkback', 'desc', 'desc', 'image'); //build a associative array of "clips" $seq_text = $this->getSequenceText(); $seq_lines = explode("\n", $seq_text); $parseBucket = $cur_attr = ''; $clip_inx = -1; foreach ($seq_lines as $line) { //actions start with | $e = strpos($line, '='); if ($e !== false) { $cur_attr = substr($line, 1, $e - 1); } if (in_array($cur_attr, $mvInlineAttr)) { if ($cur_attr == 'mvClip') { $clip_inx++; } //close the parse bucket (found a valid inline attr) if ($parseBucket != '' && $cur_attr != 'desc') { $output = $wgParser->parse($parseBucket, $parser->mTitle, $parser->mOptions, true, false); $parseBucket = ''; } } $start_pos = $e !== false ? $e + 1 : 0; if ($clip_inx != -1) { if (!isset($this->clips[$clip_inx])) { $this->clips[$clip_inx] = array(); } if (!isset($this->clips[$clip_inx][$cur_attr])) { $this->clips[$clip_inx][$cur_attr] = ''; } $this->clips[$clip_inx][$cur_attr] .= substr($line, $start_pos); } } //poluate data (this could go here or somewhere else) foreach ($this->clips as $inx => &$clip) { if (trim($clip['mvClip']) == '') { unset($this->clips[$inx]); continue; } if ($clip['mvClip']) { $sn = str_replace('?t=', '/', $clip['mvClip']); $streamTitle = new MV_Title($sn); $wgStreamTitle = Title::newFromText($sn, MV_NS_STREAM); if ($streamTitle->doesStreamExist()) { //mvClip is a substitue for src so assume its there: $clip['src'] = $streamTitle->getWebStreamURL(); //title if (!isset($clip['title'])) { $clip['title'] = ''; } if ($clip['title'] == '') { $clip['title'] = $streamTitle->getTitleDesc(); } if (!isset($clip['info'])) { $clip['info'] = ''; } if ($clip['info'] == '') { $clip['info'] = $wgStreamTitle->getFullURL(); } } //check if we should look up the image: if (!isset($clip['image'])) { $clip['image'] == ''; } if ($clip['image'] == '') { $clip['image'] = $streamTitle->getFullStreamImageURL(); } //check if desc was present: if (!isset($clip['desc'])) { $clip['desc'] = ''; } //for now just lookup all ... @@todo future expose diffrent language tracks if ($clip['desc'] == '') { $dbr =& wfGetDB(DB_SLAVE); $mvd_res = MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds()); if (count($dbr->numRows($mvd_res)) != 0) { $MV_Overlay = new MV_Overlay(); $wgOut->clearHTML(); while ($mvd = $dbr->fetchObject($mvd_res)) { //output a link /line break $MV_Overlay->outputMVD($mvd); $wgOut->addHTML('<br>'); } $clip['desc'] = $wgOut->getHTML(); $wgOut->clearHTML(); } } } } //print_r($this->clips); }
function mvDoMetavidStreamPage(&$title, &$article) { $mvTitle = new MV_Title($title->mDbkeyform); if ($mvTitle->doesStreamExist()) { // @@TODO check if we have /name corresponding to a view or // /ss:ss:ss or /ss:ss:ss/ee:ee:ee corresponding to a time request // force metavid to be special // (@@todo clean up skin.php to enable better tab controls) // $title->mNamespace= NS_SPECIAL; // add a hit to the digest if enabled: // @@todo (maybe in the future use javascript to confirm they acutally "watched" the clip) global $mvEnableClipViewDigest, $wgRequest; // don't log views without end times (default stream view) if ($mvEnableClipViewDigest && $mvTitle->end_time != null && $wgRequest->getVal('tl') != '1') { $dbw = wfGetDB(DB_WRITE); $dbw->insert('mv_clipview_digest', array('stream_id' => $mvTitle->getStreamId(), 'start_time' => $mvTitle->getStartTimeSeconds(), 'end_time' => $mvTitle->getEndTimeSeconds(), 'query_key' => $mvTitle->getStreamId() . $mvTitle->getStartTimeSeconds() . $mvTitle->getEndTimeSeconds(), 'view_date' => time())); // compensate for $mvDefaultClipRange around clips global $mvDefaultClipRange; $start_time = $mvTitle->getStartTimeSeconds() + $mvDefaultClipRange < 0 ? 0 : $mvTitle->getStartTimeSeconds() + $mvDefaultClipRange; $end_time = $mvTitle->getEndTimeSeconds() - $mvDefaultClipRange > $mvTitle->getDuration() ? 0 : $mvTitle->getEndTimeSeconds() - $mvDefaultClipRange; // also increment the mvd_page if we find a match: $dbw->update('mv_mvd_index', array('`view_count`=`view_count`+1'), array('stream_id' => $mvTitle->getStreamId(), 'start_time' => $start_time, 'end_time' => $end_time)); // print $dbw->lastQuery(); // also update the mvd_page if directly requested: $dbw->update('mv_mvd_index', array('`view_count`=`view_count`+1'), array('stream_id' => $mvTitle->getStreamId(), 'start_time' => $mvTitle->getStartTimeSeconds(), 'end_time' => $mvTitle->getEndTimeSeconds())); // print $dbw->lastQuery(); } // @@todo check if the requested title is already just the stream name: $streamTitle = Title::newFromText($mvTitle->getStreamName(), MV_NS_STREAM); // print " new title: " . $streamTitle . "\n"; $article = new MV_StreamPage($streamTitle, $mvTitle); } else { mvMissingStreamPage($mvTitle->stream_name); } }
function do_edit_submit($titleKey, $mvd_id, $returnEncapsulated = false) { global $wgOut, $wgScriptPath, $wgUser, $wgTitle, $wgRequest; if ($mvd_id == 'new') { $titleKey = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], '/')) . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new']; $pos2 = strpos($_REQUEST['title'], '/'); $pos1 = strpos($_REQUEST['title'], ':'); //$nameKey ='mp_names'.substr($_REQUEST['title'],$pos1,$pos2).$_REQUEST['mv_start_hr_new'].'/'.$_REQUEST['mv_end_hr_new']; $nameKey = 'mp_names:' . $_REQUEST['wgTitle'] . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new']; } else { $nameKey = 'mp_names:' . $_REQUEST['wgTitle'] . '/' . $_REQUEST['mv_start_hr_' . $mvd_id] . '/' . $_REQUEST['mv_end_hr_' . $mvd_id]; } $type = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], ':')); //set up the title /article $wgTitle = Title::newFromText($titleKey, MV_NS_MVD); $Article = new Article($wgTitle); if ($type != 'Anno_en') { $tit = Title::newFromText($nameKey, MV_NS_MVD); $art = new Article($tit); if (!$art->exists()) { $art->doEdit($_REQUEST['smw_Spoken_By'], 'MP names DO NOT EDIT', EDIT_NEW); //$art->doPurge(); } else { $art->doEdit($_REQUEST['smw_Spoken_By'], 'MP names DO NOT EDIT', EDIT_UPDATE); //$art->doPurge(); } } //xxxx //add all semantic form based attributes/relations to the posted body text foreach ($_POST as $key => $val) { $do_swm_include = true; if (substr($key, 0, 4) == 'smw_') { //try attribute $swmTitle = Title::newFromText(substr($key, 4), SMW_NS_PROPERTY); if ($swmTitle->exists()) { //make sure the person is not empty: if (trim($val) != '') { //@@todo update for other smw types: //$wgRequest->data['wpTextbox1'] = trim($_REQUEST['wpTextbox1']); if ($key == 'smw_Spoken_By') { //update the request wpTextBox: $wgRequest->data['wpTextbox1'] .= "[[" . $swmTitle->getText() . ':=' . $val . ']]'; } else { if ($key == 'smw_Edited_By') { $user = User::newFromId($val); $user->addWatch($wgTitle); $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] '; } else { if ($key == 'smw_Read_By') { $user = User::newFromId($val); $user->addWatch($wgTitle); $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] '; } else { if ($key == 'smw_Reported_By') { $user = User::newFromId($val); $user->addWatch($wgTitle); $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] '; } else { if ($key == 'smw_Status') { $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $val . ']] '; } } } } } } } } } /* global $reportersTable; if (isset($wgRequest->data['smw_Reported_By'])) { $name = $wgRequest->data['smw_Reported_By']; $sql = 'SELECT * FROM '.$reportersTable.' WHERE name="'.$name.'"'; $dbr =& wfGetDB(DB_SLAVE); $result = $dbr->query($sql); $row = $dbr->fetchObject($result); $number = $row->order_number; if ($row->next == 'next') { $dbw =& wfGetDB(DB_WRITE); $sql = 'UPDATE '.$reportersTable.' SET next="" WHERE name="'.$name.'"'; $result = $dbw->query($sql); $sql = 'SELECT * FROM '.$reportersTable.' WHERE order_number='."$number+1"; $result = $dbr->query($sql); $row = $dbr->numRows($result); if ($row > 0) { $sql = 'UPDATE '.$reportersTable.' SET next="next" WHERE order_number='."$number+1"; } else { $sql = 'UPDATE '.$reportersTable.' SET next="next" WHERE order_number=1'; } $result = $dbw->query($sql); } } */ $editPageAjax = new MV_EditPageAjax($Article); $editPageAjax->mvd_id = $mvd_id; //undesa global $mvgIP; $pages_start = array(); $pages_end = array(); $overlap = false; $start_hour = substr($_REQUEST['mv_start_hr_new'], 0, 1); $start_min = substr($_REQUEST['mv_start_hr_new'], 2, 2); $start_sec = substr($_REQUEST['mv_start_hr_new'], 5, 2); $start_time_in_sec = $start_hour * 3600 + $start_min * 60 + $start_sec; $end_hour = substr($_REQUEST['mv_end_hr_new'], 0, 1); $end_min = substr($_REQUEST['mv_end_hr_new'], 2, 2); $end_sec = substr($_REQUEST['mv_end_hr_new'], 5, 2); $end_time_in_sec = $end_hour * 3600 + $end_min * 60 + $end_sec; $streamTitle = new MV_Title($_REQUEST['title']); //$transcript_title = new MV_Title($titleKey); //$start = $transcript_title->getStartTimeSeconds(); //$end = $transcript_title->getEndTimeSeconds(); require_once $mvgIP . '/includes/MV_Index.php'; $dbr =& wfGetDB(DB_SLAVE); $result =& MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), 'Ht_en'); if ($dbr->numRows($result) == 0) { $pages_start = array(); $pages_end = array(); } else { while (($row = $dbr->fetchObject($result)) && $overlap == false) { $pages_start[$row->id] = $row->start_time; $pages_end[$row->id] = $row->end_time; if ($row->start_time <= $start_time_in_sec && $start_time_in_sec <= $row->end_time || $row->start_time <= $end_time_in_sec && $end_time_in_sec <= $row->end_time) { $overlap = true; } } } $val = $wgRequest->getVal('overlap'); if ($overlap == true && !isset($_POST['wpPreview']) && $val == 'no') { return "alert(\"The transcript you are trying to save" . $val . " overlaps with another\");" . $wgOut->getHTML(); } //undesa //if preview just return the parsed preview //@@todo refactor to use as much EditPage code as possible // use the "livePreview" functionality of Edit page. if (isset($_POST['wpPreview'])) { //$out = $editPageAjax->getPreviewText(); //$wgOut->addHTML($out); $mvTitle = new MV_Title($_REQUEST['title']); $parserOutput = $this->parse_format_text($wgRequest->data['wpTextbox1'], $mvTitle); $wgOut->addParserOutput($parserOutput); return $wgOut->getHTML() . '<div style="clear:both;"><hr></div>'; } if ($editPageAjax->edit($wgRequest->data['wpTextbox1']) == false) { if ($mvd_id == 'new') { //get context info to position timeline element: $rt = isset($_REQUEST['wgTitle']) ? $_REQUEST['wgTitle'] : null; $this->get_overlay_context_from_title($rt); //get updated mvd_id: $dbr =& wfGetDB(DB_SLAVE); $result =& MV_Index::getMVDbyTitle($titleKey, 'mv_page_id'); $mvd_id = $result->id; $result2 =& MV_Index::getMVDbyTitle($nameKey, 'mv_page_id'); //purge cache for parent stream MV_MVD::onEdit($this->mvd_pages, $mvd_id); //MV_MVD::onEdit($this->mvd_pages, $result2->id); //return Encapsulated (since its a new mvd) $returnEncapsulated = true; } else { //purge cache for parent stream MV_MVD::onEdit($this->mvd_pages, $mvd_id); } if ($returnEncapsulated) { if ($_REQUEST['saveandcreate'] == 'true') { $time_range = seconds2ntp($end_time_in_sec + 1) . '/' . seconds2ntp($end_time_in_sec + 600); $time_str = 'mv_disp_add_mvd("ht_en","' . $time_range . '")'; return php2jsObj(array('status' => 'ok', 'mvd_id' => $mvd_id, 'titleKey' => $titleKey, 'fd_mvd' => $this->get_fd_mvd_request($titleKey, $mvd_id, 'enclosed'), 'tl_mvd' => $this->get_tl_mvd_request($titleKey, $mvd_id), 'saveandcreate' => $time_str)); } else { return php2jsObj(array('status' => 'ok', 'mvd_id' => $mvd_id, 'titleKey' => $titleKey, 'fd_mvd' => $this->get_fd_mvd_request($titleKey, $mvd_id, 'enclosed'), 'tl_mvd' => $this->get_tl_mvd_request($titleKey, $mvd_id))); } } else { return $this->get_fd_mvd_request($titleKey, $mvd_id); } //return "page saved successfully?"; } else { //return "edit failed/ or preview? "; //$wgOut should have edit form with reported conflict, error or whatever return $wgOut->getHTML(); } }