<commit_before><?php

class CM_RenderAdapter_Page extends CM_RenderAdapter_Abstract {

	public function fetch(array $params = array()) {
		/** @var CM_Page_Abstract $page */
		$page = $this->_getView();
		$js = $this->getRender()->getJs();

		$this->getRender()->pushStack('pages', $page);
		$this->getRender()->pushStack('views', $page);

		$options = array();
		$options['releaseStamp'] = CM_App::getInstance()->getReleaseStamp();
		$options['renderStamp'] = floor(microtime(true) * 1000);
		$options['siteId'] = $this->getRender()->getSite()->getId();
		$options['url'] = $this->getRender()->getUrl();
		$options['urlStatic'] = $this->getRender()->getUrlStatic();
		$options['urlUserContent'] = $this->getRender()->getUrlUserContent();
		$options['urlResource'] = $this->getRender()->getUrlResource();
		$options['language'] = $this->getRender()->getLanguage();
		$options['stream'] = array();
		$options['stream']['enabled'] = CM_Stream::getEnabled();
		if (CM_Stream::getEnabled()) {
			$options['stream']['adapter'] = CM_Stream::getAdapterClass();
			$options['stream']['server'] = CM_Stream::getServer();
		}
		if ($viewer = $page->getViewer()) {
			$options['stream']['channel'] = CM_Stream::getStreamChannel($viewer);
		}
		$js->onloadHeaderJs('cm.options = ' . CM_Params::encode($options, true));

		$js->onloadHeaderJs('WEB_SOCKET_SWF_LOCATION = "' . $this->getRender()->getUrlStatic('/swf/WebSocketMainInsecure.swf') . '"');
		if ($viewer = $page->getViewer()) {
			$js->onloadHeaderJs('cm.viewer = ' . CM_Params::encode($viewer, true));
		}

		$this->getRender()->getJs()->registerPage($page);
		$js->onloadReadyJs('cm.findView()._ready();');

		$assign = $page->getTplParams();
		$assign['pageObj'] = $page;
		$assign['viewer'] = $page->getViewer();
		$html = $this->_renderTemplate('default.tpl', $assign);

		$this->getRender()->popStack('pages');<commit_msg>Fix: Move cm.ready() into page init<commit_after><?php

class CM_RenderAdapter_Page extends CM_RenderAdapter_Abstract {

	public function fetch(array $params = array()) {
		/** @var CM_Page_Abstract $page */
		$page = $this->_getView();
		$js = $this->getRender()->getJs();

		$this->getRender()->pushStack('pages', $page);
		$this->getRender()->pushStack('views', $page);

		$options = array();
		$options['releaseStamp'] = CM_App::getInstance()->getReleaseStamp();
		$options['renderStamp'] = floor(microtime(true) * 1000);
		$options['siteId'] = $this->getRender()->getSite()->getId();
		$options['url'] = $this->getRender()->getUrl();
		$options['urlStatic'] = $this->getRender()->getUrlStatic();
		$options['urlUserContent'] = $this->getRender()->getUrlUserContent();
		$options['urlResource'] = $this->getRender()->getUrlResource();
		$options['language'] = $this->getRender()->getLanguage();
		$options['stream'] = array();
		$options['stream']['enabled'] = CM_Stream::getEnabled();
		if (CM_Stream::getEnabled()) {
			$options['stream']['adapter'] = CM_Stream::getAdapterClass();
			$options['stream']['server'] = CM_Stream::getServer();
		}
		if ($viewer = $page->getViewer()) {
			$options['stream']['channel'] = CM_Stream::getStreamChannel($viewer);
		}
		$js->onloadHeaderJs('cm.options = ' . CM_Params::encode($options, true));

		$js->onloadHeaderJs('WEB_SOCKET_SWF_LOCATION = "' . $this->getRender()->getUrlStatic('/swf/WebSocketMainInsecure.swf') . '"');
		if ($viewer = $page->getViewer()) {
			$js->onloadHeaderJs('cm.viewer = ' . CM_Params::encode($viewer, true));
		}

		$js->onloadHeaderJs('cm.ready();');

		$this->getRender()->getJs()->registerPage($page);
		$js->onloadReadyJs('cm.findView()._ready();');

		$assign = $page->getTplParams();
		$assign['pageObj'] = $page;
		$assign['viewer'] = $page->getViewer();
		$html = $this->_renderTemplate('default.tpl', $assign);

		$this->getRender()->popStack('pages');
{'fraction_non_alphanumeric': 0.23825767515087903, 'fraction_numerical': 0.0020991865652059826, 'mean_word_length': 6.260952380952381, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920614', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1258, 'n_words': 161}