4 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
5 include_once(
"./Modules/Portfolio/classes/class.ilObjPortfolio.php");
42 $this->portfolio_id = $a_val;
82 $this->title = $a_title;
95 if ($this->title ==
"###-") {
96 return $lng->txt(
"profile");
109 $this->order_nr = (int) $a_val;
132 $ilDB = $DIC->database();
134 $set =
$ilDB->query(
"SELECT MAX(order_nr) m FROM usr_portfolio_page" .
135 " WHERE portfolio_id = " .
$ilDB->quote($a_portfolio_id,
"integer"));
136 $rec =
$ilDB->fetchAssoc($set);
137 return (
int) $rec[
"m"];
147 $fields = array(
"portfolio_id" => array(
"integer", $this->portfolio_id),
148 "type" => array(
"integer", $this->
getType()),
149 "title" => array(
"text", $this->
getTitle()),
150 "order_nr" => array(
"integer", $this->
getOrderNr()));
158 public function create($a_import =
false)
163 $this->
setOrderNr(self::lookupMaxOrderNr($this->portfolio_id) + 10);
166 $id =
$ilDB->nextId(
"usr_portfolio_page");
170 $fields[
"id"] = array(
"integer",
$id);
172 $ilDB->insert(
"usr_portfolio_page", $fields);
185 public function update($a_validate =
true, $a_no_history =
false)
193 "usr_portfolio_page",
195 array(
"id" => array(
"integer",
$id))
211 $query =
"SELECT * FROM usr_portfolio_page" .
212 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
214 $rec =
$ilDB->fetchAssoc($set);
228 public function delete()
235 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
239 $query =
"DELETE FROM usr_portfolio_page" .
240 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
259 $ilDB = $DIC->database();
261 $set =
$ilDB->query(
"SELECT " . $a_prop .
262 " FROM usr_portfolio_page" .
263 " WHERE id = " .
$ilDB->quote($a_id,
"integer"));
264 $rec =
$ilDB->fetchAssoc($set);
265 return $rec[$a_prop];
275 return self::lookupProperty($a_page_id,
"title");
288 $ilDB = $DIC->database();
289 $lng = $DIC->language();
291 $set =
$ilDB->query(
"SELECT * FROM usr_portfolio_page" .
292 " WHERE portfolio_id = " .
$ilDB->quote($a_portfolio_id,
"integer") .
293 " ORDER BY order_nr");
295 while ($rec =
$ilDB->fetchAssoc($set)) {
297 if ($rec[
"title"] ==
"###-") {
298 $rec[
"title"] =
$lng->txt(
"profile");
315 $ilDB = $DIC->database();
317 $pages = self::getAllPortfolioPages($a_portfolio_id);
319 foreach ($pages as $p) {
321 "UPDATE usr_portfolio_page SET " .
322 " order_nr = " .
$ilDB->quote($cnt,
"integer") .
323 " WHERE id = " .
$ilDB->quote($p[
"id"],
"integer")
337 return self::lookupProperty($a_page_id,
"portfolio_id");
350 $pid = self::findPortfolioForPage((
int) $a_target);
352 if (
$type ==
"prtt") {
353 $ctrl = $DIC->ctrl();
354 $ctrl->setParameterByClass(
"ilobjportfoliotemplategui",
"user_page", $a_target);
355 $href = $ctrl->getLinkTargetByClass(array(
"ilRepositoryGUI",
"ilObjPortfolioTemplateGUI",
"ilobjportfoliotemplategui"),
"preview");
358 $href =
"./goto.php?client_id=" . CLIENT_ID .
"&target=prtf_" . $pid .
"_" . $a_target;
360 $href =
"prtf_" . $a_target .
".html";
372 $all_fixes = array();
373 foreach ($a_copied_nodes as $original_id => $copied_id) {
374 $pid = self::findPortfolioForPage((
int) $copied_id);
380 if ($a_target_obj->
getType() ==
"prtf") {
383 if ($a_target_obj->
getType() ==
"prtt") {
387 $il = $tpg->getInternalLinks();
390 foreach ($il as
$l) {
396 foreach ($targets as
$target) {
397 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
398 ($target[
"type"] ==
"ppage")) {
400 if ($a_copied_nodes[$target[
"id"]] > 0) {
401 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
407 if (count($fix) > 0) {
409 if (is_array($all_fixes[
$t .
":" . $copied_id])) {
410 $all_fixes[
$t .
":" . $copied_id] += $fix;
412 $all_fixes[
$t .
":" . $copied_id] = $fix;
417 foreach ($all_fixes as $pg => $fixes) {
418 $pg = explode(
":", $pg);
419 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
421 if ($page->moveIntLinks($fixes)) {
422 $page->update(
true,
true);
441 for (
$i = 0;
$i < count(
$res->nodeset);
$i++) {
445 if (isset($a_title_changes[$obj_id]) && is_int(strpos(
$target,
"__"))) {
446 if (
$type ==
"PortfolioPage") {
447 if (
$res->nodeset[
$i]->get_content() == $a_title_changes[$obj_id][
"old"]) {
448 $res->nodeset[
$i]->set_content($a_title_changes[$obj_id][
"new"]);
469 $ilDB = $DIC->database();
471 $set =
$ilDB->query(
"SELECT * FROM usr_portfolio_page" .
472 " WHERE title = " .
$ilDB->quote($a_blog_id,
"text") .
473 " AND type = " .
$ilDB->quote(self::TYPE_BLOG,
"integer"));
475 while ($rec =
$ilDB->fetchAssoc($set)) {
static lookupProperty($a_id, $a_prop)
Lookup portfolio page property.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
setTitle($a_title)
Set Title.
setPortfolioId($a_val)
Set portfolio id.
getPropertiesForDB()
Get properties for insert/update statements.
xpath_new_context($dom_document)
static _extractInstOfTarget($a_target)
Extract installation id out of target.
static getGotoForPortfolioPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.
static _extractTypeOfTarget($a_target)
Extract type out of target.
static _extractObjIdOfTarget($a_target)
Extract object id out of target.
static findPortfolioForPage($a_page_id)
Get portfolio id of page id.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
create($a_import=false)
Create new portfolio page.
static fixOrdering($a_portfolio_id)
Fix ordering.
getParentType()
Get parent type.
getOrderNr()
Get order nr.
static updateInternalLinks($a_copied_nodes, ilObjPortfolioBase $a_target_obj)
Update internal links, after multiple pages have been copied.
renameLinksOnTitleChange($a_title_changes)
static lookupTitle($a_page_id)
Lookup title.
foreach($_POST as $key=> $value) $res
update($a_validate=true, $a_no_history=false)
Update page.
Page for portfolio template.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getPagesForBlog($a_blog_id)
Get portfolio pages for blog.
update($pash, $contents, Config $config)
static lookupMaxOrderNr($a_portfolio_id)
Lookup max order nr for portfolio.
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
getPortfolioId()
Get portfolio id.
setOrderNr($a_val)
Set order nr.
static _deleteAllLinksToTarget($a_target_type, $a_target_id, $a_target_inst=0)
Delete all links to a given target.