Beispiel #1
0
/**
 * Updates customization mode (design/translation/css editor)
 * @param array $modes list of modes with statuses
 * @return bool true if mode updated, false - otherwise
 */
function fn_update_customization_mode($modes)
{
    if (!empty($modes)) {
        $available_modes = fn_get_customization_modes();
        $enabled_modes = fn_array_combine(explode(',', Registry::get('settings.customization_mode')), true);
        foreach ($modes as $c_mode => $c_status) {
            if (empty($available_modes[$c_mode])) {
                // skip enable/disable for non-existent modes
                continue;
            }
            if ($c_status == 'enable') {
                $enabled_modes[$c_mode] = true;
            } elseif ($c_status == 'disable') {
                unset($enabled_modes[$c_mode]);
            }
        }
        Settings::instance()->updateValue('customization_mode', implode(',', array_keys($enabled_modes)));
        return true;
    }
    return false;
}
*                                                                          *
*   (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev    *
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($mode == 'disable_mode') {
    if (!empty($_REQUEST['type'])) {
        $c_mode = $_REQUEST['type'];
        $avail_modes = array_keys(fn_get_customization_modes());
        if (!in_array($c_mode, $avail_modes)) {
            return array(CONTROLLER_STATUS_NO_PAGE);
        }
        if ($c_mode == 'theme_editor') {
            unset($_SESSION['demo_customize_theme']);
        }
        fn_update_customization_mode(array($c_mode => 'disable'));
        return array(CONTROLLER_STATUS_OK, 'index.index');
    }
}
//comparison list number for footer
$view->assign('comparison_list_no', count($_SESSION["comparison_list"]));
Beispiel #3
0
/**
 * Updates customization mode (design/translation/css editor)
 * @param array $modes list of modes with statuses
 * @return bool true if mode updated, false - otherwise
 */
function fn_update_customization_mode($modes)
{
    if (empty($modes)) {
        return false;
    }
    $available_modes = fn_get_customization_modes();
    $enabled_modes = fn_array_combine(explode(',', Registry::get('settings.customization_mode')), true);
    foreach ($modes as $c_mode => $c_status) {
        if (empty($available_modes[$c_mode])) {
            // skip enable/disable for non-existent modes
            continue;
        }
        if ($c_status == 'enable') {
            $enabled_modes[$c_mode] = true;
        } elseif ($c_status == 'disable') {
            unset($enabled_modes[$c_mode]);
        }
    }
    /**
     * Hook is executed before saving enabled customization modes to DB.
     *
     * @param array $modes List of modes to be changed passed to function
     * @param array $enabled_modes Modes that will be enabled
     * @param array $available_modes All available modes
     */
    fn_set_hook('update_customization_mode', $modes, $enabled_modes, $available_modes);
    Settings::instance()->updateValue('customization_mode', implode(',', array_keys($enabled_modes)));
    return true;
}