Updates for packages
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 24 Oct 2016 15:18:17 +0000 (11:18 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 24 Oct 2016 15:18:17 +0000 (11:18 -0400)
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
Toolkit/Page.php
Toolkit/Template/BreadCrumbs.php
admin/packages.php
js/jquery.browser/jquery.browser.min.js [new file with mode: 0644]
package.json
package.php
templates/template.html

index 67242c6..9a80fa5 100644 (file)
@@ -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
index df0b3c5..08db54a 100755 (executable)
@@ -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 = '';
+        }
     }
 
     /**
index 1b29dd8..856ff32 100644 (file)
  */
 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 = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
-                       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 = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
+            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 = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
-                               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 = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
-                               array_unshift($stack, $anchor);
-                               $parent = $page['parent'];
-                       }
-
-                       $anchor = '<a href="' . BASE_URL . 'index.php">Home</a>';
-                       array_unshift($stack, $anchor);
-               }
-
-               return $stack;
-       }
-
-       //      }}}
-       //      {{{     toHtml()
+                    $this->pageGateway,
+                    $id
+                );
+                $anchor = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
+                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 = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
+                array_unshift($stack, $anchor);
+                $parent = $page['parent'];
+            }
+
+            $anchor = '<a href="' . BASE_URL . 'index.php">Home</a>';
+            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)
-                       ? '<div id="breadcrumbs" class="opensearchserver.ignore">' . $breadCrumbs . '</div>'
-                       : '';
-       }
+        return !empty($breadCrumbsArray)
+            ? '<div id="breadcrumbs" class="opensearchserver.ignore">' . $breadCrumbs . '</div>'
+            : '';
+    }
 
-       //      }}}
+    //  }}}
 }
 ?>
index fbbc856..a5839ed 100644 (file)
 /**
  * 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 (file)
index 0000000..491da7c
--- /dev/null
@@ -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
index acd14c1..2a41ce2 100644 (file)
@@ -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"
   }
 }
index 404c70b..175b371 100644 (file)
@@ -1,17 +1,17 @@
 <?php
-
 $package_id = filter_var($_REQUEST['package_id'], FILTER_VALIDATE_INT);
 if ( $package_id ) {
     $package = Toolkit_Packages_Package::fetchById(
         Toolkit_Database::getInstance(),
         $package_id
     );
+    if ( $pageId = filter_var( $_REQUEST['pageId'], FILTER_VALIDATE_INT ) ) {
+        $breadCrumbsBuilder = $breadCrumbsFactory->createBreadCrumbsHelper();
+        $output             = $breadCrumbsBuilder->toHtml( $pageId );
+    }
+
     if ( is_object( $package ) && $package instanceof Toolkit_Packages_Package ) {
-        $output  = '<div id="breadcrumbs" class="opensearchserver.ignore">
-    <a href="'.BASE_URL.'">Home</a>
-    &gt; <a href="'.BASE_URL.'lodging-specials-4/">Lodging Specials</a> &gt; ';
-        $output .= $package->getTitle();
-        $output .= '</div><div id="category">';
+        $output .= '<div id="category">';
         $output .= '<div id="pDetailContainer" class="row">'
                 . '<div class="small-12 columns">';
         $output .='<h1>' . $package->getTitle() . '</h1>';
index 22ea7ba..fccf68e 100755 (executable)
                                         <div class="pContentSub">
                                         <h3 class="pTitle">{v[title]:h}</h3>
                                         {v[intro]:h}
-                                        <a class="pDetailButton" href="{baseURLDefined:h}index.php?package_id={v[id]}">&gt;&gt;View Details</a>
+                                        <a class="pDetailButton" href="{baseURLDefined:h}index.php?package_id={v[id]}&pageId={pageId}">&gt;&gt;View Details</a>
                                         </div>
-                                        
+
                                     </div>
                                 </div>
                             </div>