Ejemplo n.º 1
0
 protected function filterItemsByKeyWord(array $a_items, $a_keyword)
 {
     $res = array();
     include_once "./Modules/Blog/classes/class.ilBlogPostingGUI.php";
     foreach ($a_items as $month => $items) {
         foreach ($items as $item) {
             if (in_array($a_keyword, ilBlogPostingGUI::getKeywords($this->obj_id, $item["id"]))) {
                 $res[] = $item;
             }
         }
     }
     return $res;
 }
Ejemplo n.º 2
0
 public function getNotificationAbstract()
 {
     include_once "Modules/Blog/classes/class.ilBlogPostingGUI.php";
     $snippet = ilBlogPostingGUI::getSnippet($this->getId(), true);
     // making things more readable
     $snippet = str_replace('<br/>', "\n", $snippet);
     $snippet = str_replace('<br />', "\n", $snippet);
     $snippet = str_replace('</p>', "\n", $snippet);
     $snippet = str_replace('</div>', "\n", $snippet);
     return trim(strip_tags($snippet));
 }
 protected function renderBlog($a_user_id, $a_blog_id, array $a_posting_ids = null)
 {
     global $ilCtrl;
     // :TODO: what about user?
     // full blog (separate tab/page)
     if (!$a_posting_ids) {
         include_once "Modules/Blog/classes/class.ilObjBlogGUI.php";
         $blog = new ilObjBlogGUI($a_blog_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
         $blog->disableNotes(!$this->enable_comments);
         $blog->setContentStyleSheet();
         if ($this->getOutputMode() != "offline") {
             return $ilCtrl->getHTML($blog);
         } else {
         }
     } else {
         $html = array();
         include_once "Modules/Blog/classes/class.ilObjBlog.php";
         $html[] = ilObjBlog::_lookupTitle($a_blog_id);
         include_once "Modules/Blog/classes/class.ilBlogPostingGUI.php";
         foreach ($a_posting_ids as $post) {
             $page = new ilBlogPostingGUI(0, null, $post);
             if ($this->getOutputMode() != "offline") {
                 $page->setOutputMode(IL_PAGE_PREVIEW);
             } else {
                 $page->setOutputMode("offline");
             }
             $html[] = $page->showPage();
         }
         return implode("\n", $html);
     }
 }
Ejemplo n.º 4
0
 /**
  * Deliver blog as rss feed
  * 
  * @param int $a_wsp_id
  */
 static function deliverRSS($a_wsp_id)
 {
     global $tpl, $ilSetting;
     if (!$ilSetting->get('enable_global_profiles')) {
         return;
     }
     // #10827
     if (substr($a_wsp_id, -4) != "_cll") {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         $wsp_id = new ilWorkspaceTree(0);
         $obj_id = $wsp_id->lookupObjectId($a_wsp_id);
         $is_wsp = "_wsp";
     } else {
         $a_wsp_id = substr($a_wsp_id, 0, -4);
         $obj_id = ilObject::_lookupObjId($a_wsp_id);
         $is_wsp = null;
     }
     if (!$obj_id) {
         return;
     }
     $blog = new self($obj_id, false);
     if (!$blog->hasRSS()) {
         return;
     }
     include_once "Services/Feeds/classes/class.ilFeedWriter.php";
     $feed = new ilFeedWriter();
     include_once "Services/Link/classes/class.ilLink.php";
     $url = ilLink::_getStaticLink($a_wsp_id, "blog", true, $is_wsp);
     $url = str_replace("&", "&amp;", $url);
     $feed->setChannelTitle($blog->getTitle());
     $feed->setChannelDescription($blog->getDescription());
     $feed->setChannelLink($url);
     // needed for blogpostinggui / pagegui
     $tpl = new ilTemplate("tpl.main.html", true, true);
     include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
     include_once "./Modules/Blog/classes/class.ilBlogPostingGUI.php";
     foreach (ilBlogPosting::getAllPostings($obj_id) as $item) {
         $id = $item["id"];
         // only published items
         $is_active = ilBlogPosting::_lookupActive($id, "blp");
         if (!$is_active) {
             continue;
         }
         $snippet = strip_tags(ilBlogPostingGUI::getSnippet($id));
         $snippet = str_replace("&", "&amp;", $snippet);
         $url = ilLink::_getStaticLink($a_wsp_id, "blog", true, "_" . $id . $is_wsp);
         $url = str_replace("&", "&amp;", $url);
         $feed_item = new ilFeedItem();
         $feed_item->setTitle($item["title"]);
         $feed_item->setDate($item["created"]->get(IL_CAL_DATETIME));
         $feed_item->setDescription($snippet);
         $feed_item->setLink($url);
         $feed_item->setAbout($url);
         $feed->addItem($feed_item);
     }
     $feed->showFeed();
     exit;
 }
Ejemplo n.º 5
0
 /**
  * Export all pages
  * 
  * @param string $a_target_directory
  * @param string $a_link_template (embedded)
  * @param array $a_tpl_callback (embedded)
  * @param object $a_co_page_html_export (embedded)
  * @param string $a_index_name (embedded)
  */
 function exportHTMLPages($a_target_directory, $a_link_template = null, $a_tpl_callback = null, $a_co_page_html_export = null, $a_index_name = "index.html")
 {
     if (!$a_link_template) {
         $a_link_template = "bl{TYPE}_{ID}.html";
     }
     if ($a_co_page_html_export) {
         $this->co_page_html_export = $a_co_page_html_export;
     }
     $nav = $this->renderNavigation($this->items, "", "", $a_link_template);
     // month list
     $has_index = false;
     foreach (array_keys($this->items) as $month) {
         $file = $this->buildExportLink($a_link_template, "list", $month);
         $list = $this->renderList($this->items[$month], "render", $a_link_template, false, $a_target_directory);
         if (!$a_tpl_callback) {
             $tpl = $this->buildExportTemplate();
         } else {
             $tpl = call_user_func($a_tpl_callback);
         }
         $file = $this->writeExportFile($a_target_directory, $file, $tpl, $list, $nav);
         if (!$has_index) {
             copy($file, $a_target_directory . "/" . $a_index_name);
             $has_index = true;
         }
     }
     // single postings
     include_once "./Services/COPage/classes/class.ilPageContentUsage.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $pages = ilBlogPosting::getAllPostings($this->object->getId(), 0);
     foreach ($pages as $page) {
         if (ilBlogPosting::_exists("blp", $page["id"])) {
             include_once "./Modules/Blog/classes/class.ilBlogPostingGUI.php";
             $blp_gui = new ilBlogPostingGUI(0, null, $page["id"]);
             $blp_gui->setOutputMode("offline");
             $blp_gui->setFullscreenLink("fullscreen.html");
             // #12930 - see page.xsl
             $blp_gui->add_date = true;
             $page_content = $blp_gui->showPage();
             $back = $this->buildExportLink($a_link_template, "list", substr($page["created"]->get(IL_CAL_DATE), 0, 7));
             $file = $this->buildExportLink($a_link_template, "posting", $page["id"]);
             if (!$a_tpl_callback) {
                 $tpl = $this->buildExportTemplate();
             } else {
                 $tpl = call_user_func($a_tpl_callback);
             }
             $this->writeExportFile($a_target_directory, $file, $tpl, $page_content, $nav, $back);
             $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
         }
     }
     $this->co_page_html_export->exportPageElements();
 }