From ad7daf2de4288cff974e97ec9290533ba732df3b Mon Sep 17 00:00:00 2001 From: Calin Burloiu Date: Thu, 25 Aug 2011 13:07:36 +0300 Subject: [PATCH] article engine for static pages was integrated --- .buildpath | 5 ++ .project | 28 ++++++++ .settings/.jsdtscope | 12 ++++ .settings/org.eclipse.php.core.prefs | 3 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + application/config/config.php | 27 +++++++ application/config/routes.php | 6 +- application/controllers/admin.php | 2 +- application/controllers/article.php | 57 +++++++++++++++ application/controllers/catalog.php | 8 +-- application/controllers/help.php | 18 ----- application/controllers/tmp.php | 2 +- application/controllers/video.php | 2 +- application/core/Article_Controller.php | 70 +++++++++++++++++++ application/language/english/article_lang.php | 6 ++ .../language/romanian/article_lang.php | 6 ++ application/language/romanian/ui_lang.php | 11 +++ application/models/videos_model.php | 32 +++++---- application/views/article/english/about.php | 1 + application/views/article/english/help.php | 1 + application/views/article/romanian/about.php | 1 + application/views/article/romanian/help.php | 1 + application/views/echo.php | 4 ++ application/views/header.php | 23 +++--- docs/links.txt | 1 + system/core/Controller.php | 50 +++++++++++++ system/core/Model.php | 50 +++++++++++++ 28 files changed, 377 insertions(+), 52 deletions(-) create mode 100644 .buildpath create mode 100644 .project create mode 100644 .settings/.jsdtscope create mode 100644 .settings/org.eclipse.php.core.prefs create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 application/controllers/article.php delete mode 100644 application/controllers/help.php create mode 100644 application/core/Article_Controller.php create mode 100644 application/language/english/article_lang.php create mode 100644 application/language/romanian/article_lang.php create mode 100644 application/views/article/english/about.php create mode 100644 application/views/article/english/help.php create mode 100644 application/views/article/romanian/about.php create mode 100644 application/views/article/romanian/help.php create mode 100644 application/views/echo.php create mode 100644 docs/links.txt diff --git a/.buildpath b/.buildpath new file mode 100644 index 0000000..8bcb4b5 --- /dev/null +++ b/.buildpath @@ -0,0 +1,5 @@ + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..c4351b7 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + P2PTube + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.dltk.core.scriptbuilder + + + + + + org.eclipse.php.core.PHPNature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..b13d303 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.settings/org.eclipse.php.core.prefs b/.settings/org.eclipse.php.core.prefs new file mode 100644 index 0000000..071a66b --- /dev/null +++ b/.settings/org.eclipse.php.core.prefs @@ -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 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -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 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/application/config/config.php b/application/config/config.php index 1402953..10b45e0 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -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; + } + } +} + diff --git a/application/config/routes.php b/application/config/routes.php index 4397b79..8b85ff6 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -40,9 +40,13 @@ $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 */ diff --git a/application/controllers/admin.php b/application/controllers/admin.php index 3d38865..2951570 100644 --- a/application/controllers/admin.php +++ b/application/controllers/admin.php @@ -1,7 +1,7 @@ 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 */ diff --git a/application/controllers/catalog.php b/application/controllers/catalog.php index 7dee3e9..23a2f17 100644 --- a/application/controllers/catalog.php +++ b/application/controllers/catalog.php @@ -1,7 +1,7 @@ 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 index 927480d..0000000 --- a/application/controllers/help.php +++ /dev/null @@ -1,18 +0,0 @@ -_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 index 0000000..761e696 --- /dev/null +++ b/application/language/english/article_lang.php @@ -0,0 +1,6 @@ + from DB - * * shorted_title => ellipsized title - * * video_url => P2P-Tube video URl - * * TODO: user_id, user_name - * * thumbs => thumbnail images' URLs + * */ 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 + * */ 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 index 0000000..204d9c4 --- /dev/null +++ b/application/views/article/english/about.php @@ -0,0 +1 @@ +About us! \ 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 index 0000000..30b2de3 --- /dev/null +++ b/application/views/article/english/help.php @@ -0,0 +1 @@ +TODO Help \ 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 index 0000000..3791331 --- /dev/null +++ b/application/views/article/romanian/about.php @@ -0,0 +1 @@ +Despre noi! \ 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 index 0000000..53d5b38 --- /dev/null +++ b/application/views/article/romanian/help.php @@ -0,0 +1 @@ +TODO Ajutor \ No newline at end of file diff --git a/application/views/echo.php b/application/views/echo.php new file mode 100644 index 0000000..3c94e8c --- /dev/null +++ b/application/views/echo.php @@ -0,0 +1,4 @@ + +
+ + -