homepage, categories pages; javascript and stylesheets renamed to js and css resp.
authorCalin Burloiu <calin.burloiu@gmail.com>
Wed, 27 Jul 2011 07:52:23 +0000 (10:52 +0300)
committerCalin Burloiu <calin.burloiu@gmail.com>
Wed, 27 Jul 2011 07:52:23 +0000 (10:52 +0300)
26 files changed:
.htaccess
application/config/p2p-tube.php
application/config/pagination.php [new file with mode: 0644]
application/controllers/catalog.php
application/controllers/video.php
application/libraries/Html_head_params.php
application/models/videos_model.php
application/views/catalog/category_view.php
application/views/catalog/index_view.php
application/views/html_begin.php
application/views/video/watch_view.php
css/NextShare_VLC_plugin.css [moved from stylesheets/NextShare_VLC_plugin.css with 100% similarity]
css/catalog.css [moved from stylesheets/catalog.css with 50% similarity]
css/default.css [new file with mode: 0644]
css/jquery-ui.css [moved from stylesheets/jquery-ui.css with 100% similarity]
img/bg.png [new file with mode: 0644]
img/thumb_container.png
img/thumb_container02.png [new file with mode: 0644]
js/NextShare_VLC_plugin.js [moved from javascript/NextShare_VLC_plugin.js with 100% similarity]
js/default.js [moved from javascript/default.js with 100% similarity]
js/jquery-1.6.2.min.js [moved from javascript/jquery-1.6.2.min.js with 100% similarity]
js/jquery-ui.min.js [moved from javascript/jquery-ui.min.js with 100% similarity]
js/jquery.js [moved from javascript/jquery.js with 100% similarity]
js/jquery.min.js [moved from javascript/jquery.min.js with 100% similarity]
js/video.js [moved from javascript/video.js with 62% similarity]
stylesheets/default.css [deleted file]

index d9fdd6a..25b547b 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -20,5 +20,5 @@
 </Files>
 
 RewriteEngine on
-RewriteCond $1 !^(index\.php|img|stylesheets|javascript|data|robots\.txt)
+RewriteCond $1 !^(index\.php|img|css|js|data|robots\.txt)
 RewriteRule ^(.*)$ index.php/$1 [L]
index b17610a..89bd1ef 100644 (file)
@@ -21,12 +21,12 @@ $config['site_name'] = 'P2P-Next UPB LivingLab';
 | page generated with 'application/views/html_begin.php' view and
 | HTML_head_params library.
 |
-| Do not include any path to the file! 'stylesheets/' is going to be used.
+| Do not include any path to the file! 'css/' is going to be used.
 |
 | Leave blank for no default stylesheet.
 |
 */
-$config['default_stylesheet'] = 'default.css';
+$config['default_css'] = 'default.css';
 
 /*
 |--------------------------------------------------------------------------
@@ -37,12 +37,12 @@ $config['default_stylesheet'] = 'default.css';
 | HTML page generated with 'application/views/html_begin.php' view and
 | HTML_head_params library.
 |
-| Do not include any path to the file! 'javascripts/' is going to be used.
+| Do not include any path to the file! 'js/' is going to be used.
 |
 | Leave blank for no default javascript.
 |
 */
-$config['default_javascript'] = '';
+$config['default_js'] = '';
 
 /*
 |--------------------------------------------------------------------------
@@ -86,3 +86,23 @@ $config['default_torrent_ext'] = 'tstream';
 |
 */
 $config['categories'] = array(1 => 'Movies', 2 => 'TechTalks', 3 => 'Events', 4 => 'Karaoke');
