Overview

Namespaces

  • Simpletools
    • Autoload
    • Config
    • Db
      • Mysql
    • Event
    • Http
    • Mvc
    • Page
    • Store

Classes

  • Simpletools\Autoload\Loader
  • Simpletools\Config\Ini
  • Simpletools\Db\Mysql\Client
  • Simpletools\Db\Mysql\Iterator
  • Simpletools\Db\Mysql\Model
  • Simpletools\Db\Mysql\QueryBuilder
  • Simpletools\Db\Mysql\Result
  • Simpletools\Db\Mysql\Sql
  • Simpletools\Event\Event
  • Simpletools\Http\Ssl
  • Simpletools\Mvc\Common
  • Simpletools\Mvc\Controller
  • Simpletools\Mvc\Model
  • Simpletools\Mvc\Router
  • Simpletools\Mvc\RoutingHook
  • Simpletools\Mvc\View
  • Simpletools\Page\Layout
  • Simpletools\Store\Cookie
  • Simpletools\Store\Flash
  • Simpletools\Store\Session
  • Overview
  • Namespace
  • Class
  1: <?php
  2: /*
  3:  * Simpletools Framework.
  4:  * Copyright (c) 2009, Marcin Rosinski. (https://www.getsimpletools.com/)
  5:  * All rights reserved.
  6:  * 
  7:  * LICENCE
  8:  *
  9:  * Redistribution and use in source and binary forms, with or without modification, 
 10:  * are permitted provided that the following conditions are met:
 11:  *
 12:  * -    Redistributions of source code must retain the above copyright notice, 
 13:  *      this list of conditions and the following disclaimer.
 14:  * 
 15:  * -    Redistributions in binary form must reproduce the above copyright notice, 
 16:  *      this list of conditions and the following disclaimer in the documentation and/or other 
 17:  *      materials provided with the distribution.
 18:  * 
 19:  * -    Neither the name of the Simpletools nor the names of its contributors may be used to 
 20:  *      endorse or promote products derived from this software without specific prior written permission.
 21:  * 
 22:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
 23:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
 24:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 25:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 27:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 28:  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
 29:  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30:  * 
 31:  * @framework       Simpletools
 32:  * @description     MVC framework
 33:  * @copyright       Copyright (c) 2009 Marcin Rosinski. (https://www.getsimpletools.com/)
 34:  * @license         (BSD)
 35:  *
 36:  */
 37: 
 38:     namespace Simpletools\Mvc;
 39: 
 40:     /**
 41:     * MVC View
 42:     */
 43:     class View extends \Simpletools\Mvc\Common
 44:     {
 45:         protected $_shifted_params  = 0;
 46:         protected static $_instance     = null;
 47:         protected $_view_ext            = 'phtml';
 48: 
 49:         public function __construct($view_extension='phtml')
 50:         {
 51:             $this->_view_ext = $view_extension;
 52: 
 53:             if (empty(self::$_instance))
 54:             {
 55:                 self::$_instance = &$this;
 56:             }
 57:         }
 58: 
 59:         public function getViewExt()
 60:         {
 61:             return $this->_view_ext;
 62:         }
 63: 
 64:         public static function &getInstance()
 65:         {
 66:             if (!empty(self::$_instance)) 
 67:             {
 68:                 return self::$_instance;
 69:             }
 70:             else
 71:             {
 72:                 throw new \Exception('Asking for instance before instance has been created. This method should be use after SimpleMVC::dispatch() only',123);
 73:             }
 74:         }
 75: 
 76:         public function registerObject($objectName,&$object)
 77:         {
 78:             $this->{$objectName} = &$object;
 79:         }
 80: 
 81:         public function render($dir)
 82:         {
 83:             require($dir);
 84:         }
 85: 
 86:         public function url(Array $urls, $absolute=false, $https=false, $slashEnd=false)
 87:         {
 88:             $counter = 0;
 89:             $url = null;
 90: 
 91:             if(is_array($this->_shifted_params) && count($this->_shifted_params))
 92:             {
 93:                 foreach($this->_shifted_params as $p)
 94:                 {
 95:                     $url .= '/'.$p;
 96:                 }
 97:             }
 98: 
 99:             if(isset($urls['controller']))
100:             {
101:                 foreach($urls as $key => $value)
102:                 {
103:                     if($key == 'controller' || $key == 'action')
104:                     {
105:                         $url .= '/'.$value;
106:                     }
107:                     else
108:                     {
109:                         $url .= '/'.$key.'/'.$value;
110:                     }
111:                 }
112:             }
113:             else
114:             {
115:                 foreach($urls as $value)
116:                 {
117: 
118:                     $url .= '/'.$value;
119: 
120:                 }
121:             }
122: 
123:             if($absolute)
124:             {
125:                 if($https)
126:                 {
127:                     $protocol = 'https://';
128:                 }
129:                 else
130:                 {
131:                     $protocol = 'http://';
132:                 }
133: 
134:                 $url = $protocol.$_SERVER['SERVER_NAME'].$url;
135:             }
136: 
137:             if($slashEnd)
138:             {
139:                 $url .= '/';
140:             }
141: 
142:             return $url;
143:         }
144:     }
145: 
146: ?>
API documentation generated by ApiGen