예제 #1
0
 public static function getInstance()
 {
     if (self::$theInstance == null) {
         self::$theInstance = new ElectionService();
     }
     return self::$theInstance;
 }
예제 #2
0
<?php

/*
Copyright: All contributers to the Umple Project
This file is made available subject to the open source license found at:
http://umple.org/license
*/
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'loadAllElections':
            require_once "ElectionService.php";
            $allElections = ElectionService::getInstance()->getElections();
            echo $allElections;
            break;
        case 'loadAllPositions':
            require_once "PositionService.php";
            $allPositions = PositionService::getInstance()->getPositions();
            echo $allPositions;
            break;
        case 'addElectionForPosition':
            require_once "ElectionForPositionService.php";
            $first = true;
            $result = '';
            foreach ($_POST as $json) {
                if (!$first) {
                    ElectionForPositionService::getInstance()->setEfpJSON($json);
                    $result = $result . ElectionForPositionService::getInstance()->getLatestResult();
                } else {
                    $first = false;
                }
            }
예제 #3
0
<?php

/*
Copyright: All contributers to the Umple Project
This file is made available subject to the open source license found at:
http://umple.org/license
*/
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'addElection':
            require_once "ElectionService.php";
            ElectionService::getInstance()->setElectionJSON($_POST['electionJSON']);
            $result = ElectionService::getInstance()->getLatestResult();
            echo $result;
            break;
    }
} else {
    echo <<<_OUT
\t\t<!DOCTYPE html>
        <html>
                <head>
\t\t\t\t\t<script type="text/javascript" src="addelection.js"></script>
\t\t\t\t\t<link rel="stylesheet" href="usecase.css" />
                </head>
                <body>
                    <div class="mainForm">
\t\t\t\t\t\t<label for="electionName">Enter an election name:</label>
\t\t\t\t\t\t\t\t<input type="text" id="electionName"></input>
\t\t\t\t\t\t<label for="electionDescriptiom">Enter an election description:</label>
\t\t\t\t\t\t\t\t<input type="text" id="electionDescription"></input>
\t\t\t\t\t\t<button id="addElection" onclick="addElection()">add</button>