diff --git a/application/core/Application.php b/application/core/Application.php index 4cc689c..ecbf7a5 100644 --- a/application/core/Application.php +++ b/application/core/Application.php @@ -19,10 +19,13 @@ class Application private $action_name; /** - * Start the application, analyze URL elements, call according controller/method or relocate to fallback location + * Construct */ public function __construct() { + // Reset header render flag + View::resetHeaderRendered(); + // create array with URL parts in $url $this->splitUrl(); diff --git a/application/core/View.php b/application/core/View.php index 7de1c28..035fdf3 100644 --- a/application/core/View.php +++ b/application/core/View.php @@ -16,6 +16,11 @@ class View public $user_avatar_file; public $avatar_file_path; public $user_account_type; + + /** + * Static property to track if header has been rendered + */ + private static $header_rendered = false; /** * simply includes (=shows) the view. this is done from the controller. In the controller, you usually say @@ -32,9 +37,15 @@ class View } } - require Config::get('PATH_VIEW') . '_templates/header.php'; - require Config::get('PATH_VIEW') . $filename . '.php'; - require Config::get('PATH_VIEW') . '_templates/footer.php'; + if (!self::$header_rendered) { + self::$header_rendered = true; + + require Config::get('PATH_VIEW') . '_templates/header.php'; + require Config::get('PATH_VIEW') . $filename . '.php'; + require Config::get('PATH_VIEW') . '_templates/footer.php'; + } else { + require Config::get('PATH_VIEW') . $filename . '.php'; + } } /** @@ -51,13 +62,17 @@ class View return false; } - if ($data) { - foreach ($data as $key => $value) { - $this->{$key} = $value; + if (!self::$header_rendered) { + self::$header_rendered = true; + + if ($data) { + foreach ($data as $key => $value) { + $this->{$key} = $value; + } } - } - require Config::get('PATH_VIEW') . '_templates/header.php'; + require Config::get('PATH_VIEW') . '_templates/header.php'; + } foreach($filenames as $filename) { require Config::get('PATH_VIEW') . $filename . '.php'; @@ -91,6 +106,14 @@ class View header("Content-Type: application/json"); echo json_encode($data); } + + /** + * Reset header render flag at start of request + */ + public static function resetHeaderRendered() + { + self::$header_rendered = false; + } /** * renders the feedback messages into the view diff --git a/application/view/message/conversation.php b/application/view/message/conversation.php index 7537863..7062df0 100644 --- a/application/view/message/conversation.php +++ b/application/view/message/conversation.php @@ -1,117 +1,115 @@ -render('_templates/header'); ?> -
-
- - +
+ + - -
- -
-
-
- Conversation with other_user->user_name) ?> -
-
- messages)): ?> -
- No messages yet. Start a conversation! -
- - messages as $msg): ?> -
-
- message) ?> -
-
- created_at)) ?> -
-
- - -
- - - +
+ +
+ +
+
+
+ Conversation with other_user->user_name) ?> +
+
+ messages)): ?> +
+ No messages yet. Start a conversation!
+ + messages as $msg): ?> +
+
+ message) ?> +
+
+ created_at)) ?> +
+
+ +
+ + + +
+
-render('_templates/footer'); ?> \ No newline at end of file +render('_templates/footer'); ?> diff --git a/application/view/message/index.php b/application/view/message/index.php index db85850..54779f2 100644 --- a/application/view/message/index.php +++ b/application/view/message/index.php @@ -1,177 +1,175 @@ -render('_templates/header'); ?> -
-

Messenger

- -
- -
-
-
- Conversations - unread_count > 0): ?> - unread_count ?> +

Messenger

+ +
+ +
+
+
+ Conversations + unread_count > 0): ?> + unread_count ?> + +
+ - - -
-
New Message
-
-
-
- - -
-
- - -
-
- - -
- -
-
-
- - -
-
Send to Group
-
-
-
- - -
-
- - -
-
- - -
- -
-
-
+ +

+ last_message_time)) ?> +

+ + + +
- - -
-
-
- Chat Area - Select a conversation to start messaging -
-
- Select a conversation from the left to view messages -
+
+ + +
+
New Message
+
+
+
+ +
+
+ + +
+
+ + +
+ +
+
+ + +
+
Send to Group
+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+
+ Chat Area + Select a conversation to start messaging +
+
+ Select a conversation from the left to view messages +
+
+
+
-render('_templates/footer'); ?> \ No newline at end of file +render('_templates/footer'); ?>