Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added session messages
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 5, 2010
1 parent d1959b2 commit 918add2
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 3 deletions.
22 changes: 22 additions & 0 deletions components/journal/controllers/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ private function _Prep ( ) {
unset ( $row );
}

$this->_PrepMessage();

return ( true );
}

Expand Down Expand Up @@ -175,5 +177,25 @@ private function _PageCalc ( ) {
return ( $return );
}

private function _PrepMessage ( ) {

$markup = $this->View;

$session = $this->GetSys ( 'Session' );
$session->Context ( $this->Get ( 'Context' ) );

if ( $message = $session->Get ( 'Message' ) ) {
$markup->Find ( '.entries-message', 0 )->innertext = $message;
if ( $error = $session->Get ( 'Error' ) ) {
$markup->Find ( '.entries-message', 0 )->class .= ' error ';
} else {
$markup->Find ( '.entries-message', 0 )->class .= ' message ';
}
$session->Destroy ( 'Message');
$session->Destroy ( 'Error ');
}

return ( true );
}

}
34 changes: 34 additions & 0 deletions components/journal/controllers/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ private function _Prep ( ) {

$this->View->Find ( '.back', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/';

$this->_PrepMessage();

return ( true );
}

Expand Down Expand Up @@ -140,6 +142,8 @@ private function _PrepAdd ( ) {

$this->View->Find ( '.remove', 0 )->outertext= "";

$this->_PrepMessage();

return ( true );
}

Expand Down Expand Up @@ -170,6 +174,8 @@ private function _PrepEdit ( ) {
$this->View->Find ( '[name=Title]', 0 )->value = $this->Model->Get ( 'Title' );
$this->View->Find ( '[name=Body]', 0 )->innertext = $this->Model->Get ( 'Body' );

$this->_PrepMessage();

return ( true );
}

Expand Down Expand Up @@ -204,6 +210,9 @@ public function Save ( ) {

$this->Talk ( 'Search', 'Index', array ( 'text' => $text, 'context' => $context, 'id' => $id ) );

$this->GetSys ( 'Session' )->Context ( $this->Get ( 'Context' ) );
$this->GetSys ( 'Session' )->Set ( 'Message', __ ( 'Item Saved' ) );

header ( 'Location: ' . $location );
exit;
}
Expand Down Expand Up @@ -235,8 +244,33 @@ public function Cancel ( ) {
$location = '/profile/' . $this->_Focus->Username . '/journal/';
}

$this->GetSys ( 'Session' )->Context ( 'entries.journal.(\d+).entries' );
$this->GetSys ( 'Session' )->Set ( 'Message', __ ( 'Edit Cancelled' ) );

header ( 'Location: ' . $location );
exit;
}

private function _PrepMessage ( ) {

$markup = $this->View;

$session = $this->GetSys ( 'Session' );
$session->Context ( $this->Get ( 'Context' ) );

if ( $message = $session->Get ( 'Message' ) ) {
$markup->Find ( '.entry-message', 0 )->innertext = $message;
if ( $error = $session->Get ( 'Error' ) ) {
$markup->Find ( '.entry-message', 0 )->class .= ' error ';
} else {
$markup->Find ( '.entry-message', 0 )->class .= ' message ';
}
$session->Destroy ( 'Message');
$session->Destroy ( 'Error ');
}

return ( true );
}


}
2 changes: 1 addition & 1 deletion components/journal/journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public function IdentifierExists ( $pData = null ) {
return ( false );
}

}
}
5 changes: 4 additions & 1 deletion components/journal/languages/en-US/journal.lang
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ ADD_NEW="New"
RSS_FEED="RSS"
BACK_TO_ENTRIES="← journal entries"

LOGIN_TO_SEE_THIS_PAGE="You must log in to see this page."
LOGIN_TO_SEE_THIS_PAGE="You must log in to see this page."

EDIT_CANCELLED="Your changes have been cancelled"
ITEM_SAVED="Your journal entry has been saved"
1 change: 1 addition & 0 deletions components/journal/views/entries.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<section id="profile-journal">
<p class="entries-message"></p>
<a class="add">Add New</a>
<a class="rss">RSS Feed</a>
Expand Down
1 change: 1 addition & 0 deletions components/journal/views/entry.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script type="text/javascript" src="/components/journal/assets/javascript/edit.js"></script>

<section id="profile-journal-entry">
<p class="entry-message"></p>
<a class="back">Back To Entries</a>
<a class="edit">Edit</a>
<h1 class="title"></h1>
Expand Down
6 changes: 5 additions & 1 deletion themes/default/style/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@


/* Journal Entry */
#profile-journal-entry .entry-message { float:left; clear:both; margin-bottom:10px; }

#profile-journal-entry .title { float:left; clear:both; margin-top:5px; width:100%; }
#profile-journal-entry .body { float:left; clear:both; font-size:100%; width:670px; margin:10px 10px; border:1px solid #c0d895; padding:5px; }
#profile-journal-entry .body img { max-width:590px; }
Expand All @@ -495,14 +497,16 @@
#profile-journal-edit .preview h4, #profile-journal-entry .body h4 { color:#2a2a2a; font-size:130%; border:none; clear:both; float:left; margin-bottom:5px; }
#profile-journal-edit .preview h5, #profile-journal-entry .body h5 { color:#2a2a2a; font-size:120%; border:none; clear:both; float:left; margin-bottom:5px; }
#profile-journal-edit .preview h6, #profile-journal-entry .body h6 { color:#2a2a2a; font-size:110%; border:none; clear:both; float:left; margin-bottom:5px; }
#profile-journal-edit form .journal-markup-info { margin:10px 10px 10px 128px; padding:10px; }

#profile-journal-entry .permalink { float:left; clear:both; margin-top:5px; color:#8a8a8a; font-style:italic; }
#profile-journal-entry .permalink a { color:#8a8a8a; background:none; padding:0; }
#profile-journal-entry .edit { font-size:80%; float:right; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }
#profile-journal-entry .back { font-size:80%; float:left; background:none; padding:0; margin:0; }
#profile-journal-edit form .journal-markup-info { margin:10px 10px 10px 128px; padding:10px; }

/* Journal Entries */
#profile-journal .entries-message { float:left; clear:both; margin-bottom:10px; }

#profile-journal .add { font-size:80%; float:right; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }

#profile-journal .rss { font-size:80%; float:left; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }
Expand Down

0 comments on commit 918add2

Please sign in to comment.