function initJS($blockContent)
 {
     $script = "";
     $script .= parent::initJS($blockContent);
     $script .= "\nPHOCOA.namespace('widgets.{$this->id}.PhocoaDialog');\nPHOCOA.widgets.{$this->id}.PhocoaDialog.queueProps = function(o) {\n    PHOCOA.widgets.{$this->id}.Panel.queueProps(o); // queue parent props\n    // alert('id={$this->id}: queue PhocoaDialog props');\n    // queue PhocoaDialog props here\n};\nPHOCOA.widgets.{$this->id}.PhocoaDialog.init = function() {\n    PHOCOA.widgets.{$this->id}.Panel.init();   // init parent\n    var phocoaDialog = PHOCOA.runtime.getObject('{$this->id}');\n    phocoaDialog.cfg.setProperty('deferModuleViewLoading', " . ($this->deferModuleViewLoading ? 'true' : 'false') . ");\n    phocoaDialog.cfg.setProperty('cacheModuleView', " . ($this->cacheModuleView ? 'true' : 'false') . ");\n    phocoaDialog.cfg.setProperty('moduleViewInvocationPath', " . ($this->moduleView ? "'" . WWW_ROOT . '/' . $this->moduleView->invocationPath() . "'" : 'null') . ");\n    " . ($this->inline ? "phocoaDialog.element.setStyle({position:'static'});" : null) . "\n};\n" . (get_class($this) == 'WFYAHOO_widget_PhocoaDialog' ? "PHOCOA.widgets.{$this->id}.init = function() { PHOCOA.widgets.{$this->id}.PhocoaDialog.init(); };" : NULL);
     return $script;
 }
