Utils
@param  [type] $page  [description]
@param  [type] $data  [description]
@param  [type] $jsvar [description]
@return [type]        [description]
773007
final public function sendPage($page, $data = null, $jsvar = null)
    {
        $html = new \Devbr\Html();

        $html->setPathHtml($this->patchHtml)
             ->body($page)
             ->header($this->header)
             ->footer($this->footer)
             ->setName($this->pageName)
             ->insertScripts($this->scripts)
             ->insertStyles($this->styles)
             ->val($data)
             ->jsvar($jsvar)
             ->render()
             ->send();
    }
1361430
public function compile(JsUtils $js=NULL, &$view=NULL) {
		$this->slides [0]->setClass("item active");
		$this->indicators [0]->setClass("active");
		$this->createControls();
		return parent::compile($js, $view);
	}
217071
public function cell($vars = '', $content = '')
    {
        $html = $this->wrapUp('cell');
        $tag = ($this->head) ? 'th' : 'td';
        $this->cell = '</'.$tag.'>';
        $vars = $this->values($vars);
        if (!empty($this->vars)) {
            $vars = array_merge($this->vars, $vars);
        }

        return $html.$this->page->tag($tag, $vars).$content;
    }
1234826
public static function create($totalPage, $pageSize = 10, $page = 1, $gets = [])
    {
        $p = new PageUtil();
        if ($pageSize < 1) {
            $pageSize = 1;
        }

        $total = ceil($totalPage / $pageSize);

        if ($page < 1) {
            $page = 1;
        } else if ($page > $total) {
            $page = $total;
        }

        $p->page = $page;
        $p->gets = $gets;
        $p->total = $total;
        $p->pageSize = $pageSize;
        return $p;
    }
846463
public function setPage($page = null)
    {
        // The following argument formats are supported:
        //
        // null = set current page
        // '.' = set current page
        // 'page' = sets webroot/page.html
        // './page' = set page relatively to current page
        // '..' = parent page
        // '../page' = page besides our own (foo/bar -> foo/page)
        // 'index' = properly points to the index page defined in APP
        // '/admin/' = will not be converted

        /** @type $this->app App_Web */

        $destination = '';

        if (is_null($page)) {
            $page = '.';
        }

        foreach (explode('/', $page) as $component) {
            if ($component == '') {
                continue;
            }
            if ($component == '.' && $destination == '') {
                if ($this->app->page == 'index') {
                    continue;
                }
                $destination = str_replace('_', '/', $this->app->page);
                continue;
            }

            if ($component == '..') {
                if (!$destination) {
                    $destination = str_replace('_', '/', $this->app->page);
                }
                $tmp = explode('/', $destination);
                array_pop($tmp);
                $destination = implode('/', $tmp);
                continue;
            }

            if ($component == 'index' && $destination == '') {
                $destination = $this->app->index_page;
                continue;
            }

            $destination = $destination ? $destination.'/'.$component : $component;
        }
        if ($destination === '') {
            $destination = @$this->app->index_page;
        }

        $this->page = $destination;

        // check if it's current page
        list($p, $ap) = str_replace('/', '_', array($this->page, $this->app->page));
        $this->_current = ($p == $ap); // page exactly match
        $this->_current_sub = ($p == substr($ap, 0, strlen($p)) && isset($ap[strlen($p)]) && $ap[strlen($p)] == '_'); // first part of page match followed by separator

        return $this;
    }
532163
public static Object getVariable(PageContext pc, Collection collection, String var) throws PageException {
	StringList list = parse(pc, new ParserString(var), false);
	if (list == null) throw new InterpreterException("invalid variable declaration [" + var + "]");

	while (list.hasNextNext()) {
	    collection = Caster.toCollection(collection.get(KeyImpl.init(list.next())));
	}
	return collection.get(KeyImpl.init(list.next()));
    }
