00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018 class breadcrumb
00019 {
00020 var $title;
00021 var $url;
00022
00029 function breadcrumb( $title, $url )
00030 {
00031 $this->title = $title;
00032 $this->url = $url;
00033 }
00034
00040 function render()
00041 {
00042 return "<a class=\"breadcrumb\" href=\"" . $this->url . "\">" . $this->title . "</a>";
00043 }
00044 }
00045
00047 class breadcrumbs
00048 {
00049 var $crumbs;
00050
00057 function breadcrumbs( $basetitle, $baseurl )
00058 {
00059 $this->crumbs[] = new breadcrumb( $basetitle, $baseurl );
00060 }
00061
00070 function addCrumb( $title, $url )
00071 {
00072 $this->crumbs[] = new breadcrumb( $title, $url );
00073 }
00074
00080 function render()
00081 {
00082 $rendered = "<div class=\"breadcrumbs\">";
00083
00084 foreach( $this->crumbs as $key => $value )
00085 $rendered .= $value->render() . " » ";
00086
00087
00088 $rendered = substr( $rendered, 0, -9 );
00089
00090 $rendered .= "</div>";
00091
00092 return $rendered;
00093 }
00094 }
00095
00104 function globalIDtoBreadcrumb( $globalID, $baseLevel = 0 )
00105 {
00106 $splitID = explode( "/", $globalID );
00107 foreach( $splitID as $key => $value)
00108 {
00109 if( $key > $baseLevel )
00110 {
00111 $currentID .= "/$value";
00112 $trail->addCrumb( $value, globalIDtoURL( $currentID ) );
00113 }
00114 else
00115 {
00116 if( $key == 0 )
00117 $currentID = $value;
00118 else
00119 $currentID .= "/$value";
00120
00121 if( $key == $baseLevel )
00122 $trail = new breadcrumbs( $value, globalIDtoURL( $currentID ) );
00123 }
00124 }
00125
00126 return $trail;
00127 }
00128
00140 function renderNavigator($entryCount, $currentPage, $lowerBound, $upperBound, $entriesPerPage)
00141 {
00142 if( $upperBound + 1 > $entryCount )
00143 $upperBound = $entryCount;
00144
00145 $navigator = "";
00146
00147 if( $currentPage <= ($upperBound / $entriesPerPage) - 1 )
00148 $navigator_previous .= "<a class=\"command\" href=\"" . thisPageURL() . "&currentpage=" . ($currentPage + 1) . "\">[ « " . i18n("Prevous ##0##", array($entriesPerPage) ) . "]</a> ";
00149
00150 if( $currentPage > 0 )
00151 $navigator_next .= " <a class=\"command\" href=\"" . thisPageURL() . "&currentpage=" . ($currentPage - 1) . "\">[" . i18n("Next ##0##", array($entriesPerPage) ) . " » ]</a>";
00152
00153 if( $entryCount > $entriesPerPage )
00154 $navigator = "
00155 <div class=\"pagination_navigator\">
00156 $navigator_previous
00157 " .i18n("Showing entries number ##0## to ##1## of ##2##", array($entryCount - $upperBound + 1, $entryCount - $lowerBound, $entryCount ) ) . "
00158 $navigator_next
00159 </div>";
00160
00161 return $navigator;
00162 }
00163
00164
00172 function formatTime( $timestamp )
00173 {
00174 global $systemOptions;
00175
00176 if( $timestamp == 0 )
00177 $thetime = i18n("never");
00178 else
00179 {
00180 $timeformat = getUserInfo( currentUser(), "timeformat" );
00181 if( $timeformat == getUserInfo( currentUser(), "/none/" ) || $timeformat == i18n( "No ##0## information\n", array("timeformat") ) )
00182 $timeformat = $systemOptions["timeformat"];
00183
00184 if( $timeformat == "" )
00185 $timeformat = "r";
00186
00187 $thetime = date( $timeformat, $timestamp );
00188 }
00189 return $thetime;
00190 }
00191
00202 function renderCustomBox( $title, $text, $class, $page_data = true )
00203 {
00204 if( $page_data )
00205 $parsedtext = str_replace( "<p >", "<p class=\"$class\">", parse_page_data( $text ) );
00206 else
00207 $parsedtext = $text;
00208
00209 $thebox = "
00210 <div class=\"$class\">
00211 <h6 class=\"$class\">$title</h6>
00212 $parsedtext
00213 </div>";
00214
00215 return $thebox;
00216 }
00217
00227 function renderInformationBox( $title, $text, $page_data = true )
00228 {
00229 return renderCustomBox( $title, $text, "information", $page_data );
00230 }
00231
00241 function renderWarningBox( $title, $text, $page_data = true )
00242 {
00243 return renderCustomBox( $title, $text, "warning", $page_data );
00244 }
00245
00255 function renderErrorBox( $title, $text, $page_data = true )
00256 {
00257 return renderCustomBox( $title, $text, "error", $page_data );
00258 }
00259
00269 function renderQuestionBox( $title, $text, $page_data = true )
00270 {
00271 return renderCustomBox( $title, $text, "question", $page_data );
00272 }
00273
00275 class confirmDeleteDialog
00276 {
00277 var $name;
00278 var $description;
00279 var $globalID;
00280
00281 var $title;
00282 var $text;
00283 var $checkbox;
00284
00285 var $submitted;
00286 var $confirmed;
00287
00288 function confirmDeleteDialog( $name, $description, $globalID )
00289 {
00290 $this->name = $name;
00291 $this->description = $description;
00292 $this->globalID = $globalID;
00293
00294 $this->title = i18n( "Please conform delete of ##0##", array( $this->name ) );
00295 $this->text = i18n("Please confirm that you wish to delete the item described below by ticking the checkbox. When you have made your choice, click the Continue button.");
00296 $this->checkbox = i18n("Yes, delete ##0##.", array( $this->name ) );
00297
00298 if( $_POST["deleteSubmitted"] )
00299 $this->submitted = true;
00300 if( $_POST["deleteConfirmed"] )
00301 $this->confirmed = true;
00302 }
00303
00304 function render()
00305 {
00306 $thumbnail = getGlobalIDThumbnail($this->globalID);
00307 $content = $this->text . "<hr />";
00308 $content .= "<p class=\"question wikicenteralign\"><img src=\"" . $thumbnail["uri"] . "\" width=\"" . $thumbnail["width"] . "\" height=\"" . $thumbnail["height"] . "\" alt=\"" . $this->name . "\" /></p>";
00309 $content .= parse_page_data($this->description) . "<hr />";
00310 $content .= "<p class=\"question\"><label><input type=\"checkbox\" name=\"deleteConfirmed\" />" . $this->checkbox . "</label></p>";
00311 $content .= "<p class=\"question wikicenteralign\"><input type=\"submit\" name=\"deleteSubmitted\" value=\"" . i18n("Continue") . "\" /></p>";
00312
00313 $renderedDialog = "<form method=\"POST\" action=\"" . thisPageURL() . "\">" . renderQuestionBox( $this->title, $content, false ) . "</form>";
00314
00315 return $renderedDialog;
00316 }
00317 }
00318
00319 ?>