Initializes the DataManager object from the database entities

@param Language $language
@param Page     $page
429991
public function fromEntities(Language $language = null, Page $page = null)
    {
        $this->language = $language;
        $this->page = $page;
        if (null !== $this->language && null !== $this->page) {
            $options = array(
                "languageId" => $this->language->getId(),
                "pageId" => $this->page->getId(),
            );
            $this->seo = $this->setupSeo($options);
        }
    }
88548
protected function _init(Model $Model, $page, $limit) {
		$habtm = array();
		$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
		foreach ($allHabtm as $assocAlias) {
			if (isset($Model->ShadowModel->_schema[$assocAlias])) {
				$habtm[] = $assocAlias;
			}
		}
		$all = $Model->find('all', array(
			'limit' => $limit,
			'page' => $page,
			'contain' => $habtm));
		$versionCreated = date('Y-m-d H:i:s');
		foreach ($all as $data) {
			$Model->ShadowModel->create($data);
			$Model->ShadowModel->set('version_created', $versionCreated);
			$Model->ShadowModel->save();
		}
	}
271908
private static function initLanguageMap($language = '')
    {
        if (count(self::$map) > 0 && (($language == '') || ($language == self::$language))) {
            return;
        }

        // Is a specific map associated with $language?
        if (isset(self::$maps[$language]) && is_array(self::$maps[$language])) {
            // Move this map to end. This means it will have priority over others
            $m = self::$maps[$language];
            unset(self::$maps[$language]);
            self::$maps[$language] = $m;
        }

        // Reset static vars
        self::$language = $language;
        self::$map = array();
        self::$chars = '';

        foreach (self::$maps as $map) {
            foreach ($map as $orig => $conv) {
                self::$map[$orig] = $conv;
                self::$chars .= $orig;
            }
        }

        self::$regex = '/[' . self::$chars . ']/u';
    }
705043
public function setPage($page)
    {
        $this->page = intval($page);
        
        if ($this->page == 0) {
            $this->page = 1;
        }
    }
60079
public function loadLanguage($language)
    {
        if ($this->isLoaded($language)) {
            return;
        }

        $langfile = $language . '.php';

        $this->strings[$language] = [];

        // Determine where the language file is and load it
        if (file_exists($this->filePath . $langfile)) {
            $this->strings[$language] = include $this->filePath . $langfile;
        }

        $this->languagesLoaded[] = $language;
    }
926563
protected function loadInflection(string $language): void
	{
		$this->inflections[$language] = $this->loader->loadInflection($language);
	}
679025
public function init()
    {
        $default = $this->config->get('system.languages.default_lang');
        if (isset($default) && $this->validate($default)) {
            $this->default = $default;
        } else {
            $this->default = reset($this->languages);
        }

        $this->page_extensions = null;

        if (empty($this->languages)) {
            $this->enabled = false;
        }
    }
761959
public static function init(moodle_page $page = null) {
        global $PAGE;

        if (empty($page)) {
            $page = $PAGE;
        }
        // setup variables for non-js interface
        self::$nonjs = optional_param('nonjscomment', '', PARAM_ALPHANUM);
        self::$comment_itemid = optional_param('comment_itemid',  '', PARAM_INT);
        self::$comment_component = optional_param('comment_component', '', PARAM_COMPONENT);
        self::$comment_context = optional_param('comment_context', '', PARAM_INT);
        self::$comment_page = optional_param('comment_page',    '', PARAM_INT);
        self::$comment_area = optional_param('comment_area',    '', PARAM_AREA);

        $page->requires->strings_for_js(array(
                'addcomment',
                'comments',
                'commentscount',
                'commentsrequirelogin',
                'deletecommentbyon'
            ),
            'moodle'
        );
    }
1107339
public function setLanguage($language = null)
    {
        if (is_null($language)) {
            if (($language = Yii::$app->request->getQueryParam('_lang')) !== null) {
                $this->language = $language;
                Yii::$app->response->cookies->add(new Cookie(['name' => '_lang', 'value' => $language]));
            } else if (($cookie = Yii::$app->request->cookies->get('_lang')) !== null) {
                $this->language = $cookie->value;
            } else if (($language = Yii::$app->request->getPreferredLanguage()) !== null) {
                $this->language = $language;
            }
        } else {
            $this->language = $language;
        }
    }
163318
public function create(Page &$page)
    {
        $data = $page->exportData();
        $endpoint= '/admin/pages.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'page' => $data
            )
        );
        $page->setData($response['page']);
    }
