Beispiel #1
0
 /**
  * Run this widget.
  */
 public function run()
 {
     $id = $this->getId();
     assert('!empty($this->uniqueLayoutId)');
     assert('!empty($this->item)');
     echo JuiPortlets::renderPortlet($this->item, $this->uniqueLayoutId, $this->moduleId, false);
 }
Beispiel #2
0
 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     assert('!empty($this->uniqueLayoutId)');
     $id = $this->getId();
     $this->htmlOptions['id'] = $id;
     $columnsClass = '.juiportlet-columns-' . $this->uniqueLayoutId;
     $script = "juiPortlets.init('" . $this->uniqueLayoutId . "',";
     // Not Coding Standard
     $script .= "'" . $this->moduleId . "', '" . $this->saveUrl . "', ";
     if (Yii::app()->request->enableCsrfValidation) {
         $script .= "'" . Yii::app()->request->csrfTokenName . "', '" . Yii::app()->request->csrfToken . "', ";
     } else {
         $script .= "null, null, ";
     }
     $script .= "'" . $columnsClass . "', '" . $this->collapsible . "', '" . $this->movable . "', ";
     $script .= "'" . Yii::t('Default', 'This portlet will be removed, ok?') . "');";
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $script);
     $content = "";
     $content .= "<div class=\"juiportlet-columns\"> \n";
     if (!empty($this->items)) {
         if ($this->layoutType == '100') {
             $totalColumns = 1;
             $columnStyle[1] = 'juiportlet-column-no-split';
         }
         if ($this->layoutType == '50,50') {
             $totalColumns = 2;
             $columnStyle[1] = 'juiportlet-column-split-even-2';
             $columnStyle[2] = 'juiportlet-column-split-even-2';
         }
         if ($this->layoutType == '75,25') {
             $totalColumns = 2;
             $columnStyle[1] = 'juiportlet-column-split-left-75';
             $columnStyle[2] = 'juiportlet-column-split-right-25';
         }
         if (count($this->items) < $totalColumns) {
             $keys = array_keys($this->items);
             if ($keys[0] == $totalColumns) {
                 //TODO: when we expand to 3 or 4 columns, need to fill blank columns when appropriate and it might
                 //be more than just one occurance. We will need some sort of for loop.
                 $this->items = array(1 => array(array('blankColumn' => true))) + $this->items;
             } else {
                 $this->items[] = array(array('blankColumn' => true));
             }
         }
         foreach ($this->items as $column => $columnPortlets) {
             $classString = "juiportlet-columns-" . $this->uniqueLayoutId . " ";
             $classString .= "juiportlet-widget-column" . $column . " ";
             if ($totalColumns > 1) {
                 $classString .= "juiportlet-column " . $columnStyle[$column];
             }
             $content .= "<ul class=\"" . $classString . "\">\n";
             foreach ($columnPortlets as $position => $item) {
                 if (isset($item['blankColumn']) && $item['blankColumn']) {
                     $content .= "<li>&#160;\n";
                     $content .= "</li>\n";
                 } else {
                     $content .= "<li class=\"juiportlet-widget " . $item['uniqueClass'] . "\" id=\"" . $item['uniqueId'] . "\">\n";
                     $content .= JuiPortlets::renderPortlet($item, $this->uniqueLayoutId, $this->moduleId);
                     $content .= "</li>\n";
                 }
             }
             $content .= "</ul>\n";
         }
     }
     $content .= "</div>";
     echo $content;
 }