Exemplo n.º 1
0
 public function execute()
 {
     if (empty($_POST['city'])) {
         throw new InvalidParamException();
     }
     $result = Office::fromDatabaseSearchByCity($_POST['city']);
     $content = array();
     $content['NumOffices'] = count($result);
     $content['Offices'] = array();
     foreach ($result as $office) {
         $officeObj = array('Code' => $office->getCode(), 'Name' => $office->getName(), 'City' => $office->getCity(), 'Address' => $office->getAddress(), 'Host' => $office->getHost());
         $content['Offices'][] = $officeObj;
     }
     return $content;
 }
Exemplo n.º 2
0
    public function getTableRows()
    {
        $offices = Office::fromDatabaseSearchByCity($this->city);
        if (!$offices) {
            return "\n    <tr><td colspan=\"4\">Nessun ufficio trovato.</td></tr>";
        }
        $rows = '';
        foreach ($offices as $office) {
            $rows .= <<<EOS
    <tr>
        <td>{$office->getCode()}</td>
        <td>{$office->getName()}</td>
        <td>{$office->getCity()}</td>
        <td>{$office->getAddress()}</td>
        <td><a href="http://{$office->getHost()}">{$office->getHost()}</a></td>
    </tr>
EOS;
        }
        return $rows;
    }