Skip to content

Commit

Permalink
Created common function generate_refresh_meta() to replace redundant …
Browse files Browse the repository at this point in the history
…code in dispaly

 files.
  • Loading branch information
umcesrjones committed Nov 7, 2006
1 parent ff015bd commit 76ba1a8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 47 deletions.
7 changes: 1 addition & 6 deletions day.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@
}
$eventinfo = ( ! empty ( $eventinfo )? $eventinfo : '' );
$trailerStr = print_trailer ();
$HeadX = '';
if ( $AUTO_REFRESH == 'Y' && ! empty ( $AUTO_REFRESH_TIME ) ) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; url=day.php?$u_url" .
"date=$nowYmd$caturl" . ( ! empty ( $friendly ) ? '&amp;friendly=1' : '') . "\" />\n";
}
$HeadX = generate_refresh_meta ();
$INC = array('js/popups.php/true');
print_header($INC,$HeadX);

Expand Down
17 changes: 17 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6178,4 +6178,21 @@ function generate_application_name ( $custom=true ) {
return htmlspecialchars ( $APPLICATION_NAME );
}
}

/**
* Generate Refresh Meta Tag
*
* @return HTML for Meta Tag
*/
function generate_refresh_meta () {
global $AUTO_REFRESH, $AUTO_REFRESH_TIME, $REQUEST_URI;

$ret = '';
if ( $AUTO_REFRESH == 'Y' && ! empty ( $AUTO_REFRESH_TIME ) &&
! empty ( $REQUEST_URI )) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$ret .= "<meta http-equiv=\"refresh\" content=\"$refresh; url=$REQUEST_URI\" />";
}
return $ret;
}
?>
8 changes: 4 additions & 4 deletions includes/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function print_header ( $includes = '', $HeadX = '', $BodyX = '',
}
// Do we need anything else inside the header tag?
if ( $HeadX )
$ret .= $HeadX . "\n";
$ret .= "\n " . $HeadX;
// Include the styles
// Include CSS needed for the top menu
if ( $MENU_ENABLED == 'Y' ) {
Expand Down Expand Up @@ -207,12 +207,12 @@ function print_header ( $includes = '', $HeadX = '', $BodyX = '',
<link rel="alternate" type="application/rss+xml" title="'
. $appStr . ' [RSS 2.0]" href="rss.php'
// TODO: single-user mode, etc.
. ( $login != '__public__' ? '?user=' . $login : '' ) . '" />' : '' )
. ( $login != '__public__' ? '?user=' . $login : '' ) . '" />' : '' ) . "\n"
// Link to favicon
. '<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />'
. ' <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />'. "\n"
. ( $MENU_ENABLED == 'Y' ? $menuScript : '' )
// Finish the header
. '</head>
. ' </head>
<body'
// Add the page direction if right-to-left
. ( $direction == 'rtl' ? ' dir="rtl"' : '' )
Expand Down
10 changes: 1 addition & 9 deletions list_unapproved.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@
! access_is_enabled () )
$user = $login;

$HeadX = '';
if ( $AUTO_REFRESH == 'Y' && ! empty ( $AUTO_REFRESH_TIME ) ) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$returl = "list_unapproved.php";
if ( ! empty ( $user ) && $user != $login )
$returl .= "?user=" . $user;
$HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; URL=" .
$returl . "\" />\n";
}
$HeadX = generate_refresh_meta ();
//make sure we return after editing an event via this page
remember_this_view();

Expand Down
8 changes: 1 addition & 7 deletions minical.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,7 @@
$startdate = mktime ( 0, 0, 0, $thismonth, 1, $thisyear );
$enddate = mktime ( 23, 59, 59, $thismonth + 1, 0, $thisyear );


$HeadX = '';
if ( $AUTO_REFRESH == 'Y' && ! empty ( $AUTO_REFRESH_TIME ) ) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; url=minical.php?$u_url" .
"year=$thisyear&amp;month=$thismonth \" />\n";
}
$HeadX = generate_refresh_meta ();

$INC = '';
$BodyX = '';
Expand Down
10 changes: 3 additions & 7 deletions month.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,16 @@
$navStr = display_navigation( 'month' );
$monthStr = display_month ( $thismonth, $thisyear );
$eventinfo = ( ! empty ( $eventinfo )? $eventinfo : '' );
$HeadX = '';

if ( empty ( $friendly ) ) {
$unapprovedStr = display_unapproved_events ( ( $is_assistant ||
$is_nonuser_admin ? $user : $login ) );
$printerStr = generate_printer_friendly ( 'month.php' );
}
$trailerStr = print_trailer ();

if ( $AUTO_REFRESH == 'Y' && ! empty ( $AUTO_REFRESH_TIME ) ) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; url=month.php?$u_url" .
"year=$thisyear&amp;month=$thismonth$caturl" .
( ! empty ( $friendly ) ? '&amp;friendly=1' : '') . "\" />\n";
}
$HeadX = generate_refresh_meta ();

$INC = array('js/popups.php/true', 'js/visible.php/true');
print_header($INC,$HeadX);

Expand Down
9 changes: 1 addition & 8 deletions week.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,7 @@
$minical_tasks .= '</td>';
}//end minical

$HeadX = '';
if ( ! empty ( $AUTO_REFRESH ) && $AUTO_REFRESH == 'Y' &&
! empty ( $AUTO_REFRESH_TIME ) ) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; url=week.php?$u_url" .
"date=$startdate$caturl" .
( ! empty ( $friendly ) ? '&amp;friendly=1': '') . "\" />\n";
}
$HeadX = generate_refresh_meta ();
$INC = array('js/popups.php/true');
print_header($INC,$HeadX);

Expand Down
7 changes: 1 addition & 6 deletions week_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@
$end_ind = 6;
}

$HeadX = '';
if ( $AUTO_REFRESH == 'Y' && ! empty ( $AUTO_REFRESH_TIME ) ) {
$refresh = $AUTO_REFRESH_TIME * 60; // convert to seconds
$HeadX = "<meta http-equiv=\"refresh\" content=\"$refresh; url=week_details.php?$u_url" .
"date=$thisdate$caturl\" />\n";
}
$HeadX = generate_refresh_meta ();
$printerStr = generate_printer_friendly ( 'week_details.php' );

$INC = array('js/popups.php/true');
Expand Down

0 comments on commit 76ba1a8

Please sign in to comment.