Пример #1
0
function dashboard_widgets()
{
    $_widgets = mcache_get('cn:widgets');
    $selected = REQ('selected');
    // Apply the changes
    if (request_type('POST')) {
        cn_dsi_check();
        // Apply PLUGIN section
        if (isset($_POST['submit_plugin'])) {
            if ($_POST['delete']) {
                $plugin_name = REQ('plugin_name');
                @unlink(SERVDIR . '/cdata/plugins/' . $plugin_name . '.php');
                cn_throw_message('Plugin deleted');
            }
        } elseif (isset($_POST['submit_widget'])) {
            // call syscall for widget
            if ($wn = $_POST['widget_name']) {
                // Save widget data in CuteNews
                if (isset($_POST['wsettings']) && is_array($_POST['wsettings'])) {
                    setoption("widget/{$wn}", $_POST['wsettings']);
                }
                // save in module
                cn_widget($wn, '?dosave');
            }
        }
    }
    $s_plugin = '';
    $s_widget = '';
    $widget_current = '';
    $plugin_current = '';
    $widget_settings = '';
    // ---
    $widgets = array();
    if (is_array($_widgets)) {
        foreach ($_widgets as $wn => $w1) {
            foreach ($w1 as $w) {
                $WD5 = substr(md5("{$wn}:{$w}"), 0, 8);
                $widgets[] = array('group' => $wn, 'name' => $w, 'md5' => $WD5, 'selected' => $WD5 === $selected ? TRUE : FALSE, 'alias' => cn_widget($w, '?alias'));
                if ($WD5 === $selected) {
                    $s_widget = array($wn, $w);
                }
            }
        }
    }
    // widget selected
    if ($s_widget) {
        ob_start();
        cn_widget($s_widget[0], '?settings');
        $widget_settings = ob_get_clean();
        $widget_current = $s_widget[0];
    }
    // --
    $plugins = scan_dir(SERVDIR . '/cdata/plugins');
    foreach ($plugins as $id => $plugin) {
        $PD5 = substr(md5("plugin:{$plugin}"), 0, 8);
        $plugins[$id] = array('md5' => $PD5, 'selected' => $PD5 === $selected ? TRUE : FALSE, 'name' => str_replace('.php', '', $plugin));
        if ($PD5 === $selected) {
            $s_plugin = $plugins[$id]['name'];
        }
    }
    // plugin selected
    if ($s_plugin) {
        $plugin_current = $s_plugin;
    }
    cn_assign('widgets, plugins, widget_settings, widget_current, plugin_current, s_widget', $widgets, $plugins, $widget_settings, $widget_current, $plugin_current, $s_widget);
    echoheader('-@dashboard/style.css', 'Plugins');
    echo exec_tpl('dashboard/widgets');
    echofooter();
}
Пример #2
0
function cn_extrn_init()
{
    global $template;
    if ($template == 'rss') {
        return;
    }
    $i18n = getoption('i18n');
    if (!$i18n) {
        $i18n = 'en_US';
    }
    // Facebook initialzie
    if ((getoption('use_fbcomments') || getoption('use_fblike')) && !mcache_get('fb_js_on') && $template != 'rss') {
        echo str_replace(array('{appID}', '{fbi18n}'), array(getoption('fb_appid'), str_replace('-', '_', $i18n)), read_tpl('fb_comments'));
        mcache_set('fb_js_on', true);
    }
    // Definition G+ code uses
    if (getoption('use_gplus') && !mcache_get('gplus_js_on') && $template != 'rss') {
        echo str_replace('{lang}', $i18n, read_tpl('google_plus'));
        mcache_set('gplus_js_on', true);
    }
    // First init CN script
    if (!mcache_get('cn:extr_init')) {
        echo preg_replace('/\\s{2,}/s', ' ', read_tpl('cnscript'));
        mcache_set('cn:extr_init', true);
    }
}