324701
protected function resolveVars(&$vars, &$data, array &$data_pointer = [])
    {
        if (is_object($vars)) {
            if (property_exists($vars, '$ref') && is_string($vars->{'$ref'})) {
                $ref = $vars->{'$ref'};
                $relative = JsonPointer::parseRelativePointer($ref, true);
                if ($relative === null) {
                    $resolved = JsonPointer::getDataByPointer($data, $ref, $this, false);
                } else {
                    if (!JsonPointer::isEscapedPointer($ref)) {
                        throw new InvalidJsonPointerException($ref);
                    }
                    $resolved = JsonPointer::getDataByRelativePointer($data, $relative, $data_pointer, $this);
                }
                if ($resolved === $this) {
                    throw new InvalidJsonPointerException($ref);
                }
                if (is_array($resolved) && property_exists($vars, '$each') && is_object($vars->{'$each'})) {
                    $pointer = $relative['pointer'] ?? [];
                    foreach ($resolved as $index => &$item) {
                        $copy = $this->deepClone($vars->{'$each'});
                        $pointer[] = $index;
                        $this->resolveVars($copy,$data,$pointer);
                        array_pop($pointer);
                        $item = $copy;
                        unset($copy, $item, $index);
                    }
                    unset($pointer);
                }
                $vars = $resolved;
                return;
            }
        } elseif (!is_array($vars)) {
            return;
        }

        foreach ($vars as $name => &$var) {
            if (is_array($var) || is_object($var)) {
                $this->resolveVars($var, $data, $data_pointer);
            }
            unset($var);
        }
    }
182328
function Page(page) {
  if (!page) page = {};
  for (var key in page) this[key] = page[key];
  if (!this.hasOwnProperty('idx')) this.idx = 0;
  if (!this.hasOwnProperty('total')) this.total = 1;
  if (!this.hasOwnProperty('current')) {
    this.current = this.total;
  }
}
459776
public function get($objects, $pages = null) {
		$objects = $this->getDatas ( $objects );
		return $this->format ( [ "datas" => $objects,"count" => \sizeof ( $objects ) ] );
	}
869654
function createPlaceHolder($page, type) {
        var placeHolders = { kittens : 'placekitten.com', bears: 'placebear.com', lorem: 'lorempixel.com',
            bacon: 'baconmockup.com', murray: 'www.fillmurray.com'};
        var gallery = '';
        for (var i = 0; i < getRandomInt(50,100); i++) {
            gallery += '<li class="photoClass" style="background:url(http://' + placeHolders[type] + '/' +
                getRandomInt(200,300) + '/' + getRandomInt(200,300) + ') 50% 50% no-repeat"></li>';
        }
        $page.find('.photo-gallery').html(gallery);
        tt.refreshScroll(); // Refresh the scroller
        tt.scrollTo(0,0);   // Move back to the top of the page...
    }
382928
function extractPageVariables(fileName, data, userDefinedVariables, includedVariables) {
  const $ = cheerio.load(data);
  const pageVariables = { };
  $('variable').each(function () {
    const variableElement = $(this);
    const variableName = variableElement.attr('name');
    if (!variableName) {
      // eslint-disable-next-line no-console
      console.warn(`Missing 'name' for variable in ${fileName}\n`);
      return;
    }
    if (!pageVariables[variableName]) {
      const variableValue
        = nunjucks.renderString(md.renderInline(variableElement.html()),
                                { ...pageVariables, ...userDefinedVariables, ...includedVariables });
      pageVariables[variableName] = variableValue;
      if (!VARIABLE_LOOKUP[fileName]) {
        VARIABLE_LOOKUP[fileName] = {};
      }
      VARIABLE_LOOKUP[fileName][variableName] = variableValue;
    }
  });
  return pageVariables;
}
1367812
function GrantAddContentToPage(Page $page)
    {
        //dummy content for evaluation
        $content = new Content();
        $content->SetUserGroup(GroupFinder::FindPageGroup($page));
        $pageRights = RightsFinder::FindPageRights($page);
        if ($pageRights)
        {
            $content->SetUserGroupRights($pageRights->GetContentRights());
        }
        return $this->Grant(BackendAction::Create(), $content);
    }
266402
public function actionIndex($page = 1, $id = 0)
    {
        $searchModel = $this->module->model('UserSearch');
        $params = Yii::$app->request->queryParams;
        $dataProvider = $searchModel->search($params);

        $pager = $dataProvider->getPagination();
        $pager->pageSize = intval($this->module->params['pageSizeAdmin']);
        $pager->totalCount = $dataProvider->getTotalCount();

        // page number correction
        $maxPage = ceil($pager->totalCount / $pager->pageSize);
        if ($page > $maxPage) {
            $pager->page = $maxPage - 1;
        } else {
            $pager->page = $page - 1; //! from 0
        }

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
            'currentId'    => $id,
        ]);
    }
