Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Bug #14, PSR-2 coding standard - whitespace fixes [iet:3708522]
Browse files Browse the repository at this point in the history
  • Loading branch information
nfreear committed Jul 2, 2015
1 parent 198ad5c commit 76e56f0
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 107 deletions.
6 changes: 2 additions & 4 deletions application/core/MY_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ public function library($library = '', $params = null, $object_name = null)
public function theme($theme_name)
{
if ($this->CI->use_composer()) {

$sub = new \IET_OU\SubClasses\SubClasses();
$themes = $sub->get_player_themes();

$theme_name = str_replace('-', '_', $theme_name);
if (isset($themes[ $theme_name ])) {

$this->CI->theme = new $themes[ $theme_name ] ();
} else {
$this->CI->theme = new $themes[ $this->config->item('player_default_theme') ] ();
Expand All @@ -68,13 +66,13 @@ public function theme($theme_name)
require_once $theme_path;

$this->CI->theme = new $classname();
}
}

#$this->_ci_view_paths = array_merge($this->_ci_view_paths, array("../themes/$theme_name" => TRUE));
#$this->add_package_path(APPPATH .'/themes/'. $theme_name);
#$this->add_package_path(APPPATH .'/themes/'. $this->CI->theme->parent);

return $this->CI->theme;
return $this->CI->theme;
}

