2016-10-06 15:57:01 +00:00
< ? php
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
/**
* Project :
* Contenido Content Management System
*
* Description :
* Displays structure
*
* Requirements :
* @ con_php_req 5.0
*
*
* @ package Contenido Backend includes
* @ version 1.0 . 4
* @ author Olaf Niemann
* @ copyright four for business AG < www . 4 fb . de >
* @ license http :// www . contenido . org / license / LIZENZ . txt
* @ link http :// www . 4 fb . de
* @ link http :// www . contenido . org
* @ since file available since contenido release <= 4.6
*
* { @ internal
* created 2003 - 03 - 28
* modified 2008 - 06 - 27 , Dominik Ziegler , add security fix
* modified 2009 - 10 - 14 , Dominik Ziegler - added some functionality for " cancel moving tree "
* modified 2009 - 10 - 15 , Dominik Ziegler - removed unnecessary database query for selecting the level ( level is already available )
* modified 2010 - 01 - 30 , Ingo van Peeren , some optimization of the amount of db queries for template names and descriptions , see [ CON - 301 ]
* removed use of deprecated methods of class . template . php , see [ CON - 302 ]
* modified 2010 - 02 - 06 , Ingo van Peeren , fixed small bug added by last modification
*
2019-07-03 11:58:28 +00:00
* $Id $ :
2016-10-06 15:57:01 +00:00
* }}
*
*/
2017-03-09 13:52:17 +00:00
if ( ! defined ( 'CON_FRAMEWORK' )) {
die ( 'Illegal call' );
2016-10-06 15:57:01 +00:00
}
2017-06-09 14:53:30 +00:00
$debug = FALSE ;
2016-10-06 15:57:01 +00:00
$tmp_area = " str " ;
if ( $action == " str_duplicate " &&
2017-03-09 13:52:17 +00:00
( $perm -> have_perm_area_action ( " str " , " str_duplicate " ) ||
$perm -> have_perm_area_action_item ( " str " , " str_duplicate " , $idcat ))) {
strCopyTree ( $idcat , $parentid );
2016-10-06 15:57:01 +00:00
}
//Everybody is allowed to update aliases, if there is no Permission to update category names, this block updates category alias only
2017-03-09 13:52:17 +00:00
if ( isset ( $_POST [ 'newcategoryalias' ]) && isset ( $_POST [ 'action' ]) && $_POST [ 'action' ] == 'str_renamecat' ) {
$iIdCat = ( int ) $_POST [ 'idcat' ];
if ( ! ( $perm -> have_perm_area_action ( $tmp_area , " str_renamecat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_renamecat " , $iIdCat ))) {
if ( trim ( $_POST [ 'newcategoryalias' ]) != '' ) {
$sUrlName = capiStrCleanURLCharacters ( $_POST [ 'newcategoryalias' ]);
$sql = " UPDATE { $cfg [ 'tab' ][ 'cat_lang' ] } SET urlname = ' " . Contenido_Security :: escapeDB ( $sUrlName , $db ) . " ' WHERE idcat = ' " . Contenido_Security :: toInteger ( $iIdCat ) . " ' AND idlang = ' " . Contenido_Security :: toInteger ( $lang ) . " ' " ;
$db -> query ( $sql );
} else {
//Use categoryname as default -> get it escape it save it as urlname
$sql = " SELECT name from { $cfg [ 'tab' ][ 'cat_lang' ] } WHERE idcat = ' " . Contenido_Security :: toInteger ( $iIdCat ) . " ' AND idlang = ' " . Contenido_Security :: toInteger ( $lang ) . " ' " ;
$db -> query ( $sql );
if ( $db -> next_record ()) {
$sUrlName = capiStrCleanURLCharacters ( $db -> f ( 'name' ));
$sql = " UPDATE { $cfg [ 'tab' ][ 'cat_lang' ] } SET urlname = ' " . $sUrlName . " ' WHERE idcat = ' " . Contenido_Security :: toInteger ( $iIdCat ) . " ' AND idlang = ' " . Contenido_Security :: toInteger ( $lang ) . " ' " ;
$db -> query ( $sql );
$lang = Contenido_Security :: escapeDB ( $lang , null );
@ unlink ( $cfgClient [ $client ][ " path " ][ " frontend " ] . " cache/locationstring-url-cache- $lang .txt " );
}
}
2016-10-06 15:57:01 +00:00
}
}
$oDirectionDb = new DB_ConLite ();
/**
* Build a Category select Box containg all categories which user is allowed to create new categories
*
* @ return String HTML
*/
function buildCategorySelectRights () {
2017-03-09 13:52:17 +00:00
global $cfg , $client , $lang , $idcat , $perm , $tmp_area ;
$db = new DB_ConLite ();
$oHtmlSelect = new cHTMLSelectElement ( 'idcat' , " " , " new_idcat " );
2016-10-06 15:57:01 +00:00
$oHtmlSelectOption = new cHTMLOptionElement ( i18n ( " Please choose " ), '' , true );
$oHtmlSelect -> addOptionElement ( 0 , $oHtmlSelectOption );
2017-03-09 13:52:17 +00:00
$sql = " SELECT a.idcat AS idcat, b.name AS name, c.level FROM
" . $cfg["tab"] [ " cat " ] . " AS a , " . $cfg["tab"] [ " cat_lang " ] . " AS b ,
" . $cfg["tab"] [ " cat_tree " ] . " AS c WHERE a . idclient = '" . Contenido_Security::toInteger($client) . "'
AND b . idlang = '" . Contenido_Security::toInteger($lang) . "' AND b . idcat = a . idcat AND c . idcat = a . idcat
2016-10-06 15:57:01 +00:00
ORDER BY c . idtree " ;
2017-03-09 13:52:17 +00:00
$db -> query ( $sql );
2016-10-06 15:57:01 +00:00
2017-03-09 13:52:17 +00:00
$categories = array ();
2016-10-06 15:57:01 +00:00
2017-03-09 13:52:17 +00:00
while ( $db -> next_record ()) {
$categories [ $db -> f ( " idcat " )][ " name " ] = $db -> f ( " name " );
2016-10-06 15:57:01 +00:00
$categories [ $db -> f ( " idcat " )][ " idcat " ] = $db -> f ( " idcat " );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_newcat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_newcat " , $db -> f ( " idcat " ))) {
$categories [ $db -> f ( " idcat " )][ " perm " ] = 1 ;
} else {
$categories [ $db -> f ( " idcat " )][ " perm " ] = 0 ;
}
2017-03-09 13:52:17 +00:00
$categories [ $db -> f ( " idcat " )][ " level " ] = $db -> f ( " level " );
}
2016-10-06 15:57:01 +00:00
$aCategoriesReversed = array_reverse ( $categories );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$iLevel = 0 ;
foreach ( $aCategoriesReversed as $iKeyIdCat => $aValues ) {
if ( $aValues [ 'level' ] > $iLevel && $aValues [ 'perm' ]) {
$iLevel = $aValues [ 'level' ];
} else if ( $aValues [ 'level' ] < $iLevel ) {
$iLevel = $aValues [ 'level' ];
} else {
if ( ! $aValues [ 'perm' ]) {
unset ( $categories [ $aValues [ " idcat " ]]);
}
}
}
$j = 1 ;
2017-03-09 13:52:17 +00:00
foreach ( $categories as $tmpidcat => $props ) {
$spaces = " " ;
2016-10-06 15:57:01 +00:00
2017-03-09 13:52:17 +00:00
for ( $i = 0 ; $i < $props [ " level " ]; $i ++ ) {
$spaces .= " " ;
}
2016-10-06 15:57:01 +00:00
$sCategoryname = clHtmlSpecialChars ( $props [ " name " ]);
$sCategoryname = capiStrTrimHard ( $sCategoryname , 30 );
2017-03-09 13:52:17 +00:00
$oHtmlSelectOption = new cHTMLOptionElement ( $spaces . " > " . $sCategoryname , $tmpidcat , false , ! $props [ " perm " ]);
$oHtmlSelect -> addOptionElement ( $j , $oHtmlSelectOption );
$j ++ ;
}
2016-10-06 15:57:01 +00:00
2017-03-09 13:52:17 +00:00
return $oHtmlSelect -> toHtml ();
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
function getExpandCollapseButton ( $item , $catName ) {
global $sess , $PHP_SELF , $frame , $area ;
$selflink = " main.php " ;
$img = new cHTMLImage ;
$img -> updateAttributes ( array ( " style " => " padding:4px; " ));
if ( count ( $item -> subitems ) > 0 ) {
if ( $item -> collapsed == true ) {
$expandlink = $sess -> url ( $selflink . " ?area= $area &frame= $frame &expand= " . $item -> id );
$img -> setSrc ( $item -> collapsed_icon );
$img -> setAlt ( i18n ( " Open category " ));
return ( '<a href="' . $expandlink . '">' . $img -> render () . '</a> ' . '<a href="' . $expandlink . '">' . $catName . '</a>' );
} else {
$collapselink = $sess -> url ( $selflink . " ?area= $area &frame= $frame &collapse= " . $item -> id );
$img -> setSrc ( $item -> expanded_icon );
$img -> setAlt ( i18n ( " Close category " ));
return ( '<a href="' . $collapselink . '">' . $img -> render () . '</a> ' . '<a href="' . $collapselink . '">' . $catName . '</a>' );
}
} else {
return '<img src="images/spacer.gif" style="padding:4px;" width="7" height="7"> ' . $catName ;
}
2016-10-06 15:57:01 +00:00
}
function getTemplateSelect () {
global $client , $cfg , $db ;
2017-03-09 13:52:17 +00:00
$oHtmlSelect = new cHTMLSelectElement ( 'cat_template_select' , " " , " cat_template_select " );
$oHtmlSelectOption = new cHTMLOptionElement ( '--- ' . i18n ( " none " ) . ' ---' , 0 , false );
2016-10-06 15:57:01 +00:00
$oHtmlSelect -> addOptionElement ( 0 , $oHtmlSelectOption );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$sql = " SELECT
idtpl ,
name , defaulttemplate
FROM
2017-03-09 13:52:17 +00:00
" . $cfg['tab'] ['tpl'] . "
2016-10-06 15:57:01 +00:00
WHERE
2017-03-09 13:52:17 +00:00
idclient = '" . $client . "'
2016-10-06 15:57:01 +00:00
ORDER BY
name " ;
2017-03-09 13:52:17 +00:00
$i = 1 ;
2016-10-06 15:57:01 +00:00
if ( $db -> query ( $sql )) {
while ( $db -> next_record ()) {
$bDefaultTemplate = $db -> f ( 'defaulttemplate' );
$oHtmlSelectOption = new cHTMLOptionElement ( $db -> f ( 'name' ), $db -> f ( 'idtpl' ), $bDefaultTemplate );
$oHtmlSelect -> addOptionElement ( $i , $oHtmlSelectOption );
$i ++ ;
}
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
return $oHtmlSelect -> toHtml ();
}
getTemplateSelect ();
$sess -> register ( " remakeStrTable " );
$sess -> register ( " StrTableClient " );
$sess -> register ( " StrTableLang " );
$cancel = $sess -> url ( " main.php?area= $area &frame= $frame " );
if ( isset ( $force ) && $force == 1 ) {
$remakeStrTable = true ;
}
2017-03-09 13:52:17 +00:00
if ( $StrTableClient != $client ) {
unset ( $expandedList );
2016-10-06 15:57:01 +00:00
$remakeStrTable = true ;
}
2017-03-09 13:52:17 +00:00
if ( $StrTableLang != $lang ) {
unset ( $expandedList );
$remakeStrTable = true ;
2016-10-06 15:57:01 +00:00
}
$StrTableClient = $client ;
$StrTableLang = $lang ;
2017-03-09 13:52:17 +00:00
if ( ! isset ( $idcat ))
$idcat = 0 ;
if ( ! isset ( $action ))
$action = 0 ;
2019-07-07 18:14:22 +00:00
function buildTree ( & $rootItem , $itemsIterator ) {
global $nextItem , $perm , $tmp_area ;
while ( $itemsIterator -> valid ()) {
$key = $itemsIterator -> key ();
$item = $itemsIterator -> current ();
$itemsIterator -> next ();
unset ( $newItem );
$bCheck = false ;
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_newtree' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_newcat' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_makevisible' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_makepublic' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_deletecat' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_moveupcat' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $ tmp_area , 'str_movedowncat' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_movesubtree' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , 'str_renamecat' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( 'str_tplcfg' , 'str_tplcfg' );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_item ( $tmp_area , $item [ 'idcat' ]);
}
if ( $bCheck ) {
$newItem = new TreeItem ( $item [ 'name' ], $item [ 'idcat' ], true );
} else {
$newItem = new TreeItem ( $item [ 'name' ], $item [ 'idcat' ], false );
}
$newItem -> setCollapsedIcon ( 'images/open_all.gif' );
$newItem -> setExpandedIcon ( 'images/close_all.gif' );
$newItem -> setCustom ( 'idtree' , $item [ 'idtree' ]);
$newItem -> setCustom ( 'level' , $item [ 'level' ]);
$newItem -> setCustom ( 'idcat' , $item [ 'idcat' ]);
$newItem -> setCustom ( 'idtree' , $item [ 'idtree' ]);
$newItem -> setCustom ( 'parentid' , $item [ 'parentid' ]);
$newItem -> setCustom ( 'alias' , $item [ 'alias' ]);
$newItem -> setCustom ( 'preid' , $item [ 'preid' ]);
$newItem -> setCustom ( 'postid' , $item [ 'postid' ]);
$newItem -> setCustom ( 'visible' , $item [ 'visible' ]);
$newItem -> setCustom ( 'idtplcfg' , $item [ 'idtplcfg' ]);
$newItem -> setCustom ( 'public' , $item [ 'public' ]);
if ( $perm -> have_perm_item ( 'str' , $item [ 'idcat' ])) {
$newItem -> setCustom ( 'forcedisplay' , 1 );
}
if ( $itemsIterator -> offsetExists ( $key + 1 )) {
$nextItem = $itemsIterator -> offsetGet ( $key + 1 );
} else {
$nextItem = 0 ;
}
$rootItem -> addItem ( $newItem );
if ( $nextItem [ 'level' ] > $item [ 'level' ]) {
$oldRoot = $rootItem ;
buildTree ( $newItem , $itemsIterator );
$rootItem = $oldRoot ;
}
if ( $nextItem [ 'level' ] < $item [ 'level' ]) {
return ;
}
}
}
2016-10-06 15:57:01 +00:00
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $area )) {
2016-10-06 15:57:01 +00:00
$sql = " SELECT
idtree , A . idcat , level , name , parentid , preid , postid , visible , public , idtplcfg , C . urlname as alias
FROM
2017-03-09 13:52:17 +00:00
" . $cfg["tab"] [ " cat_tree " ] . " AS A ,
" . $cfg["tab"] [ " cat " ] . " AS B ,
" . $cfg["tab"] [ " cat_lang " ] . " AS C
2016-10-06 15:57:01 +00:00
WHERE
A . idcat = B . idcat AND
B . idcat = C . idcat AND
2017-03-09 13:52:17 +00:00
C . idlang = '" . Contenido_Security::toInteger($lang) . "' AND
B . idclient = '" . Contenido_Security::toInteger($client) . "'
2016-10-06 15:57:01 +00:00
ORDER BY
idtree " ;
# Debug info
2017-03-09 13:52:17 +00:00
if ( $debug ) {
2016-10-06 15:57:01 +00:00
echo " <pre> " ;
echo $sql ;
echo " </pre> " ;
}
$db -> query ( $sql );
2017-03-09 13:52:17 +00:00
$bIgnore = false ;
$iIgnoreLevel = 0 ;
$items = array ();
while ( $db -> next_record ()) {
2016-10-06 15:57:01 +00:00
$bSkip = false ;
2017-03-09 13:52:17 +00:00
if ( $bIgnore == true && $iIgnoreLevel >= $db -> f ( " level " )) {
$bIgnore = false ;
}
if ( $db -> f ( " idcat " ) == $movesubtreeidcat ) {
$bIgnore = true ;
$iIgnoreLevel = $db -> f ( " level " );
$sMoveSubtreeCatName = $db -> f ( " name " );
}
2016-10-06 15:57:01 +00:00
if ( $iCurLevel == $db -> f ( " level " )) {
if ( $iCurParent != $db -> f ( " parentid " )) {
$bSkip = true ;
}
} else {
$iCurLevel = $db -> f ( " level " );
$iCurParent = $db -> f ( " parentid " );
}
2017-03-09 13:52:17 +00:00
if ( $bIgnore == false && $bSkip == false ) {
$entry = array ();
$entry [ 'idtree' ] = $db -> f ( " idtree " );
$entry [ 'idcat' ] = $db -> f ( " idcat " );
$entry [ 'level' ] = $db -> f ( " level " );
$entry [ 'name' ] = htmldecode ( $db -> f ( " name " ));
$entry [ 'alias' ] = htmldecode ( $db -> f ( " alias " ));
$entry [ 'parentid' ] = $db -> f ( " parentid " );
$entry [ 'preid' ] = $db -> f ( " preid " );
$entry [ 'postid' ] = $db -> f ( " postid " );
$entry [ 'visible' ] = $db -> f ( " visible " );
$entry [ 'public' ] = $db -> f ( " public " );
$entry [ 'idtplcfg' ] = $db -> f ( " idtplcfg " );
array_push ( $items , $entry );
}
}
$rootStrItem = new TreeItem ( " root " , - 1 );
$rootStrItem -> collapsed_icon = 'images/open_all.gif' ;
$rootStrItem -> expanded_icon = 'images/close_all.gif' ;
2019-07-07 18:14:22 +00:00
$arrayObj = new ArrayObject ( $items );
buildTree ( $rootStrItem , $arrayObj -> getIterator ());
2017-03-09 13:52:17 +00:00
$expandedList = unserialize ( $currentuser -> getUserProperty ( " system " , " cat_expandstate " ));
if ( is_array ( $expandedList )) {
$rootStrItem -> markExpanded ( $expandedList );
}
if ( isset ( $collapse ) && is_numeric ( $collapse )) {
$rootStrItem -> markCollapsed ( $collapse );
}
if ( isset ( $expand ) && is_numeric ( $expand )) {
$rootStrItem -> markExpanded ( $expand );
}
if ( isset ( $expand ) && $expand == " all " ) {
$rootStrItem -> expandAll ( - 1 );
}
if ( isset ( $collapse ) && $collapse == " all " ) {
$rootStrItem -> collapseAll ( - 1 );
}
if ( $action === " str_newcat " ) {
$rootStrItem -> markExpanded ( $idcat );
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
$expandedList = Array ();
$objects = array ();
$rootStrItem -> traverse ( $objects );
$rootStrItem -> getExpandedList ( $expandedList );
$currentuser -> setUserProperty ( " system " , " cat_expandstate " , serialize ( $expandedList ));
2016-10-06 15:57:01 +00:00
# Reset Template
$tpl -> reset ();
$tpl -> set ( 's' , 'SID' , $sess -> id );
$tpl -> set ( 's' , 'AREA' , $area );
$tpl -> set ( 's' , 'FRAME' , $frame );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$_cecIterator = $_cecRegistry -> getIterator ( " Contenido.CategoryList.Columns " );
2017-03-09 13:52:17 +00:00
$listColumns = array ();
if ( $_cecIterator -> count () > 0 ) {
while ( $chainEntry = $_cecIterator -> next ()) {
$tmplistColumns = $chainEntry -> execute ( array ());
if ( is_array ( $tmplistColumns )) {
$listColumns = array_merge ( $listColumns , $tmplistColumns );
}
}
foreach ( $listColumns as $content ) {
// Header for additional columns
$additionalheaders [] = '<td class="header" nowrap="nowrap">' . $content . '</td>' ;
}
$additionalheader = implode ( " " , $additionalheaders );
} else {
$additionalheader = " " ;
}
$tpl -> set ( 's' , 'ADDITIONALHEADERS' , $additionalheader );
// We don't want to show our root
unset ( $objects [ 0 ]);
2016-10-06 15:57:01 +00:00
$selflink = " main.php " ;
$expandlink = $sess -> url ( $selflink . " ?area= $area &frame= $frame &expand=all&syncoptions= $syncoptions " );
$collapselink = $sess -> url ( $selflink . " ?area= $area &frame= $frame &collapse=all&syncoptions= $syncoptions " );
2017-03-09 13:52:17 +00:00
$collapseimg = '<a class="black" href="' .
$collapselink .
'" alt="' . i18n ( " Close all categories " ) .
'" title="' . i18n ( " Close all categories " ) . ' " >
< img src = " images/close_all.gif " >& nbsp ; ' . i18n ( " Close all categories " ) .
'</a>' ;
$expandimg = '<a class="black" href="' .
$expandlink .
'" alt="' . i18n ( " Open all categories " ) .
'" title="' . i18n ( " Open all categories " ) . ' " >
< img src = " images/open_all.gif " >& nbsp ; ' . i18n ( " Open all categories " ) .
'</a>' ;
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'COLLAPSE_ALL' , $collapseimg );
$tpl -> set ( 's' , 'EXPAND_ALL' , $expandimg );
$sMouseover = 'onmouseover="str.over(this)" onmouseout="str.out(this)" onclick="str.click(this)"' ;
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
//Fill inline edit table row
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'SUM_COLUMNS_EDIT' , 14 + count ( $listColumns ));
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'ACTION_EDIT_URL' , $sess -> url ( " main.php?frame= $frame " ));
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'SRC_CANCEL' , $cfg [ " path " ][ " contenido_fullhtml " ] . $cfg [ " path " ][ " images " ] . 'but_cancel.gif' );
$tpl -> set ( 's' , 'SRC_OK' , $cfg [ " path " ][ " contenido_fullhtml " ] . $cfg [ " path " ][ " images " ] . 'but_ok.gif' );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'HREF_CANCEL' , " javascript:handleInlineEdit(0) " );
$tpl -> set ( 's' , 'LABEL_ALIAS_NAME' , i18n ( 'Alias' ));
$tpl -> set ( 's' , 'TEMPLATE_URL' , $sess -> url ( " main.php?area=str_tplcfg&frame= $frame " ));
$message = addslashes ( i18n ( " Do you really want to duplicate the following category:<br><br><b>%s</b><br><br>Notice: The duplicate process can take up to several minutes, depending on how many subitems and articles you've got. " ));
$tpl -> set ( 's' , 'DUPLICATE_MESSAGE' , $message );
$tpl -> set ( 's' , 'DELETE_MESSAGE' , i18n ( " Do you really want to delete the following category:<br><br><b>%s</b> " ));
$bAreaAddNewCategory = false ;
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$aInlineEditData = array ();
$sql = " SELECT
idtplcfg , idtpl
FROM
2017-03-09 13:52:17 +00:00
" . $cfg["tab"] [ " tpl_conf " ];
$db -> query ( $sql );
$aTplconfigs = array ();
while ( $db -> next_record ()) {
2016-10-06 15:57:01 +00:00
$aTplconfigs [ $db -> f ( 'idtplcfg' )] = $db -> f ( 'idtpl' );
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$sql = " SELECT
name , description , idtpl
FROM
2017-03-09 13:52:17 +00:00
" . $cfg["tab"] [ " tpl " ];
2016-10-06 15:57:01 +00:00
$db -> query ( $sql );
2017-03-09 13:52:17 +00:00
$aTemplates = array ();
while ( $db -> next_record ()) {
2016-10-06 15:57:01 +00:00
$aTemplates [ $db -> f ( 'idtpl' )] = array (
2017-03-09 13:52:17 +00:00
'name' => $db -> f ( 'name' ),
'description' => $db -> f ( 'description' )
2016-10-06 15:57:01 +00:00
);
}
2017-03-09 13:52:17 +00:00
foreach ( $objects as $key => $value ) {
2016-10-06 15:57:01 +00:00
// check if there area any permission for this $idcat in the mainarea 6 (=str) and there subareas
$bCheck = false ;
2017-03-09 13:52:17 +00:00
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_newtree " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_newcat " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_makevisible " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_makepublic " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_deletecat " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_moveupcat " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_movedowncat " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_movesubtree " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( $tmp_area , " str_renamecat " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_area_action ( " str_tplcfg " , " str_tplcfg " );
}
if ( ! $bCheck ) {
$bCheck = $perm -> have_perm_item ( $tmp_area , $value -> id );
}
if ( ! $bCheck ) {
$bCheck = $value -> isCustomAttributeSet ( " forcedisplay " );
}
if ( $bCheck ) {
2016-10-06 15:57:01 +00:00
//Insert empty row
2017-03-09 13:52:17 +00:00
if ( $value -> custom [ 'level' ] == 0 && $value -> custom [ 'preid' ] != 0 ) {
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'BGCOLOR' , '#FFFFFF' );
$tpl -> set ( 'd' , 'BGCOLOR_EDIT' , '#F1F1F1' );
$tpl -> set ( 'd' , 'ALIAS' , ' ' );
$tpl -> set ( 'd' , 'INDENT' , '3px' );
$tpl -> set ( 'd' , 'RENAMEBUTTON' , ' ' );
$tpl -> set ( 'd' , 'NEWCATEGORYBUTTON' , ' ' );
$tpl -> set ( 'd' , 'VISIBLEBUTTON' , ' ' );
$tpl -> set ( 'd' , 'PUBLICBUTTON' , ' ' );
$tpl -> set ( 'd' , 'DELETEBUTTON' , ' ' );
$tpl -> set ( 'd' , 'UPBUTTON' , ' ' );
$tpl -> set ( 'd' , 'COLLAPSE_CATEGORY_NAME' , ' ' );
$tpl -> set ( 'd' , 'TPLNAME' , ' ' );
$tpl -> set ( 'd' , 'MOVEBUTTON' , ' ' );
$tpl -> set ( 'd' , 'DOWNBUTTON' , ' ' );
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER' , '' );
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_ALIAS' , '' );
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_CATEGORY' , '' );
$tpl -> set ( 'd' , 'TPLDESC' , '' );
$tpl -> set ( 'd' , 'DUPLICATEBUTTON' , ' ' );
$tpl -> set ( 'd' , 'TEMPLATEBUTTON' , ' ' );
$tpl -> set ( 'd' , 'MOUSEOVER' , '' );
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'SUM_COLUMNS_EDIT' , 14 + count ( $listColumns ));
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'CATID' , '' );
$tpl -> set ( 'd' , 'ACTION_EDIT_URL' , '' );
$tpl -> set ( 'd' , 'INPUT_CATEGORY' , '' );
$tpl -> set ( 'd' , 'LABEL_ALIAS_NAME' , '' );
$tpl -> set ( 'd' , 'HREF_CANCEL' , '' );
$tpl -> set ( 'd' , 'SRC_CANCEL' , '' );
$tpl -> set ( 'd' , 'DIRECTION' , '' );
$tpl -> set ( 'd' , 'SRC_OK' , '' );
$tpl -> set ( 'd' , 'VALUE_ALIAS_NAME' , '' );
$tpl -> set ( 'd' , 'HEIGTH' , 'height:5px;' );
$tpl -> set ( 'd' , 'BORDER_CLASS' , 'str-style-b' );
$additionalColumns = array ();
2017-03-09 13:52:17 +00:00
foreach ( $listColumns as $content ) {
// Content rows
$additionalColumns [] = '<td style="border: 0px; border-bottom:1px; border-right: 1px; border-color: #B3B3B3; border-style: solid;" nowrap="nowrap"> </td>' ;
}
$tpl -> set ( 'd' , 'ADDITIONALCOLUMNS' , implode ( " " , $additionalColumns ));
$tpl -> next ();
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$bgcolor = ( is_int ( $tpl -> dyn_cnt / 2 ) ) ? $cfg [ " color " ][ " table_light " ] : $cfg [ " color " ][ " table_dark " ];
$tpl -> set ( 'd' , 'BGCOLOR' , $bgcolor );
$tpl -> set ( 'd' , 'BGCOLOR_EDIT' , '#F1F1F1' );
$tpl -> set ( 'd' , 'HEIGTH' , 'height:25px' );
$tpl -> set ( 'd' , 'BORDER_CLASS' , 'str-style-c' );
$spaces = " " ;
$tpl -> set ( 'd' , 'INDENT' , ( $value -> custom [ 'level' ] * 16 ) . " px " );
$sCategoryname = $value -> name ;
if ( strlen ( $value -> name ) > 30 ) {
$sCategoryname = capiStrTrimHard ( $sCategoryname , 30 );
2017-03-09 13:52:17 +00:00
}
2016-10-06 15:57:01 +00:00
//$tpl->set('d', 'CATEGORY', $sCategoryname);
if ( strlen ( $value -> name ) > 30 ) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_CATEGORY' , 'onmouseover="Tip(\'' . $value -> name . '\', BALLOON, true, ABOVE, true);"' );
2016-10-06 15:57:01 +00:00
} else {
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_CATEGORY' , '' );
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'COLLAPSE_CATEGORY_NAME' , getExpandCollapseButton ( $value , $sCategoryname ));
if ( $value -> custom [ 'alias' ]) {
2017-03-09 13:52:17 +00:00
$sCategoryalias = $value -> custom [ 'alias' ];
if ( strlen ( $value -> custom [ 'alias' ]) > 30 ) {
$sCategoryalias = capiStrTrimHard ( $sCategoryalias , 30 );
}
$tpl -> set ( 'd' , 'ALIAS' , $sCategoryalias );
if ( strlen ( $value -> custom [ 'alias' ]) > 30 ) {
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_ALIAS' , 'onmouseover="Tip(\'' . $value -> custom [ 'alias' ] . '\', BALLOON, true, ABOVE, true);"' );
} else {
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_ALIAS' , '' );
}
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER_ALIAS' , '' );
$tpl -> set ( 'd' , 'ALIAS' , ' ' );
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
$template = $aTemplates [ $aTplconfigs [ $value -> custom [ 'idtplcfg' ]]][ 'name' ];
$templateDescription = $aTemplates [ $aTplconfigs [ $value -> custom [ 'idtplcfg' ]]][ 'description' ];
2016-10-06 15:57:01 +00:00
$descString = '' ;
2017-03-09 13:52:17 +00:00
if ( $template == " " ) {
$template = '--- ' . i18n ( " none " ) . ' ---' ;
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
// Description for hover effect
2017-03-09 13:52:17 +00:00
$descString = '<b>' . $template . '</b>' ;
2019-07-07 18:14:22 +00:00
if ( strlen ( $templateDescription ) > 0 ) {
2017-03-09 13:52:17 +00:00
$descString .= '<br>' . $templateDescription ;
}
2016-10-06 15:57:01 +00:00
$sTemplatename = $template ;
if ( strlen ( $template ) > 20 ) {
$sTemplatename = capiStrTrimHard ( $sTemplatename , 20 );
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'TPLNAME' , $sTemplatename );
$tpl -> set ( 'd' , 'TPLDESC' , $descString );
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_renamecat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_renamecat " , $value -> id )) {
2016-10-06 15:57:01 +00:00
$bPermRename = 1 ;
2017-03-09 13:52:17 +00:00
} else {
2016-10-06 15:57:01 +00:00
$bPermRename = 0 ;
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( " str_tplcfg " , " str_tplcfg " ) || $perm -> have_perm_area_action_item ( " str_tplcfg " , " str_tplcfg " , $value -> id )) {
2016-10-06 15:57:01 +00:00
$bPermTplcfg = 1 ;
} else {
$bPermTplcfg = 0 ;
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$aRecord = array ();
$sCatName = $value -> name ;
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$aRecord [ 'catn' ] = str_replace ( '\'' , '\\\'' , $sCatName );
$sAlias = $value -> custom [ 'alias' ];
$aRecord [ 'alias' ] = str_replace ( '\'' , '\\\'' , $sAlias );
$aRecord [ 'idtplcfg' ] = $value -> custom [ 'idtplcfg' ];
$aRecord [ 'pName' ] = $bPermRename ;
$aRecord [ 'pTplcfg' ] = $bPermTplcfg ;
$aInlineEditData [ $value -> id ] = $aRecord ;
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'RENAMEBUTTON' , " <a class= \" action \" href= \" javascript:handleInlineEdit( " . $value -> id . " ); \" ><img src= \" " . $cfg [ " path " ][ " images " ] . " but_todo.gif \" id= \" cat_ " . $value -> id . " _image \" ></a> " );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'CATID' , $value -> id );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
if ( strlen ( $template ) > 20 ) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER' , 'onmouseover="Tip(\'' . $descString . '\', BALLOON, true, ABOVE, true);"' );
2016-10-06 15:57:01 +00:00
} else {
$tpl -> set ( 'd' , 'SHOW_MOUSEOVER' , '' );
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'MOUSEOVER' , $sMouseover );
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_newcat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_newcat " , $value -> id )) {
$bAreaAddNewCategory = true ;
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_makevisible " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_makevisible " , $value -> id )) {
2016-10-06 15:57:01 +00:00
if ( $value -> custom [ 'visible' ] == 1 ) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'VISIBLEBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_makevisible&frame= $frame &idcat= " . $value -> id . " &visible= " . $value -> custom [ 'visible' ]) . " #clickedhere \" ><img src= \" images/online.gif \" ></a> " );
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'VISIBLEBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_makevisible&frame= $frame &idcat= " . $value -> id . " &visible= " . $value -> custom [ 'visible' ]) . " #clickedhere \" ><img src= \" images/offline.gif \" ></a> " );
2016-10-06 15:57:01 +00:00
}
} else {
$tpl -> set ( 'd' , 'VISIBLEBUTTON' , ' ' );
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_makepublic " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_makepublic " , $value -> id )) {
2016-10-06 15:57:01 +00:00
if ( $value -> custom [ 'public' ] == 1 ) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'PUBLICBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_makepublic&frame= $frame &idcat= " . $value -> id . " &public= " . $value -> custom [ 'public' ]) . " #clickedhere \" ><img src= \" images/folder_delock.gif \" ></a> " );
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'PUBLICBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_makepublic&frame= $frame &idcat= " . $value -> id . " &public= " . $value -> custom [ 'public' ]) . " #clickedhere \" ><img src= \" images/folder_lock.gif \" ></a> " );
2016-10-06 15:57:01 +00:00
}
} else {
$tpl -> set ( 'd' , 'PUBLICBUTTON' , ' ' );
}
$hasChildren = strNextDeeper ( $value -> id );
$hasArticles = strHasArticles ( $value -> id );
2017-03-09 13:52:17 +00:00
if (( $hasChildren == 0 ) && ( $hasArticles == false ) && ( $perm -> have_perm_area_action ( $tmp_area , " str_deletecat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_deletecat " , $value -> id ))) {
2016-10-06 15:57:01 +00:00
2017-03-09 13:52:17 +00:00
$delete = '<a href="javascript://" onclick="confDel(' . $value -> id . ',' . $value -> custom [ 'parentid' ] . ', \'' . clHtmlSpecialChars ( $value -> name ) . '\')">' . " <img src= \" " . $cfg [ " path " ][ " images " ] . " delete.gif \" ></a> " ;
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'DELETEBUTTON' , $delete );
} else {
$message = i18n ( " No permission " );
2017-03-09 13:52:17 +00:00
if ( $hasChildren ) {
2016-10-06 15:57:01 +00:00
$button = 'delete_inact_h.gif' ;
}
2017-03-09 13:52:17 +00:00
if ( $hasArticles ) {
2016-10-06 15:57:01 +00:00
$button = 'delete_inact_g.gif' ;
}
2017-03-09 13:52:17 +00:00
if ( $hasChildren && $hasArticles ) {
2016-10-06 15:57:01 +00:00
$button = 'delete_inact.gif' ;
}
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'DELETEBUTTON' , '<img src="' . $cfg [ " path " ][ " images " ] . $button . '">' );
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_moveupcat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_moveupcat " , $value -> id )) {
2016-10-06 15:57:01 +00:00
$rand = rand ();
2017-03-09 13:52:17 +00:00
if ( $value -> custom [ 'parentid' ] == 0 && $value -> custom [ 'preid' ] == 0 ) {
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'UPBUTTON' , " <img src= \" images/folder_moveup_inact.gif \" > " );
} else {
2017-03-09 13:52:17 +00:00
if ( $value -> custom [ 'preid' ] != 0 ) {
$tpl -> set ( 'd' , 'UPBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_moveupcat&frame= $frame &idcat= " . $value -> id . " &rand= $rand " ) . " #clickedhere \" ><img src= \" images/folder_moveup.gif \" ></a> " );
} else {
$tpl -> set ( 'd' , 'UPBUTTON' , " <img src= \" images/folder_moveup_inact.gif \" > " );
}
}
2016-10-06 15:57:01 +00:00
} else {
$tpl -> set ( 'd' , 'UPBUTTON' , " <img src= \" images/folder_moveup_inact.gif \" > " );
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_movedowncat " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_movedowncat " , $value -> id )) {
2016-10-06 15:57:01 +00:00
$rand = rand ();
2017-03-09 13:52:17 +00:00
if ( $value -> custom [ 'postid' ] == 0 ) {
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'DOWNBUTTON' , " <img src= \" images/folder_movedown_inact.gif \" > " );
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'DOWNBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_movedowncat&frame= $frame &idcat= " . $value -> id . " &rand= $rand " ) . " #clickedhere \" ><img src= \" images/folder_movedown.gif \" ></a> " );
2016-10-06 15:57:01 +00:00
}
} else {
$tpl -> set ( 'd' , 'DOWNBUTTON' , " <img src= \" images/folder_movedown_inact.gif \" > " );
}
2017-03-09 13:52:17 +00:00
if (( $action === " str_movesubtree " ) && ( ! isset ( $parentid_new ))) {
if ( $perm -> have_perm_area_action ( $tmp_area , " str_movesubtree " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_movesubtree " , $value -> id )) {
if ( $value -> id == $idcat ) {
$tpl -> set ( 'd' , 'MOVEBUTTON' , " <a name=#movesubtreehere><a href= \" " . $sess -> url ( " main.php?area= $area &action=str_movesubtree&frame= $frame &idcat= $idcat &parentid_new=0 " ) . " \" ><img src= \" " . $cfg [ " path " ][ " images " ] . " but_move_subtree_main.gif \" ></a> " );
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$allowed = strMoveCatTargetallowed ( $value -> id , $idcat );
if ( $allowed == 1 ) {
$tpl -> set ( 'd' , 'MOVEBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_movesubtree&frame= $frame &idcat= $idcat &parentid_new= " . $value -> id ) . " \" ><img src= \" " . $cfg [ " path " ][ " images " ] . " but_move_subtree_target.gif \" ></a> " );
} else {
$tpl -> set ( 'd' , 'MOVEBUTTON' , ' ' );
}
2016-10-06 15:57:01 +00:00
}
} else {
$tpl -> set ( 'd' , 'MOVEBUTTON' , ' ' );
}
} else {
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_movesubtree " ) || $perm -> have_perm_area_action_item ( $tmp_area , " str_movesubtree " , $value -> id )) {
$tpl -> set ( 'd' , 'MOVEBUTTON' , " <a href= \" " . $sess -> url ( " main.php?area= $area &action=str_movesubtree&frame= $frame &idcat= " . $value -> id ) . " #movesubtreehere \" ><img src= \" " . $cfg [ " path " ][ " images " ] . " but_move_subtree.gif \" ></a> " );
} else {
2016-10-06 15:57:01 +00:00
$tpl -> set ( 'd' , 'MOVEBUTTON' , ' ' );
}
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( " str " , " str_duplicate " ) || $perm -> have_perm_area_action_item ( " str " , " str_duplicate " , $value -> id )) {
$duplicate = '<a href="javascript://" onclick="confDupl(' . $value -> id . ',' . $value -> custom [ 'parentid' ] . ', \'' . clHtmlSpecialChars ( $value -> name ) . '\')">' . " <img src= \" " . $cfg [ " path " ][ " images " ] . " folder_duplicate.gif \" ></a> " ;
$tpl -> set ( 'd' , 'DUPLICATEBUTTON' , $duplicate );
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 'd' , 'DUPLICATEBUTTON' , ' ' );
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
// DIRECTION
2017-03-09 13:52:17 +00:00
cInclude ( 'includes' , 'functions.lang.php' );
$tpl -> set ( 'd' , 'DIRECTION' , 'dir="' . langGetTextDirection ( $lang , $oDirectionDb ) . '"' );
2016-10-06 15:57:01 +00:00
$columns = array ();
2017-03-09 13:52:17 +00:00
foreach ( $listColumns as $key => $content ) {
$columnInfo = array ();
$_cecIterator = $_cecRegistry -> getIterator ( " Contenido.CategoryList.RenderColumn " );
$columnContents = array ();
if ( $_cecIterator -> count () > 0 ) {
while ( $chainEntry = $_cecIterator -> next ()) {
$columnContents [] = $chainEntry -> execute ( $value -> id , $key );
}
} else {
$columnContents [] = '' ;
}
$columns [] = '<td class="str-style-c">' . implode ( " " , $columnContents ) . '</td>' ;
}
$tpl -> set ( 'd' , 'ADDITIONALCOLUMNS' , implode ( " " , $columns ));
2016-10-06 15:57:01 +00:00
$tpl -> next ();
} //end if -> perm
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$jsDataArray = " " ;
foreach ( $aInlineEditData as $iIdCat => $aData ) {
$aTmp = array ();
foreach ( $aData as $aKey => $aValue ) {
2017-03-09 13:52:17 +00:00
array_push ( $aTmp , $aKey . " ':' " . $aValue );
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
$jsDataArray .= " tmpObject = new Object();
tmpObject = { '" . implode("' , '", $aTmp) . "' };
2016-10-06 15:57:01 +00:00
dataArray [ $iIdCat ] = tmpObject ;
2017-03-09 13:52:17 +00:00
" ;
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'JS_DATA' , $jsDataArray );
2017-03-09 13:52:17 +00:00
$string = markSubMenuItem ( 0 , true );
2016-10-06 15:57:01 +00:00
//Set DHTML generic Values
$sImagepath = $cfg [ " path " ][ " images " ];
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'SUM_COLUMNS' , 14 + count ( $listColumns ));
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'HREF_ACTION' , $sess -> url ( " main.php?frame= $frame " ));
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'CON_IMAGES' , $cfg [ " path " ][ " contenido_fullhtml " ] . $cfg [ " path " ][ " images " ]);
2016-10-06 15:57:01 +00:00
//Generate input fields for category new layer and category edit layer
2017-03-09 13:52:17 +00:00
$oSession = new cHTMLHiddenField ( $sess -> name , $sess -> id );
$oActionEdit = new cHTMLHiddenField ( 'action' , 'str_renamecat' );
$oIdcat = new cHTMLHiddenField ( 'idcat' );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'INPUT_SESSION' , $oSession -> render ());
$tpl -> set ( 's' , 'INPUT_ACTION_EDIT' , $oActionEdit -> render ());
$tpl -> set ( 's' , 'INPUT_IDCAT' , $oIdcat -> render ());
2017-03-09 13:52:17 +00:00
$oVisible = new cHTMLHiddenField ( 'visible' , 0 , 'visible_input' );
$oPublic = new cHTMLHiddenField ( 'public' , 1 , 'public_input' );
$oTemplate = new cHTMLHiddenField ( 'idtplcfg' , 0 , 'idtplcfg_input' );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'INPUT_VISIBLE' , $oVisible -> render ());
$tpl -> set ( 's' , 'INPUT_PUBLIC' , $oPublic -> render ());
$tpl -> set ( 's' , 'INPUT_TEMPLATE' , $oTemplate -> render ());
2017-03-09 13:52:17 +00:00
$oCatName = new cHTMLTextbox ( 'categoryname' , '' , '' , '' , 'cat_categoryname' );
2016-10-06 15:57:01 +00:00
$oCatName -> setStyle ( 'width:150px; vertical-align:middle;' );
$tpl -> set ( 's' , 'INPUT_CATNAME_NEW' , $oCatName -> render ());
2017-03-09 13:52:17 +00:00
$oAlias = new cHTMLTextbox ( 'categoryalias' );
2016-10-06 15:57:01 +00:00
$oAlias -> setStyle ( 'width:150px; vertical-align:middle;' );
$tpl -> set ( 's' , 'INPUT_ALIAS_NEW' , $oAlias -> render ());
2017-03-09 13:52:17 +00:00
$oNewCatName = new cHTMLTextbox ( 'newcategoryname' );
2016-10-06 15:57:01 +00:00
$oNewCatName -> setStyle ( 'width:150px; vertical-align:middle;' );
$tpl -> set ( 's' , 'INPUT_CATNAME_EDIT' , $oNewCatName -> render ());
2017-03-09 13:52:17 +00:00
$oNewAlias = new cHTMLTextbox ( 'newcategoryalias' );
2016-10-06 15:57:01 +00:00
$oNewAlias -> setStyle ( 'width:150px; vertical-align:middle;' );
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'INPUT_ALIAS_EDIT' , $oNewAlias -> render ());
2016-10-06 15:57:01 +00:00
$sCategorySelect = buildCategorySelectRights ( 'idcat' , '' );
# Show Layerbutton for adding new Cateogries and set options according to Permisssions
2017-03-09 13:52:17 +00:00
if (( $perm -> have_perm_area_action ( $tmp_area , " str_newtree " ) ||
$perm -> have_perm_area_action ( $tmp_area , " str_newcat " ) ||
$bAreaAddNewCategory ) && ( int ) $client > 0 && ( int ) $lang > 0 ) {
$tpl -> set ( 's' , 'NEWCAT' , $string . " <a class= \" black \" id= \" new_tree_button \" href= \" javascript:showNewForm(); \" ><img src= \" images/folder_new.gif \" > " . i18n ( 'Create new category' ) . " </a> " );
if ( $perm -> have_perm_area_action ( $tmp_area , " str_newtree " )) {
if ( $perm -> have_perm_area_action ( $tmp_area , " str_newcat " ) || $bAreaAddNewCategory ) {
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'PERMISSION_NEWTREE' , '' );
2017-03-09 13:52:17 +00:00
$oActionNew = new cHTMLHiddenField ( 'action' , 'str_newcat' , 'cat_new_action' );
2016-10-06 15:57:01 +00:00
} else {
$tpl -> set ( 's' , 'PERMISSION_NEWTREE' , 'disabled checked' );
2017-03-09 13:52:17 +00:00
$oActionNew = new cHTMLHiddenField ( 'action' , 'str_newcat' , 'str_newtree' );
2016-10-06 15:57:01 +00:00
}
$tpl -> set ( 's' , 'INPUT_ACTION_NEW' , $oActionNew -> render ());
$tpl -> set ( 's' , 'PERMISSION_NEWTREE_DISPLAY' , 'block' );
2017-03-09 13:52:17 +00:00
} else {
$oActionNew = new cHTMLHiddenField ( 'action' , 'str_newcat' , 'cat_new_action' );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'PERMISSION_NEWTREE' , 'disabled' );
$tpl -> set ( 's' , 'PERMISSION_NEWTREE_DISPLAY' , 'none' );
$tpl -> set ( 's' , 'NEW_ACTION' , 'str_newcat' );
$tpl -> set ( 's' , 'INPUT_ACTION_NEW' , $oActionNew -> render ());
}
2017-03-09 13:52:17 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_newcat " ) || $bAreaAddNewCategory ) {
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'CATEGORY_SELECT' , $sCategorySelect );
$tpl -> set ( 's' , 'PERMISSION_NEWCAT_DISPLAY' , 'block' );
} else {
$tpl -> set ( 's' , 'CATEGORY_SELECT' , '' );
$tpl -> set ( 's' , 'PERMISSION_NEWCAT_DISPLAY' , 'none' );
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
if ( $perm -> have_perm_area_action ( " str_tplcfg " , " str_tplcfg " )) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'TEMPLATE_BUTTON_NEW' , '<a href="javascript:showTemplateSelect();"><img src="' . $sImagepath . 'template_properties.gif" id="cat_category_select_button" title="' . i18n ( 'Configure category' ) . '" alt="' . i18n ( 'Configure category' ) . '"></a>' );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'SELECT_TEMPLATE' , getTemplateSelect ());
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'TEMPLATE_BUTTON_NEW' , '<img src="' . $sImagepath . 'template_properties_off.gif" id="cat_category_select_button" title="' . i18n ( 'Configure category' ) . '" alt="' . i18n ( 'Configure category' ) . '">' );
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'SELECT_TEMPLATE' , '' );
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_makevisible " )) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'MAKEVISIBLE_BUTTON_NEW' , '<a href="javascript:changeVisible();"><img src="' . $sImagepath . 'offline.gif" id="visible_image" title="' . i18n ( 'Make online' ) . '" alt="' . i18n ( 'Make online' ) . '"></a>' );
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'MAKEVISIBLE_BUTTON_NEW' , '<img src="' . $sImagepath . 'offline_off.gif" id="visible_image" title="' . i18n ( 'Make online' ) . '" alt="' . i18n ( 'Make online' ) . '">' );
2016-10-06 15:57:01 +00:00
}
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
if ( $perm -> have_perm_area_action ( $tmp_area , " str_makepublic " )) {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'MAKEPUBLIC_BUTTON_NEW' , '<a href="javascript:changePublic();"><img src="' . $sImagepath . 'folder_delock.gif" id="public_image" title="' . i18n ( 'Protect category' ) . '" alt="' . i18n ( 'Protect category' ) . '"></a>' );
2016-10-06 15:57:01 +00:00
} else {
2017-03-09 13:52:17 +00:00
$tpl -> set ( 's' , 'MAKEPUBLIC_BUTTON_NEW' , '<img src="' . $sImagepath . 'folder_delocked.gif" id="public_image" title="' . i18n ( 'Protect category' ) . '" alt="' . i18n ( 'Protect category' ) . '">' );
2016-10-06 15:57:01 +00:00
}
} else {
$tpl -> set ( 's' , 'NEWCAT' , $string );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'PERMISSION_NEWTREE' , 'disabled' );
$tpl -> set ( 's' , 'PERMISSION_NEWTREE_DISPLAY' , 'none' );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'CATEGORY_SELECT' , '' );
$tpl -> set ( 's' , 'PERMISSION_NEWCAT_DISPLAY' , 'none' );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'TEMPLATE_BUTTON_NEW' , '' );
$tpl -> set ( 's' , 'MAKEVISIBLE_BUTTON_NEW' , '' );
$tpl -> set ( 's' , 'MAKEPUBLIC_BUTTON_NEW' , '' );
2017-03-09 13:52:17 +00:00
2016-10-06 15:57:01 +00:00
$tpl -> set ( 's' , 'NEW_ACTION' , 'str_newcat' );
$tpl -> set ( 's' , 'SELECT_TEMPLATE' , '' );
}
# Generate template
2017-03-09 13:52:17 +00:00
$clang = new cApiLanguage ( $lang );
if ( $movesubtreeidcat != 0 ) {
if ( strlen ( $sMoveSubtreeCatName ) > 30 ) {
$sLimiter = " ... " ;
} else {
$sLimiter = " " ;
}
$sButtonDesc = sprintf ( i18n ( 'Cancel moving %s' ), '"' . substr ( $sMoveSubtreeCatName , 0 , 30 ) . $sLimiter . '"' );
$tpl -> set ( 's' , 'CANCEL_MOVE_TREE' , '<a class="black" id="cancel_move_tree_button" href="javascript:cancelMoveTree(\'' . $movesubtreeidcat . '\');"><img src="images/but_cancel.gif" alt="' . $sButtonDesc . '" /> ' . $sButtonDesc . '</a>' );
} else {
$tpl -> set ( 's' , 'CANCEL_MOVE_TREE' , '' );
}
$tpl -> setEncoding ( $clang -> get ( " encoding " ));
2016-10-06 15:57:01 +00:00
$tpl -> generate ( $cfg [ 'path' ][ 'templates' ] . $cfg [ 'templates' ][ 'str_overview' ]);
}
?>