Example #1
0
File: View.php Project: gueff/mymvc
 /**
  * instantiates smarty object and set major smarty configs
  * 
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->sTemplateDir = \mvc\registry::get('MVC_MODULES') . '/' . \mvc\Request::getInstance()->getModule() . '/templates';
     $this->sTemplate = Registry::get('MVC_SMARTY_TEMPLATE_DEFAULT');
     $this->iSmartyVersion = (int) preg_replace('/[^0-9]+/', '', self::SMARTY_VERSION);
     $this->setAbsolutePathToTemplateDir();
     $this->setCompileDir(\MVC\Registry::get('MVC_SMARTY_TEMPLATE_CACHE_DIR'));
     $this->setCacheDir(\MVC\Registry::get('MVC_SMARTY_CACHE_DIR'));
     $this->caching = \MVC\Registry::get('MVC_SMARTY_CACHE_STATUS');
     $aPlugInDir = array(\MVC\Registry::get('MVC_APPLICATION_PATH') . '/vendor/smarty/smarty/libs/plugins/');
     \MVC\Registry::isRegistered('MVC_SMARTY_PLUGINS_DIR') ? $aPlugInDir = array_merge($aPlugInDir, \MVC\Registry::get('MVC_SMARTY_PLUGINS_DIR')) : false;
     $this->setPluginsDir($aPlugInDir);
     $this->checkDirs();
     \MVC\Event::BIND('mvc.view.echoOut.off', function () {
         MVC_View::$bEchoOut = false;
     });
     \MVC\Event::BIND('mvc.view.echoOut.on', function () {
         MVC_View::$bEchoOut = true;
     });
 }
Example #2
0
File: IDS.php Project: gueff/mymvc
 /**
  * dispose affected Variables
  * 
  * @param \IDS\Report $oIdsReport
  * @access public
  * @static
  */
 public static function dispose(\IDS\Report $oIdsReport)
 {
     $aName = array();
     $aDisposed = array();
     // get Name of Variables
     foreach ($oIdsReport->getIterator() as $oEvent) {
         $aName[] = $oEvent->getName();
     }
     // iterate infected and dispose those
     foreach ($aName as $sName) {
         // get Type and Key
         $aType = explode('.', $sName);
         $sType = isset($aType[0]) ? $aType[0] : '';
         $sKey = isset($aType[1]) ? $aType[1] : '';
         $aAffected = isset($GLOBALS['_' . $sType][$sKey]) ? $GLOBALS['_' . $sType][$sKey] : array();
         if (!empty($aAffected)) {
             if ('GET' == $sType) {
                 if (isset($_GET[$sKey])) {
                     $_GET[$sKey] = null;
                     unset($_GET[$sKey]);
                 }
             }
             if ('POST' == $sType) {
                 if (isset($_POST[$sKey])) {
                     $_POST[$sKey] = null;
                     unset($_POST[$sKey]);
                 }
             }
             if ('COOKIE' == $sType) {
                 if (isset($_COOKIE[$sKey])) {
                     $_COOKIE[$sKey] = null;
                     unset($_COOKIE[$sKey]);
                 }
             }
             $aDisposed[] = $sType . '[' . $sKey . ']';
             \MVC\Log::WRITE("INFO\tdisposed: " . $sType . '[' . $sKey . ']', 'ids.log');
             // overwrite
             $oRequest = Request::getInstance();
             $oRequest->saveRequest();
         }
     }
     \MVC\Registry::set('MVC_IDS_DISPOSED', $aDisposed);
 }
Example #3
0
File: View.php Project: gueff/mymvc
 /**
  * set absolute Path to Smarty Template Dir and saves this into includePath
  * 
  * @access public
  * @param string $sAbsolutePathToTemplateDir
  * @return void
  */
 public function setAbsolutePathToTemplateDir($sAbsolutePathToTemplateDir = '')
 {
     if ($sAbsolutePathToTemplateDir === '') {
         $aQueryArray = \MVC\Request::getInstance()->getQueryArray();
         array_key_exists(Registry::get('MVC_GET_PARAM_MODULE'), $aQueryArray['GET']) ? $sAbsolutePathToTemplateDir = realpath(\MVC\Registry::get('MVC_MODULES') . '/' . $aQueryArray['GET'][Registry::get('MVC_GET_PARAM_MODULE')] . '/templates/') : false;
     }
     if (is_dir($sAbsolutePathToTemplateDir)) {
         $aIncludePath = explode(PATH_SEPARATOR, get_include_path());
         if (!in_array($sAbsolutePathToTemplateDir, $aIncludePath)) {
             $aIncludePath[] = $sAbsolutePathToTemplateDir;
         }
         $sImplodePaths = implode(PATH_SEPARATOR, $aIncludePath);
         set_include_path($sImplodePaths);
     }
     $this->setTemplateDir($sAbsolutePathToTemplateDir);
 }
