article engine for static pages was integrated
authorCalin Burloiu <calin.burloiu@gmail.com>
Thu, 25 Aug 2011 10:07:36 +0000 (13:07 +0300)
committerCalin Burloiu <calin.burloiu@gmail.com>
Thu, 25 Aug 2011 10:07:36 +0000 (13:07 +0300)
28 files changed:
.buildpath [new file with mode: 0644]
.project [new file with mode: 0644]
.settings/.jsdtscope [new file with mode: 0644]
.settings/org.eclipse.php.core.prefs [new file with mode: 0644]
.settings/org.eclipse.wst.jsdt.ui.superType.container [new file with mode: 0644]
.settings/org.eclipse.wst.jsdt.ui.superType.name [new file with mode: 0644]
application/config/config.php
application/config/routes.php
application/controllers/admin.php
application/controllers/article.php [new file with mode: 0644]
application/controllers/catalog.php
application/controllers/help.php [deleted file]
application/controllers/tmp.php
application/controllers/video.php
application/core/Article_Controller.php [new file with mode: 0644]
application/language/english/article_lang.php [new file with mode: 0644]
application/language/romanian/article_lang.php [new file with mode: 0644]
application/language/romanian/ui_lang.php
application/models/videos_model.php
application/views/article/english/about.php [new file with mode: 0644]
application/views/article/english/help.php [new file with mode: 0644]
application/views/article/romanian/about.php [new file with mode: 0644]
application/views/article/romanian/help.php [new file with mode: 0644]
application/views/echo.php [new file with mode: 0644]
application/views/header.php
docs/links.txt [new file with mode: 0644]
system/core/Controller.php
system/core/Model.php

diff --git a/.buildpath b/.buildpath
new file mode 100644 (file)
index 0000000..8bcb4b5
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<buildpath>
+       <buildpathentry kind="src" path=""/>
+       <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
+</buildpath>
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..c4351b7
--- /dev/null
+++ b/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>P2PTube</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.wst.validation.validationbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.dltk.core.scriptbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.php.core.PHPNature</nature>
+               <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+       </natures>
+</projectDescription>
diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope
new file mode 100644 (file)
index 0000000..b13d303
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path=""/>
+       <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+               <attributes>
+                       <attribute name="hide" value="true"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+       <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/.settings/org.eclipse.php.core.prefs b/.settings/org.eclipse.php.core.prefs
new file mode 100644 (file)
index 0000000..071a66b
--- /dev/null
@@ -0,0 +1,3 @@
+#Thu Aug 25 11:41:32 EEST 2011
+eclipse.preferences.version=1
+include_path=0;/P2PTube
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644 (file)
index 0000000..3bd5d0a
--- /dev/null
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644 (file)
index 0000000..05bd71b
--- /dev/null
@@ -0,0 +1 @@
+Window
\ No newline at end of file
index 1402953..10b45e0 100644 (file)
@@ -358,3 +358,30 @@ $config['rewrite_short_tags'] = FALSE;
 $config['proxy_ips'] = '';
 
 
+/*
+| -------------------------------------------------------------------
+|  Native Autoload - by Phil Sturgeon.
+| -------------------------------------------------------------------
+|
+| Nothing to do with config/autoload.php, this allows PHP autoload to work
+| for base controllers and some third-party libraries.
+|
+| If using HMVC you do not need this! HMVC will autoload.
+|
+| Place this code at the bottom of your application/config/config.php file.
+*/
+function __autoload($class)
+{
+    if (strpos($class, 'CI_') !== 0)
+    {
+        if (file_exists($file = APPPATH . 'core/' . $class . EXT))
+        {
+            include $file;
+        }
+        elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
+        {
+            include $file;
+        }
+    }
+} 
+
index 4397b79..8b85ff6 100644 (file)
 
 $route['default_controller'] = "catalog";
 $route['404_override'] = '';
-
+// Watch pages
 $route['watch/([\d]+)/?'] = "video/watch/$1";
 $route['watch/([\d]+)/(.+)'] = "video/watch/$1/$2";
