Ejemplo n.º 1
0
 function Video($Source, $Attributes = array())
 {
     static $DefaultAttributes = array('width' => 640, 'height' => 360, 'poster' => '', 'autoplay' => False, 'controls' => 'controls');
     static $VideoType = array('3gp' => '3gpp', 'ogv' => 'ogg', 'mkv' => 'x-matroska', 'm4v' => 'mp4');
     //static $Codecs = array('mp4' => 'avc1.42E01E, mp4a.40.2', 'webm' => 'vp8, vorbis', 'ogg' => 'theora, vorbis');
     static $Codecs;
     $Source = SplitString($Source);
     $StoreDirectory = trim(GetValue('StoreDirectory', $Attributes, '', True), '/');
     foreach ($Source as $Src) {
         if ($StoreDirectory != '') {
             $Src = $StoreDirectory . '/' . $Src;
         }
         $Extension = strtolower(pathinfo($Src, 4));
         $Type = ArrayValue($Extension, $VideoType, $Extension);
         $Codec = ArrayValue($Extension, $Codecs);
         $Src = Asset($Src);
         if ($Codec != False && strpos($Type, ';') === False) {
             $Type = $Type . ';' . Attribute('codecs', $Codec);
         }
         $Type = PrefixString('video/', $Type);
         $SourceAttributes = array('src' => $Src, 'type' => $Type);
         $Sources[] = '<source' . Attribute($SourceAttributes) . ' />';
     }
     $Sources = implode("\n", $Sources);
     $Poster = ArrayValue('poster', $Attributes);
     // TODO: make poster from video
     if ($Poster && (GetValue('SizeOfPoster', $Attributes, False, True) || !array_key_exists('width', $Attributes))) {
         // TODO: FIX ME (WITHOUT URL)
         $ImagePoster = Asset($Poster, True);
         list($width, $height) = GetImageSize($ImagePoster);
         $Attributes = array_merge($Attributes, compact('width', 'height'), array('poster' => $ImagePoster));
     }
     $Unsupported = sprintf(T('Your browser cant play this video. You can %s instead.'), Anchor(T('download the video'), $Source[0]));
     $Attributes = array_merge($DefaultAttributes, compact('Unsupported'), $Attributes);
     $Unsupported = Wrap(GetValue('Unsupported', $Attributes, '', True), 'p');
     return Wrap($Sources . $Unsupported, 'video', $Attributes);
     // Flash Fallback.
     /*$Config = new StdClass();
     		$Config->clip->url = $Source[0];
     		$Config->autoPlay = ArrayValue('autoplay', $Attributes, False);
     		$Config->autoBuffering = ArrayValue('autobuffering', $Attributes, True);
     		//d(json_encode($Config));
     		$FlashOptions = array('width' => $Attributes['width'], 'height' => $Attributes['width'],
     			'FlashVars' => array('config' => json_encode($Config))
     		);
     		$Flash = FlashHtml('http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf', $FlashOptions);
     		// TODO: Image Fallback
     		//$ImageFallback = Img($Poster, array('alt' => 'Poster', 'title' => T('No video playback capabilities.')));
     		*/
 }
Ejemplo n.º 2
0
ini_set('memory_limit', '512M');
$Handler = new StdClass();
$Handler->Returns = array();
$Handler->EventArguments = array();
$PluginManager = Gdn::PluginManager();
$Ticks = array(60 => 'Minute', 3600 => 'Hour', 86400 => 'Day');
$Matches = array('Minutes' => 'i', 'Hours' => 'H', 'Day' => 'j', 'Month' => 'n');
$Events = array();
$Exception = Null;
$LastYearSeconds = 0;
do {
    $YearSeconds = (int) (YearSeconds() / 60) * 60;
    // rewind to begining of the minute
    $Event = '';
    foreach ($Matches as $Name => $Token) {
        $Event = PrefixString('Match', $Event . '_' . date($Token) . '_' . $Name);
        try {
            $PluginManager->CallEventHandlers($Handler, 'Tick', $Event);
            //K('#'.$Event, (int)K('#'.$Event) + 1);
        } catch (Exception $Exception) {
        }
        Console::Message('Tick: %s', $Event);
        $Events[] = $Event;
    }
    $Event = $Events[1] . '_' . date('l');
    try {
        $PluginManager->CallEventHandlers($Handler, 'Tick', $Event);
        //K('#'.$Event, (int)K('#'.$Event) + 1);
    } catch (Exception $Exception) {
    }
    Console::Message('Tick: %s', $Event);
Ejemplo n.º 3
0
 protected static function ProcessImportCssText($CssText = '', $Filepath)
 {
     if (!$CssText) {
         $CssText = file_get_contents($Filepath);
     }
     preg_match_all('/(@import\\s+url\\(((.+?)\\)).*)/i', $CssText, $Match);
     if (!(isset($Match[3]) && count($Match[3]) > 0)) {
         return False;
     }
     $CssFiles = $Match[3];
     //$Url = Url('/', True);
     $DocRoot = Gdn::Request()->GetValue('DOCUMENT_ROOT');
     $Replace = array();
     foreach ($CssFiles as $N => $Filename) {
         $Filename = trim($Filename, '"\'');
         if ($Filename[0] == '/') {
             $ImportFilepath = PrefixString($DocRoot, $Filename);
         } else {
             // relative path
             $ImportFilepath = dirname($Filepath) . DS . $Filename;
         }
         if (!file_exists($ImportFilepath)) {
             trigger_error("File not found ({$ImportFilepath})");
         }
         $ImportedCss = file_get_contents($ImportFilepath);
         self::ChangeBackgroundUrl($ImportedCss, $ImportFilepath);
         $ImportMatch = $Match[0][$N];
         $Replace[$ImportMatch] = "\n" . $ImportedCss;
     }
     $Result = str_replace(array_keys($Replace), array_values($Replace), $CssText);
     return $Result;
 }
function FormatDate($Year = "", $Month = "", $Day = "", $Format = "mysql", $Hour = "", $Minute = "", $Second = "")
{
    // Manipulate year
    $Year = ForceInt($Year, 0);
    if ($Year == 0 || strlen($Year) != 4) {
        $Year = date("Y", mktime());
    }
    // Manipulate month
    $Month = ForceInt($Month, 0);
    if ($Month <= 0 || $Month > 12) {
        $Month = date("n", mktime());
    }
    // Manipulate Day
    $Day = ForceInt($Day, 0);
    if ($Day <= 0 || $Day > 31) {
        $Day = date("j", mktime());
    }
    // Manipulate Hour
    $Hour = ForceInt($Hour, 0);
    if ($Hour <= 0 || $Hour > 23) {
        $Hour = 0;
    }
    // Manipulate Minute
    $Minute = ForceInt($Minute, 0);
    if ($Minute <= 1 || $Minute > 60) {
        $Minute = 0;
    }
    // Manipulate Second
    $Second = ForceInt($Second, 0);
    if ($Second <= 1 || $Second > 60) {
        $Second = 0;
    }
    if ($Format == "unixtimestamp") {
        return mktime($Hour, $Minute, $Second, $Month, $Day, $Year);
    } else {
        $Month = PrefixString($Month, "0", 2);
        $Day = PrefixString($Day, "0", 2);
        $Hour = PrefixString($Hour, "0", 2);
        $Minute = PrefixString($Minute, "0", 2);
        $Second = PrefixString($Second, "0", 2);
        return $Year . "-" . $Month . "-" . $Day . " " . $Hour . ":" . $Minute . ":" . $Second;
    }
}