| 1 | package FWS::V2::Display; | ||
| 2 | |||
| 3 | use 5.006; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | no warnings 'uninitialized'; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | FWS::V2::Display - Framework Sites version 2 web display methods | ||
| 11 | |||
| 12 | =head1 VERSION | ||
| 13 | |||
| 14 | Version 1.13091122 | ||
| 15 | |||
| 16 | =cut | ||
| 17 | |||
| 18 | our $VERSION = '1.13091122'; | ||
| 19 | |||
| 20 | |||
| 21 | =head1 SYNOPSIS | ||
| 22 | |||
| 23 | use FWS::V2; | ||
| 24 | |||
| 25 | my $fws = FWS::V2->new(); | ||
| 26 | |||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | FWS version 2 core web display methods | ||
| 31 | |||
| 32 | =head1 METHODS | ||
| 33 | |||
| 34 | =head2 addToFoot | ||
| 35 | |||
| 36 | Add content to the html just above the body tag. | ||
| 37 | |||
| 38 | =cut | ||
| 39 | |||
| 40 | sub addToFoot { | ||
| 41 | my ( $self, $addToFootVar ) = @_; | ||
| 42 | $self->siteValue( 'pageFoot', $addToFootVar . $self->siteValue( 'pageFoot' ) ); | ||
| 43 | return; | ||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | =head2 addToHead | ||
| 48 | |||
| 49 | Add content to the html head area. | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | sub addToHead { | ||
| 54 | my ( $self, $addToHeadVar ) = @_; | ||
| 55 | $self->siteValue( 'pageHead', $addToHeadVar . $self->siteValue( 'pageHead' ) ); | ||
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | =head2 FWSHead | ||
| 61 | |||
| 62 | Return the head html for a fws page rendering. | ||
| 63 | |||
| 64 | =cut | ||
| 65 | |||
| 66 | sub FWSHead { | ||
| 67 | my ( $self ) = @_; | ||
| 68 | |||
| 69 | my $pageTitle = $self->siteValue( 'pageTitle' ); | ||
| 70 | |||
| 71 | if ( !$pageTitle && $self->formValue( 'p' ) =~ /^fws_/ ) { | ||
| 72 | $pageTitle = 'FrameWork Sites ' . $self->{FWSVersion}; | ||
| 73 | $self->jqueryEnable( 'ui-1.8.9' ); | ||
| 74 | $self->jqueryEnable( 'ui.widget-1.8.9' ); | ||
| 75 | $self->jqueryEnable( 'ui.mouse-1.8.9' ); | ||
| 76 | $self->jqueryEnable( 'ui.dialog-1.8.9' ); | ||
| 77 | $self->jqueryEnable( 'ui.datepicker-1.8.9' ); | ||
| 78 | $self->jqueryEnable( 'ui.slider-1.8.9' ); | ||
| 79 | $self->jqueryEnable( 'timepickr-0.9.6' ); | ||
| 80 | $self->jqueryEnable( 'ui.position-1.8.9' ); | ||
| 81 | } | ||
| 82 | |||
| 83 | my $html = '<title>' . $pageTitle . "</title>\n"; | ||
| 84 | if ( $self->siteValue( 'pageKeywords' ) ) { $html .= '<meta name="keywords" content="' . $self->siteValue( 'pageKeywords' ) . "\"/>\n" } | ||
| 85 | if ( $self->siteValue( 'pageDescription' ) ) { $html .= '<meta name="description" content="' . $self->siteValue( 'pageDescription' ) . "\"/>\n" } | ||
| 86 | |||
| 87 | |||
| 88 | # | ||
| 89 | # Load jquery in head if it is flagged to, if not it will be lazy loaded | ||
| 90 | # | ||
| 91 | my %jqueryHash = %{$self->{_jqueryHash}}; | ||
| 92 | if ( keys %jqueryHash && $self->{loadJQueryInHead} ) { | ||
| 93 | $html .= "<script type=\"text/javascript\" src=\"" . $self->{fileFWSPath} . "/jquery/jquery-1.7.1.min.js\"></script>\n"; | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | return $html . $self->siteValue( 'pageHead' ) . $self->siteValue( 'templateHead' ); | ||
| 98 | } | ||
| 99 | |||
| 100 | |||
| 101 | =head2 FWSJava | ||
| 102 | |||
| 103 | Return the lazy loaded JavaScript including anything added to the pageFoot. | ||
| 104 | |||
| 105 | =cut | ||
| 106 | |||
| 107 | sub FWSJava { | ||
| 108 | my ( $self ) = @_; | ||
| 109 | |||
| 110 | # | ||
| 111 | # add tinyMCE if needed fixes a FF bug if we lazy load it. | ||
| 112 | # | ||
| 113 | my $pageJava; | ||
| 114 | if ( $self->siteValue( 'urchinId' ) && !$self->formValue( 'editMode' ) ) { | ||
| 115 | $pageJava .= "<script type=\"text/javascript\">\n"; | ||
| 116 | $pageJava .= "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\n"; | ||
| 117 | $pageJava .= "document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\n"; | ||
| 118 | $pageJava .= "</script>\n"; | ||
| 119 | $pageJava .= "<script type=\"text/javascript\">\n"; | ||
| 120 | $pageJava .= "var pageTracker = _gat._getTracker(\"" . $self->siteValue( 'urchinId' ) . "\");\n"; | ||
| 121 | $pageJava .= "pageTracker._initData();\n"; | ||
| 122 | $pageJava .= "pageTracker._trackPageview();\n"; | ||
| 123 | $pageJava .= "</script>\n"; | ||
| 124 | } | ||
| 125 | |||
| 126 | |||
| 127 | # | ||
| 128 | # at some point landingId should be settable in site settings | ||
| 129 | # | ||
| 130 | if ( $self->siteValue( 'facebookAppId' ) ) { | ||
| 131 | |||
| 132 | my $landingId = $self->safeQuery( $self->formValue( 'p' ) ); | ||
| 133 | if ( $self->formValue( 'id' ) ) { $landingId .= '&id=' . $self->safeQuery( $self->formValue( 'id' ) ) } | ||
| 134 | |||
| 135 | $pageJava .= '<div id="fb-root"></div><script>'; | ||
| 136 | |||
| 137 | # | ||
| 138 | # tell FB we are french if we are | ||
| 139 | # | ||
| 140 | my $FBLang = 'en_US'; | ||
| 141 | if ( $self->language() =~ /fr/i ) { $FBLang = 'fr_CA' } | ||
| 142 | |||
| 143 | # | ||
| 144 | # leave this split up goofy for now. The code compressor freaks out a bit on | ||
| 145 | # on this when it is formated better, so it is this way on pupose. I need to update | ||
| 146 | # the compressor first before we can pretty this up | ||
| 147 | # | ||
| 148 | $pageJava .= | ||
| 149 | 'window.fbAsyncInit = function () {' . | ||
| 150 | "FB.init({ appId: '" . $self->siteValue( 'facebookAppId' ) . "', oauth: true, cookie: true, status: true, xfbml: true" . '}); ' . | ||
| 151 | 'FB.getLoginStatus(function (response) {' . | ||
| 152 | "if (response.session) {\$('#loginFBLoginBox').hide(); } " . | ||
| 153 | "else {\$('#loginFBLoginBox').show(); } " . | ||
| 154 | '}); '; | ||
| 155 | |||
| 156 | # | ||
| 157 | # prevent recursive FB Redirects | ||
| 158 | # | ||
| 159 | if ( !$self->isUserLoggedIn() ) { | ||
| 160 | $pageJava .= | ||
| 161 | "FB.Event.subscribe('auth.login', function () {" . | ||
| 162 | "window.location = '" . $self->{scriptName} . '?s=' . $self->{siteId} . '&p=' . $landingId . "&FBRedirect=1'; " . | ||
| 163 | '}); '; | ||
| 164 | } | ||
| 165 | |||
| 166 | $pageJava .= | ||
| 167 | '}; ' . | ||
| 168 | '(function () {' . | ||
| 169 | "var e = document.createElement('script'); e.async = true; " . | ||
| 170 | 'e.src = document.location.protocol + ' . | ||
| 171 | "'//connect.facebook.net/" . $FBLang . "/all.js'; " . | ||
| 172 | "document.getElementById('fb-root').appendChild(e); " . | ||
| 173 | ' }());' ; | ||
| 174 | |||
| 175 | if ( $self->formValue( 'FBRedirect' ) ) { | ||
| 176 | $pageJava .= "window.location = '" . $self->{scriptName} . '?s=' . $self->{siteId} . '&p=' . $landingId ."'; "; | ||
| 177 | } | ||
| 178 | $pageJava .= '</script>'; | ||
| 179 | } | ||
| 180 | |||
| 181 | |||
| 182 | $pageJava .= $self->siteValue( 'pageFoot' ); | ||
| 183 | return $pageJava; | ||
| 184 | } | ||
| 185 | |||
| 186 | |||
| 187 | |||
| 188 | |||
| 189 | =head2 displayContent | ||
| 190 | |||
| 191 | Return the full web rendering for a FWS Page. This includes the Content-Type HTML headers. preContent hook element can be added to a site that will run before any rendering takes place. | ||
| 192 | |||
| 193 | =cut | ||
| 194 | |||
| 195 | sub displayContent { | ||
| 196 | my ( $self ) = @_; | ||
| 197 | #$self->setPageCache(); | ||
| 198 | |||
| 199 | $self->runScript( 'preContent' ); | ||
| 200 | |||
| 201 | # | ||
| 202 | # return just statusNote formfield created by the actions. Useful mostly in ajax calls | ||
| 203 | # | ||
| 204 | if ( $self->formValue( 'returnStatusNote' ) ) { | ||
| 205 | print "Content-Type: text/html; charset=UTF-8\n\n"; | ||
| 206 | print $self->formValue( 'statusNote' ); | ||
| 207 | } | ||
| 208 | |||
| 209 | # | ||
| 210 | # if returnAndDoNothing is specified as a formValue get the hell out of here and .... do nothing! | ||
| 211 | # TODO Think returnAndDoNothing isn't needed anymore | ||
| 212 | # | ||
| 213 | elsif ( $self->formValue( 'returnAndDoNothing' ) ne '1' ) { | ||
| 214 | |||
| 215 | # | ||
| 216 | # all is good and lets just make sure this flag wasn't set by a element and print the page | ||
| 217 | # | ||
| 218 | if ( $self->formValue( 'returnAndDoNothing' ) ne '1') { | ||
| 219 | $self->printPage( content => $self->_FWSContent() ); | ||
| 220 | } | ||
| 221 | } | ||
| 222 | return; | ||
| 223 | } | ||
| 224 | |||
| 225 | |||
| 226 | =head2 printPage | ||
| 227 | |||
| 228 | Return the processed FWS Page, this can be used for any content type and is not prefaced with any specific web headers During this process the session will be updated if it was changed from when it was received . | ||
| 229 | |||
| 230 | =cut | ||
| 231 | |||
| 232 | sub printPage { | ||
| 233 | my ( $self, %paramHash ) = @_; | ||
| 234 | |||
| 235 | # | ||
| 236 | # default stop processing to off | ||
| 237 | # | ||
| 238 | $self->{stopProcessing} ||= 0; | ||
| 239 | |||
| 240 | |||
| 241 | |||
| 242 | if ( !$self->{stopProcessing} ) { | ||
| 243 | |||
| 244 | # | ||
| 245 | # set default content dispoistion | ||
| 246 | # | ||
| 247 | $paramHash{contentDisposition} ||= 'attachment'; | ||
| 248 | |||
| 249 | # | ||
| 250 | # set the content type if we didn't get it in | ||
| 251 | # | ||
| 252 | $paramHash{contentType} ||= 'text/html; charset=UTF-8'; | ||
| 253 | |||
| 254 | # | ||
| 255 | # TODO don't think returnAdnDoNothing is needed anymore | ||
| 256 | # bust out of here if there is nothing to do | ||
| 257 | # | ||
| 258 | if ( $self->formValue( 'returnAndDoNothing' ) ) { return } | ||
| 259 | |||
| 260 | # | ||
| 261 | # do reverse friendly logic to turn friendly URLs to non friendlies | ||
| 262 | # | ||
| 263 | if ( $self->siteValue( 'noFriendlies' ) && $self->formValue( 'p' ) !~ /^fws_/ ) { | ||
| 264 | my @friendlyArray = @{$self->runSQL( SQL => "SELECT friendly_url FROM data WHERE site_guid='" . $self->{siteGUID} . "' and (element_type='page')" )}; | ||
| 265 | while (@friendlyArray) { | ||
| 266 | my $FURL = shift @friendlyArray; | ||
| 267 | my $nonFURL = $self->{scriptName} . $self->{queryHead} . 'p=' . $FURL; | ||
| 268 | $paramHash{content} =~ s/"\/$FURL"/"$nonFURL"/g; | ||
| 269 | } | ||
| 270 | } | ||
| 271 | |||
| 272 | $self->saveSession(); | ||
| 273 | |||
| 274 | |||
| 275 | # | ||
| 276 | # Return HTTP | ||
| 277 | # Trim the domain name so it only ahs this.com without the host name. this will fix stuff to make these all the same cookie | ||
| 278 | # www.gnetworks.com secure.gnetworks.com www2.gnetworks.com cricket.gnetworks.com...... | ||
| 279 | # | ||
| 280 | my $cookieDomain; | ||
| 281 | my $cookie; | ||
| 282 | if ( $self->{cookieDomainName} ) { | ||
| 283 | $cookieDomain = ' domain=' . $self->{cookieDomainName} . ';'; | ||
| 284 | } | ||
| 285 | |||
| 286 | # | ||
| 287 | # if domainName doesn't have more than two dots in it, it is invalid by browsers | ||
| 288 | # so lets kill it if thats the case so it will use a null/empty type value | ||
| 289 | # | ||
| 290 | if ( ($cookieDomain =~ tr/\.//) < 2 ) { $cookieDomain = '' } | ||
| 291 | |||
| 292 | # | ||
| 293 | # build the cookies for display | ||
| 294 | # | ||
| 295 | $cookie .= 'Set-Cookie: ' . $self->{sessionCookieName} . '=' . $self->formValue( 'session' ) . ';' . $cookieDomain . ' Path=/;' . ' Expires=' . $self->formatDate( format => 'cookie', monthMod => 1 ) . "\n"; | ||
| 296 | $cookie .= 'Set-Cookie: fbsr_' . $self->siteValue( 'facebookAppId' ) . '=deleted; Path=/;' . " Expires=Thu, 01-Jan-1970 00:00:01 GMT\n"; | ||
| 297 | |||
| 298 | # | ||
| 299 | # simple page rendering | ||
| 300 | # | ||
| 301 | if ( $paramHash{head} ) { | ||
| 302 | $paramHash{content} = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n" . $paramHash{head} . "</head>\n<body>\n" . $paramHash{content} . "\n" . $paramHash{foot} . "\n</body>\n</html>"; | ||
| 303 | } | ||
| 304 | |||
| 305 | # | ||
| 306 | # always return a 200 | ||
| 307 | # | ||
| 308 | my $theHeader = "Status: 200 OK\n"; | ||
| 309 | |||
| 310 | # | ||
| 311 | # if the contentType doesn't have HTML in it, lets not pass the cookies | ||
| 312 | # | ||
| 313 | if ( $paramHash{contentType} =~ /html/i ) { $theHeader .= $cookie } | ||
| 314 | $theHeader .= "Accept-Ranges: bytes\n"; | ||
| 315 | if ( $paramHash{contentLength} ) { $theHeader .= 'Content-Length: ' . $paramHash{contentLength} . "\n" } | ||
| 316 | if ( $paramHash{accessControlAllowOrigin} ) { $theHeader .= 'Access-Control-Allow-Origin: ' . $paramHash{accessControlAllowOrigin} . "\n" } | ||
| 317 | if ( $paramHash{fileName} ) { $theHeader .= 'Content-disposition: ' . $paramHash{contentDisposition} . ';' . ' filename="' . $paramHash{fileName} . "\"\n" } | ||
| 318 | $theHeader .= 'Content-Type: ' . $paramHash{contentType} . "\n\n"; | ||
| 319 | |||
| 320 | # | ||
| 321 | # in case this was sent via a eval from an eplement, lets set the formvalue | ||
| 322 | # | ||
| 323 | $self->formValue( 'FWS_showElementOnly', 1 ); | ||
| 324 | |||
| 325 | if ( $self->formValue( 'redirect' ) ) { | ||
| 326 | print "Status: 302 Found\n"; | ||
| 327 | print 'Location: ' . $self->urlDecode( $self->formValue( 'redirect' ) ) . "\n\n"; | ||
| 328 | } | ||
| 329 | else { | ||
| 330 | print $theHeader . $paramHash{content}; | ||
| 331 | } | ||
| 332 | |||
| 333 | # | ||
| 334 | # process our queue for every page we render | ||
| 335 | # | ||
| 336 | $self->processQueue(); | ||
| 337 | |||
| 338 | # | ||
| 339 | # shut off processing so we never do this more than once | ||
| 340 | # | ||
| 341 | $self->{stopProcessing} = 1; | ||
| 342 | } | ||
| 343 | return; | ||
| 344 | } | ||
| 345 | |||
| 346 | |||
| 347 | sub _FWSContent { | ||
| 348 | my ( $self ) = @_; | ||
| 349 | |||
| 350 | |||
| 351 | my $pageHTML; | ||
| 352 | |||
| 353 | if ( !$self->{stopProcessing} ) { | ||
| 354 | |||
| 355 | |||
| 356 | |||
| 357 | my $pageId = $self->safeSQL( $self->formValue( 'p' ) ); | ||
| 358 | |||
| 359 | # | ||
| 360 | # this flag will suppress any access wrapping around the element | ||
| 361 | # | ||
| 362 | my $showElementOnly = 0; | ||
| 363 | |||
| 364 | # | ||
| 365 | # if this is an admin url move to a adminLogin | ||
| 366 | # | ||
| 367 | if ( $pageId eq $self->{adminURL} ) { $self->displayAdminLogin() } | ||
| 368 | |||
| 369 | # | ||
| 370 | # if this is an ispadmin contorl process the page differntly | ||
| 371 | # | ||
| 372 | if ( $pageId =~ /^fws_/ ) { $self->displayAdminPage() } | ||
| 373 | |||
| 374 | if ( $pageId eq 'favicon.ico' ) { | ||
| 375 | print "Status: 404 Not Found\n"; | ||
| 376 | print "Connection: close\n"; | ||
| 377 | print "Content-Type: text/html\n\n"; | ||
| 378 | print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"; | ||
| 379 | print "<HTML><HEAD>\n<TITLE>404 Not Found</TITLE>\n</HEAD><BODY>\n<H1>Not Found</H1>\n<P>The requested file is not available or does not exist.</P>\n</BODY></HTML>"; | ||
| 380 | $self->{stopProcessing} = 1; | ||
| 381 | } | ||
| 382 | |||
| 383 | if ( $pageId eq "robots.txt" ) { | ||
| 384 | if( !$self->siteValue( 'robots.txt' ) ) { | ||
| 385 | $self->siteValue( 'robots.txt', "User-agent: *\nDisallow: " . $self->{scriptName} . "\nAllow: /\n" ); | ||
| 386 | } | ||
| 387 | my $robotsContent = $self->siteValue( 'robots.txt' ); | ||
| 388 | print "Status: 200 OK\n"; | ||
| 389 | print "Accept-Ranges: bytes\n"; | ||
| 390 | print "Content-Length: " . length( $robotsContent ) . "\n"; | ||
| 391 | print "Content-Type:text/plain\n\n"; | ||
| 392 | print $robotsContent; | ||
| 393 | $self->{stopProcessing} = 1; | ||
| 394 | } | ||
| 395 | |||
| 396 | if ( !$self->{stopProcessing} ) { | ||
| 397 | |||
| 398 | my $addToUnion; | ||
| 399 | for my $table ( keys %{$self->{dataSchema}} ) { | ||
| 400 | if ( $table ne 'data' && $self->{dataSchema}{$table}{friendly_url}{type} ) { | ||
| 401 | $addToUnion .= "union SELECT 1,'',''," . $self->safeSQL( $table ) . ".friendly_url,'" . $self->safeSQL( $self->{siteGUID} ) . "',data.guid," . $self->safeSQL( $table ) . ".page_friendly_url,'' from " . $self->safeSQL( $table ) . " left join data on data.friendly_url=" . $self->safeSQL( $table ) . ".page_friendly_url where " . $self->safeSQL( $table ) . ".friendly_url='" . $pageId . "' "; | ||
| 402 | } | ||
| 403 | } | ||
| 404 | |||
| 405 | # | ||
| 406 | # set page defaults if we have them | ||
| 407 | # | ||
| 408 | my @pageArray = @{$self->runSQL( SQL => "select 0,extra_value,title,friendly_url,site_guid,guid,element_type,name from data where (friendly_url like '" . $self->safeSQL( $pageId ) . "' or guid = '" . $self->safeSQL( $pageId ) . "') and (site_guid='" . $self->safeSQL( $self->{siteGUID} ) . "') union select 0,extra_value,title,friendly_url,site_guid,guid,element_type,name from data where (friendly_url like '" . $self->safeSQL( $pageId ) . "' or guid = '" . $self->safeSQL ( $pageId ) . "') and (site_guid='" . $self->safeSQL( $self->fwsGUID() ) . "')" . $addToUnion )}; | ||
| 409 | |||
| 410 | # | ||
| 411 | # shave off the first one in case there is two | ||
| 412 | # | ||
| 413 | my %pageHash; | ||
| 414 | my $dynamicFriendly = shift @pageArray; | ||
| 415 | my $pageExtraValue = shift @pageArray; | ||
| 416 | $pageHash{title} = shift @pageArray; | ||
| 417 | $pageHash{friendlyURL} = shift @pageArray; | ||
| 418 | $pageHash{siteGUID} = shift @pageArray; | ||
| 419 | $pageHash{guid} = shift @pageArray; | ||
| 420 | $pageHash{type} = shift @pageArray; | ||
| 421 | $pageHash{name} = shift @pageArray; | ||
| 422 | %pageHash = $self->mergeExtra( $pageExtraValue, %pageHash ); | ||
| 423 | |||
| 424 | # | ||
| 425 | # if this is blank, that means we are talking about a homepage that does not exist yet | ||
| 426 | # | ||
| 427 | if ( !$pageHash{guid} ) { | ||
| 428 | if ( $self->siteValue( 'homeGUID' ) eq $pageId ) { | ||
| 429 | %pageHash = $self->saveData( | ||
| 430 | guid => $pageId, | ||
| 431 | active => '1', | ||
| 432 | name => '', | ||
| 433 | type => 'page', | ||
| 434 | parent => '' | ||
| 435 | ); | ||
| 436 | } | ||
| 437 | else { | ||
| 438 | # | ||
| 439 | # the page we are looking for does not exist. Lets get back and show some home page! | ||
| 440 | # | ||
| 441 | %pageHash = $self->dataHash( guid => $self->siteValue( 'homeGUID' ) ); | ||
| 442 | $pageId = $self->siteValue( 'homeGUID' ); | ||
| 443 | $self->formValue( 'p', $pageId ); | ||
| 444 | } | ||
| 445 | } | ||
| 446 | |||
| 447 | # | ||
| 448 | # if we DO have a guid, then lets set pageId to what the guid is in case we came in from a p=friendlyurl | ||
| 449 | # | ||
| 450 | else { $pageId = $pageHash{guid} } | ||
| 451 | |||
| 452 | # | ||
| 453 | # set the intial page type to be used to determin if we should be putting columns | ||
| 454 | # | ||
| 455 | my $pageHead; | ||
| 456 | my $somethingIsOnThePage = 0; | ||
| 457 | my %templateHash = $self->templateHash( pageGIUD => $pageId ); | ||
| 458 | |||
| 459 | # | ||
| 460 | # lets not change this stuff around if we are on an aadmin page of some sort | ||
| 461 | # | ||
| 462 | if ( $pageId !~ /^fws_/ ) { | ||
| 463 | # | ||
| 464 | # ONLY if these things aren't set by elements, then set them by the page defaults... if not pass them by and accept what it already is | ||
| 465 | # | ||
| 466 | if ( !$self->siteValue( 'pageTitle' ) ) { $self->siteValue( 'pageTitle' , $self->{siteName} . ' - ' . $pageHash{title} ) } | ||
| 467 | if ( !$self->siteValue( 'pageKeywords' ) ) { $self->siteValue( 'pageKeywords' , $pageHash{pageKeywords} ) } | ||
| 468 | if ( !$self->siteValue( 'pageDescription' ) ) { $self->siteValue( 'pageDescription' , $pageHash{pageDescription} ) } | ||
| 469 | } | ||
| 470 | |||
| 471 | # | ||
| 472 | # set the dir\filename it will be the same for all these files, | ||
| 473 | # | ||
| 474 | my $fileDir = $self->{fileWebPath} . "/" . $self->{siteGUID} . "/"; | ||
| 475 | |||
| 476 | # | ||
| 477 | # Template level CSS | ||
| 478 | # | ||
| 479 | if ( $templateHash{css} > 0 ) { | ||
| 480 | $self->_cssEnable( $self->{siteGUID} . "/" . $templateHash{guid} . "/FWSElement-" . $templateHash{css} ); | ||
| 481 | $somethingIsOnThePage = 1; | ||
| 482 | } | ||
| 483 | if ( $templateHash{js} > 0 ) { | ||
| 484 | $self->_jsEnable( $self->{siteGUID} . "/" . $templateHash{guid} . "/FWSElement-" . $templateHash{js} ); | ||
| 485 | $somethingIsOnThePage = 1; | ||
| 486 | } | ||
| 487 | |||
| 488 | # | ||
| 489 | # site level css and js | ||
| 490 | # | ||
| 491 | $pageHead .= $self->siteValue( 'siteHead' ); | ||
| 492 | if ( $self->siteValue( 'cssDevel' ) > 0 ) { | ||
| 493 | $self->_cssEnable( $self->{siteGUID} . "/assets/FWSElement-" . $self->siteValue( 'cssDevel' ) ); | ||
| 494 | $somethingIsOnThePage = 1; | ||
| 495 | } | ||
| 496 | if ( $self->siteValue( 'jsDevel' ) > 0 ) { | ||
| 497 | $self->_jsEnable( $self->{siteGUID} . "/assets/FWSElement-" . $self->siteValue( 'jsDevel' ) ); | ||
| 498 | $somethingIsOnThePage = 1; | ||
| 499 | } | ||
| 500 | |||
| 501 | # | ||
| 502 | # Page level CSS | ||
| 503 | # | ||
| 504 | $pageHead .= $pageHash{pageHead}; | ||
| 505 | if ( $pageHash{cssDevel} > 0 ) { | ||
| 506 | $self->_cssEnable( $self->{siteGUID} . "/" . $pageId . "/FWSElement-" . $pageHash{cssDevel} ); | ||
| 507 | $somethingIsOnThePage = 1; | ||
| 508 | } | ||
| 509 | if ( $pageHash{jsDevel} > 0 ) { | ||
| 510 | $self->_jsEnable( $self->{siteGUID} . "/" . $pageId . "/FWSElement-" . $pageHash{jsDevel} ); | ||
| 511 | $somethingIsOnThePage = 1; | ||
| 512 | } | ||
| 513 | |||
| 514 | # | ||
| 515 | # set page head | ||
| 516 | # | ||
| 517 | $self->siteValue( 'pageHead', $pageHead ); | ||
| 518 | |||
| 519 | # | ||
| 520 | # if the pageTitle ends with ' - ' then eat it | ||
| 521 | # | ||
| 522 | ( my $cleanTitle = $self->siteValue( 'pageTitle' ) ) =~ s/\s*(-|\|)\s*$//g; | ||
| 523 | $self->siteValue( 'pageTitle', $cleanTitle ); | ||
| 524 | |||
| 525 | my @elements = $self->openRS("select distinct d1.extra_value, d1.site_guid, x2.layout, d1.active, x1.ord+(d1.default_element*100000) as real_ord, x1.layout, d1.disable_edit_mode, d1.groups_guid, d1.guid, d1.element_type, d1.name, d1.title, d1.show_resubscribe, d1.show_login, d1.show_mobile, d1.lang, d1.friendly_url, d1.page_friendly_url, d1.default_element, d1.disable_title, d1.nav_name from data d1 LEFT JOIN guid_xref x1 ON (d1.guid = x1.child) left join guid_xref x2 on (x2.child = x1.parent) left join data d2 on (x2.child=d2.guid) where (d1.site_guid = '" . $self->safeSQL( $self->{siteGUID} ) . "' or d1.site_guid = '" . $self->safeSQL( $self->fwsGUID() ) . "') and d1.element_type <> 'data' and d1.element_type <> 'url' and d1.element_type <> 'page' and (x1.parent='' or d1.guid='" . $self->safeSQL( $pageId ) . "' or (d2.element_type='page')) and (((x1.parent='" . $self->safeSQL( $pageId ) . "') or d1.default_element <> '0') or d1.guid='" . $self->safeSQL( $pageId ) . "') order by x1.layout, real_ord", 1); | ||
| 526 | |||
| 527 | # | ||
| 528 | # set the pageTitle Hash into a fws var | ||
| 529 | # | ||
| 530 | $self->formValue( 'fws_pageTitle' , $pageHash{pageTitle} ); | ||
| 531 | $self->formValue( 'fws_pageNavigationName' , $pageHash{name} ); | ||
| 532 | $self->formValue( 'fws_pageReferenceId' , $pageHash{name} ); | ||
| 533 | $self->formValue( 'fws_pageId' , $pageHash{guid} ); | ||
| 534 | $self->formValue( 'fws_secureDomain' , $self->{secureDomain} ); | ||
| 535 | $self->formValue( 'fws_domain' , $self->{domain} ); | ||
| 536 | |||
| 537 | # | ||
| 538 | # Mech to figure out what number layout in the list we are so we can set class based on location ancestory | ||
| 539 | # | ||
| 540 | my %layoutCountHash; | ||
| 541 | |||
| 542 | |||
| 543 | my $columnWrapperStartFlag = 0; | ||
| 544 | my $columnWrapperStopFlag = 0; | ||
| 545 | my $lastLayoutId = 0; | ||
| 546 | my $elementTotal = 0; | ||
| 547 | my %columnContent; | ||
| 548 | my %columnCount; | ||
| 549 | my $FWSMenu; | ||
| 550 | |||
| 551 | # | ||
| 552 | # set the hash we use to ensure we don't use an default element more than once on the same page | ||
| 553 | # | ||
| 554 | my %elementUsed; | ||
| 555 | |||
| 556 | # | ||
| 557 | # here is some js and css hashs so we don't add multipuls to each page if ther eis more than one element that has the same file on one page | ||
| 558 | # | ||
| 559 | my %JSHash; | ||
| 560 | my %CSSHash; | ||
| 561 | |||
| 562 | while ( @elements ) { | ||
| 563 | # | ||
| 564 | # start with ext hash, and then overwrite if there is conflicts | ||
| 565 | # | ||
| 566 | my $extraValue = shift @elements; | ||
| 567 | my %valueHash = $self->mergeExtra( $extraValue ); | ||
| 568 | |||
| 569 | $valueHash{siteGUID} = shift @elements; | ||
| 570 | my $elementTemplateId = shift @elements; | ||
| 571 | $valueHash{active} = shift @elements; | ||
| 572 | $valueHash{ord} = shift @elements; | ||
| 573 | $valueHash{layout} = shift @elements; | ||
| 574 | $valueHash{disableEditMode} = shift @elements; | ||
| 575 | $valueHash{userGroup} = shift @elements; | ||
| 576 | $valueHash{guid} = shift @elements; | ||
| 577 | $valueHash{type} = shift @elements; | ||
| 578 | $valueHash{name} = shift @elements; | ||
| 579 | $valueHash{title} = shift @elements; | ||
| 580 | $valueHash{showResubscribe} = shift @elements; | ||
| 581 | $valueHash{showLogin} = shift @elements; | ||
| 582 | $valueHash{showMobile} = shift @elements; | ||
| 583 | $valueHash{lang} = shift @elements; | ||
| 584 | $valueHash{friendlyURL} = shift @elements; | ||
| 585 | $valueHash{pageFriendlyURL} = shift @elements; | ||
| 586 | $valueHash{defaultElement} = shift @elements; | ||
| 587 | $valueHash{disableTitle} = shift @elements; | ||
| 588 | $valueHash{navigationName} = shift @elements; | ||
| 589 | |||
| 590 | # | ||
| 591 | # make sure userGroup is numeric | ||
| 592 | # | ||
| 593 | $valueHash{userGroup} ||= 0; | ||
| 594 | |||
| 595 | # | ||
| 596 | # if title is blank, lets use name | ||
| 597 | # | ||
| 598 | $valueHash{title} ||= $valueHash{name}; | ||
| 599 | |||
| 600 | # | ||
| 601 | # a couple of presets we will need | ||
| 602 | # | ||
| 603 | $valueHash{editBoxColor} = "#FF0000"; | ||
| 604 | |||
| 605 | # | ||
| 606 | # This should be legacy at some point and replaced with pageGUID... we will address later | ||
| 607 | # | ||
| 608 | $valueHash{parent} = $pageId; | ||
| 609 | |||
| 610 | # | ||
| 611 | # by defult lets give a delete button to everything | ||
| 612 | # | ||
| 613 | $valueHash{deleteTool} = 1; | ||
| 614 | |||
| 615 | # | ||
| 616 | # figure out the layout area and tweek for normilization | ||
| 617 | # | ||
| 618 | my $layoutCount = $layoutCountHash{$valueHash{layout}}; | ||
| 619 | $layoutCountHash{$valueHash{layout}}++; | ||
| 620 | if ( $elementTemplateId eq '') { $elementTemplateId = $templateHash{homeGUID} } | ||
| 621 | if ( $elementTemplateId eq '0') { $elementTemplateId = $templateHash{defaultGUID} } | ||
| 622 | |||
| 623 | # | ||
| 624 | # make sure we are talking about the element on a compatable page... or we are cool if the element is the dirived element because it was | ||
| 625 | # accessed via p=theElementId or p=theFriendlyUrl or /theElementsFriendlyURL | ||
| 626 | # | ||
| 627 | # And Check to see if we already spit out this element to the page | ||
| 628 | # | ||
| 629 | if ( ( $elementTemplateId eq $templateHash{guid} || $valueHash{guid} eq $pageId ) && !$elementUsed{$valueHash{guid}} ) { | ||
| 630 | |||
| 631 | # | ||
| 632 | # set the flag so we don't use it more than once | ||
| 633 | # | ||
| 634 | $elementUsed{$valueHash{guid}} = 1; | ||
| 635 | |||
| 636 | # | ||
| 637 | # is active or not | ||
| 638 | # | ||
| 639 | if (( $valueHash{active} || ( $self->formValue( 'editMode' ) ) ) ) { | ||
| 640 | |||
| 641 | $valueHash{layout} ||= 1; | ||
| 642 | |||
| 643 | # | ||
| 644 | # LOGIN GROUP KEY | ||
| 645 | # | ||
| 646 | # 0 No login required | ||
| 647 | # 1 Show if logged in as a site user | ||
| 648 | # -101 Show if logged in as a admin user | ||
| 649 | # -103 Show if logged in as a subscriber | ||
| 650 | # -1 Do not show if logged in as a site user | ||
| 651 | # -102 Do not show if logged in as a admin user | ||
| 652 | # -104 Do not show if logged in as a subscriber'; | ||
| 653 | |||
| 654 | # | ||
| 655 | # if userGroup ne 0 then we need to be logged in or supress | ||
| 656 | # | ||
| 657 | if ( $valueHash{userGroup} ne '0' ) { | ||
| 658 | my %userHash = $self->userHash(); | ||
| 659 | |||
| 660 | # | ||
| 661 | # if If group ID is "-1" then all I need to be is just logged in | ||
| 662 | # Special login code group flag checker | ||
| 663 | # | ||
| 664 | %userHash = $self->runScript( 'login', | ||
| 665 | %userHash, | ||
| 666 | 'userGroup' => $valueHash{userGroup}, | ||
| 667 | 'type' => $valueHash{type}, | ||
| 668 | 'showLogin' => $valueHash{showLogin}, | ||
| 669 | 'showResubscribe' => $valueHash{showResubscribe}, | ||
| 670 | |||
| 671 | # LEGACY NAMES | ||
| 672 | 'elementType' => $valueHash{type}, | ||
| 673 | 'show_login' => $valueHash{showLogin}, | ||
| 674 | 'show_resubscribe' => $valueHash{showResubscribe}, | ||
| 675 | ); | ||
| 676 | |||
| 677 | # | ||
| 678 | # se the login mod stuff back in case it changed form the script | ||
| 679 | # | ||
| 680 | $valueHash{type} = $userHash{elementType}; | ||
| 681 | |||
| 682 | # | ||
| 683 | # you must be admin logged in to see it. | ||
| 684 | # | ||
| 685 | if ( $userHash{userGroup} eq '-101' && !$self->isAdminLoggedIn() ) { | ||
| 686 | $valueHash{type} = ''; | ||
| 687 | } | ||
| 688 | |||
| 689 | # | ||
| 690 | # you must be admin logged in to see it. | ||
| 691 | # | ||
| 692 | if ( $userHash{userGroup} eq '-102' && $self->isAdminLoggedIn() ) { | ||
| 693 | $valueHash{type} = ''; | ||
| 694 | } | ||
| 695 | |||
| 696 | # | ||
| 697 | # you can't be logged in to see it. supress the element | ||
| 698 | # | ||
| 699 | if ( $userHash{userGroup} eq '-1' && $userHash{active} ) { | ||
| 700 | $valueHash{type} = ''; | ||
| 701 | } | ||
| 702 | |||
| 703 | |||
| 704 | # | ||
| 705 | # if this is set to 0 then negative the login because it must have been set that way | ||
| 706 | # from the loginMod, This is a string and can contain guids, so we can't use math here | ||
| 707 | # | ||
| 708 | if ( $userHash{userGroup} !~ /^-/ || $userHash{userGroup} eq '0') { | ||
| 709 | |||
| 710 | # | ||
| 711 | # If group ID is "1" then all I need to be is just logged in | ||
| 712 | # | ||
| 713 | if ( $userHash{userGroup} eq '1' && $userHash{active} ) { | ||
| 714 | #DON't panic. we good to go! we won't switch anyting | ||
| 715 | } | ||
| 716 | |||
| 717 | # | ||
| 718 | # If we have a spacific group, figure it out and do it | ||
| 719 | # | ||
| 720 | elsif ( $userHash{group}{$userHash{userGroup}} && $userHash{active} ) { | ||
| 721 | #Nice! we are gtg, don't do anything | ||
| 722 | } | ||
| 723 | |||
| 724 | # | ||
| 725 | # Set elementType your not set to see, set login or blank the element | ||
| 726 | # | ||
| 727 | else { | ||
| 728 | if ( $userHash{show_login} ) { | ||
| 729 | $valueHash{type} = 'FWSLogin'; | ||
| 730 | } | ||
| 731 | else { | ||
| 732 | $valueHash{type} = ''; | ||
| 733 | } | ||
| 734 | } | ||
| 735 | } | ||
| 736 | } | ||
| 737 | |||
| 738 | # | ||
| 739 | # If your a mobile device, and your mobile is set to (2) show desktop only then eat the type | ||
| 740 | # | ||
| 741 | if ( $ENV{HTTP_USER_AGENT} =~ /mobile/i && $valueHash{showMobile} eq '2' ) { | ||
| 742 | $valueHash{type} = ''; | ||
| 743 | } | ||
| 744 | |||
| 745 | # | ||
| 746 | # If your NOT a mobile device, and your mobile is set to (1) show mobile only then eat the type | ||
| 747 | # | ||
| 748 | if ( $ENV{HTTP_USER_AGENT} !~ /mobile/i && $valueHash{showMobile} eq '1' ) { | ||
| 749 | $valueHash{type} = ''; | ||
| 750 | } | ||
| 751 | |||
| 752 | # | ||
| 753 | # set defaults and get the editBox going | ||
| 754 | # | ||
| 755 | my $html; | ||
| 756 | |||
| 757 | # | ||
| 758 | # set elementId in a formValue so the FWS can use it when working with adminField function | ||
| 759 | # | ||
| 760 | $self->formValue( 'FWS_elementId', $valueHash{guid} ); | ||
| 761 | $self->formValue( 'FWS_pageId', $pageId ); | ||
| 762 | |||
| 763 | # | ||
| 764 | # Get the element | ||
| 765 | # | ||
| 766 | my %elementHash = $self->elementHash( guid => $valueHash{type} ); | ||
| 767 | |||
| 768 | # | ||
| 769 | # add css or js if its needed | ||
| 770 | # | ||
| 771 | if ( !$JSHash{$valueHash{type}} && $elementHash{jsDevel} ) { | ||
| 772 | $JSHash{$valueHash{type}} = 1; | ||
| 773 | $self->_jsEnable( $elementHash{siteGUID} . "/" . $valueHash{type} . "/FWSElement-" . $elementHash{jsDevel},-1000 ); | ||
| 774 | } | ||
| 775 | if ( !$CSSHash{$valueHash{type}} && $elementHash{cssDevel} ) { | ||
| 776 | $CSSHash{$valueHash{type}} = 1; | ||
| 777 | $self->_cssEnable( $elementHash{siteGUID} . "/" . $valueHash{type} . "/FWSElement-" . $elementHash{cssDevel},-1000 ); | ||
| 778 | } | ||
| 779 | |||
| 780 | # | ||
| 781 | # convert the code to the fws friendly version | ||
| 782 | # | ||
| 783 | $elementHash{scriptDevel} =~ s/self-/fws-/g; | ||
| 784 | |||
| 785 | # | ||
| 786 | # copy the GNF object to fws | ||
| 787 | # | ||
| 788 | my $fws = $self; | ||
| 789 | |||
| 790 | # | ||
| 791 | # set the valueHash for value conduit style programming | ||
| 792 | # | ||
| 793 | #my %valueHash; | ||
| 794 | $valueHash{pageId} = $pageId; | ||
| 795 | $valueHash{elementId} = $valueHash{guid}; | ||
| 796 | $valueHash{elementWebPath} = $self->{fileWebPath} . "/" . $elementHash{siteGUID} . "/" . $valueHash{type}; | ||
| 797 | |||
| 798 | # | ||
| 799 | # set this so its available in the elementStart via the FWS_elementClassPrefix, and valueHash | ||
| 800 | # | ||
| 801 | $self->formValue( 'FWS_elementClassPrefix', $elementHash{classPrefix} ); | ||
| 802 | $valueHash{classPrefix} = $elementHash{classPrefix}; | ||
| 803 | |||
| 804 | # | ||
| 805 | # | ||
| 806 | # run the script and inject it into the html for the node | ||
| 807 | # | ||
| 808 | my $htmlHold = $html; | ||
| 809 | $html = ''; | ||
| 810 | ## no critic qw(RequireCheckingReturnValueOfEval ProhibitStringyEval) | ||
| 811 | eval $elementHash{scriptDevel}; | ||
| 812 | ## use critic | ||
| 813 | my $errorCode = $@; | ||
| 814 | if ( $errorCode ) { | ||
| 815 | $valueHash{html} .= "<div style=\"border:solid 1px;font-weight:bold;\">FrameWork Element Error:</div><div style=\"font-style:italic;\">" . $errorCode . "</div>"; | ||
| 816 | } | ||
| 817 | |||
| 818 | # | ||
| 819 | # now put it back | ||
| 820 | # | ||
| 821 | $self = $fws; | ||
| 822 | $html = $valueHash{html}; | ||
| 823 | |||
| 824 | # | ||
| 825 | # if we are updating a element from editModeUpdate - then just do that only | ||
| 826 | # | ||
| 827 | if ( $self->formValue( 'FWS_editModeUpdate' ) && $pageId eq $valueHash{guid} ) { | ||
| 828 | # | ||
| 829 | # make sure debug is turned off, because that would look silly in fws devel mode | ||
| 830 | # | ||
| 831 | return $self->editBox(%valueHash) . $html | ||
| 832 | } | ||
| 833 | else { | ||
| 834 | # | ||
| 835 | # if this is a showElementOnly then ditch the current page up to this point | ||
| 836 | # and also ditch out of the element loop | ||
| 837 | # | ||
| 838 | if ( $showElementOnly || $self->formValue( 'FWS_showElementOnly') ) { return $html } | ||
| 839 | else { $html = $htmlHold . $html } | ||
| 840 | } | ||
| 841 | |||
| 842 | # | ||
| 843 | # start the top of the element if its new | ||
| 844 | # | ||
| 845 | if ( !$columnContent{$valueHash{layout}} ) { | ||
| 846 | $columnCount{$valueHash{layout}} = 0; | ||
| 847 | } | ||
| 848 | |||
| 849 | # | ||
| 850 | # increment the column count | ||
| 851 | # | ||
| 852 | $columnCount{$valueHash{layout}}++; | ||
| 853 | |||
| 854 | # | ||
| 855 | # create the edit control if we are supposed to | ||
| 856 | # | ||
| 857 | my $editBox; | ||
| 858 | |||
| 859 | $columnContent{$valueHash{layout}} .= "<div" . $editBox . " class=\"" . $valueHash{layout} . "_element element_" . $valueHash{guid} . "\" id=\"" . $valueHash{layout} . "_element_" . $columnCount{$valueHash{layout}} . "\">"; | ||
| 860 | |||
| 861 | if ( ( $self->{adminLoginId} && $valueHash{siteGUID} eq $self->{siteGUID} && !$self->formValue( 'FWS_showElementOnly' ) && !$showElementOnly && !$valueHash{disableEditMode} && $self->formValue( 'editMode' ) ) ) { | ||
| 862 | $columnContent{$valueHash{layout}} .= $self->editBox( %valueHash, AJAXDivStyle => 'border: solid 1px #FF0000;border-top: 0;', editBoxContent => $html ); | ||
| 863 | } | ||
| 864 | else { | ||
| 865 | $columnContent{$valueHash{layout}} .= $html; | ||
| 866 | } | ||
| 867 | |||
| 868 | $elementTotal++; | ||
| 869 | $columnContent{$valueHash{layout}} .= "</div>"; | ||
| 870 | } | ||
| 871 | } | ||
| 872 | } | ||
| 873 | |||
| 874 | # | ||
| 875 | # check if this is the home page, with no stuff on it, if not we need to dump to login, or redirect to fws_systemInfo | ||
| 876 | # only do this for the site though, if your making blank other sites for other reasons lets just let that happen | ||
| 877 | # | ||
| 878 | if ( $elementTotal < 1 && $pageId eq $self->homeGUID() && !$somethingIsOnThePage && $self->formValue( 's' ) eq 'site' ) { | ||
| 879 | if ( $self->{adminLoginId} ) { | ||
| 880 | print "Status: 302 Found\n"; | ||
| 881 | print "Location: " . $self->{scriptName} . $self->{queryHead} . "p=fws_systemInfo\n\n"; | ||
| 882 | } | ||
| 883 | else { | ||
| 884 | $self->displayAdminLogin(); | ||
| 885 | } | ||
| 886 | } | ||
| 887 | |||
| 888 | |||
| 889 | if ( !$showElementOnly ) { | ||
| 890 | |||
| 891 | $pageHTML = $templateHash{template}; | ||
| 892 | |||
| 893 | # | ||
| 894 | # Put in the edit mode box if we are in edit mod and loged in as the correct user for this site | ||
| 895 | # | ||
| 896 | |||
| 897 | if ( $self->{adminLoginId} ) { | ||
| 898 | # | ||
| 899 | # set all the things we could need | ||
| 900 | # | ||
| 901 | $self->{tinyMCEEnable} = 1; | ||
| 902 | $self->jqueryEnable( 'ui-1.8.9' ); | ||
| 903 | $self->jqueryEnable( 'ui.widget-1.8.9' ); | ||
| 904 | $self->jqueryEnable( 'ui.mouse-1.8.9' ); | ||
| 905 | $self->jqueryEnable( 'ui.datepicker-1.8.9' ); | ||
| 906 | $self->jqueryEnable( 'ui.slider-1.8.9' ); | ||
| 907 | $self->jqueryEnable( 'timepickr-0.9.6' ); | ||
| 908 | $self->jqueryEnable( 'ui.tabs-1.8.9' ); | ||
| 909 | $self->jqueryEnable( 'simplemodal-1.4.4' ); | ||
| 910 | $self->jqueryEnable( 'fileupload-ui-4.4.1' ); | ||
| 911 | $self->jqueryEnable( 'fileupload-4.5.1' ); | ||
| 912 | $self->jqueryEnable( 'fileupload-uix-4.6' ); | ||
| 913 | $self->jqueryEnable( 'ui.fws-1.8.9' ); | ||
| 914 | |||
| 915 | if ( $pageId eq $self->homeGUID() ) { $pageHash{disableDeleteTool} = 1 } | ||
| 916 | $pageHash{layout} = 'FWSPageMenu'; | ||
| 917 | $pageHash{guid} = $pageId; | ||
| 918 | $pageHash{FWSMenuTool} = 1; | ||
| 919 | $pageHash{pageOnly} = 1; | ||
| 920 | $pageHash{alwaysShow} = 1; | ||
| 921 | $pageHash{disableActiveTool} = 1; | ||
| 922 | $pageHash{disableOrderTool} = 1; | ||
| 923 | if ( $pageHash{siteGUID} eq $self->{siteGUID} ) { | ||
| 924 | $pageHash{name} = $self->FWSMenu( pageId => $pageId ) . $pageHash{name}; | ||
| 925 | } | ||
| 926 | else { | ||
| 927 | $pageHash{addElementTool} = 0; | ||
| 928 | $pageHash{disableDeleteTool} = 1; | ||
| 929 | $pageHash{disableEditTool} = 1; | ||
| 930 | $pageHash{disableActiveTool} = 1; | ||
| 931 | $pageHash{disableOrderTool} = 1; | ||
| 932 | $pageHash{name} = "Default FWS Page - To override this page create a new page with the friendly url of [ " . $pageHash{friendlyURL} . " ]"; | ||
| 933 | } | ||
| 934 | |||
| 935 | |||
| 936 | # | ||
| 937 | # if we are not able to see the buttons lets kill them | ||
| 938 | # | ||
| 939 | if ( ( !$self->userValue( 'showDesign' ) && !$self->userValue( 'showContent' ) && !$self->userValue( 'showDeveloper' ) ) || ( $pageHash{siteGUID} ne $self->{siteGUID} ) ) { | ||
| 940 | $pageHash{addElementTool} = 0; | ||
| 941 | $pageHash{disableDeleteTool} = 1; | ||
| 942 | $pageHash{disableEditTool} = 1; | ||
| 943 | $pageHash{disableActiveTool} = 1; | ||
| 944 | $pageHash{disableOrderTool} = 1; | ||
| 945 | } | ||
| 946 | |||
| 947 | $pageHash{editBoxColor} = '#000000'; | ||
| 948 | $FWSMenu .= $self->editBox( %pageHash ); | ||
| 949 | } | ||
| 950 | |||
| 951 | # | ||
| 952 | # before we print head and foot css and js we need to compile and set cache | ||
| 953 | # | ||
| 954 | $self->setPageCache(); | ||
| 955 | |||
| 956 | # | ||
| 957 | # add the head where it goes | ||
| 958 | # | ||
| 959 | my $FWSHead = $self->FWSHead(); | ||
| 960 | $pageHTML =~ s/#FWSHead#/$FWSHead/g; | ||
| 961 | |||
| 962 | # | ||
| 963 | # add the menu | ||
| 964 | # | ||
| 965 | $pageHTML =~ s/#FWSMenu#/$FWSMenu/g; | ||
| 966 | |||
| 967 | # | ||
| 968 | # Clean up the adminLoggedIn stuff | ||
| 969 | # | ||
| 970 | $pageHTML =~ s/#FWSAdminLoggedIn#//g; | ||
| 971 | $pageHTML =~ s/#FWSAdminLoggedInEnd#//g; | ||
| 972 | |||
| 973 | # | ||
| 974 | # but all non-main info in the page | ||
| 975 | # | ||
| 976 | while ( $templateHash{template} =~ /#FWSShow-(.*?)#/g ) { | ||
| 977 | my $layout = $1; | ||
| 978 | if ( $layout ne 'main' ) { | ||
| 979 | |||
| 980 | # | ||
| 981 | # add it to the page | ||
| 982 | # | ||
| 983 | $pageHTML = $self->_replaceContentColumn( | ||
| 984 | layout => $layout, | ||
| 985 | html => $pageHTML, | ||
| 986 | content => $columnContent{$layout}, | ||
| 987 | guid => $pageId, | ||
| 988 | contentType => 'FWSShow', | ||
| 989 | pageType => $pageHash{type}, | ||
| 990 | siteGUID => $pageHash{siteGUID}, | ||
| 991 | ); | ||
| 992 | |||
| 993 | # | ||
| 994 | # delete it so we don't add it to main in the next section | ||
| 995 | # | ||
| 996 | delete $columnContent{$layout}; | ||
| 997 | } | ||
| 998 | } | ||
| 999 | |||
| 1000 | # | ||
| 1001 | # but all non-main info in the page | ||
| 1002 | # | ||
| 1003 | while ( $templateHash{template} =~ /#FWSShowNoHeader-(.*?)#/g ) { | ||
| 1004 | my $layout = $1; | ||
| 1005 | if ( $layout ne 'main' ) { | ||
| 1006 | |||
| 1007 | # | ||
| 1008 | # add it to the page | ||
| 1009 | # | ||
| 1010 | $pageHTML = $self->_replaceContentColumn( | ||
| 1011 | layout => $layout, | ||
| 1012 | html => $pageHTML, | ||
| 1013 | content => $columnContent{$layout}, | ||
| 1014 | guid => $pageId, | ||
| 1015 | contentType => 'FWSShowNoHeader', | ||
| 1016 | pageType => $pageHash{type}, | ||
| 1017 | siteGUID => $pageHash{siteGUID}, | ||
| 1018 | ); | ||
| 1019 | |||
| 1020 | # | ||
| 1021 | # delete it so we don't add it to main in the next section | ||
| 1022 | # | ||
| 1023 | delete $columnContent{$layout}; | ||
| 1024 | } | ||
| 1025 | } | ||
| 1026 | |||
| 1027 | # | ||
| 1028 | # add the rest to main | ||
| 1029 | # | ||
| 1030 | for my $columnKey ( keys %columnContent ) { | ||
| 1031 | if ( $columnContent{$columnKey} ne '' && $columnKey ne 'main' ) { | ||
| 1032 | $columnContent{main} .= $columnContent{$columnKey}; | ||
| 1033 | } | ||
| 1034 | } | ||
| 1035 | |||
| 1036 | # | ||
| 1037 | # add main to the page | ||
| 1038 | # | ||
| 1039 | while ( $templateHash{template} =~ /#FWSShow-main#/g ) { | ||
| 1040 | $pageHTML = $self->_replaceContentColumn( | ||
| 1041 | layout => 'main', | ||
| 1042 | html => $pageHTML, | ||
| 1043 | content => $columnContent{main}, | ||
| 1044 | guid => $pageId, | ||
| 1045 | contentType => 'FWSShow', | ||
| 1046 | pageType => $pageHash{type}, | ||
| 1047 | siteGUID => $pageHash{siteGUID}, | ||
| 1048 | ); | ||
| 1049 | } | ||
| 1050 | |||
| 1051 | |||
| 1052 | my $FWSJava = $self->FWSJava(); | ||
| 1053 | $pageHTML =~ s/#FWSJavaLoad#/$FWSJava/g; | ||
| 1054 | |||
| 1055 | |||
| 1056 | my $FWSLink = "<a href=\"http://www.frameworksites.com/poweredByFrameWorkSites\"><img style=\"border: 0 none;\" src=\"https://www.frameworksites.com/poweredByFrameWorkSites.jpg\" alt=\"This site was built using FrameWork Sites!\"/></a>"; | ||
| 1057 | $pageHTML =~ s/#FWSLink#/$FWSLink/g; | ||
| 1058 | while ( $pageHTML =~ /#FWSField-(.*?)#/g ) { | ||
| 1059 | my $formField = $1; | ||
| 1060 | my $changeFrom = '#FWSField-' . $formField . '#'; | ||
| 1061 | my $changeTo = $self->removeHTML( $self->formValue( $formField ) ); | ||
| 1062 | $pageHTML =~ s/$changeFrom/$changeTo/g; | ||
| 1063 | } | ||
| 1064 | } | ||
| 1065 | } | ||
| 1066 | } | ||
| 1067 | return $pageHTML; | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | |||
| 1071 | |||
| 1072 | sub _replaceContentColumn { | ||
| 1073 | my ( $self, %editHash ) = @_; | ||
| 1074 | |||
| 1075 | $editHash{id} = $editHash{guid}; | ||
| 1076 | $editHash{type} = ''; | ||
| 1077 | $editHash{editBoxColor} = '#2b6fb6'; | ||
| 1078 | $editHash{layoutTitle} = 1; | ||
| 1079 | $editHash{addSubElementTool} = 0; | ||
| 1080 | $editHash{disableEditTool} = 1; | ||
| 1081 | $editHash{disableActiveTool} = 1; | ||
| 1082 | $editHash{orderTool} = 1; | ||
| 1083 | $editHash{name} = '| ' . $editHash{layout} . ' |'; | ||
| 1084 | my $changeFrom = '#' . $editHash{contentType} . '-' . $editHash{layout} . '#'; | ||
| 1085 | my $changeTo = '<div class="FWSLanguage-' . uc( $self->language() ) . '" id="' . $editHash{layout} . '">'; | ||
| 1086 | |||
| 1087 | if ( $editHash{siteGUID} ne $self->fwsGUID() || $self->{showFWSInSiteList} ) { | ||
| 1088 | if ( $self->formValue( 'editMode' ) && $editHash{contentType} ne 'FWSShowNoHeader' && $editHash{pageType} eq 'page' && !$self->{hideEditModeHeaders} ) { | ||
| 1089 | $changeTo .= $self->editBox( %editHash ); | ||
| 1090 | } | ||
| 1091 | } | ||
| 1092 | |||
| 1093 | $changeTo .= $editHash{content} . '</div>'; | ||
| 1094 | $editHash{html} =~ s/$changeFrom/$changeTo/msg; | ||
| 1095 | |||
| 1096 | return( $editHash{html} ); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | =head1 AUTHOR | ||
| 1100 | |||
| 1101 | Nate Lewis, C<< <nlewis at gnetworks.com> >> | ||
| 1102 | |||
| 1103 | =head1 BUGS | ||
| 1104 | |||
| 1105 | Please report any bugs or feature requests to C<bug-fws-v2 at rt.cpan.org>, or through | ||
| 1106 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FWS-V2>. I will be notified, and then you'll | ||
| 1107 | automatically be notified of progress on your bug as I make changes. | ||
| 1108 | |||
| 1109 | |||
| 1110 | |||
| 1111 | |||
| 1112 | =head1 SUPPORT | ||
| 1113 | |||
| 1114 | You can find documentation for this module with the perldoc command. | ||
| 1115 | |||
| 1116 | perldoc FWS::V2::Display | ||
| 1117 | |||
| 1118 | |||
| 1119 | You can also look for information at: | ||
| 1120 | |||
| 1121 | =over 4 | ||
| 1122 | |||
| 1123 | =item * RT: CPAN's request tracker (report bugs here) | ||
| 1124 | |||
| 1125 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=FWS-V2> | ||
| 1126 | |||
| 1127 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 1128 | |||
| 1129 | L<http://annocpan.org/dist/FWS-V2> | ||
| 1130 | |||
| 1131 | =item * CPAN Ratings | ||
| 1132 | |||
| 1133 | L<http://cpanratings.perl.org/d/FWS-V2> | ||
| 1134 | |||
| 1135 | =item * Search CPAN | ||
| 1136 | |||
| 1137 | L<http://search.cpan.org/dist/FWS-V2/> | ||
| 1138 | |||
| 1139 | =back | ||
| 1140 | |||
| 1141 | |||
| 1142 | =head1 LICENSE AND COPYRIGHT | ||
| 1143 | |||
| 1144 | Copyright 2013 Nate Lewis. | ||
| 1145 | |||
| 1146 | This program is free software; you can redistribute it and/or modify it | ||
| 1147 | under the terms of either: the GNU General Public License as published | ||
| 1148 | by the Free Software Foundation; or the Artistic License. | ||
| 1149 | |||
| 1150 | See http://dev.perl.org/licenses/ for more information. | ||
| 1151 | |||
| 1152 | |||
| 1153 | =cut | ||
| 1154 | |||
| 1155 | 1; # End of FWS::V2::Display |