+// Article pages
+$route['about'] = 'article/about';
+$route['help'] = 'article/help';
+
 
 
 /* End of file routes.php */
index 3d38865..2951570 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Class Admin controlls site administration features
+ * Class Admin controls site administration features
  *
  * @category   Controller
  * @author             Călin-Andrei Burloiu
diff --git a/application/controllers/article.php b/application/controllers/article.php
new file mode 100644 (file)
index 0000000..dda09f7
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Class Article typically controls static pages.
+ * Their content depends on the language.
+ *
+ * The page views are located in "application/views/article/$language/$method".
+ * Article's name can be set in language file 'article_lang.php' by using an
+ * entry named "article_$method". If not present "$method" is used as a name.
+ * Article meta description has the entry "article_$method_description"
+ *
+ * @category   Controller
+ * @author             Călin-Andrei Burloiu
+ */
+class Article extends Article_Controller {
+
+       public function _remap($method, $params = array())
+       {
+               // **
+               // ** DATA
+               // **
+               $this->lang->load('article');
+               $title = $this->lang->line("article_$method");
+               if ($title == FALSE)
+                       $title = $method;
+               $descr = $this->lang->line("article_${method}_description");
+               if ($descr == FALSE)
+                       $descr = '';
+               
+               $html_params = array(   'title' => 
+                                                               $title.' - '. $this->config->item('site_name'),
+                                                       'css' => array(
+                                                               'jquery-ui.css'
+                                                               ),
+                                                       //'js' => array(),
+                                                       'metas' => array('description'=>$descr)
+                                                       );
+               $this->load->library('html_head_params', $html_params);
+
+               // **
+               // ** LOADING VIEWS
+               // **
+               $this->load->view('html_begin', $this->html_head_params);
+               $this->load->view('header', array('selected_menu' => $method));
+               
+               $this->load->view('echo', 
+                       array('output' => $this->_load($method, $params),
+                               'clear' => TRUE)
+                       );
+               
+               $this->load->view('footer');
+               $this->load->view('html_end');
+       }
+}
+
+/* End of file article.php */
+/* Location: ./application/controllers/article.php */
index 7dee3e9..23a2f17 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Class Catalog controlls video hierarchy and searching
+ * Class Catalog controls video hierarchy and searching
  *
  * @category   Controller
  * @author             Călin-Andrei Burloiu