+
+/*
+|--------------------------------------------------------------------------
+| Videos per page
+|--------------------------------------------------------------------------
+|
+| The number of video icons shown per page (as in catalog/category).
+|
+*/
+$config['videos_per_page'] = 16;
+
+/*
+|--------------------------------------------------------------------------
+| Videos per row
+|--------------------------------------------------------------------------
+|
+| The number of video icons shown on a single line (as in home page).
+|
+*/
+$config['videos_per_row'] = 4;
diff --git a/application/config/pagination.php b/application/config/pagination.php
new file mode 100644 (file)
index 0000000..8df4933
--- /dev/null
@@ -0,0 +1,7 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+$config['per_page'] = 16; 
+$config['num_links'] = 2;
+
+$config['full_tag_open'] = '<div class="pagination">';
+$config['full_tag_close'] = '</div>';
\ No newline at end of file
index e6d2c0d..3447167 100644 (file)
@@ -8,15 +8,25 @@
  */
 class Catalog extends CI_Controller {
        
+       public function __construct()
+       {
+               parent::__construct();
+       }       
+       
        public function index()
        {
                // Retrieve videos summary.
+               $data['categories'] = $this->config->item('categories');
                $this->load->model('videos_model');
-               $data['videos'] = $this->videos_model->get_videos_summary();
+               foreach ($data['categories'] as $id => $name)
+               {
+                       $data['videos'][$id] = $this->videos_model->get_videos_summary(
+                               $id, 0, $this->config->item('videos_per_row'));
+               }
                
                $params = array(        'title' => $this->config->item('site_name'),
-                                                       //'stylesheets' => array(),
-                                                       //'javascripts' => array(),
+                                                       'css' => array('catalog.css'),
+                                                       //'js' => array(),
                                                        //'metas' => array('description'=>'','keywords'=>'')
                                                        );
                $this->load->library('html_head_params', $params);
@@ -29,25 +39,41 @@ class Catalog extends CI_Controller {
                $this->load->view('html_end');
        }
        
-       public function test()
+       public function test($page = 0)
        {
                $this->load->helper('url');
+               $this->load->library('pagination');
                
-               echo '<a href="/">link</a>';
+               $config['base_url'] = site_url('catalog/test/');
+               $config['total_rows'] = '160';
+               $this->pagination->initialize($config);
+               echo $this->pagination->create_links();
        }
        
-       public function category($category_id)
+       public function category($category_id, $offset = 0)
        {
                // Retrieve videos summary.
                $this->load->model('videos_model');
-               $data['videos'] = $this->videos_model->get_videos_summary($category_id);
+               $data['videos'] = $this->videos_model->get_videos_summary(
+                       $category_id, intval($offset),
+                       $this->config->item('videos_per_page'));
                $categories = $this->config->item('categories');
                $data['category'] = $categories[$category_id];
                $data['category_id'] = $category_id;
                
+               // Pagination
+               $this->load->library('pagination');
+               $pg_config['base_url'] = site_url("catalog/category/$category_id/");
+               $pg_config['uri_segment'] = 4;
+               $pg_config['total_rows'] = $this->videos_model->get_videos_count(
+                       $category_id);
+               $pg_config['per_page'] = $this->config->item('videos_per_page');
+               $this->pagination->initialize($pg_config);
+               $data['pagination'] = $this->pagination->create_links();
+               
                $params = array(        'title' => $this->config->item('site_name'),
-                                                       'stylesheets' => array('catalog.css'),
-                                                       //'javascripts' => array(),
+                                                       'css' => array('catalog.css'),
+                                                       //'js' => array(),
                                                        //'metas' => array('description'=>'','keywords'=>'')
                                                        );
                $this->load->library('html_head_params', $params);
index 64a1e63..f892349 100644 (file)
@@ -39,8 +39,8 @@ class Video extends CI_Controller {
                // Display page.
                $params = array(        'title' => $data['video']['title'] . ' -- '
                                                                . $this->config->item('site_name'),
-                                                       'stylesheets' => array('jquery-ui.css', 'NextShare_VLC_plugin.css'),
-                                                       'javascripts' => array('jquery.min.js', 'jquery-ui.min.js', 'NextShare_VLC_plugin.js', 'video.js'),
+                                                       'css' => array('jquery-ui.css', 'NextShare_VLC_plugin.css'),
+                                                       'js' => array('jquery.min.js', 'jquery-ui.min.js', 'NextShare_VLC_plugin.js', 'video.js'),
                                                        //'metas' => array('description'=>'','keywords'=>'')
                                                        );
                $this->load->library('html_head_params', $params);
@@ -56,7 +56,7 @@ class Video extends CI_Controller {
        /**
         * AJAX page which retrieves a video plugin.
         *
-        * The associated with this controller should be parameter type
+        * The view associated with this controller should be parameter type
         * concatenated with '_plugin_view' and must be located in
         * 'application/views/video'.
         *
index fec1055..6723455 100644 (file)
@@ -12,8 +12,8 @@
  * The variables are passed as data in 'application/views/html_begin.php' which
  * is going to generate the tags based on their information.
  *
- * All .css files must be located in 'stylesheets' and all .js file in
- * 'javascripts'.
+ * All .css files must be located in 'css' and all .js file in
+ * 'js'.
  *
  * @category   Library
  * @author             Călin-Andrei Burloiu
 class Html_head_params {
        public $title;
        // List of .css files
-       public $stylesheets;
+       public $css;
        // List of .js files
-       public $javascripts;
+       public $js;
        // Dictionary for meta tags: name => content
        public $metas;
        
        /**
         * Initializes member variables with the parameters provided and adds the
-        * default stylesheet to member $stylesheets and the default script to
-        * member $javascripts. The URL prefixes are also added to filenames.
+        * default stylesheet to member $css and the default script to
+        * member $js. The URL prefixes are also added to filenames.
         *
         * Do not add in the parameters list the default stylesheet and script!
         *
         * @access              public
         * @param               array $params   asscociative list with the following parameters:
         *   * 'title' => HTML title tag content (page title)
-        *   * 'stylesheets' => list of .css files without any path
-        *   * 'javascripts' => list of .js files without any path
+        *   * 'css' => list of .css files without any path
+        *   * 'js' => list of .js files without any path
         *   * 'metas' => associative list of "name => content" meta
         */
        public function __construct($params)
@@ -52,15 +52,15 @@ class Html_head_params {
                else
                        $this->title = '';
                        
-               if (isset($params['stylesheets']))
-                       $this->stylesheets = $params['stylesheets'];
+               if (isset($params['css']))
+                       $this->css = $params['css'];
                else
-                       $this->stylesheets = array();
+                       $this->css = array();
                        
-               if (isset($params['javascripts']))
-                       $this->javascripts = $params['javascripts'];
+               if (isset($params['js']))
+                       $this->js = $params['js'];
                else
-                       $this->javascripts = array();
+                       $this->js = array();
                
                if (isset($params['metas']))
                        $this->metas = $params['metas'];
@@ -68,16 +68,16 @@ class Html_head_params {
                        $this->metas = array();
                        
                // Default parameters from configuration file
-               if ($CI->config->item('default_stylesheet') != '')
-                       $this->stylesheets[] = $CI->config->item('default_stylesheet');
-               if ($CI->config->item('default_javascript') != '')
-                       $this->javascripts[] = $CI->config->item('default_javascript');
+               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');
                
                // URL correct prefixes
-               foreach ($this->stylesheets as $i => $val)
-                       $this->stylesheets[$i] = site_url("stylesheets/$val");
-               foreach ($this->javascripts as $i => $val)
-                       $this->javascripts[$i] = site_url("javascript/$val");
+               foreach ($this->css as $i => $val)
+                       $this->css[$i] = site_url("css/$val");
+               foreach ($this->js as $i => $val)
+                       $this->js[$i] = site_url("js/$val");
        }       
 }
 
index 223def7..3ab8592 100644 (file)
@@ -25,6 +25,9 @@ class Videos_model extends CI_Model {
         * displayed in the catalog.
         *
         * TODO: filter, limit, ordering parameters
+        * @param               int $category_id        DB category ID
+        * @param               int $offset
+        * @param               int $count
         * @return              array   a list of videos, each one being an assoc array with:
         *   * id, name, title, duration, thumbs_count, default_thumb, views => from DB
         *   * shorted_title => ellipsized title
@@ -32,7 +35,7 @@ class Videos_model extends CI_Model {
         *   * TODO: user_id, user_name
         *   * thumbs => thumbnail images' URLs
         */
-       public function get_videos_summary($category_id)
+       public function get_videos_summary($category_id, $offset, $count)
        {
                $this->load->helper('text');
                
@@ -41,9 +44,14 @@ class Videos_model extends CI_Model {
                                default_thumb
                        FROM `videos`
                        WHERE category_id = ?
-                       ORDER BY name', // TODO summary order 
-                       $category_id); 
-               $videos = $query->result_array();
+                       ORDER BY name
+                       LIMIT ?, ?', // TODO summary order 
+                       array(intval($category_id), $offset, $count)); 
+               
+               if ($query->num_rows() > 0)
+                       $videos = $query->result_array();
+               else
+                       return NULL;
                
                foreach ($videos as & $video)
                {
@@ -63,6 +71,21 @@ class Videos_model extends CI_Model {
                return $videos;
        }
        
+       public function get_videos_count($category_id)
+       {
+               $query = $this->db->query(
+                       'SELECT COUNT(*) count
+                       FROM `videos`
+                       WHERE category_id = ?',
+                       $category_id);
+               
+               if ($query->num_rows() > 0)
+                       return $row = $query->row()->count;
+               
+               // Error
+               return NULL;
+       }
+       
        /**
         * Retrieves information about a video.
         *
index d4e8127..6831bb6 100644 (file)
@@ -1,19 +1,21 @@
 <div id="body">
 <div id="content">
 
+<div class="video-list">
 <h1><?php echo $category ?></h1>
 
-<div class="video-list">
+<?php echo $pagination ?>
+
 <?php foreach($videos as $video):
        $thumb_src = $video['thumbs'][ $video['default_thumb'] ];
        ?>
        <div class="video-icon">
-               <a href="<?php echo $video['video_url'] ?>">
-                       <div class="video-thumb">
+               <div class="video-thumb">
+                       <a href="<?php echo $video['video_url'] ?>">
                                <img src="<?php echo $thumb_src ?>" />
                                <div class="video-duration"><?php echo $video['duration'] ?></div>
-                       </div>
-               </a>
+                       </a>
+               </div>
                <div class="video-title">
                        <a href="<?php echo $video['video_url'] ?>">                    
                        <?php echo $video['shorted_title'] ?></a>
@@ -22,6 +24,9 @@
                <!--<div class="video-username"><?php echo 'TODO: print user name' ?></div>-->
        </div>
 <?php endforeach ?>
+
+<?php echo $pagination ?>
+
 </div>
 
 </div>
index ef62249..0905dc3 100644 (file)
@@ -1,15 +1,37 @@
 <div id="body">
-       <?php foreach($videos as $video):
-               $img_src = $video['thumbs'][ $video['default_thumb'] ];
-               ?>
-               <div class="video-icon">
-                       <img src="<?php echo $img_src ?>" />
+<div id="content">
+
+<?php foreach ($categories as $category_id => $category_name): ?>
+<div class="video-list">
+<h1>
+       <a href="<?php echo site_url("catalog/category/$category_id") ?>">
+               <?php echo $category_name ?>
+       </a>
+</h1>
+
+<?php foreach($videos[$category_id] as $video):
+       $thumb_src = $video['thumbs'][ $video['default_thumb'] ];
+       ?>
+       <div class="video-icon">
+               
+               <div class="video-thumb">
                        <a href="<?php echo $video['video_url'] ?>">
-                               <div class="video-icon_title"><?php echo $video['title'] ?></div>
+                               <img src="<?php echo $thumb_src ?>" />
+                               <div class="video-duration"><?php echo $video['duration'] ?></div>
                        </a>
-                       <div class="video-icon_duration"><?php echo $video['duration'] ?></div>
-                       <div class="video-icon_views"><?php echo $video['views'] . ' views' ?></div>
-                       <!--<div class="video-icon_user"><?php echo 'TODO: print user name' ?></div>-->
-                       <br />
-       <?php endforeach ?>
+               </div>
+               <div class="video-title">
+                       <a href="<?php echo $video['video_url'] ?>">                    
+                       <?php echo $video['shorted_title'] ?></a>
+               </div>          
+               <div class="video-views"><?php echo $video['views'] . ' views' ?></div>
+               <!--<div class="video-username"><?php echo 'TODO: print user name' ?></div>-->
+       </div>
+<?php endforeach ?>
+
+<div style="clear: both"></div>
+</div>
+<?php endforeach ?>
+
+</div>
 </div>
index 12490b2..9ccf899 100644 (file)
@@ -8,11 +8,11 @@
 
 <title><?php echo $title ?></title>
 
-<?php foreach ($stylesheets as $stylesheet): ?>
+<?php foreach ($css as $stylesheet): ?>
 <link rel="stylesheet" type="text/css" href="<?php echo $stylesheet ?>" />
 <?php endforeach ?>
 
-<?php foreach ($javascripts as $javascript): ?>
+<?php foreach ($js as $javascript): ?>
 <script type="text/javascript" src="<?php echo $javascript ?>"></script>
 <?php endforeach ?>
 
index 98aac30..dd9f6d6 100644 (file)
@@ -1,4 +1,7 @@
-<script type="text/javascript">siteUrl = '<?php echo site_url() ?>';</script>
+<!--Javascript initializations-->
+<script type="text/javascript">
+       siteUrl = '<?php echo site_url() ?>';
+</script>
 
 <div id="body">
        <!-- Invalid name in URL-->
                <h1><?php echo $video['title'] ?></h1>
                
                <ul>
-                       <li><a href="javascript: void(0)" onclick="getNsVlcPlugin('<? echo $video['torrents'][0] ?>')">VLC</a></li>
+                       <li><a href="javascript: void(0)" onclick="retrieveNsVlcPlugin('<? echo $video['torrents'][0] ?>')">VLC</a></li>
                
-                       <li><a href="javascript: void(0)" onclick="getNsHtml5Plugin('<?php echo 'tribe://'. $video['torrents'][0] ?>')">HTML5</a></li>
+                       <li><a href="javascript: void(0)" onclick="retrieveNsHtml5Plugin('<?php echo 'tribe://'. $video['torrents'][0] ?>')">HTML5</a></li>
                </ul>
                
                <div id="video_plugin"></div>
                <!--TODO preload user preferred plugin-->
-               <script type="text/javascript"> getNsHtml5Plugin('<?php echo 'tribe://'. $video['torrents'][0] ?>') </script>
+               <script type="text/javascript"> retrieveNsHtml5Plugin('<?php echo 'tribe://'. $video['torrents'][0] ?>') </script>
                
                <!--TODO user name-->
                <!--TODO change format controls-->
similarity index 50%
rename from stylesheets/catalog.css
rename to css/catalog.css
index 3ee4581..eba58b2 100644 (file)
        height: 190px;
        margin-right: 8px;
 }
+
 .video-icon .video-thumb
 {
        position: relative;
-       width: 128px;
-       height: 98px;
-       background: url('/LivingLab/img/thumb_container.png') no-repeat left top;
+       width: 132px;
+       height: 99px;
+       background: url('/devel/img/thumb_container.png') no-repeat left top;
 }
-.video-icon .video-thumb img
+.video-icon .video-thumb img
 {
        position: absolute;
        margin: auto;
-       left: 4px;
+       left: 6px;
        top: 4px;
 }
-.video-icon .video-thumb .video-duration
+.video-icon .video-thumb .video-duration
 {
        position: absolute;
-       right: 5px;
+       right: 6px;
        bottom: 5px;
        font-size: 10px;
        font-weight: bold;
        color: white;
        background: black;
 }
+.video-icon .video-thumb a
+{
+       border-style: none;
+       text-decoration: none;
+}
 
-Scorpions - Wind of Change / Gloria Gaynor - I Will Survive
-Independenta Romaniei: Rasboiul Romano-Ruso-Turc 1877
\ No newline at end of file
+.video-icon .video-title
+{
+       font-size: 12px;
+}
+.video-icon .video-views
+{
+       font-size: 12px;
+}
\ No newline at end of file
diff --git a/css/default.css b/css/default.css
new file mode 100644 (file)
index 0000000..5e8e017
--- /dev/null
@@ -0,0 +1,47 @@
+body
+{
+       font-family: Arial, Helvetica, sans-serif;
+       font-size: 13px;
+       background: white url('/devel/img/bg.png') repeat-x left top;
+}
+
+a:link
+{
+       color: rgb(0,90,192);
+       text-decoration: none;
+}
+a:visited
+{
+       color: rgb(0,56,112);
+}
+a:hover, a:active
+{
+       text-decoration: underline;
+}
+
+#header
+{
+       clear: both;
+}
+
+#body
+{
+       position: relative;
+}
+
+#content
+{
+       float: left;
+       width: 616px;
+       padding: 12px;
+}
+
+#footer
+{
+       clear: both;
+}
+
+.pagination
+{
+       clear: both;
+}
similarity index 100%
rename from stylesheets/jquery-ui.css
rename to css/jquery-ui.css
diff --git a/img/bg.png b/img/bg.png
new file mode 100644 (file)
index 0000000..8a64257
Binary files /dev/null and b/img/bg.png differ
index 0a3a70f..e83a93c 100644 (file)
Binary files a/img/thumb_container.png and b/img/thumb_container.png differ
diff --git a/img/thumb_container02.png b/img/thumb_container02.png
new file mode 100644 (file)
index 0000000..3db86b4
Binary files /dev/null and b/img/thumb_container02.png differ
similarity index 100%
rename from javascript/default.js
rename to js/default.js
similarity index 100%
rename from javascript/jquery.js
rename to js/jquery.js
similarity index 100%
rename from javascript/jquery.min.js
rename to js/jquery.min.js
similarity index 62%
rename from javascript/video.js
rename to js/video.js
index 284e7ee..2e0f574 100644 (file)
@@ -1,7 +1,11 @@
+/**
+ * Video page client scripting (AJAX, events etc.)
+ */
+
 // Usually replaced in PHP
 siteUrl = '/';
 
-function getNsVlcPlugin(videoUrl)
+function retrieveNsVlcPlugin(videoUrl)
 {
        $.post(
                siteUrl + 'video/plugin/ns-vlc',
@@ -12,7 +16,7 @@ function getNsVlcPlugin(videoUrl)
        );
 }
 
-function getNsHtml5Plugin(videoUrl)
+function retrieveNsHtml5Plugin(videoUrl)
 {
        $.post(
                siteUrl + 'video/plugin/ns-html5',
@@ -21,4 +25,9 @@ function getNsHtml5Plugin(videoUrl)
                        $('#video_plugin').html(data);
                }
        );
-}
\ No newline at end of file
+}
+
+/*$(document).ready(function()
+{
+       $       
+}*/
\ No newline at end of file
diff --git a/stylesheets/default.css b/stylesheets/default.css
deleted file mode 100644 (file)
index 4ed1cd3..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-body
-{ 
-       font-size: 13px;
-}
-
-#header
-{
-       clear: both;
-}
-
-#body
-{
-       position: relative;
-}
-
-#content
-{
-       float: left;
-       width: 640px;
-       padding: 12px;
-       outline: 1px solid gray; /*TODO*/
-}
-
-#footer
-{
-       clear: both;
-}