* @license http://www.contenido.org/license/LIZENZ.txt * @link http://www.4fb.de * @link http://www.contenido.org * @since file available since contenido release <= 4.6 * * {@internal * created unknown * modified 2008-06-26, Timo Trautmann, changed post var from treeItem to treeItemPost (security issue) * modified 2008-07-02, Frederic Schneider, add security fix * * $Id: class.content_allocation_treeview.php 128 2019-07-03 11:58:28Z oldperl $: * }} * */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } /** * Todo * - generalize this and papitree !!!! * - Comments! */ class pApiContentAllocationTreeView extends pApiTree { /** * */ var $tpl = null; /** * */ var $template = ''; /** * */ public function __construct($uuid) { global $cfg; parent::__construct($uuid); $this->tpl = new Template; $this->template = $cfg['pica']['treetemplate']; } /** * */ function _buildRenderTree($tree) { global $action, $frame, $area, $sess; $result = array(); foreach ($tree as $item_tmp) { $item = array(); // update item if ($_GET['step'] == 'rename' && $item_tmp['idpica_alloc'] == $_GET['idpica_alloc']) { $item = array(); $item['ITEMNAME'] = '
 ';
            $item['ACTION_RENAME'] = '
';
            $item['ACTION_RENAME'] = ' ';
            $item['ACTION_MOVE_UP'] = (count($result) >= 1) ? '
';
            $item['ACTION_MOVE_UP'] = (count($result) >= 1) ? ' ' : '
' : ' ';
            $item['ACTION_MOVE_DOWN'] = (count($result) >= 1) ? '
';
            $item['ACTION_MOVE_DOWN'] = (count($result) >= 1) ? ' ' : '
' : ' ';
            $item['ACTION_MOVE_DOWN'] = '';
            if ($item_tmp['online'] == 1) { // set offline
                $item['ACTION_ONOFFLINE'] = '
';
            $item['ACTION_MOVE_DOWN'] = '';
            if ($item_tmp['online'] == 1) { // set offline
                $item['ACTION_ONOFFLINE'] = ' ';
            } else {
                $item['ACTION_ONOFFLINE'] = '
';
            } else {
                $item['ACTION_ONOFFLINE'] = ' ';
            }
            if ($item_tmp['children']) {
                $item['ACTION_DELETE'] = '
';
            }
            if ($item_tmp['children']) {
                $item['ACTION_DELETE'] = ' ';
            } else {
                $item['ACTION_DELETE'] = '
';
            } else {
                $item['ACTION_DELETE'] = ' ';
            }
            array_push($result, $item);
            if ($item_tmp['children']) {
                $children = $this->_buildRenderTree($item_tmp['children']);
                $result = array_merge($result, $children);
            }
            // add new item -> show formular
            if ($_GET['step'] == 'add' && $item_tmp['idpica_alloc'] == $_GET['parentid']) {
                $item = array();
                $item['ITEMNAME'] = '
';
            }
            array_push($result, $item);
            if ($item_tmp['children']) {
                $children = $this->_buildRenderTree($item_tmp['children']);
                $result = array_merge($result, $children);
            }
            // add new item -> show formular
            if ($_GET['step'] == 'add' && $item_tmp['idpica_alloc'] == $_GET['parentid']) {
                $item = array();
                $item['ITEMNAME'] = '
					 ';
                $item['ACTION_RENAME'] = '
';
                $item['ACTION_RENAME'] = ' ';
                $item['ACTION_MOVE_UP'] = '
';
                $item['ACTION_MOVE_UP'] = ' ';
                $item['ACTION_MOVE_DOWN'] = '
';
                $item['ACTION_MOVE_DOWN'] = ' ';
                $item['ACTION_MOVE_DOWN'] = '';
                $item['ACTION_DELETE'] = '
';
                $item['ACTION_MOVE_DOWN'] = '';
                $item['ACTION_DELETE'] = ' ';
                $item['ACTION_ONOFFLINE'] = '
';
                $item['ACTION_ONOFFLINE'] = ' ';
                array_push($result, $item);
            }
        }
        return $result;
    }
    /**
     * 
     */
    function renderTree($return = true) {
        $this->tpl->reset();
        $tree = $this->fetchTree(false, 0, true); # modified 27.10.2005
        if ($tree === false) {
            return false;
        }
        $tree = $this->_buildRenderTree($tree);
        $even = true;
        foreach ($tree as $item) {
            $even = !$even;
            $bgcolor = ($even) ? '#FFFFFF' : '#F1F1F1';
            $this->tpl->set('d', 'BACKGROUND_COLOR', $bgcolor);
            foreach ($item as $key => $value) {
                $this->tpl->set('d', $key, $value);
            }
            $this->tpl->next();
        }
        $this->tpl->set('s', 'CATEGORY', i18n("Category", "content_allocation"));
        $this->tpl->set('s', 'ACTIONS', i18n("Actions", "content_allocation"));
        if ($return === true) {
            return $this->tpl->generate($this->template, true);
        } else {
            $this->tpl->generate($this->template);
        }
    }
}
?>
';
                array_push($result, $item);
            }
        }
        return $result;
    }
    /**
     * 
     */
    function renderTree($return = true) {
        $this->tpl->reset();
        $tree = $this->fetchTree(false, 0, true); # modified 27.10.2005
        if ($tree === false) {
            return false;
        }
        $tree = $this->_buildRenderTree($tree);
        $even = true;
        foreach ($tree as $item) {
            $even = !$even;
            $bgcolor = ($even) ? '#FFFFFF' : '#F1F1F1';
            $this->tpl->set('d', 'BACKGROUND_COLOR', $bgcolor);
            foreach ($item as $key => $value) {
                $this->tpl->set('d', $key, $value);
            }
            $this->tpl->next();
        }
        $this->tpl->set('s', 'CATEGORY', i18n("Category", "content_allocation"));
        $this->tpl->set('s', 'ACTIONS', i18n("Actions", "content_allocation"));
        if ($return === true) {
            return $this->tpl->generate($this->template, true);
        } else {
            $this->tpl->generate($this->template);
        }
    }
}
?>