Permalink
Browse files

blogs integrated as a block

  • Loading branch information...
1 parent 9489bec commit 056c027035ef3d3129e7989a41de118c7df46146 @jordan-wilson committed May 15, 2012
Showing with 768 additions and 399 deletions.
  1. +33 −0 app/front/controllers/blocks.controller.php
  2. +0 −84 app/front/controllers/blog.controller.php
  3. +182 −0 app/front/controllers/blogs.controller.php
  4. +4 −6 app/front/controllers/forms.controller.php
  5. +63 −61 app/front/controllers/{page.controller.php → pages.controller.php}
  6. +2 −22 app/front/core/controller.php
  7. +1 −1 app/front/core/router.php
  8. +52 −0 app/front/models/blocks.model.php
  9. +18 −14 app/front/models/{blog.model.php → blogs.model.php}
  10. +93 −0 app/front/models/layouts.model.php
  11. +55 −86 app/front/models/{page.model.php → pages.model.php}
  12. +1 −1 index.php
  13. +10 −0 skins/front/default/blocks.blue.template.php
  14. +10 −0 skins/front/default/blocks.default.template.php
  15. +10 −0 skins/front/default/blocks.green.template.php
  16. +0 −30 skins/front/default/blog.landing.template.php
  17. +0 −20 skins/front/default/blog.view.template.php
  18. +12 −0 skins/front/default/blogs.blog.block.template.php
  19. +10 −0 skins/front/default/blogs.categories.block.template.php
  20. +32 −0 skins/front/default/blogs.landing.template.php
  21. +11 −0 skins/front/default/blogs.recent.block.template.php
  22. +5 −0 skins/front/default/blogs.subscribe.block.template.php
  23. +22 −0 skins/front/default/blogs.view.template.php
  24. +0 −20 skins/front/default/css/blog.css
  25. +43 −0 skins/front/default/css/blogs.css
  26. +93 −0 skins/front/default/css/content.css
  27. +0 −51 skins/front/default/css/style.css
  28. +2 −2 skins/front/default/footer.template.php
  29. +1 −0 skins/front/default/header.template.php
  30. 0 skins/front/default/{layout.blog.template.php → layout.blogs.template.php}
  31. +3 −1 skins/front/default/{page.index.template.php → pages.content.template.php}
