Example #1
0
/**
 * GOOD PRACTICE FOR VIEWS:
 *
 * A view should only display data and should not access the methods of the calling controller.
 * A view can:
 * - use the content of PHP variables defined by the calling controller + action
 * - define PHP variables locally (be careful to not crush the PHP variables defined by the calling controller)
 * - use utility classes to do data formatting
 * - integrate other views
 * - contain client code for web browsers (html, css, javascript, etc...)
 * - be tested to display data without using any controller
 * A view MUST NOT:
 * - contain "$this" or "self", i.e. no direct reference to methods and properties of the calling controller!
 * - directly access to the context of the web application (variables $_GET, $_POST, $_SESSION, $GLOBALS, etc...),
 *   because the calling controller is responsible for that!
 */
use PHPYAM\core\Core;
?>
<h2>Choose your demo:</h2>

<ul>
<li><a href="<?php 
echo Core::url('form1', 'index');
?>
">Form with field validation and resubmit control</a></li>
<li><a href="<?php 
echo Core::url('form2', 'index');
?>
">Form with field validation, Ajax submit and resubmit control</a></li>
</ul>
Example #2
0
		value="Validate">

	<div style="display: <?php 
echo $_logs !== '' ? 'block' : 'none';
?>
;">
		<div id="feedback-panel-id"><?php 
echo $_logs;
?>
</div>
	</div>
</form>

<div style="position: fixed; bottom: 0;">
	<a href="<?php 
echo Core::url(DEFAULT_CONTROLLER, DEFAULT_ACTION);
?>
">Go back to
		home page</a>
</div>

<script type="text/javascript">
$(document).ready(function() {
	// Initialization of the form validation plugin
	$("#form-id").validate();

	// Attach a submit handler to the form
	$("#submit-button-id").click(function(event) {

		// Stop form from submitting normally
		event.preventDefault();
Example #3
0
			<tr>
				<th>Key</th>
				<th>Value</th>
			</tr>
		</thead>
		<tbody>
<?php 
foreach ($_POST as $key => $value) {
    ?>
			<tr>
				<td><?php 
    echo Core::html($key);
    ?>
</td>
				<td><?php 
    echo Core::html($value);
    ?>
</td>
			</tr>
<?php 
}
?>
		</tbody>
	</table>

	<input type="button" name="cancel-button" id="cancel-button-id"
		value="Cancel" onclick="location.href='<?php 
echo URL;
?>
'"> <input
		type="submit" name="submit-button" id="submit-button-id"
Example #4
0
	<script type="text/javascript" src="<?php 
echo URL_PUB;
?>
js/jquery/1.12.4/jquery<?php 
echo YAM_MIN;
?>
.js"></script>
	<![endif]-->
	<!--[if gte IE 9]><!-->
	<script type="text/javascript" src="<?php 
echo URL_PUB;
?>
js/jquery/2.2.4/jquery<?php 
echo YAM_MIN;
?>
.js"></script>
	<!--<![endif]-->
</head>
<body>
<?php 
if (isset($_pageTitle)) {
    ?>
	<h1><?php 
    echo Core::html($_pageTitle);
    ?>
</h1>
<?php 
}
?>

Example #5
0
 public function confirm()
 {
     $formValues = array();
     Assert::isTrue(IntelliForm::submitted(true), 'The form was not submitted.');
     Assert::isTrue($this->checkFormValues($formValues), 'The form data is invalid.');
     $_htmlFormValues = $formValues;
     Core::htmlize($_htmlFormValues);
     // load views.
     $_pageTitle = 'CONFIRMATION OF DATA ENTRY';
     require __DIR__ . '/../views/__templates/header.php';
     require __DIR__ . '/../views/form2/confirm.php';
     require __DIR__ . '/../views/__templates/footer.php';
 }
Example #6
0
 * A view should only display data and should not access the methods of the calling controller.
 * A view can:
 * - use the content of PHP variables defined by the calling controller + action
 * - define PHP variables locally (be careful to not crush the PHP variables defined by the calling controller)
 * - use utility classes to do data formatting
 * - integrate other views
 * - contain client code for web browsers (html, css, javascript, etc...)
 * - be tested to display data without using any controller
 * A view MUST NOT:
 * - contain "$this" or "self", i.e. no direct reference to methods and properties of the calling controller!
 * - directly access to the context of the web application (variables $_GET, $_POST, $_SESSION, $GLOBALS, etc...),
 *   because the calling controller is responsible for that!
 */
use PHPYAM\core\Core;
?>
<div>
	<ul>
		<?php 
if (is_array($_listOfErrors)) {
    foreach ($_listOfErrors as $error) {
        if ($error instanceof Exception) {
            echo '<li><span>' . preg_replace('/\\r\\n?|\\n/', '<br />', Core::html($error)) . '</span></li>';
        } else {
            echo '<li><span>' . Core::html($error) . '</span></li>';
        }
    }
}
?>
	</ul>
</div>
Example #7
0
 /**
  * (non-PHPdoc)
  *
  * @see \PHPYAM\core\interfaces\IRouter::forward()
  */
 public final function forward($urlController, $urlAction, array $urlParameters = array(), $clearOutputBuffersBeforeRedirect = true)
 {
     if ($clearOutputBuffersBeforeRedirect) {
         // We empty all buffers.
         while (ob_get_level() > 0) {
             ob_end_clean();
         }
     }
     // We check that the header() statements have been taken into account,
     // which is only possible if the HTTP headers have not been sent yet.
     Assert::isFalse(headers_sent(), StringUtils::gettext('HTTP headers have already been sent.'));
     header('location:' . Core::url($urlController, $urlAction, $urlParameters));
 }