@@ -6,25 +6,25 @@ |
||
| 6 | 6 | abstract class DefaultPageController extends PageController |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - protected $activityRepository; |
|
| 9 | + protected $activityRepository; |
|
| 10 | 10 | |
| 11 | - public function __construct() |
|
| 12 | - { |
|
| 11 | + public function __construct() |
|
| 12 | + { |
|
| 13 | 13 | parent::__construct(); |
| 14 | 14 | |
| 15 | 15 | global $container; |
| 16 | 16 | $this->activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
| 17 | - } |
|
| 18 | - |
|
| 19 | - protected function set_head_data() |
|
| 20 | - { |
|
| 21 | - $this->add_css('normalize'); |
|
| 22 | - $this->add_css('lifestream', 2); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - protected function set_body_data() |
|
| 26 | - { |
|
| 27 | - $this->set_body_view('Page'); |
|
| 28 | - } |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + protected function set_head_data() |
|
| 20 | + { |
|
| 21 | + $this->add_css('normalize'); |
|
| 22 | + $this->add_css('lifestream', 2); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + protected function set_body_data() |
|
| 26 | + { |
|
| 27 | + $this->set_body_view('Page'); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | } |
@@ -5,33 +5,33 @@ |
||
| 5 | 5 | final class AboutController extends DefaultPageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = "About | What's a Lifestream?"; |
|
| 9 | - private static $DESCRIPTION = 'A breakdown of what a lifestream is, why Jacob Emerick made one, and how he made it.'; |
|
| 8 | + private static $TITLE = "About | What's a Lifestream?"; |
|
| 9 | + private static $DESCRIPTION = 'A breakdown of what a lifestream is, why Jacob Emerick made one, and how he made it.'; |
|
| 10 | 10 | |
| 11 | - private static $KEYWORD_ARRAY = array( |
|
| 12 | - 'about', |
|
| 13 | - 'lifestream', |
|
| 14 | - 'feed', |
|
| 15 | - 'activity stream', |
|
| 16 | - 'Jacob Emerick', |
|
| 17 | - 'jpemeric'); |
|
| 11 | + private static $KEYWORD_ARRAY = array( |
|
| 12 | + 'about', |
|
| 13 | + 'lifestream', |
|
| 14 | + 'feed', |
|
| 15 | + 'activity stream', |
|
| 16 | + 'Jacob Emerick', |
|
| 17 | + 'jpemeric'); |
|
| 18 | 18 | |
| 19 | - protected function set_head_data() |
|
| 20 | - { |
|
| 21 | - $this->set_title(self::$TITLE); |
|
| 22 | - $this->set_description(self::$DESCRIPTION); |
|
| 23 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 19 | + protected function set_head_data() |
|
| 20 | + { |
|
| 21 | + $this->set_title(self::$TITLE); |
|
| 22 | + $this->set_description(self::$DESCRIPTION); |
|
| 23 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 24 | 24 | |
| 25 | - parent::set_head_data(); |
|
| 26 | - } |
|
| 25 | + parent::set_head_data(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - protected function set_body_data() |
|
| 29 | - { |
|
| 30 | - $this->set_body('title', "WHAT'S A LIFESTREAM?"); |
|
| 31 | - $this->set_body('type', 'about'); |
|
| 32 | - $this->set_body('view', 'About'); |
|
| 28 | + protected function set_body_data() |
|
| 29 | + { |
|
| 30 | + $this->set_body('title', "WHAT'S A LIFESTREAM?"); |
|
| 31 | + $this->set_body('type', 'about'); |
|
| 32 | + $this->set_body('view', 'About'); |
|
| 33 | 33 | |
| 34 | - parent::set_body_data(); |
|
| 35 | - } |
|
| 34 | + parent::set_body_data(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -5,79 +5,79 @@ |
||
| 5 | 5 | final class HomeController extends DefaultListController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = "Jacob Emerick's Lifestream"; |
|
| 9 | - private static $DESCRIPTION = 'Lifestream for Jacob Emerick, a combination of his latest twitter, youtube, running, reading, and blogging activity.'; |
|
| 8 | + private static $TITLE = "Jacob Emerick's Lifestream"; |
|
| 9 | + private static $DESCRIPTION = 'Lifestream for Jacob Emerick, a combination of his latest twitter, youtube, running, reading, and blogging activity.'; |
|
| 10 | 10 | |
| 11 | - private static $KEYWORD_ARRAY = array( |
|
| 12 | - 'lifestream', |
|
| 13 | - 'activity stream', |
|
| 14 | - 'Jacob Emerick', |
|
| 15 | - 'jacobemerick', |
|
| 16 | - 'jpemeric', |
|
| 17 | - 'twitter'); |
|
| 11 | + private static $KEYWORD_ARRAY = array( |
|
| 12 | + 'lifestream', |
|
| 13 | + 'activity stream', |
|
| 14 | + 'Jacob Emerick', |
|
| 15 | + 'jacobemerick', |
|
| 16 | + 'jpemeric', |
|
| 17 | + 'twitter'); |
|
| 18 | 18 | |
| 19 | - private static $LIST_DESCRIPTION = 'viewing %d - %d of %d total activities'; |
|
| 19 | + private static $LIST_DESCRIPTION = 'viewing %d - %d of %d total activities'; |
|
| 20 | 20 | |
| 21 | - protected function set_head_data() |
|
| 22 | - { |
|
| 23 | - $this->set_title(self::$TITLE); |
|
| 24 | - $this->set_description(self::$DESCRIPTION); |
|
| 25 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 21 | + protected function set_head_data() |
|
| 22 | + { |
|
| 23 | + $this->set_title(self::$TITLE); |
|
| 24 | + $this->set_description(self::$DESCRIPTION); |
|
| 25 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 26 | 26 | |
| 27 | - parent::set_head_data(); |
|
| 28 | - } |
|
| 27 | + parent::set_head_data(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - protected function set_body_data() |
|
| 31 | - { |
|
| 32 | - $this->set_body('title', "What's Jacob Up To?"); |
|
| 33 | - $this->set_body('description', "A combination of Jacob Emerick's tweets, runs, reads, blogs, and YouTubes all in <em>one awesome lifestream</em>."); |
|
| 30 | + protected function set_body_data() |
|
| 31 | + { |
|
| 32 | + $this->set_body('title', "What's Jacob Up To?"); |
|
| 33 | + $this->set_body('description', "A combination of Jacob Emerick's tweets, runs, reads, blogs, and YouTubes all in <em>one awesome lifestream</em>."); |
|
| 34 | 34 | |
| 35 | - parent::set_body_data(); |
|
| 36 | - } |
|
| 35 | + parent::set_body_data(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - protected function get_page_number() |
|
| 39 | - { |
|
| 40 | - $page = URLDecode::getPiece(2); |
|
| 41 | - if(isset($page) && is_numeric($page)) |
|
| 42 | - return $page; |
|
| 43 | - return 1; |
|
| 44 | - } |
|
| 38 | + protected function get_page_number() |
|
| 39 | + { |
|
| 40 | + $page = URLDecode::getPiece(2); |
|
| 41 | + if(isset($page) && is_numeric($page)) |
|
| 42 | + return $page; |
|
| 43 | + return 1; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - protected function get_list_results() |
|
| 47 | - { |
|
| 46 | + protected function get_list_results() |
|
| 47 | + { |
|
| 48 | 48 | return $this->activityRepository->getActivities(self::$POSTS_PER_PAGE, $this->offset); |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function get_list_description() |
|
| 52 | - { |
|
| 53 | - $start = $this->offset + 1; |
|
| 54 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
| 51 | + protected function get_list_description() |
|
| 52 | + { |
|
| 53 | + $start = $this->offset + 1; |
|
| 54 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
| 55 | 55 | |
| 56 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
| 57 | - } |
|
| 56 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - protected function get_list_next_link() |
|
| 60 | - { |
|
| 61 | - if($this->page == 1) |
|
| 62 | - return; |
|
| 63 | - if($this->page == 2) |
|
| 64 | - return Loader::getRootUrl('lifestream'); |
|
| 65 | - return Loader::getRootUrl('lifestream') . 'page/' . ($this->page - 1) . '/'; |
|
| 66 | - } |
|
| 59 | + protected function get_list_next_link() |
|
| 60 | + { |
|
| 61 | + if($this->page == 1) |
|
| 62 | + return; |
|
| 63 | + if($this->page == 2) |
|
| 64 | + return Loader::getRootUrl('lifestream'); |
|
| 65 | + return Loader::getRootUrl('lifestream') . 'page/' . ($this->page - 1) . '/'; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - protected function get_list_prev_link() |
|
| 69 | - { |
|
| 70 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 71 | - return; |
|
| 72 | - return Loader::getRootUrl('lifestream') . 'page/' . ($this->page + 1) . '/'; |
|
| 73 | - } |
|
| 68 | + protected function get_list_prev_link() |
|
| 69 | + { |
|
| 70 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 71 | + return; |
|
| 72 | + return Loader::getRootUrl('lifestream') . 'page/' . ($this->page + 1) . '/'; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - private $total_post_count; |
|
| 76 | - protected function get_total_post_count() |
|
| 77 | - { |
|
| 78 | - if(!isset($this->total_post_count)) |
|
| 79 | - $this->total_post_count = $this->activityRepository->getActivitiesCount(); |
|
| 80 | - return $this->total_post_count; |
|
| 81 | - } |
|
| 75 | + private $total_post_count; |
|
| 76 | + protected function get_total_post_count() |
|
| 77 | + { |
|
| 78 | + if(!isset($this->total_post_count)) |
|
| 79 | + $this->total_post_count = $this->activityRepository->getActivitiesCount(); |
|
| 80 | + return $this->total_post_count; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | } |
@@ -5,20 +5,20 @@ |
||
| 5 | 5 | class Error503Controller extends PageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function set_head_data() |
|
| 9 | - { |
|
| 10 | - $this->set_header_method('send503'); |
|
| 11 | - $this->add_css('normalize'); |
|
| 12 | - $this->add_css('503'); |
|
| 8 | + protected function set_head_data() |
|
| 9 | + { |
|
| 10 | + $this->set_header_method('send503'); |
|
| 11 | + $this->add_css('normalize'); |
|
| 12 | + $this->add_css('503'); |
|
| 13 | 13 | |
| 14 | - $this->set_title("Jacob Emerick's 503 Page"); |
|
| 15 | - $this->set_description('Global 503 page for sites under jacobemerick.com. Page not found!'); |
|
| 16 | - $this->set_keywords(array()); |
|
| 17 | - } |
|
| 14 | + $this->set_title("Jacob Emerick's 503 Page"); |
|
| 15 | + $this->set_description('Global 503 page for sites under jacobemerick.com. Page not found!'); |
|
| 16 | + $this->set_keywords(array()); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - protected function set_body_data() |
|
| 20 | - { |
|
| 21 | - $this->set_body_view('/503'); |
|
| 22 | - } |
|
| 19 | + protected function set_body_data() |
|
| 20 | + { |
|
| 21 | + $this->set_body_view('/503'); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | } |
@@ -5,13 +5,13 @@ |
||
| 5 | 5 | class Error301Controller extends PageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public function __construct($uri) |
|
| 9 | - { |
|
| 10 | - Header::redirect($uri); |
|
| 11 | - exit; |
|
| 12 | - } |
|
| 8 | + public function __construct($uri) |
|
| 9 | + { |
|
| 10 | + Header::redirect($uri); |
|
| 11 | + exit; |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - protected function set_head_data() {} |
|
| 15 | - protected function set_body_data() {} |
|
| 14 | + protected function set_head_data() {} |
|
| 15 | + protected function set_body_data() {} |
|
| 16 | 16 | |
| 17 | 17 | } |
@@ -1,60 +1,60 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', array( |
| 4 | - 'Header', |
|
| 5 | - 'Request')); |
|
| 4 | + 'Header', |
|
| 5 | + 'Request')); |
|
| 6 | 6 | |
| 7 | 7 | abstract class AJAXController |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - private static $RESPONSE_HEADER = 'sendJSON'; |
|
| 10 | + private static $RESPONSE_HEADER = 'sendJSON'; |
|
| 11 | 11 | |
| 12 | - private $response = array(); |
|
| 12 | + private $response = array(); |
|
| 13 | 13 | |
| 14 | - abstract protected function set_data(); |
|
| 14 | + abstract protected function set_data(); |
|
| 15 | 15 | |
| 16 | - function __construct() {} |
|
| 16 | + function __construct() {} |
|
| 17 | 17 | |
| 18 | - public function activate() |
|
| 19 | - { |
|
| 20 | - call_user_func(array('Header', self::$RESPONSE_HEADER)); |
|
| 18 | + public function activate() |
|
| 19 | + { |
|
| 20 | + call_user_func(array('Header', self::$RESPONSE_HEADER)); |
|
| 21 | 21 | |
| 22 | - $this->set_data(); |
|
| 23 | - echo $this->response_as_json(); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - protected function set_response($message, $type = 'internal') |
|
| 27 | - { |
|
| 28 | - switch($type) |
|
| 29 | - { |
|
| 30 | - case 'internal' : |
|
| 31 | - $this->response['internal'] = $message; |
|
| 32 | - break; |
|
| 33 | - case 'error' : |
|
| 34 | - $this->response['error'] = $message; |
|
| 35 | - default : |
|
| 36 | - $this->response[$type] = $message; |
|
| 37 | - break; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - protected function fail_response($message) |
|
| 42 | - { |
|
| 43 | - $this->set_response($message, 'error'); |
|
| 44 | - return false; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - protected function eject($message) |
|
| 48 | - { |
|
| 49 | - $this->fail_response($message); |
|
| 50 | - echo $this->response_as_json(); |
|
| 51 | - exit(); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - private function response_as_json() |
|
| 55 | - { |
|
| 56 | - return json_encode($this->response); |
|
| 57 | - } |
|
| 22 | + $this->set_data(); |
|
| 23 | + echo $this->response_as_json(); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + protected function set_response($message, $type = 'internal') |
|
| 27 | + { |
|
| 28 | + switch($type) |
|
| 29 | + { |
|
| 30 | + case 'internal' : |
|
| 31 | + $this->response['internal'] = $message; |
|
| 32 | + break; |
|
| 33 | + case 'error' : |
|
| 34 | + $this->response['error'] = $message; |
|
| 35 | + default : |
|
| 36 | + $this->response[$type] = $message; |
|
| 37 | + break; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + protected function fail_response($message) |
|
| 42 | + { |
|
| 43 | + $this->set_response($message, 'error'); |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + protected function eject($message) |
|
| 48 | + { |
|
| 49 | + $this->fail_response($message); |
|
| 50 | + echo $this->response_as_json(); |
|
| 51 | + exit(); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + private function response_as_json() |
|
| 55 | + { |
|
| 56 | + return json_encode($this->response); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
@@ -5,15 +5,15 @@ |
||
| 5 | 5 | abstract class DefaultPageController extends PageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - protected function set_head_data() |
|
| 9 | - { |
|
| 10 | - $this->add_css('normalize'); |
|
| 11 | - $this->add_css('home'); |
|
| 12 | - } |
|
| 8 | + protected function set_head_data() |
|
| 9 | + { |
|
| 10 | + $this->add_css('normalize'); |
|
| 11 | + $this->add_css('home'); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - protected function set_body_data() |
|
| 15 | - { |
|
| 16 | - $this->set_body('activity_array', $this->get_recent_activity()); |
|
| 17 | - } |
|
| 14 | + protected function set_body_data() |
|
| 15 | + { |
|
| 16 | + $this->set_body('activity_array', $this->get_recent_activity()); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | } |
@@ -5,32 +5,32 @@ |
||
| 5 | 5 | final class AboutController extends DefaultPageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = 'About | Jacob Emerick'; |
|
| 9 | - private static $DESCRIPTION = 'Some basic information about Jacob Emerick and his past, web development, and hiking adventures'; |
|
| 8 | + private static $TITLE = 'About | Jacob Emerick'; |
|
| 9 | + private static $DESCRIPTION = 'Some basic information about Jacob Emerick and his past, web development, and hiking adventures'; |
|
| 10 | 10 | |
| 11 | - private static $KEYWORD_ARRAY = array( |
|
| 12 | - 'Jacob Emerick', |
|
| 13 | - 'jacobemerick', |
|
| 14 | - 'jpemeric', |
|
| 15 | - 'about', |
|
| 16 | - 'bio', |
|
| 17 | - 'web developer', |
|
| 18 | - 'hiker'); |
|
| 11 | + private static $KEYWORD_ARRAY = array( |
|
| 12 | + 'Jacob Emerick', |
|
| 13 | + 'jacobemerick', |
|
| 14 | + 'jpemeric', |
|
| 15 | + 'about', |
|
| 16 | + 'bio', |
|
| 17 | + 'web developer', |
|
| 18 | + 'hiker'); |
|
| 19 | 19 | |
| 20 | - protected function set_head_data() |
|
| 21 | - { |
|
| 22 | - $this->set_title(self::$TITLE); |
|
| 23 | - $this->set_description(self::$DESCRIPTION); |
|
| 24 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 20 | + protected function set_head_data() |
|
| 21 | + { |
|
| 22 | + $this->set_title(self::$TITLE); |
|
| 23 | + $this->set_description(self::$DESCRIPTION); |
|
| 24 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 25 | 25 | |
| 26 | - parent::set_head_data(); |
|
| 27 | - } |
|
| 26 | + parent::set_head_data(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - protected function set_body_data() |
|
| 30 | - { |
|
| 31 | - $this->set_body_view('About'); |
|
| 29 | + protected function set_body_data() |
|
| 30 | + { |
|
| 31 | + $this->set_body_view('About'); |
|
| 32 | 32 | |
| 33 | - parent::set_body_data(); |
|
| 34 | - } |
|
| 33 | + parent::set_body_data(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -5,73 +5,73 @@ |
||
| 5 | 5 | final class ContactController extends DefaultPageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TITLE = 'Contact | Jacob Emerick'; |
|
| 9 | - private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
| 8 | + private static $TITLE = 'Contact | Jacob Emerick'; |
|
| 9 | + private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
| 10 | 10 | |
| 11 | - private static $KEYWORD_ARRAY = array( |
|
| 12 | - 'Jacob Emerick', |
|
| 13 | - 'jacobemerick', |
|
| 14 | - 'jpemeric', |
|
| 15 | - 'contact', |
|
| 16 | - 'email', |
|
| 17 | - 'connect'); |
|
| 11 | + private static $KEYWORD_ARRAY = array( |
|
| 12 | + 'Jacob Emerick', |
|
| 13 | + 'jacobemerick', |
|
| 14 | + 'jpemeric', |
|
| 15 | + 'contact', |
|
| 16 | + 'email', |
|
| 17 | + 'connect'); |
|
| 18 | 18 | |
| 19 | - protected function set_head_data() |
|
| 20 | - { |
|
| 21 | - $this->set_title(self::$TITLE); |
|
| 22 | - $this->set_description(self::$DESCRIPTION); |
|
| 23 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 19 | + protected function set_head_data() |
|
| 20 | + { |
|
| 21 | + $this->set_title(self::$TITLE); |
|
| 22 | + $this->set_description(self::$DESCRIPTION); |
|
| 23 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
| 24 | 24 | |
| 25 | - parent::set_head_data(); |
|
| 26 | - } |
|
| 25 | + parent::set_head_data(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - protected function set_body_data() |
|
| 29 | - { |
|
| 30 | - $this->set_body('form_container', $this->process_form()); |
|
| 31 | - $this->set_body_view('Contact'); |
|
| 28 | + protected function set_body_data() |
|
| 29 | + { |
|
| 30 | + $this->set_body('form_container', $this->process_form()); |
|
| 31 | + $this->set_body_view('Contact'); |
|
| 32 | 32 | |
| 33 | - parent::set_body_data(); |
|
| 34 | - } |
|
| 33 | + parent::set_body_data(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - private function process_form() |
|
| 37 | - { |
|
| 38 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
| 39 | - return (object) array('display' => 'normal'); |
|
| 36 | + private function process_form() |
|
| 37 | + { |
|
| 38 | + if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
| 39 | + return (object) array('display' => 'normal'); |
|
| 40 | 40 | |
| 41 | - Loader::load('utility', 'Validate'); |
|
| 42 | - $error_result = array(); |
|
| 43 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
| 44 | - $error_result['name'] = 'please enter your name'; |
|
| 45 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
| 46 | - $error_result['email'] = 'please enter a valid email'; |
|
| 47 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
| 48 | - $error_result['message'] = 'please write a message'; |
|
| 41 | + Loader::load('utility', 'Validate'); |
|
| 42 | + $error_result = array(); |
|
| 43 | + if(!Validate::checkRequest('post', 'name', 'string')) |
|
| 44 | + $error_result['name'] = 'please enter your name'; |
|
| 45 | + if(!Validate::checkRequest('post', 'email', 'string')) |
|
| 46 | + $error_result['email'] = 'please enter a valid email'; |
|
| 47 | + if(!Validate::checkRequest('post', 'message', 'string')) |
|
| 48 | + $error_result['message'] = 'please write a message'; |
|
| 49 | 49 | |
| 50 | - $values = (object) array( |
|
| 51 | - 'name' => Request::getPost('name'), |
|
| 52 | - 'email' => Request::getPost('email'), |
|
| 53 | - 'message' => Request::getPost('message')); |
|
| 50 | + $values = (object) array( |
|
| 51 | + 'name' => Request::getPost('name'), |
|
| 52 | + 'email' => Request::getPost('email'), |
|
| 53 | + 'message' => Request::getPost('message')); |
|
| 54 | 54 | |
| 55 | - if(count($error_result) > 0) |
|
| 56 | - { |
|
| 57 | - return (object) array( |
|
| 58 | - 'display' => 'error', |
|
| 59 | - 'messages' => $error_result, |
|
| 60 | - 'values' => $values); |
|
| 61 | - } |
|
| 55 | + if(count($error_result) > 0) |
|
| 56 | + { |
|
| 57 | + return (object) array( |
|
| 58 | + 'display' => 'error', |
|
| 59 | + 'messages' => $error_result, |
|
| 60 | + 'values' => $values); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | global $container; |
| 64 | 64 | $sent = $container['mail'] |
| 65 | - ->addTo($container['config']->admin_email) |
|
| 66 | - ->setSubject('Home Page Contact') |
|
| 67 | - ->setPlainMessage( |
|
| 65 | + ->addTo($container['config']->admin_email) |
|
| 66 | + ->setSubject('Home Page Contact') |
|
| 67 | + ->setPlainMessage( |
|
| 68 | 68 | "Name: {$values->name}\n" . |
| 69 | 69 | "Email: {$values->email}\n" . |
| 70 | 70 | "Message: {$values->message}" |
| 71 | - ) |
|
| 72 | - ->send(); |
|
| 71 | + ) |
|
| 72 | + ->send(); |
|
| 73 | 73 | |
| 74 | - return (object) array('display' => 'success'); |
|
| 75 | - } |
|
| 74 | + return (object) array('display' => 'success'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | } |