Subversion Repositories travelsized

Rev

Rev 152 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?PHP
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of Travelsized CMS
 *              A content management system with modules, based on wiki syntax
 *
 * Author: Dan Jensen <admin@leinir.dk>
 * Copyright 2003/2004
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The GNU General Public License is available at: http://www.gnu.org/copyleft/
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


$page_author = $creator_name;
$page_author_email = $creator_email;
$page_menu = 1;
$page_date = formatTime( time() );
$page_title = i18n("Page setup");

if( array_key_exists( "username", $_REQUEST ) && array_key_exists( "password", $_REQUEST ) && !auth( $_REQUEST["username"], $_REQUEST["password"] ) )
        $page_content = loginform($language, globalIDtoURL("setup/pagesetup"), $auth_messages);
else if( isauth() )
{
        $setupPage = new setupPage;
        $setupPage->addBreadcrumb( i18n("Pages"), globalIDtoURL("setup/pagesetup") );
        $setupPage->addCommand( i18n("Rebuild page index"), i18n("If you have manually deleted a page, click here to regenerate the page index, to pages show up properly in the system"), globalIDtoURL("setup/pagesetup/rebuild") );
        $setupPage->addCommand( i18n("New"), i18n("Create a new page"), globalIDtoURL("setup/editpage/$language/" . i18n("New page") ) );
       
        if ($theAction == "rebuild")
        {
                update_getpage_id($page_folder, $setup_folder, $pagectl);
                $setupPage->contents = "<p>" . i18n("The reverse lookup table for pages has been rebuilt") . "</p>";
        }
        //Manage pages (delete, update \$page-to-\$page_id backwards lookup index (setup/page_backwards.txt))


        if( $theAction == "delete" && $deleteID != "" )
        {
                global $setup_folder;
                if( array_key_exists( "confirm_delete", $_REQUEST ) && $_REQUEST["confirm_delete"] == "true" )
                {
                        // get array $pagefiles
                        $fp = opendir("$setup_folder/pages");
                        while( $file = readdir($fp) )
                                if( substr($file, 0, strlen("$deleteID.")) == "$deleteID." )
                                        $pagefile[] ="$setup_folder/pages/$file";
                       
                        closedir($fp);

                        foreach( $pagefile as $key => $value )
                                if( !unlink("$value") )
                                        $setupPage->contents = "<p>" . i18n("An error occured during the removal of the page files!") . "</p>";
                       
                        if( $setupPage->contents == "" )
                                header("Location: " . globalIDtoURL("setup/pagesetup") );
                }
                else
                {
                        $setupPage->contents = "
                                <p>"
. i18n("Please confirm that you wish to delete the page with ID ##0##", array($deleteID)) . "</p>
                                <p class=\"wikicenteralign\">
                                "
. drawCommand( i18n("Confirm delete"), i18n("Confirm that you wish to delete this page"), globalIDtoURL("setup/pagesetup/delete/$deleteID", array( "confirm_delete" => "true" ) ) ) . "
                                "
. drawCommand( i18n("Abort delete"), i18n("Abort the deletion process"), globalIDtoURL("setup/pagesetup") ). "
                                </p>"
;
                }
        }
        else
        {
                $pages_temp = $pagectl->fetchPageList($page_folder);
                sort($pages_temp);
               
                $setupPage->contents = "
                                <table class=\"setup\">
                                        <tr class=\"setup\">
                                        <th class=\"setup\" width=\"8%\">"
. i18n("ID") . "</th>
                                        <th class=\"setup\">"
. i18n("Title (click to edit)") . "</th>
                                        <th class=\"setup\" width=\"12%\">"
. i18n("Language") . "</th>
                                        <th class=\"setup\" width=\"12%\">"
. i18n("Delete") . "</th>
                                        </tr>
                                        <tr class=\"setup\">
                                        <td class=\"setup\">
                                                <div>0</div>
                                        </td>
                                        <td class=\"setup\">
                                                <div><em>"
. i18n("Front page") . "</em></div>
                                        </td>
                                        <td class=\"setup wikicenteralign\">"
;
                        foreach ($languages as $key => $value) {
                                $setupPage->contents .= "                                       <div><a class=\"command\" href=\"" . globalIDtoURL("setup/editpage/$value/0") . "\">[$value]</a></div>";
                        }
                        $setupPage->contents .= "</td>
                                        <td class=\"setup\">
                                        &nbsp;
                                        </td>
                                        </tr>"
;
       
                $bgarray[1] = "#e0e0e0";
                $bgarray[2] = "transparent";
                if( count($pages_temp) > 0 )
                {
                        foreach( $pages_temp as $key => $value )
                        {
                                $bgarray = array_reverse($bgarray);
                                $setupPage->contents .= "
                                                        <tr class=\"setup\"><td class=\"setup\" style=\"background-color: {$bgarray[1]}\"><div>{$value["
id"]}</div></td>
                                                                <td class=\"setup\" style=\"background-color: {$bgarray[1]}\">"
;
                                foreach( $value["title"] as $key2 => $value2 )
                                        $setupPage->contents .= "<div><a href=\"" . globalIDtoURL("setup/editpage/{$value['language'][$key2]}/{$value["id"]}") . "\">$value2</a></div>";
                               
                                $setupPage->contents .= "</td><td style=\"background-color: {$bgarray[1]}\"  class=\"setup wikicenteralign\">";
                                foreach ($value["language"] as $key2 => $value2)
                                        $setupPage->contents .= "<div><a href=\"" . globalIDtoURL("setup/editpage/{$value['language'][$key2]}/{$value["id"]}") . "\">[$value2]</a></div>";
                               
                                $setupPage->contents .= "</td><td style=\"background-color: {$bgarray[1]}\"  class=\"setup wikirightalign\"><a class=\"command\" href=\"" . globalIDtoURL("setup/pagesetup/delete/{$value['id']}") . "\">[" . i18n("Delete") . "]</a></td></tr>";
                        }
                }
                $setupPage->contents .= "
                        </td></tr></table>"
;
        }
        $page_content = $setupPage->render();
}
?>