public function testCreateDelete() { echo "creating a news..\n"; $objNews = new class_module_news_news(); $objNews->setStrTitle("autotest"); $objNews->setStrIntro("autotest"); $objNews->setStrText("autotest"); $this->assertTrue($objNews->updateObjectToDb(), __FILE__ . " save news"); echo "creating category...\n"; $objCat = new class_module_news_category(); $objCat->setStrTitle("autotest"); $this->assertTrue($objCat->updateObjectToDb(), __FILE__ . " save cat"); $this->flushDBCache(); $this->assertEquals(0, count(class_module_news_category::getNewsMember($objNews->getSystemid())), __FILE__ . " check cats for news"); $this->assertEquals(0, count(class_module_news_news::getObjectList($objCat->getSystemid())), __FILE__ . " check news for cat"); echo "adding news to category..\n"; $objNews->setArrCats(array($objCat->getSystemid())); $this->assertTrue($objNews->updateObjectToDb(), __FILE__ . " update news"); $strNewsId = $objNews->getSystemid(); $strCatId = $objCat->getSystemid(); $this->flushDBCache(); $objNews = new class_module_news_news($strNewsId); $objCat = new class_module_news_category($strCatId); $this->assertEquals(1, count(class_module_news_category::getNewsMember($objNews->getSystemid())), __FILE__ . " check cats for news"); $this->assertEquals(1, count(class_module_news_news::getObjectList($objCat->getSystemid())), __FILE__ . " check news for cat"); echo "deleting news...\n"; $this->assertTrue($objNews->deleteObjectFromDatabase(), __FILE__ . " delete news"); $this->flushDBCache(); $this->assertEquals(0, count(class_module_news_news::getObjectList($objCat->getSystemid())), __FILE__ . " check news for cat"); $this->assertTrue($objCat->deleteObjectFromDatabase(), __FILE__ . " delete cat"); }
public function testObjectIndexerPerformance() { if (class_module_system_module::getModuleByName("news") === null) { return; } $arrNewsIds = array(); echo "Indexing without deferred indexer...\n"; class_module_system_changelog::$bitChangelogEnabled = false; $intTimeStart = microtime(true); $intQueriesStart = class_db::getInstance()->getNumber(); for ($intI = 0; $intI < 15; $intI++) { $objNews = new class_module_news_news(); $objNews->setStrTitle("demo 1"); $objNews->setStrIntro("intro demo news"); $objNews->setStrText("text demo news"); $objNews->updateObjectToDb(); $arrNewsIds[] = $objNews->getSystemid(); } echo "Queries pre indexing: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n"; $objHandler = new class_module_search_request_endprocessinglistener(); $objHandler->handleEvent(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, array()); $intTimeEnd = microtime(true); $time = $intTimeEnd - $intTimeStart; echo "Object updates: ", sprintf('%f', $time), " sec.\n"; echo "Queries total: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n"; echo "\nIndexing with deferred indexer...\n"; $objConfig = class_module_system_setting::getConfigByName("_search_deferred_indexer_"); $objConfig->setStrValue("true"); $objConfig->updateObjectToDb(); $intTimeStart = microtime(true); $intQueriesStart = class_db::getInstance()->getNumber(); for ($intI = 0; $intI < 15; $intI++) { $objNews = new class_module_news_news(); $objNews->setStrTitle("demo 1"); $objNews->setStrIntro("intro demo news"); $objNews->setStrText("text demo news"); $objNews->updateObjectToDb(); $arrNewsIds[] = $objNews->getSystemid(); } echo "Queries pre indexing: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n"; echo "Triggering queue update event...\n"; $objHandler = new class_module_search_request_endprocessinglistener(); $objHandler->handleEvent(class_system_eventidentifier::EVENT_SYSTEM_REQUEST_AFTERCONTENTSEND, array()); $intTimeEnd = microtime(true); $time = $intTimeEnd - $intTimeStart; echo "Object updates: ", sprintf('%f', $time), " sec.\n"; echo "Queries total: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n"; $objConfig = class_module_system_setting::getConfigByName("_search_deferred_indexer_"); $objConfig->setStrValue("false"); $objConfig->updateObjectToDb(); foreach ($arrNewsIds as $strNewsId) { class_objectfactory::getInstance()->getObject($strNewsId)->deleteObjectFromDatabase(); } }
public function testObjectIndexerPerformance() { if (class_module_system_module::getModuleByName("news") === null) { return; } $objNews = new class_module_news_news(); $objNews->setStrTitle("demo 1"); $objNews->setStrIntro("intro demo news"); $objNews->setStrText("text demo news"); $objNews->updateObjectToDb(); $strNewsId = $objNews->getSystemid(); echo "Status changes with disabled changelog indexer integration...\n"; class_module_system_changelog::$bitChangelogEnabled = false; $intTimeStart = microtime(true); $intQueriesStart = class_db::getInstance()->getNumber(); for ($intI = 0; $intI < 150; $intI++) { $objNews->setIntRecordStatus($intI % 2); $objNews->updateObjectToDb(); } $intTimeEnd = microtime(true); $time = $intTimeEnd - $intTimeStart; echo "Object updates: ", sprintf('%f', $time), " sec.\n"; echo "Queries: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n"; echo "Status changes with enabled changelog indexer integration...\n"; class_module_system_changelog::$bitChangelogEnabled = true; $intTimeStart = microtime(true); $intQueriesStart = class_db::getInstance()->getNumber(); for ($intI = 0; $intI < 150; $intI++) { $objNews->setIntRecordStatus($intI % 2); $objNews->updateObjectToDb(); } $intTimeEnd = microtime(true); $time = $intTimeEnd - $intTimeStart; echo "Object updates: ", sprintf('%f', $time), " sec.\n"; echo "Queries: ", class_db::getInstance()->getNumber() - $intQueriesStart . " \n"; class_objectfactory::getInstance()->getObject($strNewsId)->deleteObjectFromDatabase(); }
/** * Renders the news category titles * @param class_module_news_news $objNews * * @return string */ private function renderCategoryTitles(class_module_news_news $objNews) { if (count(class_module_news_category::getNewsMember($objNews->getSystemid())) == 0) { return ""; } $strCategories = ""; foreach (class_module_news_category::getNewsMember($objNews->getSystemid()) as $objCat) { $objMapper = new class_template_mapper($objCat); $strCategories .= $objMapper->writeToTemplate("/module_news/" . $this->arrElementData["news_template"], "categories_category"); } $strWrapper = $this->objTemplate->readTemplate("/module_news/" . $this->arrElementData["news_template"], "categories_wrapper"); return $this->objTemplate->fillTemplate(array("categories" => $strCategories), $strWrapper); }
/** * Does the hard work: installs the module and registers needed constants * */ public function install() { $strReturn = ""; //fetch navifolder-id $strNaviFolderId = ""; $arrFolder = class_module_pages_folder::getFolderList(); foreach ($arrFolder as $objOneFolder) { if ($objOneFolder->getStrName() == "mainnavigation") { $strNaviFolderId = $objOneFolder->getSystemid(); } } //search the index page $objIndex = class_module_pages_page::getPageByName("index"); $objMaster = class_module_pages_page::getPageByName("master"); if ($objIndex != null) { $this->strIndexID = $objIndex->getSystemid(); } if ($objMaster != null) { $this->strMasterID = $objMaster->getSystemid(); } $strReturn .= "Creating new category...\n"; $objNewsCategory = new class_module_news_category(); $objNewsCategory->setStrTitle("TOP-News"); $objNewsCategory->updateObjectToDb(); $strCategoryID = $objNewsCategory->getSystemid(); $strReturn .= "ID of new category: " . $strCategoryID . "\n"; $strReturn .= "Creating news\n"; $objNews = new class_module_news_news(); if ($this->strContentLanguage == "de") { $objNews->setStrTitle("Erfolgreich installiert"); $objNews->setStrText("Eine weitere Installation von Kajona V3 war erfolgreich. Für weitere Infomationen zu Kajona besuchen Sie www.kajona.de."); $objNews->setStrIntro("Kajona wurde erfolgreich installiert..."); } else { $objNews->setStrTitle("Installation successful"); $objNews->setStrText("Another installation of Kajona was successful. For further information, support or proposals, please visit our website: www.kajona.de"); $objNews->setStrIntro("Kajona installed successfully..."); } $objNews->setObjDateStart(new class_date()); $objNews->setArrCats(array($strCategoryID)); $objNews->updateObjectToDb(); $strNewsId = $objNews->getSystemid(); $strReturn .= "ID of new news: " . $strNewsId . "\n"; $strReturn .= "Creating news\n"; $objNews = new class_module_news_news(); $objNews->setStrTitle("Sed non enim est"); $objNews->setStrText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non enim est, id hendrerit metus. Sed tempor quam sed ante viverra porta. Quisque sagittis egestas tortor, in euismod sapien iaculis at. Nullam vitae nunc tortor. Mauris justo lectus, bibendum et rutrum id, fringilla eget ipsum. Nullam volutpat sodales mollis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis tempor ante eget justo blandit imperdiet. Praesent ut risus tempus metus sagittis fermentum eget eu elit. Mauris consequat ornare massa, a rhoncus enim sodales auctor. Duis lacinia dignissim eros vel mollis. Etiam metus tortor, pellentesque eu ultricies sit amet, elementum et dolor. Proin tincidunt nunc id magna volutpat lobortis. Vivamus metus quam, accumsan eget vestibulum vel, rutrum sit amet mauris. Phasellus lectus leo, vulputate eget molestie et, consectetur nec urna. "); $objNews->setStrIntro("Quisque sagittis egestas tortor"); $objNews->setObjDateStart(new class_date()); $objNews->setArrCats(array($strCategoryID)); $objNews->updateObjectToDb(); $strNewsId = $objNews->getSystemid(); $strReturn .= "ID of new news: " . $strNewsId . "\n"; $strReturn .= "Adding news element to the master-page...\n"; if ($this->strMasterID != "") { if (class_module_pages_element::getElement("news") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("mastertopnews_news"); $objPagelement->setStrName("mastertopnews"); $objPagelement->setStrElement("news"); $objPagelement->updateObjectToDb($this->strMasterID); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_news\n SET news_category=?,\n news_view = ?,\n news_mode = ?,\n news_order = ?,\n news_amount = ?,\n news_detailspage = ?,\n news_template = ?\n WHERE content_id = ?"; if ($this->objDB->_pQuery($strQuery, array($strCategoryID, 0, 0, 0, 10, "newsdetails", "demo.tpl", $strElementId))) { $strReturn .= "Newselement created.\n"; } else { $strReturn .= "Error creating newselement.\n"; } } } $strReturn .= "Creating news-detail\n"; $objPage = new class_module_pages_page(); $objPage->setStrName("newsdetails"); $objPage->setStrBrowsername("News"); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb(); $strNewsdetailsId = $objPage->getSystemid(); $strReturn .= "ID of new page: " . $strNewsdetailsId . "\n"; $strReturn .= "Adding newsdetails to new page\n"; if (class_module_pages_element::getElement("news") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("special_news|guestbook|downloads|gallery|galleryRandom|form|tellafriend|maps|search|navigation|faqs|postacomment|votings|userlist|rssfeed|tagto|portallogin|portalregistration|portalupload|directorybrowser|lastmodified|tagcloud|downloadstoplist|flash|mediaplayer|tags|eventmanager"); $objPagelement->setStrName("special"); $objPagelement->setStrElement("news"); $objPagelement->updateObjectToDb($strNewsdetailsId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_news\n SET news_category=?,\n news_view = ?,\n news_mode = ?,\n news_order = ?,\n news_amount = ?,\n news_detailspage = ?,\n news_template = ?\n WHERE content_id = ?"; if ($this->objDB->_pQuery($strQuery, array($strCategoryID, 1, 0, 0, 20, "index", "demo.tpl", $strElementId))) { $strReturn .= "Newselement created.\n"; } else { $strReturn .= "Error creating newselement.\n"; } } $strReturn .= "Adding headline-element to new page\n"; if (class_module_pages_element::getElement("row") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("headline_row"); $objPagelement->setStrName("headline"); $objPagelement->setStrElement("row"); $objPagelement->updateObjectToDb($strNewsdetailsId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_paragraph\n SET paragraph_title = ?\n WHERE content_id = ?"; if ($this->objDB->_pQuery($strQuery, array("News", $strElementId))) { $strReturn .= "Headline element created.\n"; } else { $strReturn .= "Error creating headline element.\n"; } } $strReturn .= "Creating news-list-pge\n"; $objPage = new class_module_pages_page(); $objPage->setStrName("news"); $objPage->setStrBrowsername("News"); $objPage->setStrTemplate("standard.tpl"); $objPage->updateObjectToDb($strNaviFolderId); $strNewslistId = $objPage->getSystemid(); $strReturn .= "ID of new page: " . $strNewsdetailsId . "\n"; $strReturn .= "Adding newsdetails to new page\n"; if (class_module_pages_element::getElement("news") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("special_news|guestbook|downloads|gallery|galleryRandom|form|tellafriend|maps|search|navigation|faqs|postacomment|votings|userlist|rssfeed|tagto|portallogin|portalregistration|portalupload|directorybrowser|lastmodified|tagcloud|downloadstoplist|flash|mediaplayer|tags|eventmanager"); $objPagelement->setStrName("special"); $objPagelement->setStrElement("news"); $objPagelement->updateObjectToDb($strNewslistId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_news\n SET news_category=?,\n news_view = ?,\n news_mode = ?,\n news_order = ?,\n news_amount = ?,\n news_detailspage = ?,\n news_template = ?\n WHERE content_id = ?"; if ($this->objDB->_pQuery($strQuery, array($strCategoryID, 0, 0, 0, 20, "newsdetails", "demo.tpl", $strElementId))) { $strReturn .= "Newselement created.\n"; } else { $strReturn .= "Error creating newselement.\n"; } } $strReturn .= "Adding headline-element to new page\n"; if (class_module_pages_element::getElement("row") != null) { $objPagelement = new class_module_pages_pageelement(); $objPagelement->setStrPlaceholder("headline_row"); $objPagelement->setStrName("headline"); $objPagelement->setStrElement("row"); $objPagelement->updateObjectToDb($strNewslistId); $strElementId = $objPagelement->getSystemid(); $strQuery = "UPDATE " . _dbprefix_ . "element_paragraph\n SET paragraph_title = ?\n WHERE content_id = ?"; if ($this->objDB->_pQuery($strQuery, array("Newslist", $strElementId))) { $strReturn .= "Headline element created.\n"; } else { $strReturn .= "Error creating headline element.\n"; } } $strReturn .= "Creating news-feed\n"; $objNewsFeed = new class_module_news_feed(); $objNewsFeed->setStrTitle("kajona news"); $objNewsFeed->setStrUrlTitle("kajona_news"); $objNewsFeed->setStrLink("http://www.kajona.de"); if ($this->strContentLanguage == "de") { $objNewsFeed->setStrDesc("Dies ist ein Kajona demo news feed"); } else { $objNewsFeed->setStrDesc("This is a Kajona demo news feed"); } $objNewsFeed->setStrPage($objPage->getStrName()); $objNewsFeed->setStrCat("0"); $objNewsFeed->setIntAmount(25); $objNewsFeed->updateObjectToDb(); $strNewsFeedId = $objNewsFeed->getSystemid(); $strReturn .= "ID of new news-feed: " . $strNewsFeedId . "\n"; $strReturn .= "Adding rating permissions...\n"; class_carrier::getInstance()->getObjRights()->addGroupToRight(class_module_system_setting::getConfigValue("_guests_group_id_"), class_module_system_module::getModuleByName("news")->getSystemid(), class_rights::$STR_RIGHT_RIGHT3); return $strReturn; }
/** * Returns a xml-based representation of a single news. * Return format: * <news> * <title></title> * <systemid></systemid> * <intro></intro> * <text></text> * <image></image> * <categories></categories> * <startdate></startdate> * <enddate></enddate> * <archivedate></archivedate> * </news> * * @return string * @xml */ protected function actionNewsDetails() { $strReturn = ""; $objNews = new class_module_news_news($this->getSystemid()); $arrCats = class_module_news_category::getNewsMember($objNews->getSystemid()); array_walk($arrCats, function (class_module_news_category &$objValue) { $objValue = $objValue->getSystemid(); }); if ($objNews->rightView()) { $strReturn .= " <news>\n"; $strReturn .= " <title>" . xmlSafeString($objNews->getStrTitle()) . "</title>"; $strReturn .= " <systemid>" . $objNews->getSystemid() . "</systemid>"; $strReturn .= " <intro>" . xmlSafeString($objNews->getStrIntro()) . "</intro>"; $strReturn .= " <text>" . xmlSafeString($objNews->getStrText()) . "</text>"; $strReturn .= " <image>" . xmlSafeString($objNews->getStrImage()) . "</image>"; $strReturn .= " <categories>" . xmlSafeString(implode(",", $arrCats)) . "</categories>"; $strReturn .= " <startdate>" . xmlSafeString($objNews->getObjStartDate() != null ? $objNews->getObjStartDate()->getTimeInOldStyle() : "") . "</startdate>"; $strReturn .= " <enddate>" . xmlSafeString($objNews->getObjEndDate() != null ? $objNews->getObjEndDate()->getTimeInOldStyle() : "") . "</enddate>"; $strReturn .= " <archivedate>" . xmlSafeString($objNews->getObjDateSpecial() != null ? $objNews->getObjDateSpecial()->getTimeInOldStyle() : "") . "</archivedate>"; $strReturn .= " </news>\n"; } else { $strReturn = "<error>" . $this->getLang("commons_error_permissions") . "</error>"; } return $strReturn; }