<commit_before><?php
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2013 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*   $Id$                               *
********************************************************************************************************/

/**
 * Installer of the navigation samplecontent
 *
 * @package module_navigation
 */
class class_installer_sc_02navigation implements interface_sc_installer  {

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

    private $strMasterID = "";

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

        //search the master page
        $objMaster = class_module_pages_page::getPageByName("master");
        if($objMaster != null)
            $this->strMasterID = $objMaster->getSystemid();

        //fetch navifolder-id
        $strNaviFolderId = "";
        $arrFolder = class_module_pages_folder::getFolderList();
        foreach($arrFolder as $objOneFolder)
            if($objOneFolder->getStrName() == "mainnavigation")
                $strNaviFolderId = $objOneFolder->getSystemid();


        $strReturn = "";
        $strReturn .= "Creating new mainnavigation-tree\n";
        $objNaviTree = new class_module_navigation_tree();
        $objNaviTree->setStrName("mainnavigation");
        $objNaviTree->setStrFolderId($strNaviFolderId);
        $objNaviTree->updateObjectToDb();
        $strTreeId = $objNaviTree->getSystemid();
        $strReturn .= "ID of new navigation-tree: ".$strTreeId."\n";


        $strReturn .= "Creating new portalnavigation-tree\n";
        $objNaviTree = new class_module_navigation_tree();
        $objNaviTree->setStrName("portalnavigation");
        $objNaviTree->updateObjectToDb();
        $strTreePortalId = $objNaviTree->getSystemid();
        $strReturn .= "ID of new navigation-tree: ".$strTreePortalId."\n";

        $strReturn .= "Creating navigation points\n";
        $objNaviPoint = new class_module_navigation_point();
        $objNaviPoint->setStrName("Home");
        $objNaviPoint->setStrPageI("index");
        $objNaviPoint->updateObjectToDb($strTreePortalId);



        if($this->strMasterID != "") {
            $strReturn .= "Adding mainnavigation to master page\n";
            $strReturn .= "ID of master page: ".$this->strMasterID."\n";

            if(class_module_pages_element::getElement("navigation") != null) {
                $objPagelement = new class_module_pages_pageelement();
                $objPagelement->setStrPlaceholder("mastermainnavi_navigation");
                $objPagelement->setStrName("mastermainnavi");
                $objPagelement->setStrElement("navigation");
                $objPagelement->updateObjectToDb($this->strMasterID);
                $strElementId = $objPagelement->getSystemid();
                $strQuery = "UPDATE "._dbprefix_."element_navigation
                                SET navigation_id= ?,
                                    navigation_template = ?
                                WHERE content_id = ?";
                if($this->objDB->_pQuery($strQuery, array($strTreeId, "mainnavi.tpl", $strElementId)))
                    $strReturn .= "Navigation element created.\n";
                else
                    $strReturn .= "Error creating navigation element.\n";
            }

            $strReturn .= "Adding portalnavigation to master page\n";
            $strReturn .= "ID of master page: ".$this->strMasterID."\n";

            if(class_module_pages_element::getElement("navigation") != null) {
                $objPagelement = new class_module_pages_pageelement();
                $objPagelement->setStrPlaceholder("masterportalnavi_navigation");
                $objPagelement->setStrName("masterportalnavi");
                $objPagelement->setStrElement("navigation");
                $objPagelement->updateObjectToDb($this->strMasterID);
                $strElementId = $objPagelement->getSystemid();
                $strQuery = "UPDATE "._dbprefix_."element_navigation
                                SET navigation_id= ?,
                                    navigation_template = ?
                                WHERE content_id = ?";
                if($this->objDB->_pQuery($strQuery, array($strTreePortalId, "portalnavi.tpl", $strElementId)))
                    $strReturn .= "Navigation element created.\n";
                else
                    $strReturn .= "Error creating navigation element.\n";

            }

            $strReturn .= "Adding pathnavigation to master page\n";
            $strReturn .= "ID of master page: ".$this->strMasterID."\n";

            if(class_module_pages_element::getElement("navigation") != null) {
                $objPagelement = new class_module_pages_pageelement();
                $objPagelement->setStrPlaceholder("masterpathnavi_navigation");
                $objPagelement->setStrName("masterpathnavi");
                $objPagelement->setStrElement("navigation");
                $objPagelement->updateObjectToDb($this->strMasterID);
                $strElementId = $objPagelement->getSystemid();
                $strQuery = "UPDATE "._dbprefix_."element_navigation
                                SET navigation_id= ?,
                                    navigation_template = ?
                                WHERE content_id = ?";
                if($this->objDB->_pQuery($strQuery, array($strTreePortalId, "breadcrumbnavi.tpl", $strElementId)))
                    $strReturn .= "Navigation element created.\n";
                else
                    $strReturn .= "Error creating navigation element.\n";

            }
        }

        $strReturn .= "Creating simple sitemap...\n";
        $objPage = new class_module_pages_page();
        $objPage->setStrName("sitemap");
        $objPage->setStrBrowsername("Sitemap");
        $objPage->setStrTemplate("standard.tpl");
        $objPage->updateObjectToDb();
        $strSitemapId = $objPage->getSystemid();
        $strReturn .= "ID of new page: ".$strSitemapId."\n";
        $strReturn .= "Adding sitemap to new page\n";

