FOF30\Factory\Scaffolding\Layout\Builder::saveStrings PHP Method

saveStrings() protected method

Saves the language strings, merged with any old ones, to a Joomla! INI language file
protected saveStrings ( string $targetFilename = null )
$targetFilename string The full path to the INI file, leave blank for auto-detection
    protected function saveStrings($targetFilename = null)
    {
        // If no filename is defined, get the component's language definition filename
        if (empty($targetFilename)) {
            $jLang = $this->container->platform->getLanguage();
            $basePath = $this->container->platform->isBackend() ? JPATH_ADMINISTRATOR : JPATH_SITE;
            $lang = $jLang->setLanguage('en-GB');
            $jLang->setLanguage($lang);
            $path = $jLang->getLanguagePath($basePath, $lang);
            $targetFilename = $path . '/' . $lang . '.' . $this->container->componentName . '.ini';
        }
        // Try to load the existing language file
        $strings = array();
        if (@file_exists($targetFilename)) {
            $contents = file_get_contents($targetFilename);
            $contents = str_replace('_QQ_', '"\\""', $contents);
            $strings = @parse_ini_string($contents);
        }
        $strings = array_merge($strings, $this->strings);
        // Create the INI file
        $iniFile = '';
        foreach ($strings as $k => $v) {
            $iniFile .= strtoupper($k) . '="' . str_replace('"', '"_QQ_"', $v) . "\"\n";
        }
        // Save it
        $saveResult = @file_put_contents($targetFilename, $iniFile);
        if ($saveResult === false) {
            \JLoader::import('joomla.filesystem.file');
            \JFile::write($targetFilename, $iniFile);
        }
    }