示例#1
0
 /**
  * Create a row based on the item and children
  *
  * @param object	$object	@link icms_ipf_Object
  * @param integer	$level	sub-level of the item
  */
 public function createTableRow($object, $level = 0)
 {
     $aObject = array();
     $i = 0;
     $aColumns = array();
     $doWeHaveActions = false;
     foreach ($this->_columns as $column) {
         $aColumn = array();
         if ($i == 0) {
             $class = "head";
         } elseif ($i % 2 == 0) {
             $class = "even";
         } else {
             $class = "odd";
         }
         if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
             $method = $column->_customMethodForValue;
             $value = $object->{$method}();
         } else {
             /**
              * If the column is the identifier, then put a link on it
              */
             if ($column->getKeyName() == $this->_objectHandler->identifierName) {
                 $value = $object->getItemLink();
             } else {
                 $value = $object->getVar($column->getKeyName());
             }
         }
         $space = '';
         if ($column->getKeyName() == $this->_objectHandler->identifierName) {
             for ($i = 0; $i < $level; $i++) {
                 $space = $space . '--';
             }
         }
         if ($space != '') {
             $space .= '&nbsp;';
         }
         $aColumn['value'] = $space . $value;
         $aColumn['class'] = $class;
         $aColumn['width'] = $column->getWidth();
         $aColumn['align'] = $column->getAlign();
         $aColumn['key'] = $column->getKeyName();
         $aColumns[] = $aColumn;
         $i++;
     }
     $aObject['columns'] = $aColumns;
     $class = $class == 'even' ? 'odd' : 'even';
     $aObject['class'] = $class;
     $actions = array();
     // Adding the custom actions if any
     foreach ($this->_custom_actions as $action) {
         if (method_exists($object, $action)) {
             $actions[] = $object->{$action}();
         }
     }
     $controller = new icms_ipf_Controller($this->_objectHandler);
     if (in_array('edit', $this->_actions)) {
         $actions[] = $controller->getEditItemLink($object, false, true);
     }
     if (in_array('delete', $this->_actions)) {
         $actions[] = $controller->getDeleteItemLink($object, false, true);
     }
     $aObject['actions'] = $actions;
     $this->_tpl->assign('icms_actions_column_width', count($actions) * 30);
     $aObject['id'] = $object->id();
     $this->_aObjects[] = $aObject;
     $childrenObjects = $this->getChildrenOf($object->id());
     $this->_hasActions = $this->_hasActions ? true : count($actions) > 0;
     if ($childrenObjects) {
         $level++;
         foreach ($childrenObjects as $subObject) {
             $this->createTableRow($subObject, $level);
         }
     }
 }
示例#2
0
 /**
  *
  *
  * @param	bool	$onlyUrl
  * @param	bool	$withimage
  * @param	bool	$userSide
  */
 public function getEditItemLink($onlyUrl = false, $withimage = true, $userSide = false)
 {
     $controller = new icms_ipf_Controller($this->handler);
     return $controller->getEditItemLink($this, $onlyUrl, $withimage, $userSide);
 }