1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113:
<?php
defined('ICMS_ROOT_PATH') or die('ImpressCMS root path not defined');
class icms_ipf_view_Single {
var $_object;
var $_userSide;
var $_tpl;
var $_rows;
var $_actions;
var $_headerAsRow = true;
public function __construct(&$object, $userSide = false, $actions = array(), $headerAsRow = true) {
$this->_object = $object;
$this->_userSide = $userSide;
$this->_actions = $actions;
$this->_headerAsRow = $headerAsRow;
}
public function addRow($rowObj) {
$this->_rows[] = $rowObj;
}
public function render($fetchOnly = false, $debug = false) {
$this->_tpl = new icms_view_Tpl();
$vars = $this->_object->vars;
$icms_object_array = array();
foreach ($this->_rows as $row) {
$key = $row->getKeyName();
if ($row->_customMethodForValue && method_exists($this->_object, $row->_customMethodForValue)) {
$method = $row->_customMethodForValue;
$value = $this->_object->$method();
} else {
$value = $this->_object->getVar($row->getKeyName());
}
if ($row->isHeader()) {
$this->_tpl->assign('icms_single_view_header_caption', $this->_object->vars[$key]['form_caption']);
$this->_tpl->assign('icms_single_view_header_value', $value);
} else {
$icms_object_array[$key]['value'] = $value;
$icms_object_array[$key]['header'] = $row->isHeader();
$icms_object_array[$key]['caption'] = $this->_object->vars[$key]['form_caption'];
}
}
$action_row = '';
if (in_array('edit', $this->_actions)) {
$action_row .= $this->_object->getEditItemLink(false, true, $this->_userSide);
}
if (in_array('delete', $this->_actions)) {
$action_row .= $this->_object->getDeleteItemLink(false, true, $this->_userSide);
}
if ($action_row) {
$icms_object_array['zaction']['value'] = $action_row;
$icms_object_array['zaction']['caption'] = _CO_ICMS_ACTIONS;
}
$this->_tpl->assign('icms_header_as_row', $this->_headerAsRow);
$this->_tpl->assign('icms_object_array', $icms_object_array);
if ($fetchOnly) {
return $this->_tpl->fetch('db:system_persistable_singleview.html');
} else {
$this->_tpl->display('db:system_persistable_singleview.html');
}
}
public function fetch($debug = false) {
return $this->render(true, $debug);
}
}