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();
     }
 }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 public function testRssFeed()
 {
     echo "creating news & category..\n";
     $objNews = new class_module_news_news();
     $objNews->setStrTitle("autotest");
     $objNews->setStrIntro("autotest");
     $objNews->setStrText("autotest");
     $this->assertTrue($objNews->updateObjectToDb(), __FILE__ . " save news");
     $objNews2 = new class_module_news_news();
     $objNews2->setStrTitle("autotest2");
     $objNews2->setStrIntro("autotest2");
     $objNews2->setStrText("autotest2");
     $this->assertTrue($objNews2->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();
     echo "adding news to category..\n";
     $objNews->setArrCats(array($objCat->getSystemid()));
     $this->assertTrue($objNews->updateObjectToDb(), __FILE__ . " update news");
     $this->flushDBCache();
     echo "creating feed...\n";
     $objFeed = new class_module_news_feed();
     $objFeed->setStrTitle("testfeed");
     $objFeed->setStrCat($objCat->getSystemid());
     $objFeed->setStrUrlTitle("autotest");
     $objFeed->setStrPage("autotest");
     $objFeed->updateObjectToDb();
     $this->flushDBCache();
     $this->assertEquals(1, count(class_module_news_feed::getNewsList($objFeed->getStrCat())), __FILE__ . " check news for feed");
     $this->assertEquals(1, count(class_module_news_feed::getNewsList($objFeed->getStrCat(), 1)), __FILE__ . " check news for feed");
     echo "generating feed by creating a fake request...\n";
     $objNewsPortalXML = new class_module_news_portal_xml();
     $objNewsPortalXML->setParam("feedTitle", "autotest");
     $strFeed = $objNewsPortalXML->action("newsFeed");
     $this->assertTrue(uniStrpos($strFeed, "<title>autotest</title>") !== false, __FILE__ . " check rss feed");
     echo "parsing feed with xml parser...\n";
     $objXmlParser = new class_xml_parser();
     $objXmlParser->loadString($strFeed);
     $arrFeed = $objXmlParser->xmlToArray();
     $intNrOfNews = count($arrFeed["rss"][0]["channel"][0]["item"]);
     $this->assertEquals(1, $intNrOfNews, __FILE__ . " check items for feed");
     $strTitle = $arrFeed["rss"][0]["channel"][0]["item"][0]["title"][0]["value"];
     $this->assertEquals("autotest", $strTitle, __FILE__ . " check items-title for feed");
     echo "adding news to category..\n";
     $objNews2->setArrCats(array($objCat->getSystemid()));
     $this->assertTrue($objNews2->updateObjectToDb(), __FILE__ . " update news");
     $this->flushDBCache();
     $objNewsPortalXML = new class_module_news_portal_xml();
     $objNewsPortalXML->setParam("feedTitle", "autotest");
     $strFeed = $objNewsPortalXML->action("newsFeed");
     $this->assertTrue(uniStrpos($strFeed, "<title>autotest</title>") !== false, __FILE__ . " check rss feed");
     echo "parsing feed with xml parser...\n";
     $objXmlParser = new class_xml_parser();
     $objXmlParser->loadString($strFeed);
     $arrFeed = $objXmlParser->xmlToArray();
     //var_dump($arrFeed["rss"][0]["channel"][0]["item"]);
     $intNrOfNews = count($arrFeed["rss"][0]["channel"][0]["item"]);
     $this->assertEquals(2, $intNrOfNews, __FILE__ . " check items for feed");
     echo "deleting news & category...\n";
     $this->assertTrue($objNews->deleteObjectFromDatabase(), __FILE__ . " delete news");
     $this->assertTrue($objNews2->deleteObjectFromDatabase(), __FILE__ . " delete news");
     $this->assertTrue($objCat->deleteObjectFromDatabase(), __FILE__ . " delete cat");
     $this->assertTrue($objFeed->deleteObjectFromDatabase(), __FILE__ . " delete feed");
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
 /**
  * Saves newscontent as passed by post-paras via an xml-request.
  * Params expected are: newstitle, newsintro, newsimage, newstext, categories, startdate, enddate, archivedate
  *
  * @return string
  * @xml
  */
 protected function actionUpdateNewsXml()
 {
     $objNews = new class_module_news_news($this->getSystemid());
     if ($objNews->rightEdit() || $this->getSystemid() == "") {
         $arrCats = array();
         foreach (explode(",", $this->getParam("categories")) as $strCatId) {
             $arrCats[$strCatId] = "c";
         }
         $objNews->setStrTitle($this->getParam("newstitle"));
         $objNews->setStrIntro($this->getParam("newsintro"));
         $objNews->setStrImage($this->getParam("newsimage"));
         $objNews->setStrText($this->getParam("newstext"));
         if ($this->getParam("startdate") > 0) {
             $objDate = new class_date($this->getParam("startdate"));
             $objNews->setObjDateStart($objDate);
         }
         if ($this->getParam("enddate") > 0) {
             $objDate = new class_date($this->getParam("enddate"));
             $objNews->setObjDateEnd($objDate);
         }
         if ($this->getParam("archivedate") > 0) {
             $objDate = new class_date($this->getParam("archivedate"));
             $objNews->setObjDateSpecial($objDate);
         }
         $objNews->setArrCats($arrCats);
         if ($objNews->updateObjectToDb()) {
             $strReturn = "<success></success>";
         } else {
             $strReturn = "<error></error>";
         }
     } else {
         $strReturn = "<error>" . $this->getLang("commons_error_permissions") . "</error>";
     }
     return $strReturn;
 }