PHP Classes

File: demo/includes/common.php

Recommend this page to a friend!
  Classes of Koala Yeung   Widgetfy   demo/includes/common.php   Download  
File: demo/includes/common.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Widgetfy
Generate HTML to embed video content of given URL
Author: By
Last change: Update of demo/includes/common.php
Date: 2 months ago
Size: 893 bytes
 

Contents

Class file image Download
<?php

// turn on error reporting for debug
error_reporting(E_ALL);
ini_set('display_error', 1);

// use autoloader
require_once dirname(dirname(__DIR__)) . '/autoload.php';

// load demo site information
function getDemoURLs() {
   
$json_raw = file_get_contents(dirname(__DIR__) . '/misc/demo.json');
    return
json_decode($json_raw, TRUE);
}

// render css style for .videoblock
function style_block($embed) {
 
$d = &$embed['dimension'];
 
// if scale model is no-scale, allow to "force dynamic"
  // by setting "dynamic" to TRUE
 
if (!$d->dynamic && ($d->scale_model == 'no-scale')) {
    return
'width: '.$d->width.'px';
  }
  return
'';
}

// render css style for .videowrapper
function style_wrapper($embed) {
 
$d = &$embed['dimension'];
  if (
$d->dynamic && ($d->scale_model == 'scale-width-height')) {
    return
'padding-bottom: ' . ($d->factor * 100) . '%;';
  }
  return
'';
}