本文整理汇总了PHP中Video::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Video::exists方法的具体用法?PHP Video::exists怎么用?PHP Video::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVideo
public function getVideo()
{
return Video::exists($this->video_id) ? Video::find($this->video_id) : false;
}
示例2: generateId
public static function generateId($length)
{
$idExists = true;
while ($idExists) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$id = '';
for ($i = 0; $i < $length; $i++) {
$id .= $chars[rand(0, strlen($chars) - 1)];
}
$idExists = Video::exists(array('id' => $id));
}
return $id;
}
示例3: status
/**
*
* Return a Json Response. The most important index for js are data.sd.status and data.hd.status :
* values can be :
* 'ok' => everything is okay,
* 'doing' => a file is being converted,
* 'no' => There is no file availlable in this resolution
*/
public function status($id, $request)
{
if (Video::exists($id)) {
$video = Video::find($id);
$data = [];
$sizes = ['sd' => '640x360p', 'hd' => '1280x720p'];
//Arrays of sizes and formats
$formats = ['mp4', 'webm'];
foreach ($sizes as $k => $size) {
//For each size
foreach ($formats as $format) {
//And each format
$file_name = $video->url . '_' . $size . '.' . $format;
//File name = <url of the video>_<size>.<format>
if (Utils::stringStartsWith($file_name, 'http')) {
//If stocked on an external server : absoulute path.
$data[$k][$format] = Utils::getHTTPStatusCodeFromURL($file_name);
} else {
$data[$k][$format] = Utils::getHTTPStatusCodeFromURL('http://' . $_SERVER['HTTP_HOST'] . '/' . $file_name);
//Ressource is directly on the same server with relative path
}
}
}
foreach ($data as $k => $v) {
if ($v['mp4'] < 400 && $v['webm'] < 400) {
$data[$k]['status'] = 'ok';
} elseif ($v['mp4'] < 400 xor $v['webm'] < 400) {
$data[$k]['status'] = 'doing';
} else {
$data[$k]['status'] = 'no';
}
}
return new JsonResponse($data);
//Return as JSON
} else {
return new JsonResponse([null]);
}
}
示例4: foreach
if (!$user->exists()) {
Redirect::to('../index.php');
} else {
if (!$user->isLoggedIn() || !$user->hasPermission('admin')) {
Redirect::to('../index.php');
} else {
foreach ($_GET as $key => $value) {
if ($value == "") {
Redirect::to('../index.php');
}
}
if (Input::exists('get')) {
$video_entry = new Video();
$video_entry_id = $video_entry->safe_string(Input::get('id'));
$video_entry->find($video_entry_id);
if (!$video_entry->exists()) {
Redirect::to('../index.php');
} else {
$video_entry_title = $video_entry->data()->video_title;
try {
$video_entry->delete(['id', '=', Input::get('id')]);
Session::flash('delete', 'Video for entry "' . $video_entry_title . '" has been deleted from the database.');
Redirect::to('../index.php');
} catch (Exception $e) {
die($e->getMessage());
}
}
} else {
Redirect::to('../index.php');
}
}
示例5: video
public function video($id, $request)
{
$video = Video::exists($id) ? Video::find($id) : false;
if (!$request->acceptsJson()) {
return new RedirectResponse(WEBROOT . 'watch/' . $id);
}
if (is_object($video)) {
$comments = $video->getComments();
$commentsData = array();
foreach ($comments as $comment) {
$commentsData[] = array('id' => $comment->id, 'author' => UserChannel::find($comment->poster_id)->name, 'video_id' => $comment->video_id, 'comment' => $comment->comment, 'relativeTime' => Utils::relative_time($comment->timestamp), 'timestamp' => $comment->timestamp, 'likes' => $comment->likes, 'dislikes' => $comment->dislikes);
}
return new JsonResponse($commentsData);
}
return new Response(500);
}
示例6:
?>
">
<div class="thumbnail bg-loader" data-background-load-in-view data-background="http://lorempicsum.com/up/350/200/6"></div>
<p><?php
echo $phrase;
?>
</p>
</a>
<i><?php
echo Utils::relative_time($action->timestamp);
?>
</i>
</div>
<?php
} else {
if ($action->type == 'comment' && Video::exists($action->target)) {
$comment = Comment::getByChannelAction($action);
$video = Utils::secureActiveRecordModel(Video::find($action->target));
?>
<div class="card<?php
echo $supp_class;
?>
comment">
<a href="<?php
echo WEBROOT . 'watch/' . $action->target;
?>
">
<p><b><?php
echo Utils::secure($channel_action->name);
?>
</b> a commenté votre vidéo "<b><?php