/** * Load the strings from the language file * * @param bool $onlyNew Get only new records * * @return bool True on success, false otherwise */ public function loadStringsFromFile($onlyNew = false) { $filePath = $this->getFilePath(); $overwrittenStrings = $this->loadStringsFromTemplateOverwrite(); // Check if the file exists. if (file_exists($filePath) || !empty($overwrittenStrings)) { $strings = array(); if (file_exists($filePath)) { $strings = NenoHelper::readLanguageFile($filePath); } // Merging these two arrays $strings = array_merge($strings, $overwrittenStrings); if ($strings !== false) { // Init the string array $this->languageStrings = array(); // Loop through all the strings foreach ($strings as $constant => $string) { // If this language string exists already, let's load it $languageString = NenoContentElementLanguageString::load(array('constant' => $constant, 'languagefile_id' => $this->id)); // If it's not, let's create it if (empty($languageString)) { $languageString = new NenoContentElementLanguageString(array('constant' => $constant, 'string' => $string, 'time_added' => new DateTime())); } $languageString->setLanguageFile($this); if ($languageString->isNew() && $onlyNew || !$onlyNew) { $this->languageStrings[] = $languageString; } } } } return true; }