Subversion Repositories travelsized

Rev

Rev 473 | 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("Menu setup");

if( array_key_exists( "username", $_REQUEST ) && array_key_exists( "password", $_REQUEST ) && !auth( $_REQUEST["username"], $_REQUEST["password"] ) )
        $page_content = loginform($language, globalIDtoURL("setup/menusetup"), $auth_messages);
else if( !isAllowed("global_menus") )
        $page_content = "<p>" . i18n("You do not have the correct permissions to edit menus") . "</p>";
else if( isauth() )
{
        $setupPage = new setupPage;
        $setupPage->addBreadcrumb( i18n("Menus"), globalIDtoURL("setup/menusetup") );
        $setupPage->addCommand( i18n("New"), i18n("Create a new menu"), globalIDtoURL("setup/editmenu/" . rawurlencode(i18n("New menu"))) );
       
        if ($theAction == "assign")
        {
                if( array_key_exists( "assign", $_POST ) && $_POST["assign"] )
                {
                        $assignto = $_POST["pages"];
                        if( is_array($assignto) )
                        {
                                global $page_folder;
                                foreach( $assignto as $key => $value )
                                {
                                        $temp_page = $pagectl->fetchPageData($key, $value);
                                        $pagectl->savePageData($page_folder, $temp_page["id"], $temp_page["language"], $temp_page["author"], $temp_page["email"], $theMenuID, $temp_page["title"], $temp_page["content"]);
                                }
                        }
                        header("Location: " . globalIDtoURL("setup/menusetup") );
                }
                else
                {
                        $pages_temp = $pagectl->fetchPageList($page_folder);
                        sort($pages_temp);
                        $setupPage->contents = "
                        <div align=\"center\">
                                <form action=\""
. thisPageURL() . "\" method=\"POST\">
                                <table class=\"setup\">
                                        <tr class=\"setup\">
                                                <th class=\"setup\" width=\"8%\">"
. i18n("ID") . "</th>
                                                <th class=\"setup\" width=\"12%\">"
. i18n("Assign") . "</th>
                                                <th class=\"setup\">"
. i18n("Title (click to edit)") . "</th>
                                                <th class=\"setup\" width=\"12%\">"
. i18n("Language") . "</th>
                                        </tr>"
;
                       
                        $bgarray[1] = "transparent";
                        $bgarray[2] = "#e0e0e0";
                        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 )
                                {
                                        $temp_page = $pagectl->fetchPageData($value["id"], $value["language"][$key2]);
                                        if ($temp_page["menu"] == $theMenuID) {
                                                $setupPage->contents .= "<div><label><input type=\"checkbox\" disabled checked />" . i18n("Assign") . "</label></div>";
                                        } else {
                                                $setupPage->contents .= "<div><label><input type=\"checkbox\" name=\"pages[{$value["id"]}]\" value=\"{$value['language'][$key2]}\" />" . i18n("Assign") . "</label></div>";
                                        }
                                }
                                $setupPage->contents .= "
                                                </td>
                                                <td class=\"setup\" style=\"background-color: {$bgarray[1]}\">"
;
                                foreach ($value["title"] as $key2 => $value2)
                                        $setupPage->contents .= "<div><a href=\"" . globalIDtoURL("content/{$value['language'][$key2]}/{$value["id"]}") . "\">$value2</a></div>";
                               
                                $setupPage->contents .= "
                                                </td>
                                                <td class=\"setup\" style=\"background-color: {$bgarray[1]}\">"
;
                                foreach ($value["language"] as $key2 => $value2)
                                        $setupPage->contents .= "<div>[$value2]</div>";
                               
                                $setupPage->contents .= "
                                                </td>
                                        </tr>"
;
                        }
                        $setupPage->contents .= "
                                </td></tr></table>
                                <input type=\"submit\" name=\"assign\" value=\""
. i18n("Assign") . "\" />
                                <input type=\"reset\" value=\""
. i18n("Reset changes") . "\" />
                                </div>"
;
                }
        }
        else if( $theAction == "delete" && $theMenuID != "" )
        {
                global $setup_folder;
                if ($deleteComfirm) {
                        if( removeUsergroup("menu_" . $theMenuID . "_view") && removeUsergroup("menu_" . $theMenuID . "_edit") )
                        {
                                // get array $menufiles$fp = opendir("$setup_folder/modules");
                                $fp = opendir("$setup_folder/menus");
                                while( $file = readdir($fp) )
                                        if( substr($file, 0, strlen("$theMenuID.")) == "$theMenuID." )
                                                $menufile[] ="$setup_folder/menus/$file";
                               
                                closedir($fp);

                                foreach ($menufile as $key => $value)
                                        if( !unlink("$value") )
                                                $setupPage->contents = "<p>" . i18n("An error occured during the removal of the menu files!") . "</p>";
                               
                                if( $setupPage->contents == "" )
                                        header("Location: " . globalIDtoURL("setup/menusetup") );
                        }
                        else
                                $setupPage->contents = "<p>" . i18n("An error occured during removal of the usergroups that are assigned to this menu!") . "</p>";
               
                }
                else
                {
                        $setupPage->contents = "
                                <p>"
. i18n("Please confirm that you wish to delete the menu with ID ##0##", array($theMenuID)) . "</p>
                                <p class=\"wikicenteralign\">
                                "
. drawCommand( i18n("Confirm delete"), i18n("Confirm menu delete"), globalIDtoURL("setup/menusetup/delete/$theMenuID/confirm") ) . "
                                "
. drawCommand( i18n("Abort delete"), i18n("Abort the deletion process"), globalIDtoURL("setup/menusetup") ) . "
                                </p>"
;
                }
        }
        else
        {
                $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=\"15%\">"
. i18n("Functions") . "</th>
                                </tr>"
;
       
                //Make the Menu menu sub-section
                $bgarray = array();
                $bgarray[1] = "transparent";
                $bgarray[2] = "#e0e0e0";
                $temp_menus = $pagectl->fetchMenuMenuList($menu_folder);
                foreach( $temp_menus as $key => $value )
                {
                        if( is_array($value["language"]) )
                        {
                                $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["language"] as $key2 => $value2)
                                        $setupPage->contents .= "<div align=\"left\"><a href=\"" . globalIDtoURL("setup/editmenu/$value2/{$value["id"]}") . "\">{$value['title'][$key2]}</a></div>";
                               
                                $setupPage->contents .= "
                                        </td>
                                        <td class=\"setup\" style=\"text-align: center; background-color: {$bgarray[1]};\">"
;
                                foreach( $value["language"] as $key2 => $value2 )
                                        $setupPage->contents .= "<div><a href=\"" . globalIDtoURL("setup/editmenu/$value2/{$value["id"]}") . "\">[{$value2}]</a></div>";
                               
                                $setupPage->contents .= "
                                        <td class=\"setup\" style=\"background-color: {$bgarray[1]}; text-align: right;\"><div>
                                                "
. drawCommand( i18n("Delete"), i18n("Delete the menu"), globalIDtoURL("setup/menusetup/delete/{$value['id']}") ) . "
                                                "
. drawCommand( i18n("Assign"), i18n("Assign the menu to multipple pages"), globalIDtoURL("setup/menusetup/assign/{$value["id"]}") ) . "
                                                </div>
                                        </td>
                                </tr>"
;
                        }
                        else
                        {
                                $setupPage->contents .= "
                                <tr>
                                        <td class=\"setup\" style=\"background-color: {$bgarray[1]};\"><div>{$value["
id"]}</div></td>
                                        <td class=\"setup\" style=\"background-color: {$bgarray[1]};\"><div align=\"left\"><a href=\""
. globalIDtoURL("setup/editmenu/$value2/{$value["id"]}") . "\">{$value["title"]}</a></div></td>
                                        <td class=\"setup\" style=\"background-color: {$bgarray[1]};\"><div>[{$value["
language"]}]</div></td><td style=\"background-color: {$bgarray[1]}; text-align: right;\"><div>
                                                "
. drawCommand( i18n("Assign"), i18n("Assign the menu to multipple pages"), globalIDtoURL("setup/menusetup/assign/{$value["id"]}") ) . "
                                        </div></td>
                                </tr>"
;
                        }
                }
               
                $setupPage->contents .= "
                        </td></tr></table>"
;
        }
        $page_content = $setupPage->render();
}
?>