コード例 #1
0
ファイル: systemsortfix.php プロジェクト: jinshana/kajonacms
function validateSinglePage(class_module_pages_page $objPage)
{
    $arrElements = class_module_pages_pageelement::getAllElementsOnPage($objPage->getSystemid());
    $intI = 0;
    $strPrevPlaceholder = "";
    $strPrevLanguage = "";
    foreach ($arrElements as $objOneElement) {
        $strCurLevel = $objOneElement->getSystemid() . " - " . $objOneElement->getIntSort() . " - " . $objOneElement->getStrRecordClass() . " - " . $objOneElement->getStrDisplayName() . " - " . $objOneElement->getStrPlaceholder();
        if ($strPrevPlaceholder != $objOneElement->getStrPlaceholder() || $strPrevLanguage != $objOneElement->getStrLanguage()) {
            $intI = 1;
        }
        if ($objOneElement->getIntSort() != $intI) {
            $strCurLevel = "<span style='color: red'>expected: " . $intI . ", got " . $objOneElement->getIntSort() . " @ " . $strCurLevel . "</span>";
            if (getGet("doFix") != "") {
                $strCurLevel .= "\nSetting new sort-id to " . $intI . "\n";
                $strQuery = "UPDATE " . _dbprefix_ . "system SET system_sort = ? WHERE system_id = ? ";
                class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array($intI, $objOneElement->getSystemid()));
            }
        } else {
            $strCurLevel = "<span style='color: green'>" . $strCurLevel . "</span>";
        }
        echo "<div style='padding-left: 25px;'>" . $strCurLevel . "</div>";
        $strPrevPlaceholder = $objOneElement->getStrPlaceholder();
        $strPrevLanguage = $objOneElement->getStrLanguage();
        $intI++;
    }
}
コード例 #2
0
 public function testImportExport()
 {
     class_carrier::getInstance()->getObjRights()->setBitTestMode(true);
     $strName = generateSystemid();
     $strBrowsername = generateSystemid();
     $strSeoString = generateSystemid();
     $strDesc = generateSystemid();
     $objPage = new class_module_pages_page();
     $objPage->setStrName($strName);
     $objPage->setStrBrowsername($strBrowsername);
     $objPage->setStrSeostring($strSeoString);
     $objPage->setStrDesc($strDesc);
     $objPage->setStrTemplate("standard.tpl");
     $objPage->updateObjectToDb();
     $strPagesystemid = $objPage->getSystemid();
     $objPagelement = new class_module_pages_pageelement();
     $objPagelement->setStrPlaceholder("text_paragraph");
     $objPagelement->setStrName("text");
     $objPagelement->setStrElement("paragraph");
     $objPagelement->updateObjectToDb($objPage->getSystemid());
     $objElement = new class_element_paragraph_admin($objPagelement->getSystemid());
     $objElement->setSystemid($objPagelement->getSystemid());
     $objElement->loadElementData();
     $objElement->setStrTitle("para_title");
     $objElement->updateForeignElement();
     $objPagelement = new class_module_pages_pageelement($objPagelement->getSystemid());
     class_carrier::getInstance()->setParam("pageExport", $strName);
     $objPageExport = new class_systemtask_pageexport();
     $objPageExport->executeTask();
     $objPage->deleteObjectFromDatabase();
     class_orm_rowcache::flushCache();
     class_db::getInstance()->flushQueryCache();
     $this->assertNull(class_module_pages_page::getPageByName($strName));
     $this->assertFileExists(_realpath_ . _projectpath_ . "/temp/" . $strPagesystemid . ".xml");
     class_carrier::getInstance()->setParam("pageimport_file", _projectpath_ . "/temp/" . $strPagesystemid . ".xml");
     $objImport = new class_systemtask_pageimport();
     $objImport->executeTask();
     $objPage = class_module_pages_page::getPageByName($strName);
     $this->assertNotNull($objPage);
     $this->assertEquals($objPage->getStrName(), $strName);
     $this->assertEquals($objPage->getStrDesc(), $strDesc);
     $this->assertEquals($objPage->getStrSeostring(), $strSeoString);
     $this->assertEquals($objPage->getStrBrowsername(), $strBrowsername);
     $objElements = class_module_pages_pageelement::getAllElementsOnPage($objPage->getSystemid());
     $this->assertEquals(1, count($objElements));
     $objElements = $objElements[0];
     $this->assertEquals($objElements->getStrClassAdmin(), "class_element_paragraph_admin.php");
     $objElement = $objElements->getConcreteAdminInstance();
     $objElement->setSystemid($objElements->getSystemid());
     $objElement->loadElementData();
     $this->assertEquals("para_title", $objElement->getStrTitle());
     $objPage->deleteObjectFromDatabase();
 }
コード例 #3
0
 private function createElementData($strPageId, XMLWriter $objWriter)
 {
     $arrElements = class_module_pages_pageelement::getAllElementsOnPage($strPageId);
     foreach ($arrElements as $objOneElement) {
         $objWriter->startElement("element");
         //elements metadata
         $objWriter->startElement("metadata");
         $objWriter->startElement("systemid");
         $objWriter->text($objOneElement->getSystemid());
         $objWriter->endElement();
         $objWriter->startElement("placeholder");
         $objWriter->text($objOneElement->getStrPlaceholder());
         $objWriter->endElement();
         $objWriter->startElement("name");
         $objWriter->text($objOneElement->getStrName());
         $objWriter->endElement();
         $objWriter->startElement("element");
         $objWriter->text($objOneElement->getStrElement());
         $objWriter->endElement();
         $objWriter->startElement("title");
         $objWriter->text($objOneElement->getStrTitle(false));
         $objWriter->endElement();
         $objWriter->startElement("language");
         $objWriter->text($objOneElement->getStrLanguage());
         $objWriter->endElement();
         $objWriter->endElement();
         //the elements-content itself
         $objElement = $objOneElement->getConcreteAdminInstance();
         //Fetch the table
         $strElementTable = $objElement->getTable();
         $objWriter->startElement("foreignTable");
         $objWriter->startAttribute("table");
         $objWriter->text(uniStrReplace(_dbprefix_, "", $strElementTable));
         $objWriter->endAttribute();
         //content-row
         $arrContentRow = class_carrier::getInstance()->getObjDB()->getPRow("SELECT * FROM " . $strElementTable . " WHERE content_id = ? ", array($objOneElement->getSystemid()));
         $arrColumns = class_carrier::getInstance()->getObjDB()->getColumnsOfTable($strElementTable);
         foreach ($arrColumns as $arrOneCol) {
             $objWriter->startElement("column");
             $objWriter->startAttribute("name");
             $objWriter->text($arrOneCol["columnName"]);
             $objWriter->endAttribute();
             $objWriter->startCdata();
             $objWriter->text($arrContentRow[$arrOneCol["columnName"]]);
             $objWriter->endCdata();
             //column
             $objWriter->endElement();
         }
         //foreignTable
         $objWriter->endElement();
         //element
         $objWriter->endElement();
     }
 }
コード例 #4
0
ファイル: test_pagesTest.php プロジェクト: jinshana/kajonacms
 public function testCopyPage()
 {
     $strTitle = generateSystemid();
     $objPage = new class_module_pages_page();
     $objPage->setStrName($strTitle);
     $objPage->setStrBrowsername(generateSystemid());
     $objPage->setStrSeostring(generateSystemid());
     $objPage->setStrDesc(generateSystemid());
     $objPage->setStrTemplate("standard.tpl");
     $objPage->updateObjectToDb();
     $strOldSystemid = $objPage->getSystemid();
     $objPagelement = new class_module_pages_pageelement();
     $objPagelement->setStrPlaceholder("text_paragraph");
     $objPagelement->setStrName("text");
     $objPagelement->setStrElement("paragraph");
     $objPagelement->updateObjectToDb($objPage->getSystemid());
     $objPagelement = new class_module_pages_pageelement($objPagelement->getSystemid());
     //and finally create the object
     /** @var $objElement class_element_paragraph_admin */
     $objElement = $objPagelement->getConcreteAdminInstance();
     $objElement->setStrTitle("autotest");
     $objElement->doBeforeSaveToDb();
     $objElement->updateForeignElement();
     $objElement->doAfterSaveToDb();
     //copy the page itself
     $objPage->copyObject();
     $strNewSystemid = $objPage->getSystemid();
     $this->flushDBCache();
     $objOldPage = new class_module_pages_page($strOldSystemid);
     $objNewPage = new class_module_pages_page($strNewSystemid);
     $this->assertNotEquals($objOldPage->getStrName(), $objNewPage->getStrName());
     $this->assertEquals($objOldPage->getStrBrowsername(), $objNewPage->getStrBrowsername());
     $this->assertEquals($objOldPage->getStrSeostring(), $objNewPage->getStrSeostring());
     $this->assertEquals($objOldPage->getStrDesc(), $objNewPage->getStrDesc());
     $this->assertEquals($objOldPage->getStrTemplate(), $objNewPage->getStrTemplate());
     $arrOldElements = class_module_pages_pageelement::getAllElementsOnPage($strOldSystemid);
     $arrNewElements = class_module_pages_pageelement::getAllElementsOnPage($strNewSystemid);
     $this->assertEquals(count($arrOldElements), count($arrNewElements));
     $this->assertEquals(1, count($arrOldElements));
     $this->assertEquals(1, count($arrNewElements));
     $objOldElement = $arrOldElements[0];
     $objNewElement = $arrNewElements[0];
     $this->assertEquals($objOldElement->getStrPlaceholder(), $objNewElement->getStrPlaceholder());
     $this->assertEquals($objOldElement->getStrLanguage(), $objNewElement->getStrLanguage());
     $this->assertEquals($objOldElement->getStrElement(), $objNewElement->getStrElement());
     /** @var class_element_paragraph_admin $objOldElementInstance */
     $objOldElementInstance = $objOldElement->getConcreteAdminInstance();
     $arrOldElementData = $objOldElementInstance->loadElementData();
     /** @var class_element_paragraph_admin $objNewElementInstance */
     $objNewElementInstance = $objNewElement->getConcreteAdminInstance();
     $arrNewElementData = $objNewElementInstance->loadElementData();
     $this->assertNotEquals($arrOldElementData["content_id"], $arrNewElementData["content_id"]);
     $this->assertEquals($arrOldElementData["paragraph_title"], $arrNewElementData["paragraph_title"]);
     $this->assertEquals($objOldElementInstance->getStrTitle(), $objNewElementInstance->getStrTitle());
     $this->assertEquals($objOldElementInstance->getStrTitle(), "autotest");
     $this->assertEquals($objNewElementInstance->getStrTitle(), "autotest");
     $objNewPage->deleteObjectFromDatabase();
     $objOldPage->deleteObjectFromDatabase();
 }