public static function getFullFormatName($format) { if (self::$_allFormats === null) { self::$_allFormats = self::getAllFormats(); } return isset(self::$_allFormats[$format]) ? self::$_allFormats[$format] : $format; }
function upload() { global $root; if ($_FILES['sub']['size'] == 0 && $_FILES['sub']['error'] > 0) { return 'Error al subir el subtítulo.'; } $file = $_FILES['sub']['name']; $frame = Request::getPost('frame'); $comment = Request::getPost('comment'); $credits = Request::getPost('credits'); if (empty($frame)) { return 'Falta el frame.'; } $format = substr($file, -3); $formatName = Formats::get($format); if (empty($formatName)) { return 'El archivo no es de un formato válido.'; } $filename = substr($file, 0, strlen($file) - 4); $id = Db::insert('subs', array('filename' => $filename, 'ext' => $format, 'frame' => $frame, 'comment' => $comment, 'credits' => $credits, 'time' => time())); $fullpath = "{$root}/upload/{$id}"; # $fullpath = "/var/www/subs/$id"; if (!@move_uploaded_file($_FILES['sub']['tmp_name'], $fullpath)) { if ($id) { Db::delete('subs', "id = '{$id}'"); } return 'No se logró subir el archivo, intente nuevamente en unos minutos.'; } header("Location: /{$id}.html"); }
/** * Format string. * * @param $str * @param $format * @return string */ public function format($str, $format) { if (is_string($format)) { $format = array_key_exists($format, static::$formats) ? static::$formats[$format] : $format; if ($format instanceof \Closure) { return $format($str, $format); } } return Formats::regex($str, $format); }
e(date('d/m', $this->time)); ?> ; descargado <?php e(number_format($this->downloads)); ?> veces; <?php e(number_format($this->frame)); ?> fps en formato <a href="http://en.wikipedia.org/wiki/<?php e(Formats::get($this->ext)); ?> "><?php e(Formats::get($this->ext)); ?> </a>. </p> <?php if ($this->comment) { ?> <p><?php e($this->comment); ?> </p> <?php } ?>
/** * Wrapper to Formats::addInput. * * @param string $locale Name of locale, the same format of setlocale php function * @param string $format An array like in the description * * @return Localize Current instance of that class, for chaining methods */ public static function addFormat($locale, $format) { Formats::addInput($locale, $format); return new static(); }
/** * Returns the available formats in a processed easy to use format. * * @access public * @author Oliver Lillie * @param boolean $read_from_cache If true and the data exists within a cache then that data is used. If false * then the data is re-read from ffmpeg. * @return array Returns an array of formats and related information about each format. */ public function getFormats($read_from_cache = true) { $cache_key = 'ffmpeg_parser/parsed_formats'; if ($read_from_cache === true && ($data = $this->_cacheGet($cache_key))) { return $data; } // get the raw format information $raw_data = $this->getRawFormatData(); // then match out the relevant data, clean and process. $data = array(); if (preg_match_all('/ (DE|D|E) (.*) {1,} (.*)/', $raw_data, $format_matches) > 0) { foreach ($format_matches[0] as $key => $match) { $format_code = strtolower(trim($format_matches[2][$key])); $mux_and_demux = $format_matches[1][$key] === 'DE'; $data[$format_code] = array('mux' => $mux_and_demux === true || $format_matches[1][$key] === 'E', 'demux' => $mux_and_demux === true || $format_matches[1][$key] === 'D', 'fullname' => $format_matches[3][$key], 'extensions' => Formats::toExtensions($format_code)); } } $this->_cacheSet($cache_key, $data); return $data; }
public function run() { $htmlOptions = $this->htmlOptions; $tableOptions = $this->tableOptions; $model = $this->model; $name = $this->name; if (!isset($htmlOptions['class'])) { $htmlOptions['class'] = 'table-responsive'; } else { $htmlOptions['class'] .= ' table-responsive'; } $htmlOptions['id'] = 'schedules'; if (!isset($tableOptions['class'])) { $tableOptions['class'] = 'table table-condensed'; } else { $tableOptions['class'] .= ' table table-condensed'; } echo CHtml::openTag('div', $htmlOptions); echo CHtml::openTag('table', $tableOptions); echo CHtml::openTag('thead'); echo CHtml::openTag('tr'); echo CHtml::tag('th', array(), '第几天'); echo CHtml::tag('th', array(), '赛区'); echo CHtml::tag('th', array(), '开始时间'); echo CHtml::tag('th', array(), '结束时间'); echo CHtml::tag('th', array(), '项目'); echo CHtml::tag('th', array(), '分组'); echo CHtml::tag('th', array(), '轮次'); echo CHtml::tag('th', array(), '赛制'); echo CHtml::tag('th', array(), '及格线(秒)'); echo CHtml::tag('th', array(), '还原时限(秒)'); echo CHtml::tag('th', array(), '人数'); echo CHtml::closeTag('tr'); echo CHtml::closeTag('thead'); $schedules = $model->{$name}; $schedules[] = Schedule::model()->attributes; $events = Events::getScheduleEvents(); foreach ($events as $key => $value) { $events[$key] = Yii::t('event', $value); } $formats = Formats::getAllFormats(); foreach ($formats as $key => $value) { $formats[$key] = Yii::t('common', $value); } $rounds = Rounds::getAllRounds(); foreach ($rounds as $key => $value) { $rounds[$key] = Yii::t('Rounds', $value); } $stages = Schedule::getStages(); echo CHtml::openTag('tbody'); foreach ($schedules as $key => $value) { extract($value); echo CHtml::openTag('tr'); echo CHtml::tag('td', array(), CHtml::activeNumberField($model, "{$name}[day][]", array('value' => $day ?: 1, 'min' => 1, 'max' => 4))); echo CHtml::tag('td', array(), CHtml::dropDownList(CHtml::activeName($model, "{$name}[stage][]"), $stage, $stages)); echo CHtml::tag('td', array(), CHtml::activeTextField($model, "{$name}[start_time][]", array('value' => $start_time ? date('H:i', $start_time) : '', 'class' => 'datetime-picker', 'data-date-format' => 'hh:ii', 'data-max-view' => '1', 'data-start-view' => '1'))); echo CHtml::tag('td', array(), CHtml::activeTextField($model, "{$name}[end_time][]", array('value' => $end_time ? date('H:i', $end_time) : '', 'class' => 'datetime-picker', 'data-date-format' => 'hh:ii', 'data-max-view' => '1', 'data-start-view' => '1'))); echo CHtml::tag('td', array(), CHtml::dropDownList(CHtml::activeName($model, "{$name}[event][]"), $event, $events, array('prompt' => ''))); echo CHtml::tag('td', array(), CHtml::activeTextField($model, "{$name}[group][]", array('value' => $group))); echo CHtml::tag('td', array(), CHtml::dropDownList(CHtml::activeName($model, "{$name}[round][]"), $round, $rounds, array('prompt' => ''))); echo CHtml::tag('td', array(), CHtml::dropDownList(CHtml::activeName($model, "{$name}[format][]"), $format, $formats, array('prompt' => ''))); echo CHtml::tag('td', array(), CHtml::activeNumberField($model, "{$name}[cut_off][]", array('value' => $cut_off, 'max' => 3600))); echo CHtml::tag('td', array(), CHtml::activeNumberField($model, "{$name}[time_limit][]", array('value' => $time_limit, 'max' => 3600))); echo CHtml::tag('td', array(), CHtml::activeNumberField($model, "{$name}[number][]", array('value' => $number))); echo CHtml::closeTag('tr'); } echo CHtml::closeTag('tbody'); echo CHtml::closeTag('table'); echo CHtml::closeTag('div'); Yii::app()->clientScript->registerScript('SchedulesForm', <<<EOT \$(document).on('focus', '#schedules table tbody tr:last-child', function() { \$(this).clone().insertAfter(this); \$('.datetime-picker').datetimepicker({ autoclose: true }); }); EOT ); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Formats::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getListableSchedules() { $listableSchedules = array(); $schedules = $this->schedule; usort($schedules, array($this, 'sortSchedules')); $hasGroup = false; $hasNumber = false; $specialEvents = array('333fm' => array(), '333mbf' => array()); foreach ($schedules as $key => $schedule) { if (trim($schedule->group) != '') { $hasGroup = true; } if ($schedule->number > 0) { $hasNumber = true; } else { $schedule->number = ''; } if (isset($specialEvents[$schedule->event])) { $specialEvents[$schedule->event][$schedule->round][] = $key; } } $scheduleEvents = Events::getOnlyScheduleEvents(); foreach ($schedules as $key => $schedule) { if (isset($scheduleEvents[$schedule->event])) { $schedule->round = $schedule->group = $schedule->format = ''; $schedule->cut_off = $schedule->time_limit = 0; } $event = Yii::t('event', Events::getFullEventName($schedule->event)); if (isset($specialEvents[$schedule->event][$schedule->round]) && count($specialEvents[$schedule->event][$schedule->round]) > 1) { $times = array_search($key, $specialEvents[$schedule->event][$schedule->round]); switch ($times + 1) { case 1: $event .= Yii::t('common', '(1st attempt)'); break; case 2: $event .= Yii::t('common', '(2nd attempt)'); break; case 3: $event .= Yii::t('common', '(3rd attempt)'); break; default: $event .= Yii::t('common', '({times}th attempt)', array('{times}' => $times)); break; } } $temp = array('Start Time' => date('H:i', $schedule->start_time), 'End Time' => date('H:i', $schedule->end_time), 'Event' => $event, 'Group' => $schedule->group, 'Round' => Yii::t('Rounds', Rounds::getFullRoundName($schedule->round)), 'Format' => Yii::t('common', Formats::getFullFormatName($schedule->format)), 'Cut Off' => self::formatTime($schedule->cut_off), 'Time Limit' => self::formatTime($schedule->time_limit), 'Competitors' => $schedule->number, 'id' => $schedule->id, 'event' => $schedule->event, 'round' => $schedule->round); if ($hasGroup === false) { unset($temp['Group']); } if ($hasNumber === false) { unset($temp['Competitors']); } $listableSchedules[$schedule->day][$schedule->stage][] = $temp; } return $listableSchedules; }