Example #4
0
 /**
  * collects all Info for being displayed by the Toolbar
  * 
  * @access private
  * @param \Smarty $oView
  * @return array $aToolbar containing all Info for toolbar
  */
 private function collectInfo(\Smarty $oView)
 {
     $aToolbar = array();
     $aToolbar['sPHP'] = phpversion();
     $aToolbar['sOS'] = PHP_OS;
     $aToolbar['sEnv'] = \MVC\Registry::get('MVC_ENV');
     $aToolbar['aGet'] = array_map('htmlentities', $_GET);
     $aToolbar['aPost'] = array_map('htmlentities', $_POST);
     $aToolbar['aCookie'] = array_map('htmlentities', $_COOKIE);
     $aToolbar['aRequest'] = array_map('htmlentities', $_REQUEST);
     $aToolbar['aSession'] = $_SESSION;
     $aToolbar['aSmartyTemplateVars'] = $oView->getTemplateVars();
     $aConstants = get_defined_constants(true);
     $aToolbar['aConstant'] = $aConstants['user'];
     $aToolbar['aServer'] = $_SERVER;
     $aToolbar['oMvcRequestGetWhitelistParams'] = \MVC\Request::getInstance()->getWhitelistParams();
     $aToolbar['oMvcRequestGetQueryArray'] = \MVC\Request::getInstance()->getQueryArray();
     $aToolbar['aEvent'] = \MVC\Registry::isRegistered('MVC_EVENT') ? \MVC\Registry::get('MVC_EVENT') : array();
     $aRequest = \MVC\Request::GETCURRENTREQUEST();
     $aToolbar['aRouting'] = array('aRequest' => \MVC\Request::GETCURRENTREQUEST(), 'sModule' => \MVC\Request::getInstance()->getModule(), 'sController' => \MVC\Request::getInstance()->getController(), 'sMethod' => \MVC\Request::getInstance()->getMethod(), 'sArg' => isset($aToolbar['oMvcRequestGetQueryArray']['GET']['a']) ? $aToolbar['oMvcRequestGetQueryArray']['GET']['a'] : '', 'aRoute' => \MVC\Registry::get('MVC_ROUTING_CURRENT'), 'sRoutingJsonBuilder' => \MVC\Registry::get('MVC_ROUTING_JSON_BUILDER'), 'sRoutingHandling' => \MVC\Registry::get('MVC_ROUTING_HANDLING'));
     $aPolicy = \MVC\Registry::get('MVC_POLICY');
     $sController = '\\' . \MVC\Request::getInstance()->getModule() . '\\Controller\\' . \MVC\Request::getInstance()->getController();
     $sMethod = \MVC\Request::getInstance()->getMethod();
     $aToolbar['aPolicy']['aRule'] = \MVC\Registry::isRegistered('MVC_POLICY') ? \MVC\Registry::get('MVC_POLICY') : array();
     $aToolbar['aPolicy']['aApplied'] = isset($aPolicy[$sController][$sMethod]) ? $aPolicy[$sController][$sMethod] : false;
     $aToolbar['aPolicy']['sAppliedAt'] = isset($aPolicy[$sController][$sMethod]) ? $sController . '::' . $sMethod : false;
     $sTemplate = file_exists($oView->sTemplate) ? $oView->sTemplate : (file_exists($oView->_joined_template_dir . '/' . $oView->sTemplate) ? $oView->_joined_template_dir . '/' . $oView->sTemplate : false);
     $aToolbar['sTemplate'] = $sTemplate;
     $aToolbar['sTemplateContent'] = file_get_contents($aToolbar['sTemplate']);
     ob_start();
     $sTemplate = file_get_contents($oView->sTemplate, true);
     $oView->renderString($sTemplate);
     $sRendered = ob_get_contents();
     ob_end_clean();
     $aToolbar['sRendered'] = $sRendered;
     $aToolbar['aFilesIncluded'] = get_required_files();
     $aToolbar['aMemory'] = array('iRealMemoryUsage' => memory_get_usage(true) / 1024, 'dMemoryUsage' => memory_get_usage() / 1024, 'dMemoryPeakUsage' => memory_get_peak_usage() / 1024);
     $aToolbar['aRegistry'] = \MVC\Registry::getStorageArray();
     $aToolbar['aCache'] = $this->getCaches();
     $aToolbar['aError'] = \MVC\Error::getERROR();
     $aToolbar['oIds'] = \MVC\Registry::isRegistered('MVC_IDS_IMPACT') ? \MVC\Registry::get('MVC_IDS_IMPACT') : '';
     $aToolbar['aIdsConfig'] = \MVC\Registry::isRegistered('MVC_IDS_INIT') ? \MVC\Registry::get('MVC_IDS_INIT') : '';
     $aToolbar['aIdsDisposed'] = \MVC\Registry::isRegistered('MVC_IDS_DISPOSED') ? \MVC\Registry::get('MVC_IDS_DISPOSED') : '';
     $iMicrotime = microtime(true);
     $sMicrotime = sprintf("%06d", ($iMicrotime - floor($iMicrotime)) * 1000000);
     $oDateTime = new \DateTime(date('Y-m-d H:i:s.' . $sMicrotime, $iMicrotime));
     $oStart = \MVC\Session::getInstance()->get('startDateTime');
     $dDiff = date_format($oDateTime, "s.u") - date_format($oStart, "s.u");
     $aToolbar['sConstructionTime'] = round($dDiff, 3);
     return $aToolbar;
 }