ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilPCBlogGUI Class Reference

Class ilPCBlogGUI Handles user commands on blog data. More...

+ Inheritance diagram for ilPCBlogGUI:
+ Collaboration diagram for ilPCBlogGUI:

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 executeCommand ()
 execute command More...
 
 insert (?ilPropertyFormGUI $a_form=null)
 
 edit (?ilPropertyFormGUI $a_form=null)
 
 create ()
 Create new blog. More...
 
 update ()
 Update blog. More...
 
 insertPosting (int $a_blog_id, ?ilPropertyFormGUI $a_form=null)
 Insert new blog posting form. More...
 
 editPosting (int $a_blog_id, ?ilPropertyFormGUI $a_form=null)
 Edit blog posting form. More...
 
- Public Member Functions inherited from ilPageContentGUI
 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id="", string $a_pc_id="0")
 
 setContentObject (ilPageContent $a_val)
 
 getContentObject ()
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 setPageConfig (ilPageConfig $a_val)
 
 getPageConfig ()
 
 setStyleId (int $a_styleid)
 
 getStyleId ()
 
 getStyle ()
 
 getCharacteristicsOfCurrentStyle (array $a_type)
 Get characteristics of current style and call setCharacteristics, if style is given. More...
 
 setCharacteristics (array $a_chars)
 
 getCharacteristics ()
 
 getHierId ()
 
 setHierId (string $a_hier_id)
 set hierarchical id in dom object More...
 
 delete ()
 
 displayValidationError ()
 
 cancelCreate ()
 cancel creating page content More...
 
 cancelUpdate ()
 cancel update More...
 
 cancel ()
 Cancel. More...
 
 deactivate ()
 gui function set enabled if is not enabled and vice versa More...
 
 cut ()
 Cut single element. More...
 
 copy ()
 Copy single element. More...
 
 getTemplateOptions (string $a_type="")
 Get table templates. More...
 

Protected Member Functions

 initForm (bool $a_insert=false)
 
 initPostingForm (int $a_blog_id, bool $a_insert=false)
 Init blog posting form. More...
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent (string $hier_id="")
 
 getParentReturn (string $hier_id="")
 
 updateAndReturn ()
 
 setCurrentTextLang (string $lang_key)
 
 getCurrentTextLang ()
 
 setEditorToolContext ()
 
 initEditor ()
 
 getEditorScriptTag (string $form_pc_id="", string $form_cname="")
 

Protected Attributes

PostingManager $posting_manger
 
int $requested_blog
 
int $requested_blog_id
 
ilObjUser $user
 
- Protected Attributes inherited from ilPageContentGUI
ILIAS COPage Editor GUIService $editor_gui
 
ILIAS COPage InternalGUIService $gui
 
EditSessionRepository $edit_repo
 
string $pc_id = ""
 
array $chars
 
ilObjStyleSheet $style = null
 
LOMServices $lom_services
 
ilLogger $log
 
int $styleid = 0
 
EditGUIRequest $request
 
string $sub_command = ""
 
int $requested_ref_id = 0
 
ILIAS GlobalScreen ScreenContext ContextServices $tool_context
 
Style Content CharacteristicManager $char_manager
 

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 
- Data Fields inherited from ilPageContentGUI
ilPageContent $content_obj
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilPageObject $pg_obj
 
string $hier_id = ""
 
DOMDocument $dom
 
 $updated
 
string $target_script = ""
 
string $return_location = ""
 
ilPageConfig $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static string $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
 
- Static Protected Attributes inherited from ilPageContentGUI
static array $common_bb_buttons
 

Detailed Description

