From 6bb5d83770d75dce4ef772c4e64f03fabe05328b Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 24 Oct 2016 11:18:17 -0400 Subject: [PATCH] Updates for packages Updating the package detail breadcrumbs. Update package app so they can put on any page. Page will get full width. Currently will only work if previewed from admin side. --- Toolkit/Packages/application.ini | 2 +- Toolkit/Page.php | 11 +- Toolkit/Template/BreadCrumbs.php | 193 ++++++++++++------------ admin/packages.php | 4 +- js/jquery.browser/jquery.browser.min.js | 14 ++ package.json | 3 +- package.php | 12 +- templates/template.html | 4 +- 8 files changed, 135 insertions(+), 108 deletions(-) create mode 100644 js/jquery.browser/jquery.browser.min.js diff --git a/Toolkit/Packages/application.ini b/Toolkit/Packages/application.ini index 67242c6..9a80fa5 100644 --- a/Toolkit/Packages/application.ini +++ b/Toolkit/Packages/application.ini @@ -19,7 +19,7 @@ jqueryui.version = "1.12.1" ; jQuery themes {"base", "cupertino", "smoothness", "start"} jqueryui.theme = "smoothness" -canCreateOnAnyPage = Off +canCreateOnAnyPage = On ; development server configuration data inherits from production and ; overrides values as necessary diff --git a/Toolkit/Page.php b/Toolkit/Page.php index df0b3c5..08db54a 100755 --- a/Toolkit/Page.php +++ b/Toolkit/Page.php @@ -460,9 +460,7 @@ class Toolkit_Page } $this->_navigationFactory->setGateway($this->_pageGateway); $this->mainNav = $this->_getMainNav($this->_catid); - if ( $this->_catid != 4 ) { - $this->sideNav = $this->_getSideNav($this->_catid); - } + $this->sideNav = $this->_getSideNav($this->_catid); $this->mobileNav = $this->_getMobileNavigation(); $this->newsletterAction = Toolkit_Template_Page::getSeoUrl( @@ -523,7 +521,9 @@ class Toolkit_Page ) { $this->_getBlocks(); } - $this->_getPackages(); + //if ( filter_var( $_REQUEST['preview'], FILTER_VALIDATE_BOOLEAN ) ) { + $this->_getPackages(); + //} if ( defined("PRESS_DB") && PRESS_DB @@ -847,6 +847,9 @@ class Toolkit_Page $this->packages = $packages->getPagePackagesAsArray((int)$this->_catid); $cache->save(serialize($this->packages), $this->_catid, 'Packages'); } + if ( count( $this->packages ) > 0 ) { + $this->sideNav = ''; + } } /** diff --git a/Toolkit/Template/BreadCrumbs.php b/Toolkit/Template/BreadCrumbs.php index 1b29dd8..856ff32 100644 --- a/Toolkit/Template/BreadCrumbs.php +++ b/Toolkit/Template/BreadCrumbs.php @@ -29,17 +29,17 @@ */ class Toolkit_Template_BreadCrumbs { - // {{{ properties + // {{{ properties /** * Description for $pageGateway * @var Toolkit_Toolbox_PageGatewayAbstract $gateway * @access protected */ - protected $pageGateway; + protected $pageGateway; - // }}} - // {{{ __construct() + // }}} + // {{{ __construct() /** * Class constructor @@ -47,13 +47,13 @@ class Toolkit_Template_BreadCrumbs * @param Toolkit_Toolbox_PageGatewayAbstract $gateway Gateway * @access public */ - public function __construct(Toolkit_Toolbox_PageGatewayAbstract $gateway) - { - $this->pageGateway = $gateway; - } + public function __construct(Toolkit_Toolbox_PageGatewayAbstract $gateway) + { + $this->pageGateway = $gateway; + } - // }}} - // {{{ getBreadCrumbsArray() + // }}} + // {{{ getBreadCrumbsArray() /** * Gets bread crumbs array @@ -64,35 +64,35 @@ class Toolkit_Template_BreadCrumbs * @throws RuntimeException * @access protected */ - protected function getBreadCrumbsArray($id) - { - $stack = array(); - - $hasPhotoGalleriesOnThisPage - = ( defined('PHOTO_GALLERY') - && PHOTO_GALLERY - && filter_var($_GET['photo_catid'], FILTER_VALIDATE_INT) - ); - - if ($hasPhotoGalleriesOnThisPage) { - if (!$catid = filter_var($_GET['catid'], FILTER_VALIDATE_INT)) { - throw new RuntimeException('Invalid catid'); - } - if (!$photoCatid = filter_var($_GET['photo_catid'], FILTER_VALIDATE_INT)) { - throw new RuntimeException('Invalid photo_catid'); - } - $page = $this->pageGateway->findNavItem($catid); - array_unshift($stack, $page['photo_galleries'][$_GET['photo_catid']]); - $seoUrl = Toolkit_Template_Page::getSeoUrl( - $this->pageGateway, - $_GET['catid'] - ); - $anchor = ''.$page['navigation_name'].''; - array_unshift($stack, $anchor); - } + protected function getBreadCrumbsArray($id) + { + $stack = array(); + + $hasPhotoGalleriesOnThisPage + = ( defined('PHOTO_GALLERY') + && PHOTO_GALLERY + && filter_var($_GET['photo_catid'], FILTER_VALIDATE_INT) + ); + + if ($hasPhotoGalleriesOnThisPage) { + if (!$catid = filter_var($_GET['catid'], FILTER_VALIDATE_INT)) { + throw new RuntimeException('Invalid catid'); + } + if (!$photoCatid = filter_var($_GET['photo_catid'], FILTER_VALIDATE_INT)) { + throw new RuntimeException('Invalid photo_catid'); + } + $page = $this->pageGateway->findNavItem($catid); + array_unshift($stack, $page['photo_galleries'][$_GET['photo_catid']]); + $seoUrl = Toolkit_Template_Page::getSeoUrl( + $this->pageGateway, + $_GET['catid'] + ); + $anchor = ''.$page['navigation_name'].''; + array_unshift($stack, $anchor); + } $hasCommonEvents = (defined('COMMON_EVENTS') && COMMON_EVENTS); - if ($id != HOME_ID) { + if ($id != HOME_ID) { if ( defined('EVENT_DB') && EVENT_DB && !$hasCommonEvents && $eventId = filter_var($_REQUEST['eventid'], FILTER_VALIDATE_INT) @@ -118,6 +118,13 @@ class Toolkit_Template_BreadCrumbs Toolkit_Common::handleError($e); } } + if ( $package_id = filter_var( $_REQUEST['package_id'], FILTER_VALIDATE_INT ) ) { + $package = Toolkit_Packages_Package::fetchById( + Toolkit_Database::getInstance(), + $package_id + ); + array_unshift($stack, $package->getTitle()); + } if ( defined('EVENT_DB') && EVENT_DB && !$hasCommonEvents && $categoryId = filter_var($_REQUEST['category'], FILTER_VALIDATE_INT) @@ -143,56 +150,56 @@ class Toolkit_Template_BreadCrumbs Toolkit_Common::handleError($e); } } - $page = $this->pageGateway->findNavItem($id); - $isSearch = filter_var($_REQUEST['search'], FILTER_VALIDATE_INT); - if ($isSearch && !$eventHeader && !$topicHeader && !$hasCommonEvents) { - array_unshift($stack, 'Events Search'); - } - $isShortcut = filter_var($_REQUEST['t'], FILTER_SANITIZE_STRING); - if ($isShortcut && !$eventHeader && !$topicHeader && !$hasCommonEvents) { - if ($isShortcut == "today") { - array_unshift($stack, 'Today'); - } else if ($isShortcut == "tomorrow") { - array_unshift($stack, 'Tomorrow'); - } else if ($isShortcut == "next") { - array_unshift($stack, 'Next 7 Days'); - } - } - if ($hasPhotoGalleriesOnThisPage) { - // Do Nothing - } else if (($eventHeader || $topicHeader || $isSearch || $isShortcut) + $page = $this->pageGateway->findNavItem($id); + $isSearch = filter_var($_REQUEST['search'], FILTER_VALIDATE_INT); + if ($isSearch && !$eventHeader && !$topicHeader && !$hasCommonEvents) { + array_unshift($stack, 'Events Search'); + } + $isShortcut = filter_var($_REQUEST['t'], FILTER_SANITIZE_STRING); + if ($isShortcut && !$eventHeader && !$topicHeader && !$hasCommonEvents) { + if ($isShortcut == "today") { + array_unshift($stack, 'Today'); + } else if ($isShortcut == "tomorrow") { + array_unshift($stack, 'Tomorrow'); + } else if ($isShortcut == "next") { + array_unshift($stack, 'Next 7 Days'); + } + } + if ($hasPhotoGalleriesOnThisPage) { + // Do Nothing + } else if (($eventHeader || $topicHeader || $isSearch || $isShortcut || $package_id) && !$hasCommonEvents ) { $seoUrl = Toolkit_Template_Page::getSeoUrl( - $this->pageGateway, - $id - ); - $anchor = ''.$page['navigation_name'].''; - array_unshift($stack, $anchor); - } else { - array_unshift($stack, $page['navigation_name']); - } - $parent = $page['parent']; - while ($parent != 0) { - $page = $this->pageGateway->findNavItem($parent); - $seoUrl = Toolkit_Template_Page::getSeoUrl( - $this->pageGateway, - $parent - ); - $anchor = ''.$page['navigation_name'].''; - array_unshift($stack, $anchor); - $parent = $page['parent']; - } - - $anchor = 'Home'; - array_unshift($stack, $anchor); - } - - return $stack; - } - - // }}} - // {{{ toHtml() + $this->pageGateway, + $id + ); + $anchor = ''.$page['navigation_name'].''; + array_unshift($stack, $anchor); + } else { + array_unshift($stack, $page['navigation_name']); + } + $parent = $page['parent']; + while ($parent != 0) { + $page = $this->pageGateway->findNavItem($parent); + $seoUrl = Toolkit_Template_Page::getSeoUrl( + $this->pageGateway, + $parent + ); + $anchor = ''.$page['navigation_name'].''; + array_unshift($stack, $anchor); + $parent = $page['parent']; + } + + $anchor = 'Home'; + array_unshift($stack, $anchor); + } + + return $stack; + } + + // }}} + // {{{ toHtml() /** * to html @@ -202,16 +209,16 @@ class Toolkit_Template_BreadCrumbs * @return string * @access public */ - public function toHtml($id) - { - $breadCrumbsArray = $this->getBreadCrumbsArray($id); - $breadCrumbs = implode(' > ', $breadCrumbsArray); + public function toHtml($id) + { + $breadCrumbsArray = $this->getBreadCrumbsArray($id); + $breadCrumbs = implode(' > ', $breadCrumbsArray); - return !empty($breadCrumbsArray) - ? '' - : ''; - } + return !empty($breadCrumbsArray) + ? '' + : ''; + } - // }}} + // }}} } ?> diff --git a/admin/packages.php b/admin/packages.php index fbbc856..a5839ed 100644 --- a/admin/packages.php +++ b/admin/packages.php @@ -15,13 +15,15 @@ /** * required files */ -define( 'JQUERY_CDN_JS', '//code.jquery.com/jquery-3.1.1.min.js' ); +//define( 'JQUERY_CDN_JS', '//code.jquery.com/jquery-3.1.1.min.js' ); +define( 'JQUERY_CDN_JS', '//code.jquery.com/jquery-3.0.0.min.js' ); require_once '../setup.phtml'; // get Application config file loaded into Zend_Config $config = new Zend_Config_Ini( BASE . 'Toolkit/Packages/application.ini', strtolower( $_ENV['GLM_HOST_ID'] ) ); // add our custom jquery ui js file to all areas of this admin side application $jQueryVersion = $config->jqueryui->version; $jQueryTheme = $config->jqueryui->theme; +$GLOBALS['topScripts'][] = BASE_URL . 'js/jquery.browser/jquery.browser.min.js'; $GLOBALS['bottomScripts'][] = "//code.jquery.com/ui/{$jQueryVersion}/jquery-ui.js"; $GLOBALS['styleSheets'][] = "//code.jquery.com/ui/{$jQueryVersion}/themes/{$jQueryTheme}/jquery-ui.css"; // create Registry diff --git a/js/jquery.browser/jquery.browser.min.js b/js/jquery.browser/jquery.browser.min.js new file mode 100644 index 0000000..491da7c --- /dev/null +++ b/js/jquery.browser/jquery.browser.min.js @@ -0,0 +1,14 @@ +/*! + * jQuery Browser Plugin 0.1.0 + * https://github.com/gabceb/jquery-browser-plugin + * + * Original jquery-browser code Copyright 2005, 2015 jQuery Foundation, Inc. and other contributors + * http://jquery.org/license + * + * Modifications Copyright 2015 Gabriel Cebrian + * https://github.com/gabceb + * + * Released under the MIT license + * + * Date: 23-11-2015 + */!function(a){"function"==typeof define&&define.amd?define(["jquery"],function(b){return a(b)}):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(window.jQuery)}(function(a){"use strict";function b(a){void 0===a&&(a=window.navigator.userAgent),a=a.toLowerCase();var b=/(edge)\/([\w.]+)/.exec(a)||/(opr)[\/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(iemobile)[\/]([\w.]+)/.exec(a)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[],c=/(ipad)/.exec(a)||/(ipod)/.exec(a)||/(windows phone)/.exec(a)||/(iphone)/.exec(a)||/(kindle)/.exec(a)||/(silk)/.exec(a)||/(android)/.exec(a)||/(win)/.exec(a)||/(mac)/.exec(a)||/(linux)/.exec(a)||/(cros)/.exec(a)||/(playbook)/.exec(a)||/(bb)/.exec(a)||/(blackberry)/.exec(a)||[],d={},e={browser:b[5]||b[3]||b[1]||"",version:b[2]||b[4]||"0",versionNumber:b[4]||b[2]||"0",platform:c[0]||""};if(e.browser&&(d[e.browser]=!0,d.version=e.version,d.versionNumber=parseInt(e.versionNumber,10)),e.platform&&(d[e.platform]=!0),(d.android||d.bb||d.blackberry||d.ipad||d.iphone||d.ipod||d.kindle||d.playbook||d.silk||d["windows phone"])&&(d.mobile=!0),(d.cros||d.mac||d.linux||d.win)&&(d.desktop=!0),(d.chrome||d.opr||d.safari)&&(d.webkit=!0),d.rv||d.iemobile){var f="msie";e.browser=f,d[f]=!0}if(d.edge){delete d.edge;var g="msedge";e.browser=g,d[g]=!0}if(d.safari&&d.blackberry){var h="blackberry";e.browser=h,d[h]=!0}if(d.safari&&d.playbook){var i="playbook";e.browser=i,d[i]=!0}if(d.bb){var j="blackberry";e.browser=j,d[j]=!0}if(d.opr){var k="opera";e.browser=k,d[k]=!0}if(d.safari&&d.android){var l="android";e.browser=l,d[l]=!0}if(d.safari&&d.kindle){var m="kindle";e.browser=m,d[m]=!0}if(d.safari&&d.silk){var n="silk";e.browser=n,d[n]=!0}return d.name=e.browser,d.platform=e.platform,d}return window.jQBrowser=b(window.navigator.userAgent),window.jQBrowser.uaMatch=b,a&&(a.browser=window.jQBrowser),window.jQBrowser}); \ No newline at end of file diff --git a/package.json b/package.json index acd14c1..2a41ce2 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "grunt-sass": "~0.18.0", "grunt-contrib-uglify": "~0.7.0", "grunt-contrib-concat": "~0.5.0", - "grunt-contrib-copy": "~0.7.0" + "grunt-contrib-copy": "~0.7.0", + "jquery.browser": "~0.1.0" } } diff --git a/package.php b/package.php index 404c70b..175b371 100644 --- a/package.php +++ b/package.php @@ -1,17 +1,17 @@ createBreadCrumbsHelper(); + $output = $breadCrumbsBuilder->toHtml( $pageId ); + } + if ( is_object( $package ) && $package instanceof Toolkit_Packages_Package ) { - $output = '
'; + $output .= '
'; $output .= '
' . '
'; $output .='

' . $package->getTitle() . '

'; diff --git a/templates/template.html b/templates/template.html index 22ea7ba..fccf68e 100755 --- a/templates/template.html +++ b/templates/template.html @@ -142,9 +142,9 @@

{v[title]:h}

{v[intro]:h} - >>View Details + >>View Details
- +
-- 2.17.1