Пример #1
0
 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
 {
     $res = array();
     // postings
     include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
     $pg_ids = array();
     foreach ($a_ids as $id) {
         $pages = ilBlogPosting::getAllPostings($id);
         foreach (array_keys($pages) as $p) {
             $pg_ids[] = "blp:" . $p;
         }
     }
     if (sizeof($pg_ids)) {
         $res[] = array("component" => "Services/COPage", "entity" => "pg", "ids" => $pg_ids);
     }
     // style
     $style_ids = array();
     foreach ($a_ids as $id) {
         include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $style_id = ilObjStyleSheet::lookupObjectStyle($id);
         if ($style_id > 0) {
             $style_ids[] = $style_id;
         }
     }
     if (sizeof($style_ids)) {
         $res[] = array("component" => "Services/Style", "entity" => "sty", "ids" => $style_ids);
     }
     return $res;
 }
 /**
  * Final processing
  *
  * @param	array		mapping array
  */
 function finalProcessing($a_mapping)
 {
     $blp_map = $a_mapping->getMappingsOfEntity("Services/COPage", "pg");
     foreach ($blp_map as $blp_id) {
         $blp_id = substr($blp_id, 4);
         $blog_id = ilBlogPosting::lookupBlogId($blp_id);
         ilPageObject::_writeParentId("blp", $blp_id, $blog_id);
     }
 }
 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
 {
     include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
     $pg_ids = array();
     foreach ($a_ids as $id) {
         $pages = ilBlogPosting::getAllPostings($id);
         foreach (array_keys($pages) as $p) {
             $pg_ids[] = "blp:" . $p;
         }
     }
     return array(array("component" => "Services/COPage", "entity" => "pg", "ids" => $pg_ids));
 }
Пример #4
0
 /**
  * Final processing
  *
  * @param	array		mapping array
  */
 function finalProcessing($a_mapping)
 {
     $blp_map = $a_mapping->getMappingsOfEntity("Services/COPage", "pg");
     foreach ($blp_map as $blp_id) {
         $blp_id = substr($blp_id, 4);
         $blog_id = ilBlogPosting::lookupBlogId($blp_id);
         ilBlogPosting::_writeParentId("blp", $blp_id, $blog_id);
     }
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $sty_map = $a_mapping->getMappingsOfEntity("Services/Style", "sty");
     foreach ($sty_map as $old_sty_id => $new_sty_id) {
         if (is_array(ilBlogDataSet::$style_map[$old_sty_id])) {
             foreach (ilBlogDataSet::$style_map[$old_sty_id] as $blog_id) {
                 ilObjStyleSheet::writeStyleUsage($blog_id, $new_sty_id);
             }
         }
     }
 }
Пример #5
0
 public function deactivateAdmin()
 {
     if ($this->checkPermissionBool("write") && (int) $_GET["apid"]) {
         // ilBlogPostingGUI::deactivatePage()
         include_once "Modules/Blog/classes/class.ilBlogPosting.php";
         $post = new ilBlogPosting((int) $_GET["apid"]);
         $post->setApproved(false);
         $post->setActive(false);
         $post->update(true, false, false);
         ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
     }
     $this->ctrl->redirect($this, "render");
 }
Пример #6
0
 /**
  * Delete all postings for blog
  *
  * @param int $a_blog_id
  */
 static function deleteAllBlogPostings($a_blog_id)
 {
     global $ilDB;
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $query = "SELECT * FROM il_blog_posting" . " WHERE blog_id = " . $ilDB->quote($a_blog_id, "integer");
     $set = $ilDB->query($query);
     while ($rec = $ilDB->fetchAssoc($set)) {
         // delete all md keywords
         $md_obj = new ilMD($a_blog_id, $rec["id"], "blp");
         if (is_object($md_section = $md_obj->getGeneral())) {
             foreach ($md_section->getKeywordIds() as $id) {
                 $md_key = $md_section->getKeyword($id);
                 $md_key->delete();
             }
         }
         $post = new ilBlogPosting($rec["id"]);
         $post->delete();
     }
 }
