Esempio n. 1
0
/**
 * Function icms_cp_header
 *
 * @since ImpressCMS 1.2
 * @version $Id: cp_functions.php 12115 2012-11-18 16:10:55Z fiammy $
 *
 * @author rowd (from the XOOPS Community)
 * @author nekro (aka Gustavo Pilla)<*****@*****.**>
 */
function icms_cp_header()
{
    global $icmsConfig, $icmsConfigPlugins, $icmsConfigPersona, $icmsModule, $xoopsModule, $xoopsTpl, $xoopsOption, $icmsTheme, $xoTheme, $icmsConfigMultilang, $icmsAdminTpl;
    icms::$logger->stopTime('Module init');
    icms::$logger->startTime('ImpressCMS CP Output Init');
    if (!headers_sent()) {
        header('Content-Type:text/html; charset=' . _CHARSET);
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Pragma: no-cache");
    }
    $icmsAdminTpl = new icms_view_Tpl();
    $icmsAdminTpl->assign('xoops_url', ICMS_URL);
    $icmsAdminTpl->assign('icms_sitename', $icmsConfig['sitename']);
    if (@$xoopsOption['template_main']) {
        if (false === strpos($xoopsOption['template_main'], ':')) {
            $xoopsOption['template_main'] = 'db:' . $xoopsOption['template_main'];
        }
    }
    $xoopsThemeFactory = new icms_view_theme_Factory();
    $xoopsThemeFactory->allowedThemes = $icmsConfig['theme_set_allowed'];
    // The next 2 lines are for compatibility only... to implement the admin theme ;)
    // TODO: Remove all this after a few versions!!
    if (isset($icmsConfig['theme_admin_set'])) {
        $xoopsThemeFactory->defaultTheme = $icmsConfig['theme_admin_set'];
    }
    $icmsTheme = $xoTheme =& $xoopsThemeFactory->createInstance(array('contentTemplate' => @$xoopsOption['template_main'], 'canvasTemplate' => 'theme' . (file_exists(ICMS_THEME_PATH . '/' . $icmsConfig['theme_admin_set'] . '/theme_admin.html') || file_exists(ICMS_MODULES_PATH . '/system/themes/' . $icmsConfig['theme_admin_set'] . '/theme_admin.html') ? '_admin' : '') . '.html', 'plugins' => array('icms_view_PageBuilder'), 'folderName' => $icmsConfig['theme_admin_set']));
    $icmsAdminTpl = $xoTheme->template;
    // ################# Preload Trigger startOutputInit ##############
    icms::$preload->triggerEvent('adminHeader');
    $xoTheme->addScript(ICMS_URL . '/include/xoops.js', array('type' => 'text/javascript'));
    $xoTheme->addScript('', array('type' => 'text/javascript'), 'startList = function() {
						if (document.all&&document.getElementById) {
							navRoot = document.getElementById("nav");
							for (i=0; i<navRoot.childNodes.length; i++) {
								node = navRoot.childNodes[i];
								if (node.nodeName=="LI") {
									node.onmouseover=function() {
										this.className+=" over";
									}
									node.onmouseout=function() {
										this.className=this.className.replace(" over", "");
									}
								}
							}
						}
					}
					window.onload=startList;');
    /** @todo	Remove icms.css in 2.0 */
    icms_core_Debug::setDeprecated("Elements from icms.css need to be moved to your theme", sprintf(_CORE_REMOVE_IN_VERSION, '2.0'));
    $xoTheme->addStylesheet(ICMS_URL . '/icms' . (defined('_ADM_USE_RTL') && _ADM_USE_RTL ? '_rtl' : '') . '.css', array('media' => 'screen'));
    // JQuery UI Dialog
    $xoTheme->addScript(ICMS_URL . '/libraries/jquery/jquery.js', array('type' => 'text/javascript'));
    if (!empty($_SESSION['redirect_message'])) {
        $xoTheme->addScript(ICMS_URL . '/libraries/jquery/jgrowl.js', array('type' => 'text/javascript'));
        $xoTheme->addStylesheet(ICMS_URL . '/libraries/jquery/jgrowl' . (defined('_ADM_USE_RTL') && _ADM_USE_RTL ? '_rtl' : '') . '.css', array('media' => 'screen'));
        $xoTheme->addScript('', array('type' => 'text/javascript'), '
	if (!window.console || !console.firebug) {
		var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
		window.console = {};

		for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
	}

	(function($) {
		$(document).ready(function() {
			$.jGrowl("' . $_SESSION['redirect_message'] . '", {  life:5000 , position: "center", speed: "slow" });
		});
	})(jQuery);
	');
        unset($_SESSION['redirect_message']);
    }
    $xoTheme->addScript(ICMS_URL . '/libraries/jquery/ui/ui.min.js', array('type' => 'text/javascript'));
    $xoTheme->addScript(ICMS_URL . '/libraries/jquery/helptip.js', array('type' => 'text/javascript'));
    $xoTheme->addStylesheet(ICMS_URL . '/libraries/jquery/ui/css/ui-smoothness/ui.css', array('media' => 'screen'));
    $xoTheme->addStylesheet(ICMS_LIBRARIES_URL . '/jquery/colorbox/colorbox.css');
    $xoTheme->addScript(ICMS_LIBRARIES_URL . '/jquery/colorbox/jquery.colorbox-min.js');
    /*	$jscript = '';
    	 if(class_exists('icms_form_elements_Dhtmltextarea')){
    		foreach ($icmsConfigPlugins['sanitizer_plugins'] as $key) {
    		if( empty( $key ) )
    		continue;
    		if(file_exists(ICMS_ROOT_PATH.'/plugins/textsanitizer/'.$key.'/'.$key.'.js')){
    		$xoTheme->addScript(ICMS_URL.'/plugins/textsanitizer/'.$key.'/'.$key.'.js', array('type' => 'text/javascript'));
    		}else{
    		$extension = include_once ICMS_ROOT_PATH.'/plugins/textsanitizer/'.$key.'/'.$key.'.php';
    		$func = 'render_'.$key;
    		if ( function_exists($func) ) {
    		@list($encode, $jscript) = $func($ele_name);
    		if (!empty($jscript)) {
    		if(!file_exists(ICMS_ROOT_PATH.'/'.$jscript)){
    		$xoTheme->addScript('', array('type' => 'text/javascript'), $jscript);
    		}else{
    		$xoTheme->addScript($jscript, array('type' => 'text/javascript'));
    		}
    		}
    		}
    		}
    		}
    		}
    		*/
    $style_info = '';
    if (!empty($icmsConfigPlugins['sanitizer_plugins'])) {
        foreach ($icmsConfigPlugins['sanitizer_plugins'] as $key) {
            if (empty($key)) {
                continue;
            }
            if (file_exists(ICMS_ROOT_PATH . '/plugins/textsanitizer/' . $key . '/' . $key . '.css')) {
                $xoTheme->addStylesheet(ICMS_URL . '/plugins/textsanitizer/' . $key . '/' . $key . '.css', array('media' => 'screen'));
            } else {
                $extension = (include_once ICMS_ROOT_PATH . '/plugins/textsanitizer/' . $key . '/' . $key . '.php');
                $func = 'style_' . $key;
                if (function_exists($func)) {
                    $style_info = $func();
                    if (!empty($style_info)) {
                        if (!file_exists(ICMS_ROOT_PATH . '/' . $style_info)) {
                            $xoTheme->addStylesheet('', array('media' => 'screen'), $style_info);
                        } else {
                            $xoTheme->addStylesheet($style_info, array('media' => 'screen'));
                        }
                    }
                }
            }
        }
    }
    /**
     * Loading admin dropdown menus
     */
    if (!file_exists(ICMS_CACHE_PATH . '/adminmenu_' . $icmsConfig['language'] . '.php')) {
        xoops_module_write_admin_menu(impresscms_get_adminmenu());
    }
    $file = file_get_contents(ICMS_CACHE_PATH . "/adminmenu_" . $icmsConfig['language'] . ".php");
    $admin_menu = eval('return ' . $file . ';');
    $moduleperm_handler = icms::handler('icms_member_groupperm');
    $module_handler = icms::handler('icms_module');
    foreach ($admin_menu as $k => $navitem) {
        //Getting array of allowed modules to use in admin home
        if ($navitem['id'] == 'modules') {
            $perm_itens = array();
            foreach ($navitem['menu'] as $item) {
                $module = $module_handler->getByDirname($item['dir']);
                $admin_perm = $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), icms::$user->getGroups());
                if ($admin_perm) {
                    if ($item['dir'] != 'system') {
                        $perm_itens[] = $item;
                    }
                }
            }
            $navitem['menu'] = $mods = $perm_itens;
        }
        //end
        if ($navitem['id'] == 'opsystem') {
            $groups = icms::$user->getGroups();
            $all_ok = false;
            if (!in_array(ICMS_GROUP_ADMIN, $groups)) {
                $sysperm_handler = icms::handler('icms_member_groupperm');
                $ok_syscats =& $sysperm_handler->getItemIds('system_admin', $groups);
            } else {
                $all_ok = true;
            }
            $perm_itens = array();
            /**
             * Allow easely change the order of system dropdown menu.
             * $adminmenuorder = 1; Alphabetically order;
             * $adminmenuorder = 0; Indice key order;
             * 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
             *
             * @todo: Create a preference option to set this value and improve the way to change the order.
             */
            $adminmenuorder = 1;
            $adminsubmenuorder = 1;
            $adminsubsubmenuorder = 1;
            if ($adminmenuorder == 1) {
                foreach ($navitem['menu'] as $k => $sortarray) {
                    $column[] = $sortarray['title'];
                    if (isset($sortarray['subs']) && count($sortarray['subs']) > 0 && $adminsubmenuorder) {
                        asort($navitem['menu'][$k]['subs']);
                    }
                    if (isset($sortarray['subs']) && count($sortarray['subs']) > 0) {
                        foreach ($sortarray['subs'] as $k2 => $sortarray2) {
                            if (isset($sortarray2['subs']) && count($sortarray2['subs']) > 0 && $adminsubsubmenuorder) {
                                asort($navitem['menu'][$k]['subs'][$k2]['subs']);
                                //Sorting submenus of preferences
                            }
                        }
                    }
                }
                //sort arrays after loop
                array_multisort($column, SORT_ASC, $navitem['menu']);
            }
            foreach ($navitem['menu'] as $item) {
                foreach ($item['subs'] as $key => $subitem) {
                    if ($all_ok == false && !in_array($subitem['id'], $ok_syscats)) {
                        // remove the subitem
                        unset($item['subs'][$key]);
                    }
                }
                // only add the item (first layer: groups) if it has subitems
                if (count($item['subs']) > 0) {
                    $perm_itens[] = $item;
                }
            }
            //Getting array of allowed system prefs
            $navitem['menu'] = $sysprefs = $perm_itens;
        }
        $icmsAdminTpl->append('navitems', $navitem);
    }
    if (count($sysprefs) > 0) {
        $icmsAdminTpl->assign('systemadm', 1);
    } else {
        $icmsAdminTpl->assign('systemadm', 0);
    }
    if (count($mods) > 0) {
        $icmsAdminTpl->assign('modulesadm', 1);
    } else {
        $icmsAdminTpl->assign('modulesadm', 0);
    }
    /**
     * Loading options of the current module.
     */
    if ($icmsModule) {
        if ($icmsModule->getVar('dirname') == 'system') {
            if (isset($sysprefs) && count($sysprefs) > 0) {
                // remove the grouping for the system module preferences (first layer)
                $sysprefs_tmp = array();
                foreach ($sysprefs as $pref) {
                    $sysprefs_tmp = array_merge($sysprefs_tmp, $pref['subs']);
                }
                $sysprefs = $sysprefs_tmp;
                unset($sysprefs_tmp);
                for ($i = count($sysprefs) - 1; $i >= 0; $i = $i - 1) {
                    if (isset($sysprefs[$i])) {
                        $reversed_sysprefs[] = $sysprefs[$i];
                    }
                }
                foreach ($reversed_sysprefs as $k) {
                    $icmsAdminTpl->append('mod_options', array('title' => $k['title'], 'link' => $k['link'], 'icon' => isset($k['icon']) && $k['icon'] != '' ? $k['icon'] : ''));
                }
            }
        } else {
            foreach ($mods as $mod) {
                if ($mod['dir'] == $icmsModule->getVar('dirname')) {
                    $m = $mod;
                    //Getting info of the current module
                    break;
                }
            }
            if (isset($m['subs']) && count($m['subs']) > 0) {
                for ($i = count($m['subs']) - 1; $i >= 0; $i = $i - 1) {
                    if (isset($m['subs'][$i])) {
                        $reversed_module_admin_menu[] = $m['subs'][$i];
                    }
                }
                foreach ($reversed_module_admin_menu as $k) {
                    $icmsAdminTpl->append('mod_options', array('title' => $k['title'], 'link' => $k['link'], 'icon' => isset($k['icon']) && $k['icon'] != '' ? $k['icon'] : ''));
                }
            }
        }
        $icmsAdminTpl->assign('modpath', ICMS_URL . '/modules/' . $icmsModule->getVar('dirname'));
        $icmsAdminTpl->assign('modname', $icmsModule->getVar('name'));
        $icmsAdminTpl->assign('modid', $icmsModule->getVar('mid'));
        $icmsAdminTpl->assign('moddir', $icmsModule->getVar('dirname'));
        $icmsAdminTpl->assign('lang_prefs', _PREFERENCES);
    }
    if (@is_object($xoTheme->plugins['icms_view_PageBuilder'])) {
        $aggreg =& $xoTheme->plugins['icms_view_PageBuilder'];
        $icmsAdminTpl->assign_by_ref('xoAdminBlocks', $aggreg->blocks);
        // Backward compatibility code for pre 2.0.14 themes
        $icmsAdminTpl->assign_by_ref('xoops_lblocks', $aggreg->blocks['canvas_left']);
        $icmsAdminTpl->assign_by_ref('xoops_rblocks', $aggreg->blocks['canvas_right']);
        $icmsAdminTpl->assign_by_ref('xoops_ccblocks', $aggreg->blocks['page_topcenter']);
        $icmsAdminTpl->assign_by_ref('xoops_clblocks', $aggreg->blocks['page_topleft']);
        $icmsAdminTpl->assign_by_ref('xoops_crblocks', $aggreg->blocks['page_topright']);
        $icmsAdminTpl->assign('xoops_showlblock', !empty($aggreg->blocks['canvas_left']));
        $icmsAdminTpl->assign('xoops_showrblock', !empty($aggreg->blocks['canvas_right']));
        $icmsAdminTpl->assign('xoops_showcblock', !empty($aggreg->blocks['page_topcenter']) || !empty($aggreg->blocks['page_topleft']) || !empty($aggreg->blocks['page_topright']));
        /**
         * Send to template some ml infos
         */
        $icmsAdminTpl->assign('lang_prefs', _PREFERENCES);
        $icmsAdminTpl->assign('ml_is_enabled', $icmsConfigMultilang['ml_enable']);
        $icmsAdminTpl->assign('adm_left_logo', $icmsConfigPersona['adm_left_logo']);
        $icmsAdminTpl->assign('adm_left_logo_url', $icmsConfigPersona['adm_left_logo_url']);
        $icmsAdminTpl->assign('adm_left_logo_alt', $icmsConfigPersona['adm_left_logo_alt']);
        $icmsAdminTpl->assign('adm_right_logo', $icmsConfigPersona['adm_right_logo']);
        $icmsAdminTpl->assign('adm_right_logo_url', $icmsConfigPersona['adm_right_logo_url']);
        $icmsAdminTpl->assign('adm_right_logo_alt', $icmsConfigPersona['adm_right_logo_alt']);
        $icmsAdminTpl->assign('show_impresscms_menu', $icmsConfigPersona['show_impresscms_menu']);
    }
}
Esempio n. 2
0
 /**
  * Displays the (good old) adminmenu
  *
  * @param int  $currentoption  The current option of the admin menu
  * @param string  $breadcrumb  The breadcrumb trail
  * @param bool  $submenus  Show the submenus!
  * @param int  $currentsub  The current submenu
  *
  * @return datatype  description
  */
 public function displayAdminMenu($currentoption = 0, $breadcrumb = '', $submenus = false, $currentsub = -1)
 {
     global $icmsModule, $icmsConfig;
     icms_loadLanguageFile($icmsModule->getVar('dirname'), 'modinfo');
     icms_loadLanguageFile($icmsModule->getVar('dirname'), 'admin');
     $tpl = new icms_view_Tpl();
     $tpl->assign(array('headermenu' => $this->getAdminHeaderMenu(), 'adminmenu' => $this->getAdminMenu(), 'current' => $currentoption, 'breadcrumb' => $breadcrumb, 'headermenucount' => count($this->getAdminHeaderMenu()), 'submenus' => $submenus, 'currentsub' => $currentsub, 'submenuscount' => count($submenus)));
     $tpl->display(ICMS_ROOT_PATH . '/modules/system/templates/admin/system_adm_modulemenu.html');
 }
