/** * Adds columns from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_TableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addBrowseTableColumns(\MUtil_Model_Bridge_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $tUtil = $this->util->getTokenData(); $table = $bridge->getTable(); $table->appendAttrib('class', 'compliance'); $thead = $table->thead(); $th_row = $thead->tr(array('class' => 'rounds')); $th = $th_row->td(); $span = 1; $cRound = null; $cDesc = null; $thead->tr(); if ($showMenuItem = $this->getShowMenuItem()) { $bridge->addItemLink($showMenuItem->toActionLinkLower($this->request, $bridge)); } // Initialize alter $alternateClass = new \MUtil_Lazy_Alternate(array('odd', 'even')); foreach ($model->getItemsOrdered() as $name) { if ($label = $model->get($name, 'label')) { $round = $model->get($name, 'round'); if ($round == $cRound) { $span++; $class = null; } else { // If the round has an icon, show the icon else just 'R' since // complete round description messes up the display $th->append($cDesc); $th->title = $cRound; $th->colspan = $span; $span = 1; $cRound = $round; if ($cIcon = $model->get($name, 'roundIcon')) { $cDesc = \MUtil_Html_ImgElement::imgFile($cIcon, array('alt' => $cRound, 'title' => $cRound)); } else { if (substr($name, 0, 5) == 'stat_') { $cDesc = 'R'; } else { $cDesc = null; } } $class = 'newRound'; $thClass = $class . ' ' . $alternateClass; // Add alternate class only for th $th = $th_row->td(array('class' => $thClass)); } if ($model->get($name, 'noSort')) { $title = array(\MUtil_Lazy::method($tUtil, 'getStatusDescription', $bridge->{$name}), "\n" . $model->get($name, 'description')); $token = 'tok_' . substr($name, 5); $href = new \MUtil_Html_HrefArrayAttribute(array($this->request->getControllerKey() => 'track', $this->request->getActionKey() => 'show', \MUtil_Model::REQUEST_ID => $bridge->{$token})); $href->setRouteReset(); $onclick = new \MUtil_Html_OnClickArrayAttribute(); $onclick->addUrl($href)->addCancelBubble(); $tds = $bridge->addColumn(array(\MUtil_Html_AElement::iflink($bridge->{$token}, array($href, 'onclick' => 'event.cancelBubble = true;', 'title' => $title, $bridge->{$name}), $bridge->{$name}), 'class' => array('round', \MUtil_Lazy::method($tUtil, 'getStatusClass', $bridge->{$name})), 'title' => $title, 'onclick' => \MUtil_Lazy::iff($bridge->{$token}, $onclick)), array($label, 'title' => $model->get($name, 'description'), 'class' => 'round')); } else { $tds = $bridge->addSortable($name, $label); } if ($class) { $tds->appendAttrib('class', $class); } } } $th->append($cRound); $th->colspan = $span; }
/** * Get the file icons * * @param \MUtil_Model_Bridge_TableBridge $bridge * @return array $icon => $menuItem or array($menuItem, $other) */ protected function getFileIcons(\MUtil_Model_Bridge_TableBridge $bridge) { $onDelete = new \MUtil_Html_OnClickArrayAttribute(); $onDelete->addConfirm(\MUtil_Lazy::call('sprintf', $this->_("Are you sure you want to delete '%s'?"), $bridge->relpath)); return array('process.png' => $this->findMenuItem($this->request->getControllerName(), 'import'), 'download.png' => $this->findMenuItem($this->request->getControllerName(), 'download'), 'eye.png' => $this->findMenuItem($this->request->getControllerName(), 'show'), 'edit.png' => $this->findMenuItem($this->request->getControllerName(), 'edit'), 'delete.png' => array($this->findMenuItem($this->request->getControllerName(), 'delete'), $onDelete)); }
/** * Add a file upload/download page to the menu * * @param string $label The label to display for the menu item, null for access without display * @param string $privilege The privilege for the item, null is always, 'pr.islogin' must be logged in, 'pr.nologin' only when not logged in. * @param string $controller What controller to use * @param string $action The name of the action * @param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only' * @return \Gems_Menu_SubMenuItem */ public function addFilePage($label, $privilege, $controller, array $other = array()) { $page = $this->addPage($label, $privilege, $controller, 'index', $other); $page->addAutofilterAction(); // $page->addCreateAction(); // $page->addExcelAction(); $page = $page->addShowAction(); $page->addEditAction(); $onDelete = new \MUtil_Html_OnClickArrayAttribute(); $onDelete->addConfirm($this->_("Are you sure you want to delete this file?")); $page->addButtonOnly($this->_('Delete'), $privilege . '.delete', $controller, 'delete', array('onclick' => $onDelete))->setModelParameters(1); $page->addButtonOnly($this->_('Download'), $privilege . '.download', $controller, 'download')->setModelParameters(1); return $page; }