Example #1
0
 /**
  * Process the form on POST submission.  If you return false from getFormFields(),
  * this will obviously never be reached.  If you don't want to do anything with the
  * form, just return false here
  * @param  $data Array
  * @return Bool|Array true for success, false for didn't-try, array of errors on failure
  */
 public function onSubmit($data)
 {
     // Record upload and update metadata cache
     $this->video = Video::newFromName($this->oldvideo->ov_name, $this->getContext());
     $this->video->addVideo($this->oldvideo->ov_url, $this->oldvideo->ov_type, '');
     return true;
 }
function VideoGalleryPopulate($input, $args, $parser)
{
    $parser->disableCache();
    $category = isset($args['category']) ? $args['category'] : '';
    $limit = isset($args['limit']) ? intval($args['limit']) : 10;
    if (empty($category)) {
        return '';
    }
    // Use Parser::recursivePreprocess() if available instead of creating another Parser instance
    if (is_callable(array($parser, 'recursivePreprocess'))) {
        $category = $parser->recursivePreprocess($category);
    } else {
        $newParser = new Parser();
        $category = $newParser->preprocess($category, $parser->getTitle(), $parser->getOptions());
    }
    $category_title = Title::newFromText($category);
    if (!$category_title instanceof Title) {
        return '';
    }
    // @todo FIXME: not overly i18n-friendly here...
    $category_title_secondary = Title::newFromText($category . ' Videos');
    if (!$category_title_secondary instanceof Title) {
        return '';
    }
    $params['ORDER BY'] = 'page_id';
    if ($limit) {
        $params['LIMIT'] = $limit;
    }
    $dbr = wfGetDB(DB_SLAVE);
    $res = $dbr->select(array('page', 'categorylinks'), 'page_title', array('cl_to' => array($category_title->getDBkey(), $category_title_secondary->getDBkey()), 'page_namespace' => NS_VIDEO), __METHOD__, $params, array('categorylinks' => array('INNER JOIN', 'cl_from = page_id')));
    $gallery = new VideoGallery();
    $gallery->setParsing(true);
    $gallery->setShowFilename(true);
    foreach ($res as $row) {
        $video = Video::newFromName($row->page_title, RequestContext::getMain());
        $gallery->add($video);
    }
    return $gallery->toHtml();
}
	/**
	 * Custom validator for the Title field
	 *
	 * Just checks that it's a valid title name and that it doesn't already
	 * exist (unless it's an overwrite)
	 *
	 * @param $value Array
	 * @param $allData Array
	 * @return bool|String
	 */
	public function validateTitleField( $value, $allData ) {
		$video = Video::newFromName( $value, $this->getContext() );

		if ( $video === null || !( $video instanceof Video ) ) {
			return wfMsg( 'badtitle' );
		}

		// TODO: Check to see if this is a new version
		if ( $video->exists() && !$this->getRequest()->getCheck( 'forReUpload' ) ) {
			return wfMsgHtml( 'video-addvideo-exists' );
		}

		$this->video = $video;

		return true;
	}
Example #4
0
 /**
  * Callback function for VideoHooks::registerVideoHook.
  *
  * @param $input [unused]
  * @param $argv Array: array or user-supplied arguments; name must be present.
  *                     Optional args include width, height and align.
  * @param $parser Object: instance of parser
  * @return String
  */
 public static function videoEmbed($input, $argv, $parser)
 {
     $video_name = $argv['name'];
     if (!$video_name) {
         return '';
     }
     $width = $width_max = 425;
     $height = $height_max = 350;
     $validAlign = array('LEFT', 'CENTER', 'RIGHT');
     if (!empty($argv['width']) && $width_max >= $argv['width']) {
         $width = $argv['width'];
     }
     if (!empty($argv['height']) && $height_max >= $argv['height']) {
         $height = $argv['height'];
     }
     $align = isset($argv['align']) ? $argv['align'] : 'left';
     $alignTag = '';
     if (in_array(strtoupper($align), $validAlign)) {
         $alignTag = " class=\"float{$align}\" ";
     }
     $output = '';
     $video = Video::newFromName($video_name, RequestContext::getMain());
     if ($video->exists()) {
         $video->setWidth($width);
         $video->setHeight($height);
         $output .= "<div{$alignTag}>";
         $output .= $video->getEmbedCode();
         $output .= '</div>';
     }
     return $output;
 }