Esempio n. 3
0
 /**
  * Render the feed and display it directly
  */
 public function render()
 {
     icms::$logger->disableLogger();
     //header ('Content-Type:text/xml; charset='._CHARSET);
     $xoopsOption['template_main'] = "db:system_rss.html";
     $tpl = new icms_view_Tpl();
     $tpl->assign('channel_title', $this->title);
     $tpl->assign('channel_link', $this->url);
     $tpl->assign('channel_desc', $this->description);
     $tpl->assign('channel_webmaster', $this->webMaster);
     $tpl->assign('channel_editor', $this->channelEditor);
     $tpl->assign('channel_category', $this->category);
     $tpl->assign('channel_generator', $this->generator);
     $tpl->assign('channel_language', $this->language);
     $tpl->assign('channel_lastbuild', $this->lastbuild);
     $tpl->assign('channel_copyright', $this->copyright);
     $tpl->assign('channel_width', $this->width);
     $tpl->assign('channel_height', $this->height);
     $tpl->assign('channel_ttl', $this->ttl);
     $tpl->assign('image_url', $this->image['url']);
     foreach ($this->feeds as $feed) {
         $tpl->append('items', $feed);
     }
     $tpl->display('db:system_rss.html');
 }
Esempio n. 4
0
					:'') 
				. '.css" /><link rel="stylesheet" type="text/css" media="screen" href="' 
				. xoops_getcss($icmsConfig['theme_set']) . '" />';

			$css =& $tpltpl_handler->find($icmsConfig['template_set'], 'css', 0, NULL, NULL, TRUE);
			$csscount = count($css);

			for ($i = 0; $i < $csscount; $i++) {
				$dummylayout .= "\n" . $css[$i]->getVar('tpl_source');
			}

			$dummylayout .= "\n" . '</style></head><body><div id="xo-canvas"><{$content}></div></body></html>';
			if ($tplfile->getVar('tpl_type') == 'block') {

				$block = new icms_view_block_Object($tplfile->getVar('tpl_refid'));
				$xoopsTpl->assign('block', $block->buildBlock());
			}

			$dummytpl = '_dummytpl_' . time() . '.html';
			$fp = fopen(ICMS_CACHE_PATH . '/' . $dummytpl, 'w');
			fwrite($fp, $html);
			fclose($fp);
			$xoopsTpl->assign('content', $xoopsTpl->fetch('file:' . ICMS_CACHE_PATH . '/' . $dummytpl));
			$xoopsTpl->clear_compiled_tpl('file:' . ICMS_CACHE_PATH . '/' . $dummytpl);
			unlink(ICMS_CACHE_PATH . '/' . $dummytpl);
			$dummyfile = '_dummy_' . time() . '.html';
			$fp = fopen(ICMS_CACHE_PATH . '/' . $dummyfile, 'w');
			fwrite($fp, $dummylayout);
			fclose($fp);
			$tplset= $tplfile->getVar('tpl_tplset');
			$tform = array('tpl_tplset' => $tplset, 'tpl_id' => $id, 'tpl_file' => $tplfile->getVar('tpl_file'), 'tpl_desc' => $tplfile->getVar('tpl_desc'), 'tpl_lastmodified' => $tplfile->getVar('tpl_lastmodified'), 'tpl_source' => htmlspecialchars($html, ENT_QUOTES), 'tpl_module' => $moddir);