/** Load a view file from the theme or parent theme directory.
Expand Down
216 changes: 117 additions & 99 deletions application/helpers/ouplayer_helper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* OU Media Player helper functions.
*
Expand All @@ -9,31 +9,35 @@

/** JSON encode a string, removing the outer quotes (").
*/
function json_encode_str($str) {
return str_replace("'", "\\'", trim(json_encode($str), '"{}'));
function json_encode_str($str)
{
return str_replace("'", "\\'", trim(json_encode($str), '"{}'));
}

/** JSON encode an object, removing the outer braces {}.
*/
function json_encode_bare($obj, $parse_function = FALSE) {
$json = str_replace("'", "\\'", trim(json_encode($obj), '{}'));
function json_encode_bare($obj, $parse_function = false)
{
$json = str_replace("'", "\\'", trim(json_encode($obj), '{}'));

if ($parse_function) {
$json = preg_replace_callback('/"\s*
if ($parse_function) {
$json = preg_replace_callback(
'/"\s*
(?P<js_function>function\s*\(.+\})
\s*"/x',
function ($matches) {
return strtr($matches['js_function'], array(
'\r' => '',
'\n' => "\n\t",
'\t' => "\t",
))
. "\n";
},
$json);
}

return $json;
function ($matches) {
return strtr($matches['js_function'], array(
'\r' => '',
'\n' => "\n\t",
'\t' => "\t",
))
. "\n";
},
$json
);
}

return $json;
}


Expand All @@ -43,21 +47,25 @@ function ($matches) {
* @link http://php.net/manual/en/changelog.strings.php PHP 5.4+
*/
if (! defined('ENT_HTML401')) {
define('ENT_HTML401', 0);
define('ENT_XML1', 16);
define('ENT_XHTML', 32);
define('ENT_HTML5', 16|32);
define('ENT_HTML401', 0);
define('ENT_XML1', 16);
define('ENT_XHTML', 32);
define('ENT_HTML5', 16|32);
}
function html_chars($str, $flags = NULL, $encoding = 'UTF-8', $double_encode = FALSE) {
if (! $flags) $flags = ENT_COMPAT | ENT_HTML5;
return htmlspecialchars($str, $flags, $encoding, $double_encode);
function html_chars($str, $flags = null, $encoding = 'UTF-8', $double_encode = false)
{
if (! $flags) {
$flags = ENT_COMPAT | ENT_HTML5;
}
return htmlspecialchars($str, $flags, $encoding, $double_encode);
}


/** Does haystack contain needle? (Semantic wrapper around 'strpos')
*/
function contains($haystack, $needle) {
return FALSE !== strpos($haystack, $needle);
function contains($haystack, $needle)
{
return false !== strpos($haystack, $needle);
}


Expand All @@ -67,29 +75,29 @@ function contains($haystack, $needle) {
* Site URL. (Based on `/system/helpers/url_helper.php`)
* @return string
*/
if ( ! function_exists('site_url'))
{
function site_url($uri = '')
{
$CI =& get_instance();
$site_url = $CI->config->site_url($uri);
return preg_replace('@https?:\/\/@', '//', $site_url);
}
if (! function_exists('site_url')) {
function site_url($uri = '')
{
$CI =& get_instance();
$site_url = $CI->config->site_url($uri);
return preg_replace('@https?:\/\/@', '//', $site_url);
}
}


/**
* Video/audio media and images stored on OU Podcasts [iet-it-bugs:1486]
* @return string
*/
function media_url($uri, $return = false) {
$CI =& get_instance();
$media_url_regex = $CI->config->item('https_media_url_regex');
$media_url = preg_replace($media_url_regex, '//$1', $uri);
if ($return) {
return $media_url;
}
echo $media_url;
function media_url($uri, $return = false)
{
$CI =& get_instance();
$media_url_regex = $CI->config->item('https_media_url_regex');
$media_url = preg_replace($media_url_regex, '//$1', $uri);
if ($return) {
return $media_url;
}
echo $media_url;
}

/**
Expand All @@ -100,46 +108,49 @@ function media_url($uri, $return = false) {
@param bool $hash Whether to use a hash/version ID in the URL.
* @return string
*/
function player_res_url($uri = '', $hash = true, $return = false) {
static $base_url;
if (! $base_url) {
//Was: $base_url = preg_replace('@https?:\/\/@', '//', base_url());
$p = parse_url(base_url());
$base_url = $p['path'];
}

if ($hash) {
$hash = '?v=0';
} else {
$hash = '';
}

if ($return) {
return $base_url. $uri . $hash;
}
echo $base_url. $uri . $hash;
function player_res_url($uri = '', $hash = true, $return = false)
{
static $base_url;
if (! $base_url) {
//Was: $base_url = preg_replace('@https?:\/\/@', '//', base_url());
$p = parse_url(base_url());
$base_url = $p['path'];
}

if ($hash) {
$hash = '?v=0';
} else {
$hash = '';
}

if ($return) {
return $base_url. $uri . $hash;
}
echo $base_url. $uri . $hash;
}

/**
* Output URL for a site resource - HTTPS/SSL-neutral [iet-it-bugs:1329]
* @return string
*/
function site_res_url($uri = '') {
$p = parse_url(base_url());
$site_url = $p['path'] . $uri;
function site_res_url($uri = '')
{
$p = parse_url(base_url());
$site_url = $p['path'] . $uri;

return $site_url;
return $site_url;
}

/**
* Get a Google Analytics ID, if available [iet-it-bugs:1486]
* @return string
*/
function google_analytics_id($key) {
$CI =& get_instance();
$CI->config->load('providers');
$ga_analytics_ids = $CI->config->item('provider_google_analytics_ids');
return isset($ga_analytics_ids[$key]) ? $ga_analytics_ids[$key] : NULL;
function google_analytics_id($key)
{
$CI =& get_instance();
$CI->config->load('providers');
$ga_analytics_ids = $CI->config->item('provider_google_analytics_ids');
return isset($ga_analytics_ids[$key]) ? $ga_analytics_ids[$key] : null;
}

// ====================================================================
Expand All @@ -148,50 +159,57 @@ function google_analytics_id($key) {
/** Return class and aria-label attributes for player controls.
* @return string
*/
function _oupc_label($className, $text) {
return "class=\"$className\" aria-label=\"$text\"";
function _oupc_label($className, $text)
{
return "class=\"$className\" aria-label=\"$text\"";
}

/** Return the path for the main Flowplayer Flash file, based on config. variables.
* @return string
*/
function _flowplayer_flash() {
function _flowplayer_flash()
{
$CI =& get_instance();
$flowplayer_dev= $CI->config->item('flowplayer_dev');
$flow_key = $CI->config->item('flowplayer_key');
$flow_commercial= $flow_key ? '.commercial' : '';
$flow_version = $CI->config->item('flowplayer_version');
if(!$flow_version || !$flow_key){$flow_version='3.2.7';}

if ($flowplayer_dev) {
return "assets/flowplayer_dev/flowplayer$flow_commercial.swf";
}
return "swf/flowplayer$flow_commercial-$flow_version.swf";
}
if (!$flow_version || !$flow_key) {
$flow_version='3.2.7';
}

if ($flowplayer_dev) {
return "assets/flowplayer_dev/flowplayer$flow_commercial.swf";
}
return "swf/flowplayer$flow_commercial-$flow_version.swf";
}

/** Return the path for a Flowplayer Flash plugin, based on config. variables.
* @return string
*/
function _flowplayer_plugin($name, $version) {
function _flowplayer_plugin($name, $version)
{
$flowplayer_dev = config_item('flowplayer_dev');
if ($flowplayer_dev) {
return "flowplayer.$name.swf";
}
return "flowplayer.$name-$version.swf";
}

function cache_exists($key) {
$CI =& get_instance();
$CI->load->driver('cache', array('adapter'=>'file')); #,array('adapter'=>'apc', 'backup'=>'file'));
$stat = $CI->cache->get_metadata($key);
return (bool) $stat;
if ($flowplayer_dev) {
return "flowplayer.$name.swf";
}
return "flowplayer.$name-$version.swf";
}

function cache_time($key) {
$CI =& get_instance();
$CI->load->driver('cache', array('adapter'=>'file'));
$stat = $CI->cache->get_metadata($key);

function cache_exists($key)
{
$CI =& get_instance();
$CI->load->driver('cache', array('adapter'=>'file')); #,array('adapter'=>'apc', 'backup'=>'file'));
$stat = $CI->cache->get_metadata($key);
return (bool) $stat;
}

function cache_time($key)
{
$CI =& get_instance();
$CI->load->driver('cache', array('adapter'=>'file'));
$stat = $CI->cache->get_metadata($key);

#var_dump($stat);
return $stat['mtime'];
return $stat['mtime'];
}
1 change: 1 addition & 0 deletions application/themes/Oup_Light_Theme.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace IET_OU\Open_Media_Player;

/**
* OU Player Light 2012 theme.
*
Expand Down
6 changes: 2 additions & 4 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
<exclude-pattern>*/*BAK*</exclude-pattern>

<!-- Exclude third-party libraries. -->
<exclude-pattern>/application/libraries/FirePHPCore</exclude-pattern>
<exclude-pattern>/application/libraries/class.pdf2text.php</exclude-pattern>
<exclude-pattern>/application/libraries/POParser.php</exclude-pattern>

<!-- Temporarily exclude all views and provider-libraries. -->
<exclude-pattern>*/views/*</exclude-pattern>
<exclude-pattern>/application/libraries/providers/</exclude-pattern>
<exclude-pattern>/application/libraries/</exclude-pattern>
<!--<exclude-pattern>/application/libraries/</exclude-pattern>-->


<rule ref="./vendor/iet-ou/open-media-player-core/phpcs.xml"/>
Expand All @@ -34,4 +32,4 @@
<exclude name="PSR1.Classes.ClassDeclaration"/>
</rule>

</ruleset>
</ruleset>

0 comments on commit 76e56f0

Please sign in to comment.