function printLangPanel($target, $target_id, $field) { if (!$target_id) { return; } $langs = cmsCore::getDirsList('/languages'); if (count($langs) > 1) { foreach ($langs as $lang) { ?> <a class="ajaxlink editfieldlang" href="#" onclick="return editFieldLang('<?php echo $lang; ?> ','<?php echo $target; ?> ','<?php echo $target_id; ?> ','<?php echo $field; ?> ', this);"><strong><?php echo mb_strtoupper($lang); ?> </strong></a> <?php } } }
function mod_template($mod, $cfg){ cmsPage::initTemplate('modules', $cfg['tpl'])-> assign('current_template', (isset($_SESSION['template']) ? $_SESSION['template'] : ''))-> assign('templates', cmsCore::getDirsList('/templates'))-> display(); return true; }
function applet_templates() { global $adminAccess; global $_LANG; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } $do = cmsCore::request('do', array('config', 'save_config'), 'main'); cmsCore::c('page')->setTitle($_LANG['AD_TEMPLATES_SETTING']); cpAddPathway($_LANG['AD_TEMPLATES_SETTING'], 'index.php?view=templates'); if ($do == 'main') { cmsCore::c('page')->initTemplate('applets', 'templates')->assign('templates', cmsCore::getDirsList('/templates'))->display(); } if ($do == 'config') { $template = cmsCore::request('template', 'str', ''); cpAddPathway($_LANG['AD_TEMPLATE'] . ': ' . $template, 'index.php?view=templates&do=config&template=' . $template); if (!file_exists(PATH . '/templates/' . $template) || !file_exists(PATH . '/templates/' . $template . '/config.php')) { cmsCore::error404(); } include PATH . '/templates/' . $template . '/config.php'; if (function_exists('get_template_cfg_fields')) { $tpl_cfgs = get_template_cfg_fields(); if (!empty($tpl_cfgs)) { $tpl_cfgs_val = cmsCore::getTplCfg($template); cmsCore::c('page')->initTemplate('applets', 'templates')->assign('template', $template)->assign('form_gen_form', cmsCore::c('form_gen')->generateForm($tpl_cfgs, $tpl_cfgs_val))->display(); } else { cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_NO_CONFIG'], 'error'); cmsCore::redirectBack(); } } else { cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_CFG_ERROR'], 'error'); cmsCore::redirectBack(); } } if ($do == 'save_config') { $template = cmsCore::request('template', 'str', ''); if (!file_exists(PATH . '/templates/' . $template) || !file_exists(PATH . '/templates/' . $template . '/config.php') || !cmsUser::checkCsrfToken()) { cmsCore::error404(); } include PATH . '/templates/' . $template . '/config.php'; if (function_exists('get_template_cfg_fields')) { $tpl_cfgs = get_template_cfg_fields(); if (!empty($tpl_cfgs)) { $tpl_cfgs = cmsCore::c('form_gen')->requestForm($tpl_cfgs); cmsCore::saveTplCfg($tpl_cfgs, $template); cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_CFG_SAVED'], 'success'); cmsCore::redirect('/admin/index.php?view=templates'); } else { cmsCore::error404(); } } else { cmsCore::error404(); } } }
function applet_config() { // получаем оригинальный конфиг $config = cmsConfig::getDefaultConfig(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_SITE_SETTING']); cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config'); $do = cmsCore::request('do', 'str', 'list'); if ($do == 'save') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $newCFG = cmsCore::getArrayFromRequest(array('scheme' => array('scheme', array('http', 'https'), ''), 'sitename' => array('sitename', 'str', ''), 'title_and_sitename' => array('title_and_sitename', 'int', 0), 'title_and_page' => array('title_and_page', 'int', 0), 'hometitle' => array('hometitle', 'str', ''), 'homecom' => array('homecom', 'str', ''), 'com_without_name_in_url' => array('com_without_name_in_url', 'str', ''), 'siteoff' => array('siteoff', 'int', 0), 'only_authorized' => array('only_authorized', 'int', 0), 'debug' => array('debug', 'int', 0), 'offtext' => array('offtext', 'str', ''), 'keywords' => array('keywords', 'str', ''), 'metadesc' => array('metadesc', 'str', ''), 'seourl' => array('seourl', 'int', 0), 'lang' => array('lang', 'str', 'ru'), 'is_change_lang' => array('is_change_lang', 'int', 0), 'sitemail' => array('sitemail', 'str', ''), 'sitemail_name' => array('sitemail_name', 'str', ''), 'wmark' => array('wmark', 'str', ''), 'template' => array('template', 'str', ''), 'admin_template' => array('admin_template', 'str', ''), 'cache' => array('cache', 'int', 0), 'cache_type' => array('cache_type', array('file', 'memcached'), ''), 'memcached_host' => array('memcached_host', 'str', ''), 'memcached_port' => array('memcached_port', 'int', 0), 'combine_css_enable' => array('combine_css_enable', 'int', 0), 'combine_css' => array('combine_css', 'html', ''), 'combine_js_enable' => array('combine_js_enable', 'int', 0), 'combine_js' => array('combine_js', 'html', ''), 'splash' => array('splash', 'int', 0), 'slight' => array('slight', 'int', 0), 'show_pw' => array('show_pw', 'int', 0), 'last_item_pw' => array('last_item_pw', 'int', 0), 'index_pw' => array('index_pw', 'int', 0), 'fastcfg' => array('fastcfg', 'int', 0), 'mailer' => array('mailer', 'str', ''), 'smtpsecure' => array('smtpsecure', 'str', ''), 'smtpauth' => array('smtpauth', 'int', 0), 'smtpuser' => array('smtpuser', 'str', $config['smtpuser']), 'smtppass' => array('smtppass', 'str', $config['smtppass']), 'smtphost' => array('smtphost', 'str', ''), 'smtpport' => array('smtpport', 'int', '25'), 'timezone' => array('timezone', 'str', $config['timezone']), 'user_stats' => array('user_stats', 'int', 0), 'seo_url_count' => array('seo_url_count', 'int', 0), 'max_pagebar_links' => array('max_pagebar_links', 'int', 0), 'allow_ip' => array('allow_ip', 'str', ''), 'iframe_enable' => array('iframe_enable', 'int', 0), 'vk_enable' => array('vk_enable', 'int', 0), 'vk_id' => array('vk_id', 'str', ''), 'vk_private_key' => array('vk_private_key', 'str', ''))); $newCFG['sitename'] = stripslashes($newCFG['sitename']); $newCFG['hometitle'] = stripslashes($newCFG['hometitle']); $newCFG['offtext'] = htmlspecialchars($newCFG['offtext'], ENT_QUOTES); $newCFG['db_host'] = $config['db_host']; $newCFG['db_base'] = $config['db_base']; $newCFG['db_user'] = $config['db_user']; $newCFG['db_pass'] = $config['db_pass']; $newCFG['db_prefix'] = $config['db_prefix']; if (cmsConfig::saveToFile($newCFG)) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } else { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error'); } cmsCore::clearCache(); cmsCore::redirect('index.php?view=config'); } cpCheckWritable('/includes/config/config.inc.json'); $result = cmsCore::c('db')->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" . $config['db_base'] . "'", true); if (!cmsCore::c('db')->error()) { $s = cmsCore::c('db')->fetch_assoc($result); } else { $s['size'] = 0; } cmsCore::c('page')->initTemplate('applets', 'config')->assign('config', $config)->assign('timezone_opt', cmsCore::getTimeZonesOptions($config['timezone']))->assign('admin_templates', cmsCore::getDirsList('/templates/admin'))->assign('templates', cmsCore::getDirsList('/templates'))->assign('tpl_info', cmsCore::c('page')->getTplInfo(cmsCore::c('page')->template))->assign('components_opt', cmsCore::getListItems('cms_components', $config['com_without_name_in_url'], 'title', 'ASC', 'internal=0', 'link'))->assign('homecom_opt', cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'))->assign('langs', cmsCore::getDirsList('/languages'))->assign('db_size', round($s['size'], 2))->display(); }
function applet_config() { // получаем оригинальный конфиг $config = cmsConfig::getDefaultConfig(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_SITE_SETTING']); cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config'); $do = cmsCore::request('do', 'str', 'list'); if ($do == 'save') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $newCFG = cmsCore::getArrayFromRequest(array( 'scheme' => array('scheme', array('http', 'https'), ''), 'sitename' => array('sitename', 'str', ''), 'title_and_sitename' => array('title_and_sitename', 'int', 0), 'title_and_page' => array('title_and_page', 'int', 0), 'hometitle' => array('hometitle', 'str', ''), 'homecom' => array('homecom', 'str', ''), 'com_without_name_in_url' => array('com_without_name_in_url', 'str', ''), 'siteoff' => array('siteoff', 'int', 0), 'only_authorized' => array('only_authorized', 'int', 0), 'debug' => array('debug', 'int', 0), 'offtext' => array('offtext', 'str', ''), 'keywords' => array('keywords', 'str', ''), 'metadesc' => array('metadesc', 'str', ''), 'seourl' => array('seourl', 'int', 0), 'lang' => array('lang', 'str', 'ru'), 'is_change_lang' => array('is_change_lang', 'int', 0), 'sitemail' => array('sitemail', 'str', ''), 'sitemail_name' => array('sitemail_name', 'str', ''), 'wmark' => array('wmark', 'str', ''), 'template' => array('template', 'str', ''), 'cache' => array('cache', 'int', 0), 'cache_type' => array('cache_type', array('file', 'memcached'), ''), 'memcached_host' => array('memcached_host', 'str', ''), 'memcached_port' => array('memcached_port', 'int', 0), 'combine_css_enable' => array('combine_css_enable', 'int', 0), 'combine_css' => array('combine_css', 'html', ''), 'combine_js_enable' => array('combine_js_enable', 'int', 0), 'combine_js' => array('combine_js', 'html', ''), 'splash' => array('splash', 'int', 0), 'slight' => array('slight', 'int', 0), 'show_pw' => array('show_pw', 'int', 0), 'last_item_pw' => array('last_item_pw', 'int', 0), 'index_pw' => array('index_pw', 'int', 0), 'fastcfg' => array('fastcfg', 'int', 0), 'mailer' => array('mailer', 'str', ''), 'smtpsecure' => array('smtpsecure', 'str', ''), 'smtpauth' => array('smtpauth', 'int', 0), 'smtpuser' => array('smtpuser', 'str', $config['smtpuser']), 'smtppass' => array('smtppass', 'str', $config['smtppass']), 'smtphost' => array('smtphost', 'str', ''), 'smtpport' => array('smtpport', 'int', '25'), 'timezone' => array('timezone', 'str', $config['timezone']), 'user_stats' => array('user_stats', 'int', 0), 'seo_url_count' => array('seo_url_count', 'int', 0), 'max_pagebar_links' => array('max_pagebar_links', 'int', 0), 'allow_ip' => array('allow_ip', 'str', ''), 'iframe_enable' => array('iframe_enable', 'int', 0), 'vk_enable' => array('vk_enable', 'int', 0), 'vk_id' => array('vk_id', 'str', ''), 'vk_private_key' => array('vk_private_key', 'str', ''), )); $newCFG['sitename'] = stripslashes($newCFG['sitename']); $newCFG['hometitle'] = stripslashes($newCFG['hometitle']); $newCFG['offtext'] = htmlspecialchars($newCFG['offtext'], ENT_QUOTES); $newCFG['db_host'] = $config['db_host']; $newCFG['db_base'] = $config['db_base']; $newCFG['db_user'] = $config['db_user']; $newCFG['db_pass'] = $config['db_pass']; $newCFG['db_prefix'] = $config['db_prefix']; if (cmsConfig::saveToFile($newCFG)) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'] , 'success'); } else { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error'); } cmsCore::clearCache(); cmsCore::redirect('index.php?view=config'); } cpCheckWritable('/includes/config/config.inc.json'); ?> <form class="form-horizontal" role="form" action="/admin/index.php?view=config" method="post" name="CFGform" target="_self" id="CFGform" style="margin-bottom:30px"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" /> <div class="uitabs"> <ul id="tabs"> <li><a href="#basic"><span><?php echo $_LANG['AD_SITE']; ?></span></a></li> <li><a href="#home"><span><?php echo $_LANG['AD_MAIN']; ?></span></a></li> <li><a href="#cache"><span><?php echo $_LANG['AD_CACHE']; ?></span></a></li> <li><a href="#database"><span><?php echo $_LANG['AD_DB'] ; ?></span></a></li> <li><a href="#mail"><span><?php echo $_LANG['AD_POST']; ?></span></a></li> <li><a href="#other"><span><?php echo $_LANG['AD_PATHWAY']; ?></span></a></li> <li><a href="#seq"><span><?php echo $_LANG['AD_SECURITY']; ?></span></a></li> <li><a href="#soc_apps"><span><?php echo $_LANG['AD_SOC_APPS']; ?></span></a></li> </ul> <div id="basic"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SCHEME_TYPE']; ?></label> <div class="col-sm-7"> <select id="scheme" class="form-control" name="scheme"> <option value=""><?php echo $_LANG['AD_SCHEME_ANY']; ?></option> <option value="http" <?php if ($config['scheme'] == 'http') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SCHEME_http']; ?></option> <option value="https" <?php if ($config['scheme'] == 'https') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SCHEME_https']; ?></option> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TIME_ARREA']; ?></label> <div class="col-sm-7"> <select id="timezone" class="form-control" name="timezone"> <?php echo cmsCore::getTimeZonesOptions($config['timezone']); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITENAME']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="sitename" value="<?php echo htmlspecialchars($config['sitename']);?>" /> <div class="help-block"><?php echo $_LANG['AD_USE_HEADER']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['TEMPLATE']; ?></label> <div class="col-sm-7"> <select id="template" class="form-control" name="template" onchange="document.CFGform.submit();"> <?php $templates = cmsCore::getDirsList('/templates'); foreach ($templates as $template) { if ($template == 'admin') { continue; } echo '<option value="'. $template .'" '. ($config['template'] == $template ? 'selected="selected"' : '') .'>'. $template .'</option>'; } $tpl_info = cmsCore::c('page')->getCurrentTplInfo(); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEARCH_RESULT']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['slight']) { echo 'active'; } ?>"> <input type="radio" name="slight" <?php if ($config['slight']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['SHOW']; ?> </label> <label class="btn btn-default <?php if (!$config['slight']) { echo 'active'; } ?>"> <input type="radio" name="slight" <?php if (!$config['slight']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TAGE_ADD']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['title_and_sitename']) { echo 'active'; } ?>"> <input type="radio" name="title_and_sitename" <?php if ($config['title_and_sitename']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['title_and_sitename']) { echo 'active'; } ?>"> <input type="radio" name="title_and_sitename" <?php if (!$config['title_and_sitename']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_TAGE_ADD_PAGINATION']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['title_and_page']) { echo 'active'; } ?>"> <input type="radio" name="title_and_page" <?php if ($config['title_and_page']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['title_and_page']) { echo 'active'; } ?>"> <input type="radio" name="title_and_page" <?php if (!$config['title_and_page']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_COM_WITHOUT_NAME_IN_URL']; ?></label> <div class="col-sm-7"> <select class="form-control" name="com_without_name_in_url"> <?php echo cmsCore::getListItems('cms_components', $config['com_without_name_in_url'], 'title', 'ASC', 'internal=0', 'link'); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['TEMPLATE_INTERFACE_LANG']; ?></label> <div class="col-sm-7"> <select class="form-control" name="lang"> <?php $langs = cmsCore::getDirsList('/languages'); foreach ($langs as $lng) { echo '<option value="'. $lng .'" '. ($config['lang'] == $lng ? 'selected="selected"' : '') .'>'. $lng .'</option>'; } ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_LANGUAGE_CHANGE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['is_change_lang']) { echo 'active'; } ?>"> <input type="radio" name="is_change_lang" <?php if ($config['is_change_lang']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['is_change_lang']) { echo 'active'; } ?>"> <input type="radio" name="is_change_lang" <?php if (!$config['is_change_lang']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_VIEW_FORM_LANGUAGE_CHANGE']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_ON']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (!$config['siteoff']) { echo 'active'; } ?>"> <input type="radio" name="siteoff" <?php if (!$config['siteoff']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if ($config['siteoff']) { echo 'active'; } ?>"> <input type="radio" name="siteoff" <?php if ($config['siteoff']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_ONLY_ADMINS']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_ONLY_AUTHORIZED']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['only_authorized']) { echo 'active'; } ?>"> <input type="radio" name="only_authorized" <?php if ($config['only_authorized']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['only_authorized']) { echo 'active'; } ?>"> <input type="radio" name="only_authorized" <?php if (!$config['only_authorized']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_SITE_ONLY_AUTHORIZED_INFO']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DEBUG_ON']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['debug']) { echo 'active'; } ?>"> <input type="radio" name="debug" <?php if ($config['debug']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['debug']) { echo 'active'; } ?>"> <input type="radio" name="debug" <?php if (!$config['debug']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_WIEW_DB_ERRORS']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_WHY_STOP']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="offtext" value="<?php echo htmlspecialchars($config['offtext']); ?>" /> <div class="help-block"><?php echo $_LANG['AD_VIEW_WHY_STOP']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_WATERMARK']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="wmark" value="<?php echo $config['wmark']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_WATERMARK_NAME']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_QUICK_CONFIG']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['fastcfg']) { echo 'active'; } ?>"> <input type="radio" name="fastcfg" <?php if ($config['fastcfg']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['fastcfg']) { echo 'active'; } ?>"> <input type="radio" name="fastcfg" <?php if (!$config['fastcfg']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_MODULE_CONFIG']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ONLINESTATS']; ?></label> <div class="col-sm-7"> <select class="form-control" name="user_stats"> <option value="0" <?php if (!$config['user_stats']) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_NO_ONLINESTATS']; ?></option> <option value="1" <?php if ($config['user_stats'] == 1) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_YES_ONLINESTATS']; ?></option> <option value="2" <?php if ($config['user_stats'] == 2) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_CRON_ONLINESTATS']; ?></option> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEO_URL_COUNT']; ?></label> <div class="col-sm-7"> <input type="number" class="form-control" name="seo_url_count" value="<?php echo $config['seo_url_count']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_SEO_URL_COUNT_HINT']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_PAGEBAR_MAX_LINKS']; ?></label> <div class="col-sm-7"> <input type="number" class="form-control" name="max_pagebar_links" value="<?php echo $config['max_pagebar_links']; ?>" /> </div> </div> </div> </div> <div id="home"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAIN_PAGE']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="hometitle" value="<?php echo htmlspecialchars($config['hometitle']); ?>" /> <div class="help-block"><?php echo $_LANG['AD_MAIN_SITENAME']; ?></div> <div class="help-block"><?php echo $_LANG['AD_BROWSER_TITLE']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_KEY_WORDS']; ?></label> <div class="col-sm-7"> <textarea class="form-control" name="keywords" rows="3"><?php echo $config['keywords']; ?></textarea> <div class="help-block"><?php echo $_LANG['AD_FROM_COMMA']; ?></div> <div class="help-block"><a style="color:#09C" href="http://tutorial.semonitor.ru/#5" target="_blank"><?php echo $_LANG['AD_WHAT_KEY_WORDS']; ?></a></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DESCRIPTION']; ?></label> <div class="col-sm-7"> <textarea class="form-control" name="metadesc" rows="3"><?php echo $config['metadesc']; ?></textarea> <div class="help-block"><?php echo $_LANG['AD_LESS_THAN']; ?></div> <div class="help-block"><a style="color:#09C" href="http://tutorial.semonitor.ru/#219" target="_blank"><?php echo $_LANG['AD_WHAT_DESCRIPTION']; ?></a></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAIN_PAGE_COMPONENT']; ?></label> <div class="col-sm-7"> <select class="form-control" name="homecom"> <option value="" <?php if (!$config['homecom']) { ?>selected="selected"<?php } ?>><?php echo $_LANG['AD_ONLY_MODULES']; ?></option> <?php echo cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'); ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_GATE_PAGE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['splash']) { echo 'active'; } ?>"> <input type="radio" name="splash" <?php if ($config['splash']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['SHOW']; ?> </label> <label class="btn btn-default <?php if (!$config['splash']) { echo 'active'; } ?>"> <input type="radio" name="splash" <?php if (!$config['splash']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_FIRST_VISIT']; ?></div> <div class="help-block"><?php echo $_LANG['AD_FIRST_VISIT_TEMPLATE']; ?></div> </div> </div> </div> </div> <div id="cache"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_CACHE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['cache']) { echo 'active'; } ?>"> <input type="radio" name="cache" <?php if ($config['cache']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['cache']) { echo 'active'; } ?>"> <input type="radio" name="cache" <?php if (!$config['cache']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"> <?php echo $_LANG['AD_CACHE_INFO']; ?> </div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_CACHE_TYPE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <select class="form-control" name="cache_type" onchange="if ($(this).val() == 'memcached'){$('.memcached').show();}else{$('.memcached').hide();}"> <option value="file" <?php if ($config['cache_type'] == 'file') { echo 'selected="selected"'; } ?>>File</option> <?php if (class_exists('Memcached')) { ?> <option value="memcached" <?php if ($config['cache_type'] == 'memcached') { echo 'selected="selected"'; } ?>>Memcached</option> <?php } ?> </select> <div class="help-block"> <?php echo $_LANG['AD_CACHE_TYPE_INFO']; ?> </div> </div> </div> <div class="form-group memcached" <?php if ($config['cache_type'] != 'memcached'){ ?>style="display:none;"<?php } ?>> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MEMCACHED_HOST']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <input type="text" class="form-control" name="memcached_host" value="<?php echo $config['memcached_host']; ?>" /> <div class="help-block"> <?php echo $_LANG['AD_MEMCACHED_HOST_INFO']; ?> </div> </div> </div> <div class="form-group memcached" <?php if ($config['cache_type'] != 'memcached'){ ?>style="display:none;"<?php } ?>> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MEMCACHED_PORT']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <input type="number" class="form-control" name="memcached_port" value="<?php echo $config['memcached_port']; ?>" /> <div class="help-block"> <?php echo $_LANG['AD_MEMCACHED_PORT_INFO']; ?> </div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"> <?php echo $_LANG['AD_COLLECT_CSS']; ?><br/> <input type="checkbox" name="combine_css_enable" value="1" <?php if ($config['combine_css_enable']) { ?>checked="checked"<?php } ?> /> <?php echo $_LANG['AD_DO_ENABLE']; ?> </label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <textarea class="form-control" style="height:150px;" name="combine_css"><?php echo cmsCore::getArrVal($config, 'combine_css', ''); ?></textarea> <div class="help-block"> <?php echo $_LANG['AD_COLLECT_CSS_INFO']; ?> </div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"> <?php echo $_LANG['AD_COLLECT_JS']; ?> <br/> <input type="checkbox" name="combine_js_enable" value="1" <?php if ($config['combine_js_enable']) { ?>checked="checked"<?php } ?> /> <?php echo $_LANG['AD_DO_ENABLE']; ?> </label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <textarea class="form-control" style="height:150px;" name="combine_js"><?php echo cmsCore::getArrVal($config, 'combine_js', ''); ?></textarea> <div class="help-block"> <?php echo $_LANG['AD_COLLECT_JS_INFO']; ?> </div> </div> </div> </div> </div> <div id="database"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_DB_SIZE']; ?></label> <div class="col-sm-7"> <?php $result = cmsCore::c('db')->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '". $config['db_base'] ."'", true); if (!cmsCore::c('db')->error()) { $s = cmsCore::c('db')->fetch_assoc($result); echo round($s['size'], 2) .' '. $_LANG['SIZE_MB']; } else { echo $_LANG['AD_DB_SIZE_ERROR']; } ?> <div class="help-block"><?php echo $_LANG['AD_MYSQL_CONFIG']; ?></div> </div> </div> </div> </div> <div id="mail"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SITE_EMAIL']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="sitemail" value="<?php echo $config['sitemail']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_SITE_EMAIL_POST']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SENDER_EMAIL']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="sitemail_name" value="<?php echo $config['sitemail_name']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_IF_NOT_HANDLER']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SEND_METHOD']; ?></label> <div class="col-sm-7"> <select class="form-control" name="mailer"> <option value="mail" <?php if ($config['mailer'] == 'mail') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_PHP_MAILER']; ?></option> <option value="sendmail" <?php if ($config['mailer'] == 'sendmail') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SEND_MAILER']; ?></option> <option value="smtp" <?php if ($config['mailer'] == 'smtp') { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_SMTP_MAILER']; ?></option> </select> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ENCRYPTING']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (!$config['smtpsecure']) { echo 'active'; } ?>"> <input type="radio" name="smtpsecure" <?php if (!$config['smtpsecure']) { echo 'checked="checked"'; } ?> value="" /> <?php echo $_LANG['NO']; ?> </label> <label class="btn btn-default <?php if ($config['smtpsecure'] == 'tls') { echo 'active'; } ?>"> <input type="radio" name="smtpsecure" <?php if ($config['smtpsecure'] == 'tls') { echo 'checked="checked"'; } ?> value="tls" /> tls </label> <label class="btn btn-default <?php if ($config['smtpsecure'] == 'ssl') { echo 'active'; } ?>"> <input type="radio" name="smtpsecure" <?php if ($config['smtpsecure'] == 'ssl') { echo 'checked="checked"'; } ?> value="ssl" /> ssl </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_LOGIN']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['smtpauth']) { echo 'active'; } ?>"> <input type="radio" name="smtpauth" <?php if ($config['smtpauth']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['smtpauth']) { echo 'active'; } ?>"> <input type="radio" name="smtpauth" <?php if (!$config['smtpauth']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_USER']; ?></label> <div class="col-sm-7"> <?php if (!$config['smtpuser']) { ?> <input type="text" class="form-control" name="smtpuser" value="<?php echo $config['smtpuser']; ?>" /> <?php } else { ?> <div class="help-block"><?php echo $_LANG['AD_IF_CHANGE_USER']; ?></div> <?php } ?> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_PASS']; ?></label> <div class="col-sm-7"> <?php if (!$config['smtppass']) { ?> <input type="text" class="form-control" name="smtppass" value="<?php echo $config['smtppass']; ?>" /> <?php } else { ?> <div class="help-block"><?php echo $_LANG['AD_IF_CHANGE_PASS']; ?></div> <?php } ?> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_HOST']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="smtphost" value="<?php echo $config['smtphost']; ?>" /> <div class="help-block"><?php echo $_LANG['AD_SOME_HOST']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_SMTP_PORT']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="smtpport" value="<?php echo $config['smtpport']; ?>" /> </div> </div> </div> </div> <div id="other"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_VIEW_PATHWAY']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['show_pw']) { echo 'active'; } ?>"> <input type="radio" name="show_pw" <?php if ($config['show_pw']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['show_pw']) { echo 'active'; } ?>"> <input type="radio" name="show_pw" <?php if (!$config['show_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> <div style="clear:both;"></div> <div class="help-block"><?php echo $_LANG['AD_PATH_TO_CATEGORY']; ?></div> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MAINPAGE_PATHWAY']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['index_pw']) { echo 'active'; } ?>"> <input type="radio" name="index_pw" <?php if ($config['index_pw']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['index_pw']) { echo 'active'; } ?>"> <input type="radio" name="index_pw" <?php if (!$config['index_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_PAGE_PATHWAY']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (!$config['last_item_pw']) { echo 'active'; } ?>"> <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['HIDE']; ?> </label> <label class="btn btn-default <?php if ($config['last_item_pw'] == 1) { echo 'active'; } ?>"> <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw'] == 1) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['AD_PAGE_PATHWAY_LINK']; ?> </label> <label class="btn btn-default <?php if ($config['last_item_pw'] == 2) { echo 'active'; } ?>"> <input type="radio" name="last_item_pw" <?php if (!$config['last_item_pw'] == 2) { echo 'checked="checked"'; } ?> value="2" /> <?php echo $_LANG['AD_PAGE_PATHWAY_TEXT']; ?> </label> </div> </div> </div> </div> <div id="seq"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IP_ADMIN']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="allow_ip" value="<?php echo htmlspecialchars($config['allow_ip']); ?>" /> <div class="help-block"><?php echo $_LANG['AD_IP_COMMA']; ?></div> </div> </div> <p style="color:#900"><?php echo $_LANG['AD_ATTENTION']; ?></p> </div> </div> <div id="soc_apps"> <div style="width:750px;"> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_ENABLE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if (cmsCore::getArrVal($config, 'iframe_enable')) { echo 'active'; } ?>"> <input type="radio" name="iframe_enable" <?php if (cmsCore::getArrVal($config, 'iframe_enable')) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!cmsCore::getArrVal($config, 'iframe_enable')) { echo 'active'; } ?>"> <input type="radio" name="iframe_enable" <?php if (!cmsCore::getArrVal($config, 'iframe_enable')) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <fieldset> <legend>VK.COM</legend> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_ENABLE']; ?></label> <div class="col-sm-7 btn-group" data-toggle="buttons"> <label class="btn btn-default <?php if ($config['vk_enable']) { echo 'active'; } ?>"> <input type="radio" name="vk_enable" <?php if ($config['vk_enable']) { echo 'checked="checked"'; } ?> value="1" /> <?php echo $_LANG['YES']; ?> </label> <label class="btn btn-default <?php if (!$config['vk_enable']) { echo 'active'; } ?>"> <input type="radio" name="vk_enable" <?php if (!$config['vk_enable']) { echo 'checked="checked"'; } ?> value="0" /> <?php echo $_LANG['NO']; ?> </label> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_APP_ID']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="vk_id" value="<?php echo $config['vk_id']; ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_IFRAME_APP_PRIVATE_KEY']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" name="vk_private_key" value="<?php echo $config['vk_private_key']; ?>" /> </div> </div> </fieldset> </div> </div> </div> <div> <input type="hidden" name="do" value="save" /> <input type="submit" class="btn btn-primary" name="save" value="<?php echo $_LANG['SAVE']; ?>" /> <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" /> </div> </form> <?php }
function applet_config() { // получаем оригинальный конфиг $config = cmsConfig::getDefaultConfig(); $inPage = cmsPage::getInstance(); $inDB = cmsDatabase::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } $GLOBALS['cp_page_title'] = $_LANG['AD_SITE_SETTING']; cpAddPathway($_LANG['AD_SITE_SETTING'], 'index.php?view=config'); $do = cmsCore::request('do', 'str', 'list'); if ($do == 'save') { if (!cmsCore::validateForm()) { cmsCore::error404(); } $newCFG = array(); $newCFG['sitename'] = stripslashes(cmsCore::request('sitename', 'str', '')); $newCFG['title_and_sitename'] = cmsCore::request('title_and_sitename', 'int', 0); $newCFG['title_and_page'] = cmsCore::request('title_and_page', 'int', 0); $newCFG['hometitle'] = stripslashes(cmsCore::request('hometitle', 'str', '')); $newCFG['homecom'] = cmsCore::request('homecom', 'str', ''); $newCFG['siteoff'] = cmsCore::request('siteoff', 'int', 0); $newCFG['debug'] = cmsCore::request('debug', 'int', 0); $newCFG['offtext'] = htmlspecialchars(cmsCore::request('offtext', 'str', ''), ENT_QUOTES); $newCFG['keywords'] = cmsCore::request('keywords', 'str', ''); $newCFG['metadesc'] = cmsCore::request('metadesc', 'str', ''); $newCFG['seourl'] = cmsCore::request('seourl', 'int', 0); $newCFG['lang'] = cmsCore::request('lang', 'str', 'ru'); $newCFG['is_change_lang'] = cmsCore::request('is_change_lang', 'int', 0); $newCFG['sitemail'] = cmsCore::request('sitemail', 'str', ''); $newCFG['sitemail_name'] = cmsCore::request('sitemail_name', 'str', ''); $newCFG['wmark'] = cmsCore::request('wmark', 'str', ''); $newCFG['template'] = cmsCore::request('template', 'str', ''); $newCFG['splash'] = cmsCore::request('splash', 'int', 0); $newCFG['slight'] = cmsCore::request('slight', 'int', 0); $newCFG['db_host'] = $config['db_host']; $newCFG['db_base'] = $config['db_base']; $newCFG['db_user'] = $config['db_user']; $newCFG['db_pass'] = $config['db_pass']; $newCFG['db_prefix'] = $config['db_prefix']; $newCFG['show_pw'] = cmsCore::request('show_pw', 'int', 0); $newCFG['last_item_pw'] = cmsCore::request('last_item_pw', 'int', 0); $newCFG['index_pw'] = cmsCore::request('index_pw', 'int', 0); $newCFG['fastcfg'] = cmsCore::request('fastcfg', 'int', 0); $newCFG['mailer'] = cmsCore::request('mailer', 'str', ''); $newCFG['smtpsecure'] = cmsCore::request('smtpsecure', 'str', ''); $newCFG['smtpauth'] = cmsCore::request('smtpauth', 'int', 0); $newCFG['smtpuser'] = cmsCore::inRequest('smtpuser') ? cmsCore::request('smtpuser', 'str', '') : $config['smtpuser']; $newCFG['smtppass'] = cmsCore::inRequest('smtppass') ? cmsCore::request('smtppass', 'str', '') : $config['smtppass']; $newCFG['smtphost'] = cmsCore::request('smtphost', 'str', ''); $newCFG['smtpport'] = cmsCore::request('smtpport', 'int', '25'); $newCFG['timezone'] = cmsCore::request('timezone', 'str', ''); $newCFG['timediff'] = cmsCore::request('timediff', 'str', ''); $newCFG['user_stats'] = cmsCore::request('user_stats', 'int', 0); $newCFG['allow_ip'] = cmsCore::request('allow_ip', 'str', ''); if (cmsConfig::saveToFile($newCFG)) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } else { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SITE_ERROR'], 'error'); } cmsCore::clearCache(); cmsCore::redirect('index.php?view=config'); } ?> <div> <?php cpCheckWritable('/includes/config.inc.php'); ?> <div id="config_tabs" class="uitabs"> <ul id="tabs"> <li><a href="#basic"><span><?php echo $_LANG['AD_SITE']; ?> </span></a></li> <li><a href="#home"><span><?php echo $_LANG['AD_MAIN']; ?> </span></a></li> <li><a href="#design"><span><?php echo $_LANG['AD_DESIGN']; ?> </span></a></li> <li><a href="#time"><span><?php echo $_LANG['AD_TIME']; ?> </span></a></li> <li><a href="#database"><span><?php echo $_LANG['AD_DB']; ?> </span></a></li> <li><a href="#mail"><span><?php echo $_LANG['AD_POST']; ?> </span></a></li> <li><a href="#other"><span><?php echo $_LANG['AD_PATHWAY']; ?> </span></a></li> <li><a href="#seq"><span><?php echo $_LANG['AD_SECURITY']; ?> </span></a></li> </ul> <form action="/admin/index.php?view=config" method="post" name="CFGform" target="_self" id="CFGform" style="margin-bottom:30px"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?> " /> <div id="basic"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_SITENAME']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_USE_HEADER']; ?> </span> </td> <td width="350" valign="top"> <input name="sitename" type="text" id="sitename" value="<?php echo htmlspecialchars($config['sitename']); ?> " style="width:358px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_TAGE_ADD']; ?> </strong> </td> <td valign="top"> <label><input name="title_and_sitename" type="radio" value="1" <?php if ($config['title_and_sitename']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="title_and_sitename" type="radio" value="0" <?php if (!$config['title_and_sitename']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_TAGE_ADD_PAGINATION']; ?> </strong> </td> <td valign="top"> <label><input name="title_and_page" type="radio" value="1" <?php if ($config['title_and_page']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="title_and_page" type="radio" value="0" <?php if (!$config['title_and_page']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['TEMPLATE_INTERFACE_LANG']; ?> :</strong> </td> <td width="350" valign="top"> <select name="lang" id="lang" style="width:364px"> <?php $langs = cmsCore::getDirsList('/languages'); foreach ($langs as $lng) { echo '<option value="' . $lng . '" ' . ($config['lang'] == $lng ? 'selected="selected"' : '') . '>' . $lng . '</option>'; } ?> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SITE_LANGUAGE_CHANGE']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_VIEW_FORM_LANGUAGE_CHANGE']; ?> </span> </td> <td valign="top"> <label><input name="is_change_lang" type="radio" value="1" <?php if ($config['is_change_lang']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="is_change_lang" type="radio" value="0" <?php if (!$config['is_change_lang']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SITE_ON']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_ONLY_ADMINS']; ?> </span> </td> <td valign="top"> <label><input name="siteoff" type="radio" value="0" <?php if (!$config['siteoff']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="siteoff" type="radio" value="1" <?php if ($config['siteoff']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_DEBUG_ON']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_WIEW_DB_ERRORS']; ?> </span> </td> <td valign="top"> <label><input name="debug" type="radio" value="1" <?php if ($config['debug']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="debug" type="radio" value="0" <?php if (!$config['debug']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td valign="middle"> <strong><?php echo $_LANG['AD_WHY_STOP']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_VIEW_WHY_STOP']; ?> </span> </td> <td valign="top"><input name="offtext" type="text" id="offtext" value="<?php echo htmlspecialchars($config['offtext']); ?> " style="width:358px" /></td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_WATERMARK']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_WATERMARK_NAME']; ?> </span> </td> <td> <input name="wmark" type="text" id="wmark" value="<?php echo $config['wmark']; ?> " style="width:358px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_QUICK_CONFIG']; ?> </strong> <br /> <span class="hinttext"><?php echo $_LANG['AD_MODULE_CONFIG']; ?> </span> </td> <td valign="top"> <label><input name="fastcfg" type="radio" value="1" <?php if ($config['fastcfg']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="fastcfg" type="radio" value="0" <?php if (!$config['fastcfg']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_ONLINESTATS']; ?> </strong> </td> <td valign="top"> <label><input name="user_stats" type="radio" value="0" <?php if (!$config['user_stats']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_NO_ONLINESTATS']; ?> </label><br> <label><input name="user_stats" type="radio" value="1" <?php if ($config['user_stats'] == 1) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_YES_ONLINESTATS']; ?> </label><br> <label><input name="user_stats" type="radio" value="2" <?php if ($config['user_stats'] == 2) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_CRON_ONLINESTATS']; ?> </label> </td> </tr> </table> </div> <div id="home"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_MAIN_PAGE']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_MAIN_SITENAME']; ?> </span><br/> <span class="hinttext"><?php echo $_LANG['AD_BROWSER_TITLE']; ?> </span> </td> <td width="350" valign="top"> <input name="hometitle" type="text" id="hometitle" value="<?php echo htmlspecialchars($config['hometitle']); ?> " style="width:358px" /> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_KEY_WORDS']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_FROM_COMMA']; ?> </span> <div class="hinttext" style="margin-top:4px"><a style="color:#09C" href="http://tutorial.semonitor.ru/#5" target="_blank"><?php echo $_LANG['AD_WHAT_KEY_WORDS']; ?> </a></div> </td> <td> <textarea name="keywords" style="width:350px" rows="3" id="keywords"><?php echo $config['keywords']; ?> </textarea> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_DESCRIPTION']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_LESS_THAN']; ?> </span> <div class="hinttext" style="margin-top:4px"><a style="color:#09C" href="http://tutorial.semonitor.ru/#219" target="_blank"><?php echo $_LANG['AD_WHAT_DESCRIPTION']; ?> </a></div> </td> <td> <textarea name="metadesc" style="width:350px" rows="3" id="metadesc"><?php echo $config['metadesc']; ?> </textarea> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_MAIN_PAGE_COMPONENT']; ?> </strong> </td> <td width="350" valign="top"> <select name="homecom" style="width:358px"> <option value="" <?php if (!$config['homecom']) { ?> selected="selected"<?php } ?> ><?php echo $_LANG['AD_ONLY_MODULES']; ?> </option> <?php echo cmsCore::getListItems('cms_components', $config['homecom'], 'title', 'ASC', 'internal=0', 'link'); ?> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_GATE_PAGE']; ?> </strong> <br/> <span class="hinttext"><?php echo $_LANG['AD_FIRST_VISIT']; ?> </span> <br/> <span class="hinttext"><?php echo $_LANG['AD_FIRST_VISIT_TEMPLATE']; ?> </strong></span> </td> <td valign="top"> <label><input name="splash" type="radio" value="0" <?php if (!$config['splash']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['HIDE']; ?> </label> <label><input name="splash" type="radio" value="1" <?php if ($config['splash']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['SHOW']; ?> </label> </td> </tr> </table> </div> <div id="design"> <table width="720" border="0" cellpadding="5"> <tr> <td valign="top"> <div style="margin-top:2px"> <strong><?php echo $_LANG['TEMPLATE']; ?> :</strong><br /> <span class="hinttext"><?php echo $_LANG['AD_TEMPLATE_FOLDER']; ?> </span> </div> </td> <td> <select name="template" id="template" style="width:350px" onchange="document.CFGform.submit();"> <?php $templates = cmsCore::getDirsList('/templates'); foreach ($templates as $template) { echo '<option value="' . $template . '" ' . ($config['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>'; } $tpl_info = $inPage->getCurrentTplInfo(); ?> </select> <?php if (file_exists(PATH . '/templates/' . TEMPLATE . '/positions.jpg')) { ?> <script> $(function() { $('#pos').dialog({modal: true, autoOpen: false, closeText: LANG_CLOSE, width: 'auto'}); }); </script> <a onclick="$('#pos').dialog('open');return false;" href="#" class="ajaxlink"><?php echo $_LANG['AD_TPL_POS']; ?> </a> <div id="pos" title="<?php echo $_LANG['AD_TPL_POS']; ?> "><img src="/templates/<?php echo TEMPLATE; ?> /positions.jpg" alt="<?php echo $_LANG['AD_TPL_POS']; ?> " /></div> <?php } ?> <div style="margin-top:5px" class="hinttext"> <?php echo sprintf($_LANG['AD_TEMPLATE_INFO'], $tpl_info['author'], $tpl_info['renderer'], $tpl_info['ext']); ?> </div> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_SEARCH_RESULT']; ?> </strong></td> <td valign="top"> <label><input name="slight" type="radio" value="1" <?php if ($config['slight']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="slight" type="radio" value="0" <?php if (!$config['slight']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> </table> </div> <div id="time"> <table width="720" border="0" cellpadding="5"> <tr> <td valign="top" width="100"> <div style="margin-top:2px"> <strong><?php echo $_LANG['AD_TIME_ARREA']; ?> </strong> </div> </td> <td> <select name="timezone" id="timezone" style="width:350px"> <?php include PATH . '/admin/includes/timezones.php'; ?> <?php foreach ($timezones as $tz) { ?> <option value="<?php echo $tz; ?> " <?php if ($tz == $config['timezone']) { ?> selected="selected"<?php } ?> ><?php echo $tz; ?> </option> <?php } ?> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_TIME_SLIP']; ?> </strong> </td> <td width="350"> <select name="timediff" id="timediff" style="width:60px"> <?php for ($h = -12; $h <= 12; $h++) { ?> <option value="<?php echo $h; ?> " <?php if ($h == $config['timediff']) { ?> selected="selected"<?php } ?> ><?php echo $h > 0 ? '+' . $h : $h; ?> </option> <?php } ?> </select> </td> </tr> </table> </div> <div id="database"> <table width="720" border="0" cellpadding="5" style="margin-top:15px;"> <tr> <td> <strong><?php echo $_LANG['AD_DB_SIZE']; ?> </strong> </td> <td width="350"> <?php $result = $inDB->query("SELECT (sum(data_length)+sum(index_length))/1024/1024 as size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '{$config['db_base']}'", true); if (!$inDB->error()) { $s = $inDB->fetch_assoc($result); echo round($s['size'], 2) . ' ' . $_LANG['SIZE_MB']; } else { echo $_LANG['AD_DB_SIZE_ERROR']; } ?> </td> </tr> <tr> <td colspan="2"><span class="hinttext"><?php echo $_LANG['AD_MYSQL_CONFIG']; ?> </span></td> </tr> </table> </div> <div id="mail"> <table width="720" border="0" cellpadding="5" style="margin-top:15px;"> <tr> <td width="250"> <strong><?php echo $_LANG['AD_SITE_EMAIL']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_SITE_EMAIL_POST']; ?> </span> </td> <td> <input name="sitemail" type="text" id="sitemail" value="<?php echo $config['sitemail']; ?> " style="width:358px" /> </td> </tr> <tr> <td width="250"> <strong><?php echo $_LANG['AD_SENDER_EMAIL']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_IF_NOT_HANDLER']; ?> </span> </td> <td> <input name="sitemail_name" type="text" id="sitemail_name" value="<?php echo $config['sitemail_name']; ?> " style="width:358px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SEND_METHOD']; ?> </strong> </td> <td> <select name="mailer" style="width:354px"> <option value="mail" <?php if ($config['mailer'] == 'mail') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_PHP_MAILER']; ?> </option> <option value="sendmail" <?php if ($config['mailer'] == 'sendmail') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_SEND_MAILER']; ?> </option> <option value="smtp" <?php if ($config['mailer'] == 'smtp') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_SMTP_MAILER']; ?> </option> </select> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_ENCRYPTING']; ?> </strong> </td> <td> <label><input name="smtpsecure" type="radio" value="" <?php if (!$config['smtpsecure']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> <label><input name="smtpsecure" type="radio" value="tls" <?php if ($config['smtpsecure'] == 'tls') { echo 'checked="checked"'; } ?> /> tls</label> <label><input name="smtpsecure" type="radio" value="ssl" <?php if ($config['smtpsecure'] == 'ssl') { echo 'checked="checked"'; } ?> /> ssl</label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_LOGIN']; ?> </strong> </td> <td> <label><input name="smtpauth" type="radio" value="1" <?php if ($config['smtpauth']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="smtpauth" type="radio" value="0" <?php if (!$config['smtpauth']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_USER']; ?> </strong> </td> <td> <?php if (!$config['smtpuser']) { ?> <input name="smtpuser" type="text" id="smtpuser" value="<?php echo $config['smtpuser']; ?> " style="width:350px" /> <?php } else { ?> <span class="hinttext"><?php echo $_LANG['AD_IF_CHANGE_USER']; ?> </span> <?php } ?> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_PASS']; ?> </strong> </td> <td> <?php if (!$config['smtppass']) { ?> <input name="smtppass" type="password" id="smtppass" value="<?php echo $config['smtppass']; ?> " style="width:350px" /> <?php } else { ?> <span class="hinttext"><?php echo $_LANG['AD_IF_CHANGE_PASS']; ?> </span> <?php } ?> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_HOST']; ?> </strong><br> <span class="hinttext"><?php echo $_LANG['AD_SOME_HOST']; ?> </span> </td> <td> <input name="smtphost" type="text" id="smtphost" value="<?php echo $config['smtphost']; ?> " style="width:350px" /> </td> </tr> <tr> <td> <strong><?php echo $_LANG['AD_SMTP_PORT']; ?> </strong> </td> <td> <input name="smtpport" type="text" id="smtpport" value="<?php echo $config['smtpport']; ?> " style="width:350px" /> </td> </tr> </table> </div> <div id="other"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_VIEW_PATHWAY']; ?> </strong><br /> <span class="hinttext"> <?php echo $_LANG['AD_PATH_TO_CATEGORY']; ?> </span> </td> <td> <label><input name="show_pw" type="radio" value="1" <?php if ($config['show_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="show_pw" type="radio" value="0" <?php if (!$config['show_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_MAINPAGE_PATHWAY']; ?> </strong></td> <td> <label><input name="index_pw" type="radio" value="1" <?php if ($config['index_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['YES']; ?> </label> <label><input name="index_pw" type="radio" value="0" <?php if (!$config['index_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td><strong><?php echo $_LANG['AD_PAGE_PATHWAY']; ?> </strong></td> <td> <label><input name="last_item_pw" type="radio" value="0" <?php if (!$config['last_item_pw']) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['HIDE']; ?> </label> <label><input name="last_item_pw" type="radio" value="1" <?php if ($config['last_item_pw'] == 1) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_PAGE_PATHWAY_LINK']; ?> </label> <label><input name="last_item_pw" type="radio" value="2" <?php if ($config['last_item_pw'] == 2) { echo 'checked="checked"'; } ?> /><?php echo $_LANG['AD_PAGE_PATHWAY_TEXT']; ?> </label> </td> </tr> </table> </div> <div id="seq"> <table width="720" border="0" cellpadding="5"> <tr> <td> <strong><?php echo $_LANG['AD_IP_ADMIN']; ?> </strong> <br /> <span class="hinttext"><?php echo $_LANG['AD_IP_COMMA']; ?> </span></td> <td valign="top"> <input name="allow_ip" type="text" id="allow_ip" value="<?php echo htmlspecialchars($config['allow_ip']); ?> " style="width:358px" /></td> </tr> </table> <p style="color:#900"><?php echo $_LANG['AD_ATTENTION']; ?> </p> </div> <div align="left"> <input name="do" type="hidden" id="do" value="save" /> <input name="save" type="submit" id="save" value="<?php echo $_LANG['SAVE']; ?> " /> <input name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?> " onclick="window.history.back();" /> </div> </form> </div></div> <?php }
function applet_menu() { $inCore = cmsCore::getInstance(); $inDB = cmsDatabase::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) { cpAccessDenied(); } $GLOBALS['cp_page_title'] = $_LANG['AD_MENU']; cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu'); $do = cmsCore::request('do', 'str', 'list'); $id = cmsCore::request('id', 'int', -1); if ($do == 'list') { $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add'); $toolmenu[] = array('icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu'); $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=edit&multiple=1');"); $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');"); $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');"); $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');"); $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu'); cpToolMenu($toolmenu); $fields[] = array('title' => 'Lt', 'field' => 'NSLeft', 'width' => '30'); $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=menu&do=edit&id=%id%'); $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '60'); $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100'); $fields[] = array('title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById'); $fields[] = array('title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu'); $fields[] = array('title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '70', 'prc' => 'cpTemplateById'); $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%'); $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%'); cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering'); } else { $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'); $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu'); cpToolMenu($toolmenu); } if ($do == 'move_up') { $inDB->moveNsCategory('cms_menu', $id, 'up'); cmsCore::redirectBack(); } if ($do == 'move_down') { $inDB->moveNsCategory('cms_menu', $id, 'down'); cmsCore::redirectBack(); } if ($do == 'show') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { dbShow('cms_menu', $id); } echo '1'; exit; } else { dbShowList('cms_menu', $_REQUEST['item']); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirectBack(); } } if ($do == 'hide') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { dbHide('cms_menu', $id); } echo '1'; exit; } else { dbHideList('cms_menu', cmsCore::request('item', 'array_int', array())); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirectBack(); } } if ($do == 'delete') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { $inDB->deleteNS('cms_menu', (int) $id); } } else { $items = cmsCore::request('item', 'array_int', array()); foreach ($items as $item_id) { $inDB->deleteNS('cms_menu', $item_id); } } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirectBack(); } if ($do == 'update') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $id = cmsCore::request('id', 'int', 0); if (!$id) { cmsCore::redirectBack(); } $title = cmsCore::request('title', 'str', ''); $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', '')); $linktype = cmsCore::request('mode', 'str', ''); $linkid = cmsCore::request($linktype, 'str', ''); $link = $inCore->getMenuLink($linktype, $linkid); $target = cmsCore::request('target', 'str', ''); $published = cmsCore::request('published', 'int', 0); $template = cmsCore::request('template', 'str', ''); $iconurl = cmsCore::request('iconurl', 'str', ''); $parent_id = cmsCore::request('parent_id', 'int', 0); $oldparent = cmsCore::request('oldparent', 'int', 0); $is_lax = cmsCore::request('is_lax', 'int', 0); $css_class = cmsCore::request('css_class', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $ns = $inCore->nestedSetsInit('cms_menu'); if ($oldparent != $parent_id) { $ns->MoveNode($id, $parent_id); } $sql = "UPDATE cms_menu\n SET title='{$title}',\n css_class='{$css_class}',\n menu='{$menu}',\n link='{$link}',\n linktype='{$linktype}',\n linkid='{$linkid}',\n target='{$target}',\n published='{$published}',\n template='{$template}',\n access_list='{$access_list}',\n is_lax='{$is_lax}',\n iconurl='{$iconurl}'\n WHERE id = '{$id}'\n LIMIT 1"; $inDB->query($sql); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) { cmsCore::redirect('?view=menu'); } else { cmsCore::redirect('?view=menu&do=edit'); } } if ($do == 'submit') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $title = cmsCore::request('title', 'str', ''); $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', '')); $linktype = cmsCore::request('mode', 'str', ''); $linkid = cmsCore::request($linktype, 'str', ''); $link = $inCore->getMenuLink($linktype, $linkid); $target = cmsCore::request('target', 'str', ''); $published = cmsCore::request('published', 'int', 0); $template = cmsCore::request('template', 'str', ''); $iconurl = cmsCore::request('iconurl', 'str', ''); $parent_id = cmsCore::request('parent_id', 'int', 0); $css_class = cmsCore::request('css_class', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); $is_lax = cmsCore::request('is_lax', 'int', 0); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $ns = $inCore->nestedSetsInit('cms_menu'); $myid = $ns->AddNode($parent_id); $sql = "UPDATE cms_menu\n\t\t\t\tSET menu='{$menu}',\n\t\t\t\t\ttitle='{$title}',\n css_class='{$css_class}',\n\t\t\t\t\tlink='{$link}',\n\t\t\t\t\tlinktype='{$linktype}',\n\t\t\t\t\tlinkid='{$linkid}',\n\t\t\t\t\ttarget='{$target}',\n\t\t\t\t\tpublished='{$published}',\n\t\t\t\t\ttemplate='{$template}',\n\t\t\t\t\taccess_list='{$access_list}',\n\t\t\t\t\tis_lax='{$is_lax}',\n\t\t\t\t\ticonurl='{$iconurl}'\n\t\t\t\tWHERE id = '{$myid}'"; $inDB->query($sql); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('?view=menu'); } if ($do == 'submitmenu') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1"; $result = $inDB->query($sql); $row = $inDB->fetch_assoc($result); $maxorder = $row['max_o'] + 1; $menu = cmsCore::request('menu', 'str', ''); $title = cmsCore::request('title', 'str', ''); $position = cmsCore::request('position', 'str', ''); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $cfg['menu'] = $menu; $cfg_str = cmsCore::arrayToYaml($cfg); $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list)\n VALUES ('{$position}', '{$_LANG['AD_MENU']}', '{$title}', 1, 'mod_menu', {$maxorder}, 1, {$published}, 0, '{$cfg_str}', '{$css_prefix}', '{$access_list}')"; $inDB->query($sql); $newid = $inDB->get_last_id('cms_modules'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('?view=modules&do=edit&id=' . $newid); } if ($do == 'addmenu' || $do == 'add' || $do == 'edit') { $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>'; echo '<script>'; echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU'); echo '</script>'; } if ($do == 'addmenu') { $GLOBALS['cp_page_title'] = $_LANG['AD_MENU_ADD']; cpAddPathway($_LANG['AD_MENU_ADD']); $menu_list = cpGetList('menu'); ?> <form id="addform" name="addform" action="index.php?view=menu&do=submitmenu" method="post"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?> " /> <table class="proptable" width="650" cellspacing="10" cellpadding="10"> <tr> <td width="300" valign="top"> <strong><?php echo $_LANG['AD_MODULE_MENU_TITLE']; ?> </strong> </td> <td valign="top"> <input name="title" type="text" id="title2" style="width:99%" value=""/> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_MENU_TO_VIEW']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_TO_CREATE_NEW_POINT']; ?> </span> </td> <td valign="top"> <select name="menu" id="menu" style="width:99%"> <?php foreach ($menu_list as $menu) { ?> <option value="<?php echo $menu['id']; ?> "> <?php echo $menu['title']; ?> </option> <?php } ?> </select> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_POSITION_TO_VIEW']; ?> </strong><br /> <span class="hinttext"><?php echo $_LANG['AD_POSITION_MUST_BE']; ?> </span> </td> <td valign="top"> <?php $pos = cpModulePositions(cmsConfig::getConfig('template')); ?> <select name="position" id="position" style="width:99%"> <?php if ($pos) { foreach ($pos as $key => $position) { if (@$mod['position'] == $position) { echo '<option value="' . $position . '" selected>' . $position . '</option>'; } else { echo '<option value="' . $position . '">' . $position . '</option>'; } } } ?> </select> <input name="is_external" type="hidden" id="is_external" value="0" /> </td> </tr> <tr> <td valign="top"><strong><?php echo $_LANG['AD_MENU_PUBLIC']; ?> </strong></td> <td valign="top"> <label><input name="published" type="radio" value="1" checked="checked" <?php if (@$mod['published']) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['YES']; ?> </label> <label><input name="published" type="radio" value="0" <?php if (@(!$mod['published'])) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['NO']; ?> </label> </td> </tr> <tr> <td valign="top"><strong><?php echo $_LANG['AD_PREFIX_CSS']; ?> </strong></td> <td valign="top"> <input name="css_prefix" type="text" id="css_prefix" value="<?php echo @$mod['css_prefix']; ?> " style="width:99%" /> </td> </tr> <tr> <td valign="top"> <strong><?php echo $_LANG['AD_TAB_ACCESS']; ?> :</strong><br /> <span class="hinttext"><?php echo $_LANG['AD_GROUP_ACCESS']; ?> </span> </td> <td valign="top"> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px"> <tr> <td width="20"> <?php $groups = cmsUser::getGroups(); $style = 'disabled="disabled"'; $public = 'checked="checked"'; if ($do == 'edit') { if ($mod['access_list']) { $public = ''; $style = ''; $access_list = $inCore->yamlToArray($mod['access_list']); } } ?> <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> /> </td> <td><label for="is_public"><strong><?php echo $_LANG['AD_SHARE']; ?> </strong></label></td> </tr> </table> <div style="padding:5px"> <span class="hinttext"> <?php echo $_LANG['AD_VIEW_IF_CHECK']; ?> </span> </div> <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp"> <div> <strong><?php echo $_LANG['AD_GROUPS_VIEW']; ?> </strong><br /> <span class="hinttext"> <?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?> </span> </div> <div> <?php echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>'; if ($groups) { foreach ($groups as $group) { echo '<option value="' . $group['id'] . '"'; if ($do == 'edit') { if (inArray($access_list, $group['id'])) { echo 'selected="selected"'; } } echo '>'; echo $group['title'] . '</option>'; } } echo '</select>'; ?> </div> </div> </td> </tr> <tr> <td colspan="2" valign="top"> <div style="padding:10px;margin:4px;background-color:#EBEBEB;border:solid 1px gray"> <?php echo $_LANG['AD_NEW_MENU_NEW_MODULE']; ?> </div> </td> </tr> </table> <div style="margin-top:5px"> <input name="save" type="submit" id="save" value="<?php echo $_LANG['AD_MENU_ADD']; ?> " /> <input name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?> " onclick="window.location.href='index.php?view=menu';" /> </div> </form> <?php } if ($do == 'add' || $do == 'edit') { require '../includes/jwtabs.php'; $GLOBALS['cp_page_head'][] = jwHeader(); $menu_list = cpGetList('menu'); if ($do == 'add') { cpAddPathway($_LANG['AD_MENU_POINT_ADD']); $mod['menu'] = array('mainmenu'); } else { if (isset($_REQUEST['multiple'])) { if (isset($_REQUEST['item'])) { $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array()); } else { cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error'); cmsCore::redirectBack(); } } $ostatok = ''; if (isset($_SESSION['editlist'])) { $item_id = array_shift($_SESSION['editlist']); if (sizeof($_SESSION['editlist']) == 0) { unset($_SESSION['editlist']); } else { $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')'; } } else { $item_id = cmsCore::request('id', 'int', 0); } $mod = $inDB->get_fields('cms_menu', "id = '{$item_id}'", '*'); if (!$mod) { cmsCore::error404(); } $mod['menu'] = cmsCore::yamlToArray($mod['menu']); cpAddPathway($_LANG['AD_MENU_POINT_EDIT'] . $ostatok . ' "' . $mod['title'] . '"'); } ?> <form id="addform" name="addform" method="post" action="index.php"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?> " /> <input type="hidden" name="view" value="menu" /> <table class="proptable" width="100%" cellpadding="15" cellspacing="2"> <tr> <td valign="top"> <div><strong><?php echo $_LANG['AD_MENU_POINT_TITLE']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_VIEW_IN_SITE']; ?> </span></div> <div><input name="title" type="text" id="title" style="width:100%" value="<?php echo htmlspecialchars($mod['title']); ?> " /></div> <div><strong><?php echo $_LANG['AD_PARENT_POINT']; ?> </strong></div> <div> <?php $rootid = $inDB->get_field('cms_menu', 'parent_id=0', 'id'); ?> <select name="parent_id" size="10" id="parent_id" style="width:100%"> <option value="<?php echo $rootid; ?> " <?php if (@$mod['parent_id'] == $rootid || !isset($mod['parent_id'])) { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_MENU_ROOT']; ?> </option> <?php if (isset($mod['parent_id'])) { echo $inCore->getListItemsNS('cms_menu', $mod['parent_id']); } else { echo $inCore->getListItemsNS('cms_menu'); } ?> </select> <input type="hidden" name="oldparent" value="<?php echo @$mod['parent_id']; ?> " /> </div> <div><strong><?php echo $_LANG['AD_MENU_POINT_ACTION']; ?> </strong></div> <div> <select name="mode" id="linktype" style="width:100%" onchange="showMenuTarget()"> <option value="link" <?php if (@$mod['linktype'] == 'link' || !isset($mod['mode'])) { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_LINK']; ?> </option> <option value="content" <?php if (@$mod['linktype'] == 'content') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_ARTICLE']; ?> </option> <option value="category" <?php if (@$mod['linktype'] == 'category') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_PARTITION']; ?> </option> <?php if ($inCore->isComponentInstalled('video')) { ?> <option value="video_cat" <?php if (@$mod['linktype'] == 'video_cat') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_VIDEO_PARTITION']; ?> </option> <?php } ?> <option value="component" <?php if (@$mod['linktype'] == 'component') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_COMPONENT']; ?> </option> <option value="blog" <?php if (@$mod['linktype'] == 'blog') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_BLOG']; ?> </option> <option value="uccat" <?php if (@$mod['linktype'] == 'uccat') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_CATEGORY']; ?> </option> <option value="photoalbum" <?php if (@$mod['linktype'] == 'photoalbum') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_OPEN_ALBUM']; ?> </option> </select> </div> <div id="t_link" class="menu_target" style="display:<?php if ($mod['linktype'] == 'link' || $mod['linktype'] == 'ext' || !$mod['linktype']) { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_LINK']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_LINK_HINT']; ?> <b>http://</b></span> </div> <div> <input name="link" type="text" id="link" size="50" style="width:100%" <?php if (@$mod['linktype'] == 'link' || @$mod['linktype'] == 'ext') { echo 'value="' . $mod['link'] . '"'; } ?> /> </div> </div> <div id="t_content" class="menu_target" style="display:<?php if ($mod['linktype'] == 'content') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_ARTICLE']; ?> </strong> </div> <div> <select name="content" id="content" style="width:100%"> <?php if (@$mod['linktype'] == 'content') { echo $inCore->getListItems('cms_content', $mod['linkid']); } else { echo $inCore->getListItems('cms_content'); } ?> </select> </div> </div> <?php if ($inCore->isComponentInstalled('video')) { ?> <div id="t_video_cat" class="menu_target" style="display:<?php if ($mod['linktype'] == 'video_cat') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_PARTITION']; ?> </strong> </div> <div> <select name="video_cat" id="video_cat" style="width:100%"> <?php if (@$mod['linktype'] == 'video_cat') { echo $inCore->getListItemsNS('cms_video_category', $mod['linkid']); } else { echo $inCore->getListItemsNS('cms_video_category'); } ?> </select> </div> </div> <?php } ?> <div id="t_category" class="menu_target" style="display:<?php if ($mod['linktype'] == 'category') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_PARTITION']; ?> </strong> </div> <div> <select name="category" id="category" style="width:100%"> <?php if (@$mod['linktype'] == 'category') { echo $inCore->getListItemsNS('cms_category', $mod['linkid']); } else { echo $inCore->getListItemsNS('cms_category'); } ?> </select> </div> </div> <div id="t_component" class="menu_target" style="display:<?php if ($mod['linktype'] == 'component') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_COMPONENT']; ?> </strong> </div> <div> <select name="component" id="component" style="width:100%"> <?php if (@$mod['linktype'] == 'component') { echo $inCore->getListItems('cms_components', $mod['linkid'], 'title', 'asc', 'internal=0', 'link'); } else { echo $inCore->getListItems('cms_components', 0, 'title', 'asc', 'internal=0', 'link'); } ?> </select> </div> </div> <div id="t_blog" class="menu_target" style="display:<?php if ($mod['linktype'] == 'blog') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_BLOG']; ?> </strong> </div> <div> <select name="blog" id="blog" style="width:100%"> <?php if (@$mod['linktype'] == 'blog') { echo $inCore->getListItems('cms_blogs', $mod['linkid'], 'title', 'asc', "owner='user'"); } else { echo $inCore->getListItems('cms_blogs', 0, 'title', 'asc', "owner='user'"); } ?> </select> </div> </div> <div id="t_uccat" class="menu_target" style="display:<?php if ($mod['linktype'] == 'uccat') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_CATEGORY']; ?> </strong> </div> <div> <select name="uccat" id="uccat" style="width:100%"> <?php if (@$mod['linktype'] == 'uccat') { echo $inCore->getListItems('cms_uc_cats', $mod['linkid']); } else { echo $inCore->getListItems('cms_uc_cats'); } ?> </select> </div> </div> <div id="t_photoalbum" class="menu_target" style="display:<?php if ($mod['linktype'] == 'photoalbum') { echo 'block'; } else { echo 'none'; } ?> "> <div> <strong><?php echo $_LANG['AD_CHECK_ALBUM']; ?> </strong> </div> <div> <select name="photoalbum" id="photoalbum" style="width:100%"> <?php if (@$mod['linktype'] == 'photoalbum') { echo $inCore->getListItems('cms_photo_albums', $mod['linkid'], 'id', 'ASC', 'NSDiffer = ""'); } else { echo $inCore->getListItems('cms_photo_albums', 0, 'id', 'ASC', 'NSDiffer = ""'); } ?> </select> </div> </div> </td> <td width="300" valign="top" style="background:#ECECEC;"> <?php ob_start(); ?> {tab=<?php echo $_LANG['AD_TAB_PUBLISH']; ?> } <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist"> <tr> <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php if ($mod['published'] || $do == 'add') { echo 'checked="checked"'; } ?> /></td> <td><label for="published"><strong><?php echo $_LANG['AD_MENU_POINT_PUBLIC']; ?> </strong></label></td> </tr> </table> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_OPEN_POINT']; ?> </strong> </div> <div> <select name="target" id="target" style="width:100%"> <option value="_self" <?php if (@$mod['target'] == '_self') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_SELF']; ?> </option> <option value="_parent"><?php echo $_LANG['AD_PARENT']; ?> </option> <option value="_blank" <?php if (@$mod['target'] == '_blank') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_BLANK']; ?> </option> <option value="_top" <?php if (@$mod['target'] == '_top') { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_TOP']; ?> </option> </select> </div> <div style="margin-top:15px"> <strong><?php echo $_LANG['TEMPLATE']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_DESIGN_CHANGE']; ?> </span> </div> <div> <select name="template" id="template" style="width:100%"> <option value="0" <?php if (@$mod['template'] == 0 || !$mod['template']) { echo 'selected="selected"'; } ?> ><?php echo $_LANG['AD_BY_DEFAULT']; ?> </option> <?php $templates = cmsCore::getDirsList('/templates'); foreach ($templates as $template) { echo '<option value="' . $template . '" ' . (@$mod['template'] == $template ? 'selected="selected"' : '') . '>' . $template . '</option>'; } ?> </select> </div> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_ICON_PICTURE']; ?> </strong><br/> <span class="hinttext"><?php echo $_LANG['AD_ICON_FILENAME']; ?> </span> </div> <div> <input name="iconurl" type="text" id="iconurl" size="30" value="<?php echo @$mod['iconurl']; ?> " style="width:100%"/> <div> <a id="iconlink" style="display:block;" href="javascript:showIcons()"><?php echo $_LANG['AD_CHECK_ICON']; ?> </a> <div id="icondiv" style="display:none; padding:6px;border:solid 1px gray;background:#FFF"> <div><?php iconList(); ?> </div> </div> </div> </div> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_CSS_CLASS']; ?> </strong> </div> <div> <input name="css_class" type="text" size="30" value="<?php echo @$mod['css_class']; ?> " style="width:100%"/> </div> {tab=<?php echo $_LANG['AD_TAB_ACCESS']; ?> } <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px"> <tr> <td width="20"> <?php $groups = cmsUser::getGroups(); $style = 'disabled="disabled"'; $public = 'checked="checked"'; if ($do == 'edit') { if ($mod['access_list']) { $public = ''; $style = ''; $access_list = $inCore->yamlToArray($mod['access_list']); } } ?> <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> /> </td> <td><label for="is_public"><strong><?php echo $_LANG['AD_SHARE']; ?> </strong></label></td> </tr> </table> <div style="padding:5px"> <span class="hinttext"> <?php echo $_LANG['AD_VIEW_IF_CHECK']; ?> </span> </div> <div style="margin-top:10px;padding:5px;padding-right:0px;" id="grp"> <div> <strong><?php echo $_LANG['AD_GROUPS_VIEW']; ?> </strong><br /> <span class="hinttext"> <?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?> </span> </div> <div> <?php echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>'; if ($groups) { foreach ($groups as $group) { echo '<option value="' . $group['id'] . '"'; if ($do == 'edit' && $mod['access_list']) { if (inArray($access_list, $group['id'])) { echo 'selected="selected"'; } } echo '>'; echo $group['title'] . '</option>'; } } echo '</select>'; ?> </div> </div> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px"> <tr> <td width="20"> <input name="is_lax" type="checkbox" id="is_lax" value="1" <?php if (@$mod['is_lax']) { ?> checked="checked"<?php } ?> /> </td> <td><label for="is_lax"><strong><?php echo $_LANG['AD_ONLY_CHILD_ITEM']; ?> </strong></label></td> </tr> </table> {tab=<?php echo $_LANG['AD_MENU']; ?> } <div style="padding:5px;padding-right:0px;"> <div> <strong><?php echo $_LANG['AD_MENU_TO_VIEW']; ?> </strong><br /> <span class="hinttext"> <?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?> </span> </div> <div> <select style="width: 99%" name="menu[]" size="9" multiple="multiple"> <?php foreach ($menu_list as $menu) { ?> <option value="<?php echo $menu['id']; ?> " <?php if (@in_array($menu['id'], @$mod['menu'])) { echo 'selected="selected"'; } ?> > <?php echo $menu['title']; ?> </option> <?php } ?> </select> </div> </div> {/tabs} <?php echo jwTabs(ob_get_clean()); ?> </td> </tr> </table> <p> <input name="add_mod" type="button" onclick="submitItem()" id="add_mod" value="<?php echo $_LANG['SAVE']; ?> " /> <input name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?> " onclick="window.location.href='index.php?view=menu';" /> <input name="do" type="hidden" id="do" <?php if ($do == 'add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> /> <?php if ($do == 'edit') { echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />'; } ?> </p> </form> <?php } }
<?php /******************************************************************************/ /********************************CMS.VADYUS.COM********************************/ /******************************************************************************/ header('Content-Type: text/html; charset=utf-8'); Error_Reporting(E_ALL & ~E_NOTICE & ~E_WARNING); session_start(); define('PATH', dirname(__FILE__)); define("VALID_CMS", 1); include PATH . '/core/cms.php'; cmsCore::getInstance(); if (!cmsConfig::getConfig('is_change_lang')) { cmsCore::halt(); } $set_lang = cmsCore::request('lang', 'str', 'ru'); $langs = cmsCore::getDirsList('/languages'); if (!in_array($set_lang, $langs)) { cmsCore::halt(); } $_SESSION['lang'] = $set_lang; cmsCore::redirectBack();
/** * Возвращает список папок с модулями * @return array */ public static function getModulesDirs() { return cmsCore::getDirsList('/modules'); }
function applet_modules() { $inCore = cmsCore::getInstance(); $inDB = cmsDatabase::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cpAccessDenied(); } $GLOBALS['cp_page_title'] = $_LANG['AD_MODULES']; cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules'); $GLOBALS['cp_page_head'][] = '<script language="JavaScript" type="text/javascript" src="js/modules.js"></script>'; $do = cmsCore::request('do', 'str', 'list'); $id = cmsCore::request('id', 'int', -1); $co = cmsCore::request('co', 'int', -1); //============================================================================// //============================================================================// if ($do == 'config') { $module_name = cpModuleById($id); $module_title = cpModuleTitleById($id); if (!$module_name) { cmsCore::redirect('index.php?view=modules&do=edit&id=' . $id); } $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml'; $php_file = 'modules/' . $module_name . '/backend.php'; if (!file_exists($xml_file)) { if (file_exists($php_file)) { include $php_file; return; } cmsCore::halt(); } $cfg = $inCore->loadModuleConfig($id); cmsCore::loadClass('formgen'); $formGen = new cmsFormGen($xml_file, $cfg); cpAddPathway($module_title, '?view=modules&do=edit&id=' . $id); cpAddPathway($_LANG['AD_SETTINGS']); echo '<h3>' . $module_title . '</h3>'; $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();'); $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules'); $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id=' . $id); cpToolMenu($toolmenu); echo '<form action="index.php?view=modules&do=save_auto_config&id=' . $id . '" method="post" name="optform" target="_self" id="optform">'; echo $formGen->getHTML(); echo '</form>'; return; } //============================================================================// //============================================================================// if ($do == 'save_auto_config') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $module_name = cpModuleById($id); $is_ajax = cmsCore::inRequest('ajax'); if ($is_ajax) { $title = cmsCore::request('title', 'str', ''); $published = cmsCore::request('published', 'int', 0); $inDB->query("UPDATE cms_modules SET title='{$title}', published='{$published}' WHERE id={$id}"); if (cmsCore::inRequest('content')) { $content = $inDB->escape_string(cmsCore::request('content', 'html')); $inDB->query("UPDATE cms_modules SET content='{$content}' WHERE id={$id}"); } // Добавим возможность изменять css_префикс с фронта if (cmsCore::inRequest('css_prefix')) { // На шаблонах не не отдающих параметра затирать класс не будем $css_prefix = cmsCore::request('css_prefix', 'str', ''); $inDB->query("UPDATE cms_modules SET css_prefix='{$css_prefix}' WHERE id='{$id}'"); } } if (cmsCore::inRequest('title_only')) { cmsCore::redirectBack(); } $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml'; if (!file_exists($xml_file)) { cmsCore::halt(); } $cfg = array(); $backend = simplexml_load_file($xml_file); foreach ($backend->params->param as $param) { $name = (string) $param['name']; $type = (string) $param['type']; $default = (string) $param['default']; switch ($param['type']) { case 'number': $value = cmsCore::request($name, 'int', $default); break; case 'string': $value = cmsCore::request($name, 'str', $default); break; case 'html': $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default)); break; case 'flag': $value = cmsCore::request($name, 'int', 0); break; case 'list': $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default); break; case 'list_function': $value = cmsCore::request($name, 'str', $default); break; case 'list_db': $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default); break; } $cfg[$name] = $value; } $inCore->saveModuleConfig($id, $cfg); if (!$is_ajax) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } cmsCore::redirectBack(); } //============================================================================// //============================================================================// if ($do == 'list') { $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add'); $toolmenu[] = array('icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module'); $toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');"); $toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');"); $toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');"); $toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');"); $toolmenu[] = array('icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder'); $toolmenu[] = array('icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');"); $toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules'); cpToolMenu($toolmenu); $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30'); $fields[] = array('title' => $_LANG['AD_TITLE'], 'field' => array('title', 'titles'), 'width' => '', 'link' => '?view=modules&do=edit&id=%id%', 'prc' => function ($i) { $i['titles'] = cmsCore::yamlToArray($i['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($i['titles'][cmsConfig::getConfig('lang')])) { $i['title'] = $i['titles'][cmsConfig::getConfig('lang')]; } return $i['title']; }); $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15'); $fields[] = array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '55'); $fields[] = array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110'); $fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '65'); $fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '75'); $fields[] = array('title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('positions')); $actions[] = array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig'); $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%'); $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%'); cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC'); } //============================================================================// //============================================================================// if ($do == 'autoorder') { $rs = $inDB->query("SELECT id, position FROM cms_modules ORDER BY position"); if ($inDB->num_rows($rs)) { $ord = 1; while ($item = $inDB->fetch_assoc($rs)) { if (isset($latest_pos)) { if ($latest_pos != $item['position']) { $ord = 1; } } $inDB->query("UPDATE cms_modules SET ordering = {$ord} WHERE id='{$item['id']}'"); $ord += 1; $latest_pos = $item['position']; } } cmsCore::redirect('index.php?view=modules'); } //============================================================================// //============================================================================// if ($do == 'move_up') { if ($id >= 0) { dbMoveUp('cms_modules', $id, $co); } cmsCore::redirectBack(); } if ($do == 'move_down') { if ($id >= 0) { dbMoveDown('cms_modules', $id, $co); } cmsCore::redirectBack(); } //============================================================================// //============================================================================// if ($do == 'saveorder') { if (isset($_REQUEST['ordering'])) { $ord = $_REQUEST['ordering']; $ids = $_REQUEST['ids']; foreach ($ord as $id => $ordering) { $inDB->query("UPDATE cms_modules SET ordering = '" . (int) $ordering . "' WHERE id = '" . (int) $ids[$id] . "'"); } cmsCore::redirect('index.php?view=modules'); } } //============================================================================// //============================================================================// if ($do == 'show') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { dbShow('cms_modules', $id); } echo '1'; exit; } else { dbShowList('cms_modules', cmsCore::request('item', 'array_int', array())); cmsCore::redirectBack(); } } if ($do == 'hide') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { dbHide('cms_modules', $id); } echo '1'; exit; } else { dbHideList('cms_modules', cmsCore::request('item', 'array_int', array())); cmsCore::redirectBack(); } } if ($do == 'delete') { if (!isset($_REQUEST['item'])) { $inCore->removeModule($id); } else { $inCore->removeModule(cmsCore::request('item', 'array_int', array())); } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('index.php?view=modules'); } //============================================================================// //============================================================================// if ($do == 'update') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $id = cmsCore::request('id', 'int', 0); $name = cmsCore::request('name', 'str', ''); $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $position = cmsCore::request('position', 'str', ''); $showtitle = cmsCore::request('showtitle', 'int', 0); $content = $inDB->escape_string(cmsCore::request('content', 'html', '')); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0); $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array())); } $template = cmsCore::request('template', 'str', ''); $cache = cmsCore::request('cache', 'int', 0); $cachetime = cmsCore::request('cachetime', 'int', 0); $cacheint = cmsCore::request('cacheint', 'str', ''); $sql = "UPDATE cms_modules\r\n SET name='{$name}',\r\n title='{$title}',\r\n titles='{$titles}',\r\n position='{$position}',\r\n template='{$template}',\r\n showtitle={$showtitle},"; if ($content) { $sql .= "content='{$content}',"; } $sql .= "\r\n published={$published},\r\n css_prefix='{$css_prefix}',\r\n access_list='{$access_list}',\r\n hidden_menu_ids='',\r\n cachetime = '{$cachetime}',\r\n cacheint = '{$cacheint}',\r\n cache = '{$cache}',\r\n is_strict_bind = '{$is_strict_bind}',\r\n is_strict_bind_hidden = '{$is_strict_bind_hidden}'\r\n WHERE id = '{$id}'\r\n LIMIT 1"; $inDB->query($sql); $sql = "DELETE FROM cms_modules_bind WHERE module_id = {$id}"; $inDB->query($sql); if (cmsCore::request('show_all', 'int', 0)) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n VALUES ({$id}, 0, '{$position}')"; $inDB->query($sql); $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array()); if ($hidden_menu_ids) { $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids); $inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$id}' LIMIT 1"); } } else { $showin = cmsCore::request('showin', 'array_int', array()); $showpos = cmsCore::request('showpos', 'array_str', array()); if ($showin) { foreach ($showin as $key => $value) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n VALUES ({$id}, {$value}, '{$showpos[$value]}')"; $inDB->query($sql); } } } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) { cmsCore::redirect('index.php?view=modules'); } else { cmsCore::redirect('index.php?view=modules&do=edit'); } } //============================================================================// //============================================================================// if ($do == 'submit') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $sql = "SELECT ordering as max_o FROM cms_menu ORDER BY ordering DESC LIMIT 1"; $result = $inDB->query($sql); $row = $inDB->fetch_assoc($result); $maxorder = $row['max_o'] + 1; $name = cmsCore::request('name', 'str', ''); $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $position = cmsCore::request('position', 'str', ''); $showtitle = cmsCore::request('showtitle', 'int', 0); $content = $inDB->escape_string(cmsCore::request('content', 'html', '')); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array())); } $template = cmsCore::request('template', 'str', ''); $cache = cmsCore::request('cache', 'int', 0); $cachetime = cmsCore::request('cachetime', 'int', 0); $cacheint = cmsCore::request('cacheint', 'str', ''); $operate = cmsCore::request('operate', 'str', ''); $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0); $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0); if ($operate == 'user') { //USER MODULE $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden)\r\n\t\t\t\t\tVALUES ('{$position}', '{$name}', '{$title}', '{$titles}', 0, '{$content}', '{$maxorder}', '{$showtitle}', '{$published}', 1, 1, '{$css_prefix}', '{$access_list}', '{$template}', '{$is_strict_bind}', '{$is_strict_bind_hidden}')"; $inDB->query($sql); } if ($operate == 'clone') { //DUPLICATE MODULE $mod_id = cmsCore::request('clone_id', 'int', 0); $sql = "SELECT * FROM cms_modules WHERE id = {$mod_id} LIMIT 1"; $result = $inDB->query($sql); $original = $inDB->escape_string($inDB->fetch_assoc($result)); $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0; $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external,\r\n content, ordering, showtitle, published,\r\n original, user, config, css_prefix, template,\r\n access_list, is_strict_bind, is_strict_bind_hidden,\r\n cache, cachetime, cacheint, version)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t\t'{$position}',\r\n\t\t\t\t\t\t\t'{$original['name']}',\r\n\t\t\t\t\t\t\t'{$title}',\r\n\t\t\t\t\t\t\t'{$titles}',\r\n\t\t\t\t\t\t\t'{$original['is_external']}',\r\n\t\t\t\t\t\t\t'{$original['content']}',\r\n\t\t\t\t\t\t\t'{$maxorder}',\r\n\t\t\t\t\t\t\t'{$showtitle}',\r\n\t\t\t\t\t\t\t'{$published}',\r\n\t\t\t\t\t\t\t'{$is_original}',\r\n\t\t\t\t\t\t\t'{$original['user']}',\r\n\t\t\t\t\t\t\t'{$original['config']}',\r\n\t\t\t\t\t\t\t'{$css_prefix}',\r\n '{$template}',\r\n '{$access_list}',\r\n '{$is_strict_bind}',\r\n '{$is_strict_bind_hidden}',\r\n '{$cache}', '{$cachetime}', '{$cacheint}', '{$original['version']}'\r\n )"; $inDB->query($sql); if ($is_original) { $sql = "DELETE FROM cms_modules WHERE id = {$mod_id}"; $inDB->query($sql); } } $lastid = $inDB->get_last_id('cms_modules'); if (cmsCore::request('show_all', 'int', 0)) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n\t\t\t\t\tVALUES ({$lastid}, 0, '{$position}')"; $inDB->query($sql); $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array()); if ($hidden_menu_ids) { $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids); $inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$lastid}' LIMIT 1"); } } else { $showin = cmsCore::request('showin', 'array_int', array()); $showpos = cmsCore::request('showpos', 'array_str', array()); if ($showin) { foreach ($showin as $key => $value) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n\t\t\t\t\t\t\tVALUES ({$lastid}, {$value}, '{$showpos[$value]}')"; $inDB->query($sql); } } } cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'], 'success'); cmsCore::redirect('index.php?view=modules'); } //============================================================================// //============================================================================// if ($do == 'add' || $do == 'edit') { require '../includes/jwtabs.php'; $GLOBALS['cp_page_head'][] = jwHeader(); $langs = cmsCore::getDirsList('/languages'); if ($do == 'add') { cpAddPathway($_LANG['AD_MODULE_ADD']); echo '<h3>' . $_LANG['AD_MODULE_ADD'] . '</h3>'; $show_all = false; } else { if (isset($_REQUEST['multiple'])) { if (isset($_REQUEST['item'])) { $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array()); } else { cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error'); cmsCore::redirectBack(); } } $ostatok = ''; if (isset($_SESSION['editlist'])) { $item_id = array_shift($_SESSION['editlist']); if (sizeof($_SESSION['editlist']) == 0) { unset($_SESSION['editlist']); } else { $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')'; } } else { $item_id = cmsCore::request('id', 'int', 0); } $mod = $inDB->get_fields('cms_modules', "id = '{$item_id}'", '*'); if (!$mod) { cmsCore::error404(); } $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']); $mod['titles'] = cmsCore::yamlToArray($mod['titles']); $sql = "SELECT id FROM cms_modules_bind WHERE module_id = {$id} AND menu_id = 0 LIMIT 1"; $result = $inDB->query($sql); if ($inDB->num_rows($result)) { $show_all = true; } else { $show_all = false; } echo '<h3>' . $_LANG['AD_EDIT_MODULE'] . $ostatok . '</h3>'; cpAddPathway($mod['name']); } $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'); $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'); if (@$mod['is_external']) { $php_file = 'modules/' . $mod['content'] . '/backend.php'; $xml_file = 'modules/' . $mod['content'] . '/backend.xml'; if (file_exists($php_file) || file_exists($xml_file)) { $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id=' . $mod['id']); } } cpToolMenu($toolmenu); ?> <form id="addform" name="addform" method="post" action="index.php"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?> " /> <input type="hidden" name="view" value="modules" /> <table class="proptable" width="100%" cellpadding="15" cellspacing="2"> <tr> <!-- главная ячейка --> <td valign="top"> <div><strong><?php echo $_LANG['AD_MODULE_TITLE']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_VIEW_IN_SITE']; ?> </span></div> <div> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><input name="title" type="text" id="title" style="width:100%" value="<?php echo htmlspecialchars($mod['title']); ?> " /></td> <td style="width:15px;padding-left:10px;padding-right:0px;"> <input type="checkbox" title="<?php echo $_LANG['AD_VIEW_TITLE']; ?> " name="showtitle" <?php if ($mod['showtitle'] || $do == 'add') { echo 'checked="checked"'; } ?> value="1"> </td> </tr> </table> </div> <?php if (count($langs) > 1) { ?> <div><strong><?php echo $_LANG['AD_LANG_TITLES']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_LANG_TITLES_HINT']; ?> </span></div> <?php foreach ($langs as $lang) { ?> <div><strong><?php echo $lang; ?> :</strong> <input name="titles[<?php echo $lang; ?> ]" type="text" style="width:97%" value="<?php echo htmlspecialchars(@$mod['titles'][$lang]); ?> " placeholder="<?php echo $_LANG['AD_HINT_DEFAULT']; ?> " /></div> <?php } ?> <?php } ?> <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:10px;"> <tr> <td valign="top"> <div> <strong><?php echo $_LANG['AD_MODULE_NAME']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_SHOW_ADMIN']; ?> </span> </div> <div> <?php if (!isset($mod['user']) || @$mod['user'] == 1) { ?> <input name="name" type="text" id="name" style="width:99%" value="<?php echo htmlspecialchars($mod['name']); ?> " /> <?php } else { ?> <input name="" type="text" id="name" style="width:99%" value="<?php echo @$mod['name']; ?> " disabled="disabled" /> <input name="name" type="hidden" value="<?php echo htmlspecialchars($mod['name']); ?> " /> <?php } ?> </div> </td> <td valign="top" width="160" style="padding-left:10px;"> <div> <strong><?php echo $_LANG['AD_PREFIX_CSS']; ?> </strong> </div> <div> <input name="css_prefix" type="text" id="css_prefix" value="<?php echo @$mod['css_prefix']; ?> " style="width:154px" /> </div> </td> </tr> </table> <div style="margin-top:8px"> <strong><?php echo $_LANG['AD_DEFOLT_VIEW']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_POSITION_MUST_BE']; ?> </span> </div> <div> <?php $pos = cpModulePositions(cmsConfig::getConfig('template')); ?> <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;"> <tr> <td valign="top"> <select name="position" id="position" style="width:100%"> <?php if ($pos) { foreach ($pos as $key => $position) { if (@$mod['position'] == $position) { echo '<option value="' . $position . '" selected>' . $position . '</option>'; } else { echo '<option value="' . $position . '">' . $position . '</option>'; } } } ?> </select> </td> <?php if (file_exists(PATH . '/templates/' . TEMPLATE . '/positions.jpg')) { ?> <td valign="top" width="160" style="padding-left:10px;"> <script> $(function() { $('#pos').dialog({modal: true, autoOpen: false, closeText: LANG_CLOSE, width: 'auto'}); }); </script> <a onclick="$('#pos').dialog('open');return false;" href="#" class="ajaxlink"><?php echo $_LANG['AD_SEE_VISUALLY']; ?> </a> <div id="pos" title="<?php echo $_LANG['AD_TPL_POS']; ?> "><img src="/templates/<?php echo TEMPLATE; ?> /positions.jpg" alt="<?php echo $_LANG['AD_TPL_POS']; ?> " /></div> </td> <?php } ?> </tr> </table> </div> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_MODULE_TEMPLATE']; ?> </strong> <span class="hinttext">— <?php echo $_LANG['AD_FOLDER_MODULES']; ?> </span> </div> <div> <?php $tpls = cmsAdmin::getModuleTemplates(); ?> <select name="template" id="template" style="width:100%"> <?php foreach ($tpls as $tpl) { $selected = $mod['template'] == $tpl || !$mod['template'] && $tpl == 'module.tpl' ? 'selected="selected"' : ''; echo '<option value="' . $tpl . '" ' . $selected . '>' . $tpl . '</option>'; } ?> </select> </div> <?php if ($do == 'add') { ?> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_MODULE_TYPE']; ?> </strong> </div> <div> <select name="operate" id="operate" onchange="checkDiv()" style="width:100%"> <option value="user" selected="selected"><?php echo $_LANG['AD_MODULE_TYPE_NEW']; ?> </option> <option value="clone"><?php echo $_LANG['AD_MODULE_TYPE_COPY']; ?> </option> </select> </div> <?php } ?> <?php if (!isset($mod['user']) || $mod['user'] == 1 || $do == 'add') { ?> <div id="user_div"> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_MODULE_CONTENT']; ?> </strong> </div> <div><?php insertPanel(); ?> </div> <div> <?php $inCore->insertEditor('content', $mod['content'], '250', '100%'); ?> </div> </div> <?php } ?> <div id="clone_div" style="display:none;"> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_MODULE_COPY']; ?> </strong> </div> <div> <select name="clone_id" id="clone_id" style="width:100%"> <?php echo $inCore->getListItems('cms_modules'); ?> </select> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:6px"> <tr> <td width="20"><input type="checkbox" name="del_orig" id="del_orig" value="1" /></td> <td><label for="del_orig"><?php echo $_LANG['AD_ORIGINAL_MODULE_DELETE']; ?> </label></td> </tr> </table> </div> </div> </td> <!-- боковая ячейка --> <td width="300" valign="top" style="background:#ECECEC;"> <?php ob_start(); ?> {tab=<?php echo $_LANG['AD_TAB_PUBLISH']; ?> } <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist"> <tr> <td width="20"><input type="checkbox" name="published" id="published" value="1" <?php if ($mod['published'] || $do == 'add') { echo 'checked="checked"'; } ?> /></td> <td><label for="published"><strong><?php echo $_LANG['AD_MODULE_PUBLIC']; ?> </strong></label></td> </tr> <tr> <td width="20"><input name="show_all" id="show_all" type="checkbox" value="1" onclick="checkGroupList()" <?php if ($show_all) { echo 'checked'; } ?> /></td> <td><label for="show_all"><strong><?php echo $_LANG['AD_VIEW_ALL_PAGES']; ?> </strong></label></td> </tr> </table> <?php if ($do == 'edit') { $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = " . $mod['id']; $bind_res = $inDB->query($bind_sql); $bind = array(); $bind_pos = array(); while ($r = $inDB->fetch_assoc($bind_res)) { $bind[] = $r['menu_id']; $bind_pos[$r['menu_id']] = $r['position']; } } $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering"; $menu_res = $inDB->query($menu_sql); $menu_items = array(); if ($inDB->num_rows($menu_res)) { while ($item = $inDB->fetch_assoc($menu_res)) { if ($do == 'edit') { if (in_array($item['id'], $bind)) { $item['selected'] = true; $item['position'] = $bind_pos[$item['id']]; } } $item['titles'] = cmsCore::yamlToArray($item['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($item['titles'][cmsConfig::getConfig('lang')])) { $item['title'] = $item['titles'][cmsConfig::getConfig('lang')]; } $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']); $menu_items[] = $item; } } ?> <div id="grp"> <div style="margin-top:13px"> <strong class="show_list"><?php echo $_LANG['AD_WHERE_MODULE_VIEW']; ?> </strong> <strong class="hide_list"><?php echo $_LANG['AD_WHERE_MODULE_NOT_VIEW']; ?> </strong> </div> <div style="height:300px;overflow: auto;border: solid 1px #999; padding:5px 10px; background: #FFF;"> <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center"> <tr> <td colspan="2" height="25"><strong><?php echo $_LANG['AD_MENU']; ?> </strong></td> <td class="show_list" align="center" width="50"><strong><?php echo $_LANG['AD_POSITION']; ?> </strong></td> </tr> <?php foreach ($menu_items as $i) { ?> <tr class="show_list"> <td width="20" height="25"> <input type="checkbox" name="showin[]" id="mid<?php echo $i['id']; ?> " value="<?php echo $i['id']; ?> " <?php if ($i['selected']) { ?> checked="checked"<?php } ?> onclick="$('#p<?php echo $i['id']; ?> ').toggle()"/> </td> <td style="padding-left:<?php echo $i['NSLevel'] * 6 - 6; ?> px"><label for="mid<?php echo $i['id']; ?> "><?php echo $i['title']; ?> </label></td> <td align="center"> <select id="p<?php echo $i['id']; ?> " name="showpos[<?php echo $i['id']; ?> ]" style="<?php if (!$i['selected']) { ?> display:none<?php } ?> "> <?php foreach ($pos as $position) { ?> <option value="<?php echo $position; ?> " <?php if ($i['position'] == $position) { ?> selected="selected"<?php } ?> ><?php echo $position; ?> </option> <?php } ?> </select> </td> </tr> <?php } ?> <?php foreach ($menu_items as $it) { ?> <tr class="hide_list"> <td width="20" height="25"> <input type="checkbox" name="hidden_menu_ids[]" id="hmid<?php echo $it['id']; ?> " value="<?php echo $it['id']; ?> " <?php if (in_array($it['id'], $mod['hidden_menu_ids'])) { ?> checked="checked"<?php } ?> /> </td> <td style="padding-left:<?php echo $it['NSLevel'] * 6 - 6; ?> px"><label for="hmid<?php echo $it['id']; ?> "><?php echo $it['title']; ?> </label></td> </tr> <?php } ?> </table> </div> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist show_list"> <tr> <td width="20"><input type="checkbox" name="is_strict_bind" id="is_strict_bind" value="1" <?php if ($mod['is_strict_bind']) { echo 'checked="checked"'; } ?> /></td> <td><label for="is_strict_bind"><strong><?php echo $_LANG['AD_DONT_VIEW']; ?> </strong></label></td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist hide_list"> <tr> <td width="20"><input type="checkbox" name="is_strict_bind_hidden" id="is_strict_bind_hidden" value="1" <?php if ($mod['is_strict_bind_hidden']) { echo 'checked="checked"'; } ?> /></td> <td><label for="is_strict_bind_hidden"><strong><?php echo $_LANG['AD_EXCEPT_NESTED']; ?> </strong></label></td> </tr> </table> </div> <?php if ($mod['is_external'] && $do == 'edit' || $do == 'add') { ?> {tab=<?php echo $_LANG['AD_MODULE_CACHE']; ?> } <div style="margin-top:4px"> <strong><?php echo $_LANG['AD_DO_MODULE_CACHE']; ?> </strong> </div> <div> <select name="cache" id="cache" style="width:100%"> <option value="0" <?php if (@(!$mod['cache'])) { echo 'selected="selected"'; } ?> ><?php echo $_LANG['NO']; ?> </option> <option value="1" <?php if (@$mod['cache']) { echo 'selected="selected"'; } ?> ><?php echo $_LANG['YES']; ?> </option> </select> </div> <div style="margin-top:15px"> <strong><?php echo $_LANG['AD_MODULE_CACHE_PERIOD']; ?> </strong> </div> <div> <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;"> <tr> <td valign="top" width="100"> <input name="cachetime" type="text" id="int_1" style="width:99%" value="<?php echo @(int) $mod['cachetime']; ?> "/> </td> <td valign="top" style="padding-left:5px"> <select name="cacheint" id="int_2" style="width:100%"> <option value="MINUTE" <?php if (@mb_strstr($mod['cacheint'], 'MINUTE')) { echo 'selected="selected"'; } ?> ><?php echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false); ?> </option> <option value="HOUR" <?php if (@mb_strstr($mod['cacheint'], 'HOUR')) { echo 'selected="selected"'; } ?> ><?php echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false); ?> </option> <option value="DAY" <?php if (@mb_strstr($mod['cacheint'], 'DAY')) { echo 'selected="selected"'; } ?> ><?php echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false); ?> </option> <option value="MONTH" <?php if (@mb_strstr($mod['cacheint'], 'MONTH')) { echo 'selected="selected"'; } ?> ><?php echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false); ?> </option> </select> </td> </tr> </table> </div> <div style="margin-top:15px"> <?php if ($do == 'edit') { if ($inCore->isCached('module', $mod['id'], $mod['cachetime'], $mod['cacheint'])) { $t = 'module' . $mod['id']; $cfile = PATH . '/cache/' . md5($t) . '.html'; if (file_exists($cfile)) { $kb = round(filesize($cfile) / 1024, 2); echo '<a href="index.php?view=cache&do=delcache&target=module&id=' . $mod['id'] . '">' . $_LANG['AD_MODULE_CACHE_DELETE'] . '</a> (' . $kb . $_LANG['SIZE_KB'] . ')'; } } else { echo '<span style="color:gray">' . $_LANG['AD_NO_CACHE'] . '</span>'; } } ?> </div> <?php } ?> {tab=<?php echo $_LANG['AD_TAB_ACCESS']; ?> } <table width="100%" cellpadding="0" cellspacing="0" border="0" class="checklist" style="margin-top:5px"> <tr> <td width="20"> <?php $groups = cmsUser::getGroups(); $style = 'disabled="disabled"'; $public = 'checked="checked"'; if ($do == 'edit') { if ($mod['access_list']) { $public = ''; $style = ''; $access_list = $inCore->yamlToArray($mod['access_list']); } } ?> <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> /> </td> <td><label for="is_public"><strong><?php echo $_LANG['AD_SHARE']; ?> </strong></label></td> </tr> </table> <div style="padding:5px"> <span class="hinttext"> <?php echo $_LANG['AD_IF_CHECKED']; ?> </span> </div> <div style="margin-top:10px;padding:5px;padding-right:0px;"> <div> <strong><?php echo $_LANG['AD_GROUPS_VIEW']; ?> </strong><br /> <span class="hinttext"> <?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?> </span> </div> <div> <?php echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" ' . $style . '>'; if ($groups) { foreach ($groups as $group) { echo '<option value="' . $group['id'] . '"'; if ($do == 'edit' && $mod['access_list']) { if (inArray($access_list, $group['id'])) { echo 'selected="selected"'; } } echo '>'; echo $group['title'] . '</option>'; } } echo '</select>'; ?> </div> </div> {/tabs} <?php echo jwTabs(ob_get_clean()); ?> </td> </tr> </table> <p> <input name="add_mod" type="submit" id="add_mod" value="<?php echo $_LANG['SAVE']; ?> " /> <input name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?> " onclick="window.history.back();" /> <input name="do" type="hidden" id="do" <?php if ($do == 'add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> /> <?php if ($do == 'edit') { echo '<input name="id" type="hidden" value="' . $mod['id'] . '" />'; } ?> </p> </form> <?php } //============================================================================// //============================================================================// }
function mod_template() { cmsPage::initTemplate('modules', 'mod_template')->assign('current_template', isset($_SESSION['template']) ? $_SESSION['template'] : '')->assign('templates', cmsCore::getDirsList('/templates'))->display('mod_template.tpl'); return true; }
/** * Генерирует html код поля <select> из списка названий директорий в указанной папке * @param array $field Массив параметров, вдобавок к стандартным (name, title...) * обязательно должен быть указан параметр path содержащую ссылку на папку * относительно корня сайта * @return boolean|array */ private function dir_list($field) { if (empty($field['name']) || empty($field['path'])) { return false; } $field['path'] = rtrim($field['path'], '/'); if (!file_exists(PATH . $field['path']) || !is_dir(PATH . $field['path'])) { return false; } $this->fields['select']['count']++; $selected = $this->getValue($field); if (!is_array($selected)) { $selected = array($selected); } $attr_field = $field; unset($attr_field['path']); $html = '<select id="'. $this->fields['select']['class'] .'_'. $this->fields['select']['count'] .'" class="form-control '. $this->fields['select']['class'] .' '. cmsCore::getArrVal($field, 'class', '') .'"'. $this->getStyle(cmsCore::getArrVal($field, 'style', false)) .''. $this->getOtherAttributes($field) .' name="'. $this->name_prefix . $field['name'] .'">' ."\n"; $dirs = cmsCore::getDirsList($field['path'] .'/'); if (!empty($dirs)) { foreach ($dirs as $dir) { $html .= ' <option value="'. htmlspecialchars($dir) .'"'. (in_array($dir, $selected) ? ' selected="selected"' : '') .'>'. $dir .'</option>'. "\n"; } } $html .= '</select>'; return array( 'type' => $field['type'], 'title' => $this->getTD($field, 'title', 'dir_list', $field['name']), 'description' => $this->getTD($field, 'description', 'dir_list', $field['name']), 'html' => $html ); }
function applet_modules() { $inCore = cmsCore::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_MODULES']); cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules'); cmsCore::c('page')->addHeadJS('admin/js/modules.js'); $do = cmsCore::request('do', 'str', 'list'); $id = cmsCore::request('id', 'int', -1); $co = cmsCore::request('co', 'int', -1); if ($do == 'config') { $module_name = cpModuleById($id); $module_title = cpModuleTitleById($id); if (!$module_name) { cmsCore::redirect('index.php?view=modules&do=edit&id='. $id); } $xml_file = PATH .'/admin/modules/'. $module_name .'/backend.xml'; $php_file = 'modules/'. $module_name .'/backend.php'; if (file_exists($php_file)) { include $php_file; return; } $cfg = $inCore->loadModuleConfig($id); cpAddPathway($module_title, '?view=modules&do=edit&id='. $id); cpAddPathway($_LANG['AD_SETTINGS']); echo '<h3>'. $module_title .'</h3>'; $toolmenu = array( array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();' ), array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules' ), array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id='. $id ) ); cpToolMenu($toolmenu); ?> <form action="index.php?view=modules&do=save_auto_config&id=<?php echo $id; ?>" method="post" name="optform" target="_self" id="optform"> <div class="panel panel-default" style="width:650px;"> <div class="panel-body"> <?php if (file_exists($xml_file)) { cmsCore::loadClass('formgen'); $formGen = new cmsFormGen($xml_file, $cfg); echo $formGen->getHTML(); } else { ?> <div class="form-group"> <label class="col-sm-5 control-label"><?php echo $_LANG['AD_MODULE_TEMPLATE']; ?></label> <div class="col-sm-7"> <input type="text" class="form-control" value="<?php echo $cfg['tpl']; ?>" /> </div> </div> <?php } ?> </div> <div class="panel-footer"> <input type="submit" name="save" class="btn btn-primary" value="<?php echo $_LANG['SAVE']; ?>" /> </div> </div> <script type="text/javascript"> function submitModuleConfig(){ $('#optform').submit(); } </script> </form> <?php return; } if ($do == 'save_auto_config') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $module_name = cpModuleById($id); $is_ajax = cmsCore::inRequest('ajax'); if ($is_ajax) { $title = cmsCore::request('title', 'str', ''); $published = cmsCore::request('published', 'int', 0); cmsCore::c('db')->query("UPDATE cms_modules SET title='". $title ."', published='". $published ."' WHERE id=". $id); if (cmsCore::inRequest('content')) { $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html')); cmsCore::c('db')->query("UPDATE cms_modules SET content='". $content ."' WHERE id=". $id); } } if (cmsCore::inRequest('title_only')) { cmsCore::redirectBack(); } $xml_file = PATH .'/admin/modules/'. $module_name .'/backend.xml'; if (file_exists($xml_file)) { $cfg = array(); $backend = simplexml_load_file($xml_file); foreach ($backend->params->param as $param) { $name = (string)$param['name']; $type = (string)$param['type']; $default = (string)$param['default']; switch($param['type']) { case 'number': $value = cmsCore::request($name, 'int', $default); break; case 'string': $value = cmsCore::request($name, 'str', $default); break; case 'html': $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default)); break; case 'flag': $value = cmsCore::request($name, 'int', 0); break; case 'list': $value = (is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default)); break; case 'list_function': $value = cmsCore::request($name, 'str', $default); break; case 'list_db': $value = (is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default)); break; } $cfg[$name] = $value; } } $cfg['tpl'] = cmsCore::request('tpl', 'str', $module_name); $inCore->saveModuleConfig($id, $cfg); if (!$is_ajax) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } cmsCore::redirectBack(); } if ($do == 'list') { $toolmenu = array( array( 'icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add' ), array( 'icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module' ), array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');" ), array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');" ), array( 'icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');" ), array( 'icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');" ), array( 'icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder' ), array( 'icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');" ), array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules' ) ); cpToolMenu($toolmenu); $fields = array( array( 'title' => 'id', 'field' => 'id', 'width' => '40' ), array( 'title' => $_LANG['AD_TITLE'], 'field' => array('title','titles'), 'width'=>'', 'link' => '?view=modules&do=edit&id=%id%', 'prc' => function ($i) { $i['titles'] = cmsCore::yamlToArray($i['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($i['titles'][cmsConfig::getConfig('lang')])) { $i['title'] = $i['titles'][cmsConfig::getConfig('lang')]; } return $i['title']; } ), array( 'title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15' ), array( 'title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '70' ), array( 'title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110' ), array( 'title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80' ), array( 'title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100' ), array( 'title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('positions') ) ); $actions = array( array( 'title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig' ), array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%' ), array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%' ) ); cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC'); } if ($do == 'autoorder'){ $rs = cmsCore::c('db')->query("SELECT id, position FROM cms_modules ORDER BY position") ; if (cmsCore::c('db')->num_rows($rs)) { $ord = 1; while ($item = cmsCore::c('db')->fetch_assoc($rs)) { if (isset($latest_pos)) { if ($latest_pos != $item['position']) { $ord = 1; } } cmsCore::c('db')->query("UPDATE cms_modules SET ordering = ". $ord ." WHERE id=". $item['id']) ; $ord += 1; $latest_pos = $item['position']; } } cmsCore::redirect('index.php?view=modules'); } if ($do == 'move_up') { if ($id >= 0) { dbMoveUp('cms_modules', $id, $co); } cmsCore::redirectBack(); } if ($do == 'move_down') { if ($id >= 0) { dbMoveDown('cms_modules', $id, $co); } cmsCore::redirectBack(); } if ($do == 'saveorder') { if (isset($_REQUEST['ordering'])) { $ord = $_REQUEST['ordering']; $ids = $_REQUEST['ids']; foreach ($ord as $id=>$ordering) { cmsCore::c('db')->query("UPDATE cms_modules SET ordering = ". (int)$ordering ." WHERE id = ". (int)$ids[$id]); } cmsCore::redirect('index.php?view=modules'); } } if ($do == 'show') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '1'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '1'); cmsCore::redirectBack(); } } if ($do == 'hide') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '0'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '0'); cmsCore::redirectBack(); } } if ($do == 'delete') { if (!cmsCore::inRequest('item')) { $inCore->removeModule($id); } else { $inCore->removeModule(cmsCore::request('item', 'array_int', array())); } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('index.php?view=modules'); } if ($do == 'update') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $id = cmsCore::request('id', 'int', 0); $mod = cmsCore::c('db')->get_fields('cms_modules', "id = ". $id ."", '*'); $module = array( 'name' => cmsCore::request('name', 'str', ''), 'title' => cmsCore::request('title', 'str', ''), 'titles' => cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())), 'position' => cmsCore::request('position', 'str', ''), 'showtitle' => cmsCore::request('showtitle', 'int', 0), 'published' => cmsCore::request('published', 'int', 0), 'css_prefix' => cmsCore::request('css_prefix', 'str', ''), 'is_strict_bind' => cmsCore::request('is_strict_bind', 'int', 0), 'is_strict_bind_hidden' => cmsCore::request('is_strict_bind_hidden', 'int', 0), 'template' => cmsCore::request('template', 'str', ''), 'cache' => cmsCore::request('cache', 'int', 0), 'cachetime' => cmsCore::request('cachetime', 'int', 0), 'cacheint' => cmsCore::request('cacheint', 'str', ''), 'access_list' => '', 'hidden_menu_ids' => '' ); if (!$mod['is_external']) { $module['content'] = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', '')); } $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $module['access_list'] = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array())); } cmsCore::c('db')->update('cms_modules', $module, $id); cmsCore::c('db')->delete('cms_modules_bind', "module_id=". $id ." AND tpl='". cmsCore::c('config')->template ."'"); if (cmsCore::request('show_all', 'int', 0)) { cmsCore::c('db')->insert( 'cms_modules_bind', array( 'module_id' => $id, 'menu_id' => 0, 'position' => $module['position'], 'tpl' => cmsCore::c('config')->template ) ); $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array()); if (!empty($hidden_menu_ids)) { $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids); cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='". $hidden_menu_ids ."' WHERE id = '". $id ."' LIMIT 1"); } } else { $showin = cmsCore::request('showin', 'array_int', array()); $showpos = cmsCore::request('showpos', 'array_str', array()); if (count($showin) > 0) { foreach ($showin as $key => $value) { cmsCore::c('db')->insert( 'cms_modules_bind', array( 'module_id' => $id, 'menu_id' => $value, 'position' => $showpos[$value], 'tpl' => cmsCore::c('config')->template ) ); } } } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) { cmsCore::redirect('index.php?view=modules'); } else { cmsCore::redirect('index.php?view=modules&do=edit'); } } if ($do == 'submit') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $maxorder = cmsCore::c('db')->get_field('cms_menu', '1=1 ORDER BY ordering DESC', 'ordering') + 1; $name = cmsCore::request('name', 'str', ''); $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $position = cmsCore::request('position', 'str', ''); $showtitle = cmsCore::request('showtitle', 'int', 0); $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', '')); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array())); } $template = cmsCore::request('template', 'str', ''); $cache = cmsCore::request('cache', 'int', 0); $cachetime = cmsCore::request('cachetime', 'int', 0); $cacheint = cmsCore::request('cacheint', 'str', ''); $operate = cmsCore::request('operate', array('user', 'clone'), ''); $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0); $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0); if ($operate == 'user') { //USER MODULE $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden) VALUES ('". $position ."', '". $name ."', '". $title ."', '". $titles ."', 0, '". $content ."', '". $maxorder ."', '". $showtitle ."', '". $published ."', 1, 1, '". $css_prefix ."', '". $access_list ."', '". $template ."', '". $is_strict_bind ."', '". $is_strict_bind_hidden ."')"; cmsCore::c('db')->query($sql) ; } if ($operate == 'clone') { //DUPLICATE MODULE $mod_id = cmsCore::request('clone_id', 'int', 0); $sql = "SELECT * FROM cms_modules WHERE id = ". $mod_id ." LIMIT 1"; $result = cmsCore::c('db')->query($sql) ; $original = cmsCore::c('db')->escape_string(cmsCore::c('db')->fetch_assoc($result)); $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0; $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, original, user, config, css_prefix, template, access_list, is_strict_bind, is_strict_bind_hidden, cache, cachetime, cacheint, version) VALUES ( '". $position ."', '". $original['name'] ."', '". $title ."', '". $titles ."', '". $original['is_external'] ."', '". $original['content'] ."', '". $maxorder ."', '". $showtitle ."', '". $published ."', '". $is_original ."', '". $original['user'] ."', '". $original['config'] ."', '". $css_prefix ."', '". $template ."', '". $access_list ."', '". $is_strict_bind ."', '". $is_strict_bind_hidden ."', '". $cache ."', '". $cachetime ."', '". $cacheint ."', '". $original['version'] ."' )"; cmsCore::c('db')->query($sql); if (cmsCore::request('del_orig', 'int', 0)) { $sql = "DELETE FROM cms_modules WHERE id = ". $mod_id; cmsCore::c('db')->query($sql) ; } } $lastid = cmsCore::c('db')->get_last_id('cms_modules'); if (cmsCore::request('show_all', 'int', 0)) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl) VALUES (". $lastid .", 0, '". $position ."', '". cmsCore::c('config')->template ."')"; cmsCore::c('db')->query($sql) ; $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array()); if ($hidden_menu_ids) { $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids); cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='". $hidden_menu_ids ."' WHERE id = '". $lastid ."' LIMIT 1"); } } else { $showin = cmsCore::request('showin', 'array', array()); $showpos = cmsCore::request('showpos', 'array', array()); if (count($showin) > 0) { foreach ($showin as $key=>$value) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl) VALUES (". $lastid .", ". $value .", '". $showpos[$value] ."', '". cmsCore::c('config')->template ."')"; cmsCore::c('db')->query($sql) ; } } } cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'] , 'success'); cmsCore::redirect('index.php?view=modules'); } if ($do == 'add' || $do == 'edit') { $langs = cmsCore::getDirsList('/languages'); if ($do == 'add') { cpAddPathway($_LANG['AD_MODULE_ADD']); echo '<h3>'. $_LANG['AD_MODULE_ADD'] .'</h3>'; $show_all = false; } else { if (cmsCore::inRequest('multiple')) { if (cmsCore::inRequest('item')) { $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array()); } else { cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error'); cmsCore::redirectBack(); } } $ostatok = ''; if (isset($_SESSION['editlist'])) { $item_id = array_shift($_SESSION['editlist']); if (count($_SESSION['editlist'])==0) { unset($_SESSION['editlist']); } else { $ostatok = '('. $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) .')'; } } else { $item_id = cmsCore::request('id', 'int', 0); } $mod = cmsCore::c('db')->get_fields('cms_modules', "id = '". $item_id ."'", '*'); if (!$mod) { cmsCore::error404(); } $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']); $mod['titles'] = cmsCore::yamlToArray($mod['titles']); $show_all = false; $default_position = cmsCore::c('db')->get_field('cms_modules_bind', "module_id='". $mod['id'] ."' AND menu_id=0 AND tpl='". cmsCore::c('config')->template ."'", 'position'); if (!empty($default_position)) { $show_all = true; $mod['position'] = $default_position; } echo '<h3>'. $_LANG['AD_EDIT_MODULE'] . $ostatok .'</h3>'; cpAddPathway($mod['name']); } $toolmenu[] = array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ); $toolmenu[] = array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);' ); if (cmsCore::getArrVal($mod, 'is_external')) { $php_file = 'modules/'. $mod['content'] .'/backend.php'; $xml_file = 'modules/'. $mod['content'] .'/backend.xml'; if (file_exists($php_file) || file_exists($xml_file)) { $toolmenu[] = array( 'icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id='. $mod['id'] ); } } cpToolMenu($toolmenu); ?> <form id="addform" name="addform" method="post" action="index.php"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" /> <input type="hidden" name="view" value="modules" /> <table class="table"> <tr><td> <div class="panel panel-default"> <div class="panel-body"> <div class="form-group"> <label><?php echo $_LANG['AD_MODULE_TITLE']; ?> (<input type="checkbox" class="uittip" title="<?php echo $_LANG['AD_VIEW_TITLE'];?>" name="showtitle" <?php if ($mod['showtitle'] || $do == 'add') { echo 'checked="checked"'; } ?> value="1" />)</label> <input type="text" id="title" class="form-control" style="width:100%" name="title" value="<?php echo htmlspecialchars($mod['title']);?>" /> <div class="help-block"><?php echo $_LANG['AD_VIEW_IN_SITE']; ?></div> </div> <?php if (count($langs) > 1) { ?> <label><?php echo $_LANG['AD_LANG_TITLES']; ?></label> <?php foreach ($langs as $lang) { ?> <div> <strong><?php echo $lang; ?>:</strong> <input name="titles[<?php echo $lang; ?>]" type="text" style="width:97%" value="<?php echo htmlspecialchars($mod['titles'][$lang]); ?>" placeholder="<?php echo $_LANG['AD_HINT_DEFAULT']; ?>" /> </div> <?php } ?> <div class="help-block"><?php echo $_LANG['AD_LANG_TITLES_HINT']; ?></div> <?php } ?> <div class="form-group"> <label><?php echo $_LANG['AD_MODULE_NAME']; ?></label> <?php if (!isset($mod['user']) || @$mod['user'] == 1) { ?> <input type="text" id="name" class="form-control" style="width:99%" name="name" value="<?php echo htmlspecialchars($mod['name']);?>" /> <?php } else { ?> <input type="text" id="name" class="form-control" style="width:99%" name="" value="<?php echo @$mod['name'];?>" disabled="disabled" /> <input type="hidden" name="name" value="<?php echo htmlspecialchars($mod['name']);?>" /> <?php } ?> <div class="help-block"><?php echo $_LANG['AD_SHOW_ADMIN']; ?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_PREFIX_CSS']; ?></label> <input type="text" id="css_prefix" class="form-control" style="width:154px" name="css_prefix" value="<?php echo @$mod['css_prefix'];?>" /> </div> <div class="form-group"> <label><?php echo $_LANG['AD_DEFOLT_VIEW']; ?></label> <?php $pos = cpModulePositions(cmsConfig::getConfig('template')); ?> <select id="position" class="form-control" style="width:100%" name="position"> <?php if ($pos){ foreach($pos as $key=>$position) { if (@$mod['position']==$position) { echo '<option value="'.$position.'" selected>'.$position.'</option>'; } else { echo '<option value="'.$position.'">'.$position.'</option>'; } } } ?> </select> <div class="help-block"> <?php echo $_LANG['AD_POSITION_MUST_BE']; ?> <?php if (file_exists(PATH .'/templates/'. cmsCore::c('config')->template .'/positions.jpg')) { ?> <a href="#myModal" role="button" class="btn btn-sm btn-default" data-toggle="modal"><?php echo $_LANG['AD_SEE_VISUALLY']; ?></a> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="myModalLabel"><?php echo $_LANG['AD_TPL_POS']; ?></h4> </div> <div class="modal-body"> <img src="/templates/<?php echo cmsCore::c('config')->template; ?>/positions.jpg" alt="<?php echo $_LANG['AD_TPL_POS']; ?>" style="width:100%;height:auto;" /> </div> </div> </div> </div> <?php } ?> </div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_MODULE_TEMPLATE']; ?></label> <?php $tpls = cmsAdmin::getModuleTemplates(); ?> <select id="template" class="form-control" style="width:100%" name="template"> <?php foreach ($tpls as $tpl) { $selected = ($mod['template'] == $tpl || (!$mod['template'] && $tpl == 'module' )) ? 'selected="selected"' : ''; echo '<option value="'. $tpl .'" '. $selected .'>'. $tpl .'</option>'; } ?> </select> <div class="help-block"><?php echo $_LANG['AD_FOLDER_MODULES'];?></div> </div> <?php if ($do == 'add') { ?> <div class="form-group"> <label><?php echo $_LANG['AD_MODULE_TYPE']; ?></label> <select id="operate" class="form-control" style="width:100%" name="operate" onchange="checkDiv()" > <option value="user" selected="selected"><?php echo $_LANG['AD_MODULE_TYPE_NEW'];?></option> <option value="clone"><?php echo $_LANG['AD_MODULE_TYPE_COPY'];?></option> </select> </div> <?php } ?> <?php if (!isset($mod['user']) || $mod['user'] == 1 || $do == 'add') { ?> <div id="user_div" class="form-group"> <label><?php echo $_LANG['AD_MODULE_CONTENT']; ?></label> <div><?php insertPanel(); ?></div> <div><?php $inCore->insertEditor('content', $mod['content'], '250', '100%'); ?></div> </div> <?php } ?> <div id="clone_div" class="form-group" style="display:none;"> <label><?php echo $_LANG['AD_MODULE_COPY']; ?></label> <select id="clone_id" class="form-control" style="width:100%" name="clone_id"> <?php echo $inCore->getListItems('cms_modules'); ?> </select> <label> <input type="checkbox" name="del_orig" value="1" /> <?php echo $_LANG['AD_ORIGINAL_MODULE_DELETE'];?> </label> </div> </div> </div> </td> <!-- боковая ячейка --> <td width="400" valign="top"> <div class="uitabs"> <ul id="tabs"> <li><a href="#upr_publish"><span><?php echo $_LANG['AD_TAB_PUBLISH']; ?></span></a></li> <?php if ((($mod['is_external'] && $do == 'edit') || $do == 'add') && cmsCore::c('config')->cache) { ?> <li><a href="#upr_cache"><span><?php echo $_LANG['AD_MODULE_CACHE']; ?></span></a></li> <?php } ?> <li><a href="#upr_access"><span><?php echo $_LANG['AD_TAB_ACCESS']; ?></span></a></li> </ul> <div id="upr_publish"> <div class="form-group"> <label> <input type="checkbox" name="published" id="published" value="1" <?php if ($mod['published'] || $do=='add') { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['AD_MODULE_PUBLIC'];?> </label> </div> <div class="form-group"> <label> <input name="show_all" id="show_all" type="checkbox" value="1" onclick="checkGroupList()" <?php if ($show_all) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['AD_VIEW_ALL_PAGES'];?> </label> </div> <?php if ($do == 'edit') { $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = ". $mod['id'] ." AND tpl = '". cmsConfig::getConfig('template') ."'"; $bind_res = cmsCore::c('db')->query($bind_sql); $bind = array(); $bind_pos = array(); while ($r = cmsCore::c('db')->fetch_assoc($bind_res)) { $bind[] = $r['menu_id']; $bind_pos[$r['menu_id']] = $r['position']; } } $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering"; $menu_res = cmsCore::c('db')->query($menu_sql) ; $menu_items = array(); if (cmsCore::c('db')->num_rows($menu_res)) { while ($item = cmsCore::c('db')->fetch_assoc($menu_res)) { if ($do == 'edit') { if (in_array($item['id'], $bind)) { $item['selected'] = true; $item['position'] = $bind_pos[$item['id']]; } } $item['titles'] = cmsCore::yamlToArray($item['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($item['titles'][cmsCore::c('config')->lang])) { $item['title'] = $item['titles'][cmsCore::c('config')->lang]; } $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']); $menu_items[] = $item; } } ?> <div id="grp" class="form-group"> <label> <span class="show_list"><?php echo $_LANG['AD_WHERE_MODULE_VIEW'];?></span> <span class="hide_list"><?php echo $_LANG['AD_WHERE_MODULE_NOT_VIEW'];?></span> </label> <div style="height:400px;overflow: auto;border: solid 1px #999; padding:5px 10px; background: #FFF;"> <table class="table"> <tr> <td colspan="2" height="25"><strong><?php echo $_LANG['AD_MENU'];?></strong></td> <td class="show_list" align="center" width="50"><strong><?php echo $_LANG['AD_POSITION'];?></strong></td> </tr> <?php foreach($menu_items as $i) { ?> <tr class="show_list"> <td width="20" height="25"> <input type="checkbox" name="showin[]" id="mid<?php echo $i['id']; ?>" value="<?php echo $i['id']; ?>" <?php if ($i['selected']){ ?>checked="checked"<?php } ?> onclick="$('#p<?php echo $i['id']; ?>').toggle()"/> </td> <td style="padding-left:<?php echo ($i['NSLevel'])*6-6; ?>px"><label for="mid<?php echo $i['id']; ?>"><?php echo $i['title']; ?></label></td> <td align="center"> <select id="p<?php echo $i['id']; ?>" name="showpos[<?php echo $i['id']; ?>]" style="<?php if (!$i['selected']) { ?>display:none<?php } ?>"> <?php foreach($pos as $position){ ?> <option value="<?php echo $position; ?>" <?php if ($i['position']==$position){ ?>selected="selected"<?php } ?>><?php echo $position; ?></option> <?php } ?> </select> </td> </tr> <?php } ?> <?php foreach($menu_items as $it) { ?> <tr class="hide_list"> <td width="20" height="25"> <input type="checkbox" name="hidden_menu_ids[]" id="hmid<?php echo $it['id']; ?>" value="<?php echo $it['id']; ?>" <?php if (in_array($it['id'], $mod['hidden_menu_ids'])){ ?>checked="checked"<?php } ?> /> </td> <td style="padding-left:<?php echo ($it['NSLevel'])*6-6; ?>px"><label for="hmid<?php echo $it['id']; ?>"><?php echo $it['title']; ?></label></td> </tr> <?php } ?> </table> </div> <label class="show_list"> <input type="checkbox" name="is_strict_bind" id="is_strict_bind" value="1" <?php if ($mod['is_strict_bind']) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['AD_DONT_VIEW']; ?> </label> <label class="hide_list"> <input type="checkbox" name="is_strict_bind_hidden" id="is_strict_bind_hidden" value="1" <?php if ($mod['is_strict_bind_hidden']) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['AD_EXCEPT_NESTED']; ?> </label> </div> </div> <?php if ((($mod['is_external'] && $do == 'edit') || $do == 'add') && cmsCore::c('config')->cache) { ?> <div id="upr_cache"> <div class="form-group"> <label><?php echo $_LANG['AD_DO_MODULE_CACHE']; ?></label> <select id="cache" class="form-control" style="width:100%" name="cache"> <option value="0" <?php if (!cmsCore::getArrVal($mod, 'cache')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['NO']; ?></option> <option value="1" <?php if (cmsCore::getArrVal($mod, 'cache')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['YES']; ?></option> </select> </div> <div class="form-group"> <label><?php echo $_LANG['AD_MODULE_CACHE_PERIOD']; ?></label> <table class="table"> <tr> <td valign="top" width="100"> <input id="int_1" class="form-control" style="width:99%" name="cachetime" type="text" value="<?php echo cmsCore::getArrVal($mod, 'cachetime', 0); ?>"/> </td> <td valign="top" style="padding-left:5px"> <select id="int_2" class="form-control" style="width:100%" name="cacheint"> <option value="MINUTE" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MINUTE')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false); ?></option> <option value="HOUR" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'HOUR')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false); ?></option> <option value="DAY" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'DAY')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false); ?></option> <option value="MONTH" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MONTH')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false); ?></option> </select> </td> </tr> </table> <div style="margin-top:15px"> <?php if ($do == 'edit') { $cache = cmsCore::c('cache')->get('modules', $mod['id'], $mod['content'], array(cmsCore::getArrVal($mod, 'cachetime', 1), cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'))); if (!empty($cache)){ $kb = round(mb_strlen($cache)/1024, 2); unset($cache); echo '<a href="index.php?view=cache&component=modules&target='. $mod['content'] .'&target_id='. $mod['id'] .'">'. $_LANG['AD_MODULE_CACHE_DELETE'] .'</a> ('. $kb . $_LANG['SIZE_KB'] .')'; } else { echo '<span style="color:gray">'. $_LANG['AD_NO_CACHE'] .'</span>'; } } ?> </div> </div> </div> <?php } ?> <div id="upr_access"> <div class="form-group"> <?php $groups = cmsUser::getGroups(); $style = 'disabled="disabled"'; $public = 'checked="checked"'; if ($do == 'edit') { if ($mod['access_list']) { $public = ''; $style = ''; $access_list = $inCore->yamlToArray($mod['access_list']); } } ?> <label> <input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> /> <?php echo $_LANG['AD_SHARE']; ?> </label> <div class="help-block"><?php echo $_LANG['AD_IF_CHECKED']; ?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label> <?php echo '<select style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" '.$style.'>'; if ($groups) { foreach($groups as $group) { echo '<option value="'.$group['id'].'"'; if ($do == 'edit' && $mod['access_list']) { if (in_array($group['id'], $access_list)) { echo 'selected="selected"'; } } echo '>'; echo $group['title'].'</option>'; } } echo '</select>'; ?> <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?></div> </div> </div> </div> </td></tr> </table> <p> <input type="submit" id="add_mod" class="btn btn-primary" name="add_mod" value="<?php echo $_LANG['SAVE']; ?>" /> <input type="button" id="back" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.history.back();" /> <input type="hidden" id="do" name="do" <?php if ($do == 'add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> /> <?php if ($do == 'edit') { echo '<input name="id" type="hidden" value="'. $mod['id'] .'" />'; } ?> </p> </form> <?php } }
function applet_menu() { $inCore = cmsCore::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_MENU']); cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu'); $do = cmsCore::request('do', 'str', 'list'); $id = cmsCore::request('id', 'int', -1); if ($do == 'list') { $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add'), array('icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=edit&multiple=1');"), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');"), array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');"), array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');"), array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu')); cpToolMenu($toolmenu); $fields = array(array('title' => 'Lt', 'field' => 'NSLeft', 'width' => '40'), array('title' => $_LANG['TITLE'], 'field' => array('title', 'titles'), 'width' => '', 'link' => '?view=menu&do=edit&id=%id%', 'prc' => function ($i) { $i['titles'] = cmsCore::yamlToArray($i['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($i['titles'][cmsConfig::getConfig('lang')])) { $i['title'] = $i['titles'][cmsConfig::getConfig('lang')]; } return $i['title']; }), array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80'), array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100'), array('title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById'), array('title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu'), array('title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '90', 'prc' => 'cpTemplateById')); $actions = array(array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%')); cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering'); } else { $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu')); cpToolMenu($toolmenu); } if ($do == 'move_up') { cmsCore::c('db')->moveNsCategory('cms_menu', $id, 'up'); cmsCore::redirectBack(); } if ($do == 'move_down') { cmsCore::c('db')->moveNsCategory('cms_menu', $id, 'down'); cmsCore::redirectBack(); } if ($do == 'show') { if (!cmsCore::inRequest('item')) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_menu', $id, 'published', '1'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_menu', $_REQUEST['item'], 'published', '1'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirectBack(); } } if ($do == 'hide') { if (!cmsCore::inRequest('item')) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_menu', $id, 'published', '0'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_menu', cmsCore::request('item', 'array_int', array()), 'published', '0'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirectBack(); } } if ($do == 'delete') { if (!cmsCore::inRequest('item')) { if ($id >= 0) { cmsCore::c('db')->deleteNS('cms_menu', (int) $id); } } else { cmsCore::c('db')->deleteListNS('cms_menu', cmsCore::request('item', 'array_int', array())); } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirectBack(); } if ($do == 'update') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $id = cmsCore::request('id', 'int', 0); if (!$id) { cmsCore::redirectBack(); } $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', '')); $linktype = cmsCore::request('mode', 'str', ''); $linkid = cmsCore::request($linktype, 'str', ''); $link = $inCore->getMenuLink($linktype, $linkid); $target = cmsCore::request('target', 'str', ''); $published = cmsCore::request('published', 'int', 0); $template = cmsCore::request('template', 'str', ''); $iconurl = cmsCore::request('iconurl', 'str', ''); $parent_id = cmsCore::request('parent_id', 'int', 0); $oldparent = cmsCore::request('oldparent', 'int', 0); $is_lax = cmsCore::request('is_lax', 'int', 0); $css_class = cmsCore::request('css_class', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $ns = $inCore->nestedSetsInit('cms_menu'); if ($oldparent != $parent_id) { $ns->MoveNode($id, $parent_id); } $sql = "UPDATE cms_menu\r\n SET title='" . $title . "',\r\n titles='" . $titles . "',\r\n css_class='" . $css_class . "',\r\n menu='" . $menu . "',\r\n link='" . $link . "',\r\n linktype='" . $linktype . "',\r\n linkid='" . $linkid . "',\r\n target='" . $target . "',\r\n published='" . $published . "',\r\n template='" . $template . "',\r\n access_list='" . $access_list . "',\r\n is_lax='" . $is_lax . "',\r\n iconurl='" . $iconurl . "'\r\n WHERE id = '" . $id . "'\r\n LIMIT 1"; cmsCore::c('db')->query($sql); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) { cmsCore::redirect('?view=menu'); } else { cmsCore::redirect('?view=menu&do=edit'); } } if ($do == 'submit') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', '')); $linktype = cmsCore::request('mode', 'str', ''); $linkid = cmsCore::request($linktype, 'str', ''); $link = $inCore->getMenuLink($linktype, $linkid); $target = cmsCore::request('target', 'str', ''); $published = cmsCore::request('published', 'int', 0); $template = cmsCore::request('template', 'str', ''); $iconurl = cmsCore::request('iconurl', 'str', ''); $parent_id = cmsCore::request('parent_id', 'int', 0); $css_class = cmsCore::request('css_class', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); $is_lax = cmsCore::request('is_lax', 'int', 0); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $ns = $inCore->nestedSetsInit('cms_menu'); $myid = $ns->AddNode($parent_id); $sql = "UPDATE cms_menu\r\n SET menu='" . $menu . "',\r\n title='" . $title . "',\r\n titles='" . $titles . "',\r\n css_class='" . $css_class . "',\r\n link='" . $link . "',\r\n linktype='" . $linktype . "',\r\n linkid='" . $linkid . "',\r\n target='" . $target . "',\r\n published='" . $published . "',\r\n template='" . $template . "',\r\n access_list='" . $access_list . "',\r\n is_lax='" . $is_lax . "',\r\n iconurl='" . $iconurl . "'\r\n WHERE id = '" . $myid . "'"; cmsCore::c('db')->query($sql); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('?view=menu'); } if ($do == 'submitmenu') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1"; $result = cmsCore::c('db')->query($sql); $row = cmsCore::c('db')->fetch_assoc($result); $maxorder = $row['max_o'] + 1; $menu = cmsCore::request('menu', 'str', ''); $title = cmsCore::request('title', 'str', ''); $position = cmsCore::request('position', 'str', ''); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $cfg['menu'] = $menu; $cfg_str = cmsCore::arrayToYaml($cfg); $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list)\r\n VALUES ('" . $position . "', '" . $_LANG['AD_MENU'] . "', '" . $title . "', 1, 'mod_menu', " . $maxorder . ", 1, " . $published . ", 0, '" . $cfg_str . "', '" . $css_prefix . "', '" . $access_list . "')"; cmsCore::c('db')->query($sql); $newid = cmsCore::c('db')->get_last_id('cms_modules'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('?view=modules&do=edit&id=' . $newid); } if ($do == 'addmenu' || $do == 'add' || $do == 'edit') { cmsCore::c('page')->addHeadJS('admin/js/menu.js'); echo '<script>'; echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU'); echo '</script>'; } if ($do == 'addmenu') { cmsCore::c('page')->setTitle($_LANG['AD_MENU_ADD']); cpAddPathway($_LANG['AD_MENU_ADD']); cmsCore::c('page')->initTemlate('applets', 'menu_addmenu')->assign('menu_list', cpGetList('menu'))->assign('pos', cpModulePositions(cmsCore::c('config')->template))->assign('groups', cmsUser::getGroups())->assign('access_list', !empty($mod['access_list']) ? $inCore->yamlToArray($mod['access_list']) : array())->assign('mod', $mod)->display(); } if ($do == 'add' || $do == 'edit') { if ($do == 'add') { cpAddPathway($_LANG['AD_MENU_POINT_ADD']); $mod['menu'] = array('mainmenu'); } else { if (isset($_REQUEST['multiple'])) { if (isset($_REQUEST['item'])) { $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array()); } else { cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error'); cmsCore::redirectBack(); } } $ostatok = ''; if (isset($_SESSION['editlist'])) { $item_id = array_shift($_SESSION['editlist']); if (sizeof($_SESSION['editlist']) == 0) { unset($_SESSION['editlist']); } else { $ostatok = '(' . $_LANG['AD_NEXT_IN'] . sizeof($_SESSION['editlist']) . ')'; } } else { $item_id = cmsCore::request('id', 'int', 0); } $mod = cmsCore::c('db')->get_fields('cms_menu', "id = '{$item_id}'", '*'); if (!$mod) { cmsCore::error404(); } $mod['menu'] = cmsCore::yamlToArray($mod['menu']); $mod['titles'] = cmsCore::yamlToArray($mod['titles']); cpAddPathway($_LANG['AD_MENU_POINT_EDIT'] . $ostatok . ' "' . $mod['title'] . '"'); } $linktype = cmsCore::getArrVal($mod, 'linktype', 'link'); $tpl = cmsCore::c('page')->initTemplate('applets', 'menu_add')->assign('linktype', $linktype)->assign('langs', cmsCore::getDirsList('/languages'))->assign('templates', cmsCore::getDirsList('/templates'))->assign('menu_list', cpGetList('menu'))->assign('rootid', cmsCore::c('db')->get_field('cms_menu', 'parent_id=0', 'id'))->assign('menu_opt', $inCore->getListItemsNS('cms_menu', cmsCore::getArrVal($mod, 'parent_id', 0)))->assign('content_opt', $inCore->getListItems('cms_content', $linktype == 'content' ? $mod['linkid'] : 0))->assign('category_opt', $inCore->getListItemsNS('cms_category', $link_type == 'category' ? $mod['linkid'] : 0))->assign('components_opt', $inCore->getListItems('cms_components', $link_type == 'component' ? $mod['linkid'] : 0, 'title', 'asc', 'internal=0', 'link'))->assign('blogs_opt', $inCore->getListItems('cms_blogs', $link_type == 'blog' ? $mod['linkid'] : 0, 'title', 'asc', "owner='user'"))->assign('uc_cats_opt', $inCore->getListItems('cms_uc_cats', $link_type == 'uccat' ? $mod['linkid'] : 0))->assign('photo_albums_opt', $inCore->getListItems('cms_photo_albums', $link_type == 'photoalbum' ? $mod['linkid'] : 0, 'id', 'ASC', 'NSDiffer = ""'))->assign('video_installed', $inCore->isComponentInstalled('video'))->assign('iconList', iconList())->assign('mod', $mod); if ($inCore->isComponentInstalled('video')) { $tpl->assign('video_cats_opt', $inCore->getListItemsNS('cms_video_category', $linktype == 'video_cat' ? $mod['linkid'] : 0)); } $tpl->display(); } }
function applet_templates() { global $adminAccess; global $_LANG; if (!cmsUser::isAdminCan('admin/config', $adminAccess)) { cpAccessDenied(); } $do = cmsCore::request('do', array('config', 'save_config'), 'main'); cmsCore::c('page')->setTitle($_LANG['AD_TEMPLATES_SETTING']); cpAddPathway($_LANG['AD_TEMPLATES_SETTING'], 'index.php?view=templates'); if ($do == 'main') { $templates = cmsCore::getDirsList('/templates'); echo '<div class="panel panel-default"><div class="panel-heading">'. $_LANG['AD_TEMPLATES_LIST'] .'</div><div class="panel-body">'; echo '<table class="table table-striped"><thead><tr>'; echo '<th>'. $_LANG['AD_TEMPLATE'] .'</th>'; echo '<th width="200">'. $_LANG['AD_TEMPLATE_AUTHOR'] .'</th>'; echo '<th width="200">'. $_LANG['AD_TEMPLATE_RENDERER'] .'</th>'; echo '<th width="200">'. $_LANG['AD_TEMPLATE_EXT'] .'</th><th width="100"></th><th width="100"></th>'; echo '</tr></thead><tbody>'; foreach ($templates as $template) { if ($template == 'admin') { continue; } $tpl_info = cmsCore::c('page')->getTplInfo($template); echo '<tr>'; echo '<td><strong>'. $template .'</strong></td>'; echo '<td>'. $tpl_info['author'] .'</td>'; echo '<td>'. $tpl_info['renderer'] .'</td>'; echo '<td>'. $tpl_info['ext'] .'</td><td>'; if (file_exists(PATH .'/templates/'. $template .'/positions.jpg')) { echo '<a href="#'. $template .'" role="button" class="btn btn-sm btn-default" data-toggle="modal">'. $_LANG['AD_TPL_POS'] .'</a> <div class="modal fade" id="'. $template .'" tabindex="-1" role="dialog" aria-labelledby="'. $template .'Label" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="'. $template .'Label">'. $_LANG['AD_TPL_POS'] .'</h4> </div> <div class="modal-body"> <img src="/templates/'. $template .'/positions.jpg" alt="'. $_LANG['AD_TPL_POS'] .'" style="width:100%;height:auto;" /> </div> </div> </div> </div>'; } echo '</td><td>'; if (file_exists(PATH .'/templates/'. $template .'/config.php')) { echo '<a href="/admin/index.php?view=templates&do=config&template='. $template .'" class="btn btn-sm btn-primary">'. $_LANG['AD_CONFIG'] .'</a>'; } echo '</td></tr>'; } echo '</tbody></table></div></div>'; } if ($do == 'config') { $template = cmsCore::request('template', 'str', ''); cpAddPathway($_LANG['AD_TEMPLATE'] .': '. $template, 'index.php?view=templates&do=config&template='. $template); if (!file_exists(PATH .'/templates/'. $template) || !file_exists(PATH .'/templates/'. $template .'/config.php')) { cmsCore::error404(); } include(PATH .'/templates/'. $template .'/config.php'); if (function_exists('get_template_cfg_fields')) { $tpl_cfgs = get_template_cfg_fields(); if (!empty($tpl_cfgs)) { $tpl_cfgs_val = cmsCore::getTplCfg($template); echo '<form action="/admin/index.php?view=templates&template='. $template .'&do=save_config" method="post" style="width:650px;margin-bottom:30px">'; echo cmsCore::c('form_gen')->generateForm($tpl_cfgs, $tpl_cfgs_val); echo '<div>'; echo '<input type="submit" class="btn btn-primary" name="save" value="'. $_LANG['SAVE'] .'" /> '; echo '<input type="button" class="btn btn-default" name="back" value="'. $_LANG['CANCEL'] .'" onclick="window.history.back();" />'; echo '</div>'; echo '</form>'; } else { cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_NO_CONFIG'], 'error'); cmsCore::redirectBack(); } } else { cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_CFG_ERROR'], 'error'); cmsCore::redirectBack(); } } if ($do == 'save_config') { $template = cmsCore::request('template', 'str', ''); if (!file_exists(PATH .'/templates/'. $template) || !file_exists(PATH .'/templates/'. $template .'/config.php') || !cmsUser::checkCsrfToken()) { cmsCore::error404(); } include(PATH .'/templates/'. $template .'/config.php'); if (function_exists('get_template_cfg_fields')) { $tpl_cfgs = get_template_cfg_fields(); if (!empty($tpl_cfgs)) { $tpl_cfgs = cmsCore::c('form_gen')->requestForm($tpl_cfgs); cmsCore::saveTplCfg($tpl_cfgs, $template); cmsCore::addSessionMessage($_LANG['AD_TEMPLATE_CFG_SAVED'], 'success'); cmsCore::redirect('/admin/index.php?view=templates'); } else { cmsCore::error404(); } } else { cmsCore::error404(); } } }
function applet_menu() { $inCore = cmsCore::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_MENU']); cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu'); $do = cmsCore::request('do', 'str', 'list'); $id = cmsCore::request('id', 'int', -1); if ($do == 'list') { $toolmenu = array( array( 'icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add' ), array( 'icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu' ), array( 'icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link'=> "javascript:checkSel('?view=menu&do=edit&multiple=1');" ), array( 'icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');" ), array( 'icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');" ), array( 'icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');" ), array( 'icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu' ) ); cpToolMenu($toolmenu); $fields = array( array( 'title' => 'Lt', 'field' => 'NSLeft', 'width' => '40' ), array( 'title' => $_LANG['TITLE'], 'field' => array('title', 'titles'), 'width'=>'', 'link' => '?view=menu&do=edit&id=%id%', 'prc' => function ($i) { $i['titles'] = cmsCore::yamlToArray($i['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($i['titles'][cmsConfig::getConfig('lang')])) { $i['title'] = $i['titles'][cmsConfig::getConfig('lang')]; } return $i['title']; } ), array( 'title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80' ), array( 'title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100' ), array( 'title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById' ), array( 'title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu' ), array( 'title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '90', 'prc' => 'cpTemplateById' ) ); $actions = array( array( 'title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%' ), array( 'title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%' ) ); cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering'); } else { $toolmenu = array( array( 'icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();' ), array( 'icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu' ) ); cpToolMenu($toolmenu); } if ($do == 'move_up') { cmsCore::c('db')->moveNsCategory('cms_menu', $id, 'up'); cmsCore::redirectBack(); } if ($do == 'move_down') { cmsCore::c('db')->moveNsCategory('cms_menu', $id, 'down'); cmsCore::redirectBack(); } if ($do == 'show') { if (!cmsCore::inRequest('item')) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_menu', $id, 'published', '1'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_menu', $_REQUEST['item'], 'published', '1'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); cmsCore::redirectBack(); } } if ($do == 'hide') { if (!cmsCore::inRequest('item')) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_menu', $id, 'published', '0'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_menu', cmsCore::request('item', 'array_int', array()), 'published', '0'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); cmsCore::redirectBack(); } } if ($do == 'delete') { if (!cmsCore::inRequest('item')) { if ($id >= 0) { cmsCore::c('db')->deleteNS('cms_menu', (int)$id); } } else { cmsCore::c('db')->deleteListNS('cms_menu', cmsCore::request('item', 'array_int', array())); } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); cmsCore::redirectBack(); } if ($do == 'update') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $id = cmsCore::request('id', 'int', 0); if(!$id){ cmsCore::redirectBack(); } $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', '')); $linktype = cmsCore::request('mode', 'str', ''); $linkid = cmsCore::request($linktype, 'str', ''); $link = $inCore->getMenuLink($linktype, $linkid); $target = cmsCore::request('target', 'str', ''); $published = cmsCore::request('published', 'int', 0); $template = cmsCore::request('template', 'str', ''); $iconurl = cmsCore::request('iconurl', 'str', ''); $parent_id = cmsCore::request('parent_id', 'int', 0); $oldparent = cmsCore::request('oldparent', 'int', 0); $is_lax = cmsCore::request('is_lax', 'int', 0); $css_class = cmsCore::request('css_class', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $ns = $inCore->nestedSetsInit('cms_menu'); if ($oldparent != $parent_id) { $ns->MoveNode($id, $parent_id); } $sql = "UPDATE cms_menu SET title='". $title ."', titles='". $titles ."', css_class='". $css_class ."', menu='". $menu ."', link='". $link ."', linktype='". $linktype ."', linkid='". $linkid ."', target='". $target ."', published='". $published ."', template='". $template ."', access_list='". $access_list ."', is_lax='". $is_lax ."', iconurl='". $iconurl ."' WHERE id = '". $id ."' LIMIT 1"; cmsCore::c('db')->query($sql) ; cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) { cmsCore::redirect('?view=menu'); } else { cmsCore::redirect('?view=menu&do=edit'); } } if ($do == 'submit') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', '')); $linktype = cmsCore::request('mode', 'str', ''); $linkid = cmsCore::request($linktype, 'str', ''); $link = $inCore->getMenuLink($linktype, $linkid); $target = cmsCore::request('target', 'str', ''); $published = cmsCore::request('published', 'int', 0); $template = cmsCore::request('template', 'str', ''); $iconurl = cmsCore::request('iconurl', 'str', ''); $parent_id = cmsCore::request('parent_id', 'int', 0); $css_class = cmsCore::request('css_class', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); $is_lax = cmsCore::request('is_lax', 'int', 0); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $ns = $inCore->nestedSetsInit('cms_menu'); $myid = $ns->AddNode($parent_id); $sql = "UPDATE cms_menu SET menu='". $menu ."', title='". $title ."', titles='". $titles ."', css_class='". $css_class ."', link='". $link ."', linktype='". $linktype ."', linkid='". $linkid ."', target='". $target ."', published='". $published ."', template='". $template ."', access_list='". $access_list ."', is_lax='". $is_lax ."', iconurl='". $iconurl ."' WHERE id = '". $myid ."'"; cmsCore::c('db')->query($sql); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); cmsCore::redirect('?view=menu'); } if ($do == 'submitmenu') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $sql = "SELECT ordering as max_o FROM cms_modules ORDER BY ordering DESC LIMIT 1"; $result = cmsCore::c('db')->query($sql) ; $row = cmsCore::c('db')->fetch_assoc($result); $maxorder = $row['max_o'] + 1; $menu = cmsCore::request('menu', 'str', ''); $title = cmsCore::request('title', 'str', ''); $position = cmsCore::request('position', 'str', ''); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = $inCore->arrayToYaml(cmsCore::request('allow_group', 'array_int')); } $cfg['menu'] = $menu; $cfg_str = cmsCore::arrayToYaml($cfg); $sql = "INSERT INTO cms_modules (position, name, title, is_external, content, ordering, showtitle, published, user, config, css_prefix, access_list) VALUES ('". $position ."', '". $_LANG['AD_MENU'] ."', '". $title ."', 1, 'mod_menu', ". $maxorder .", 1, ". $published .", 0, '". $cfg_str ."', '". $css_prefix ."', '". $access_list ."')"; cmsCore::c('db')->query($sql) ; $newid = cmsCore::c('db')->get_last_id('cms_modules'); cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'] , 'success'); cmsCore::redirect('?view=modules&do=edit&id='.$newid); } if ($do == 'addmenu' || $do == 'add' || $do == 'edit') { cmsCore::c('page')->addHeadJS('admin/js/menu.js'); echo '<script>'; echo cmsPage::getLangJS('AD_SPECIFY_LINK_MENU'); echo '</script>'; } if ($do == 'addmenu') { cmsCore::c('page')->setTitle($_LANG['AD_MENU_ADD']); cpAddPathway($_LANG['AD_MENU_ADD']); $menu_list = cpGetList('menu'); ?> <form id="addform" name="addform" action="index.php?view=menu&do=submitmenu" method="post"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" /> <div class="panel panel-default" style="width:650px;"> <div class="panel-body"> <div class="form-group"> <label><?php echo $_LANG['AD_MODULE_MENU_TITLE']; ?></label> <input type="text" id="title2" class="form-control" name="title" style="width:99%" value="" /> </div> <div class="form-group"> <label><?php echo $_LANG['AD_MENU_TO_VIEW']; ?></label> <select id="menu" class="form-control" name="menu" style="width:99%"> <?php foreach ($menu_list as $menu) { ?> <option value="<?php echo $menu['id']; ?>"> <?php echo $menu['title']; ?> </option> <?php } ?> </select> <div class="help-block"><?php echo $_LANG['AD_TO_CREATE_NEW_POINT']; ?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_POSITION_TO_VIEW']; ?></label> <?php $pos = cpModulePositions(cmsConfig::getConfig('template')); ?> <select id="position" class="form-control" name="position" style="width:99%"> <?php if ($pos){ foreach($pos as $key=>$position) { if (cmsCore::getArrVal($mod, 'position') == $position){ echo '<option value="'. $position .'" selected>'. $position .'</option>'; } else { echo '<option value="'. $position .'">'. $position .'</option>'; } } } ?> </select> <input name="is_external" type="hidden" id="is_external" value="0" /> <div class="help-block"><?php echo $_LANG['AD_POSITION_MUST_BE']; ?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_MENU_PUBLIC']; ?></label> <label> <input name="published" type="radio" value="1" checked="checked" <?php if (cmsCore::getArrVal($mod, 'published')) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['YES']; ?> </label> <label> <input name="published" type="radio" value="0" <?php if (!cmsCore::getArrVal($mod, 'published')) { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['NO']; ?> </label> </div> <div class="form-group"> <label><?php echo $_LANG['AD_PREFIX_CSS']; ?></label> <input type="text" id="css_prefix" class="form-control" name="css_prefix" value="<?php echo cmsCore::getArrVal($mod, 'css_prefix'); ?>" style="width:99%" /> </div> <div class="form-group"> <label><?php echo $_LANG['AD_TAB_ACCESS']; ?>:</label> <div class="help-block"><?php echo $_LANG['AD_GROUP_ACCESS'] ; ?></div> <?php $groups = cmsUser::getGroups(); $style = 'disabled="disabled"'; $public = 'checked="checked"'; if ($do == 'edit') { if ($mod['access_list']) { $public = ''; $style = ''; $access_list = $inCore->yamlToArray($mod['access_list']); } } ?> <label><input name="is_public" type="checkbox" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public?> /> <?php echo $_LANG['AD_SHARE']; ?></label> <div class="help-block"><?php echo $_LANG['AD_VIEW_IF_CHECK']; ?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label> <?php echo '<select class="form-control" style="width: 99%" name="allow_group[]" id="allow_group" size="6" multiple="multiple" '. $style .'>'; if ($groups) { foreach ($groups as $group) { echo '<option value="'. $group['id'] .'"'; if ($do == 'edit') { if (in_array($group['id'], $access_list)) { echo 'selected="selected"'; } } echo '>'; echo $group['title'].'</option>'; } } echo '</select>'; ?> <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL']; ?></div> </div> <div class="alert alert-info" role="alert"><?php echo $_LANG['AD_NEW_MENU_NEW_MODULE']; ?></div> </div> </div> <div style="margin-top:5px"> <input class="btn btn-primary" name="save" type="submit" id="save" value="<?php echo $_LANG['AD_MENU_ADD']; ?>" /> <input class="btn btn-default" name="back" type="button" id="back" value="<?php echo $_LANG['CANCEL']; ?>" onclick="window.location.href='index.php?view=menu';" /> </div> </form> <?php } if ($do == 'add' || $do == 'edit') { $menu_list = cpGetList('menu'); $langs = cmsCore::getDirsList('/languages'); if ($do == 'add') { cpAddPathway($_LANG['AD_MENU_POINT_ADD']); $mod['menu'] = array('mainmenu'); } else { if (isset($_REQUEST['multiple'])) { if (isset($_REQUEST['item'])) { $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array()); } else { cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error'); cmsCore::redirectBack(); } } $ostatok = ''; if (isset($_SESSION['editlist'])) { $item_id = array_shift($_SESSION['editlist']); if (sizeof($_SESSION['editlist']) == 0) { unset($_SESSION['editlist']); } else { $ostatok = '('.$_LANG['AD_NEXT_IN'].sizeof($_SESSION['editlist']).')'; } } else { $item_id = cmsCore::request('id', 'int', 0); } $mod = cmsCore::c('db')->get_fields('cms_menu', "id = '$item_id'", '*'); if (!$mod) { cmsCore::error404(); } $mod['menu'] = cmsCore::yamlToArray($mod['menu']); $mod['titles'] = cmsCore::yamlToArray($mod['titles']); cpAddPathway($_LANG['AD_MENU_POINT_EDIT'].$ostatok.' "'.$mod['title'].'"'); } ?> <form id="addform" name="addform" method="post" action="index.php"> <input type="hidden" name="csrf_token" value="<?php echo cmsUser::getCsrfToken(); ?>" /> <input type="hidden" name="view" value="menu" /> <table class="table"> <tr> <td valign="top"> <div class="panel panel-default"> <div class="panel-body"> <div class="form-group"> <label><?php echo $_LANG['AD_MENU_POINT_TITLE']; ?></label> <input type="text" id="title" class="form-control" style="width:100%" name="title" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod, 'title', ''));?>" /> <div class="help-block"><?php echo $_LANG['AD_VIEW_IN_SITE']; ?></div> </div> <?php if (count($langs) > 1) { ?> <div class="form-group"> <label><?php echo $_LANG['AD_LANG_TITLES']; ?></label> <?php foreach ($langs as $lang) { ?> <div> <strong><?php echo $lang; ?>:</strong> <input name="titles[<?php echo $lang; ?>]" type="text" style="width:97%" value="<?php echo htmlspecialchars(cmsCore::getArrVal($mod['titles'], $lang, '')); ?>" placeholder="<?php echo $_LANG['AD_HINT_DEFAULT']; ?>" /> </div> <?php } ?> <div class="help-block"><?php echo $_LANG['AD_LANG_TITLES_HINT']; ?></div> </div> <?php } ?> <div class="form-group"> <label><?php echo $_LANG['AD_PARENT_POINT']; ?></label> <?php $rootid = cmsCore::c('db')->get_field('cms_menu', 'parent_id=0', 'id'); ?> <select id="parent_id" class="form-control" style="width:100%" name="parent_id" size="10"> <option value="<?php echo $rootid; ?>" <?php if (cmsCore::getArrVal($mod, 'parent_id', $rootid) == $rootid) { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_MENU_ROOT']; ?></option> <?php echo $inCore->getListItemsNS('cms_menu', cmsCore::getArrVal($mod, 'parent_id', 0)); ?> </select> <input type="hidden" name="oldparent" value="<?php echo cmsCore::getArrVal($mod, 'parent_id', '');?>" /> </div> <div class="form-group"> <label><?php echo $_LANG['AD_MENU_POINT_ACTION']; ?></label> <select id="linktype" class="form-control" style="width:100%" name="mode" onchange="showMenuTarget()"> <?php $link_type = cmsCore::getArrVal($mod, 'linktype', 'link') ?> <option value="link" <?php if ($link_type == 'link') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_LINK']; ?></option> <option value="content" <?php if ($link_type == 'content') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_ARTICLE']; ?></option> <?php if($inCore->isComponentInstalled('video')){ ?> <option value="video_cat" <?php if ($link_type == 'video_cat') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_VIDEO_PARTITION']; ?></option> <?php } ?> <option value="category" <?php if ($link_type == 'category') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_PARTITION']; ?></option> <option value="component" <?php if ($link_type == 'component') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_COMPONENT']; ?></option> <option value="blog" <?php if ($link_type == 'blog') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_BLOG']; ?></option> <option value="uccat" <?php if ($link_type == 'uccat') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_CATEGORY']; ?></option> <option value="photoalbum" <?php if ($link_type == 'photoalbum') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_OPEN_ALBUM']; ?></option> </select> </div> <div id="t_link" class="form-group menu_target" style="display:<?php if ($link_type == 'link' || $link_type == 'ext') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_LINK']; ?></label> <input type="text" id="link" class="form-control" style="width:100%" name="link" size="50" value="<?php if ($link_type == 'link' || $link_type == 'ext') { echo cmsCore::getArrVal($mod, 'link', ''); } ?>" /> <div class="help-block"><?php echo $_LANG['AD_LINK_HINT']; ?> <b>http://</b></div> </div> <div id="t_content" class="form-group menu_target" style="display:<?php if ($link_type == 'content') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_ARTICLE'] ; ?></label> <select id="content" class="form-control" style="width:100%" name="content"> <?php echo $inCore->getListItems('cms_content', (($link_type == 'content') ? $mod['linkid'] : 0)); ?> </select> </div> <?php if($inCore->isComponentInstalled('video')){ ?> <div id="t_video_cat" class="form-group menu_target" style="display:<?php if ($link_type == 'video_cat') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_PARTITION']; ?></label> <select id="video_cat" class="form-control" style="width:100%" name="video_cat"> <?php echo $inCore->getListItemsNS('cms_video_category', (($link_type == 'video_cat') ? $mod['linkid'] : 0)); ?> </select> </div> <?php } ?> <div id="t_category" class="form-group menu_target" style="display:<?php if ($link_type == 'category') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_PARTITION']; ?></label> <select id="category" class="form-control" style="width:100%" name="category"> <?php echo $inCore->getListItemsNS('cms_category', (($link_type == 'category') ? $mod['linkid'] : 0)); ?> </select> </div> <div id="t_component" class="form-group menu_target" style="display:<?php if ($link_type == 'component') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_COMPONENT']; ?></label> <select id="component" class="form-control" style="width:100%" name="component"> <?php echo $inCore->getListItems('cms_components', (($link_type == 'component') ? $mod['linkid'] : 0), 'title', 'asc', 'internal=0', 'link'); ?> </select> </div> <div id="t_blog" class="form-group menu_target" style="display:<?php if ($link_type == 'blog') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_BLOG']; ?></label> <select id="blog" class="form-control" style="width:100%" name="blog"> <?php echo $inCore->getListItems('cms_blogs', (($link_type == 'blog') ? $mod['linkid'] : 0), 'title', 'asc', "owner='user'"); ?> </select> </div> <div id="t_uccat" class="form-group menu_target" style="display:<?php if ($link_type == 'uccat') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_CATEGORY']; ?></label> <select id="blog" class="form-control" style="width:100%" name="blog"> <?php echo $inCore->getListItems('cms_uc_cats', (($link_type == 'uccat') ? $mod['linkid'] : 0)); ?> </select> </div> <div id="t_photoalbum" class="form-group menu_target" style="display:<?php if ($link_type == 'photoalbum') { echo 'block'; } else { echo 'none'; } ?>"> <label><?php echo $_LANG['AD_CHECK_ALBUM']; ?></label> <select id="blog" class="form-control" style="width:100%" name="blog"> <?php echo $inCore->getListItems('cms_photo_albums', (($link_type == 'photoalbum') ? $mod['linkid'] : 0), 'id', 'ASC', 'NSDiffer = ""'); ?> </select> </div> </div> </div> </td> <td width="400" valign="top"> <div class="uitabs"> <ul id="tabs"> <li><a href="#upr_publish"><span><?php echo $_LANG['AD_TAB_PUBLISH']; ?></span></a></li> <li><a href="#upr_access"><span><?php echo $_LANG['AD_TAB_ACCESS']; ?></span></a></li> <li><a href="#upr_menu"><span><?php echo $_LANG['AD_MENU']; ?></span></a></li> </ul> <div id="upr_publish"> <div class="form-group"> <label> <input type="checkbox" name="published" value="1" <?php if (cmsCore::getArrVal($mod, 'published') || $do == 'add') { echo 'checked="checked"'; } ?> /> <?php echo $_LANG['AD_MENU_POINT_PUBLIC']; ?> </label> </div> <div class="form-group"> <label><?php echo $_LANG['AD_OPEN_POINT']; ?></label> <select id="target" class="form-control" style="width:100%" name="target"> <option value="_self" <?php if (@$mod['target']=='_self') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_SELF']; ?></option> <option value="_parent"><?php echo $_LANG['AD_PARENT'];?></option> <option value="_blank" <?php if (@$mod['target']=='_blank') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_BLANK']; ?></option> <option value="_top" <?php if (@$mod['target']=='_top') { echo 'selected="selected"'; }?>><?php echo $_LANG['AD_TOP']; ?></option> </select> </div> <div class="form-group"> <label><?php echo $_LANG['TEMPLATE']; ?></label> <select id="template" class="form-control" style="width:100%" name="template" > <option value="0" <?php if (!cmsCore::getArrVal($mod, 'template')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['AD_BY_DEFAULT'];?></option> <?php $templates = cmsCore::getDirsList('/templates'); foreach ($templates as $template) { if ($template == 'admin') { continue; } echo '<option value="'. $template .'" '.(cmsCore::getArrVal($mod, 'template') ? 'selected="selected"': '').'>'.$template.'</option>'; } ?> </select> <div class="help-block"><?php echo $_LANG['AD_DESIGN_CHANGE'] ;?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_ICON_PICTURE']; ?></label> <input type="text" id="iconurl" class="form-control" style="width:100%" name="iconurl" size="30" value="<?php echo cmsCore::getArrVal($mod, 'iconurl', ''); ?>" /> <a id="iconlink" style="display:block;" href="javascript:showIcons()"><?php echo $_LANG['AD_CHECK_ICON'];?></a> <div id="icondiv" style="display:none; padding:6px;border:solid 1px gray;background:#FFF"> <div><?php iconList(); ?></div> </div> <div class="help-block"><?php echo $_LANG['AD_ICON_FILENAME'] ;?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_CSS_CLASS']; ?></label> <input type="text" class="form-control" style="width:100%" name="css_class" size="30" value="<?php echo cmsCore::getArrVal($mod, 'css_class', ''); ?>" /> </div> </div> <div id="upr_access"> <div class="form-group"> <?php $groups = cmsUser::getGroups(); $style = 'disabled="disabled"'; $public = 'checked="checked"'; if ($do == 'edit') { if ($mod['access_list']) { $public = ''; $style = ''; $access_list = $inCore->yamlToArray($mod['access_list']); } } ?> <label> <input type="checkbox" name="is_public" id="is_public" onclick="checkAccesList()" value="1" <?php echo $public; ?> /> <?php echo $_LANG['AD_SHARE']; ?> </label> <div class="help-block"><?php echo $_LANG['AD_VIEW_IF_CHECK'];?></div> </div> <div class="form-group"> <label><?php echo $_LANG['AD_GROUPS_VIEW']; ?></label> <?php echo '<select id="allow_group" class="form-control" style="width: 99%" name="allow_group[]" size="6" multiple="multiple" '.$style.'>'; if ($groups) { foreach($groups as $group) { echo '<option value="'. $group['id'] .'"'; if ($do == 'edit' && cmsCore::getArrVal($mod, 'access_list')) { if (in_array($group['id'], $access_list)){ echo 'selected="selected"'; } } echo '>'; echo $group['title'] .'</option>'; } } echo '</select>'; ?> <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];?></div> </div> <div class="form-group"> <label> <input type="checkbox" id="is_lax" name="is_lax" value="1" <?php if(cmsCore::getArrVal($mod, 'is_lax')) {?>checked="checked"<?php } ?> /> <?php echo $_LANG['AD_ONLY_CHILD_ITEM']; ?> </label> </div> </div> <div id="upr_menu"> <div class="form-group"> <label><?php echo $_LANG['AD_MENU_TO_VIEW'];?></label> <select class="form-control" style="width: 99%" name="menu[]" size="9" multiple="multiple"> <?php foreach ($menu_list as $menu) { ?> <option value="<?php echo $menu['id']; ?>" <?php if (in_array($menu['id'], cmsCore::getArrVal($mod, 'menu', array()))) { echo 'selected="selected"'; }?>> <?php echo $menu['title']; ?> </option> <?php } ?> </select> <div class="help-block"><?php echo $_LANG['AD_SELECT_MULTIPLE_CTRL'];?></div> </div> </div> </div> </td> </tr> </table> <div> <input type="button" class="btn btn-primary" name="add_mod" onclick="submitItem()" value="<?php echo $_LANG['SAVE']; ?> " /> <input type="button" class="btn btn-default" name="back" value="<?php echo $_LANG['CANCEL'];?>" onclick="window.location.href='index.php?view=menu';" /> <input type="hidden" name="do" <?php if ($do=='add') { echo 'value="submit"'; } else { echo 'value="update"'; } ?> /> <?php if ($do == 'edit') { echo '<input type="hidden" name="id" value="'.$mod['id'].'" />'; } ?> </div> </form> <?php } }
function applet_modules() { $inCore = cmsCore::getInstance(); global $_LANG; global $adminAccess; if (!cmsUser::isAdminCan('admin/modules', $adminAccess)) { cpAccessDenied(); } cmsCore::c('page')->setTitle($_LANG['AD_MODULES']); cpAddPathway($_LANG['AD_MODULES'], 'index.php?view=modules'); cmsCore::c('page')->addHeadJS('admin/js/modules.js'); $do = cmsCore::request('do', 'str', 'list'); $id = cmsCore::request('id', 'int', -1); $co = cmsCore::request('co', 'int', -1); if ($do == 'config') { $module_name = cpModuleById($id); $module_title = cpModuleTitleById($id); if (!$module_name) { cmsCore::redirect('index.php?view=modules&do=edit&id=' . $id); } $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml'; $php_file = 'modules/' . $module_name . '/backend.php'; if (file_exists($php_file)) { include $php_file; return; } $cfg = $inCore->loadModuleConfig($id); cpAddPathway($module_title, '?view=modules&do=edit&id=' . $id); cpAddPathway($_LANG['AD_SETTINGS']); $toolmenu = array(array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:submitModuleConfig();'), array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=modules'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_MODULE_VIEW'], 'link' => '?view=modules&do=edit&id=' . $id)); cpToolMenu($toolmenu); $tpl = cmsCore::c('page')->initTemplate('applets', 'modules_config')->assign('module_title', $module_title)->assign('id', $id); if (file_exists($xml_file)) { cmsCore::loadClass('formgen'); $formGen = new cmsFormGen($xml_file, $cfg); $tpl->assign('formGenHtml', $formGen->getHTML()); } else { $tpl->assign('cfg', $cfg); } $tpl->display(); } if ($do == 'save_auto_config') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $module_name = cpModuleById($id); $is_ajax = cmsCore::inRequest('ajax'); if ($is_ajax) { $title = cmsCore::request('title', 'str', ''); $published = cmsCore::request('published', 'int', 0); cmsCore::c('db')->query("UPDATE cms_modules SET title='" . $title . "', published='" . $published . "' WHERE id=" . $id); if (cmsCore::inRequest('content')) { $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html')); cmsCore::c('db')->query("UPDATE cms_modules SET content='" . $content . "' WHERE id=" . $id); } } if (cmsCore::inRequest('title_only')) { cmsCore::redirectBack(); } $xml_file = PATH . '/admin/modules/' . $module_name . '/backend.xml'; if (file_exists($xml_file)) { $cfg = array(); $backend = simplexml_load_file($xml_file); foreach ($backend->params->param as $param) { $name = (string) $param['name']; $type = (string) $param['type']; $default = (string) $param['default']; switch ($param['type']) { case 'number': $value = cmsCore::request($name, 'int', $default); break; case 'string': $value = cmsCore::request($name, 'str', $default); break; case 'html': $value = cmsCore::badTagClear(cmsCore::request($name, 'html', $default)); break; case 'flag': $value = cmsCore::request($name, 'int', 0); break; case 'list': $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default); break; case 'list_function': $value = cmsCore::request($name, 'str', $default); break; case 'list_db': $value = is_array($_POST[$name]) ? cmsCore::request($name, 'array_str', $default) : cmsCore::request($name, 'str', $default); break; } $cfg[$name] = $value; } } $cfg['tpl'] = cmsCore::request('tpl', 'str', $module_name); $inCore->saveModuleConfig($id, $cfg); if (!$is_ajax) { cmsCore::addSessionMessage($_LANG['AD_CONFIG_SAVE_SUCCESS'], 'success'); } cmsCore::redirectBack(); } if ($do == 'list') { $toolmenu = array(array('icon' => 'new.gif', 'title' => $_LANG['AD_MODULE_ADD'], 'link' => '?view=modules&do=add'), array('icon' => 'install.gif', 'title' => $_LANG['AD_MODULES_SETUP'], 'link' => '?view=install&do=module'), array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=edit&multiple=1');"), array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=delete&multiple=1');"), array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=show&multiple=1');"), array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=modules&do=hide&multiple=1');"), array('icon' => 'autoorder.gif', 'title' => $_LANG['AD_MODULE_ORDER'], 'link' => '?view=modules&do=autoorder'), array('icon' => 'reorder.gif', 'title' => $_LANG['AD_SAVE_ORDER'], 'link' => "javascript:checkSel('?view=modules&do=saveorder');"), array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=modules')); cpToolMenu($toolmenu); $fields = array(array('title' => 'id', 'field' => 'id', 'width' => '40'), array('title' => $_LANG['AD_TITLE'], 'field' => array('title', 'titles'), 'width' => '', 'link' => '?view=modules&do=edit&id=%id%', 'prc' => function ($i) { $i['titles'] = cmsCore::yamlToArray($i['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($i['titles'][cmsConfig::getConfig('lang')])) { $i['title'] = $i['titles'][cmsConfig::getConfig('lang')]; } return $i['title']; }), array('title' => $_LANG['TITLE'], 'field' => 'name', 'width' => '220', 'filter' => '15'), array('title' => $_LANG['AD_VERSION'], 'field' => 'version', 'width' => '70'), array('title' => $_LANG['AD_AUTHOR'], 'field' => 'author', 'width' => '110'), array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '80'), array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100'), array('title' => $_LANG['AD_POSITION'], 'field' => 'position', 'width' => '80', 'filter' => '10', 'filterlist' => cpGetList('positions'))); $actions = array(array('title' => $_LANG['AD_CONFIG'], 'icon' => 'config.gif', 'link' => '?view=modules&do=config&id=%id%', 'condition' => 'cpModuleHasConfig'), array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=modules&do=edit&id=%id%'), array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MODULE_DELETE'], 'link' => '?view=modules&do=delete&id=%id%')); cpListTable('cms_modules', $fields, $actions, '', 'published DESC, position, ordering ASC'); } if ($do == 'autoorder') { $rs = cmsCore::c('db')->query("SELECT id, position FROM cms_modules ORDER BY position"); if (cmsCore::c('db')->num_rows($rs)) { $ord = 1; while ($item = cmsCore::c('db')->fetch_assoc($rs)) { if (isset($latest_pos)) { if ($latest_pos != $item['position']) { $ord = 1; } } cmsCore::c('db')->query("UPDATE cms_modules SET ordering = " . $ord . " WHERE id=" . $item['id']); $ord += 1; $latest_pos = $item['position']; } } cmsCore::redirect('index.php?view=modules'); } if ($do == 'move_up') { if ($id >= 0) { dbMoveUp('cms_modules', $id, $co); } cmsCore::redirectBack(); } if ($do == 'move_down') { if ($id >= 0) { dbMoveDown('cms_modules', $id, $co); } cmsCore::redirectBack(); } if ($do == 'saveorder') { if (isset($_REQUEST['ordering'])) { $ord = $_REQUEST['ordering']; $ids = $_REQUEST['ids']; foreach ($ord as $id => $ordering) { cmsCore::c('db')->query("UPDATE cms_modules SET ordering = " . (int) $ordering . " WHERE id = " . (int) $ids[$id]); } cmsCore::redirect('index.php?view=modules'); } } if ($do == 'show') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '1'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '1'); cmsCore::redirectBack(); } } if ($do == 'hide') { if (!isset($_REQUEST['item'])) { if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '0'); } cmsCore::halt('1'); } else { cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '0'); cmsCore::redirectBack(); } } if ($do == 'delete') { if (!cmsCore::inRequest('item')) { $inCore->removeModule($id); } else { $inCore->removeModule(cmsCore::request('item', 'array_int', array())); } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); cmsCore::redirect('index.php?view=modules'); } if ($do == 'update') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $id = cmsCore::request('id', 'int', 0); $mod = cmsCore::c('db')->get_fields('cms_modules', "id = " . $id . "", '*'); $module = array('name' => cmsCore::request('name', 'str', ''), 'title' => cmsCore::request('title', 'str', ''), 'titles' => cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())), 'position' => cmsCore::request('position', 'str', ''), 'showtitle' => cmsCore::request('showtitle', 'int', 0), 'published' => cmsCore::request('published', 'int', 0), 'css_prefix' => cmsCore::request('css_prefix', 'str', ''), 'is_strict_bind' => cmsCore::request('is_strict_bind', 'int', 0), 'is_strict_bind_hidden' => cmsCore::request('is_strict_bind_hidden', 'int', 0), 'template' => cmsCore::request('template', 'str', ''), 'cache' => cmsCore::request('cache', 'int', 0), 'cachetime' => cmsCore::request('cachetime', 'int', 0), 'cacheint' => cmsCore::request('cacheint', 'str', ''), 'access_list' => '', 'hidden_menu_ids' => ''); if (!$mod['is_external']) { $module['content'] = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', '')); } $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $module['access_list'] = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array())); } cmsCore::c('db')->update('cms_modules', $module, $id); cmsCore::c('db')->delete('cms_modules_bind', "module_id=" . $id . " AND tpl='" . cmsCore::c('config')->template . "'"); if (cmsCore::request('show_all', 'int', 0)) { cmsCore::c('db')->insert('cms_modules_bind', array('module_id' => $id, 'menu_id' => 0, 'position' => $module['position'], 'tpl' => cmsCore::c('config')->template)); $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array()); if (!empty($hidden_menu_ids)) { $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids); cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='" . $hidden_menu_ids . "' WHERE id = '" . $id . "' LIMIT 1"); } } else { $showin = cmsCore::request('showin', 'array_int', array()); $showpos = cmsCore::request('showpos', 'array_str', array()); if (count($showin) > 0) { foreach ($showin as $key => $value) { cmsCore::c('db')->insert('cms_modules_bind', array('module_id' => $id, 'menu_id' => $value, 'position' => $showpos[$value], 'tpl' => cmsCore::c('config')->template)); } } } cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success'); if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) { cmsCore::redirect('index.php?view=modules'); } else { cmsCore::redirect('index.php?view=modules&do=edit'); } } if ($do == 'submit') { if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); } $maxorder = cmsCore::c('db')->get_field('cms_menu', '1=1 ORDER BY ordering DESC', 'ordering') + 1; $name = cmsCore::request('name', 'str', ''); $title = cmsCore::request('title', 'str', ''); $titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())); $position = cmsCore::request('position', 'str', ''); $showtitle = cmsCore::request('showtitle', 'int', 0); $content = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', '')); $published = cmsCore::request('published', 'int', 0); $css_prefix = cmsCore::request('css_prefix', 'str', ''); $is_public = cmsCore::request('is_public', 'int', ''); if (!$is_public) { $access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array())); } $template = cmsCore::request('template', 'str', ''); $cache = cmsCore::request('cache', 'int', 0); $cachetime = cmsCore::request('cachetime', 'int', 0); $cacheint = cmsCore::request('cacheint', 'str', ''); $operate = cmsCore::request('operate', array('user', 'clone'), ''); $is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0); $is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0); if ($operate == 'user') { //USER MODULE $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, user, original, css_prefix, access_list, template, is_strict_bind, is_strict_bind_hidden)\r\n VALUES ('" . $position . "', '" . $name . "', '" . $title . "', '" . $titles . "', 0, '" . $content . "', '" . $maxorder . "', '" . $showtitle . "', '" . $published . "', 1, 1, '" . $css_prefix . "', '" . $access_list . "', '" . $template . "', '" . $is_strict_bind . "', '" . $is_strict_bind_hidden . "')"; cmsCore::c('db')->query($sql); } if ($operate == 'clone') { //DUPLICATE MODULE $mod_id = cmsCore::request('clone_id', 'int', 0); $sql = "SELECT * FROM cms_modules WHERE id = " . $mod_id . " LIMIT 1"; $result = cmsCore::c('db')->query($sql); $original = cmsCore::c('db')->escape_string(cmsCore::c('db')->fetch_assoc($result)); $is_original = cmsCore::request('del_orig', 'int', 0) ? 1 : 0; $sql = "INSERT INTO cms_modules (position, name, title, titles, is_external, content, ordering, showtitle, published, original, user, config, css_prefix, template, access_list, is_strict_bind, is_strict_bind_hidden, cache, cachetime, cacheint, version)\r\n VALUES (\r\n '" . $position . "',\r\n '" . $original['name'] . "',\r\n '" . $title . "',\r\n '" . $titles . "',\r\n '" . $original['is_external'] . "',\r\n '" . $original['content'] . "',\r\n '" . $maxorder . "',\r\n '" . $showtitle . "',\r\n '" . $published . "',\r\n '" . $is_original . "',\r\n '" . $original['user'] . "',\r\n '" . $original['config'] . "',\r\n '" . $css_prefix . "',\r\n '" . $template . "',\r\n '" . $access_list . "',\r\n '" . $is_strict_bind . "',\r\n '" . $is_strict_bind_hidden . "',\r\n '" . $cache . "', \r\n '" . $cachetime . "',\r\n '" . $cacheint . "',\r\n '" . $original['version'] . "'\r\n )"; cmsCore::c('db')->query($sql); if (cmsCore::request('del_orig', 'int', 0)) { $sql = "DELETE FROM cms_modules WHERE id = " . $mod_id; cmsCore::c('db')->query($sql); } } $lastid = cmsCore::c('db')->get_last_id('cms_modules'); if (cmsCore::request('show_all', 'int', 0)) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl)\r\n VALUES (" . $lastid . ", 0, '" . $position . "', '" . cmsCore::c('config')->template . "')"; cmsCore::c('db')->query($sql); $hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array()); if ($hidden_menu_ids) { $hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids); cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='" . $hidden_menu_ids . "' WHERE id = '" . $lastid . "' LIMIT 1"); } } else { $showin = cmsCore::request('showin', 'array', array()); $showpos = cmsCore::request('showpos', 'array', array()); if (count($showin) > 0) { foreach ($showin as $key => $value) { $sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position, tpl)\r\n VALUES (" . $lastid . ", " . $value . ", '" . $showpos[$value] . "', '" . cmsCore::c('config')->template . "')"; cmsCore::c('db')->query($sql); } } } cmsCore::addSessionMessage($_LANG['AD_MODULE_ADD_SITE'], 'success'); cmsCore::redirect('index.php?view=modules'); } if ($do == 'add' || $do == 'edit') { if ($do == 'add') { cpAddPathway($_LANG['AD_MODULE_ADD']); echo '<h3>' . $_LANG['AD_MODULE_ADD'] . '</h3>'; $show_all = false; } else { if (cmsCore::inRequest('multiple')) { if (cmsCore::inRequest('item')) { $_SESSION['editlist'] = cmsCore::request('item', 'array_int', array()); } else { cmsCore::addSessionMessage($_LANG['AD_NO_SELECT_OBJECTS'], 'error'); cmsCore::redirectBack(); } } $ostatok = ''; if (isset($_SESSION['editlist'])) { $item_id = array_shift($_SESSION['editlist']); if (count($_SESSION['editlist']) == 0) { unset($_SESSION['editlist']); } else { $ostatok = '(' . $_LANG['AD_NEXT_IN'] . count($_SESSION['editlist']) . ')'; } } else { $item_id = cmsCore::request('id', 'int', 0); } $mod = cmsCore::c('db')->get_fields('cms_modules', "id = '" . $item_id . "'", '*'); if (!$mod) { cmsCore::error404(); } $mod['hidden_menu_ids'] = cmsCore::yamlToArray($mod['hidden_menu_ids']); $mod['titles'] = cmsCore::yamlToArray($mod['titles']); $show_all = false; $default_position = cmsCore::c('db')->get_field('cms_modules_bind', "module_id='" . $mod['id'] . "' AND menu_id=0 AND tpl='" . cmsCore::c('config')->template . "'", 'position'); if (!empty($default_position)) { $show_all = true; $mod['position'] = $default_position; } echo '<h3>' . $_LANG['AD_EDIT_MODULE'] . $ostatok . '</h3>'; cpAddPathway($mod['name']); } $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'); $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'javascript:history.go(-1);'); if (cmsCore::getArrVal($mod, 'is_external')) { $php_file = 'modules/' . $mod['content'] . '/backend.php'; $xml_file = 'modules/' . $mod['content'] . '/backend.xml'; if (file_exists($php_file) || file_exists($xml_file)) { $toolmenu[] = array('icon' => 'config.gif', 'title' => $_LANG['CONFIG_MODULE'], 'link' => '?view=modules&do=config&id=' . $mod['id']); } } cpToolMenu($toolmenu); $bind = array(); $bind_pos = array(); $cache = 0; if ($do == 'edit') { $bind_sql = "SELECT * FROM cms_modules_bind WHERE module_id = " . $mod['id'] . " AND tpl = '" . cmsCore::c('config')->template . "'"; $bind_res = cmsCore::c('db')->query($bind_sql); while ($r = cmsCore::c('db')->fetch_assoc($bind_res)) { $bind[] = $r['menu_id']; $bind_pos[$r['menu_id']] = $r['position']; } $cache = cmsCore::c('cache')->get('modules', $mod['id'], $mod['content'], array(cmsCore::getArrVal($mod, 'cachetime', 1), cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'))); } $menu_sql = "SELECT * FROM cms_menu ORDER BY NSLeft, ordering"; $menu_res = cmsCore::c('db')->query($menu_sql); $menu_items = array(); if (cmsCore::c('db')->num_rows($menu_res)) { while ($item = cmsCore::c('db')->fetch_assoc($menu_res)) { if ($do == 'edit') { if (in_array($item['id'], $bind)) { $item['selected'] = true; $item['position'] = $bind_pos[$item['id']]; } } $item['titles'] = cmsCore::yamlToArray($item['titles']); // переопределяем название пункта меню в зависимости от языка if (!empty($item['titles'][cmsCore::c('config')->lang])) { $item['title'] = $item['titles'][cmsCore::c('config')->lang]; } $item['title'] = str_replace($_LANG['AD_ROOT_PAGES'], $_LANG['AD_MAIN'], $item['title']); $menu_items[] = $item; } } cmsCore::c('page')->initTemplate('applets', 'modules_add')->assign('do', $do)->assign('langs', cmsCore::getDirsList('/languages'))->assign('pos', cpModulePositions(cmsCore::c('config')->template))->assign('positions_img_exist', file_exists(PATH . '/templates/' . cmsCore::c('config')->template . '/positions.jpg'))->assign('tpls', cmsAdmin::getModuleTemplates())->assign('modules_opt', $inCore->getListItems('cms_modules'))->assign('show_all', $show_all)->assign('groups', cmsUser::getGroups())->assign('kb_cache', !empty($cache) ? round(mb_strlen($cache) / 1024, 2) : false)->assign('menu_items', $menu_items)->assign('access_list', !empty($mod['access_list']) ? $inCore->yamlToArray($mod['access_list']) : array())->assign('mod', $mod)->display(); } }
/** * Получает статью * @return array */ public function getArticle($id_or_link) { if (isset($_SESSION['not_found'])) { unset($_SESSION['not_found']); } if (isset($_SESSION['lang_not_found'])) { unset($_SESSION['lang_not_found']); } if (is_numeric($id_or_link)) { $where = "con.id = '{$id_or_link}'"; } else { $where = "con.seolink = '{$id_or_link}'"; } $sql = "SELECT con.*,\n\t\t\t\t\t\tcat.title cat_title, cat.id cat_id, cat.NSLeft as leftkey, cat.NSRight as rightkey, cat.modgrp_id,\n\t\t\t\t\t\tcat.showtags as showtags, cat.seolink as catseolink, cat.cost, u.nickname as author, u.login as user_login\n\t\t\t\tFROM cms_content con\n\t\t\t\tINNER JOIN cms_category cat ON cat.id = con.category_id\n\t\t\t\tLEFT JOIN cms_users u ON u.id = con.user_id\n\t\t\t\tWHERE {$where} LIMIT 1"; $result = $this->inDB->query($sql); /*///////////// костыль для нахождения id статьи в других языках, если в текущем по $seolink статью не нашли ///////////// */ if (!$this->inDB->num_rows($result)) { $langs = cmsCore::getDirsList('/languages'); //unset($langs[0]); foreach ($langs as $lang) { if ($lang == 'ru') { $prefix_mas[$lang] = "vds_"; } else { $prefix_mas[$lang] = $lang . "_"; } } //unset($prefix_mas[$_SESSION['lang']]); foreach ($prefix_mas as $prefix) { $result = $this->inDB->query_new($sql, false, true, 'cms_', $prefix); //echo "<pre>"; var_dump($sql); //echo "<pre>"; var_dump($result); //echo "<pre>"; var_dump($prefix); if ($this->inDB->num_rows($result)) { $article_info = $this->inDB->fetch_assoc($result); $article_id = $article_info['id']; $where = "con.id = '{$article_id}'"; $sql = "SELECT con.*,\n\t\t\t\t\t\t\t\t\tcat.title cat_title, cat.id cat_id, cat.NSLeft as leftkey, cat.NSRight as rightkey, cat.modgrp_id,\n\t\t\t\t\t\t\t\t\tcat.showtags as showtags, cat.seolink as catseolink, cat.cost, u.nickname as author, u.login as user_login\n\t\t\t\t\t\t\tFROM cms_content con\n\t\t\t\t\t\t\tINNER JOIN cms_category cat ON cat.id = con.category_id\n\t\t\t\t\t\t\tLEFT JOIN cms_users u ON u.id = con.user_id\n\t\t\t\t\t\t\tWHERE {$where} LIMIT 1"; $result = $this->inDB->query($sql); break; } } //echo "<pre>"; var_dump($prefix_mas); exit(); //echo "<pre>"; var_dump($result); //exit(); } /* ---- */ if (!$this->inDB->num_rows($result)) { return false; } $article = $this->inDB->fetch_assoc($result); return $article; }
public function get_fields_lang($table, $where, $fields = '*', $order = 'id ASC') { $sql = "SELECT {$fields} FROM {$table} WHERE {$where} ORDER BY {$order} LIMIT 1"; $result = $this->query($sql); if ($this->num_rows($result)) { $data = $this->fetch_assoc($result); return $data; } else { $langs = cmsCore::getDirsList('/languages'); //unset($langs[0]); foreach ($langs as $lang) { if ($lang == 'ru') { $prefix_mas[$lang] = "vds_"; } else { $prefix_mas[$lang] = $lang . "_"; } } //unset($prefix_mas[$_SESSION['lang']]); foreach ($prefix_mas as $prefix) { $result = $this->query_new($sql, false, true, 'cms_', $prefix); //echo "<pre>"; var_dump($sql); //echo "<pre>"; var_dump($result); //echo "<pre>"; var_dump($prefix); if ($this->num_rows($result)) { $cat_info = $this->fetch_assoc($result); $cat_id = $cat_info['id']; $where = "id = '{$cat_id}'"; $sql = "SELECT {$fields} FROM {$table} WHERE {$where} ORDER BY {$order} LIMIT 1"; $result = $this->query($sql); break; } } if ($this->num_rows($result)) { $data = $this->fetch_assoc($result); return $data; } else { return false; } } }