本文整理汇总了PHP中Video::newFromName方法的典型用法代码示例。如果您正苦于以下问题:PHP Video::newFromName方法的具体用法?PHP Video::newFromName怎么用?PHP Video::newFromName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::newFromName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSubmit
/**
* 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;
}
示例2: VideoGalleryPopulate
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();
}
示例3: validateTitleField
/**
* 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;
}
示例4: videoEmbed
/**
* 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;
}