コード例 #1
0
ファイル: index.php プロジェクト: Rambutan/hamsterpaj
        $out .= '<input type="text" name="title" maxlength="100">' . "\n";
        $out .= '<input type="submit" class="button_100" value="Skapa artikel" />' . "\n";
        $out .= '</form>' . "\n";
        $out .= rounded_corners_bottom();
        break;
    case 'show':
        //If the user wish to see only one article
        $article = articles_fetch(array('id' => $_GET['id']));
        $out .= render_full_article($article);
        //$out .= '<a href="?action=list&category=' . $article['category_id'] . '">&laquo; Se alla artiklar i kategorin</a>' . "\n";
        break;
    case 'list':
        $ui_options['menu_path'] = array('artiklar', 'all');
        if (isset($_GET['category'])) {
            $ui_options['menu_path'] = array('artiklar', $_GET['category']);
            $category = categories_fetch(array('id' => $_GET['category']));
            $out .= '<h1>' . $category['name'] . '</h1>' . "\n";
        }
        $options['category'] = $_GET['category'];
        // If no category is set, itt will return null.
        $articles = articles_fetch($options);
        $out .= articles_list($articles);
        break;
    default:
        $ui_options['menu_path'] = array('artiklar', 'start');
        $out .= rounded_corners_top(array('color' => 'orange'));
        $out .= '<h1>I artikelarkivet kan man hitta en massa roliga artiklar</h1>' . "\n";
        $out .= rounded_corners_bottom(array('color' => 'orange'));
        $articles = articles_fetch();
        $out .= articles_list($articles);
}
コード例 #2
0
ファイル: articles.lib.php プロジェクト: Rambutan/hamsterpaj
function article_form($article)
{
    if (isset($article['id'])) {
        $edit = '&id=' . $article['id'];
    }
    $output .= '<form action="?article=submit' . $edit . '" method="post">' . "\n";
    $output .= '<input style="width: 99%; font-size: 20px;" name="title" value="' . $article['title'] . '" />' . "\n";
    if (isset($article['id'])) {
        $output .= '<textarea name="content" style="width: 99%; height: 400px;">' . file_get_contents(PATHS_INCLUDE . 'articles/' . $article['id'] . '.php') . '</textarea>' . "\n";
    } else {
        $output .= '<textarea name="content" style="width: 99%; height: 400px;"></textarea>' . "\n";
    }
    $output .= '<label for="summary">Sammanfattning</label>' . "\n";
    $output .= '<textarea name="summary" style="width: 99%; height: 100px;">' . $article['summary'] . '</textarea>' . "\n";
    $output .= '<label for="category">Kategori</label>' . "\n";
    $output .= '<select name="category">' . "\n";
    $output .= '<option value="">Ingen kategori</option>' . "\n";
    $categories = categories_fetch();
    foreach ($categories as $category) {
        if ($article['category_id'] == $category['id']) {
            $selected = ' selected="selected"';
        }
        $output .= '<option' . $selected . ' value="' . $category['id'] . '">' . $category['name'] . '</option>' . "\n";
        $selected = "";
        //Empties the variabel for next time
    }
    $output .= '</select>' . "\n";
    $output .= '<label for="author">Författare</label>' . "\n";
    $output .= '<select name="author">' . "\n";
    $output .= '<option value="">Anonym</option>' . "\n";
    $handle = opendir(PATHS_INCLUDE . 'article_authors/');
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            if ($article['author'] == substr($file, 0, -4)) {
                $selected = ' selected="selected"';
            }
            $output .= '<option ' . $selected . ' value="' . substr($file, 0, -4) . '">' . substr($file, 0, -4) . '</option>' . "\n";
            $selected = "";
            //Empties the variabel for next time
        }
    }
    $output .= '</select><br />' . "\n";
    $output .= '<label for="Published">Publicerad:</label>' . "\n";
    $checked .= $article['published'] == 1 ? ' checked="checked"' : '';
    $output .= '<input type="checkbox" name="published" value="1"' . $checked . '>' . "\n";
    $checked = "";
    $output .= '<label for="commentable">Möjlighet att kommentera:</label>' . "\n";
    $checked .= $article['commentable'] == 1 ? ' checked="checked"' : '';
    $output .= '<input type="checkbox" name="commentable" value="1"' . $checked . '>' . "\n";
    $checked = "";
    $output .= '<label for="ranktable">Möjlighet att betygssätta:</label>' . "\n";
    $checked .= $article['rankable'] == 1 ? ' checked="checked"' : '';
    $output .= '<input type="checkbox" name="rankable" value="1"' . $checked . '><br />' . "\n";
    $checked = "";
    $output .= '<label for="showauthor">Visa författare:</label>' . "\n";
    $checked .= $article['showauthor'] == 1 ? ' checked="checked"' : '';
    $output .= '<input type="checkbox" name="showauthor" value="1"' . $checked . '>' . "\n";
    $checked = "";
    $output .= '<label for="listed">Visa listad i artikelarkivet:</label>' . "\n";
    $checked .= $article['listed'] == 1 ? ' checked="checked"' : '';
    $output .= '<input type="checkbox" name="listed" value="1"' . $checked . '>' . "\n";
    $checked = "";
    $output .= '<label for="breaklayout">Bryt standardlayouten:</label>' . "\n";
    $checked .= $article['breaklayout'] == 1 ? ' checked="checked"' : '';
    $output .= '<input type="checkbox" name="breaklayout" value="1"' . $checked . '><br />' . "\n";
    $checked = "";
    $output .= '<label for="create_forum_category">Skapa en forumkategori(har du kryssat i knappen så kommer kategorin att skapas när du klickar på spara ändringar, sedan kan du inte ta bort forumkategorin):</label>' . "\n";
    $checked .= isset($article['forum_category_id']) && $article['forum_category_id'] != 0 ? ' checked="checked" disabled="disabled"' : '';
    $output .= '<input type="checkbox" name="create_forum_category" value="1"' . $checked . '><br />' . "\n";
    $checked = "";
    $output .= '<input type="text" name="forum_category_id" value="' . $article['forum_category_id'] . '" style="display: none;""><br />' . "\n";
    $output .= '<input type="submit" class="button" value="Spara ändringar" />' . "\n";
    if (isset($article['id'])) {
        $output .= '<a target="_blank" href="upload_photos.php?article_id=' . $article['id'] . '">Ladda upp bilder</a>';
    } else {
        $output .= 'Fulkodat skräp. Du måste spara artikeln innan du kan ladda upp bilder' . "\n";
    }
    $output .= '</form>' . "\n";
    return $output;
}