1329039
function start ( $vars )
		{
			$page  =  $this->template;

			$page  =  preg_replace("/(<!-- BEGIN [ a-zA-Z0-9_.]* -->)/",  "\n$1\n",  $page);
			$page  =  preg_replace("/(<!-- IF .+? -->)/",  "\n$1\n",  $page);
			$page  =  preg_replace("/(<!-- END.*? -->)/",  "\n$1\n",  $page);
			$page  =  preg_replace("/(<!-- ELSEIF .+? -->)/",  "\n$1\n",  $page);
			$page  =  preg_replace("/(<!-- ELSE [ a-zA-Z0-9_.]*-->)/",  "\n$1\n",  $page);

			$page  =  $this->highlight_html($page);

			$rows      =  explode("\n",  $page);
			$page_arr  =  array();
			$level     =  0;
			$blocklvl  =  0;
			$rowcnt    =  0;
			$spancnt   =  0;
			$offset    =  22;
			$lvl_block =  array();
			$lvl_row   =  array();
			$lvl_typ   =  array();
			foreach ($rows as $row)
			{
				if ($row  =  trim($row))
				{
					$closespan  =  false;
					if (substr($row, $offset, 12) == '&lt;!-- END ')
					{
						if ($level < 1)
						{
							$level++;
							$error[$rowcnt]  =  "END Without BEGIN";
						}
						elseif ($lvl_typ[$level] != 'BEGIN')
						{
							$error[$lvl_row[$level]]  =  "IF without ENDIF";
							$error[$rowcnt]  =  "END Without BEGIN";
						}
						$blocklvl--;
						$level--;
						$closespan  =  true;
					}
					if (substr($row, $offset, 14) == '&lt;!-- ENDIF ')
					{
						if ($level < 1)
						{
							$level++;
							$error[$rowcnt]  =  "ENDIF Without IF";
						}
						elseif ($lvl_typ[$level] != 'IF')
						{
							$error[$lvl_row[$level]]  =  "BEGIN without END";
							$error[$rowcnt]  =  "ENDIF Without IF";
						}
						$closespan  =  true;
						$level--;
					}
					if ($closespan)
					{
						$page_arr[$rowcnt-1]  .=  '</span>';
					}
					$this_row  =  $this->tab[$level] . $row;
					if (substr($row, $offset, 12) == '&lt;!-- ELSE')
					{
						if ($level < 1)
						{
							$error[$rowcnt]  =  "ELSE Without IF";
						}
						elseif ($lvl_typ[$level] != 'IF')
						{
							$error[$rowcnt]  =  "ELSE Without IF";
						}
						else
						{
							$this_row  =  $this->tab[$level-1] . $row;
						}
					}
					if (substr($row, $offset, 14) == '&lt;!-- BEGIN ')
					{
						if ($blocklvl == 0)
						{
							if ($lp = strpos($row, '--&gt;'))
							{
								if ($blockname  =  trim(substr($row, $offset + 14, $lp -$offset -14)))
								{
									if ($nr = count($vars[$blockname]))
									{
										$this_row  .=  $this->toggleview("$nr Entries");
									}
									else
									{
										$this_row  .=  $this->toggleview("Emtpy");
									}
								}
							}
						}
						else
						{
							$this_row  .=  $this->toggleview('[');
						}
						$blocklvl++;
						$level++;
						$lvl_row[$level]  =  $rowcnt;
						$lvl_typ[$level]  =  'BEGIN';
					}
					elseif (substr($row, $offset, 11) == '&lt;!-- IF ')
					{
						$level++;
						$lvl_row[$level]  =  $rowcnt;
						$lvl_typ[$level]  =  'IF';
						$this_row  .=  $this->toggleview();
					}
					$page_arr[]  =  $this_row;
					$lvl_block[$rowcnt]  =  $blocklvl;
					$rowcnt++;
				}
			}
			if ($level > 0)
			{
				$error[$lvl_row[$level]]  =  "Block not closed";
			}

			$page  =  join("\n", $page_arr);
			$rows  =  explode("\n",  $page);
			$cnt   =  count($rows);

			for ($i = 0;  $i < $cnt;  $i++)
			{
				//	Add Errortext
				if (isset($error))
				{
					if ($err = $error[$i])
					{
						$rows[$i]  =  '<b>' . $rows[$i] . '        ERROR: ' . $err . '!</b>';
					}
				}

				//	Replace Scalars
				if (preg_match_all('/{([a-zA-Z0-9_. &;]+)}/', $rows[$i], $var))
				{
					foreach ($var[1] as $tag)
					{
						$fulltag  =  $tag;
						if ($delim = strpos($tag, ' &gt; '))
						{
							$tag  =  substr($tag, 0, $delim);
						}
						if (substr($tag, 0, 4) == 'top.')
						{
							$title  =  $this->tip($vars[substr($tag, 4)]);
						}
						elseif ($lvl_block[$i] == 0)
						{
							$title  =  $this->tip($vars[$tag]);
						}
						else
						{
							$title  =  '[BLOCK?]';
						}
						$code  =  '<b title="' . $title . '">{' . $fulltag . '}</b>';
						$rows[$i]  =  str_replace('{'.$fulltag.'}',  $code,  $rows[$i]);
					}
				}

				//	Replace Extensions
				if (preg_match_all('/{([a-zA-Z0-9_]+):([^}]*)}/', $rows[$i], $var))
				{
					foreach ($var[2] as $tmpcnt => $tag)
					{
						$fulltag  =  $tag;
						if ($delim = strpos($tag, ' &gt; '))
						{
							$tag  =  substr($tag, 0, $delim);
						}
						if (strpos($tag, ','))
						{
							list($tag, $addparam)  =  explode(',', $tag, 2);
						}
						$extension  =  $var[1][$tmpcnt];

						if (substr($tag, 0, 4) == 'top.')
						{
							$title  =  $this->tip($vars[substr($tag, 4)]);
						}
						elseif ($lvl_block[$i] == 0)
						{
							$title  =  $this->tip($vars[$tag]);
						}
						else
						{
							$title  =  '[BLOCK?]';
						}
						$code  =  '<b title="' . $title . '">{' . $extension . ':' . $fulltag . '}</b>';
						$rows[$i]  =  str_replace('{'.$extension . ':' . $fulltag .'}',  $code,  $rows[$i]);
					}
				}

				//	'IF nnn' Blocks
				if (preg_match_all('/&lt;!-- IF ([a-zA-Z0-9_.]+) --&gt;/', $rows[$i], $var))
				{
					foreach ($var[1] as $tag)
					{
						if (substr($tag, 0, 4) == 'top.')
						{
							$title  =  $this->tip($vars[substr($tag, 4)]);
						}
						elseif ($lvl_block[$i] == 0)
						{
							$title  =  $this->tip($vars[$tag]);
						}
						else
						{
							$title  =  '[BLOCK?]';
						}
						$code  =  '<span title="' . $title . '">&lt;!-- IF ' . $tag . ' --&gt;</span>';
						$rows[$i]  =  str_replace("&lt;!-- IF $tag --&gt;",  $code,  $rows[$i]);
						if ($title == '[NULL]')
						{
							$rows[$i]  =  str_replace('Hide',  'Show',  $rows[$i]);
							$rows[$i]  =  str_replace('block',  'none',  $rows[$i]);
						}
					}
				}
			}
			$page  =  join("<br>", $rows);

			// Print Header
			echo '<html><head><script type="text/javascript">
					function toggleVisibility(el, src) {
					var v = el.style.display == "block";
					var str = src.innerHTML;
					el.style.display = v ? "none" : "block";
					src.innerHTML = v ? str.replace(/Hide/, "Show") : str.replace(/Show/, "Hide");}
					</script></head><body>';

			// Print Index
			echo '<font face="Arial" Size="3"><b>';
			echo 'SmartTemplate Debugger<br>';
			echo '<font size="2"><li>PHP-Script: ' . $_SERVER['PATH_TRANSLATED'] . '</li><li>Template: ' . $this->filename . '</li></font><hr>';
			echo '<li><a href="#template_code">Template</a></li>';
			echo '<li><a href="#compiled_code">Compiled Template</a></li>';
			echo '<li><a href="#data_code">Data</a></li>';
			echo '</b></font><hr>';

			// Print Template
			echo '<a name="template_code"><br><font face="Arial" Size="3"><b>Template:</b>&nbsp;[<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Template\'), this); return false">Hide Ouptut</a>]</font><br>';
			echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Template" style="display:block">';
			echo $page;
			echo '</pre></td></tr></table>';

			// Print Compiled Template
			if (@include_once ("class.smarttemplateparser.php"))
			{
				$parser = new SmartTemplateParser($this->filename);
				$compiled  =  $parser->compile();
				echo '<a name="compiled_code"><br><br><font face="Arial" Size="3"><b>Compiled Template:</b>&nbsp;[<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Compiled\'), this); return false">Hide Ouptut</a>]</font><br>';
				echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Compiled" style="display:block">';
				highlight_string($compiled);
				echo '</pre></td></tr></table>';
			}
			else
			{
				exit( "SmartTemplate Error: Cannot find class.smarttemplateparser.php; check SmartTemplate installation");
			}

			// Print Data
			echo '<a name="data_code"><br><br><font face="Arial" Size="3"><b>Data:</b>&nbsp;[<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Data\'), this); return false">Hide Ouptut</a>]</font><br>';
			echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Data" style="display:block">';
			echo $this->vardump($vars);
			echo '</pre></td></tr></table></body></html>';
		}
205366
public function render_data_registry_page(data_registry_page $page) {
        $data = $page->export_for_template($this);
        return parent::render_from_template('tool_dataprivacy/data_registry', $data);
    }
370737
function reanderPage(Handler, data) {
    React.render(React.createElement(Handler, { data: data }), document);
}
20597
public function runPage($page, $useAjax = true)
    {
        $this->page = $page;

        /*
         * If the page doesn't refer any layout, create the fallback layout.
         * Otherwise load the layout specified in the page.
         */
        if (!$page->layout) {
            $layout = Layout::initFallback($this->theme);
        }
        elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
            throw new CmsException(Lang::get('cms::lang.layout.not_found_name', ['name'=>$page->layout]));
        }

        $this->layout = $layout;

        /*
         * The 'this' variable is reserved for default variables.
         */
        $this->vars['this'] = [
            'page'        => $this->page,
            'layout'      => $this->layout,
            'theme'       => $this->theme,
            'param'       => $this->router->getParameters(),
            'controller'  => $this,
            'environment' => App::environment(),
            'session'     => App::make('session'),
        ];

        /*
         * Check for the presence of validation errors in the session.
         */
        $this->vars['errors'] = (Config::get('session.driver') && Session::has('errors'))
            ? Session::get('errors')
            : new \Illuminate\Support\ViewErrorBag;

        /*
         * Handle AJAX requests and execute the life cycle functions
         */
        $this->initCustomObjects();

        $this->initComponents();

        /*
         * Give the layout and page an opportunity to participate
         * after components are initialized and before AJAX is handled.
         */
        if ($this->layoutObj) {
            CmsException::mask($this->layout, 300);
            $this->layoutObj->onInit();
            CmsException::unmask();
        }

        CmsException::mask($this->page, 300);
        $this->pageObj->onInit();
        CmsException::unmask();

        /**
         * @event cms.page.init
         * Provides an opportunity to return a custom response from Controller->runPage() before AJAX handlers are executed
         *
         * Example usage:
         *
         *     Event::listen('cms.page.init', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
         *         return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
         *     });
         *
         * Or
         *
         *     $CmsController->bindEvent('page.init', function ((\Cms\Classes\Page) $page) {
         *         return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
         *     });
         *
         */
        if ($event = $this->fireSystemEvent('cms.page.init', [$page])) {
            return $event;
        }

        /*
         * Execute AJAX event
         */
        if ($useAjax && $ajaxResponse = $this->execAjaxHandlers()) {
            return $ajaxResponse;
        }

        /*
         * Execute postback handler
         */
        if (
            $useAjax &&
            ($handler = post('_handler')) &&
            $this->verifyCsrfToken() &&
            ($handlerResponse = $this->runAjaxHandler($handler)) &&
            $handlerResponse !== true
        ) {
            return $handlerResponse;
        }

        /*
         * Execute page lifecycle
         */
        if ($cycleResponse = $this->execPageCycle()) {
            return $cycleResponse;
        }

        /**
         * @event cms.page.beforeRenderPage
         * Fires after AJAX handlers are dealt with and provides an opportunity to modify the page contents
         *
         * Example usage:
         *
         *     Event::listen('cms.page.beforeRenderPage', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
         *         return 'Custom page contents';
         *     });
         *
         * Or
         *
         *     $CmsController->bindEvent('page.beforeRenderPage', function ((\Cms\Classes\Page) $page) {
         *         return 'Custom page contents';
         *     });
         *
         */
        if ($event = $this->fireSystemEvent('cms.page.beforeRenderPage', [$page])) {
            $this->pageContents = $event;
        }
        else {
            /*
             * Render the page
             */
            CmsException::mask($this->page, 400);
            $this->loader->setObject($this->page);
            $template = $this->twig->loadTemplate($this->page->getFilePath());
            $this->pageContents = $template->render($this->vars);
            CmsException::unmask();
        }

        /*
         * Render the layout
         */
        CmsException::mask($this->layout, 400);
        $this->loader->setObject($this->layout);
        $template = $this->twig->loadTemplate($this->layout->getFilePath());
        $result = $template->render($this->vars);
        CmsException::unmask();

        return $result;
    }