예제 #1
0
 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 do_update_wiki_page($wgTitle, $wikiText, $ns = null, $forceUpdate = false)
{
    global $botUserName;
    if (!is_object($wgTitle)) {
        //get the title and make sure the first letter is uper case
        $wgTitle = Title::makeTitle($ns, ucfirst($wgTitle));
    }
    if (trim($wgTitle->getDBKey()) == '') {
        print "empty title (no insert /update) \n";
        return;
    }
    //print "INSERT BODY: ".$wikiText;
    //make sure the text is utf8 encoded:
    $wikiText = utf8_encode($wikiText);
    $wgArticle = new Article($wgTitle);
    if (!mvDoMvPage($wgTitle, $wgArticle, false)) {
        print "bad title: " . $wgTitle->getNsText() . ':' . $wgTitle->getDBkey() . " no edit";
        if ($wgTitle->exists()) {
            print "remove article";
            $wgArticle->doDeleteArticle('bad title');
        }
        //some how mvdIndex and mvd pages got out of sync do a seperate check for the mvd:
        if (MV_Index::getMVDbyTitle($wgArticle->mTitle->getDBkey()) != null) {
            print ', rm mvd';
            MV_Index::remove_by_wiki_title($wgArticle->mTitle->getDBkey());
        }
        print "\n";
        return;
    }
    if ($wgTitle->getNamespace() == MV_NS_MVD && MV_Index::getMVDbyTitle($wgTitle->getDBkey()) == null) {
        //print "missing assoc mvd ...update \n";
    } else {
        if ($wgTitle->exists()) {
            //if last edit!=mvBot skip (don't overwite peoples improvments')
            $rev =& Revision::newFromTitle($wgTitle);
            if ($botUserName != $rev->getRawUserText() && !$forceUpdate) {
                print ' skiped page ' . $wgTitle->getNsText() . ':' . $wgTitle->getText() . ' edited by user:'******'#REDIRECT')) == '#REDIRECT' && !$forceUpdate) {
                print ' skiped page moved by user:'******':' . $wgTitle->getText() . " is identical (no update)\n";
                //if force update double check the mvd for consistancy?
                return;
            }
        }
    }
    //got here do the edit:
    $sum_txt = 'metavid bot insert';
    $wgArticle->doEdit($wikiText, $sum_txt);
    print "did edit on " . $wgTitle->getNsText() . ':' . $wgTitle->getDBkey() . "\n";
    //die;
}
예제 #3
0
 function do_edit_submit($titleKey, $mvd_id, $returnEncapsulated = false, $newTitleKey = '')
 {
     global $wgOut, $wgScriptPath, $wgUser, $wgTitle, $wgRequest, $wgContLang;
     if ($mvd_id == 'new') {
         $titleKey = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], '/')) . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new'];
     }
     // if doing basic editing use basic wpTextBox:
     if ($wgRequest->getVal('adv_basic') == 'basic') {
         $wpTextbox1 = $wgRequest->getVal('basic_wpTextbox');
     } else {
         $wpTextbox1 = $wgRequest->getVal('wpTextbox1');
     }
     // set up the title /article
     $wgTitle = Title::newFromText($titleKey, MV_NS_MVD);
     $Article = new Article($wgTitle);
     $wpTextbox1 = trim($wpTextbox1);
     // add all semantic form based attributes/relations to the posted body text
     $formSemanticText = '';
     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 semantic is not empty:
                 if (trim($val) != '') {
                     // @@todo update for other smw types:
                     if ($swmTitle->getDBkey() == 'Spoken_By') {
                         $wpTextbox1 = "[[" . $swmTitle->getText() . '::' . $val . ']] ' . $wpTextbox1;
                     } else {
                         $wpTextbox1 .= "\n\n[[" . $swmTitle->getText() . '::' . $val . ']]';
                     }
                 }
             }
         }
     }
     // add all categorizations:
     $catNStxt = $wgContLang->getNsText(NS_CATEGORY);
     foreach ($_POST as $k => $v) {
         if (strpos($k, 'ext_cat_') !== false) {
             $wpTextbox1 .= "\n[[" . $catNStxt . ":" . $v . "]]";
         }
     }
     // add the text to the end after a line break to not confuse manual editors
     $editPageAjax = new MV_EditPageAjax($Article);
     $editPageAjax->mvd_id = $mvd_id;
     // if preview just return the parsed preview
     // @@todo refactor to use as much EditPage code as possible or (switch over to the API)
     // use the "livePreview" functionality of Edit page.
     if (isset($_POST['wpPreview'])) {
         // $out = $editPageAjax->getPreviewText();
         // $wgOut->addHTML($out);
         $mvTitle = new MV_Title($wgRequest->getVal('title'));
         $parserOutput = $this->parse_format_text($wpTextbox1, $mvTitle);
         $wgOut->addParserOutput($parserOutput);
         return $wgOut->getHTML() . '<div style="clear:both;"><hr></div>';
     }
     if ($editPageAjax->edit($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;
             // update title key
             // purge cache for parent stream and MVD
             MV_MVD::onEdit($this->mvd_pages, $mvd_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) {
             //print "get Encapsulated:\n";
             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();
     }
 }
예제 #4
0
 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();
     }
 }