PHP Classes

File: controllers/controller.view.php

Recommend this page to a friend!
  Classes of Kristo Vaher  >  Wave Framework  >  controllers/controller.view.php  >  Download  
File: controllers/controller.view.php
Role: Class source
Content type: text/plain
Description: View Controller
Class: Wave Framework
MVC framework for building Web sites and APIs
Author: By
Last change: Fixed a problem where access-control header settings were not set properly. Removed code that was used for testing purposes and accidentally submitted to live. Added JSONP support for JavaScript wrapper as well as JSONV support (which is like JSONP, except it defines a variable instead of callback). Added a new 'file-extensions' configuration setting that is used when routing a request to File Handler. This allows to use '.' symbol in regular website URL's, since File Handler requests are whitelisted with configuration now. Methods getState(), getCookie() and getSession() now return 'null' values, if they have not been set, instead of false.
Date: 8 years ago
Size: 9,891 bytes


Class file image Download

 * Wave Framework <>
 * View Controller
 * Wave Framework comes with a View Controller and a translations system that is used to build
 * a website on Wave Framework. This View Controller is entirely optional and can be removed
 * from a system if you plan to implement your own View Controller or simply use Wave Framework
 * for API, without a website.
 * @package Tools
 * @author Kristo Vaher <>
 * @copyright Copyright (c) 2012, Kristo Vaher
 * @license GNU Lesser General Public License Version 3
 * @tutorial /doc/pages/guide_view.htm
 * @since 1.0.0
 * @version 3.6.9

class WWW_controller_view extends WWW_Factory {

     * This method is called by Data Handler to render View contents based on values from
     * URL Controller.
     * @param array $input input data sent to controller
     * @input mixed input data from URL Controller output
     * @return null
public function load($input){
// Unsetting input data that are only used by API and are accessible elsewhere by the user
// Getting view information
// If PHP libraries are set to be loaded, then loading them through Factory
if(isset($view['additional-php']) && $view['additional-php']!=''){
// Libraries are in a comma-separated list
$libraries as $l){
// Requiring override file
                } else {
// Requiring original file
// Checking for view-specific PHP script
// Requiring override file
            } else {
// Requiring original file
// Getting current view and creating view object
// Getting author and copyright, if set in configuration
// Meta title can be set in Sitemap and can also be different based on
// Here you should add your custom meta title loading, if necessary
// Title is only appended if it exists and is not empty
if($prependTitle && $prependTitle!=''){
$view['meta-title'].=$prependTitle.' - '.$view['meta-title'];
        } else {
// Project title is an empty string, if it was not defined
// Project title will be added to the end, if it is set
$view['meta-title'].=' - '.$view['project-title'];
            } else {
// List of CSS Stylesheets to load from resources folder
        // These scripts will all be unified to a single CSS
// If Sitemap file has defined additional external CSS stylesheets
if(isset($view['external-css']) && $view['external-css']!=''){
// If Sitemap file has defined additional CSS files
if(isset($view['additional-css']) && $view['additional-css']!=''){
$additionalStylesheet as $key=>$file){
// Module-specific Stylesheets is can also be loaded
// List of JavaScript to load from resources folder
        // These scripts will all be unified to a single JavaScript
// These files do not have to be in /resources/ folder and are loaded from engine folder instead
// If Sitemap file has defined additional external JavaScript libraries
if(isset($view['external-js']) && $view['external-js']!=''){
// If Sitemap file has defined additional JavaScript libraries
if(isset($view['additional-js']) && $view['additional-js']!=''){
$additionalJavaScript as $key=>$library){
// Module-specific JavaScript is can also be loaded
// Rendering the view object and capturing the output
// Header collector data for view
// HTML frame is generated with meta data and resource files
<!DOCTYPE html>
            <html lang="<?=$this->getState('language')?>" <?=(isset($view['appcache']) && $view['appcache']==1)?'manifest="'.$this->getState('url-base').'manifest.appcache"':''?>>
                    <!-- Base address for relative links -->
                    <base href="<?=$this->getState('url-base')?>"/>
                    <!-- UTF-8 -->
                    <meta charset="utf-8">
                    <!-- Useful for mobile applications -->
                    <meta name="viewport" content="width=device-width"/>
                    <?php if($view['robots']!=''){ ?>
<!-- Robots -->
                        <meta name="robots" content="<?=$view['robots']?>"/>
                    <?php } ?>
<!-- Content information -->
                    <?php if(isset($view['meta-keywords'])){ ?>
<meta name="Keywords" content="<?=$view['meta-keywords']?>"/>
                    <?php } ?>
<?php if(isset($view['meta-description'])){ ?>
<meta name="Description" content="<?=$view['meta-description']?>"/>
                    <?php } ?>
<?php if($author){ ?>
<meta name="Author" content="<?=$author?>"/>
                    <?php } ?>
<?php if($copyright){ ?>
<meta name="Copyright" content="<?=$copyright?>"/>
                    <?php } ?>
<!-- Stylesheets -->
                    <link type="text/css" href="resources/styles/<?=implode('&',$coreStyleSheet)?>" rel="stylesheet" media="all"/>
                    <?php if(isset($externalStylesheet)){ ?>
<?php foreach($externalStylesheet as $style){ ?>
<link type="text/css" href="<?=implode('&',$style)?>" rel="stylesheet" media="all"/>
                        <?php } ?>
<?php } ?>
<?php if(isset($additionalStylesheet)){ ?>
<link type="text/css" href="resources/styles/<?=implode('&',$additionalStylesheet)?>" rel="stylesheet" media="all"/>
                    <?php } ?>
<?php if(isset($moduleStylesheet)){ ?>
<link type="text/css" href="resources/styles/<?=$moduleStylesheet?>" rel="stylesheet" media="all"/>
                    <?php } ?>
<?php if(isset($viewHeaders['style'])){ ?>
<link type="text/css" href="resources/styles/<?=implode('&',$viewHeaders['style'])?>" rel="stylesheet" media="all"/>
                    <?php } ?>
<!-- Favicons -->
                    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
                    <link rel="icon" href="favicon.ico" type="image/"/>
                    <!-- JavaScript -->
                    <script type="text/javascript" src="resources/scripts/<?=implode('&',$coreJavaScript)?>"></script>
                    <?php if(isset($externalJavaScript)){ ?>
<?php foreach($externalJavaScript as $script){ ?>
<script type="text/javascript" src="<?=$script?>"></script>
                        <?php } ?>
<?php } ?>
<?php if(isset($viewHeaders['library'])){ ?>
<?php foreach($viewHeaders['library'] as $library){ ?>
<script type="text/javascript" src="resources/libraries/<?=$library?>"></script>
                        <?php } ?>
<?php } ?>
<?php if(isset($additionalJavaScript)){ ?>
<script type="text/javascript" src="resources/scripts/<?=implode('&',$additionalJavaScript)?>"></script>
                    <?php } ?>
<?php if(isset($moduleJavaScript)){ ?>
<script type="text/javascript" src="resources/scripts/<?=$moduleJavaScript?>"></script>
                    <?php } ?>
<?php if(isset($viewHeaders['script'])){ ?>
<script type="text/javascript" src="resources/scripts/<?=implode('&',$viewHeaders['script'])?>"></script>
                    <?php } ?>
<?php if(isset($viewHeaders['other'])){ ?>
<?php foreach($viewHeaders['other'] as $other){ ?>
<?php } ?>
<?php } ?>
// View content is rendered
echo $viewContent;
// API Will load result data from output buffer
return null;


For more information send a message to info at phpclasses dot org.