function getItemOutput($row, $opt = array()) { global $wgUser; $sk = $wgUser->getSkin(); //set defaults: $person_ht = $bill_ht = $category_ht = $o = ''; if (!isset($row->start_time)) { $row->start_time = 0; } if (!isset($row->end_time)) { $row->end_time = 60 * 20; } $mvd_out_html = ''; $mvd_rows = MV_Index::getMVDInRange($row->stream_id, $row->start_time, $row->end_time, $mvd_type = 'anno_en', $getText = true, $smw_properties = array('Speech_by', 'Bill', 'category'), $options = array('limit' => 1)); if (count($mvd_rows) != 0) { reset($mvd_rows); $mvd_row = current($mvd_rows); if (isset($opt['use_mvd_time']) && $opt['use_mvd_time']) { $row->start_time = $mvd_row->start_time; $row->end_time = $mvd_row->end_time; } // print_r($mvd_rows); // print "type of: " . gettype($mvd_row); if (isset($mvd_row->Speech_by)) { if (trim($mvd_row->Speech_by) != '') { $ptitle = Title::MakeTitle(NS_MAIN, $mvd_row->Speech_by); $mvd_out_html .= '<span class="keywords">' . $sk->makeKnownLinkObj($ptitle, $ptitle->getText()) . '</span><br />'; } } if (isset($mvd_row->Bill)) { if (trim($mvd_row->Bill) != '') { $btitle = Title::MakeTitle(NS_MAIN, $mvd_row->Bill); $mvd_out_html .= '<span class="keywords">Bill: ' . $sk->makeKnownLinkObj($btitle) . ' </span><br />'; } } global $wgContLang; $mvdNStxt = $wgContLang->getNsText(MV_NS_MVD); //grab categories if no bill or speech if ($this->params['display_cat'] || $mvd_out_html == '') { $dbr = wfGetDB(DB_READ); $cl_res = $dbr->select('categorylinks', 'cl_to', array('cl_sortkey' => $mvdNStxt . ':' . str_replace('_', ' ', $mvd_row->wiki_title)), 'getTopClips::Categories', 'LIMIT 0, 5'); if ($dbr->numRows($cl_res) != 0) { $mvd_out_html .= '<span class="keywords">Categories: '; $coma = ''; while ($cl_row = $dbr->fetchObject($cl_res)) { $cTitle = Title::MakeTitle(NS_CATEGORY, $cl_row->cl_to); $mvd_out_html .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText()); $coma = ', '; } $mvd_out_html .= '</span><br />'; } } } else { //we have not meta //if( isset($opt['remove_no_meta']) && $opt['remove_no_meta']) //return false; } // first make link and stream title: $mvStream = MV_Stream::newStreamByID($row->stream_id); if (!$mvStream->doesStreamExist()) { return false; } //limit our output range to < 20 min if ($row->end_time - $row->start_time > 20 * 60) { $row->end_time = $row->start_time + 20 * 60; } $nt = $mvStream->getStreamName() . '/' . seconds2npt($row->start_time) . '/' . seconds2npt($row->end_time); $mvTitle = new MV_Title($nt, MV_NS_STREAM); $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range = '0')); // output the image: $o .= $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small') . '"/>', 'tl=1'); $title_span = ''; if (isset($mvStream->date_start_time)) { $parts = split('_', $mvStream->getStreamName()); if (count($parts) >= 3) { $title_span = ucfirst($parts[0] . ' '); } else { $title_span = $mvStream->getStreamName(); } $title_span .= date('F jS, Y', $mvStream->date_start_time); } else { $title_span = $mvTitle->getStreamNameText() . $mvTitle->getTimeDesc(); } $o .= '<span class="title">' . $sk->makeKnownLinkObj($mvStreamTitle, $title_span, 'tl=1') . '</span>'; //add mvd_annotative output: $o .= $mvd_out_html; return $o; }
function processUpload() { global $wgUser, $wgOut, $wgFileExtensions, $wgScriptPath; $details = null; $value = null; global $mvMediaFilesTable, $mvStreamFilesTable, $wgRequest; $stream_id = $wgRequest->getVal('stream_id'); $file_desc_msg = $wgRequest->getVal('file_desc_msg'); $newStream = MV_Stream::newStreamByID($stream_id); $files = $newStream->getFileList(); $doAdd = true; foreach ($files as $sf) { if ($sf->file_desc_msg == $file_desc_msg) { $doAdd = false; } } if (!$doAdd) { $value = 99; } else { $value = $this->internalProcessUpload($details); } switch ($value) { case self::SUCCESS: $html = 'File has been uploaded successfully<br/>'; $file = '' . $this->mLocalFile->getPath(); if (file_exists($file)) { $f = fopen($file, "rb"); $header = fread($f, 512); $page['serial'] = substr($header, 14, 4); $page['segments'] = ord($header[26]); $page['rate'] = ord($header[27 + $page['segments'] + 15]); $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 14]); $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 13]); $page['rate'] = $page['rate'] << 8 | ord($header[27 + $page['segments'] + 12]); fseek($f, -6000, SEEK_END); $end = fread($f, 6000); $tail = strstr($end, "OggS"); if ($tail) { $serial = substr($tail, 14, 4); if ($serial == $page['serial']) { $duration = 103; $granulepos = ord($tail[6]); $granulepos = $granulepos | ord($tail[7]) << 8; $granulepos = $granulepos | ord($tail[8]) << 16; $granulepos = $granulepos | ord($tail[9]) << 24; $granulepos = $granulepos | ord($tail[10]) << 32; $granulepos = $granulepos | ord($tail[11]) << 40; $granulepos = $granulepos | ord($tail[12]) << 48; $granulepos = $granulepos | ord($tail[13]) << 56; $duration = $granulepos / $page['rate']; } } fclose($f); } $dbr =& wfGetDB(DB_WRITE); $text = '' . $wgScriptPath . '/images/' . $this->mLocalFile->getUrlRel(); if ($duration === null) { $duration = 0; } if ($dbr->insert($mvMediaFilesTable, array('path' => $text, 'duration' => $duration, 'file_desc_msg' => $file_desc_msg), __METHOD__)) { $result = $dbr->query("SELECT LAST_INSERT_ID() AS id"); $row = $dbr->fetchObject($result); $id = $row->id; if ($dbr->insert($mvStreamFilesTable, array('file_id' => $id, 'stream_id' => $stream_id), __METHOD__)) { $stream_name = MV_Stream::getStreamNameFromId($stream_id); $title = Title::newFromText($stream_name, MV_NS_STREAM); $wgOut->redirect($title->getLocalURL("action=edit")); } else { $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately'; } } else { $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately'; } /* if ($dbr->insert($mvStreamFilesTable, array('stream_id'=>$stream_id))) { $result = $dbr->query("SELECT LAST_INSERT_ID()"); $row = $dbr->fetchObject($result); if ($duration===null)$duration=0; if ($dbr->insert($mvMediaFilesTable, array('id'=>$row->id,'path'=>$text,'duration'=>$duration))) { //$html .='<input type="button" name="Close" value="Close" Onclick="window.opener.document.getElementById(\'path\').value=\''.$wgScriptPath.'/images/'.$this->mLocalFile->getUrlRel().'\'; window.opener.document.getElementById(\'duration\').value='.floor($duration).'; window.close()"></input>' ; $stream_name = MV_Stream::getStreamNameFromId($stream_id); $title = Title::newFromText( $stream_name, MV_NS_STREAM ); $wgOut->redirect($title->getLocalURL("action=edit")); } else { $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately'; } } else { $html .= 'Inserting file path into DB failed, Please notify the Administrator immediately'; } */ $wgOut->addHTML($html); break; case self::BEFORE_PROCESSING: break; case self::LARGE_FILE_SERVER: $this->mainUploadForm(wfMsgHtml('largefileserver')); break; case self::EMPTY_FILE: $this->mainUploadForm(wfMsgHtml('emptyfile')); break; case self::MIN_LENGHT_PARTNAME: $this->mainUploadForm(wfMsgHtml('minlength1')); break; case self::ILLEGAL_FILENAME: $filtered = $details['filtered']; $this->uploadError(wfMsgWikiHtml('illegalfilename', htmlspecialchars($filtered))); break; case self::PROTECTED_PAGE: $this->uploadError(wfMsgWikiHtml('protectedpage')); break; case self::OVERWRITE_EXISTING_FILE: $errorText = $details['overwrite']; $overwrite = new WikiError($wgOut->parse($errorText)); $this->uploadError($overwrite->toString()); break; case self::FILETYPE_MISSING: $this->uploadError(wfMsgExt('filetype-missing', array('parseinline'))); break; case self::FILETYPE_BADTYPE: $finalExt = $details['finalExt']; $this->uploadError(wfMsgExt('filetype-banned-type', array('parseinline'), htmlspecialchars($finalExt), implode(wfMsgExt('comma-separator', array('escapenoentities')), $wgFileExtensions))); break; case self::VERIFICATION_ERROR: $veri = $details['veri']; $this->uploadError($veri->toString()); break; case self::UPLOAD_VERIFICATION_ERROR: $error = $details['error']; $this->uploadError($error); break; case self::UPLOAD_WARNING: $warning = $details['warning']; $this->uploadWarning($warning); break; case self::INTERNAL_ERROR: $internal = $details['internal']; $this->showError($internal); break; case 99: $this->mainUploadForm('Type ' . $file_desc_msg . ' already exists'); break; default: throw new MWException(__METHOD__ . ": Unknown value `{$value}`"); } }