ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\Wiki\Page\PageManager Class Reference

Page manager. More...

+ Collaboration diagram for ILIAS\Wiki\Page\PageManager:

Public Member Functions

 __construct (InternalDataService $data_service, PageDBRepository $page_repo, \ILIAS\Wiki\Wiki\DomainService $wiki_domain, DomainService $page_domain, int $ref_id)
 
 getWikiId ()
 
 createWikiPage (string $title, int $wpg_id=0, string $lang="-", int $template_page=0)
 
 getWikiPages (string $lang="-")
 
 getInfoOfSelected (array $ids, string $lang="-")
 
 getMasterPagesWithoutTranslation (string $trans)
 
 getAllPagesInfo ()
 
 getRecentChanges ()
 
 getNewPages ()
 
 getPopularPages ()
 
 getLanguages (int $wpg_id)
 
 getOrphanedPages ()
 
 getPageIdForTitle (string $title, string $lang="-")
 
 getPermaLink (int $id, string $lang="-")
 
 getPermaLinkByTitle (string $title, string $lang="-")
 
 exists (int $id, string $lang="-")
 
 existsByTitle (string $title, string $lang="-")
 
 getTitle (int $id, string $lang="-")
 
 belongsToWiki (int $id)
 

Protected Attributes

DomainService $page_domain
 
ILIAS Wiki Wiki DomainService $wiki_domain
 
PageDBRepository $page_repo
 
int $wiki_ref_id
 
ilObjWiki $wiki
 
int $ref_id
 
InternalDataService $data_service
 

Detailed Description

Page manager.

Definition at line 29 of file PageManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Wiki\Page\PageManager::__construct ( InternalDataService  $data_service,
PageDBRepository  $page_repo,
\ILIAS\Wiki\Wiki\DomainService  $wiki_domain,
DomainService  $page_domain,
int  $ref_id 
)

Definition at line 39 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\$data_service, ILIAS\Wiki\Page\PageManager\$page_domain, ILIAS\Wiki\Page\PageManager\$page_repo, ILIAS\Wiki\Page\PageManager\$ref_id, and ILIAS\Wiki\Page\PageManager\$wiki_domain.

45  {
46  $this->wiki_ref_id = $ref_id;
47  $this->data_service = $data_service;
48  $this->page_repo = $page_repo;
49  $this->wiki_domain = $wiki_domain;
50  $this->page_domain = $page_domain;
51  $this->wiki = $this->wiki_domain->object($ref_id);
52  }
PageDBRepository $page_repo
Definition: PageManager.php:33
ILIAS Wiki Wiki DomainService $wiki_domain
Definition: PageManager.php:32
InternalDataService $data_service
Definition: PageManager.php:37

Member Function Documentation

◆ belongsToWiki()

ILIAS\Wiki\Page\PageManager::belongsToWiki ( int  $id)

Definition at line 295 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\getWikiId().

297  : bool {
298  return $this->page_repo->getWikiIdByPageId($id) === $this->getWikiId();
299  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ createWikiPage()

ILIAS\Wiki\Page\PageManager::createWikiPage ( string  $title,
int  $wpg_id = 0,
string  $lang = "-",
int  $template_page = 0 
)

Definition at line 59 of file PageManager.php.

References $lang, ilAdvancedMDValues\_cloneValues(), ILIAS\Wiki\Page\PageManager\getWikiId(), ILIAS\Repository\int(), ilWikiUtil\makeDbTitle(), and ilWikiPageTemplate\TYPE_NEW_PAGES.

64  : int {
65  if ($lang === "") {
66  $lang = "-";
67  }
68  // todo check if $wpg_id is given if lang is set
69  // todo check if $wpg_id is not given if lang is not set
70  // todo check if $wpg_id belongs to wiki, if given
71  // todo check if page (id/lang) does not exist already
72  // todo check if title is not empty
73 
74  // check if template has to be used
75  if ($template_page === 0) {
76  if (!$this->wiki->getEmptyPageTemplate()) {
77  $wt = new \ilWikiPageTemplate($this->getWikiId());
78  $ts = $wt->getAllInfo(\ilWikiPageTemplate::TYPE_NEW_PAGES, $lang);
79  if (count($ts) === 1) {
80  $t = current($ts);
81  $template_page = (int) $t["wpage_id"];
82  }
83  }
84  }
85 
86  // master language
87  if ($lang === "-") {
88  $page = new \ilWikiPage(0);
89  $page->setWikiId($this->getWikiId());
90  $page->setWikiRefId($this->wiki_ref_id);
91  $page->setTitle(\ilWikiUtil::makeDbTitle($title));
92  if ($this->wiki->getRatingPages() && $this->wiki->getRatingForNewPages()) {
93  $page->setRating(true);
94  }
95  // needed for notification
96  $page->create();
97  } else {
98  $orig_page = $this->page_domain->getWikiPage($this->wiki_ref_id, $wpg_id, 0, "-");
99  $orig_page->copyPageToTranslation($lang);
100 
101  $page = $this->page_domain->getWikiPage($this->wiki_ref_id, $wpg_id, 0, $lang);
102  $page->setTitle(\ilWikiUtil::makeDbTitle($title));
103  $page->update();
104  }
105 
106  // copy template into new page
107  if ($template_page > 0) {
108  $t_page = $this->page_domain->getWikiPage($this->wiki_ref_id, $template_page, 0, $lang);
109  $t_page->copy(
110  $page->getId(),
111  $page->getParentType(),
112  $page->getParentId(),
113  false,
114  0,
115  true
116  );
117 
118  // #15718
119  if ($lang === "-") {
121  0,
122  $this->getWikiId(),
123  $this->getWikiId(),
124  "wpg",
125  $template_page,
126  $page->getId()
127  );
128  }
129  }
130  return $page->getId();
131  }
$lang
Definition: xapiexit.php:25
static _cloneValues(int $copy_id, int $a_source_id, int $a_target_id, ?string $a_sub_type=null, ?int $a_source_sub_id=null, ?int $a_target_sub_id=null)
Clone Advanced Meta Data.
static makeDbTitle(string $a_par)
+ Here is the call graph for this function:

◆ exists()

ILIAS\Wiki\Page\PageManager::exists ( int  $id,
string  $lang = "-" 
)

Definition at line 278 of file PageManager.php.

References $lang.

278  : bool
279  {
280  return $this->page_repo->exists($id, $lang);
281  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ existsByTitle()

ILIAS\Wiki\Page\PageManager::existsByTitle ( string  $title,
string  $lang = "-" 
)

Definition at line 283 of file PageManager.php.

References $lang, and ILIAS\Wiki\Page\PageManager\getWikiId().

286  : bool {
287  return $this->page_repo->existsByTitle($this->getWikiId(), $title, $lang);
288  }
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ getAllPagesInfo()

ILIAS\Wiki\Page\PageManager::getAllPagesInfo ( )
Returns
iterable<PageInfo>

Definition at line 170 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\getWikiId().

Referenced by ILIAS\Wiki\Page\PageManager\getOrphanedPages().

170  : \Iterator
171  {
172  return $this->page_repo->getAllPagesInfo(
173  $this->getWikiId()
174  );
175  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInfoOfSelected()

ILIAS\Wiki\Page\PageManager::getInfoOfSelected ( array  $ids,
string  $lang = "-" 
)
Returns
iterable<PageInfo>

Definition at line 147 of file PageManager.php.

References $lang, and ILIAS\Wiki\Page\PageManager\getWikiId().

147  : \Iterator
148  {
149  return $this->page_repo->getInfoOfSelected(
150  $this->getWikiId(),
151  $ids,
152  $lang
153  );
154  }
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ getLanguages()

ILIAS\Wiki\Page\PageManager::getLanguages ( int  $wpg_id)
Returns
string[]

Definition at line 210 of file PageManager.php.

210  : array
211  {
212  return $this->page_repo->getLanguages($wpg_id);
213  }

◆ getMasterPagesWithoutTranslation()

ILIAS\Wiki\Page\PageManager::getMasterPagesWithoutTranslation ( string  $trans)
Returns
iterable<Page>

Definition at line 159 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\getWikiId().

159  : \Iterator
160  {
161  return $this->page_repo->getMasterPagesWithoutTranslation(
162  $this->getWikiId(),
163  $trans
164  );
165  }
+ Here is the call graph for this function:

◆ getNewPages()

ILIAS\Wiki\Page\PageManager::getNewPages ( )
Returns
iterable<PageInfo>

Definition at line 190 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\getWikiId().

190  : \Iterator
191  {
192  return $this->page_repo->getNewPages(
193  $this->getWikiId()
194  );
195  }
+ Here is the call graph for this function:

◆ getOrphanedPages()

ILIAS\Wiki\Page\PageManager::getOrphanedPages ( )
Returns
iterable<PageInfo>

Definition at line 218 of file PageManager.php.

References ilInternalLink\_getSourcesOfTarget(), ILIAS\Wiki\Page\PageManager\getAllPagesInfo(), and ILIAS\Wiki\Page\PageManager\getWikiId().

218  : \Iterator
219  {
220  $starting_page_id = $this->wiki_domain->getStartingPageId($this->wiki_ref_id);
221  foreach ($this->getAllPagesInfo() as $pi) {
222  // find wiki page sources that link to page
223  $sources = \ilInternalLink::_getSourcesOfTarget("wpg", $pi->getId(), 0);
224  $ids = [];
225  foreach ($sources as $source) {
226  if ($source["type"] === "wpg:pg") {
227  $ids[] = $source["id"];
228  }
229  }
230 
231  // cross check existence of sources in il_wiki_page
232  if (count($ids) === 0 || !$this->page_repo->doesAtLeastOnePageExist($this->getWikiId(), $ids)) {
233  continue;
234  }
235 
236  if ($pi->getId() !== $starting_page_id) {
237  yield $pi;
238  }
239  }
240  }
+ Here is the call graph for this function:

◆ getPageIdForTitle()

ILIAS\Wiki\Page\PageManager::getPageIdForTitle ( string  $title,
string  $lang = "-" 
)

Definition at line 242 of file PageManager.php.

References $lang, and ILIAS\Wiki\Page\PageManager\getWikiId().

Referenced by ILIAS\Wiki\Page\PageManager\getPermaLinkByTitle().

245  : ?int {
246  return $this->page_repo->getPageIdForTitle(
247  $this->getWikiId(),
248  $title,
249  $lang
250  );
251  }
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPermaLink()

ILIAS\Wiki\Page\PageManager::getPermaLink ( int  $id,
string  $lang = "-" 
)

Definition at line 253 of file PageManager.php.

References $lang, and null.

Referenced by ILIAS\Wiki\Page\PageManager\getPermaLinkByTitle().

253  : string
254  {
255  $lang = (!in_array($lang, ["", "-"]))
256  ? "_" . $lang
257  : "";
258  return \ilLink::_getStaticLink(
259  null,
260  "wiki",
261  true,
262  "wpage_" . $id . "_" . $this->wiki_ref_id . $lang
263  );
264  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getPermaLinkByTitle()

ILIAS\Wiki\Page\PageManager::getPermaLinkByTitle ( string  $title,
string  $lang = "-" 
)

Definition at line 266 of file PageManager.php.

References $id, $lang, ILIAS\Wiki\Page\PageManager\getPageIdForTitle(), and ILIAS\Wiki\Page\PageManager\getPermaLink().

266  : string
267  {
268  $id = $this->getPageIdForTitle($title, $lang);
269  if (!is_null($id)) {
270  return $this->getPermaLink($id, $lang);
271  }
272  return \ilLink::_getStaticLink(
273  $this->wiki_ref_id,
274  "wiki"
275  );
276  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getPageIdForTitle(string $title, string $lang="-")
getPermaLink(int $id, string $lang="-")
+ Here is the call graph for this function:

◆ getPopularPages()

ILIAS\Wiki\Page\PageManager::getPopularPages ( )
Returns
iterable<PageInfo>

Definition at line 200 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\getWikiId().

200  : \Iterator
201  {
202  return $this->page_repo->getPopularPages(
203  $this->getWikiId()
204  );
205  }
+ Here is the call graph for this function:

◆ getRecentChanges()

ILIAS\Wiki\Page\PageManager::getRecentChanges ( )
Returns
iterable<PageInfo>

Definition at line 180 of file PageManager.php.

References ILIAS\Wiki\Page\PageManager\getWikiId().

180  : \Iterator
181  {
182  return $this->page_repo->getRecentChanges(
183  $this->getWikiId()
184  );
185  }
+ Here is the call graph for this function:

◆ getTitle()

ILIAS\Wiki\Page\PageManager::getTitle ( int  $id,
string  $lang = "-" 
)

Definition at line 290 of file PageManager.php.

References $lang.

290  : string
291  {
292  return $this->page_repo->getTitle($id, $lang);
293  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getWikiId()

◆ getWikiPages()

ILIAS\Wiki\Page\PageManager::getWikiPages ( string  $lang = "-")
Returns
iterable<Page>

Definition at line 136 of file PageManager.php.

References $lang, and ILIAS\Wiki\Page\PageManager\getWikiId().

136  : \Iterator
137  {
138  return $this->page_repo->getWikiPages(
139  $this->getWikiId(),
140  $lang
141  );
142  }
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

Field Documentation

◆ $data_service

InternalDataService ILIAS\Wiki\Page\PageManager::$data_service
protected

Definition at line 37 of file PageManager.php.

Referenced by ILIAS\Wiki\Page\PageManager\__construct().

◆ $page_domain

DomainService ILIAS\Wiki\Page\PageManager::$page_domain
protected

Definition at line 31 of file PageManager.php.

Referenced by ILIAS\Wiki\Page\PageManager\__construct().

◆ $page_repo

PageDBRepository ILIAS\Wiki\Page\PageManager::$page_repo
protected

Definition at line 33 of file PageManager.php.

Referenced by ILIAS\Wiki\Page\PageManager\__construct().

◆ $ref_id

int ILIAS\Wiki\Page\PageManager::$ref_id
protected

Definition at line 36 of file PageManager.php.

Referenced by ILIAS\Wiki\Page\PageManager\__construct().

◆ $wiki

ilObjWiki ILIAS\Wiki\Page\PageManager::$wiki
protected

Definition at line 35 of file PageManager.php.

◆ $wiki_domain

ILIAS Wiki Wiki DomainService ILIAS\Wiki\Page\PageManager::$wiki_domain
protected

Definition at line 32 of file PageManager.php.

Referenced by ILIAS\Wiki\Page\PageManager\__construct().

◆ $wiki_ref_id

int ILIAS\Wiki\Page\PageManager::$wiki_ref_id
protected

Definition at line 34 of file PageManager.php.


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