示例#1
0
文件: Url.php 项目: gatorv/gecko_fw1
 /**
  * Renders the value using the specified settings
  *
  * @param string The cell value
  */
 public function renderValue($value)
 {
     $url = $this->url;
     if ($this->idColumn !== null) {
         $data = $this->grid->getDataSource()->getRowAt($this->rowNumber);
         $key = $data[$this->idColumn];
         $url = str_replace("%VALUE%", $key, $url);
     }
     $label = $this->label !== null ? $this->label : $value;
     return Gecko_HTML::LinkTag($label, $url);
 }
示例#2
0
 /**
  * Renders the value using the specified settings
  *
  * @param string The cell value
  */
 public function renderValue($value)
 {
     $route = $this->_route;
     $params = array();
     $helper = new Zend_View_Helper_Url();
     if (count($this->_params) > 0) {
         $data = $this->grid->getDataSource()->getRowAt($this->rowNumber);
         foreach ($this->_params as $column) {
             $params[$column] = $data[$column];
         }
     }
     $url = $helper->url($params, $route, true);
     $label = $this->_label !== null ? $this->_label : $value;
     return Gecko_HTML::LinkTag($label, $url);
 }
示例#3
0
 /**
  * Renders the value using the specified settings
  *
  * @param string The cell value
  */
 public function renderValue($value)
 {
     $image = $this->uriDir . $value;
     if ($this->checkImageLoc == true) {
         $path = $this->fsDir . $value;
         if (!file_exists($path)) {
             $image = $this->notFoundImage;
         }
     }
     return Gecko_HTML::drawImg($image, $value);
 }
示例#4
0
 /**
  * Returns the URI to a page
  *
  * @param int $page
  * @param string $label
  * @return string
  * @access protected
  **/
 protected function getUriLoc($page, $label = "")
 {
     if (empty($label)) {
         $label = $page + 1;
     }
     $page = (string) $page;
     $uri = Gecko_HTML::LinkTag($label, Gecko_URL::getSelfURI(array($this->pageParam => $page))) . "\n";
     return $uri;
 }
示例#5
0
 /**
  * Called when row ends
  */
 public function endRow()
 {
     if ($this->rowNum === 'header') {
         $span = 0;
         if ($this->_settings['viewLink'] == true) {
             $span++;
         }
         if ($this->_settings['editLink'] == true) {
             $span++;
         }
         if ($this->_settings['deleteLink'] == true) {
             $span++;
         }
         if ($span > 0) {
             $this->table->addHeader($this->_settings['header'], array("colspan" => $span));
         }
     } else {
         if (!$this->isValidRow()) {
             return;
         }
         $data = $this->grid->getDataSource()->getRowAt($this->rowNum);
         $key = $data[$this->_idColumn];
         if (!$key) {
             throw new Gecko_DataGrid_Exception("{$this->_idColumn} not found in data source");
         }
         if ($this->_settings['viewLink'] == true) {
             $viewLabel = $this->_settings['viewLabel'];
             $view = Gecko_HTML::LinkTag(Gecko_HTML::drawImg($this->_settings['viewImage'], $viewLabel) . ' ' . $viewLabel, $this->_createRoute('view', $key));
             $this->table->addCell($view);
         }
         if ($this->_settings['editLink'] == true) {
             $editLabel = $this->_settings['editLabel'];
             $edit = Gecko_HTML::LinkTag(Gecko_HTML::drawImg($this->_settings['editImage'], $editLabel) . ' ' . $editLabel, $this->_createRoute('edit', $key));
             $this->table->addCell($edit);
         }
         if ($this->_settings['deleteLink'] == true) {
             $deleteLabel = $this->_settings['deleteLabel'];
             $delete = Gecko_HTML::LinkTag(Gecko_HTML::drawImg($this->_settings['deleteImage'], $deleteLabel) . ' ' . $deleteLabel, $this->_createRoute('delete', $key), '_self', array('class' => 'deleteLink'));
             $this->table->addCell($delete);
         }
     }
 }
示例#6
0
 /**
  * Displays a session message via a Popup
  *
  * @return string
  */
 public static function displayMsg()
 {
     if (!isset($_SESSION)) {
         return "";
     }
     $msg = $_SESSION['GeckoSpMsg'];
     unset($_SESSION['GeckoSpMsg']);
     if (empty($msg)) {
         return "";
     }
     $html = "window.alert(\"{$msg}\");\n";
     $html = Gecko_HTML::getJavaScriptTag($html);
     return $html;
 }