Class ilPCBlogGUI Handles user commands on blog data.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 27 of file class.ilPCBlogGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPCBlogGUI::__construct ( ilPageObject  $a_pg_obj,
?ilPageContent  $a_content_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

Definition at line 34 of file class.ilPCBlogGUI.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

39  {
40  global $DIC;
41 
42  $this->tpl = $DIC["tpl"];
43  $this->ctrl = $DIC->ctrl();
44  $this->user = $DIC->user();
45  $this->lng = $DIC->language();
46  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
47 
48  // ... not sure why different ids are used for this...
49  $this->requested_blog_id = $this->request->getInt("blog_id");
50  $this->requested_blog = $this->request->getInt("blog");
51  $this->posting_manger = $DIC->blog()->internal()->domain()->posting();
52  }
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilPCBlogGUI::create ( )

Create new blog.

Definition at line 140 of file class.ilPCBlogGUI.php.

References ILIAS\Repository\ctrl(), ilPageContentGUI\getPage(), initForm(), initPostingForm(), insert(), and insertPosting().

140  : void
141  {
142  if ($this->requested_blog_id == 0) {
143  $form = $this->initForm(true);
144  if ($form->checkInput()) {
145  $this->insertPosting($this->requested_blog);
146  return;
147  }
148 
149  $form->setValuesByPost();
150  $this->insert($form);
151  } else {
152  $form = $this->initPostingForm($this->requested_blog_id, true);
153  if ($form->checkInput()) {
154  $this->content_obj = new ilPCBlog($this->getPage());
155  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
156  $this->content_obj->setData($form->getInput("blog_id"), $form->getInput("posting"));
157  $this->updated = $this->pg_obj->update();
158  if ($this->updated === true) {
159  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
160  }
161  }
162 
163  $form->setValuesByPost();
164  $this->insertPosting($this->requested_blog_id, $form);
165  }
166  }
insert(?ilPropertyFormGUI $a_form=null)
Class ilPCBlog Blog content object (see ILIAS DTD)
initPostingForm(int $a_blog_id, bool $a_insert=false)
Init blog posting form.
insertPosting(int $a_blog_id, ?ilPropertyFormGUI $a_form=null)
Insert new blog posting form.
initForm(bool $a_insert=false)
+ Here is the call graph for this function:

◆ edit()

ilPCBlogGUI::edit ( ?ilPropertyFormGUI  $a_form = null)

Definition at line 86 of file class.ilPCBlogGUI.php.

References ilPageContentGUI\$tpl, ilPageContentGUI\displayValidationError(), initForm(), and ILIAS\UICore\GlobalTemplate\setContent().

Referenced by update().

86  : void
87  {
88  $tpl = $this->tpl;
89 
90  $this->displayValidationError();
91 
92  if (!$a_form) {
93  $a_form = $this->initForm();
94  }
95  $tpl->setContent($a_form->getHTML());
96  }
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
initForm(bool $a_insert=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editPosting()

ilPCBlogGUI::editPosting ( int  $a_blog_id,
?ilPropertyFormGUI  $a_form = null 
)

Edit blog posting form.

Definition at line 220 of file class.ilPCBlogGUI.php.

References ilPageContentGUI\$tpl, ilPageContentGUI\displayValidationError(), initPostingForm(), and ILIAS\UICore\GlobalTemplate\setContent().

Referenced by update().

223  : void {
224  $tpl = $this->tpl;
225 
226  $this->displayValidationError();
227 
228  if (!$a_form) {
229  $a_form = $this->initPostingForm($a_blog_id);
230  }
231  $tpl->setContent($a_form->getHTML());
232  }
setContent(string $a_html)
Sets content for standard template.
initPostingForm(int $a_blog_id, bool $a_insert=false)
Init blog posting form.
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPCBlogGUI::executeCommand ( )

execute command

Definition at line 57 of file class.ilPCBlogGUI.php.

References ILIAS\Repository\ctrl().

57  : string
58  {
59  // get next class that processes or forwards current command
60  $next_class = $this->ctrl->getNextClass($this);
61 
62  // get current command
63  $cmd = $this->ctrl->getCmd();
64 
65  switch ($next_class) {
66  default:
67  $ret = $this->$cmd();
68  break;
69  }
70 
71  return (string) $ret;
72  }
+ Here is the call graph for this function:

◆ initForm()

ilPCBlogGUI::initForm ( bool  $a_insert = false)
protected

Definition at line 98 of file class.ilPCBlogGUI.php.

References ilPageContentGUI\$ctrl, $user, ilObject\_lookupTitle(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by create(), edit(), insert(), and update().

99  {
100  $ilCtrl = $this->ctrl;
101  $ilUser = $this->user;
102 
103  $form = new ilPropertyFormGUI();
104  $form->setFormAction($ilCtrl->getFormAction($this));
105  if ($a_insert) {
106  $form->setTitle($this->lng->txt("cont_insert_blog"));
107  } else {
108  $form->setTitle($this->lng->txt("cont_update_blog"));
109  }
110 
111  $options = array();
112  $blogs_ids = $this->posting_manger->searchBlogsByAuthor($ilUser->getId());
113 
114  if ($blogs_ids) {
115  foreach ($blogs_ids as $blog_id) {
116  $options[$blog_id] = ilObject::_lookupTitle($blog_id);
117  }
118  asort($options);
119  }
120  $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_blog"), "blog");
121  $obj->setRequired(true);
122  $obj->setOptions($options);
123  $form->addItem($obj);
124 
125  if ($a_insert) {
126  $form->addCommandButton("create", $this->lng->txt("select"));
127  $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
128  } else {
129  $obj->setValue($this->content_obj->getBlogId());
130  $form->addCommandButton("update", $this->lng->txt("select"));
131  $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
132  }
133 
134  return $form;
135  }
This class represents a selection list property in a property form.
static _lookupTitle(int $obj_id)
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPostingForm()

ilPCBlogGUI::initPostingForm ( int  $a_blog_id,
bool  $a_insert = false 
)
protected

Init blog posting form.

Definition at line 237 of file class.ilPCBlogGUI.php.

References ilPageContentGUI\$ctrl, $post, $user, ilDatePresentation\formatDate(), ilBlogPosting\getAllPostings(), IL_CAL_DATETIME, ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by create(), editPosting(), insertPosting(), and update().

241  $ilCtrl = $this->ctrl;
242  $ilUser = $this->user;
243 
244  $form = new ilPropertyFormGUI();
245  $form->setFormAction($ilCtrl->getFormAction($this));
246  if ($a_insert) {
247  $form->setTitle($this->lng->txt("cont_insert_blog"));
248  } else {
249  $form->setTitle($this->lng->txt("cont_update_blog"));
250  }
251 
252  $options = array();
253  $postings = ilBlogPosting::getAllPostings($a_blog_id);
254  if ($postings) {
255  foreach ($postings as $post) {
256  // could be posting from someone else
257  if ($post["author"] == $ilUser->getId()) {
258  $date = new ilDateTime($post["date"], IL_CAL_DATETIME);
259  $title = $post["title"] . " - " .
261 
262  $cbox = new ilCheckboxInputGUI($title, "posting");
263  $cbox->setValue($post["id"]);
264 
265  $options[] = $cbox;
266  }
267  }
268  }
269  asort($options);
270  $obj = new ilCheckboxGroupInputGUI($this->lng->txt("cont_pc_blog_posting"), "posting");
271  $obj->setRequired(true);
272  $obj->setOptions($options);
273  $form->addItem($obj);
274 
275  $blog_id = new ilHiddenInputGUI("blog_id");
276  $blog_id->setValue($a_blog_id);
277  $form->addItem($blog_id);
278 
279  if ($a_insert) {
280  $form->addCommandButton("create", $this->lng->txt("save"));
281  $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
282  } else {
283  $obj->setValue($this->content_obj->getPostings());
284  $form->addCommandButton("update", $this->lng->txt("save"));
285  $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
286  }
287 
288  return $form;
289  }
const IL_CAL_DATETIME
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
This class represents a hidden form property in a property form.
This class represents a property in a property form.
setRequired(bool $a_required)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilPCBlogGUI::insert ( ?ilPropertyFormGUI  $a_form = null)

Definition at line 74 of file class.ilPCBlogGUI.php.

References ilPageContentGUI\$tpl, ilPageContentGUI\displayValidationError(), initForm(), and ILIAS\UICore\GlobalTemplate\setContent().

Referenced by create().

74  : void
75  {
76  $tpl = $this->tpl;
77 
78  $this->displayValidationError();
79 
80  if (!$a_form) {
81  $a_form = $this->initForm(true);
82  }
83  $tpl->setContent($a_form->getHTML());
84  }
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
initForm(bool $a_insert=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertPosting()

ilPCBlogGUI::insertPosting ( int  $a_blog_id,
?ilPropertyFormGUI  $a_form = null 
)

Insert new blog posting form.

Definition at line 203 of file class.ilPCBlogGUI.php.

References ilPageContentGUI\$tpl, ilPageContentGUI\displayValidationError(), initPostingForm(), and ILIAS\UICore\GlobalTemplate\setContent().

Referenced by create().

206  : void {
207  $tpl = $this->tpl;
208 
209  $this->displayValidationError();
210 
211  if (!$a_form) {
212  $a_form = $this->initPostingForm($a_blog_id, true);
213  }
214  $tpl->setContent($a_form->getHTML());
215  }
setContent(string $a_html)
Sets content for standard template.
initPostingForm(int $a_blog_id, bool $a_insert=false)
Init blog posting form.
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilPCBlogGUI::update ( )

Update blog.

Definition at line 171 of file class.ilPCBlogGUI.php.

References ILIAS\Repository\ctrl(), edit(), editPosting(), initForm(), and initPostingForm().

171  : void
172  {
173  if ($this->requested_blog_id == 0) {
174  $form = $this->initForm();
175  if ($form->checkInput()) {
176  $this->editPosting($this->requested_blog);
177  return;
178  }
179 
180  $this->pg_obj->addHierIDs();
181  $form->setValuesByPost();
182  $this->edit($form);
183  } else {
184  $form = $this->initPostingForm($this->requested_blog_id);
185  if ($form->checkInput()) {
186  $this->content_obj->setData($form->getInput("blog_id"), $form->getInput("posting"));
187  $this->updated = $this->pg_obj->update();
188  if ($this->updated === true) {
189  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
190  }
191  }
192 
193  $this->pg_obj->addHierIDs();
194  $form->setValuesByPost();
195  $this->editPosting($this->requested_blog_id, $form);
196  }
197  }
edit(?ilPropertyFormGUI $a_form=null)
initPostingForm(int $a_blog_id, bool $a_insert=false)
Init blog posting form.
editPosting(int $a_blog_id, ?ilPropertyFormGUI $a_form=null)
Edit blog posting form.
initForm(bool $a_insert=false)
+ Here is the call graph for this function:

Field Documentation

◆ $posting_manger

PostingManager ilPCBlogGUI::$posting_manger
protected

Definition at line 29 of file class.ilPCBlogGUI.php.

◆ $requested_blog

int ilPCBlogGUI::$requested_blog
protected

Definition at line 30 of file class.ilPCBlogGUI.php.

◆ $requested_blog_id

int ilPCBlogGUI::$requested_blog_id
protected

Definition at line 31 of file class.ilPCBlogGUI.php.

◆ $user

ilObjUser ilPCBlogGUI::$user
protected

Definition at line 32 of file class.ilPCBlogGUI.php.

Referenced by initForm(), and initPostingForm().


The documentation for this class was generated from the following file: