Permalink
Browse files

Method Chaining

  • Loading branch information...
unknown
unknown committed Dec 31, 2011
1 parent 54208d8 commit 455598cb5adb06e2e5fbf0b27144f6e488af8081
@@ -1,62 +0,0 @@
-<?php
-/**
- * Access from index.php:
- */
-if(!defined("_access")) {
- die("Error: You don't have permission to access here...");
-}
-
-class Agenda_Controller extends ZP_Controller {
-
- public function __construct() {
- $this->app("agenda");
-
- $this->Agenda_Model = $this->model("Agenda_Model");
-
- $this->Templates = $this->core("Templates");
-
- $this->Templates->theme(_webTheme);
- }
-
- public function index() {
- print __("Welcome to Agenda");
- }
-
- public function add() {
- $vars["view"] = $this->view("add", TRUE);
-
- if(POST("save")) {
- $vars["alert"] = $this->Agenda_Model->save();
- }
-
- $this->template("content", $vars);
- }
-
- public function contact($contactID) {
- $data = $this->Agenda_Model->getContact($contactID);
-
- ____($data);
- }
-
- public function name($name) {
- $data = $this->Agenda_Model->getContactByName($name);
-
- ____($data);
- }
-
- public function phoneAndEmail($phone, $email) {
- $data = $this->Agenda_Model->getContactByPhoneAndEmail($phone, $email);
-
- ____($data);
- }
-
- public function contacts() {
- $data = $this->Agenda_Model->getAllContacts();
-
- $vars["contacts"] = $data;
- $vars["view"] = $this->view("contacts", TRUE);
-
- $this->template("content", $vars);
- }
-
-}
@@ -1,63 +0,0 @@
-<?php
-/**
- * Access from index.php:
- */
-if(!defined("_access")) {
- die("Error: You don't have permission to access here...");
-}
-
-class Agenda_Model extends ZP_Model {
-
- public function __construct() {
- $this->Db = $this->db();
-
- $this->helpers();
-
- $this->table = "agenda";
- }
-
- public function save() {
- if(!POST("name")) {
- return getAlert("Error falta el nombre");
- } elseif(!isEmail(POST("email"))) {
- return getAlert("Error, email invalido");
- } elseif(!POST("phone")) {
- return getAlert("Error falta telefono");
- }
-
- $data = array(
- "Name" => POST("name"),
- "Email" => POST("email"),
- "Phone" => POST("phone")
- );
-
- $this->Db->insert($this->table, $data);
-
- return getAlert("Nuevo contacto agregado con &eacute;xito", "success");
- }
-
- public function getContact($contactID) {
- $data = $this->Db->find($contactID, $this->table);
-
- return $data;
- }
-
- public function getContactByName($name) {
- $data = $this->Db->findBy("Name", $name, $this->table);
-
- return $data;
- }
-
- public function getContactByPhoneAndEmail($phone, $email) {
- $data = $this->Db->findBySQL("Phone = '$phone' AND Email = '$email'", $this->table);
-
- return $data;
- }
-
- public function getAllContacts() {
- $data = $this->Db->findAll($this->table);
-
- return $data;
- }
-
-}
@@ -1,28 +0,0 @@
-<p>Nuevo contacto</p>
-
-<form action="<?php print _webBase; ?>/agenda/add" method="post">
- <fieldset>
- <p>
- <?php print isset($alert) ? $alert : NULL; ?>
- </p>
-
- <p>
- Nombre: <br />
- <input name="name" type="text" />
- </p>
-
- <p>
- Email: <br />
- <input name="email" type="text" />
- </p>
-
- <p>
- Phone: <br />
- <input name="phone" type="text" />
- </p>
-
- <p>
- <input name="save" type="submit" value="Guardar" />
- </p>
- </fieldset>
-</form>
@@ -1,14 +0,0 @@
-<p>Lista de contactos:</p>
-
-<p>
- <?php
- if(is_array($contacts)) {
- foreach($contacts as $contact) {
- print 'ID: '. $contact["ID_Contact"] .'<br />';
- print __(_("Name")) .': '. $contact["Name"] .'<br />';
- print __(_("Email")) .': '. $contact["Email"] .'<br />';
- print __(_("Phone")) .': '. $contact["Phone"] .'<br />';
- }
- }
- ?>
-</p>
@@ -1,11 +0,0 @@
-<?php
-/**
- * Access from index.php:
- */
-if(!defined("_access")) {
- die("Error: You don't have permission to access here...");
-}
-
-define("_RESTAuth", TRUE);
-define("_RESTUser", "zanphp");
-define("_RESTPwd", "12345");
@@ -1,90 +0,0 @@
-<?php
-/**
- * Access from index.php:
- */
-if(!defined("_access")) {
- die("Error: You don't have permission to access here...");
-}
-
-class Agenmongo_Controller extends ZP_Controller {
-
- public function __construct() {
- $this->application = $this->app("agenmongo");
-
- $this->Agenmongo_Model = $this->model("Agenmongo_Model");
-
- $this->Templates = $this->core("Templates");
-
- $this->Templates->theme(_webTheme);
-
- $this->RESTServer = $this->core("RESTServer");
-
- $this->RESTServer->application($this->application);
- }
-
- public function index() {
- print __("Welcome to Agenda");
- }
-
- public function contacts() {
- $data = $this->Agenmongo_Model->getAllContacts();
-
- ____($data);
- }
-
- public function add() {
- if($this->RESTServer->isREST(TRUE, "POST")) {
- $data = $this->Agenmongo_Model->add();
-
- if($data) {
- $message = $this->RESTServer->message("The contact has been inserted correctly");
- } else {
- $message = $this->RESTServer->message("Insert fail", TRUE);
- }
- } else {
- $message = $this->RESTServer->message("Invalid REST request", TRUE);
- }
-
- $this->RESTServer->response($message, FALSE, "POST");
- }
-
- public function contact($contactID) {
- $data = $this->Agenmongo_Model->getContact($contactID);
-
- if($data) {
- if($this->RESTServer->isREST(4)) {
- $this->RESTServer->process($data, 5);
- } else {
- $vars["contacts"] = $data;
- $vars["view"] = $this->view("contacts", TRUE);
-
- $this->template("content", $vars);
- }
- } else {
- $this->template("error404");
- }
- }
-
- public function email($email) {
- $data = $this->Agenmongo_Model->getContactByEmail($email);
-
- ____($data);
- }
-
- public function edit($contactID, $name, $email, $phone) {
- $data = array(
- "Name" => $name,
- "Email" => $email,
- "Phone" => $phone
- );
-
- $response = $this->Agenmongo_Model->update($contactID, $data);
-
- ____($response);
- }
-
- public function save($name, $email, $phone) {
- $this->Agenmongo_Model->save($name, $email, $phone);
- }
-
-}
@@ -1,99 +0,0 @@
-<?php
-/**
- * Access from index.php:
- */
-if(!defined("_access")) {
- die("Error: You don't have permission to access here...");
-}
-
-class Otraapp_Controller extends ZP_Controller {
-
- public function __construct() {
- $this->application = $this->app("otraapp");
-
- $this->helpers();
-
- $this->RESTClient = $this->core("RESTClient");
- }
-
- public function addRecord() {
- $this->RESTClient->setURL("http://127.0.0.1/ZanPHP/index.php/agenmongo/add");
- $this->RESTClient->setAuth("zanphp", "12345");
-
- $data = array(
- "Name" => "Héctor",
- "Email" => "ceron@milkzoft.com",
- "Phone" => "1111111111"
- );
-
- $response = $this->RESTClient->POST($data);
-
- ____($response);
- }
-
- public function index() {
- print __("Welcome to Agenda");
- }
-
- public function contacts() {
- $data = $this->Agenmongo_Model->getAllContacts();
-
- ____($data);
- }
-
- public function add() {
- if($this->RESTServer->isREST(TRUE, "POST")) {
- $data = $this->Agenmongo_Model->add();
-
- if($data) {
- $message = $this->RESTServer->message("The contact has been inserted correctly");
- } else {
- $message = $this->RESTServer->message("Insert fail", TRUE);
- }
- } else {
- $message = $this->RESTServer->message("Invalid REST request", TRUE);
- }
-
- $this->RESTServer->response($message, FALSE, "POST");
- }
-
- public function contact($contactID) {
- $data = $this->Agenmongo_Model->getContact($contactID);
-
- if($data) {
- if($this->RESTServer->isREST(4)) {
- $this->RESTServer->process($data, 5);
- } else {
- $vars["contacts"] = $data;
- $vars["view"] = $this->view("contacts", TRUE);
-
- $this->template("content", $vars);
- }
- } else {
- $this->template("error404");
- }
- }
-
- public function email($email) {
- $data = $this->Agenmongo_Model->getContactByEmail($email);
-
- ____($data);
- }
-
- public function edit($contactID, $name, $email, $phone) {
- $data = array(
- "Name" => $name,
- "Email" => $email,
- "Phone" => $phone
- );
-
- $response = $this->Agenmongo_Model->update($contactID, $data);
-
- ____($response);
- }
-
- public function save($name, $email, $phone) {
- $this->Agenmongo_Model->save($name, $email, $phone);
- }
-
-}
Oops, something went wrong.

0 comments on commit 455598c

Please sign in to comment.