@@ -55,7 +55,7 @@ class Catalog extends CI_Controller {
                // ** LOADING VIEWS
                // **
                $this->load->view('html_begin', $this->html_head_params);
-               $this->load->view('header', array('selected_menu' => 'Home'));
+               $this->load->view('header', array('selected_menu' => 'home'));
                
                $this->load->view('catalog/index_view', $data);
                
@@ -65,11 +65,7 @@ class Catalog extends CI_Controller {
        
        public function test($page = 0)
        {
-               $this->load->helper('url');
                
-               $str = '800x600';
-               
-               echo substr($str, strpos($str, 'x') + 1);
        }
        
        public function category($category_id, $offset = 0)
diff --git a/application/controllers/help.php b/application/controllers/help.php
deleted file mode 100644 (file)
index 927480d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-/**
- * Class Help controlls site's help, support, contact, feedback etc. features
- *
- * @category   Controller
- * @author             Călin-Andrei Burloiu
- */
-class Help extends CI_Controller {
-       
-       public function index()
-       {
-               
-       }
-}
-
-/* End of file help.php */
-/* Location: ./application/controllers/help.php */
index 346acb5..44dc7c0 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Class Tmp controlls video hierarchy and searching
+ * Class Tmp controls video hierarchy and searching
  *
  * @category   Controller
  * @author             Călin-Andrei Burloiu
index 15de407..6f22400 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Class Video controlls video items handling: watching, commenting, rating,
+ * Class Video controls video items handling: watching, commenting, rating,
  * adding etc.
  *
  * @category   Controller
diff --git a/application/core/Article_Controller.php b/application/core/Article_Controller.php
new file mode 100644 (file)
index 0000000..f98bb11
--- /dev/null
@@ -0,0 +1,70 @@
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * Library Article_Controller can be extended by a controller to be used for 
+ * content pages that depend on the language.
+ *
+ * Several language specific parameters can be coded in language files.
+ * Non language specific parameters can be putted in config files.
+ *
+ * @category   Library
+ * @author             Călin-Andrei Burloiu
+ */
+class Article_Controller extends CI_Controller {
+       
+       function __construct()
+       {
+               parent::__construct();
+       }
+       
+       /**
+        * Override this with site specific information (header, menus...) and call
+        * $this->_load which is a generic method that loads the article.
+        * Both parameters must be passed to $this->_load.
+        */
+       public function _remap($method, $params = array())
+       {
+               $this->load->view('echo', 
+                       array('output' => $this->_load($method, $params),
+                               'clear' => TRUE)
+                       );
+       }
+       
+       /**
+        * Returns the article based on the language from
+        * "application/views/article/$language/$method".
+        * 
+        * @param       string $method  defines article name
+        * @param       array $params   odd elements are keys and even elements are
+        * their values (eg.: [0] => key, [1] => value etc.). This are going to
+        * be converted to an associative array that is passed to the view if 
+        * $assoc parameter is FALSE. Otherwise this parameter is already an
+        * associative array.
+        * @param       bool $assoc     states whether or not $params is associative
+        */
+       public function _load($method, $params = array(), $assoc = FALSE)
+       {
+               if (! $assoc)
+               {
+                       $alt = 0;
+                       $params_assoc = array();
+                       $prev_val = NULL;
+                       foreach ($params as $i => $val)
+                       {
+                               if ($alt == 0)
+                                       $prev_val = $val;
+                               else if ($alt == 1)
+                                       $params_assoc[$prev_val] = $val;
+                               
+                               $alt = ($alt + 1) % 2;
+                       }
+               }
+               else
+                       $params_assoc = $params;
+               
+               return $this->load->view('article/'. $this->config->item('language')
+                       . '/' . $method, $params_assoc, TRUE);
+       }
+}
+
+/* End of file Article_Controller.php */
+/* Location: ./application/core/Article_Controller.php */
diff --git a/application/language/english/article_lang.php b/application/language/english/article_lang.php
new file mode 100644 (file)
index 0000000..761e696
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+$lang['article_about'] = 'About Us';
+
+/* End of file article_lang.php */
+/* Location: ./application/language/english/article_lang.php */
\ No newline at end of file
diff --git a/application/language/romanian/article_lang.php b/application/language/romanian/article_lang.php
new file mode 100644 (file)
index 0000000..9b3d844
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+$lang['article_about'] = 'Despre noi';
+
+/* End of file article_lang.php */
+/* Location: ./application/language/romanian/article_lang.php */
\ No newline at end of file
index 362ae54..df457a9 100644 (file)
@@ -1,5 +1,14 @@
 <?php
 
+// Navigation Menu
+$lang['ui_nav_menu_home'] = 'Acasă';
+$lang['ui_nav_menu_about'] = 'Despre';
+$lang['ui_nav_menu_log_in'] = 'Autentificare';
+$lang['ui_nav_menu_register'] = 'Înregistrare';
+$lang['ui_nav_menu_help'] = 'Ajutor';
+
+$lang['ui_search'] = 'Search';
+
 // Video Categories
 $lang['ui_categ_movies'] = 'Filme';
 $lang['ui_categ_tech_talks'] = 'TechTalks';
@@ -18,6 +27,8 @@ $lang['ui_by'] = 'de';
 $lang['ui_category'] = 'categoria';
 $lang['ui_tags'] = 'etichete';
 $lang['ui_license'] = 'licență';
+$lang['ui_uploaded_by'] = 'Încărcată de';
+$lang['ui_on_date'] = 'în';
 
 /* End of file ui_lang.php */
 /* Location: ./application/language/romanian/ui_lang.php */
\ No newline at end of file
index 5c97591..922efd4 100644 (file)
@@ -29,11 +29,13 @@ class Videos_model extends CI_Model {
         * @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
-        *   * video_url => P2P-Tube video URl
-        *   * TODO: user_id, user_name
-        *   * thumbs => thumbnail images' URLs
+        * <ul>
+        *   <li>id, name, title, duration, thumbs_count, default_thumb, views => from DB</li>
+        *   <li>shorted_title => ellipsized title</li>
+        *   <li>video_url => P2P-Tube video URl</li>
+        *   <li>TODO: user_id, user_name</li>
+        *   <li>thumbs => thumbnail images' URLs</li>
+        * </ul>
         */
        public function get_videos_summary($category_id, $offset, $count)
        {
@@ -101,17 +103,19 @@ class Videos_model extends CI_Model {
         * table. NULL means there is no name provided.
         * @return              array   an associative list with information about a video
         * with the following keys:
-        *   * all columns form DB with some exceptions that are overwritten or new
-        *   * formats content is moved in assets
-        *   * assets => list of associative lists where each one represents a
+        * <ul>
+        *   <li>all columns form DB with some exceptions that are overwritten or new</li>
+        *   <li>content is moved in assets</li>
+        *   <li>assets => list of associative lists where each one represents a</li>
         * video asset having keys: "src", "res", "par" and "ext". Value of key
         * "src" is the video torrent formated as
-        * {name}_{format}.{video_ext}.{default_torrent_ext}
-        *   * user_name => TODO: user name from `users` table
-        *   * category_title => a human-friendly category name
-        *   * tags => associative list of "tag => score"
-        *   * date => date and time when the video was created
-        *   * thumbs => thumbnail images' URLs
+        * {name}_{format}.{video_ext}.{default_torrent_ext}</li>
+        *   <li>user_name => TODO: user name from `users` table</li>
+        *   <li>category_title => a human-friendly category name</li>
+        *   <li>tags => associative list of "tag => score"</li>
+        *   <li>date => date and time when the video was created</li>
+        *   <li>thumbs => thumbnail images' URLs</li>
+        * </ul>
         */
        public function get_video($id, $name = NULL)
        {
diff --git a/application/views/article/english/about.php b/application/views/article/english/about.php
new file mode 100644 (file)
index 0000000..204d9c4
--- /dev/null
@@ -0,0 +1 @@
+About <strong>us</strong>!
\ No newline at end of file
diff --git a/application/views/article/english/help.php b/application/views/article/english/help.php
new file mode 100644 (file)
index 0000000..30b2de3
--- /dev/null
@@ -0,0 +1 @@
+TODO <em>Help</em>
\ No newline at end of file
diff --git a/application/views/article/romanian/about.php b/application/views/article/romanian/about.php
new file mode 100644 (file)
index 0000000..3791331
--- /dev/null
@@ -0,0 +1 @@
+Despre <strong>noi</strong>!
\ No newline at end of file
diff --git a/application/views/article/romanian/help.php b/application/views/article/romanian/help.php
new file mode 100644 (file)
index 0000000..53d5b38
--- /dev/null
@@ -0,0 +1 @@
+TODO <em>Ajutor</em>
\ No newline at end of file
diff --git a/application/views/echo.php b/application/views/echo.php
new file mode 100644 (file)
index 0000000..3c94e8c
--- /dev/null
@@ -0,0 +1,4 @@
+<?php if ($clear): ?>
+       <div style="clear: both"></div>
+<?php endif ?>
+<?php echo $output; //print_r(get_defined_vars());
\ No newline at end of file
index e85f5e9..156aef7 100644 (file)
@@ -2,17 +2,20 @@
        $selected_menu = ''; 
 endif ?>
 
-<ul id="nav-menu"><!--
-       Home--><li class="menu-left"><a href="<?php echo site_url() ?>" <?php echo ($selected_menu == 'Home' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_home') ?></a></li><!--
-       About--><li class="menu-left"><a href="#" 
-               <?php echo ($selected_menu == 'About' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_about') ?></a></li><!--
-       Help--><li class="menu-left"><a href="#" 
-               <?php echo ($selected_menu == 'Help' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_help') ?></a></li><!--
+<ul id="nav-menu">
+       <li class="menu-left"><a href="<?php echo site_url() ?>" <?php echo ($selected_menu == 'home' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_home') ?></a></li>
        
-       Register--><li class="menu-right"><a href="#" 
-               <?php echo ($selected_menu == 'Register' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_register') ?></a></li><!--
-       Log In--><li class="menu-right"><a href="#" 
-               <?php echo ($selected_menu == 'Log In' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_log_in') ?></a></li>
+       <li class="menu-left"><a href="<?php echo site_url('about') ?>" 
+               <?php echo ($selected_menu == 'about' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_about') ?></a></li>
+       
+       <li class="menu-left"><a href="<?php echo site_url('help') ?>" 
+               <?php echo ($selected_menu == 'help' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_help') ?></a></li>
+       
+       <li class="menu-right"><a href="#<?php //echo site_url('register') ?>" 
+               <?php echo ($selected_menu == 'register' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_register') ?></a></li>
+               
+       <li class="menu-right"><a href="#<?php //echo site_url('login') ?>" 
+               <?php echo ($selected_menu == 'login' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_log_in') ?></a></li>
 </ul>
 
 <div id="header">
diff --git a/docs/links.txt b/docs/links.txt
new file mode 100644 (file)
index 0000000..7fdff3b
--- /dev/null
@@ -0,0 +1 @@
+* [[http://philsturgeon.co.uk/news/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY|Useful for more basic Controller classes]]
index 469663f..76c5306 100644 (file)
  * @link               http://codeigniter.com/user_guide/general/controllers.html
  */
 class CI_Controller {
+       
+       // TODO remove development declaration (used for Eclipse)
+       /**
+       * @var CI_Config
+       */
+       var $config;
+       /**
+        * @var CI_DB_active_record
+        */
+       var $db;
+       /**
+        * @var CI_Email
+        */
+       var $email;
+       /**
+        * @var CI_Form_validation
+        */
+       var $form_validation;
+       /**
+        * @var CI_Input
+        */
+       var $input;
+       /**
+        * @var CI_Loader
+        */
+       var $load;
+       /**
+        * @var CI_Router
+        */
+       var $router;
+       /**
+        * @var CI_Session
+        */
+       var $session;
+       /**
+        * @var CI_Table
+        */
+       var $table;
+       /**
+        * @var CI_Unit_test
+        */
+       var $unit;
+       /**
+        * @var CI_URI
+        */
+       var $uri;
+       /**
+        * @var CI_Pagination
+        */
+       var $pagination;
 
        private static $instance;
 
index 8566a0b..8dbe57f 100644 (file)
  * @link               http://codeigniter.com/user_guide/libraries/config.html
  */
 class CI_Model {
+       
+       // TODO remove development declaration (used for Eclipse)
+       /**
+        * @var CI_Config
+        */
+       var $config;
+       /**
+        * @var CI_DB_active_record
+        */
+       var $db;
+       /**
+        * @var CI_Email
+        */
+       var $email;
+       /**
+        * @var CI_Form_validation
+        */
+       var $form_validation;
+       /**
+        * @var CI_Input
+        */
+       var $input;
+       /**
+        * @var CI_Loader
+        */
+       var $load;
+       /**
+        * @var CI_Router
+        */
+       var $router;
+       /**
+        * @var CI_Session
+        */
+       var $session;
+       /**
+        * @var CI_Table
+        */
+       var $table;
+       /**
+        * @var CI_Unit_test
+        */
+       var $unit;
+       /**
+        * @var CI_URI
+        */
+       var $uri;
+       /**
+        * @var CI_Pagination
+        */
+       var $pagination;
 
        /**
         * Constructor