function formatResult($skin, $result)
 {
     global $wgUser, $wgLang, $mvImageArchive;
     $sit = new MV_Sitting(array('id' => $this->sitting_id));
     $sit->db_load_sitting();
     #make sure the first letter is upper case (makeTitle() should do that)
     $result->title = strtoupper($result->title[0]) . substr($result->title, 1);
     $img_url = $mvImageArchive . $result->title . '?size=icon&time=0:00:00';
     $img_url = MV_StreamImage::getStreamImageURL($result->stream_id, '0:00:00', 'icon', true);
     $img_html = '<img src="' . $img_url . '" width="80" height="60">';
     $title = Title::makeTitle(MV_NS_STREAM, $result->title);
     $rlink = $skin->makeLinkObj($title, $img_html . ' ' . $title->getText());
     //if admin expose an edit link
     if ($this->existing == 'false') {
         $rlink .= ' ' . $skin->makeKnownLinkObj(Title::makeTitle(MV_NS_STREAM, $title->getText()), 'edit', 'action=edit');
     } else {
         $rlink .= ' ' . $skin->makeKnownLinkObj(Title::makeTitle(MV_NS_SITTING, $sit->name), 'add', 'action=edit&mv_action=add&stream_id=' . $result->stream_id);
     }
     return $rlink;
 }
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $mvStream_name, $mvgIP;
     #init html output var:
     $html = '';
     # Get request data from, e.g.
     $title_str = $wgRequest->getVal('title');
     //get Mv_Title to normalize the stream name:
     $this->stream_name = $wgRequest->getVal('stream_name') == '' ? '' : MV_Title::normalizeTitle($wgRequest->getVal('stream_name'));
     $this->stream_type = $wgRequest->getVal('stream_type');
     $this->wpEditToken = $wgRequest->getVal('wpEditToken');
     $this->stream_desc = $wgRequest->getVal('stream_desc');
     $this->sitting_id = $wgRequest->getVal('sitting_id');
     $sit = new MV_Sitting(array('id' => $this->sitting_id));
     $sit->db_load_sitting();
     //grab the desc from the wiki page if not in the POST req
     if ($this->stream_desc == '') {
         $desTitle = Title::makeTitle(MV_NS_STREAM, $this->stream_name);
         //grab the article text:
         $curRevision = Revision::newFromTitle($desTitle);
         if ($curRevision) {
             $this->stream_desc = $curRevision->getText();
         }
     }
     if ($this->stream_name == '') {
         //default page request
         $parts = split('/', $title_str);
         if (count($parts) >= 2) {
             //means we can use part 1 as a stream name:
             $this->stream_name = $parts[1];
         }
     } else {
         if ($this->mode == 'add') {
             //output add_ status to html
             //$html.=
             if ($this->add_stream()) {
                 $streamTitle = Title::newFromText($this->stream_name, MV_NS_STREAM);
                 $wgOut->redirect($streamTitle->getLocalURL("action=edit"));
                 return;
             } else {
                 $html = "Error adding stream. Please Nofity Administrator";
                 $wgOut->addHTML($html);
                 return;
             }
         } else {
             //possible edit
         }
     }
     //if edit check for stream name:
     if ($this->mode == 'edit' && $this->stream_name == '') {
         $html .= wfMsg('edit_stream_missing');
         $wgOut->addHTML($html);
         return;
     }
     $this->check_permissions();
     if (count($this->_allowedStreamTypeArray) == 0) {
         //break out user lacks permissions to add anything
         $html .= wfMsg('add_stream_permission');
         $wgOut->addHTML($html);
         return;
     }
     //output the stream form
     //output the add stream form
     $spectitle = Title::makeTitle(NS_SPECIAL, 'Mv_Add_stream');
     $docutitle = Title::newFromText(wfMsg('mv_add_stream'), NS_HELP);
     if ($this->mode == 'edit') {
         $mvStreamTitle = Title::makeTitle(MV_NS_STREAM, $this->stream_name);
         if ($mvStreamTitle->exists()) {
             $sk = $wgUser->getSkin();
             $streamLink = $sk->makeLinkObj($mvStreamTitle, $this->stream_name);
             $html .= wfMsg('mv_edit_strea_docu', $streamLink);
         }
     } else {
         //$html.= wfMsg('mv_add_stream_docu', $docutitle->getFullURL()) ."\n";
         $title2 = Title::makeTitle(MV_NS_SITTING, $sit->name);
         $skin2 = new Linker();
         $sittingLink = $skin2->makeKnownLinkObj($title2, $sit->name);
         $html .= 'Add a stream to Sitting ' . $sittingLink;
     }
     $html .= '<form name="add_stream" action="' . $spectitle->escapeLocalURL() . '" method="post" enctype="multipart/form-data">';
     $html .= '<fieldset><legend>' . wfMsg('mv_add_stream') . '</legend>' . "\n" . '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>' . '<input type="hidden" name="sitting_id" value="' . $wgRequest->getVal('sitting_id') . '"/>';
     $html .= '<table width="600" border="0">';
     $html .= '<tr><td width="140">Sitting Id</td><td>' . $wgRequest->getVal('sitting_id') . '</tr><tr>';
     $html .= '<td>';
     //output the stream type pulldown
     $html .= '<i>' . wfMsg('mv_label_stream_name') . "</i>:";
     $html .= '</td><td>';
     $html .= '<input type="text" name="stream_name" value="' . htmlspecialchars(MV_Title::getStreamNameText($this->stream_name)) . '" size="30" maxlength="1024"><br />' . "\n";
     $html .= '</td>';
     $html .= '<td><tr><td><i>' . wfMsg('mv_label_stream_type') . '</i></td><td>';
     $html .= '<select name="stream_type">' . '<option value="">Select Stream Type</option>' . "\n";
     foreach ($this->_allowedStreamTypeArray as $type => $na) {
         $sel = $type == $this->stream_type ? 'selected' : '';
         $html .= '<option value="' . $type . '" ' . $sel . '>' . wfMsg('mv_' . $type) . '</option>' . "\n";
     }
     $html .= '</select></tr>' . "\n";
     $html .= '<tr><td valign="top"><i>' . wfMsg('mv_label_stream_desc') . '</i>:</td><td>';
     //add an edit token (for the stream description)
     if ($wgUser->isLoggedIn()) {
         $token = htmlspecialchars($wgUser->editToken());
     } else {
         $token = EDIT_TOKEN_SUFFIX;
     }
     $html .= "\n<input type='hidden' value=\"{$token}\"{$docutitle} name=\"wpEditToken\" />\n";
     //output the text area:
     $html .= '<textarea tabindex="1" accesskey="," name="stream_desc" id="stream_desc" rows=6 cols=5>' . $this->stream_desc . '</textarea>' . "\n";
     $html .= '<br /><input type="submit" value="' . wfMsg('mv_add_stream_submit') . "\"/>\n</form>";
     $html .= '</td></tr></table>';
     $html .= '</fieldset>';
     # Output menu items
     # @@todo link with language file
     $wgOut->addHTML($html);
     //output the stream files list (if in edit mode)
     if ($this->mode == 'edit') {
         $this->list_stream_files();
     }
 }
function mvDoMetavidSittingpage($title, $article)
{
	global $wgRequest;
	$name = $title->getDBKey();
	$sit = new MV_Sitting(array('name'=>$name));
	$sit->db_load_sitting();
	if ($wgRequest->getVal('action') != 'edit')
	{
		list( $limit, $offset ) = wfCheckLimits();
		$spec = new MV_SpecialListStreams($sit->id,'false');
		$spec->doQuery( $offset, $limit );
		return true;
	}
}