コード例 #1
0
ファイル: theme.php プロジェクト: anastiel/lainchan
 /**
  * Build and save the HTML of the catalog for the Ukko theme
  */
 public function buildUkko()
 {
     global $config;
     $ukkoSettings = themeSettings('ukko');
     $queries = array();
     $threads = array();
     $exclusions = explode(' ', $ukkoSettings['exclude']);
     $boards = array_diff(listBoards(true), $exclusions);
     foreach ($boards as $b) {
         if (array_key_exists($b, $this->threadsCache)) {
             $threads = array_merge($threads, $this->threadsCache[$b]);
         } else {
             $queries[] = $this->buildThreadsQuery($b);
         }
     }
     // Fetch threads from boards that haven't beenp processed yet
     if (!empty($queries)) {
         $sql = implode(' UNION ALL ', $queries);
         $res = query($sql) or error(db_error());
         $threads = array_merge($threads, $res->fetchAll(PDO::FETCH_ASSOC));
     }
     // Sort in bump order
     usort($threads, function ($a, $b) {
         return strcmp($b['bump'], $a['bump']);
     });
     // Generate data for the template
     $recent_posts = $this->generateRecentPosts($threads);
     $this->saveForBoard($ukkoSettings['uri'], $recent_posts, $config['root'] . $ukkoSettings['uri']);
 }
コード例 #2
0
ファイル: functions.php プロジェクト: Cipherwraith/infinity
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);
    }
}
コード例 #3
0
ファイル: mod.php プロジェクト: niksfish/Tinyboard
     } else {
         // install failed
         $query = prepare("DELETE FROM `theme_settings` WHERE `theme` = :theme");
         $query->bindValue(':theme', $_theme);
         $query->execute() or error(db_error($query));
     }
     $body .= '<p style="text-align:center"><a href="?/themes">Go back to themes</a>.</p>';
     // Build themes
     rebuildThemes('all');
     echo Element('page.html', array('config' => $config, 'title' => $result ? 'Installed "' . utf8tohtml($theme['name']) . '"' : 'Installation failed!', 'body' => $body, 'mod' => true));
 } else {
     $body = '<form action="" method="post">';
     if (!isset($theme['config']) || empty($theme['config'])) {
         $body .= '<p style="text-align:center" class="unimportant">(No configuration required.)</p>';
     } else {
         $settings = themeSettings($_theme);
         $body .= '<table>';
         foreach ($theme['config'] as &$c) {
             $body .= '<tr><th>' . $c['title'] . '</th><td>';
             switch ($c['type']) {
                 case 'text':
                 default:
                     $body .= '<input type="text" name="' . utf8tohtml($c['name']) . '" ' . (isset($settings[$c['name']]) ? ' value="' . utf8tohtml($settings[$c['name']]) . '" ' : (isset($c['default']) ? 'value="' . utf8tohtml($c['default']) . '" ' : '')) . (isset($c['size']) ? 'size="' . (int) $c['size'] . '" ' : '') . '/>';
             }
             if (isset($c['comment'])) {
                 $body .= ' <span class="unimportant">' . $c['comment'] . '</span>';
             }
             $body .= '</td></tr>';
         }
         $body .= '</table>';
     }
コード例 #4
0
ファイル: pages.php プロジェクト: vicentil/vichan
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)));
}