<?php
// vim: sw=4:ts=4
/**
* @version 00.04.09
* @package polaring
* @license This component in released under the GNU/GPL License
*
* File: view/diary.php
* Role: Shows diary-related elements
*
**/
/*******************
* FUNKTIONER
******************/
class show_diary {
function idag($todayinfo) {
show_diary::dag($todayinfo);
}
function dag($todayinfo) {
$phpindex = "./polaring.php?section=dagbok";
if ( empty($_GET['dag']) ) {
echo "<h2>".strings::expression("diary", "entry_for")." ".date("d M Y") . "</h2>\n";
} else {
$urldate = date("d M Y", mktime(0, 0, 0, $_GET['month'], $_GET['dag'], $_GET['ar']));
$urldate_text = "&ar=".$_GET['ar']."&month=".$_GET['month'].
"&dag=".$_GET['dag'];
echo "<h2>".strings::expression("diary", "entry_for")." ".$urldate."</h2>\n";
}
echo "<table class=\"dagbok\">\n".
" <tfoot>\n".
" <tr>\n".
" <td><p></p></td>\n".
" </tr>\n".
" <tr>\n".
" <td><a href=\"".$phpindex."&mission=dagbok&val=idag&".
"val2=skrivmer".$urldate_text."\">".strings::expression("diary", "change_add").
"</a> ".strings::expression("diary", "information")."</td>\n".
" </tr>\n".
" </tfoot>\n",
" <tbody>\n".
" <tr>\n".
" <td>";
$possibleTexts = array("general", "food", "workout");
echo "<table class=\"general food workout\">\n" .
" <tbody>\n";
// GENERAL
if ( $todayinfo['general_text'] ) {
echo " <tr>\n".
" <td class=\"dbheadline\"><h3>".strings::expression("diary", "general").
"</h3></td>\n".
" </tr>\n" .
" <tr>\n" .
" <td class=\"inlheadline\"><h4>".$todayinfo['general_hl'].
"</h4></td>\n".
" <td class=\"inltext\">".
stringModify::txtThtml($todayinfo['general_text'])."</td>\n".
" </tr>";
}
// FOOD
if ( $todayinfo['food_text'] ) {
echo " <tr>\n".
" <td class=\"dbheadline\"><h3>".strings::expression("diary", "food").
"</h3></td>\n".
" </tr>\n" .
" <tr>\n" .
" <td class=\"inlheadline\"><h4>".$todayinfo['food_hl'].
"</h4></td>\n".
" <td class=\"inltext\">".
stringModify::txtThtml($todayinfo['food_text'])."</td>\n".
" </tr>";
}
// EXERCISE
if ( $todayinfo['workout_text'] ) {
echo " <tr>\n".
" <td class=\"dbheadline\"><h3>".strings::expression("diary", "exercise").
"</h3></td>\n".
" </tr>\n" .
" <tr>\n" .
" <td class=\"inlheadline\"><h4>".$todayinfo['workout_hl'].
"</h4></td>\n".
" <td class=\"inltext\">".
stringModify::txtThtml($todayinfo['workout_text'])."</td>\n".
" </tr>";
}
echo " </tbody>\n".
"</table>\n".
" </td>\n".
" </tr>\n".
" </tbody>\n".
"</table>\n";
} // END function dag
function nodaychosen() {
echo strings::expression("diary", "frontpage");
} // END function nodaychosen
function writeInfo($info) {
$phpindex = "./polaring.php?section=dagbok";
if ( empty($_GET['dag']) ) {
echo "<h2>".strings::expression("diary", "entry_for")." ".date("d M Y")."</h2>\n";
} else {
$urldate = date("d M Y", mktime(0, 0, 0, $_GET['month'], $_GET['dag'], $_GET['ar']));
$urldate_text = "&ar=".$_GET['ar']."&month=".$_GET['month'].
"&dag=".$_GET['dag'];
echo "<h2>".strings::expression("diary", "entry_for")." ".$urldate."</h2>\n";
}
if ( empty($info) ) {
echo strings::expression("diary", "no_entry");
$general_hl="";
$general_text="";
$food_hl="";
$food_text="";
$workout_hl="";
$workout_text="";
$action = $phpindex . "&mission=dagbok&val=lagra".
$urldate_text;
} else {
echo "";
$general_hl=$info['general_hl'];
$general_text=$info['general_text'];
$food_hl=$info['food_hl'];
$food_text=$info['food_text'];
$workout_hl=$info['workout_hl'];
$workout_text=$info['workout_text'];
$action = $phpindex ."&mission=dagbok&val=lagra&".
"val2=skrivmer".$urldate_text;
}
?>
<form method="post" action="<?php echo $action; ?>">
<table class="lagra">
<tfoot>
<tr>
<td><input type="submit" name="submit" id="submit" value="<?php echo strings::expression("diary", "submit"); ?>" /></td>
</tr>
<tbody><tr><td>
<table class="allmänt">
<thead>
<tr><td><h3><? echo strings::expression("diary", "general"); ?></h3></td></tr>
</thead>
<tbody>
<tr>
<td><label for="general_hl"><?php echo strings::expression("diary", "title"); ?></label>
<input type="text" name="general_hl" id="general_hl" value="<?php echo $general_hl; ?>" /></td>
</tr>
<tr>
<td><textarea name="all_entry" id="all_entry" rows="15" cols="59"><?php echo $general_text; ?></textarea></td>
</tr>
</tbody>
<table class="mat">
<thead>
<tr><td><h3><? echo strings::expression("diary", "food"); ?></h3></td></tr>
</thead>
<tbody>
<tr>
<td><label for="food_hl"><?php echo strings::expression("diary", "title"); ?></label>
<input type="text" name="food_hl" id="food_hl" value="<?php echo $food_hl; ?>" /></td>
</tr>
<tr>
<td><textarea name="mat_entry" id="mat_entry" rows="15" cols="59"><?php echo $food_text; ?></textarea></td>
</tr>
</tbody>
<table class="motion">
<thead>
<tr><td><h3><? echo strings::expression("diary", "exercise"); ?></h3></td></tr>
</thead>
<tbody>
<tr>
<td><label for="workout_hl"><?php echo strings::expression("diary", "title"); ?></label>
<input type="text" name="workout_hl" id="workout_hl" value="<?php echo $workout_hl; ?>" /></td>
</tr>
<tr>
<td><textarea name="mot_entry" id="mot_entry" rows="15" cols="59"><?php echo $workout_text; ?></textarea></td>
</tr>
</tbody>
</td></tr></tbody>
</table>
</form>
<?php
} // END function writeInfo
function infoiswritten() {
$phpindex = "./polaring.php?section=dagbok";
if ( empty($_GET['dag']) ) {
$date_text = date("d M Y");
$date_url = "&ar=".date("Y")."&month=".date("m")."&dag=".date("d");
} else {
$date_text = date("d M Y", mktime(0, 0, 0, $_GET['month'], $_GET['dag'], $_GET['ar']));
$date_url = "&ar=".$_GET['ar']."&month=".$_GET['month'].
"&dag=".$_GET['dag'];
}
echo "<p>".strings::expression("diary", "entry_for")." ".$date_text." sparat.</p>";
empty($HTTP_POST_VARS);
echo "<p><a href=\"".$phpindex."&mission=dagbok&val=las".
$date_url."\">".strings::expression("diary", "view")."</a> ".
strings::expression("diary", "saved_entry")."</p>";
}
} // END class visa
?>