示例#7
0
 /**
  * This method will generate the DataGrid
  *
  * @return boolean
  */
 public function buildTable()
 {
     /**
      * Setup basic model settings
      **/
     if ($this->sorting) {
         $sortColumn = Gecko_URL::getRequestParam($this->sortparam);
         $sortOrder = Gecko_URL::getRequestParam($this->sortorderparam);
         $sortcol = empty($sortColumn) ? $this->sortcol : $sortColumn;
         $sortord = empty($sortOrder) ? $this->sortorder : $sortOrder;
         $this->model->setOrder($sortcol, $sortord);
     }
     if ($this->paginate && $this->model instanceof Gecko_DataSource_Paginate_Interface) {
         $page = (int) $this->getCurrentPage();
         if ($page > 0) {
             --$page;
         }
         $lstart = $page * $this->maxrows;
         if ($lstart < 0) {
             $lstart = 0;
         }
         $max = $this->maxrows;
         $this->model->limitResults($lstart, $max);
     }
     /**
      * Setup Model
      **/
     $this->model->setup();
     /**
      * Begin Table Construction
      **/
     $numColumns = $this->model->getTotalColumns();
     $totalRowset = $this->model->getTotalRowset();
     $tblSettings = array('id' => $this->name, 'cellspacing' => '0', 'class' => $this->theme);
     $this->formatter->beginTable($tblSettings);
     /**
      * If we are going to show headers...
      **/
     if ($this->sHeaders == true) {
         $this->formatter->beginRow('header');
         for ($i = 0; $i < $numColumns; $i++) {
             $fieldname = $this->model->getColumnAt($i);
             if (in_array($fieldname, $this->skipColumns)) {
                 continue;
             }
             $headerName = $this->formatter->getColumnName($fieldname);
             $header = $headerName;
             if ($this->sorting) {
                 $sparam = array($this->sortparam => $fieldname);
                 $oparam = array();
                 if ($fieldname == $sortcol) {
                     $img = '';
                     $imgtag = '<img src="%s" border="0" alt="Sort %s %s" />';
                     switch ($sortord) {
                         case 'ASC':
                             $img = sprintf($imgtag, $this->supi, $fieldname, "DESC");
                             $oparam = array($this->sortorderparam => 'DESC');
                             break;
                         case 'DESC':
                             $img = sprintf($imgtag, $this->sdni, $fieldname, "ASC");
                             $oparam = array($this->sortorderparam => 'ASC');
                             break;
                     }
                     $uri = Gecko_URL::getSelfURI(array_merge($sparam, $oparam));
                     $header = Gecko_HTML::LinkTag($headerName . $img, $uri);
                 } else {
                     $uri = Gecko_URL::getSelfURI($sparam);
                     $header = Gecko_HTML::LinkTag($headerName, $uri);
                 }
                 if (in_array($fieldname, $this->noSortColumns)) {
                     $header = $headerName;
                 }
             }
             $this->formatter->addHeader($header);
         }
         $this->formatter->endRow();
     }
     /**
      * If no rows are found...
      **/
     if ($totalRowset == 0) {
         $noRecords = $this->_getTranslatedLabel($this->noRecords);
         $this->formatter->beginRow(0);
         $this->formatter->addCell("<div style=\"text-align: center\">{$noRecords}</div>", 'norecords', array("colspan" => $numColumns));
         $this->formatter->endTable();
         $this->parsed = true;
         if ($this->paginate) {
             $this->_generatePaginator();
         }
         return true;
     }
     /**
      * All clear begin grid construction
      **/
     $isColor = false;
     if ($this->customcolors) {
         if (strpos($this->color1, "#") !== false) {
             $isColor = true;
         }
         if (strpos($this->color2, "#") !== false) {
             $isColor = true;
         }
     }
     $color = "";
     for ($i = 0; $i < $totalRowset; $i++) {
         /**
          * Get the row from the model
          **/
         $row = $this->model->getRowAt($i);
         if ($this->customcolors) {
             $color = $i % 2 == 0 ? $this->color1 : $this->color2;
         }
         /* Set OnClick Handler */
         $js = '';
         if (!empty($this->onClick)) {
             $params = "";
             if (is_array($this->onClickParams)) {
                 $params = array();
                 foreach ($this->onClickParams as $field) {
                     $params[] = "'" . $row[$field] . "'";
                 }
                 $params = implode(",", $params);
             } else {
                 if ($this->onClickParams == "NumRows") {
                     $params = $n_rows;
                 } else {
                     $params = "'" . $row[$this->onClickParams] . "'";
                 }
             }
             $js = "{$this->onClick}({$params})";
         }
         /* Set OnDblClick Handler */
         $js2 = '';
         if (!empty($this->ondblClick)) {
             $params = "";
             if (is_array($this->ondblClickParams)) {
                 $params = array();
                 foreach ($this->onClickParams as $field) {
                     $params[] = "'" . $row[$field] . "'";
                 }
                 $params = implode(",", $params);
             } else {
                 if ($this->ondblClickParams == "NumRows") {
                     $params = $n_rows;
                 } else {
                     $params = $row[$this->ondblClickParams];
                 }
             }
             $js2 = "{$this->ondblClick}({$params})";
         }
         $TRSettings = array();
         if (!empty($js)) {
             $TRSettings['onclick'] = $js;
         }
         if (!empty($js2)) {
             $TRSettings['ondblclick'] = $js2;
         }
         if (!empty($color)) {
             if ($isColor) {
                 $TRSettings["style"] = "background: {$color};";
             } else {
                 $TRSettings["class"] = $color;
             }
         }
         $this->formatter->beginRow($i, $TRSettings);
         /** Begin adding the cells to the Grid **/
         $cellNum = 0;
         foreach ($row as $cell) {
             $fieldname = $this->model->getColumnAt($cellNum);
             $cellNum++;
             if (in_array($fieldname, $this->skipColumns)) {
                 continue;
             }
             $this->formatter->addCell($cell, $fieldname);
         }
         $this->formatter->endRow();
     }
     $this->formatter->endTable();
     $this->parsed = true;
     if ($this->paginate) {
         $this->_generatePaginator();
     }
     return true;
 }