Example #2
0
 function render($blockContent = NULL)
 {
     if ($this->hidden) {
         return NULL;
     } else {
         $html = NULL;
         if ($this->showLoadingMessage) {
             // set up loading container
             $loading = new WFYAHOO_widget_Panel("phocoaWFDieselNav_Loading_{$this->id}", $this->page);
             $loading->setBody('<div style="padding: 10px; font-size: 20px; line-height: 25px;">Searching... please wait...</div><div class="phocoaWFDieselNav_Loading"></div>');
             $loading->setWidth('400px');
             $loading->setHeight('125px');
             $loading->setFixedCenter(true);
             $loading->setClose(false);
             $loading->setModal(true);
             $loading->setDraggable(false);
             //$loading->setZIndex(100);
             //$loading->setIFrame(true);
             $html .= $loading->render();
         }
         // set up popup container
         $popup = new WFYAHOO_widget_Panel("phocoaWFDieselNav_Popup_{$this->id}", $this->page);
         $popup->setRenderTo("'{$this->getForm()->id()}'");
         $popup->setConstrainToViewport(true);
         $popup->setHeader('<div style="height: 10px"></div>');
         $popup->setBody("<div id=\"phocoaWFDieselNav_PopupContent_{$this->id}\" style=\"padding: 5px;\"></div><input " . ($this->showLoadingMessage ? 'onClick="cancelPopup(); showLoading();"' : NULL) . " type=\"submit\" name=\"action|" . $this->searchAction . "\" value=\"Go\"/>");
         $popup->setValueForKey('400px', 'width');
         $popup->setContext($this->id, 'tl', 'tl');
         //$popup->setIFrame(true);
         $popup->setModal(true);
         $html .= $popup->render();
         // js
         $html .= "\n    <script type=\"text/javascript\">\n    function doPopup(facetID, dpQueryState, facetSelections, contextEl)\n    {\n        if (typeof contextEl !== 'undefined')\n        {\n            PHOCOA.runtime.getObject('phocoaWFDieselNav_Popup_{$this->id}').cfg.setProperty('context', [contextEl, 'tl', 'tl']);\n        }\n        PHOCOA.runtime.getObject('phocoaWFDieselNav_Popup_{$this->id}').show();\n        Element.update('phocoaWFDieselNav_PopupContent_{$this->id}', '<div style=\"padding: 10px; font-size: 20px; line-height: 25px;\">Loading... please wait...</div><div class=\"phocoaWFDieselNav_Loading\"></div>');\n\n        // use the baseURL to *remove* the existing query state and use the passed-in one instead, which excludes the selection for facetID\n        var rpc = new PHOCOA.WFRPC('{$this->baseURL()}/' + dpQueryState, '#page#' + facetID, 'generatePopupHTML');\n        rpc.method = 'post';\n        rpc.callback.success = function() {};\n        rpc.callback.failure = function() { alert('Failed to load popup data.'); };\n        rpc.execute(encodeURIComponent(facetSelections), null);\n    }\n    function cancelPopup()\n    {\n        Element.hide('phocoaWFDieselNav_Popup_{$this->id}');\n    }\n    function facetHandleClick(newURL)\n    {\n        cancelPopup();\n        showLoading();\n        window.location.href = newURL;\n    }\n    function showLoading()\n    {\n    ";
         if ($this->showLoadingMessage) {
             $html .= "\n        var loadingDlog = PHOCOA.runtime.getObject('phocoaWFDieselNav_Loading_{$this->id}');\n        if (loadingDlog)\n        {\n            loadingDlog.show();\n        }\n    ";
         }
         $html .= "\n    }\n    </script>\n    <div id=\"{$this->id}\">\n            ";
         // show existing "filters" in proper order
         // prepare a list of children, keyed by ID
         $facetNavsByID = array();
         foreach ($this->children() as $facetNav) {
             $facetNavsByID[$facetNav->id()] = $facetNav;
         }
         // keep track of facets that "appear" in the interface, either as a selection or as a clickable facet so that they are not repeated
         $renderedList = array();
         // keep track of each item as rendered so we don't do it 2x
         $selectionRenderedList = array();
         // 1. render current selections / filters
         // first do items in desired order
         $filtersShownCount = 0;
         foreach ($this->facetNavOrder as $id) {
             if (!isset($facetNavsByID[$id])) {
                 throw new Exception("Specified WFDieselFacet of id {$id} does not exist.");
             }
             $facetNav = $facetNavsByID[$id];
             if (!$facetNav instanceof WFDieselFacet) {
                 continue;
             }
             // display only facets; skip keyword query
             $selectedHTML = $this->facetFilterNav($facetNav);
             if ($selectedHTML) {
                 $renderedList[$id] = true;
                 $filtersShownCount++;
             }
             $html .= $selectedHTML;
             $selectionRenderedList[$id] = true;
         }
         foreach ($facetNavsByID as $id => $facetNav) {
             if (!$facetNav instanceof WFDieselFacet) {
                 continue;
             }
             // display only facets; skip keyword query
             if (!isset($selectionRenderedList[$id])) {
                 $selectedHTML = $this->facetFilterNav($facetNav);
                 if ($selectedHTML) {
                     $renderedList[$id] = true;
                     $filtersShownCount++;
                 }
                 $html .= $selectedHTML;
                 $selectionRenderedList[$id] = true;
             }
         }
         // finally, do the "keyword" if there is one
         foreach ($this->children() as $widget) {
             if ($widget instanceof WFDieselKeyword) {
                 $keywordFilterHTML = $this->facetFilterNav($widget);
                 if ($keywordFilterHTML) {
                     $filtersShownCount++;
                 }
                 $html .= $keywordFilterHTML;
                 break;
             }
         }
         // if there are any filter, offer a "clear all" link
         if ($filtersShownCount >= 2) {
             $html .= "\n<div class=\"phocoaWFDieselNav_FilterInfo\" style=\"border: 0\"><a " . ($this->showLoadingMessage ? ' onClick="showLoading(); "' : '') . " href=\"" . $this->baseURL() . '/' . urlencode($this->dieselSearchHelper->getQueryStateWithRestrictDQLOnly()) . "\">Clear all filters</a></div>\n";
         }
         $html .= "<br clear=\"all\" />\n";
         // 2. Render "expanded" facets
         // prepare a list of children, keyed by ID
         $facetNavsByID = array();
         foreach ($this->children() as $facetNav) {
             $facetNavsByID[$facetNav->id()] = $facetNav;
         }
         $renderedCount = 0;
         $moreChoicesListIDs = array();
         // render widgets
         $html .= '<ul class="phocoaWFDieselNav_FacetList">';
         // first do items in desired order
         foreach ($this->facetNavOrder as $id) {
             if (isset($facetNavsByID[$id])) {
                 $facetNav = $facetNavsByID[$id];
                 if (!$facetNav instanceof WFDieselFacet) {
                     continue;
                 }
                 // display only facets; skip keyword query
                 // only show up to max facets; the rest go in the "more" list
                 if ($renderedCount >= $this->maxFacetsToShow) {
                     $moreChoicesListIDs[$id] = true;
                     continue;
                 }
                 $facetHTML = $facetNav->render();
                 if ($facetHTML) {
                     $html .= "\n<li class='phocoaWFDieselNav_Facet'>{$facetHTML}</li>";
                     $renderedCount++;
                 }
                 $renderedList[$id] = true;
             } else {
                 throw new Exception("Specified WFDieselFacet of id {$id} does not exist.");
             }
         }
         // then do all remaining widgets
         foreach ($facetNavsByID as $id => $facetNav) {
             if (!$facetNav instanceof WFDieselFacet) {
                 continue;
             }
             // display only facets; skip keyword query
             if (!isset($renderedList[$id])) {
                 // only show up to max facets; the rest go in the "more" list
                 if ($renderedCount >= $this->maxFacetsToShow) {
                     $moreChoicesListIDs[$id] = true;
                     continue;
                 }
                 $facetHTML = $facetNav->render();
                 if ($facetHTML) {
                     $html .= "\n<li class='phocoaWFDieselNav_Facet'>{$facetHTML}</li>";
                     $renderedCount++;
                 }
                 $renderedList[$id] = true;
             }
         }
         // 3. display "more choices" as needed
         if (count($moreChoicesListIDs)) {
             $html .= "<li class='phocoaWFDieselNav_MoreChoices'><b>More Choices:</b>\n";
             $first = true;
             foreach ($moreChoicesListIDs as $id => $nothing) {
                 // skip already rendered items
                 if (isset($renderedList[$id])) {
                     continue;
                 }
                 if (isset($facetNavsByID[$id])) {
                     $facetNav = $facetNavsByID[$id];
                     if (!$facetNav instanceof WFDieselFacet) {
                         continue;
                     }
                     // display only facets; skip keyword query
                     if (!$first) {
                         $html .= ", ";
                     }
                     $html .= $facetNav->editFacetLink($facetNav->label());
                 } else {
                     throw new Exception("Specified WFDieselFacet of id {$id} does not exist.");
                 }
                 $first = false;
             }
             $html .= "\n</li>\n";
         }
         $html .= "</ul></div>";
         return $html;
     }
 }
 function initJS($blockContent)
 {
     $script .= parent::initJS($blockContent);
     $script .= "\nPHOCOA.namespace('widgets.{$this->id}.Dialog');\nPHOCOA.widgets.{$this->id}.Dialog.queueProps = function(o) {\n    PHOCOA.widgets.{$this->id}.Panel.queueProps(o); // queue parent props\n    // alert('id={$this->id}: queue Dialog props');\n    // queue Dialog props here\n    " . ($buttonsJS ? "o.cfg.queueProperty(\"buttons\", {$buttonsJS});" : NULL) . "\n};\nPHOCOA.widgets.{$this->id}.Dialog.init = function() {\n    PHOCOA.widgets.{$this->id}.Panel.init();  // init parent\n    var dialog = PHOCOA.runtime.getObject('{$this->id}');\n    dialog.cfg.setProperty('postmethod', '{$this->postmethod}');\n    " . ($this->callbackSuccess ? "dialog.callback.success = {$this->callbackSuccess};" : NULL) . "\n    " . ($this->callbackFailure ? "dialog.callback.failure = {$this->callbackFailure};" : NULL) . "\n};\n" . (get_class($this) == 'WFYAHOO_widget_Dialog' ? "PHOCOA.widgets.{$this->id}.init = function() { PHOCOA.widgets.{$this->id}.Dialog.init(); };" : NULL);
     return $script;
 }