Example #1
0
 /**
  * When widget is called, following function is run.
  */
 public function run()
 {
     // set the default values and validate the data
     if ($this->afterLabel === null) {
         $this->afterLabel = true;
     }
     if ($this->displayBreadcrumbs === null) {
         $this->displayBreadcrumbs = true;
     }
     if ($this->displayLabel === null) {
         $this->displayLabel = true;
     }
     $c = 0;
     if ($this->displayBreadcrumbs) {
         if ($this->breadcrumbs === null) {
             $this->breadcrumbs = array();
         }
         if (!is_array($this->breadcrumbs)) {
             $this->breadcrumbs = array();
         }
         if ($this->prependHome === null) {
             $this->prependHome = true;
         }
         if ($this->prependHome) {
             // add home link to the beginning of the breadcrumbs array
             array_unshift($this->breadcrumbs, array('text' => Yii::t('link', 'Home'), 'url' => Yii::app()->homeUrl, 'active' => false));
         }
         // the new array of the breadcrumbs is a validated one
         $breadcrumbs = array();
         foreach ($this->breadcrumbs as $breadcrumb) {
             if (isset($breadcrumb['visible']) && !$breadcrumb['visible']) {
                 continue;
             }
             if (is_array($breadcrumb) && (isset($breadcrumb['text']) || isset($breadcrumb['url']) || isset($breadcrumb['active']) || isset($breadcrumb['options']))) {
                 $breadcrumbs[] = array('text' => isset($breadcrumb['text']) ? (string) $breadcrumb['text'] : MParams::getPageLabel(), 'url' => isset($breadcrumb['url']) && (is_array($breadcrumb['url']) || is_string($breadcrumb['url'])) ? $breadcrumb['url'] : '#', 'active' => isset($breadcrumb['active']) ? (bool) $breadcrumb['active'] : false, 'options' => isset($breadcrumb['options']) && is_array($breadcrumb['options']) ? $breadcrumb['options'] : array());
             }
         }
         // do not display the breadcrumbs list if it has no links
         if (($c = count($breadcrumbs)) === 0) {
             $this->displayBreadcrumbs = false;
         }
         $this->breadcrumbs = $breadcrumbs;
     }
     if ($this->displayLabel) {
         if ($this->label === null) {
             $this->label = MParams::getPageLabel();
         }
     }
     // data for the renderer
     $data = array('afterLabel' => $this->afterLabel, 'breadcrumbs' => $this->breadcrumbs, 'displayBreadcrumbs' => $this->displayBreadcrumbs, 'displayLabel' => $this->displayLabel, 'label' => $this->label, 'c' => $c, 'class', 'n');
     // render the view file
     $this->render('wContentHeader', $data);
 }
