public function addAction() { $this->initalize(); $msg = new Messages(); $success = $msg->save($this->request->getPost(), array('title', 'text')); if (!$success) { $this->_msgs['error'] = array(); foreach ($msg->getMessages() as $msgs) { $this->_msgs['error'] = $msgs; } $this->flash->error($this->_msgs['error']); } else { $this->flash->success('success adding message'); $this->_msgs['success'] = "Success adding Message"; } $this->view->form = new MessageForm(); $this->view->form->initalize(); if ($this->request->isPost()) { $this->view->form->clear(); $this->dispatcher->forward(array("controller" => "message", "action" => "list")); } }
<?php // Business Delegate // load all scripts into memory require_once 'Parameters.php'; require_once 'NewUserAction.php'; //require_once('init.php'); //loadScripts(); $data = array("status" => "not set!"); if (Utils::isPOST()) { if (Utils::isAJAX()) { $parameters = new Parameters("POST"); $userNewAction = new NewUserAction(); $userNewAction->setParameters($parameters); $response = $userNewAction->register(); if ($response) { $data = array("status" => "success", "user" => $response, "msgs" => Messages::getMessages()); } else { // error message $data = array("status" => "error", "msg" => Messages::getMessages()); } } else { $data = array("status" => "error", "msg" => "AJAX Required."); } } else { $data = array("status" => "error", "msg" => "Only POST allowed."); } // lastly send JSON response echo json_encode($data, JSON_FORCE_OBJECT); // for objects do this: // json_encode(get_object_vars($your_object));
<!DOCTYPE html> <!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en" xml:lang="en"><![endif]--> <!--[if IE 7]><html class="no-js lt-ie9 lt-ie8" lang="en" xml:lang="en"><![endif]--> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" xml:lang="en"><![endif]--><!--[if gt IE 8]><!--> <html class="no-js" lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <!--<![endif]--> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>Old Boys Soccer League</title> <link rel="stylesheet" href="css/uikit.min.css" /> <script src="jquery-2.1.4.min.js"></script> <script src="js/uikit.min.js"> </script> <link type='text/css' title='standard' rel='stylesheet' href='style_messaging.css' /> <link type='text/css' title='standard' rel='stylesheet' href='media.css' /> </head> <body class="en" > <div class="container"> <div class="navbar navbar-sectionheader"> <div class="header-top"> <img class="header-image" src="../oldboys_pictures/OldboysLogoPNG.png" /> </div> <div class="menu-wrap"> <!-- This is the container enabling the JavaScript --> <div class="uk-button-dropdown" data-uk-dropdown> <!-- This is the button toggling the dropdown -->
$profile = $showUserProfileAction->getProfile(); // here's where we can choose how to render: AJAX or non-AJAX // this might affect how we output the data (i.e., JSON vs HTML) if (Utils::isAJAX()) { $data = array(); // AJAX means that we'll send it as JSON - at least for this call if ($profile == null) { // didn't find a profile with that name $data = array("status" => "error", "msg" => Messages::getMessages()); } else { $data = array("status" => "success", "profile" => $profile); } echo json_encode($data, JSON_FORCE_OBJECT); return; } else { // render the whole page using PHPTAL // finally, create a new template object $template = new PHPTAL('index.xhtml'); // now add the variables for processing and that you created from above: $template->page_title = "Index With Design Patterns"; $template->profile = $profile; // messages last $template->messages = Messages::getMessages(); // execute the template try { echo $template->execute(); } catch (Exception $e) { // not much else we can do here if the template engine barfs echo $e; } }
<?php require_once 'connection.php'; require_once 'models/chat-model.php'; $conn = getConnection(); $model = new Messages(); $messages = $model->getMessages(); var_dump($messages); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Chattin'</title> </head> <body> <form action="" method="GET"> <input type="textarea"></input> <input type="submit"></input> </form> </body> </html>
require_once $controller; $content_var = $smarty->get_template_vars('CONTENT'); if (empty($content_var)) { $content_var = $page . '.tpl'; } } else { if (file_exists($template)) { $content_var = $page . '.tpl'; } else { header("HTTP/1.1 404 Not Found"); $smarty->assign('ERROR', 'The page you are trying to access does not exists.'); $smarty->assign('ERROR_TITLE', 'Page not found'); $content_var = 'components/error.tpl'; } } $smarty->assign('CONTENT', $content_var); #index: $index = $smarty->get_template_vars('INDEX'); if (empty($index)) { if (empty($_GET['index'])) { $index = 'components/index.tpl'; } else { $index = 'components/' . $_GET['index'] . '.tpl'; } } #solve CSS cache problem: $smarty->assign('CSS_TIMESTAMP', filemtime($config->absolute_path . '/admin/css/index.css')); $smarty->assign('config', $config); $smarty->assign('page', $page); $smarty->assign('messages', Messages::getMessages()); $smarty->display($index);
$result = $msg->setMsgState('unerase', $data['id']); if ($result->resultado) { echo 'ok'; } } break; case "set_erase_send": $msg = new Messages($db); $filtros = array(); $filtros['id_message_user'] = $data['id']; if ($_SESSION['user']['type'] == PATIENT) { $user_id = $_SESSION['user']['id']; } else { $user_id = 1; } $result = $msg->getMessages($_SESSION['user']['type'], $user_id, $filtros); if ($result->resultado) { $result = $msg->setMsgState('erase_send', $data['id']); if ($result->resultado) { echo 'ok'; } } break; case "get_admins": $admin = new Admin($db); $result = $admin->getAdminsList(); if ($result->resultado) { $encode = array(); for ($i = 0; $i < count($result->datos); $i++) { $encode[] = $result->datos[$i]; }
function getMessages() { $messages = new Messages(); echo $messages->getMessages(); }
<?php include_once "../includes/webservice.inc.php"; $webService = new Webservices_Writer(); $webService->init(); $messageObj = new Messages(); $data = isset($_POST['data']) ? $_POST['data'] : ''; $result = $messageObj->getMessages($data); if ($result) { $webService->createXMLInstance(); $webService->appendArrayToRootNode('', $result); $webService->displayXML(); } else { $xmls = $webService->errorXML(join(",", $messageObj->errorMessages)); $webService->outputXML($xmls); }
// Business Delegate // load all scripts into memory //require_once('init.php'); require_once 'Parameters.php'; require_once 'ShowUserProfileAction.php'; require_once 'Utils.php'; //loadScripts(); $data = array("status" => "not set!"); if (Utils::isPOST()) { if (Utils::isAJAX()) { $parameters = new Parameters("POST"); $userProfileAction = new ShowUserProfileAction(); $userProfileAction->setParameters($parameters); $response = $userProfileAction->getProfile(); if ($response) { $data = array("status" => "success", "user" => $response, "msgs" => Messages::getMessages()); } else { // error message $data = array("12status" => "error", "msg" => Messages::getMessages()); } } else { $data = array("13status" => "error", "msg" => "AJAX Required.", "msg" => Messages::getMessages()); } } else { $data = array("status" => "error", "msg" => "Only POST allowed.", "msg" => Messages::getMessages()); } // lastly send JSON response echo json_encode($data, JSON_FORCE_OBJECT); // for objects do this: // json_encode(get_object_vars($your_object));
/** Display list of messages sent * @access public * @return void */ public function indexAction() { $this->view->params = $this->getAllParams(); $this->view->messages = $this->_messages->getMessages($this->getAllParams()); }