Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SIWECOS
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • pApiContentAllocation
  • pApiContentAllocationArticle
  • pApiContentAllocationComplexList
  • pApiContentAllocationSelectBox
  • pApiContentAllocationTreeView
  • pApiTree

Functions

  • pica_ArticleListActions
  • pica_GetCustomTabProperties
  • pica_RegisterCustomTab
  • pica_RenderArticleAction
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the tree view class for the plugin content allocation.
  5:  *
  6:  * @package    Plugin
  7:  * @subpackage ContentAllocation
  8:  * @author     Marco Jahn
  9:  * @copyright  four for business AG <www.4fb.de>
 10:  * @license    http://www.contenido.org/license/LIZENZ.txt
 11:  * @link       http://www.4fb.de
 12:  * @link       http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: plugin_include('repository', 'custom/FrontendNavigation.php');
 18: 
 19: /**
 20:  * Tree view class for content allocation
 21:  *
 22:  * @package    Plugin
 23:  * @subpackage ContentAllocation
 24:  */
 25: class pApiContentAllocationTreeView extends pApiTree {
 26: 
 27:     /**
 28:      * @var object cTemplate
 29:      */
 30:     protected $_tpl = null;
 31: 
 32:     /**
 33:      * @var string
 34:      */
 35:     protected $_template = '';
 36: 
 37:     /**
 38:      * pApiContentAllocationTreeView constructor
 39:      *
 40:      * @param string $uuid
 41:      *
 42:      * @throws cDbException
 43:      * @throws cException
 44:      */
 45:     public function __construct($uuid) {
 46:         $cfg = cRegistry::getConfig();
 47: 
 48:         parent::__construct($uuid);
 49:         $this->_tpl = new cTemplate();
 50:         $this->_template = $cfg['pica']['treetemplate'];
 51:     }
 52: 
 53:     /**
 54:      * Old constructor
 55:      *
 56:      * @deprecated [2016-02-11]
 57:      *                This method is deprecated and is not needed any longer. Please use __construct() as constructor function.
 58:      *
 59:      * @param string $uuid
 60:      *
 61:      * @return pApiContentAllocationTreeView
 62:      * @throws cDbException
 63:      * @throws cException
 64:      */
 65:     public function pApiContentAllocationTreeView($uuid) {
 66:         cDeprecated('This method is deprecated and is not needed any longer. Please use __construct() as constructor function.');
 67:         return $this->__construct($uuid);
 68:     }
 69: 
 70:     /**
 71:      * Build an render tree
 72:      *
 73:      * @param array $tree
 74:      * @return array $result html code
 75:      */
 76:     protected function _buildRenderTree($tree) {
 77:         global $action, $frame, $area;
 78:         $idart = cRegistry::getArticleId();
 79:         $sess = cRegistry::getBackendSessionId();
 80: 
 81:         $result = array();
 82:         foreach ($tree as $item_tmp) {
 83:             $item = array();
 84:             // update item
 85:             if ($_GET['step'] == 'rename' && $item_tmp['idpica_alloc'] == $_GET['idpica_alloc']) {
 86:                 $item = array();
 87:                 $item['ITEMNAME'] = '
 88:                     <table cellspacing="0" cellpaddin="0" border="0">
 89:                     <form name="rename" action="main.php" method="POST" onsubmit="return fieldCheck();">
 90:                     <input type="hidden" name="action" value="' . $action . '">
 91:                     <input type="hidden" name="frame" value="' . $frame . '">
 92:                     <input type="hidden" name="contenido" value="' . $sess . '">
 93:                     <input type="hidden" name="area" value="' . $area . '">
 94:                     <input type="hidden" name="step" value="storeRename">
 95:                     <input type="hidden" name="treeItemPost[idpica_alloc]" value="' . $item_tmp['idpica_alloc'] . '">
 96:                     <tr>
 97:                     <td class="text_medium"><input id="itemname" class="text_medium" type="text" name="treeItemPost[name]" value="' . conHtmlentities($item_tmp['name']) . '"></td>
 98:                     <td>&nbsp;
 99:                     <a href="main.php?action=' . $action . '&frame=' . $frame . '&area=' . $area . '&contenido=' . $sess . '"><img src="images/but_cancel.gif" border="0"></a>
100:                     <input type="image" src="images/but_ok.gif">
101:                     </td></tr>
102:                     </form>
103:                     </table>
104:                     <script type="text/javascript">
105:                     var controller = document.getElementById("itemname");
106:                     controller.focus();
107:                     function fieldCheck() {
108:                         if (controller.value == "") {
109:                             alert("' . i18n("Please enter a category name", 'content_allocation') . '");
110:                             controller.focus();
111:                             return false;
112:                         }
113:                         return true;
114:                     }
115:                     </script>';
116:             } else {
117:                 if ($item_tmp['children'] || $item_tmp['status'] == 'collapsed') {
118:                     $expandCollapseImg = 'images/close_all.gif';
119:                     if ($item_tmp['status'] == 'collapsed') {
120:                         $expandCollapseImg = 'images/open_all.gif';
121:                     }
122: 
123:                     $expandCollapse = '<a href="main.php?contenido=' . $sess . '&idart=' . $idart . '&action=' . $action . '&frame=' . $frame . '&area=' . $area .  '&oldstate=' . 'huhu' . '&step=collapse&idpica_alloc=' . $item_tmp['idpica_alloc'] . '"><img src="' . $expandCollapseImg . '" border="0" class="vAlignMiddle" alt="" width="7" height="7"></a>';
124:                 } else {
125:                     $expandCollapseImg = 'images/spacer.gif';
126:                     $expandCollapse = '<img src="' . $expandCollapseImg . '" border="0" alt="" class="vAlignMiddle" width="11" height="11">';
127:                 }
128: 
129:                 if ($item_tmp['status'] == 'collapsed') {
130:                     $expandCollapse = '<a href="main.php?contenido=' . $sess . '&idart=' . $idart . '&action=' . $action . '&frame=' . $frame . '&area=' . $area . '&step=expanded&idpica_alloc=' . $item_tmp['idpica_alloc'] . '"><img src="' . $expandCollapseImg . '" border="0" alt="" class="vAlignMiddle" width="7" height="7"></a>';
131:                 }
132:                 $item['ITEMNAME'] = $expandCollapse . ' ' . $item_tmp['name'];
133:             }
134:             $item['ITEMINDENT'] = $item_tmp['level'] * 15 + 3;
135:             $item['ACTION_CREATE'] = '<a href="main.php?contenido=' . $sess . '&action=' . $action . '&frame=' . $frame . '&area=' . $area . '&step=add&parentid=' . $item_tmp['idpica_alloc'] . '"><img src="images/folder_new.gif" border="0" alt="" title="' . i18n("New category", 'content_allocation') . '" alt="' . i18n("New category", 'content_allocation') . '"></a>';
136: 
137:             $item['ACTION_RENAME'] = '<a href="main.php?contenido=' . $sess . '&action=' . $action . '&frame=' . $frame . '&area=' . $area . '&step=rename&idpica_alloc=' . $item_tmp['idpica_alloc'] . '"><img src="images/but_todo.gif" width="16" height="16" border="0" alt="' . i18n("Rename category", 'content_allocation') . '" title="' . i18n("Rename category", 'content_allocation') . '"></a>';
138:             $item['ACTION_MOVE_UP'] = (count($result) >= 1) ? '<a href="main.php?contenido=' . $sess . '&action=' . $action . '&frame=' . $frame . '&area=' . $area . '&step=moveup&idpica_alloc=' . $item_tmp['idpica_alloc'] . '"><img src="images/folder_moveup.gif" border="0" alt="' . i18n("Move category up", 'content_allocation') . '" title="' . i18n("Move category up", 'content_allocation') . '"></a>' : '<img src="images/spacer.gif" width="16" height="16"></a>';
139:             $item['ACTION_MOVE_DOWN'] = (count($result) >= 1) ? '<img src="images/folder_movedown.gif" border="0" alt="' . i18n("Move category down", 'content_allocation') . '" title="' . i18n("Move category down", 'content_allocation') . '">' : '<img src="images/spacer.gif" width="16" height="16">';
140:             $item['ACTION_MOVE_DOWN'] = '';
141: 
142:             if ($item_tmp['online'] == 1) { // set offline
143:                 $item['ACTION_ONOFFLINE'] = '<a href="main.php?contenido=' . $sess . '&action=' . $action . '&frame=' . $frame . '&area=' . $area . '&step=offline&idpica_alloc=' . $item_tmp['idpica_alloc'] . '"><img src="images/online.gif" alt="' . i18n("Set category offline", 'content_allocation') . '" title="' . i18n("Set category offline", 'content_allocation') . '"></a>';
144:             } else {
145:                 $item['ACTION_ONOFFLINE'] = '<a href="main.php?contenido=' . $sess . '&action=' . $action . '&frame=' . $frame . '&area=' . $area . '&step=online&idpica_alloc=' . $item_tmp['idpica_alloc'] . '"><img src="images/offline.gif" alt="' . i18n("Set category online", 'content_allocation') . '" title="' . i18n("Set category online", 'content_allocation') . '"></a>';
146:             }
147: 
148:             if ($item_tmp['children']) {
149:                 $item['ACTION_DELETE'] = '<img src="images/delete_inact.gif" border="0" alt="' . i18n("One or more subcategories exist, unable to delete", 'content_allocation') . '" title="' . i18n("One or more subcategories exist, unable to delete", 'content_allocation') . '">';
150:             } else {
151:                 $name = str_replace("\"", "&amp;quot;", str_replace("'", "\'", $item_tmp['name']));
152:                 $item['ACTION_DELETE'] = '<a href="javascript:void(0)" onclick="Con.showConfirmation(&quot;' . i18n("Are you sure to delete the following category", 'content_allocation') . '&quot;, function() { deleteCategory(' . $item_tmp['idpica_alloc'] . '); });return false;"><img src="images/delete.gif" border="0" alt="' . i18n("Delete category") . '" title="' . i18n("Delete category", 'content_allocation') . '"></a>';
153:             }
154: 
155:             $result[] = $item;
156: 
157:             if ($item_tmp['children']) {
158:                 $children = $this->_buildRenderTree($item_tmp['children']);
159:                 $result = array_merge($result, $children);
160:             }
161: 
162:             // add new item -> show formular
163:             if ($_GET['step'] == 'add' && $item_tmp['idpica_alloc'] == $_GET['parentid']) {
164:                 $item = array();
165: 
166:                 $item['ITEMNAME'] = '
167:                     <table cellspacing="0" cellpaddin="0" border="0">
168:                     <form name="create" action="main.php" method="POST" onsubmit="return fieldCheck();">
169:                     <input type="hidden" name="action" value="' . $action . '">
170:                     <input type="hidden" name="frame" value="' . $frame . '">
171:                     <input type="hidden" name="contenido" value="' . $sess . '">
172:                     <input type="hidden" name="area" value="' . $area . '">
173:                     <input type="hidden" name="step" value="store">
174:                     <input type="hidden" name="treeItemPost[parentid]" value="' . cSecurity::toInteger($_GET['parentid']) . '">
175:                     <tr>
176:                     <td class="text_medium"><input id="itemname" class="text_medium" type="text" name="treeItemPost[name]" value=""></td>
177:                     <td>&nbsp;
178:                     <a href="main.php?action=' . $action . '&frame=' . $frame . '&area=' . $area . '&contenido=' . $sess . '"><img src="images/but_cancel.gif" alt="" border="0"></a>
179:                     <input type="image" src="images/but_ok.gif">
180:                     </td></tr>
181:                     </form>
182:                     </table>
183:                     <script type="text/javascript">
184:                     var controller = document.getElementById("itemname");
185:                     controller.focus();
186:                     function fieldCheck() {
187:                         if (controller.value == "") {
188:                             alert("' . i18n("Please enter a category name", 'content_allocation') . '");
189:                             controller.focus();
190:                             return false;
191:                         }
192:                         return true;
193:                     }
194:                     </script>';
195:                 $item['ITEMINDENT'] = ($item_tmp['level'] + 1) * 15;
196:                 $item['ACTION_CREATE'] = '<img src="images/spacer.gif" alt="" width="15" height="13">';
197:                 $item['ACTION_RENAME'] = '<img src="images/spacer.gif" alt="" width="23" height="14">';
198:                 $item['ACTION_MOVE_UP'] = '<img src="images/spacer.gif" alt="" width="15" height="13">';
199:                 $item['ACTION_MOVE_DOWN'] = '<img src="images/spacer.gif" alt="" width="15" height="13">';
200:                 $item['ACTION_MOVE_DOWN'] = '';
201:                 $item['ACTION_DELETE'] = '<img src="images/spacer.gif" alt="" width="14" height="13">';
202:                 $item['ACTION_ONOFFLINE'] = '<img src="images/spacer.gif" alt="" width="11" height="12">';
203: 
204:                 array_push($result, $item);
205:             }
206:         }
207:         return $result;
208:     }
209: 
210:     /**
211:      * Rendering tree
212:      *
213:      * @param bool $return
214:      *
215:      * @return string|bool
216:      * @throws cDbException
217:      * @throws cInvalidArgumentException
218:      */
219:     public function renderTree($return = true) {
220:         $this->_tpl->reset();
221: 
222:         $tree = $this->fetchTree(false, 0, true); // modified 27.10.2005
223: 
224:         if ($tree === false) {
225:             return false;
226:         }
227: 
228:         $tree = $this->_buildRenderTree($tree);
229: 
230:         $even = true;
231:         foreach ($tree as $item) {
232:             $even = !$even;
233:             $bgcolor = ($even) ? '#FFFFFF' : '#F1F1F1';
234:             $this->_tpl->set('d', 'BACKGROUND_COLOR', $bgcolor);
235:             foreach ($item as $key => $value) {
236:                 $this->_tpl->set('d', $key, $value);
237:             }
238:             $this->_tpl->next();
239:         }
240: 
241:         $this->_tpl->set('s', 'CATEGORY', i18n("Category", 'content_allocation'));
242:         $this->_tpl->set('s', 'ACTIONS', i18n("Actions", 'content_allocation'));
243: 
244:         if ($return === true) {
245:             return $this->_tpl->generate($this->_template, true);
246:         } else {
247:             $this->_tpl->generate($this->_template);
248:         }
249:     }
250: 
251: }
252: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0