@@ -0,0 +1,33 @@
+<?php
+
+class blocks extends controller
+{
+
+ public function get_block( $arg = '' )
+ {
+ if (is_numeric($arg))
+ {
+ // get block info
+ $blocks_model = load_model('blocks');
+ $data = $blocks_model->get_block($arg);
+
+ if ( ! count($data)) return '';
+
+ // the template to use for the block
+ $template = 'blocks.default.template.php';
+ if ($data['skin'] != '')
+ {
+ $skin = 'blocks.' . $data['skin'] . '.template.php';
+ $path = SITE_ROOT . '/skins/' . APP . '/' . $this->registry->skin . '/' . $skin;
+ if (file_exists($path))
+ $template = $skin;
+ }
+
+ // load block
+ return load_view($template, $data);
+ }
+
+ return '';
+ }
+
+}
@@ -1,84 +0,0 @@
-<?php
-
-class blog extends controller
-{
-
- public function index( $data = array() )
- {
- if ( ! $this->page) return;
-
- $request = $this->registry->request_args;
-
- // blog landing page
- if (count($request) == 1)
- {
- $this->landing($data);
- return;
- }
- // blog post
- elseif (count($request) == 2)
- {
- $this->view($request[1], $data);
- return;
- }
-
- // show error page
- if (method_exists($this->page, 'error_page'))
- {
- $this->page->error_page();
- }
-
- }
-
-
- private function add_css()
- {
- $css = '/skins/' . APP . '/' . $this->registry->skin . '/css/blog.css';
- $this->registry->add_css_by_url($css);
- }
-
-
- private function landing( $data = array() )
- {
- // get recent blogs
- $blog_model = load_model('blog');
- $data['blogs'] = $blog_model->get_landing();
-
- // add css
- $this->add_css();
-
- // load landing page
- $this->page->content = load_view('blog.landing.template.php', $data);
- }
-
-
- private function view( $url = '', $data = array() )
- {
- // get blog info
- $blog_model = load_model('blog');
- $data['blog'] = $blog_model->get_view($url);
-
- // blog not found
- if ( ! $data['blog'])
- {
- if (method_exists($this->page, 'error_page'))
- {
- $this->page->error_page();
- }
- }
-
- // update meta
- if (method_exists($this->page, 'update_meta'))
- {
- $this->page->update_meta($data['blog']);
- }
-
- // add css
- $this->add_css();
-
- // load blog post
- $this->page->content = load_view('blog.view.template.php', $data);
- }
-
-
-}
@@ -0,0 +1,182 @@
+<?php
+
+class blogs extends controller
+{
+
+ private function add_css()
+ {
+ $css = '/skins/' . APP . '/' . $this->registry->skin . '/css/blogs.css';
+ $this->registry->add_css_by_url($css);
+ }
+
+
+ public function get_block( $arg = '' )
+ {
+ // blog content
+ if ( $arg == 'content' )
+ {
+ $request = $this->registry->request_args;
+
+ // blog landing page
+ if (count($request) == 1)
+ {
+ return $this->index();
+ }
+
+ // blog post
+ elseif (count($request) == 2)
+ {
+ return $this->view( $request[1] );
+ }
+
+ // to many arguments in the url
+ elseif ($this->pages)
+ {
+ if (method_exists($this->pages, 'error_page'))
+ {
+ $this->pages->error_page();
+ }
+ }
+ }
+
+ // individual blog block
+ elseif (is_numeric($arg))
+ {
+ return $this->get_blog_block($arg);
+ }
+
+ // subscribe block
+ elseif ($arg == 'subscribe.block')
+ {
+ return $this->get_subscribe_block();
+ }
+
+ // recent blog post block
+ elseif ($arg == 'recent.block')
+ {
+ return $this->get_recent_block();
+ }
+
+ // blog categories block
+ elseif ($arg == 'categories.block')
+ {
+ return $this->get_categories_block();
+ }
+
+ return '';
+ }
+
+
+ // blogs landing page
+ public function index()
+ {
+ if ( ! $this->pages) return;
+
+ // get page data
+ $data = $this->pages->data;
+
+ // get recent blogs
+ $blogs_model = load_model('blogs');
+ $data['blogs'] = $blogs_model->get_landing();
+
+ // add css
+ $this->add_css();
+
+ // load landing page
+ return load_view('blogs.landing.template.php', $data);
+ }
+
+
+ // individual blog post
+ public function view( $url = '' )
+ {
+ if ( ! $this->pages) return;
+
+ // get page data
+ $data = $this->pages->data;
+
+ // clear default page content
+ $this->registry->page_content = '';
+
+ // get blog info
+ $blogs_model = load_model('blogs');
+ $data['blog'] = $blogs_model->get_view($url);
+
+ // if blog not found
+ if ( ! $data['blog'])
+ {
+ if (method_exists($this->pages, 'error_page'))
+ {
+ $this->pages->error_page();
+ }
+ }
+
+ // update meta
+ if (method_exists($this->pages, 'update_meta'))
+ {
+ $this->pages->update_meta($data['blog']);
+ }
+
+ // add css
+ $this->add_css();
+
+ // load blog post
+ return load_view('blogs.view.template.php', $data);
+ }
+
+
+ // individual blog block
+ private function get_blog_block( $id = 0 )
+ {
+ if ( ! $this->registry->modules['blogs']) return '';
+
+ // get blog info
+ $blogs_model = load_model('blogs');
+ $data['blog'] = $blogs_model->get_blog($id);
+ $data['link'] = '/' . $this->registry->modules['blogs'] . '/';
+
+ // if blog not found
+ if ( ! $data['blog']) return '';
+
+ // add css
+ $this->add_css();
+
+ // load blog post
+ return load_view('blogs.blog.block.template.php', $data);
+ }
+
+
+ // subscribe block
+ private function get_subscribe_block()
+ {
+ if ( ! $this->registry->modules['blogs']) return '';
+ $data['link'] = '/' . $this->registry->modules['blogs'] . '/';
+
+ // load blog subscribe block
+ return load_view('blogs.subscribe.block.template.php', $data);
+ }
+
+
+ // categories block
+ private function get_categories_block()
+ {
+ if ( ! $this->registry->modules['blogs']) return '';
+ $data['link'] = '/' . $this->registry->modules['blogs'] . '/';
+
+ // load blog categories block
+ return load_view('blogs.categories.block.template.php', $data);
+ }
+
+
+ // recent blog post block
+ private function get_recent_block()
+ {
+ if ( ! $this->registry->modules['blogs']) return '';
+ $data['link'] = '/' . $this->registry->modules['blogs'] . '/';
+
+ // load recent blog post block
+ return load_view('blogs.recent.block.template.php', $data);
+ }
+
+
+}
@@ -9,18 +9,15 @@ class forms extends controller
public function get_block( $id = 0 )
{
// check if form is unique
- if (in_array($id, $this->forms))
- return '<p><strong>!!! Form:' . $id . ' already in use on the page. Can only have a single instance of any form on a page.</strong></p>';
+ if (in_array($id, $this->forms)) return '<p>FORM ' . $id . ' IS ALREADY IN USE ON THIS PAGE. YOU CANNOT HAVE MULTIPLE INSTANCES OF A FORM ON A SINGLE PAGE AT ONE TIME.</p>';
$this->forms[] = $id;
-
+ // get the page url
$request = $this->registry->request_args;
if ( ! count($request)) return '';
-
- // the page url
$url = $request[0];
- // check if submitted
+ // check if this form has been submitted
// url would look like this: www.site.com/page/5/submit
$this->submitted = false;
$action = count($request) > 2 ? array_pop($request) : false;
@@ -98,6 +95,7 @@ public function build_form( $id = 0, $url = '', $validate = false )
$html .= $form['content'];
$html .= '</div>';
}
+
// else, return the form
else
{
Oops, something went wrong.

0 comments on commit 056c027

Please sign in to comment.