示例#1
0
文件: addNote.php 项目: kbcmdba/pjs2
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once "Libs/autoload.php";
$config = new Config();
$webPage = new PJSWebPage($config->getTitle() . "Notes - Add Note");
$body = '';
$act = Tools::Param('act');
if ("Add Note" === $act) {
    $model = new NoteModel();
    $model->populateFromForm();
    if (!$model->validateForAdd()) {
        $view = new NoteFormView('Add Note', $model);
        $body = "<h2>Invalid data</h2>\n" . $view->getForm();
    } else {
        $noteController = new NoteController();
        $newId = $noteController->add($model);
        if ($newId > 0) {
            $body = "Added note # " . $newId . "<br />\n";
        }
    }
} else {
    $body = "";
    $noteModel = new NoteModel();
    $noteModel->setAppliesToTable(Tools::param('appliesToTable'));
    $noteModel->setAppliesToId(Tools::param('appliesToId'));
    $view = new NoteFormView("Add Note", $noteModel);
    $body = $view->getForm();
}
$webPage->setBody($body);
$webPage->displayPage();
示例#2
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once "Libs/autoload.php";
$config = new Config();
$webPage = new PJSWebPage($config->getTitle() . ' - Delete Note');
$act = Tools::Param('act');
if ("Delete Note" === $act) {
    $noteModel = new NoteModel();
    $noteModel->populateFromForm();
    if (!$noteModel->validateForDelete()) {
        $noteView = new NoteFormView('Delete Note', $noteModel);
        $body = "<h2>Invalid data</h2>\n" . $noteView->getForm();
    } else {
        $noteController = new NoteController();
        $noteController->delete($noteModel);
        $body = "Deleted note # " . $noteModel->getId() . "<br />\n";
    }
} else {
    $noteController = new NoteController();
    $noteModel = $noteController->get(Tools::param('id'));
    $noteView = new NoteFormView('Delete Note', $noteModel);
    $body = $noteView->getForm();
}
$webPage->setBody($body);
$webPage->displayPage();
示例#3
0
    /**
     *
     * @return string
     */
    public function getForm($readOnly = 'readwrite')
    {
        $RO = 'readonly' === $readOnly ? 'READONLY="READONLY" ' : '';
        $searchModel = $this->_searchModel;
        $title = $this->getTitle();
        $id = $searchModel->getId();
        $engineName = htmlspecialchars($searchModel->getEngineName());
        $searchName = htmlspecialchars($searchModel->getSearchName());
        $url = htmlspecialchars($searchModel->getUrl());
        $created = $searchModel->getCreated();
        $updated = $searchModel->getUpdated();
        $buttonLabel = $this->getButtonLabel();
        if (Tools::isNumeric($id)) {
            $noteController = new NoteController('read');
            $noteModels = $noteController->getSome("appliesToTable = 'search' and appliesToId = {$id}");
            $noteListView = new NoteListView('html', $noteModels);
            $noteListView->setNoteModels($noteModels);
            $noteListView->setAppliesToTable('search');
            $noteListView->setAppliesToId($id);
            $noteListViewText = $noteListView->getView();
        } else {
            $noteListViewText = '';
        }
        $returnValue = <<<HTML
    <h2>{$title}</h2>
    <form name="search" onsubmit="return validateSearch()" method="GET">
      <table border="1" cellspacing="1" cellpadding="2">
        <tr>
          <th>ID</th>
          <td><input type="text" name="id" value="{$id}" readonly="readonly" /></td>
        </tr>
        <tr>
          <th>Engine Name *</th>
          <td><input type="text" name="engineName" value="{$engineName}" {$RO} /></td>
        </tr>
        <tr>
          <th>Search Name *</th>
          <td><input type="text" name="searchName" value="{$searchName}" {$RO} /></td>
        </tr>
        <tr>
          <th>URL *</th>
          <td><input type="text" name="url" value="{$url}" {$RO} /></td>
        </tr>
        <tr>
          <th>Created</th>
          <td><input type="text" name="created" value="{$created}" disabled="disabled" /></td>
        </tr>
        <tr>
          <th>Updated</th>
          <td><input type="text" name="updated" value="{$updated}" disabled="disabled" /></td>
        </tr>
        <tr>
          <td colspan="2">
            <center>
              <input type="reset" /> &nbsp; &nbsp; <input type="submit" name="act" value="{$buttonLabel}" />
            </center>
          </td>
        </tr>
      </table>
    </form>
    {$noteListViewText}
HTML;
        return $returnValue;
    }