801942
public final function updatePage(WebPage $page, $number)
    {

        $page->beforeSaveToSession();
        $this->pages[$number] =  ($page);
    }
1238799
public function initialise_js(moodle_page $page) {
        foreach ($this->jsyuimodules as $js) {
            $page->requires->yui_module($js->modules, $js->function, $js->arguments, null, $js->ondomready);
        }
        foreach ($this->jsinitcalls as $js) {
            $page->requires->js_init_call($js->function, $js->extraarguments, $js->ondomready, $js->module);
        }
        foreach ($this->jsstrings as $string) {
            $page->requires->strings_for_js($string->identifiers, $string->component, $string->a);
        }
    }
1284419
public function setPageLocalization(PageLocalization $pageLocalization)
	{
		$this->pageLocalization = $pageLocalization;
		$this->pageId = $pageLocalization->getMaster()->getId();
	}
95723
private function add($data, $language) {
        $parts = explode('-', $language); // To manage language with region (fr-CI, en-US, etc.)
        foreach($data as $key => $translation) {
            if (count($parts) == 1) {
                $this->translations[$language][$key] = $translation;
            } elseif (count($parts) == 2) {
                $this->translations[$parts[0]][$parts[1]][$key] = $translation;
            } else {
                throw new TranslationException('Invalid language');
            }
        }
    }
1177641
public void setLanguage(LanguageMode language) {
    checkState(language != LanguageMode.NO_TRANSPILE);
    checkState(language != LanguageMode.UNSUPPORTED);
    this.setLanguageIn(language);
    this.setLanguageOut(language);
  }
390338
public function loadByLanguage($language)
    {
        if (!is_null($language) && !preg_match('/[a-z]{2}/', $language)) {
            throw new ShopgateLibraryException(
                ShopgateLibraryException::CONFIG_READ_WRITE_ERROR,
                'invalid language code "' . $language . '"',
                true,
                false
            );
        }

        $this->loadFile($this->buildConfigFilePath('myconfig-' . $language . '.php'));
        $this->initFileNames();
    }
1246820
protected function buildPageVersion(Page $page, $lang=null, $write=false)
    {
        // Clear the cached data (especially the $page->content object)
        // or we will end up with the first language's content for all pages
        $page->reset();

        // Update the current language and active page
        if ($lang) $page->site->language = $page->site->language($lang);
        $page->site()->visit($page->uri(), $lang);

        // Let's get some metadata
        $source = $this->normalizePath($page->textfile(null, $lang));
        $source = ltrim(str_replace($this->root, '', $source), '/');
        $file   = $this->pageFilename($page, $lang);
        // Store reference to this page in case there's a fatal error
        $this->lastpage = $source;

        $log = [
            'type'   => 'page',
            'status' => '',
            'source' => $source,
            'dest'   => str_replace($this->outputdir, 'static', $file),
            'size'   => null,
            'title'  => $page->title()->value,
            'uri'    => $page->uri(),
            'files'  => []
        ];

        // Figure out if we have files to copy
        $files = [];
        if ($this->withfiles) {
            $files = $page->files();
            if (is_callable($this->withfiles)) {
                $files = $files->filter($this->withfiles);
            }
        }

        // If not writing, let's report on the existing target page
        if ($write == false) {
            if (is_file($file)) {
                $outdated = filemtime($file) < $page->modified();
                $log['status'] = $outdated ? 'outdated' : 'uptodate';
                $log['size'] = filesize($file);
            }
            else {
                $log['status'] = 'missing';
            }
            $log['files'] = count($files);
            return $this->summary[] = $log;
        }

        // Render page
        $text = $this->kirby->render($page, [], false);
        $text = $this->rewriteUrls($text, $page->url($lang));
        F::write($file, $text);
        $log['size'] = strlen($text);
        $log['status'] = 'generated';
        header_remove();

        // Option: Copy page files in a folder
        if (count($files) > 0) {
            $dir = str_replace(static::URLPREFIX, '', $page->url($lang));
            $dir = $this->normalizeSlashes($this->outputdir . '/' . $dir);
            if (!file_exists($dir)) {
                mkdir($dir, 0777, true);
            }
            foreach ($files as $f) {
                $dest = $dir . '/' . $f->filename();
                if ($f->copy($dest)) {
                    $log['files'][] = str_replace($this->outputdir, 'static', $dest);
                }
            }
        }

        return $this->summary[] = $log;
    }