示例#1
0
 function getDeleteItemLink($onlyUrl = false, $withimage = false, $userSide = false)
 {
     $controller = new SmartObjectController($this->handler);
     return $controller->getDeleteItemLink($this, $onlyUrl, $withimage, $userSide);
 }
 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}();
         }
     }
     include_once SMARTOBJECT_ROOT_PATH . "class/smartobjectcontroller.php";
     $controller = new SmartObjectController($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('smartobject_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);
         }
     }
 }
示例#3
0
 function createTableRows()
 {
     $this->_aObjects = array();
     $doWeHaveActions = false;
     $objectclass = 'odd';
     if (count($this->_objects) > 0) {
         foreach ($this->_objects as $object) {
             $aObject = array();
             $i = 0;
             $aColumns = array();
             foreach ($this->_columns as $column) {
                 $aColumn = array();
                 if ($i == 0) {
                     $class = "head";
                 } elseif ($i % 2 == 0) {
                     $class = "even";
                 } else {
                     $class = "odd";
                 }
                 if (method_exists($object, 'initiateCustomFields')) {
                     //$object->initiateCustomFields();
                 }
                 if ($column->_keyname == 'checked') {
                     $value = '<input type ="checkbox" name="selected_smartobjects[]" value="' . $object->id() . '" />';
                 } elseif ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
                     $method = $column->_customMethodForValue;
                     if ($column->_param) {
                         $value = $object->{$method}($column->_param);
                     } else {
                         $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());
                     }
                 }
                 $aColumn['value'] = $value;
                 $aColumn['class'] = $class;
                 $aColumn['width'] = $column->getWidth();
                 $aColumn['align'] = $column->getAlign();
                 $aColumns[] = $aColumn;
                 $i++;
             }
             $aObject['columns'] = $aColumns;
             $aObject['id'] = $object->id();
             $objectclass = $objectclass == 'even' ? 'odd' : 'even';
             $aObject['class'] = $objectclass;
             $actions = array();
             // Adding the custom actions if any
             foreach ($this->_custom_actions as $action) {
                 if (method_exists($object, $action)) {
                     $actions[] = $object->{$action}();
                 }
             }
             include_once SMARTOBJECT_ROOT_PATH . "class/smartobjectcontroller.php";
             $controller = new SmartObjectController($this->_objectHandler);
             if (!is_array($this->_actions) || in_array('edit', $this->_actions)) {
                 $actions[] = $controller->getEditItemLink($object, false, true, $this->_userSide);
             }
             if (!is_array($this->_actions) || in_array('delete', $this->_actions)) {
                 $actions[] = $controller->getDeleteItemLink($object, false, true, $this->_userSide);
             }
             $aObject['actions'] = $actions;
             $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
             $doWeHaveActions = $doWeHaveActions ? true : count($actions) > 0;
             $this->_aObjects[] = $aObject;
         }
         $this->_tpl->assign('smartobject_objects', $this->_aObjects);
     } else {
         $colspan = count($this->_columns) + 1;
         $this->_tpl->assign('smartobject_colspan', $colspan);
     }
     $this->_hasActions = $doWeHaveActions;
 }