Esempio n. 5
0
 * @copyright	The ImpressCMS Project http://www.impresscms.org/
 * @license		http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
 * @package		core
 * @since		1.2
 * @author		Rodrigo Pereira Lima (AKA TheRplima) <*****@*****.**>
 * @version		$Id: image-edit.php 1244 2008-03-18 17:09:11Z real_therplima $
 */
$xoopsOption['nodebug'] = 1;
if (file_exists('../../mainfile.php')) {
    include_once '../../mainfile.php';
}
defined('ICMS_ROOT_PATH') or die('ImpressCMS root path not defined');
include_once ICMS_LIBRARIES_PATH . '/wideimage/lib/WideImage.php';
icms_loadLanguageFile('system', 'images', true);
$icmsTpl = new icms_view_Tpl();
$icmsTpl->assign('icms_url', ICMS_URL);
$icmsTpl->assign('icms_root_path', ICMS_ROOT_PATH);
$icmsTpl->assign('icms_lib_path', ICMS_LIBRARIES_PATH);
$icmsTpl->assign('icms_lib_url', ICMS_LIBRARIES_URL);
$icmsTpl->assign('icms_imanager_temp_path', ICMS_IMANAGER_FOLDER_PATH . '/temp');
$icmsTpl->assign('icms_imanager_temp_url', ICMS_IMANAGER_FOLDER_URL . '/temp');
$image_id = isset($_GET['image_id']) ? (int) $_GET['image_id'] : (isset($_POST['image_id']) ? (int) $_POST['image_id'] : null);
$uniq = isset($_GET['uniq']) ? $_GET['uniq'] : (isset($_POST['uniq']) ? $_POST['uniq'] : null);
$type = isset($_GET['type']) ? filter_input(INPUT_GET, 'type') : (isset($_POST['type']) ? filter_input(INPUT_POST, 'type') : null);
$target = isset($_GET['target']) ? filter_input(INPUT_GET, 'target') : (isset($_POST['target']) ? filter_input(INPUT_POST, 'target') : null);
$op = isset($_GET['op']) ? filter_input(INPUT_GET, 'op') : (isset($_POST['op']) ? filter_input(INPUT_POST, 'op') : null);
if (!file_exists(ICMS_IMANAGER_FOLDER_PATH . '/temp/')) {
    if (!@mkdir(ICMS_IMANAGER_FOLDER_PATH . '/temp', 0777)) {
        echo '<script>alert("Temporary folder doesn\'t exist and cannot be created. Create it manually and try again. Folder: ' . str_ireplace(ICMS_ROOT_PATH, "", ICMS_IMANAGER_FOLDER_PATH) . '/temp/' . '");window.close();</script>';
        exit;
    }