function return_obj()
 {
     return php2jsObj(array('status' => $this->status, 'innerHTML' => $this->innerHTML, 'js_eval' => $this->js_eval));
 }
 function do_remove_mvd($titleKey, $mvd_id)
 {
     global $wgOut;
     $title = Title::newFromText($titleKey, MV_NS_MVD);
     $article = new Article($title);
     // purge parent article:
     MV_MVD::onEdit($this->mvd_pages, $mvd_id);
     // run the delete function:
     $article->doDelete($_REQUEST['wpReason']);
     // check if delete
     if ($article->exists()) {
         return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
     } else {
         return php2jsObj(array('status' => 'ok'));
     }
 }
/**
 * Utility functions:
 */
function mvOutputJSON(&$data)
{
    $fname = 'Mv_output_json_data';
    wfProfileIn($fname);
    global $wgRequest;
    // get callback index and wrap function:
    $callback_index = $wgRequest->getVal('cb_inx');
    $wrap_function = $wgRequest->getVal('cb');
    header('Content-Type: text/javascript');
    if ($callback_index != '' && $wrap_function != '') {
        $output = htmlspecialchars($wrap_function) . '(' . PhpArrayToJsObject_Recurse(array('cb_inx' => htmlspecialchars($callback_index), 'content-type' => 'text/xml', 'pay_load' => $data)) . ');';
    } else {
        //just produce a results var:
        $output = php2jsObj(array('pay_load' => $data));
    }
    wfProfileOut($fname);
    //if all is well return true:
    return $output;
}
/**
 * mv_edit_submit
 * @@todo this could be cleaned up by using the api .. lots of weridness otherwise
 */
function mv_edit_submit()
{
    global $wgOut, $wgRequest;
    // @@todo more input scrubbing value checks
    $title_str = $wgRequest->getVal('title');
    $mvd_id = $wgRequest->getVal('mvd_id');
    if ($title_str == '' || $mvd_id == '') {
        return 'error missing title or id';
    }
    $MV_Overlay = new MV_Overlay();
    $do_adjust = $wgRequest->getVal('do_adjust');
    if ($do_adjust == 'true') {
        //first move then edit
        $adjust_ary = $MV_Overlay->do_adjust_submit($wgRequest->getVal('titleKey'), $mvd_id, $wgRequest->getVal('newTitle'), $wgRequest->getVal('wgTitle'));
        //do edit:
        $outputMVD = $MV_Overlay->do_edit_submit($wgRequest->getVal('newTitle'), $mvd_id, false);
        $wgOut->clearHTML();
        $adjust_ary['fd_mvd'] = $MV_Overlay->get_fd_mvd_request($title_str, $mvd_id, 'enclosed', $outputMVD);
        return php2jsObj($adjust_ary);
    } else {
        return $MV_Overlay->do_edit_submit($title_str, $mvd_id);
    }
}
 function getJsonDateObj($obj_name = 'mv_result')
 {
     $dbr =& wfGetDB(DB_SLAVE);
     $sql = 'SELECT `date_start_time` FROM `mv_streams` ' . 'WHERE `date_start_time` IS NOT NULL ' . 'ORDER BY `date_start_time` ASC  LIMIT 0, 2000';
     $res = $dbr->query($sql, 'MV_SpecialMediaSearch:getJsonDateObj');
     $start_day = time();
     $end_day = 0;
     $delta = 0;
     $sDays = array();
     while ($row = $dbr->fetchObject($res)) {
         if ($row->date_start_time == 0) {
             continue;
         }
         // skip empty / zero values
         if ($row->date_start_time < $start_day) {
             $start_day = $row->date_start_time;
         }
         if ($row->date_start_time > $end_day) {
             $end_day = $row->date_start_time;
         }
         list($month, $day, $year) = explode('/', date('m/d/Y', $row->date_start_time));
         $month = trim($month, '0');
         $day = trim($day, '0');
         if (!isset($sDays[$year])) {
             $sDays[$year] = array();
         }
         if (!isset($sDays[$year][$month])) {
             $sDays[$year][$month] = array();
         }
         if (!isset($sDays[$year][$month][$day])) {
             $sDays[$year][$month][$day] = 1;
         } else {
             $sDays[$year][$month][$day]++;
         }
     }
     return php2jsObj(array('sd' => date('m/d/Y', $start_day), 'ed' => date('m/d/Y', $end_day), 'sdays' => $sDays), $obj_name);
 }
 function do_edit_submit()
 {
     global $mvgIP, $wgOut, $wgUser, $wgParser;
     $titleKey = $_POST['title'];
     // set up the title /article
     $title = Title::newFromText($titleKey, MV_NS_SEQUENCE);
     $article = new MV_SequencePage($title);
     // print "inline_seq:" .  $_POST['inline_seq'] . " wpbox: " . $_REQUEST['wpTextbox1'] . "\n";
     $editPageAjax = new MV_EditPageAjax($article);
     $editPageAjax->mvd_id = 'seq';
     $textbox1 = '<' . SEQUENCE_TAG . '>' . $_POST['inline_seq'] . '</' . SEQUENCE_TAG . '>' . "\n" . $_REQUEST['wpTextbox1'];
     // if($wgTitle->exists()){
     // print "article existing content: " . $Article->getContent();
     // }
     if (isset($_POST['wpPreview'])) {
         $sk =& $wgUser->getSkin();
         // $wgOut->addWikiText($_REQUEST['wpTextbox1']);
         // run via parser so we get categories:
         $parserOptions = ParserOptions::newFromUser($wgUser);
         $parserOptions->setEditSection(false);
         $parserOptions->setTidy(true);
         // just parse the non-seq portion:
         $parserOutput = $wgParser->parse($_REQUEST['wpTextbox1'], $title, $parserOptions);
         $wgOut->addCategoryLinks($parserOutput->getCategories());
         $wgOut->addHTML($parserOutput->mText);
         $wgOut->addHTML($sk->getCategories());
         // empty out the categories
         $wgOut->mCategoryLinks = array();
         // add horizontal rule:
         $wgOut->addHTML('<hr></hr>');
         // $wgOut->addWikiTextWithTitle( $curRevision->getText(), $wgTitle) ;
         return $wgOut->getHTML();
     }
     if ($editPageAjax->edit($textbox1) == false) {
         return php2jsObj(array('status' => 'ok'));
     } else {
         // error: retrun error msg and form:
         return $wgOut->getHTML();
     }
 }