Example #1
0
 public function render($arrLayoutData = array())
 {
     $arrBoxesResponseContents = array();
     foreach ($this->arrPlaceholderBoxes as $strPlaceholderName => $arrBoxes) {
         $arrBoxesResponseContents[$strPlaceholderName] = array();
         foreach ($arrBoxes as $objBox) {
             $objBoxResponse = $objBox->launch();
             $arrBoxesResponseContents[$strPlaceholderName][] = $objBoxResponse->__toString();
         }
     }
     $strLayoutFullName = get_called_class();
     $arrLayoutFullNameTokens = explode('\\', $strLayoutFullName);
     $strLayoutName = array_pop($arrLayoutFullNameTokens);
     $strLayoutPath = sprintf('%s/layout/view/%s', Application::getInstance()->strDirectory, $strLayoutName);
     $objTemplater = Templater::createSpecifiedTemplater(Config::get('templater'));
     $objCurrentRoute = Router::getCurrentRoute();
     if (!empty($objCurrentRoute)) {
         $arrLayoutData['route'] = array('name' => $objCurrentRoute->strRouteName, 'action' => $objCurrentRoute->strMethodName);
     }
     if (method_exists($this, 'launch')) {
         $arrLayoutData = array_merge($this->launch(), $arrLayoutData);
     }
     $strLayoutContent = $objTemplater->getTemplateFileContent($strLayoutPath, $arrLayoutData);
     foreach ($this->arrPlaceholderBoxes as $strPlaceholderName => $arrBoxes) {
         $strLayoutContent = str_replace(sprintf('[placeholder:%s]', $strPlaceholderName), join('', $arrBoxesResponseContents[$strPlaceholderName]), $strLayoutContent);
     }
     // removing unused placeholders
     $strLayoutContent = preg_replace('/\\[placeholder\\:([a-z\\-]+)\\]/', '', $strLayoutContent);
     //        echo $strLayoutContent;exit();
     //        echo $strLayoutContent;exit();
     return $strLayoutContent;
 }
Example #2
0
 public static function route($strRouteName, $arrParams = array(), $strLanguage = null)
 {
     $strUri = '';
     if (empty($strLanguage)) {
         $objLanguages = Languages::getInstance();
         $strLanguage = $objLanguages->getCurrentLanguage();
     }
     if (strpos($strRouteName, '::') === false) {
         $strRouteName .= '::index';
     }
     $objRouter = Router::getInstance();
     $objRoute = $objRouter->getRouteByNameAndLang($strRouteName, $strLanguage);
     if (empty($objRoute)) {
         $objRoute = $objRouter->getRouteByName('Homepage');
     }
     if (!empty($objRoute)) {
         $strUri = $objRoute->buildUri($arrParams);
     }
     return $strUri;
 }
Example #3
0
 public static function add($strRouteFullName, $arrUris)
 {
     $objRouter = Router::getInstance();
     //        $arrControllerActionTokens = explode('/', $strControllerAction);
     $arrRouteMethod = explode('::', $strRouteFullName);
     if (count($arrRouteMethod) == 2) {
         $strRouteName = $arrRouteMethod[0];
         $strRouteMethod = $arrRouteMethod[1];
     } else {
         $strRouteName = $arrRouteMethod[0];
         $strRouteMethod = 'index';
     }
     if (!is_array($arrUris)) {
         $arrUris = array($arrUris);
     }
     $objRoute = new Route($strRouteName);
     $objRoute->addUris($arrUris);
     $objRoute->setMethod($strRouteMethod);
     $objRoute->recognizeSetParams($arrUris);
     $objRoute->strRouteFullName = $strRouteFullName;
     $objRouter->arrRoutes[$strRouteFullName] = $objRoute;
 }
Example #4
0
 public function init()
 {
     $this->objRouter = Router::getInstance();
     self::$strCurrentAppUrl = $this->currentAppUrl();
 }
Example #5
0
 public static function currentUrl()
 {
     $objCurrentRoute = \webcitron\Subframe\Router::getCurrentRoute();
     $arrRequestParams = \webcitron\Subframe\Request::getParams();
     $strUrl = \webcitron\Subframe\Url::route($objCurrentRoute->strRouteFullName, $arrRequestParams);
     return $strUrl;
 }