<?php 
    # $Id: structuredPage.inc.php,v 1.6 2007/01/14 15:09:20 jarda Exp $

    /* Defines structured page classes
    */
    
    require_once('page.inc.php');
    
    /* Superclass of all structured page classes
    */
    abstract class StructuredPage extends Page {

        abstract function getTitle();
        
        
        /* Creates standard structured page. Subclasses are not supposed to override
        * this method, instead they are supposed to implement printContents()
        * method
        */
        function createPage()
        {
            $head = $this->getHead($this->getTitle());
            echo "<html>
$head
    <body>
        <div class=\"container\">
        <div class=\"leftcolumn\">
        <a href=\"index.php\"><img src=\"logo.png\" frame=\"0\"></a><br>
        ";
            $this->insertMenu();
            echo "        </div>
            <div class=\"contents\">";
            $this->printContents();
            echo "        </div>
        </div>
    </body>
</html>";
        }


        /* Inserts main menu to the page
        */
        function insertMenu()
        {
            if ($this->userIsLoggedIn())
            {
                echo "<ul><li><a href=\"logout.php\">Log out</a></li></ul>\n";
                if ($this->userCanChangeOwnPassword())
                    echo "<ul><li><a href=\"password_EDIT.php\">Password change</a></li></ul>\n";
            }
            else
            {
                echo "<ul><li><a href=\"login.php\">Log in</a></li></ul>\n";
            }

            if ($this->userCanEditUserAccounts())
            {
                echo "<h2>Users administration</h2>\n";
                echo "<ul>\n";
                echo "<li><a href=\"users_LISTING.php\">Users listing</a></li>\n";
                echo "</ul>\n";
            }

            if ($this->userCanEditDB())
            {
                echo "<h2>Database editing</h2>\n";
                echo "<ul>\n";
                echo "<li><a href=\"benchmarkInstance_NEW.php\">Benchmark instance addition</a></li>\n";
                echo "</ul>\n";
            }

            echo "<h2>Database browsing</h2>";
            echo "<ul><li><a href=\"benchmarkSets_LISTING.php\">Benchmark sets listing</a></li>";
            echo "<li><a href=\"formats_LISTING.php\">Formats listing</a></li>";
                echo "<li><a href=\"benchmarkInstances_SEARCH.php\">Search benchmark instances</a></li>";
            echo "</ul>";
         }

    }


    /* Superclass of structured page classes that just display some data about benchmarks
    */
    abstract class ViewStructuredPage extends StructuredPage {

        function getRequiredAccessLevel()
        {
            return 'view';
        }
        
    }


    /* Superclass of structured page classes that edit some benchmarks data
    */
    abstract class EditDBStructuredPage extends StructuredPage {
        function getRequiredAccessLevel()
        {
            return 'editDB';
        }
    }


    /* Superclass of structured page classes that edit user accounts (or display the other users' data)
    */
    abstract class EditUserAccountsStructuredPage extends StructuredPage {
        function getRequiredAccessLevel()
        {
            return 'editUserAccounts';
        }
    }


    /* Superclass of structured page classes that edit own password
    */
    abstract class ChangeOwnPasswordStructuredPage extends StructuredPage {
        function getRequiredAccessLevel()
        {
            return 'changeOwnPassword';
        }
    }
            
    // vim:enc=iso8859-2:fenc=iso8859-2:
?>
