Exemple #1
0
 function randomNodes($path = null)
 {
     $path = array_pop(explode('|', $path));
     $min = empty($path) ? 5 : 1;
     $nkids = rand($min, 5);
     $nodes = array();
     for ($i = 0; $i < $nkids; $i++) {
         $node = new WFYAHOO_widget_TreeViewNode(($path ? $path . "." : "") . ($i + 1));
         $node->setCouldHaveChildren($i % 2 == 0);
         $nodes[] = $node;
     }
     return $nodes;
 }
Exemple #2
0
 function render($blockContent = NULL)
 {
     if ($this->hidden or $this->dieselSearchHelper->isFilteringOnAttribute($this->attributeID)) {
         return NULL;
     } else {
         // set up stuff we'll use while rendering
         if ($this->class) {
             $classHTML = " class=\"{$this->class}\" ";
         }
         // output facet nav
         try {
             $Array = new JavaClass("java.lang.reflect.Array");
             $facets = $this->prepareFacets();
             if (gettype($facets) == 'array') {
                 if ($this->facetStyle == WFDieselFacet::STYLE_TREE and $this->treeDataPath) {
                     // no items, but means specifically "no kids" thus need to deal with this for the Tree callback
                     // ajax callback -- send data
                     WFYAHOO_widget_TreeView::sendTree(array());
                 }
                 return NULL;
             }
             if (gettype($facets) == 'object' and $Array->getLength($facets) == 0) {
                 return NULL;
             }
             // also no items
             // sanity check
             if ($this->facetStyle == WFDieselFacet::STYLE_MENU and $this->isTaxonomyAttribute()) {
                 throw new Exception("STYLE_MENU does not support taxonomy attributes.");
             }
             if ($this->facetStyle == WFDieselFacet::STYLE_MENU and $this->rangeCount) {
                 throw new Exception("STYLE_MENU does not support range display.");
             }
             // output!
             $html = '';
             if ($this->label) {
                 $html .= "<span style=\"font-weight: bold; white-space: nowrap;\">{$this->label}</span><br />\n";
             }
             $width = $this->width ? "width: {$this->width};" : NULL;
             $height = $this->isPopup ? '300px' : ($this->height ? $this->height : $this->parent()->facetNavHeight());
             // NOTE: Safari seems to have a bug where even tho the content fits within the width, it still puts a scroll bar. Works in FF, not sure about IE yet.
             $html .= '<div style="max-height: ' . $height . '; overflow: auto; padding-right: 4px;' . $width . '">' . "\n";
             // actual facets
             switch ($this->facetStyle) {
                 case WFDieselFacet::STYLE_MENU:
                     $html .= $this->facetMenuHTML($facets);
                     break;
                 case WFDieselFacet::STYLE_TREE:
                     // set up "root" YUITree
                     $tree = new WFYAHOO_widget_TreeView('tree_' . $this->id(), $this->page);
                     $items = array();
                     foreach ($facets as $facet) {
                         $label = str_replace("\n", '', $this->facetHTML($facet));
                         $item = new WFYAHOO_widget_TreeViewNode(java_values($facet->getAttributeValue()), $label);
                         $fkids = $facet->getChildren();
                         if ($fkids === null) {
                             $item->setCouldHaveChildren(false);
                         }
                         $items[] = $item;
                     }
                     $tree->setValue($items);
                     $tree->setDynamicCallback($this->parent()->baseURL() . '/' . urlencode($this->dieselSearchHelper->getQueryState($this->attributeID())) . '//' . $this->id() . '|');
                     if ($this->treeDataPath) {
                         // ajax callback -- send data
                         WFYAHOO_widget_TreeView::sendTree($items);
                     } else {
                         // initial display of first row of items
                         $html .= $tree->render();
                     }
                     break;
                 default:
                     foreach ($facets as $facet) {
                         $html .= $this->facetHTML($facet);
                     }
                     if ($this->maxRows != WFDieselFacet::UNLIMITED_ROWS and $Array->getLength($facets) == $this->maxRows) {
                         $html .= $this->editFacetLink('More...', $this->class);
                     } else {
                         if ($this->maxRows == WFDieselFacet::UNLIMITED_ROWS and $Array->getLength($facets) == $this->maxRows) {
                             $html .= "<p>There are too many choices to dislpay at this time. Please narrow your search by other criteria and try again.</p>";
                         }
                     }
                     break;
             }
             $html .= '</div>';
             return $html;
         } catch (JavaException $e) {
             $trace = new java("java.io.ByteArrayOutputStream");
             $e->printStackTrace(new java("java.io.PrintStream", $trace));
             throw new Exception("java stack trace:<pre> {$trace} </pre>\n");
         }
     }
 }