From 09add6ca11db3ca299f73fbc92f4f2d0aed1daa8 Mon Sep 17 00:00:00 2001 From: Calin Burloiu Date: Mon, 29 Aug 2011 15:13:26 +0300 Subject: [PATCH] plugin detection created as a widget; can't tell yet if swarmplayer is installed --- application/config/p2p-tube.php | 19 +- application/controllers/article.php | 9 +- application/controllers/catalog.php | 25 +- application/controllers/video.php | 3 - application/language/english/ui_lang.php | 7 + application/libraries/Html_head_params.php | 23 +- application/views/header.php | 2 +- application/views/side_default.php | 43 +-- css/default.css | 9 + css/jquery.ui.nsvideo.css | 1 - js/jquery.ui.nsinstall.js | 298 +++++++++++++++++++++ js/jquery.ui.nsvideo.js | 12 + 12 files changed, 386 insertions(+), 65 deletions(-) create mode 100644 js/jquery.ui.nsinstall.js diff --git a/application/config/p2p-tube.php b/application/config/p2p-tube.php index 8eddbff..045f54d 100644 --- a/application/config/p2p-tube.php +++ b/application/config/p2p-tube.php @@ -14,35 +14,38 @@ $config['site_name'] = 'P2P-Next UPB LivingLab'; /* |-------------------------------------------------------------------------- -| Default Stylesheet +| Autoload Stylesheets |-------------------------------------------------------------------------- | -| Sets the default CSS that is going to be automatically added on any HTML +| Sets the default CSSs that are going to be automatically added on any HTML | page generated with 'application/views/html_begin.php' view and | HTML_head_params library. | | Do not include any path to the file! 'css/' is going to be used. | -| Leave blank for no default stylesheet. +| Use "array()" for no default stylesheet. | */ -$config['default_css'] = 'default.css'; +$config['autoload_css'] = array('default.css', + 'jquery-ui.css'); /* |-------------------------------------------------------------------------- -| Default Javascript +| Autoload Javascript |-------------------------------------------------------------------------- | -| Sets the default Javascript that is going to be automatically added in any +| Sets the default Javascripts that are going to be automatically added in any | HTML page generated with 'application/views/html_begin.php' view and | HTML_head_params library. | | Do not include any path to the file! 'js/' is going to be used. | -| Leave blank for no default javascript. +| Use "array()" for no default javascript. | */ -$config['default_js'] = ''; +$config['autoload_js'] = array('jquery.js', + 'jquery-ui.js', + 'jquery.ui.nsinstall.js'); /* |-------------------------------------------------------------------------- diff --git a/application/controllers/article.php b/application/controllers/article.php index 27614f8..5073a5b 100644 --- a/application/controllers/article.php +++ b/application/controllers/article.php @@ -26,13 +26,8 @@ class Article extends Article_Controller { $html_params = array('title' => $this->title.' - ' . $this->config->item('site_name'), - 'css' => array( - 'jquery-ui.css' - ), - 'js' => array( - 'jquery.js', - 'jquery-ui.js' - ), + //'css' => array(), + //'js' => array(), 'metas' => array('description'=>$this->metaDescription) ); diff --git a/application/controllers/catalog.php b/application/controllers/catalog.php index 4318325..0c05388 100644 --- a/application/controllers/catalog.php +++ b/application/controllers/catalog.php @@ -43,13 +43,9 @@ class Catalog extends CI_Controller { $params = array( 'title' => $this->config->item('site_name'), 'css' => array( - 'catalog.css', - 'jquery-ui.css' - ), - 'js' => array( - 'jquery.js', - 'jquery-ui.js' + 'catalog.css' ), + //'js' => array(), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); @@ -71,13 +67,8 @@ class Catalog extends CI_Controller { public function test($page = 0) { $params = array( 'title' => 'Test - '. $this->config->item('site_name'), - 'css' => array( - 'jquery-ui.css' - ), - 'js' => array( - 'jquery.js', - 'jquery-ui.js' - ), + //'css' => array(), + //'js' => array(), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); @@ -128,13 +119,9 @@ class Catalog extends CI_Controller { $params = array( 'title' => $this->config->item('site_name'), 'css' => array( - 'catalog.css', - 'jquery-ui.css' - ), - 'js' => array( - 'jquery.js', - 'jquery-ui.js' + 'catalog.css' ), + //'js' => array(), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); diff --git a/application/controllers/video.php b/application/controllers/video.php index 5a4b9d5..019fa2c 100644 --- a/application/controllers/video.php +++ b/application/controllers/video.php @@ -45,13 +45,10 @@ class Video extends CI_Controller { $params = array( 'title' => $data['video']['title'] . ' -- ' . $this->config->item('site_name'), 'css' => array( - 'jquery-ui.css', 'jquery.ui.nsvideo.css', 'video.css' ), 'js' => array( - 'jquery.js', - 'jquery-ui.js', 'jquery.ui.nsvideo.js' ), //'metas' => array('description'=>'','keywords'=>'') diff --git a/application/language/english/ui_lang.php b/application/language/english/ui_lang.php index af184ee..0bd140d 100644 --- a/application/language/english/ui_lang.php +++ b/application/language/english/ui_lang.php @@ -11,6 +11,13 @@ $lang['ui_nav_menu_register'] = 'Register'; $lang['ui_search'] = 'Search'; +// Install Video Plugins +$lang['ui_install'] = 'Install '; +$lang['ui_install_os_not_supported'] = ' is not supported for your operating system'; +$lang['ui_install_browser_not_supported'] = ' is not supported for your browser'; +$lang['ui_install_browser_version_not_supported'] = ' is not supported for your browser version'; +$lang['ui_install_already_installed'] = ' is installed'; + // Video Categories $lang['ui_categ_movies'] = 'Movies'; $lang['ui_categ_tech_talks'] = 'TechTalks'; diff --git a/application/libraries/Html_head_params.php b/application/libraries/Html_head_params.php index 6723455..d729d88 100644 --- a/application/libraries/Html_head_params.php +++ b/application/libraries/Html_head_params.php @@ -5,9 +5,10 @@ * included inside the head tag like: title, stylesheets, scripts and meta * information. * - * The constructor automatically adds the default stylesheet and default script - * if any from 'application/config/p2p-tube.php' so they don't have to be added - * manually. + * The constructor automatically adds the autoload-configured CSSs and JSs + * if any from "application/config/${site_config}.php" so they don't have to be + * added manually. The configuration parameters are: + * 'autoload_css', 'autoload_js'. * * The variables are passed as data in 'application/views/html_begin.php' which * is going to generate the tags based on their information. @@ -27,6 +28,8 @@ class Html_head_params { // Dictionary for meta tags: name => content public $metas; + protected $site_config = 'p2p-tube'; + /** * Initializes member variables with the parameters provided and adds the * default stylesheet to member $css and the default script to @@ -45,7 +48,11 @@ class Html_head_params { { $CI =& get_instance(); $CI->load->helper('url'); - $CI->load->config('p2p-tube'); + + if (isset($this->site_config)) + $CI->load->config($this->site_config); + else + { /* TODO: no site config*/ } if (isset($params['title'])) $this->title = $params['title']; @@ -68,10 +75,10 @@ class Html_head_params { $this->metas = array(); // Default parameters from configuration file - if ($CI->config->item('default_css') != '') - $this->css[] = $CI->config->item('default_css'); - if ($CI->config->item('default_js') != '') - $this->js[] = $CI->config->item('default_js'); + $this->css = array_merge( + $CI->config->item('autoload_css'), $this->css); + $this->js = array_merge( + $CI->config->item('autoload_js'), $this->js); // URL correct prefixes foreach ($this->css as $i => $val) diff --git a/application/views/header.php b/application/views/header.php index dccb112..3e9342d 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -27,7 +27,7 @@ endif ?> ') + .appendTo(widget.$videoContainer); + $installContainer + .nsinstall({ + type: widget.options.type, + hideIfAlreadyInstalled: true + }); + var width = widget.options.width; var height = widget.options.height; @@ -833,6 +842,9 @@ $.widget( "ui.nsvideo", { }, pause: function() { + if (typeof widget.$video[0].playlist === 'undefined') + return widget; + if (widget.$video[0].playlist.isPlaying) widget.$video[0].playlist.togglePause(); -- 2.20.1