Example #2
0
 /**
  * When widget is called, following function is run.
  */
 public function run()
 {
     // set the default values and validate the data
     if ($this->displayGrid === null) {
         $this->displayGrid = $this->columns !== null && $this->columnsModel !== null;
     }
     if ($this->displaySGrid === null) {
         $this->displaySGrid = $this->sColumns !== null && $this->rows !== null;
     }
     if ($this->title === null) {
         $this->title = CHtml::encode(MParams::getPageLabel());
     } else {
         $this->title = (string) $this->title;
     }
     // jqGrid
     if ($this->displayGrid) {
         if (!is_array($this->columns)) {
             $this->columns = array();
         }
         if (!is_array($this->columnsModel)) {
             $this->columnsModel = array();
         }
         if ($this->datatype === null) {
             $this->datatype = 'json';
         }
         if ($this->displayTitlebar === null) {
             $this->displayTitlebar = true;
         }
         if ($this->gridId === null) {
             $this->gridId = 'w3Grid';
         }
         if ($this->gridPagerId === null) {
             $this->gridPagerId = $this->gridId . 'Pager';
         }
         if ($this->height === null) {
             $this->height = 500;
         } else {
             $this->height = (int) $this->height;
         }
         if ($this->mtype === null) {
             $this->mtype = 'POST';
         }
         if ($this->rowList === null) {
             $this->rowList = '[25,50,100,200]';
         }
         if ($this->rowNum === null) {
             $this->rowNum = _CController::GRID_PAGE_SIZE;
         }
         $this->rowNum = (int) $this->rowNum;
         $this->sortname = (string) $this->sortname;
         if ($this->sortorder === null) {
             $this->sortorder = 'asc';
         }
         if ($this->url === null) {
             $this->url = Yii::app()->urlManager->createUrl(Yii::app()->controller->id . '/gridData');
         }
         $this->url = (string) $this->url;
         if ($this->viewrecords === null) {
             $this->viewrecords = true;
         }
     }
     // static grid
     if ($this->displaySGrid) {
         if (!is_array($this->rows)) {
             $this->rows = array();
         }
         if ($this->controllerId === null) {
             $this->controllerId = Yii::app()->controller->id;
         }
         if ($this->displayButtonClose === null) {
             $this->displayButtonClose = false;
         }
         if ($this->displaySGridPager === null) {
             $this->displaySGridPager = true;
         }
         if ($this->displaySTitlebar === null) {
             $this->displaySTitlebar = true;
         }
         if ($this->hasLinkIcon === null) {
             $this->hasLinkIcon = true;
         }
         if (!is_array($this->importantRowsBottom)) {
             $this->importantRowsBottom = array();
         }
         if ($this->maxRow === null && $this->pages instanceof CPagination) {
             $maxRow = $this->pages->getCurrentPage() * $this->pages->getPageSize() + count($this->rows);
             // ($this->pages->getCurrentPage()+1)*$this->pages->getPageSize()
             $this->maxRow = $maxRow > $this->pages->getItemCount() ? $this->pages->getItemCount() : $maxRow;
         } else {
             $this->maxRow = (int) $this->maxRow;
         }
         if ($this->minRow === null && $this->pages instanceof CPagination) {
             $this->minRow = $this->pages->getCurrentPage() * $this->pages->getPageSize() + 1;
         } else {
             $this->minRow = (int) $this->minRow;
         }
         if ($this->registerGridLinkIcon === null) {
             $this->registerGridLinkIcon = true;
         }
         if (!is_array($this->sColumns)) {
             $this->sColumns = array();
         }
         if ($this->sGridId === null) {
             $this->sGridId = 'w3StaticGrid';
         }
         if ($this->sGridWrapperId === null) {
             $this->sGridWrapperId = $this->sGridId . 'Wrapper';
         }
         if ($this->sTitle === null) {
             $this->sTitle = $this->title;
         }
         if ($this->totalRecords === null && $this->pages instanceof CPagination) {
             $this->totalRecords = $this->pages->getItemCount();
         } else {
             $this->totalRecords = (int) $this->totalRecords;
         }
     }
     // data for the renderer
     $data = array('columns' => $this->columns, 'columnsModel' => $this->columnsModel, 'controllerId' => $this->controllerId, 'datatype' => $this->datatype, 'displayButtonClose' => $this->displayButtonClose, 'displayGrid' => $this->displayGrid, 'displaySGrid' => $this->displaySGrid, 'displaySGridPager' => $this->displaySGridPager, 'displayTitlebar' => $this->displayTitlebar, 'displaySTitlebar' => $this->displaySTitlebar, 'gridId' => $this->gridId, 'gridPagerId' => $this->gridPagerId, 'hasLinkIcon' => $this->hasLinkIcon, 'height' => $this->height, 'importantRowsBottom' => $this->importantRowsBottom, 'maxRow' => $this->maxRow, 'minRow' => $this->minRow, 'mtype' => $this->mtype, 'registerGridLinkIcon' => $this->registerGridLinkIcon, 'rowList' => $this->rowList, 'rowNum' => $this->rowNum, 'rows' => $this->rows, 'sColumns' => $this->sColumns, 'sGridId' => $this->sGridId, 'sGridWrapperId' => $this->sGridWrapperId, 'sortname' => $this->sortname, 'sortorder' => $this->sortorder, 'sTitle' => $this->sTitle, 'title' => $this->title, 'totalRecords' => $this->totalRecords, 'url' => $this->url, 'viewrecords' => $this->viewrecords, 'colModel', 'colNames', 'i', 'n');
     // render the view file
     $this->render('wGrid', $data);
 }