/**
  * This method loads all data to needed for a newsfeed
  *
  * @return string
  */
 protected function actionNewsFeed()
 {
     $strReturn = "";
     //if no sysid was given, try to load from feedname
     $objNewsfeed = null;
     if ($this->getParam("feedTitle") != "") {
         $objNewsfeed = class_module_news_feed::getFeedByUrlName($this->getParam("feedTitle"));
     }
     if ($objNewsfeed != null) {
         //and load all news belonging to the selected category
         if ($objNewsfeed->getStrCat() != "0") {
             $arrNews = class_module_news_feed::getNewsList($objNewsfeed->getStrCat(), $objNewsfeed->getIntAmount());
         } else {
             $arrNews = class_module_news_feed::getNewsList("", $objNewsfeed->getIntAmount());
         }
         $strReturn .= $this->createNewsfeedXML($objNewsfeed->getStrTitle(), $objNewsfeed->getStrLink(), $objNewsfeed->getStrDesc(), $objNewsfeed->getStrPage(), $arrNews);
         //and count the request
         $objNewsfeed->incrementNewsCounter();
     } else {
         $strReturn .= $this->createNewsfeedXML("", "", "", "", array());
     }
     return $strReturn;
 }
Пример #2
0
 /**
  * Removes the elements / modules handled by the current installer.
  * Use the reference param to add a human readable logging.
  *
  * @param string &$strReturn
  *
  * @return bool
  */
 public function remove(&$strReturn)
 {
     //delete the page-element
     $objElement = class_module_pages_element::getElement("news");
     if ($objElement != null) {
         $strReturn .= "Deleting page-element 'news'...\n";
         $objElement->deleteObjectFromDatabase();
     } else {
         $strReturn .= "Error finding page-element 'news', aborting.\n";
         return false;
     }
     /** @var class_module_news_feed $objOneObject */
     foreach (class_module_news_feed::getObjectList() as $objOneObject) {
         $strReturn .= "Deleting object '" . $objOneObject->getStrDisplayName() . "' ...\n";
         if (!$objOneObject->deleteObjectFromDatabase()) {
             $strReturn .= "Error deleting object, aborting.\n";
             return false;
         }
     }
     /** @var class_module_news_category $objOneObject */
     foreach (class_module_news_category::getObjectList() as $objOneObject) {
         $strReturn .= "Deleting object '" . $objOneObject->getStrDisplayName() . "' ...\n";
         if (!$objOneObject->deleteObjectFromDatabase()) {
             $strReturn .= "Error deleting object, aborting.\n";
             return false;
         }
     }
     /** @var class_module_news_news $objOneObject */
     foreach (class_module_news_news::getObjectList() as $objOneObject) {
         $strReturn .= "Deleting object '" . $objOneObject->getStrDisplayName() . "' ...\n";
         if (!$objOneObject->deleteObjectFromDatabase()) {
             $strReturn .= "Error deleting object, aborting.\n";
             return false;
         }
     }
     //delete the module-node
     $strReturn .= "Deleting the module-registration...\n";
     $objModule = class_module_system_module::getModuleByName($this->objMetadata->getStrTitle(), true);
     if (!$objModule->deleteObjectFromDatabase()) {
         $strReturn .= "Error deleting module, aborting.\n";
         return false;
     }
     //delete the tables
     foreach (array("news_category", "news", "news_member", "news_feed", "element_news") as $strOneTable) {
         $strReturn .= "Dropping table " . $strOneTable . "...\n";
         if (!$this->objDB->_pQuery("DROP TABLE " . $this->objDB->encloseTableName(_dbprefix_ . $strOneTable) . "", array())) {
             $strReturn .= "Error deleting table, aborting.\n";
             return false;
         }
     }
     return true;
 }
Пример #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");
 }
Пример #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;
 }