本文整理汇总了PHP中Movie::imageFromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Movie::imageFromFile方法的具体用法?PHP Movie::imageFromFile怎么用?PHP Movie::imageFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Movie
的用法示例。
在下文中一共展示了Movie::imageFromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: crawl
public function crawl()
{
$dir = $this->getOption('dir');
$minSize = $this->getOption('minSize');
$cachedir = $this->getOption('cachedir');
$photodir = $this->getOption('photodir');
$cacheage = $this->getOption('cacheage');
if (!is_dir($dir)) {
throw new Crawler_Exception('Directory not found: ' . $dir);
return false;
}
$files = $this->exe(sprintf('find %s -size +%s', $dir, $minSize));
$movies = array();
$cnt = 0;
foreach ($files as $file) {
if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'vob') {
$file = dirname($file);
//trigger_error('Think this is a DVD. Using: '. $file, E_USER_NOTICE);
if (basename($file) == 'VIDEO_TS') {
$file = dirname($file);
//trigger_error('Think this is a DVD. Using: '. $file, E_USER_NOTICE);
}
}
$cnt++;
$relativeFile = substr($file, strlen($dir) + 1);
$slug = Movie::fileslug($file);
$cacheFile = $cachedir . '/' . $slug . '.json';
#$imgFile = $photodir.'/'.$slug.'.jpg';
$imgFile = Movie::imageFromFile($file, $photodir);
if (file_exists($cacheFile) && filemtime($cacheFile) > time() - $cacheage) {
// Load cache
$movies[$relativeFile] = json_decode(file_get_contents($cacheFile), true);
} else {
$Movie = new Movie($file);
$details = $Movie->getDetails();
if (false === $details) {
echo 'No movie info found for: ' . $Movie->cleanedName . ', ' . $file . "\n";
} else {
// Use this
$movies[$relativeFile] = $details;
// Save photo
if (!file_exists($imgFile) && !empty($details['photo'])) {
if (false === $this->wget($details['photo'], $imgFile)) {
trigger_error('wget error', E_USER_ERROR);
return false;
}
}
// Save cache
file_put_contents($cacheFile, json_encode($details));
}
}
// if ($cnt > 5) {
// break;
// }
}
return $movies;
}
示例2: generate
public function generate()
{
switch ($this->_type) {
case 'html':
$Html = new KvzHTML();
$photovirt = $this->getOption('photovirt');
$head = $Html->title('Movies') . $Html->css('moviexplore.css') . $Html->js('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js') . $Html->js('moviexplore.js');
$body = '';
$index = '';
$prevdirname = '';
$dircontent = '';
ksort($this->_movies);
foreach ($this->_movies as $file => $movie) {
if (empty($movie)) {
echo 'Skipping ' . $file . '. Invalid movie information' . "\n";
continue;
}
if ($separate_on_dir = $this->getOption('separate_on_dir')) {
$parts = explode(DIRECTORY_SEPARATOR, $file);
$dirname = $parts[$separate_on_dir - 1];
}
$imgFile = Movie::imageFromFile($file, $photovirt);
if (!file_exists(realpath($this->getOption('outputdir') . '/' . $imgFile))) {
$imgFile = 'title_noposter.gif';
}
if (!is_array($movie['cast'])) {
$movie['cast'] = array();
}
if (!is_array($movie['genres'])) {
$movie['genres'] = array();
}
// 4 --- 9
// 7
// 1 --- 6 -3
//
$rateColor = statusColor(6 - ($movie['rating'] - 3.5) . '/6');
$movie['cast'] = array_slice($movie['cast'], 0, 3);
$castar = array();
foreach ($movie['cast'] as $actor) {
$castar[] = $Html->span($actor['name'], array('class' => 'actor'));
}
foreach ($movie['director'] as $director) {
$castar[] = $Html->span($director['name'], array('class' => 'director'));
}
foreach ($movie['writing'] as $writter) {
$castar[] = $Html->span($writter['name'], array('class' => 'writer'));
}
$cast = implode(', ', $castar);
if ($separate_on_dir) {
if ($prevdirname != $dirname) {
$index .= $Html->div(ucwords($dirname), array('class' => 'directory'));
$index .= $Html->hr(null);
}
}
$movie['tagline'] = strip_tags($movie['tagline']);
$movie['plotoutline'] = strip_tags($movie['plotoutline']);
$index .= $Html->div($Html->div($Html->a($movie['main_url'], $Html->img($imgFile, array('class' => 'poster'))) . $Html->p($movie['rating'], array('class' => 'rating', 'style' => '"color:' . $rateColor . ';"')) . $Html->p($movie['runtime'] ? $movie['runtime'] . 'm' : '', 'runtime'), array('class' => 'left')) . $Html->div($Html->h1($movie['title'], array('class' => 'title')) . $Html->h2($movie['tagline'], array('class' => 'tagline')) . $Html->p($movie['plotoutline'], array('class' => 'plotoutline')) . $Html->p(implode(', ', $movie['genres']), array('class' => 'genres')) . $Html->p($cast, array('class' => 'cast')), array('class' => 'right')) . $Html->div('', array('class' => 'end')), array('class' => 'movie'));
if ($separate_on_dir) {
$prevdirname = $dirname;
}
}
$body .= $Html->div($index, array('class' => 'index'));
$this->_output = $Html->html($Html->head($head) . $Html->body($body));
break;
}
}