        if(class_module_pages_element::getElement("navigation") != null) {
            $objPagelement = new class_module_pages_pageelement();
            $objPagelement->setStrPlaceholder("sitemap_navigation");
            $objPagelement->setStrName("sitemap");
            $objPagelement->setStrElement("navigation");<commit_msg>BUG: the samplecontent breadcrumb used the wrong navigation-tree<commit_after><?php
/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2013 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*   $Id$                               *
********************************************************************************************************/

/**
 * Installer of the navigation samplecontent
 *
 * @package module_navigation
 */
class class_installer_sc_02navigation implements interface_sc_installer  {

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

    private $strMasterID = "";

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

        //search the master page
        $objMaster = class_module_pages_page::getPageByName("master");
        if($objMaster != null)
            $this->strMasterID = $objMaster->getSystemid();

        //fetch navifolder-id
        $strNaviFolderId = "";
        $arrFolder = class_module_pages_folder::getFolderList();
        foreach($arrFolder as $objOneFolder)
            if($objOneFolder->getStrName() == "mainnavigation")
                $strNaviFolderId = $objOneFolder->getSystemid();


        $strReturn = "";
        $strReturn .= "Creating new mainnavigation-tree\n";
        $objNaviTree = new class_module_navigation_tree();
        $objNaviTree->setStrName("mainnavigation");
        $objNaviTree->setStrFolderId($strNaviFolderId);
        $objNaviTree->updateObjectToDb();
        $strTreeId = $objNaviTree->getSystemid();
        $strReturn .= "ID of new navigation-tree: ".$strTreeId."\n";


        $strReturn .= "Creating new portalnavigation-tree\n";
        $objNaviTree = new class_module_navigation_tree();
        $objNaviTree->setStrName("portalnavigation");
        $objNaviTree->updateObjectToDb();
        $strTreePortalId = $objNaviTree->getSystemid();
        $strReturn .= "ID of new navigation-tree: ".$strTreePortalId."\n";

        $strReturn .= "Creating navigation points\n";
        $objNaviPoint = new class_module_navigation_point();
        $objNaviPoint->setStrName("Home");
        $objNaviPoint->setStrPageI("index");
        $objNaviPoint->updateObjectToDb($strTreePortalId);



        if($this->strMasterID != "") {
            $strReturn .= "Adding mainnavigation to master page\n";
            $strReturn .= "ID of master page: ".$this->strMasterID."\n";

            if(class_module_pages_element::getElement("navigation") != null) {
                $objPagelement = new class_module_pages_pageelement();
                $objPagelement->setStrPlaceholder("mastermainnavi_navigation");
                $objPagelement->setStrName("mastermainnavi");
                $objPagelement->setStrElement("navigation");
                $objPagelement->updateObjectToDb($this->strMasterID);
                $strElementId = $objPagelement->getSystemid();
                $strQuery = "UPDATE "._dbprefix_."element_navigation
                                SET navigation_id= ?,
                                    navigation_template = ?
                                WHERE content_id = ?";
                if($this->objDB->_pQuery($strQuery, array($strTreeId, "mainnavi.tpl", $strElementId)))
                    $strReturn .= "Navigation element created.\n";
                else
                    $strReturn .= "Error creating navigation element.\n";
            }

            $strReturn .= "Adding portalnavigation to master page\n";
            $strReturn .= "ID of master page: ".$this->strMasterID."\n";

            if(class_module_pages_element::getElement("navigation") != null) {
                $objPagelement = new class_module_pages_pageelement();
                $objPagelement->setStrPlaceholder("masterportalnavi_navigation");
                $objPagelement->setStrName("masterportalnavi");
                $objPagelement->setStrElement("navigation");
                $objPagelement->updateObjectToDb($this->strMasterID);
                $strElementId = $objPagelement->getSystemid();
                $strQuery = "UPDATE "._dbprefix_."element_navigation
                                SET navigation_id= ?,
                                    navigation_template = ?
                                WHERE content_id = ?";
                if($this->objDB->_pQuery($strQuery, array($strTreePortalId, "portalnavi.tpl", $strElementId)))
                    $strReturn .= "Navigation element created.\n";
                else
                    $strReturn .= "Error creating navigation element.\n";

            }

            $strReturn .= "Adding pathnavigation to master page\n";
            $strReturn .= "ID of master page: ".$this->strMasterID."\n";

            if(class_module_pages_element::getElement("navigation") != null) {
                $objPagelement = new class_module_pages_pageelement();
                $objPagelement->setStrPlaceholder("masterpathnavi_navigation");
                $objPagelement->setStrName("masterpathnavi");
                $objPagelement->setStrElement("navigation");
                $objPagelement->updateObjectToDb($this->strMasterID);
                $strElementId = $objPagelement->getSystemid();
                $strQuery = "UPDATE "._dbprefix_."element_navigation
                                SET navigation_id= ?,
                                    navigation_template = ?
                                WHERE content_id = ?";
                if($this->objDB->_pQuery($strQuery, array($strTreeId, "breadcrumbnavi.tpl", $strElementId)))
                    $strReturn .= "Navigation element created.\n";
                else
                    $strReturn .= "Error creating navigation element.\n";

            }
        }

        $strReturn .= "Creating simple sitemap...\n";
        $objPage = new class_module_pages_page();
        $objPage->setStrName("sitemap");
        $objPage->setStrBrowsername("Sitemap");
        $objPage->setStrTemplate("standard.tpl");
        $objPage->updateObjectToDb();
        $strSitemapId = $objPage->getSystemid();
        $strReturn .= "ID of new page: ".$strSitemapId."\n";
        $strReturn .= "Adding sitemap to new page\n";

        if(class_module_pages_element::getElement("navigation") != null) {
            $objPagelement = new class_module_pages_pageelement();
            $objPagelement->setStrPlaceholder("sitemap_navigation");
            $objPagelement->setStrName("sitemap");
            $objPagelement->setStrElement("navigation");
{'fraction_non_alphanumeric': 0.1600171907456486, 'fraction_numerical': 0.002865124274765418, 'mean_word_length': 2.0292905185506616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2557498', 'n_tokens_mistral': 3658, 'n_tokens_neox': 3471, 'n_words': 590}