Exemplo n.º 1
0
         }
         // Scan directory for themes
         $themes = array();
         while ($file = readdir($dir)) {
             if ($file[0] != '.' && is_dir($config['dir']['themes'] . '/' . $file)) {
                 $themes[] = $file;
             }
         }
         closedir($dir);
         $body = '';
         if (empty($themes)) {
             $body = '<p style="text-align:center" class="unimportant">(No themes installed.)</p>';
         } else {
             $body .= '<table class="modlog">';
             foreach ($themes as &$_theme) {
                 $theme = loadThemeConfig($_theme);
                 markup($theme['description']);
                 $body .= '<tr>' . '<th class="minimal">' . _('Name') . '</th>' . '<td>' . utf8tohtml($theme['name']) . '</td>' . '</tr>' . '<tr>' . '<th class="minimal">' . _('Version') . '</th>' . '<td>' . utf8tohtml($theme['version']) . '</td>' . '</tr>' . '<tr>' . '<th class="minimal">' . _('Description') . '</th>' . '<td>' . $theme['description'] . '</td>' . '</tr>' . '<tr>' . '<th class="minimal">' . _('Thumbnail') . '</th>' . '<td><img style="float:none;margin:4px' . (isset($themes_in_use[$_theme]) ? ';border:2px solid red;padding:4px' : '') . '" src="' . $config['dir']['themes_uri'] . '/' . $_theme . '/thumb.png" /></td>' . '</tr>' . '<tr>' . '<th class="minimal">' . _('Actions') . '</th>' . '<td><ul style="padding:0 20px">' . '<li><a title="' . _('Use theme') . '" href="?/themes/' . $_theme . '">' . (isset($themes_in_use[$_theme]) ? _('Reconfigure') : _('Install')) . '</a></li>' . (isset($themes_in_use[$_theme]) ? '<li><a href="?/themes/' . $_theme . '/rebuild">' . _('Rebuild') . '</a></li>' . '<li><a href="?/themes/' . $_theme . '/uninstall">' . _('Uninstall') . '</a></li>' : '') . '</ul></td>' . '</tr>' . '<tr style="height:40px"><td colspan="2"><hr/></td></tr>';
             }
             $body .= '</table>';
         }
         if (!empty($themes_in_use)) {
             $body .= '<p style="text-align:center"><a href="?/themes/none">' . _('Uninstall all themes.') . '</a></p>';
         }
         echo Element('page.html', array('config' => $config, 'title' => _('Manage themes'), 'body' => $body, 'mod' => true));
     }
 } elseif (preg_match('/^\\/noticeboard\\/delete\\/(\\d+)$/', $query, $match)) {
     if (!hasPermission($config['mod']['noticeboard_delete'])) {
         error($config['error']['noaccess']);
     }
     $query = prepare("DELETE FROM `noticeboard` WHERE `id` = :id");
Exemplo n.º 2
0
function rebuildTheme($theme, $action, $board = false)
{
    global $config, $_theme;
    $_theme = $theme;
    $theme = loadThemeConfig($_theme);
    if (file_exists($config['dir']['themes'] . '/' . $_theme . '/theme.php')) {
        require_once $config['dir']['themes'] . '/' . $_theme . '/theme.php';
        $theme['build_function']($action, themeSettings($_theme), $board);
    }
}
Exemplo n.º 3
0
function mod_theme_configure($theme_name)
{
    global $config;
    if (!hasPermission($config['mod']['themes'])) {
        error($config['error']['noaccess']);
    }
    if (!($theme = loadThemeConfig($theme_name))) {
        error($config['error']['invalidtheme']);
    }
    if (isset($_POST['install'])) {
        // Check if everything is submitted
        foreach ($theme['config'] as &$conf) {
            if (!isset($_POST[$conf['name']]) && $conf['type'] != 'checkbox') {
                error(sprintf($config['error']['required'], $c['title']));
            }
        }
        // Clear previous settings
        $query = prepare("DELETE FROM ``theme_settings`` WHERE `theme` = :theme");
        $query->bindValue(':theme', $theme_name);
        $query->execute() or error(db_error($query));
        foreach ($theme['config'] as &$conf) {
            $query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, :name, :value)");
            $query->bindValue(':theme', $theme_name);
            $query->bindValue(':name', $conf['name']);
            if ($conf['type'] == 'checkbox') {
                $query->bindValue(':value', isset($_POST[$conf['name']]) ? 1 : 0);
            } else {
                $query->bindValue(':value', $_POST[$conf['name']]);
            }
            $query->execute() or error(db_error($query));
        }
        $query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, NULL, NULL)");
        $query->bindValue(':theme', $theme_name);
        $query->execute() or error(db_error($query));
        $result = true;
        $message = false;
        if (isset($theme['install_callback'])) {
            $ret = $theme['install_callback'](themeSettings($theme_name));
            if ($ret && !empty($ret)) {
                if (is_array($ret) && count($ret) == 2) {
                    $result = $ret[0];
                    $message = $ret[1];
                }
            }
        }
        if (!$result) {
            // Install failed
            $query = prepare("DELETE FROM ``theme_settings`` WHERE `theme` = :theme");
            $query->bindValue(':theme', $theme_name);
            $query->execute() or error(db_error($query));
        }
        // Build themes
        rebuildThemes('all');
        mod_page(sprintf(_($result ? 'Installed theme: %s' : 'Installation failed: %s'), $theme['name']), 'mod/theme_installed.html', array('theme_name' => $theme_name, 'theme' => $theme, 'result' => $result, 'message' => $message));
        return;
    }
    $settings = themeSettings($theme_name);
    mod_page(sprintf(_('Configuring theme: %s'), $theme['name']), 'mod/theme_config.html', array('theme_name' => $theme_name, 'theme' => $theme, 'settings' => $settings, 'token' => make_secure_link_token('themes/' . $theme_name)));
}