コード例 #1
0
 public function test()
 {
     $objDB = class_carrier::getInstance()->getObjDB();
     echo "\tmodul_guestbook...\n";
     echo "creating a new guestbook, moderated...\n";
     $objGuestbook = new class_module_guestbook_guestbook();
     $objGuestbook->setStrGuestbookTitle("test guestbook");
     $objGuestbook->setIntGuestbookModerated(1);
     $objGuestbook->updateObjectToDb();
     $strGBId = $objGuestbook->getSystemid();
     echo "adding a new post...\n";
     $objPost = new class_module_guestbook_post();
     $objPost->setStrGuestbookPostName("subject");
     $objPost->setStrGuestbookPostText("test");
     $objPost->updateObjectToDb($strGBId);
     $objDB->flushQueryCache();
     $this->assertEquals(0, count(class_module_guestbook_post::getPosts($strGBId, true)), __FILE__ . " check nr of posts portal");
     $this->assertEquals(1, count(class_module_guestbook_post::getPosts($strGBId)), __FILE__ . " check nr of posts total");
     echo "setting guestbook non-moderated...\n";
     $objGuestbook->setIntGuestbookModerated(0);
     $objGuestbook->updateObjectToDb();
     $objDB->flushQueryCache();
     echo "adding a new post...\n";
     $objPost = new class_module_guestbook_post();
     $objPost->setStrGuestbookPostName("subject2");
     $objPost->setStrGuestbookPostText("test2");
     $objPost->updateObjectToDb($strGBId);
     $this->assertEquals(1, count(class_module_guestbook_post::getPosts($strGBId, true)), __FILE__ . " check nr of posts portal");
     $this->assertEquals(2, count(class_module_guestbook_post::getPosts($strGBId)), __FILE__ . " check nr of posts total");
     $objDB->flushQueryCache();
     echo "deleting the guestbook...\n";
     $objGuestbook->deleteObjectFromDatabase();
 }
コード例 #2
0
 /**
  * Returns a list of all posts in the current gb
  *
  * @return string
  * @permissions view
  */
 protected function actionList()
 {
     $strReturn = "";
     $arrTemplate = array();
     $arrTemplate["liste_posts"] = "";
     //Load all posts
     $objArraySectionIterator = new class_array_section_iterator(class_module_guestbook_post::getPostsCount($this->arrElementData["guestbook_id"], true));
     $objArraySectionIterator->setIntElementsPerPage($this->arrElementData["guestbook_amount"]);
     $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1));
     $objArraySectionIterator->setArraySection(class_module_guestbook_post::getPosts($this->arrElementData["guestbook_id"], true, $objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos()));
     $arrObjPosts = $this->objToolkit->simplePager($objArraySectionIterator, $this->getLang("commons_next"), $this->getLang("commons_back"), "", $this->getPagename());
     //and put posts into a template
     /** @var class_module_guestbook_post $objOnePost */
     foreach ($objArraySectionIterator as $objOnePost) {
         if ($objOnePost->rightView()) {
             $strTemplatePostID = $this->objTemplate->readTemplate("/module_guestbook/" . $this->arrElementData["guestbook_template"], "post");
             $arrTemplatePost = array();
             $arrTemplatePost["post_name"] = "<a href=\"mailto:" . $objOnePost->getStrGuestbookPostEmail() . "\">" . $objOnePost->getStrGuestbookPostName() . "</a>";
             $arrTemplatePost["post_name_plain"] = $objOnePost->getStrGuestbookPostName();
             $arrTemplatePost["post_email"] = $objOnePost->getStrGuestbookPostEmail();
             $arrTemplatePost["post_page"] = "<a href=\"http://" . $objOnePost->getStrGuestbookPostPage() . "\">" . $objOnePost->getStrGuestbookPostPage() . "</a>";
             //replace encoded newlines
             $arrTemplatePost["post_text"] = uniStrReplace("&lt;br /&gt;", "<br />", $objOnePost->getStrGuestbookPostText());
             $arrTemplatePost["post_date"] = timeToString($objOnePost->getIntGuestbookPostDate());
             $arrTemplate["liste_posts"] .= $this->objTemplate->fillTemplate($arrTemplatePost, $strTemplatePostID, false);
         }
     }
     //link to the post-form & pageview links
     $arrTemplate["link_newentry"] = getLinkPortal($this->getParam("page") ? $this->getParam("page") : "", "", "", $this->getLang("eintragen"), "insertGuestbook");
     $arrTemplate["link_forward"] = $arrObjPosts["strForward"];
     $arrTemplate["link_pages"] = $arrObjPosts["strPages"];
     $arrTemplate["link_back"] = $arrObjPosts["strBack"];
     $strTemplateID = $this->objTemplate->readTemplate("/module_guestbook/" . $this->arrElementData["guestbook_template"], "list");
     $strReturn .= $this->fillTemplate($arrTemplate, $strTemplateID);
     return $strReturn . "";
 }
コード例 #3
0
 /**
  * Return an on-lick link for the passed object.
  * This link is rendered by the portal search result generator, so
  * make sure the link is a valid portal page.
  * If you want to suppress the entry from the result, return an empty string instead.
  * If you want to add additional entries to the result set, clone the result and modify
  * the new instance to your needs. Pack them in an array and they'll be merged
  * into the result set afterwards.
  * Make sure to return the passed result-object in this array, too.
  *
  * @param class_search_result $objResult
  *
  * @see getLinkPortalHref()
  * @return mixed
  */
 public function updateSearchResult(class_search_result $objResult)
 {
     $objORM = new class_orm_objectlist();
     $strQuery = "SELECT page_name, guestbook_amount, page_id\n                       FROM " . _dbprefix_ . "element_guestbook,\n                            " . _dbprefix_ . "page_element,\n                            " . _dbprefix_ . "page,\n                            " . _dbprefix_ . "system\n                      WHERE guestbook_id = ?\n                        AND content_id = page_element_id\n                        AND content_id = system_id\n                        AND system_prev_id = page_id\n                        AND system_status = 1\n                        " . $objORM->getDeletedWhereRestriction() . "\n                        AND page_element_ph_language = ? ";
     $arrRows = $this->objDB->getPArray($strQuery, array($this->getPrevId(), $objResult->getObjSearch()->getStrPortalLangFilter()));
     $arrReturn = array();
     foreach ($arrRows as $arrOnePage) {
         //check, if the post is available on a page using the current language
         if (!isset($arrOnePage["page_name"]) || $arrOnePage["page_name"] == "") {
             continue;
         }
         //search pv position
         $intAmount = $arrOnePage["guestbook_amount"];
         $arrPostsInGB = class_module_guestbook_post::getPosts($this->getPrevId(), true);
         $intCounter = 0;
         foreach ($arrPostsInGB as $objOnePostInGb) {
             $intCounter++;
             if ($objOnePostInGb->getSystemid() == $this->getSystemid()) {
                 break;
             }
         }
         //calculate pv
         $intPvPos = ceil($intCounter / $intAmount);
         $objNewResult = clone $objResult;
         $objNewResult->setStrPagelink(class_link::getLinkPortal($arrOnePage["page_name"], "", "_self", $arrOnePage["page_name"], "", "&highlight=" . urlencode(html_entity_decode($objResult->getObjSearch()->getStrQuery(), ENT_QUOTES, "UTF-8")) . "&pv=" . $intPvPos));
         $objNewResult->setStrPagename($arrOnePage["page_name"]);
         $objNewResult->setStrDescription($this->getStrGuestbookPostText());
         $arrReturn[] = $objNewResult;
     }
     return $arrReturn;
 }