Пример #7
0
 /**
  * Init blog posting form
  *
  * @param int $a_blog_id
  * @param bool $a_insert
  * @return ilPropertyFormGUI
  */
 protected function initPostingForm($a_blog_id, $a_insert = false)
 {
     global $ilCtrl, $ilUser;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this));
     if ($a_insert) {
         $form->setTitle($this->lng->txt("cont_insert_blog"));
     } else {
         $form->setTitle($this->lng->txt("cont_update_blog"));
     }
     $options = array();
     include_once "Modules/Blog/classes/class.ilBlogPosting.php";
     $postings = ilBlogPosting::getAllPostings($a_blog_id);
     if ($postings) {
         foreach ($postings as $post) {
             // could be posting from someone else
             if ($post["author"] == $ilUser->getId()) {
                 $date = new ilDateTime($post["date"], IL_CAL_DATETIME);
                 $title = $post["title"] . " - " . ilDatePresentation::formatDate($date);
                 $cbox = new ilCheckboxInputGUI($title, "posting");
                 $cbox->setValue($post["id"]);
                 $options[] = $cbox;
             }
         }
     }
     asort($options);
     $obj = new ilCheckboxGroupInputGUI($this->lng->txt("cont_pc_blog_posting"), "posting");
     $obj->setRequired(true);
     $obj->setOptions($options);
     $form->addItem($obj);
     $blog_id = new ilHiddenInputGUI("blog_id");
     $blog_id->setValue($a_blog_id);
     $form->addItem($blog_id);
     if ($a_insert) {
         $form->addCommandButton("create_blog", $this->lng->txt("save"));
         $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
     } else {
         $obj->setValue($this->content_obj->getPostings());
         $form->addCommandButton("update", $this->lng->txt("save"));
         $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
     }
     return $form;
 }
 /**
  * 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("&", "&", $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("&", "&", $snippet);
         $url = ilLink::_getStaticLink($a_wsp_id, "blog", true, "_" . $id . $is_wsp);
         $url = str_replace("&", "&", $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;
 }
 protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
 {
     global $lng;
     $postings = "";
     if ($a_posting_ids) {
         $postings = array("<ul>");
         include_once "Modules/Blog/classes/class.ilBlogPosting.php";
         foreach ($a_posting_ids as $post) {
             $post = new ilBlogPosting($post);
             $postings[] = "<li>" . $post->getTitle() . " - " . ilDatePresentation::formatDate($post->getCreated()) . "</li>";
         }
         $postings[] = "</ul>";
         $postings = implode("\n", $postings);
     }
     return "<div style=\"margin:5px\">" . $lng->txt("obj_blog") . ": \"" . ilObject::_lookupTitle($a_blog_id) . "\"" . $postings . "</div>";
 }
Пример #10
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "blog":
             include_once "./Modules/Blog/classes/class.ilObjBlog.php";
             // container copy
             if ($new_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"])) {
                 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
             } else {
                 $newObj = new ilObjBlog();
                 $newObj->create();
             }
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setNotesStatus($a_rec["Notes"]);
             $newObj->setBackgroundColor($a_rec["BgColor"]);
             $newObj->setFontColor($a_rec["FontColor"]);
             $newObj->setProfilePicture($a_rec["Ppic"]);
             $newObj->setRSS($a_rec["RssActive"]);
             $newObj->setApproval($a_rec["Approval"]);
             $newObj->setImage($a_rec["Img"]);
             $newObj->setAbstractShorten($a_rec["AbsShorten"]);
             $newObj->setAbstractShortenLength($a_rec["AbsShortenLen"]);
             $newObj->setAbstractImage($a_rec["AbsImage"]);
             $newObj->setAbstractImageWidth($a_rec["AbsImgWidth"]);
             $newObj->setAbstractImageHeight($a_rec["AbsImgHeight"]);
             $newObj->setNavMode($a_rec["NavMode"]);
             $newObj->setNavModeListPostings($a_rec["NavListPost"]);
             $newObj->setNavModeListMonths($a_rec["NavListMon"]);
             $newObj->setKeywords($a_rec["Keywords"]);
             $newObj->setAuthors($a_rec["Authors"]);
             $newObj->setOrder(trim($a_rec["NavOrder"]) ? explode(";", $a_rec["NavOrder"]) : null);
             $newObj->setOverviewPostings($a_rec["OvPost"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Img"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjBlog::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             if ($a_rec["Style"]) {
                 self::$style_map[$a_rec["Style"]][] = $newObj->getId();
             }
             $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
             break;
         case "blog_posting":
             $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
             if ($blog_id) {
                 include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
                 $newObj = new ilBlogPosting();
                 $newObj->setBlogId($blog_id);
                 $newObj->setTitle($a_rec["Title"]);
                 $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME));
                 $newObj->setApproved($a_rec["Approved"]);
                 // parse export id into local id (if possible)
                 $author = $this->parseObjectExportId($a_rec["Author"], -1);
                 $newObj->setAuthor($author["id"]);
                 $newObj->create(true);
                 // keywords
                 $keywords = array();
                 for ($loop = 0; $loop < 1000; $loop++) {
                     if (isset($a_rec["Keyword" . $loop])) {
                         $keyword = trim($a_rec["Keyword" . $loop]);
                         if (strlen($keyword)) {
                             $keywords[] = $keyword;
                         }
                     }
                 }
                 if (sizeof($keywords)) {
                     $newObj->updateKeywords($keywords);
                 }
                 $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
             }
             break;
     }
 }
Пример #11
0
 protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
 {
     // not used
     // $user_id = $this->getPageContentUserId($a_user_id);
     $postings = "";
     if ($a_posting_ids) {
         $postings = array("<ul>");
         include_once "Modules/Blog/classes/class.ilBlogPosting.php";
         foreach ($a_posting_ids as $post) {
             $post = new ilBlogPosting($post);
             $postings[] = "<li>" . $post->getTitle() . " - " . ilDatePresentation::formatDate($post->getCreated()) . "</li>";
         }
         $postings[] = "</ul>";
         $postings = implode("\n", $postings);
     }
     return $this->renderTeaser("blog", $this->lng->txt("obj_blog") . ' "' . ilObject::_lookupTitle($a_blog_id) . '"', $postings);
 }
 protected function initKeywordsForm()
 {
     global $ilUser;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, "saveKeywordsForm"));
     $form->setTitle($this->lng->txt("blog_edit_keywords"));
     $txt = new ilTextInputGUI($this->lng->txt("blog_keywords"), "keywords");
     // $txt->setRequired(true); #10504
     $txt->setMulti(true);
     $txt->setDataSource($this->ctrl->getLinkTarget($this, "keywordAutocomplete", "", true));
     $txt->setMaxLength(200);
     $txt->setSize(50);
     $txt->setInfo($this->lng->txt("blog_keywords_info"));
     $form->addItem($txt);
     $md_section = $this->getBlogPosting()->getMDSection();
     $keywords = array();
     foreach ($ids = $md_section->getKeywordIds() as $id) {
         $md_key = $md_section->getKeyword($id);
         if (trim($md_key->getKeyword()) != "") {
             $keywords[$md_key->getKeywordLanguageCode()][] = $md_key->getKeyword();
         }
     }
     // language is not "used" anywhere
     $ulang = $ilUser->getLanguage();
     if ($keywords[$ulang]) {
         asort($keywords[$ulang]);
         $txt->setValue($keywords[$ulang]);
     }
     // other keywords in blog
     $other = array();
     foreach (array_keys(ilBlogPosting::getAllPostings($this->getBlogPosting()->getBlogId())) as $posting_id) {
         if ($posting_id != $this->getBlogPosting()->getId()) {
             $other = array_merge($other, ilBlogPosting::getKeywords($this->getBlogPosting()->getBlogId(), $posting_id));
         }
     }
     if (is_array($keywords[$ulang])) {
         $other = array_diff($other, $keywords[$ulang]);
     }
     if (sizeof($other)) {
         $html = "";
         foreach ($other as $item) {
             $html .= '<span class="ilTag">' . $item . '</span>';
         }
         $info = new ilNonEditableValueGUI($this->lng->txt("blog_keywords_other"), "", true);
         $info->setInfo($this->lng->txt("blog_keywords_other_info"));
         $info->setValue($html);
         $form->addItem($info);
     }
     $form->addCommandButton("saveKeywordsForm", $this->lng->txt("save"));
     $form->addCommandButton("preview", $this->lng->txt("cancel"));
     return $form;
 }
Пример #13
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "blog":
             include_once "./Modules/Blog/classes/class.ilObjBlog.php";
             $newObj = new ilObjBlog();
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->create();
             $newObj->setNotesStatus($a_rec["Notes"]);
             $newObj->setBackgroundColor($a_rec["BgColor"]);
             $newObj->setFontColor($a_rec["FontColor"]);
             $newObj->setProfilePicture($a_rec["Ppic"]);
             $newObj->setRSS($a_rec["RssActive"]);
             $newObj->setApproval($a_rec["Approval"]);
             $newObj->setImage($a_rec["Img"]);
             $newObj->update();
             // handle image(s)
             if ($a_rec["Img"]) {
                 $dir = str_replace("..", "", $a_rec["Dir"]);
                 if ($dir != "" && $this->getImportDirectory() != "") {
                     $source_dir = $this->getImportDirectory() . "/" . $dir;
                     $target_dir = ilObjBlog::initStorage($newObj->getId());
                     ilUtil::rCopy($source_dir, $target_dir);
                 }
             }
             $a_mapping->addMapping("Modules/Blog", "blog", $a_rec["Id"], $newObj->getId());
             break;
         case "blog_posting":
             $blog_id = (int) $a_mapping->getMapping("Modules/Blog", "blog", $a_rec["BlogId"]);
             if ($blog_id) {
                 include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
                 $newObj = new ilBlogPosting();
                 $newObj->setBlogId($blog_id);
                 $newObj->setTitle($a_rec["Title"]);
                 $newObj->setCreated(new ilDateTime($a_rec["Created"], IL_CAL_DATETIME));
                 $newObj->setApproved($a_rec["Approved"]);
                 // parse export id into local id (if possible)
                 $author = $this->parseObjectExportId($a_rec["Author"], -1);
                 $newObj->setAuthor($author["id"]);
                 $newObj->create(true);
                 $a_mapping->addMapping("Services/COPage", "pg", "blp:" . $a_rec["Id"], "blp:" . $newObj->getId());
             }
             break;
     }
 }