Source of file InstallerSamplecontentZZLanguages.php

Size: 3,616 Bytes - Last Modified: 2016-05-18T03:08:27+02:00

buildproject/core/module_system/installer/InstallerSamplecontentZZLanguages.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
<?php
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2016 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
********************************************************************************************************/
namespace Kajona\System\Installer;

use Kajona\Pages\System\PagesPage;
use Kajona\Pages\System\PagesPageelement;
use Kajona\System\System\Carrier;
use Kajona\System\System\Classloader;
use Kajona\System\System\Database;
use Kajona\System\System\LanguagesLanguage;
use Kajona\System\System\SamplecontentInstallerInterface;
use Kajona\System\System\SystemModule;


/**
 * Installer of the navigation languages
 *
 */
class InstallerSamplecontentZZLanguages implements SamplecontentInstallerInterface
{

    /**
     * @var Database
     */
    private $objDB;
    private $strContentLanguage;


    /**
     * @inheritDoc
     */
    public function isInstalled()
    {
        if(SystemModule::getModuleByName("pages") == null) {
            return true;
        }

        $strCountQuery = "SELECT COUNT(*)
                                FROM "._dbprefix_."page_element
                               WHERE page_element_ph_language = ''";
        $arrCount = Carrier::getInstance()->getObjDB()->getPRow($strCountQuery, array());
        return $arrCount["COUNT(*)"] == 0;
    }


    /**
     *
     * Does the hard work: installs the module and registers needed constants
     *
     * @return string
     */
    public function install()
    {
        $strReturn = "";

        $strReturn .= "Assigning null-properties and elements to the default language.\n";
        if ($this->strContentLanguage == "de") {

            $strReturn .= " Target language: de\n";

            if (class_exists("Kajona\\Pages\\System\\PagesPage", false) || Classloader::getInstance()->loadClass("Kajona\\Pages\\System\\PagesPage") !== false) {
                PagesPage::assignNullProperties("de", true);
            }
            if (class_exists("Kajona\\Pages\\System\\PagesPageelement", false) || Classloader::getInstance()->loadClass("Kajona\\Pages\\System\\PagesPageelement") !== false) {
                PagesPageelement::assignNullElements("de");
            }

            $objLang = new LanguagesLanguage();
            $objLang->setStrAdminLanguageToWorkOn("de");
        }
        else {

            $strReturn .= " Target language: en\n";

            if (class_exists("Kajona\\Pages\\System\\PagesPage", false) || Classloader::getInstance()->loadClass("Kajona\\Pages\\System\\PagesPage") !== false) {
                PagesPage::assignNullProperties("en", true);
            }
            if (class_exists("Kajona\\Pages\\System\\PagesPageelement", false) || Classloader::getInstance()->loadClass("Kajona\\Pages\\System\\PagesPageelement") !== false) {
                PagesPageelement::assignNullElements("en");
            }

            $objLang = new LanguagesLanguage();
            $objLang->setStrAdminLanguageToWorkOn("en");

        }


        return $strReturn;
    }

    public function setObjDb($objDb)
    {
        $this->objDB = $objDb;
    }

    public function setStrContentlanguage($strContentlanguage)
    {
        $this->strContentLanguage = $strContentlanguage;
    }

    public function getCorrespondingModule()
    {
        return "languages";
    }
}