</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]
| 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';
/*
|--------------------------------------------------------------------------
| 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'] = '';
/*
|--------------------------------------------------------------------------
|
*/
$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;
--- /dev/null
+<?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
*/
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);
$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);
// 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);
/**
* 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'.
*
* 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)
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'];
$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");
}
}
* 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
* * 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');
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)
{
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.
*
<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>
<!--<div class="video-username"><?php echo 'TODO: print user name' ?></div>-->
</div>
<?php endforeach ?>
+
+<?php echo $pagination ?>
+
</div>
</div>
<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>
<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 ?>
-<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-->
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
--- /dev/null
+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;
+}
+/**
+ * Video page client scripting (AJAX, events etc.)
+ */
+
// Usually replaced in PHP
siteUrl = '/';
-function getNsVlcPlugin(videoUrl)
+function retrieveNsVlcPlugin(videoUrl)
{
$.post(
siteUrl + 'video/plugin/ns-vlc',
);
}
-function getNsHtml5Plugin(videoUrl)
+function retrieveNsHtml5Plugin(videoUrl)
{
$.post(
siteUrl + 'video/plugin/ns-html5',
$('#video_plugin').html(data);
}
);
-}
\ No newline at end of file
+}
+
+/*$(document).ready(function()
+{
+ $
+}*/
\ No newline at end of file
+++ /dev/null
-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;
-}