"Fossies" - the Fresh Open Source Software Archive

Member "impresscms-1.4.2/htdocs/include/cp_functions.php" (24 Dec 2020, 28328 Bytes) of package /linux/www/impresscms-1.4.2.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cp_functions.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 1.4.2_rc_vs_1.4.2 or 1.4.1_vs_1.4.2.

    1 <?php
    2 // $Id: cp_functions.php 12313 2013-09-15 21:14:35Z skenow $
    3 //  ------------------------------------------------------------------------ //
    4 //                XOOPS - PHP Content Management System                      //
    5 //                    Copyright (c) 2000 XOOPS.org                           //
    6 //                       <http://www.xoops.org/>                             //
    7 //  ------------------------------------------------------------------------ //
    8 //  This program is free software; you can redistribute it and/or modify     //
    9 //  it under the terms of the GNU General Public License as published by     //
   10 //  the Free Software Foundation; either version 2 of the License, or        //
   11 //  (at your option) any later version.                                      //
   12 //                                                                           //
   13 //  You may not change or alter any portion of this comment or credits       //
   14 //  of supporting developers from this source code or any supporting         //
   15 //  source code which is considered copyrighted (c) material of the          //
   16 //  original comment or credit authors.                                      //
   17 //                                                                           //
   18 //  This program is distributed in the hope that it will be useful,          //
   19 //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
   20 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
   21 //  GNU General Public License for more details.                             //
   22 //                                                                           //
   23 //  You should have received a copy of the GNU General Public License        //
   24 //  along with this program; if not, write to the Free Software              //
   25 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
   26 //  ------------------------------------------------------------------------ //
   27 
   28 /**
   29  * All control panel functions and forming goes from here.
   30  * Be careful while editing this file!
   31  *
   32  * @copyright   The XOOPS Project <http://www.xoops.org/>
   33  * @copyright   The ImpressCMS Project <http://www.impresscms.org/>
   34  *
   35  * @license     http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
   36  *
   37  * @package     core
   38  * @since       XOOPS
   39  * @version     $Id: cp_functions.php 12313 2013-09-15 21:14:35Z skenow $
   40  *
   41  * @author      The XOOPS Project <http://www.xoops.org>
   42  * @author      Sina Asghari (aka stranger) <pesian_stranger@users.sourceforge.net>
   43  * @author      Gustavo Pilla (aka nekro) <nekro@impresscms.org>
   44  */
   45 
   46 /** Be sure this is accessed correctly */
   47 defined('ICMS_ROOT_PATH') or die('ImpressCMS root path not defined');
   48 /** Creates constant indicating this file has been loaded */
   49 define ('XOOPS_CPFUNC_LOADED', 1);
   50 /** Load the template class */
   51 
   52 /**
   53  * Function icms_cp_header
   54  *
   55  * @since ImpressCMS 1.2
   56  * @version $Id: cp_functions.php 12313 2013-09-15 21:14:35Z skenow $
   57  *
   58  * @author rowd (from the XOOPS Community)
   59  * @author nekro (aka Gustavo Pilla)<nekro@impresscms.org>
   60  */
   61 function icms_cp_header(){
   62     global $icmsConfig, $icmsConfigPlugins, $icmsConfigPersona, $icmsModule,
   63         $xoopsModule, $xoopsTpl, $xoopsOption, $icmsTheme, $xoTheme,
   64         $icmsConfigMultilang, $icmsAdminTpl;
   65 
   66     icms::$logger->stopTime('Module init');
   67     icms::$logger->startTime('ImpressCMS CP Output Init');
   68 
   69     if (!headers_sent()) {
   70         header('Content-Type:text/html; charset='._CHARSET);
   71         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
   72         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   73         header('Cache-Control: no-store, no-cache, must-revalidate');
   74         header("Cache-Control: post-check=0, pre-check=0", false);
   75         header("Pragma: no-cache");
   76         header("X-Frame-Options: SAMEORIGIN");
   77     }
   78 
   79     $icmsAdminTpl = new icms_view_Tpl();
   80 
   81     $icmsAdminTpl->assign('xoops_url', ICMS_URL);
   82     $icmsAdminTpl->assign('icms_sitename', $icmsConfig['sitename']);
   83 
   84     if ( @$xoopsOption['template_main'] ) {
   85         if ( false === strpos( $xoopsOption['template_main'], ':' ) ) {
   86             $xoopsOption['template_main'] = 'db:' . $xoopsOption['template_main'];
   87         }
   88     }
   89 
   90     $xoopsThemeFactory = new icms_view_theme_Factory();
   91     $xoopsThemeFactory->allowedThemes = $icmsConfig['theme_set_allowed'];
   92 
   93     // The next 2 lines are for compatibility only... to implement the admin theme ;)
   94     // TODO: Remove all this after a few versions!!
   95     if (isset($icmsConfig['theme_admin_set']))
   96         $xoopsThemeFactory->defaultTheme = $icmsConfig['theme_admin_set'];
   97 
   98     $icmsTheme = $xoTheme =& $xoopsThemeFactory->createInstance(array(
   99         'contentTemplate'   => @$xoopsOption['template_main'],
  100         'canvasTemplate'    => 'theme' . (( file_exists(ICMS_THEME_PATH . '/' . $icmsConfig['theme_admin_set'] . '/theme_admin.html')
  101             || file_exists(ICMS_MODULES_PATH . '/system/themes/' . $icmsConfig['theme_admin_set'] . '/theme_admin.html') ) ?'_admin':'') . '.html',
  102         'plugins'           => array('icms_view_PageBuilder'),
  103         'folderName'        => $icmsConfig['theme_admin_set']
  104     ));
  105     $icmsAdminTpl = $xoTheme->template;
  106 
  107     // ################# Preload Trigger startOutputInit ##############
  108     icms::$preload->triggerEvent('adminHeader');
  109 
  110     $xoTheme->addScript(ICMS_URL . '/include/xoops.js', array('type' => 'text/javascript'));
  111     $xoTheme->addScript('' , array( 'type' => 'text/javascript' ) , 'startList = function() {
  112                         if (document.all&&document.getElementById) {
  113                             navRoot = document.getElementById("nav");
  114                             for (i=0; i<navRoot.childNodes.length; i++) {
  115                                 node = navRoot.childNodes[i];
  116                                 if (node.nodeName=="LI") {
  117                                     node.onmouseover=function() {
  118                                         this.className+=" over";
  119                                     }
  120                                     node.onmouseout=function() {
  121                                         this.className=this.className.replace(" over", "");
  122                                     }
  123                                 }
  124                             }
  125                         }
  126                     }
  127                     window.onload=startList;');
  128     /** @todo   Remove icms.css in 2.0 */
  129     icms_core_Debug::setDeprecated("Elements from icms.css need to be moved to your theme", sprintf(_CORE_REMOVE_IN_VERSION, '2.0'));
  130     $xoTheme->addStylesheet(ICMS_URL . '/icms' . (( defined('_ADM_USE_RTL') && _ADM_USE_RTL ) ? '_rtl' : '') . '.css', array('media' => 'screen'));
  131 
  132     // JQuery UI Dialog
  133     $xoTheme->addScript(ICMS_URL . '/libraries/jquery/jquery.js', array( 'type' => 'text/javascript'));
  134 if (! empty( $_SESSION['redirect_message'] )) {
  135     $xoTheme->addScript(ICMS_URL.'/libraries/jquery/jgrowl.js', array('type' => 'text/javascript'));
  136     $xoTheme->addStylesheet(ICMS_URL.'/libraries/jquery/jgrowl'.(( defined('_ADM_USE_RTL') && _ADM_USE_RTL )?'_rtl':'').'.css', array('media' => 'screen'));
  137     $xoTheme->addScript('', array('type' => 'text/javascript'), '
  138     if (!window.console || !console.firebug) {
  139         var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
  140         window.console = {};
  141 
  142         for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
  143     }
  144 
  145     (function($) {
  146         $(document).ready(function() {
  147             $.jGrowl("'.$_SESSION['redirect_message'].'", {  life:5000 , position: "center", speed: "slow" });
  148         });
  149     })(jQuery);
  150     ');
  151     unset( $_SESSION['redirect_message'] ) ;
  152 }
  153     $xoTheme->addScript(ICMS_URL . '/libraries/jquery/ui/ui.min.js', array( 'type' => 'text/javascript'));
  154     $xoTheme->addScript(ICMS_URL . '/libraries/jquery/helptip.js', array( 'type' => 'text/javascript'));
  155     $xoTheme->addStylesheet(ICMS_URL . '/libraries/jquery/ui/css/ui-smoothness/ui.css', array('media' => 'screen'));
  156     $xoTheme->addStylesheet(ICMS_LIBRARIES_URL.'/jquery/colorbox/colorbox.css');
  157     $xoTheme->addScript(ICMS_LIBRARIES_URL.'/jquery/colorbox/jquery.colorbox-min.js');
  158 
  159     /*  $jscript = '';
  160      if(class_exists('icms_form_elements_Dhtmltextarea')){
  161         foreach ($icmsConfigPlugins['sanitizer_plugins'] as $key) {
  162         if( empty( $key ) )
  163         continue;
  164         if(file_exists(ICMS_ROOT_PATH.'/plugins/textsanitizer/'.$key.'/'.$key.'.js')){
  165         $xoTheme->addScript(ICMS_URL.'/plugins/textsanitizer/'.$key.'/'.$key.'.js', array('type' => 'text/javascript'));
  166         }else{
  167         $extension = include_once ICMS_ROOT_PATH.'/plugins/textsanitizer/'.$key.'/'.$key.'.php';
  168         $func = 'render_'.$key;
  169         if ( function_exists($func) ) {
  170         @list($encode, $jscript) = $func($ele_name);
  171         if (!empty($jscript)) {
  172         if(!file_exists(ICMS_ROOT_PATH.'/'.$jscript)){
  173         $xoTheme->addScript('', array('type' => 'text/javascript'), $jscript);
  174         }else{
  175         $xoTheme->addScript($jscript, array('type' => 'text/javascript'));
  176         }
  177         }
  178         }
  179         }
  180         }
  181         }
  182         */
  183     $style_info = '';
  184     if (!empty($icmsConfigPlugins['sanitizer_plugins'])) {
  185         foreach ($icmsConfigPlugins['sanitizer_plugins'] as $key) {
  186             if ( empty($key) ) continue;
  187             if (file_exists(ICMS_ROOT_PATH . '/plugins/textsanitizer/' . $key . '/' . $key . '.css')) {
  188                 $xoTheme->addStylesheet(
  189                     ICMS_URL . '/plugins/textsanitizer/' . $key . '/' . $key . '.css',
  190                     array('media' => 'screen')
  191                 );
  192             } else {
  193                 $extension = include_once ICMS_ROOT_PATH . '/plugins/textsanitizer/' . $key . '/' . $key . '.php';
  194                 $func = 'style_' . $key;
  195                 if ( function_exists($func) ) {
  196                     $style_info = $func();
  197                     if (!empty($style_info)) {
  198                         if (!file_exists(ICMS_ROOT_PATH . '/' . $style_info)) {
  199                             $xoTheme->addStylesheet('', array('media' => 'screen'), $style_info);
  200                         } else {
  201                             $xoTheme->addStylesheet($style_info, array('media' => 'screen'));
  202                         }
  203                     }
  204                 }
  205             }
  206         }
  207     }
  208 
  209     /**
  210      * Loading admin dropdown menus
  211      */
  212     if (! file_exists ( ICMS_CACHE_PATH . '/adminmenu_' . $icmsConfig ['language'] . '.php' )) {
  213         xoops_module_write_admin_menu(impresscms_get_adminmenu());
  214     }
  215 
  216     $file = file_get_contents(ICMS_CACHE_PATH . "/adminmenu_" . $icmsConfig ['language'] . ".php");
  217     $admin_menu = eval('return ' . $file . ';');
  218 
  219     $moduleperm_handler = icms::handler('icms_member_groupperm');
  220     $module_handler = icms::handler('icms_module');
  221     foreach ( $admin_menu as $k => $navitem ) {
  222          //Getting array of allowed modules to use in admin home
  223         if ($navitem ['id'] == 'modules') {
  224             $perm_itens = array();
  225             foreach ( $navitem ['menu'] as $item ) {
  226                 $module = $module_handler->getByDirname($item['dir']);
  227                 $admin_perm = $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), icms::$user->getGroups());
  228                 if ($admin_perm) {
  229                     if ($item['dir'] != 'system') {
  230                         $perm_itens[] = $item;
  231                     }
  232                 }
  233             }
  234             $navitem['menu'] = $mods = $perm_itens;
  235         }
  236         //end
  237         if ($navitem['id'] == 'opsystem') {
  238             $groups = icms::$user->getGroups();
  239             $all_ok = false;
  240             if (! in_array(ICMS_GROUP_ADMIN, $groups)) {
  241                 $sysperm_handler = icms::handler('icms_member_groupperm');
  242                 $ok_syscats =& $sysperm_handler->getItemIds('system_admin', $groups);
  243             } else {
  244                 $all_ok = true;
  245             }
  246             $perm_itens = array();
  247 
  248             /**
  249              * Allow easely change the order of system dropdown menu.
  250              * $adminmenuorder = 1; Alphabetically order;
  251              * $adminmenuorder = 0; Indice key order;
  252              * To change the order when using Indice key order just change the order of the array in the file modules/system/menu.php and after update the system module
  253              *
  254              * @todo: Create a preference option to set this value and improve the way to change the order.
  255              */
  256             $adminmenuorder = 1;
  257             $adminsubmenuorder = 1;
  258             $adminsubsubmenuorder = 1;
  259             if ($adminmenuorder == 1) {
  260                 foreach ( $navitem ['menu'] as $k => $sortarray ) {
  261                     $column[] = $sortarray['title'];
  262                     if (isset($sortarray['subs']) && count($sortarray['subs']) > 0 && $adminsubmenuorder) {
  263                         asort($navitem['menu'][$k]['subs']);
  264                     }
  265                     if (isset($sortarray['subs']) && count($sortarray['subs']) > 0) {
  266                         foreach ($sortarray['subs'] as $k2 => $sortarray2) {
  267                             if (isset($sortarray2['subs']) && count($sortarray2['subs']) > 0 && $adminsubsubmenuorder) {
  268                                 asort($navitem['menu'][$k]['subs'][$k2]['subs']); //Sorting submenus of preferences
  269                             }
  270                         }
  271                     }
  272                 }
  273                 //sort arrays after loop
  274                 array_multisort($column, SORT_ASC, $navitem['menu']);
  275             }
  276             foreach ( $navitem['menu'] as $item ) {
  277                 foreach ($item['subs'] as $key => $subitem) {
  278                     if ($all_ok == false && !in_array($subitem['id'], $ok_syscats)) {
  279                         // remove the subitem
  280                         unset($item['subs'][$key]);
  281                     }
  282                 }
  283                 // only add the item (first layer: groups) if it has subitems
  284                 if (count($item['subs']) > 0) $perm_itens[] = $item;
  285             }
  286             //Getting array of allowed system prefs
  287             $navitem['menu'] = $sysprefs = $perm_itens;
  288         }
  289         $icmsAdminTpl->append('navitems', $navitem);
  290     }
  291 
  292     if (count($sysprefs) > 0) {
  293         $icmsAdminTpl->assign('systemadm', 1);
  294     } else {
  295         $icmsAdminTpl->assign('systemadm', 0);
  296     }
  297     if (count($mods) > 0) {
  298         $icmsAdminTpl->assign('modulesadm', 1);
  299     } else {
  300         $icmsAdminTpl->assign('modulesadm', 0);
  301     }
  302 
  303     /**
  304      * Loading options of the current module.
  305      */
  306     if ($icmsModule) {
  307         if ($icmsModule->getVar('dirname') == 'system') {
  308             if (isset($sysprefs) && count($sysprefs) > 0) {
  309                 // remove the grouping for the system module preferences (first layer)
  310                 $sysprefs_tmp = array();
  311                 foreach ($sysprefs as $pref) {
  312                     $sysprefs_tmp = array_merge($sysprefs_tmp, $pref['subs']);
  313                 }
  314                 $sysprefs = $sysprefs_tmp;
  315                 unset($sysprefs_tmp);
  316                 for ($i = count($sysprefs) - 1; $i >= 0; $i = $i - 1) {
  317                     if (isset($sysprefs [$i])) {
  318                         $reversed_sysprefs[] = $sysprefs[$i];
  319                     }
  320                 }
  321                 foreach ( $reversed_sysprefs as $k ) {
  322                     $icmsAdminTpl->append(
  323                         'mod_options',
  324                         array(
  325                             'title' => $k ['title'], 'link' => $k ['link'],
  326                             'icon' => (isset($k['icon']) && $k['icon'] != '' ? $k['icon'] : '')
  327                         )
  328                     );
  329                 }
  330             }
  331         } else {
  332             foreach ( $mods as $mod ) {
  333                 if ($mod['dir'] == $icmsModule->getVar('dirname')) {
  334                     $m = $mod; //Getting info of the current module
  335                     break;
  336                 }
  337             }
  338             if (isset($m['subs']) && count($m['subs']) > 0) {
  339                 for($i = count($m['subs']) - 1; $i >= 0; $i = $i - 1) {
  340                     if (isset($m['subs'][$i])) {
  341                         $reversed_module_admin_menu[] = $m['subs'][$i];
  342                     }
  343                 }
  344                 foreach ( $reversed_module_admin_menu as $k ) {
  345                     $icmsAdminTpl->append(
  346                         'mod_options',
  347                         array('title' => $k ['title'], 'link' => $k ['link'],
  348                             'icon' => (isset($k['icon']) && $k['icon'] != '' ? $k['icon'] : '')
  349                         )
  350                     );
  351                 }
  352             }
  353         }
  354         $icmsAdminTpl->assign('modpath', ICMS_URL . '/modules/' . $icmsModule->getVar('dirname'));
  355         $icmsAdminTpl->assign('modname', $icmsModule->getVar('name'));
  356         $icmsAdminTpl->assign('modid', $icmsModule->getVar('mid'));
  357         $icmsAdminTpl->assign('moddir', $icmsModule->getVar('dirname'));
  358         $icmsAdminTpl->assign('lang_prefs', _PREFERENCES);
  359     }
  360 
  361     if ( @is_object($xoTheme->plugins['icms_view_PageBuilder']) ) {
  362         $aggreg =& $xoTheme->plugins['icms_view_PageBuilder'];
  363 
  364         $icmsAdminTpl->assign_by_ref('xoAdminBlocks', $aggreg->blocks);
  365 
  366         // Backward compatibility code for pre 2.0.14 themes
  367         $icmsAdminTpl->assign_by_ref('xoops_lblocks', $aggreg->blocks['canvas_left']);
  368         $icmsAdminTpl->assign_by_ref('xoops_rblocks', $aggreg->blocks['canvas_right']);
  369         $icmsAdminTpl->assign_by_ref('xoops_ccblocks', $aggreg->blocks['page_topcenter']);
  370         $icmsAdminTpl->assign_by_ref('xoops_clblocks', $aggreg->blocks['page_topleft']);
  371         $icmsAdminTpl->assign_by_ref('xoops_crblocks', $aggreg->blocks['page_topright']);
  372 
  373         $icmsAdminTpl->assign('xoops_showlblock', !empty($aggreg->blocks['canvas_left']));
  374         $icmsAdminTpl->assign('xoops_showrblock', !empty($aggreg->blocks['canvas_right']));
  375         $icmsAdminTpl->assign(
  376             'xoops_showcblock',
  377             !empty($aggreg->blocks['page_topcenter'])
  378             || !empty($aggreg->blocks['page_topleft'])
  379             || !empty($aggreg->blocks['page_topright'])
  380         );
  381 
  382         /**
  383          * Send to template some ml infos
  384          */
  385         $icmsAdminTpl->assign('lang_prefs', _PREFERENCES);
  386         $icmsAdminTpl->assign('ml_is_enabled', $icmsConfigMultilang ['ml_enable']);
  387         $icmsAdminTpl->assign('adm_left_logo', $icmsConfigPersona['adm_left_logo']);
  388         $icmsAdminTpl->assign('adm_left_logo_url', $icmsConfigPersona['adm_left_logo_url']);
  389         $icmsAdminTpl->assign('adm_left_logo_alt', $icmsConfigPersona['adm_left_logo_alt']);
  390         $icmsAdminTpl->assign('adm_right_logo', $icmsConfigPersona['adm_right_logo']);
  391         $icmsAdminTpl->assign('adm_right_logo_url', $icmsConfigPersona['adm_right_logo_url']);
  392         $icmsAdminTpl->assign('adm_right_logo_alt', $icmsConfigPersona['adm_right_logo_alt']);
  393         $icmsAdminTpl->assign('show_impresscms_menu', $icmsConfigPersona['show_impresscms_menu']);
  394 
  395     }
  396 }
  397 
  398 /**
  399  * Backwards compatibility function.
  400  *
  401  * @since XOOPS
  402  * @version $Id: cp_functions.php 12313 2013-09-15 21:14:35Z skenow $
  403  * @deprecated use icms_cp_header instead
  404  * @todo        Remove in version 1.4 -  - all occurrences in the core have been removed
  405  *
  406  * @author The Xoops Project <http://www.xoops.org>
  407  * @author Gustavo Pilla (aka nekro) <nekro@impresscms.org>
  408  */
  409 function xoops_cp_header() {
  410     icms_core_Debug::setDeprecated('icms_cp_header', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
  411     icms_cp_header();
  412 }
  413 
  414 /**
  415  * Function icms_cp_footer
  416  *
  417  * @since ImpressCMS 1.2
  418  * @version $Id: cp_functions.php 12313 2013-09-15 21:14:35Z skenow $
  419  * @author rowd (from XOOPS Community)
  420  * @author Gustavo Pilla (aka nekro) <nekro@impresscms.org>
  421  */
  422 function icms_cp_footer() {
  423     global $xoopsOption, $xoTheme;
  424     icms::$logger->stopTime('Module display');
  425 
  426     if (!headers_sent()) {
  427         header('Content-Type:text/html; charset='._CHARSET);
  428         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  429         header('Cache-Control: private, no-cache');
  430         header('Pragma: no-cache');
  431     }
  432     if ( isset($xoopsOption['template_main']) && $xoopsOption['template_main'] != $xoTheme->contentTemplate ) {
  433         trigger_error("xoopsOption[template_main] should be defined before including header.php", E_USER_WARNING);
  434         if ( false === strpos( $xoopsOption['template_main'], ':' ) ) {
  435             $xoTheme->contentTemplate = 'db:' . $xoopsOption['template_main'];
  436         } else {
  437             $xoTheme->contentTemplate = $xoopsOption['template_main'];
  438         }
  439     }
  440 
  441     icms::$logger->stopTime( 'XOOPS output init' );
  442     icms::$logger->startTime( 'Module display' );
  443 
  444     $xoTheme->render();
  445 
  446     icms::$logger->stopTime();
  447     return;
  448 }
  449 
  450 /**
  451  * Backwards compatibility function
  452  *
  453  * @version $Id: cp_functions.php 12313 2013-09-15 21:14:35Z skenow $
  454  * @deprecated use icms_cp_footer instead
  455  * @todo remove in 1.4 - all occurrences in the core have been removed
  456  *
  457  * @author The XOOPS Project <http://www.xoops.org>
  458  * @author Gustavo Pilla (aka nekro) <nekro@impresscms.org>
  459  */
  460 function xoops_cp_footer() {
  461     icms_core_Debug::setDeprecated('icms_cp_footer', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
  462     icms_cp_footer();
  463 }
  464 
  465 /**
  466  * Do we need this? Only occurrences in the core are commented out
  467  * @todo remove this by 1.4
  468  * @deprecated used for old modules that don't use smarty templates
  469  */
  470 function OpenTable() {
  471     icms_core_Debug::setDeprecated('the smarty template system', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
  472     echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #2F5376;'><tr class='bg4'><td valign='top'>\n";
  473 }
  474 /**
  475  * Do we need this? Only occurrences in the core are commented out
  476  * @todo remove this by 1.4
  477  * @deprecated used for old modules that don't use smarty templates
  478  */
  479 function CloseTable() {
  480     icms_core_Debug::setDeprecated('the smarty template system', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
  481     echo '</td></tr></table>';
  482 }
  483 
  484 function themecenterposts($title, $content) {
  485     echo '<table cellpadding="4" cellspacing="1" width="98%" class="outer"><tr><td class="head">' . $title . '</td></tr><tr><td><br />' . $content . '<br /></td></tr></table>';
  486 }
  487 /**
  488  * Do we need this? No occurrences in the core
  489  * @todo remove this by 1.4
  490  */
  491 function myTextForm($url, $value) {
  492     return '<form action="' . $url . '" method="post"><input type="submit" value="' . $value . '" /></form>';
  493 }
  494 
  495 /**
  496  *
  497  * Is this needed? There are no occurrences in the core
  498  * @todo remove by version 1.4
  499  */
  500 function xoopsfwrite() {
  501     if ($_SERVER ['REQUEST_METHOD'] != 'POST') {
  502         return false;
  503     } else {
  504 
  505     }
  506     if (! icms::$security->checkReferer ()) {
  507         return false;
  508     } else {
  509 
  510     }
  511     return true;
  512 }
  513 
  514 /**
  515  * Creates a multidimensional array with items of the dropdown menus of the admin panel.
  516  * This array will be saved, by the function xoops_module_write_admin_menu, in a cache file
  517  * to preserve resources of the server and to maintain compatibility with some modules Xoops.
  518  *
  519  * @author TheRplima
  520  *
  521  * @return array (content of admin panel dropdown menus)
  522  */
  523 function impresscms_get_adminmenu() {
  524     $admin_menu = array ( );
  525     $modules_menu = array ( );
  526     $systemadm = false;
  527 
  528     #########################################################################
  529     # Control Panel Home menu
  530     #########################################################################
  531 
  532     $menu[0] = array(
  533         'link' => ICMS_URL . '/admin.php',
  534         'title' => _CPHOME,
  535         'absolute' => 1,
  536         'small' => ICMS_URL . '/modules/system/images/mini_cp.png',
  537     );
  538 
  539     $menu[] = array(
  540         'link' => ICMS_URL,
  541         'title' => _YOURHOME,
  542         'absolute' => 1,
  543         'small' => ICMS_URL . '/modules/system/images/home.png',
  544     );
  545 
  546     $menu[] = array(
  547         'link' => ICMS_URL . '/user.php?op=logout',
  548         'title' => _LOGOUT,
  549         'absolute' => 1,
  550         'small' => ICMS_URL . '/modules/system/images/logout.png',
  551     );
  552 
  553     $admin_menu[0] = array(
  554         'id' => 'cphome',
  555         'text' => _CPHOME,
  556         'link' => '#',
  557         'menu' => $menu,
  558     );
  559 
  560     #########################################################################
  561     # end
  562     #########################################################################
  563 
  564     #########################################################################
  565     # System Preferences menu
  566     #########################################################################
  567     $module_handler = icms::handler('icms_module');
  568     $mod = & $module_handler->getByDirname ( 'system' );
  569     $menu = array ( );
  570     foreach ( $mod->getAdminMenu () as $lkn ) {
  571         $lkn['dir'] = 'system';
  572         $menu[] = $lkn;
  573     }
  574 
  575     $admin_menu[] = array(
  576         'id' => 'opsystem',
  577         'text' => _SYSTEM,
  578         'link' => ICMS_URL . '/modules/system/admin.php',
  579         'menu' => $menu,
  580     );
  581     #########################################################################
  582     # end
  583     #########################################################################
  584 
  585     #########################################################################
  586     # Modules menu
  587     #########################################################################
  588     $module_handler = icms::handler('icms_module');
  589     $criteria = new icms_db_criteria_Compo();
  590     $criteria->add(new icms_db_criteria_Item('hasadmin', 1));
  591     $criteria->add(new icms_db_criteria_Item('isactive', 1));
  592     $modules = $module_handler->getObjects($criteria);
  593     usort($modules, 'impresscms_sort_adminmenu_modules');
  594     foreach ( $modules as $module ) {
  595         $rtn = array();
  596         $inf = & $module->getInfo();
  597         $rtn['link'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . (isset($inf['adminindex']) ? $inf['adminindex'] : '');
  598         $rtn['title'] = $module->getVar('name');
  599         $rtn['dir'] = $module->getVar('dirname');
  600         if (isset($inf['iconsmall']) && $inf['iconsmall'] != '') {
  601             $rtn['small'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . $inf['iconsmall'];
  602         }
  603         if (isset($inf['iconbig']) && $inf['iconbig'] != '') {
  604             $rtn['iconbig'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . $inf['iconbig'];
  605         }
  606         $rtn['absolute'] = 1;
  607         $rtn['subs'] = array();
  608         $module->loadAdminMenu();
  609         if (is_array($module->adminmenu) && count ($module->adminmenu) > 0) {
  610             foreach ( $module->adminmenu as $item ) {
  611                 $item['link'] = ICMS_URL . '/modules/' . $module->getVar('dirname') . '/' . $item ['link'];
  612                 $rtn['subs'][] = $item;
  613             }
  614         }
  615         $hasconfig = $module->getVar('hasconfig');
  616         $hascomments = $module->getVar('hascomments');
  617         if ((isset($hasconfig) && $hasconfig == 1) || (isset($hascomments) && $hascomments == 1)) {
  618             $subs = array(
  619                 'title' => _PREFERENCES,
  620                 'link' => ICMS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod='
  621                         . $module->getVar('mid')
  622             );
  623             $rtn['subs'][] = $subs;
  624         }
  625         $rtn['hassubs'] = (count($rtn ['subs']) > 0) ? 1 : 0;
  626         if ($rtn['hassubs'] == 0) unset($rtn ['subs']);
  627         if ($module->getVar('dirname') == 'system') {
  628             $systemadm = true;
  629         }
  630         $modules_menu[] = $rtn;
  631     }
  632 
  633     $admin_menu[] = array(
  634         'id' => 'modules',
  635         'text' => _MODULES,
  636         'link' => ICMS_URL . '/modules/system/admin.php?fct=modulesadmin',
  637         'menu' => $modules_menu,
  638     );
  639 
  640     #########################################################################
  641     # end
  642     #########################################################################
  643 
  644     #########################################################################
  645     # ImpressCMS News Feed menu
  646     #########################################################################
  647     $menu = array();
  648     $menu[] = array(
  649         'link' => 'http://www.impresscms.org',
  650         'title' => _IMPRESSCMS_HOME,
  651         'absolute' => 1,
  652         //small' => ICMS_URL . '/images/impresscms.png',
  653     );
  654 
  655 
  656     if ( _LANGCODE != 'en' ){
  657         $menu[] = array(
  658             'link' => _IMPRESSCMS_LOCAL_SUPPORT,
  659             'title' => _IMPRESSCMS_LOCAL_SUPPORT_TITLE,
  660             'absolute' => 1,
  661             //'small' => ICMS_URL . '/images/impresscms.png',
  662         );
  663     }
  664 
  665     $menu[] = array(
  666         'link' => 'https://www.impresscms.org/modules/iforum/',
  667         'title' => _IMPRESSCMS_COMMUNITY,
  668         'absolute' => 1,
  669         //'small' = ICMS_URL . '/images/impresscms.png',
  670     );
  671 
  672     $menu[] = array(
  673         'link' => 'https://www.impresscms.org/modules/downloads/',
  674         'title' => _IMPRESSCMS_ADDONS,
  675         'absolute' => 1,
  676         //'small' => ICMS_URL . '/images/impresscms.png',
  677     );
  678 
  679     $menu[] = array(
  680         'link' => 'https://www.impresscms.org/modules/simplywiki/',
  681         'title' => _IMPRESSCMS_WIKI,
  682         'absolute' => 1,
  683         //'small' = ICMS_URL . '/images/impresscms.png',
  684     );
  685 
  686     $menu[] = array(
  687         'link' => 'https://www.impresscms.org/modules/news/',
  688         'title' => _IMPRESSCMS_BLOG,
  689         'absolute' => 1,
  690         //'small'] = ICMS_URL . '/images/impresscms.png',
  691     );
  692 
  693     $menu[] = array(
  694         'link' => 'https://github.com/ImpressCMS/impresscms',
  695         'title' => _IMPRESSCMS_PROJECT,
  696         'absolute' => 1,
  697         //'small' = ICMS_URL . '/images/impresscms.png',
  698     );
  699 /*
  700     $menu[] = array(
  701         'link' => 'http://www.impresscms.org/donations/',
  702         'title' => _IMPRESSCMS_DONATE,
  703         'absolute' => 1,
  704         //'small' = ICMS_URL . '/images/impresscms.png',
  705     );
  706 */
  707     $menu[] = array(
  708     'link' => ICMS_URL . '/admin.php?rssnews=1',
  709     'title' => _IMPRESSCMS_NEWS,
  710     'absolute' => 1,
  711     //'small' => ICMS_URL . '/images/impresscms.png',
  712     );
  713 
  714     $admin_menu[] = array(
  715         'id' => 'news',
  716         'text' => _ABOUT,
  717         'link' => '#',
  718         'menu' => $menu,
  719     );
  720 
  721     #########################################################################
  722     # end
  723     #########################################################################
  724 
  725     return $admin_menu;
  726 }
  727 
  728 function impresscms_sort_adminmenu_modules($a, $b) {
  729     $a = strtolower($a->getVar("name"));
  730     $b = strtolower($b->getVar("name"));
  731     return ($a == $b) ? 0 : ($a < $b) ? -1 : +1;
  732 }
  733 
  734 /**
  735  * Function maintained only for compatibility
  736  *
  737  * @todo remove this in 1.4  - all occurrences in the core have been removed
  738  * @deprecated use impresscms_get_adminmenu instead
  739  */
  740 function xoops_module_get_admin_menu() {
  741     icms_core_Debug::setDeprecated('impresscms_get_adminmenu', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
  742     return impresscms_get_adminmenu ();
  743 }
  744 
  745 /**
  746  * Writes entire admin menu into cache
  747  * @param string  $content  content to write to the admin menu file
  748  * @return true
  749  * @todo create language constants for the error messages
  750  */
  751 function xoops_module_write_admin_menu($content) {
  752     global $icmsConfig;
  753     $filename = ICMS_CACHE_PATH . '/adminmenu_' . $icmsConfig ['language'] . '.php';
  754     if (! $file = fopen($filename, "w")) {
  755         echo 'failed open file';
  756         return false;
  757     }
  758     if (fwrite($file, var_export($content, true)) == FALSE) {
  759         echo 'failed write file';
  760         return false;
  761     }
  762     fclose($file);
  763 
  764     // write index.html file in cache folder
  765     // file is delete after clear_cache (smarty)
  766     icms_core_Filesystem::writeIndexFile(ICMS_CACHE_PATH);
  767     return true;
  768 }
  769 
  770 /**
  771  * Writes index file
  772  * @param string  $path  path to the file to write
  773  * @return bool
  774  * @todo use language constants for error messages
  775  * @todo Move to static class Filesystem
  776  */
  777 function xoops_write_index_file($path = '') {
  778     icms_core_Debug::setDeprecated('icms_core_Filesystem::writeIndexFile', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
  779     return icms_core_Filesystem::writeIndexFile($path);
  780 }