ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilWikiAdvMetaDataBlockGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("Services/Block/classes/class.ilBlockGUI.php");
6
18{
19 static $block_type = "wikiadvmd";
20 static $st_data;
21
22 protected $export = false;
23 protected $obj_id; // [int]
24 protected $ref_id; // [int]
25 protected $page_id; // [int]
26 protected $record; // [ilAdvancedMDRecord]
27 protected $adv_md_hidden; // [bool]
28
29 static protected $records = array(); // [array]
30
34 function __construct(ilAdvancedMDRecord $a_record)
35 {
36 global $ilCtrl, $lng;
37
38 parent::ilBlockGUI();
39
40 $this->record = $a_record;
41
42 $this->setTitle($this->record->getTitle());
43 $this->setBlockId("advmdwiki_".$this->record->getRecordId());
44 $this->setEnableNumInfo(false);
45 // $this->setAvailableDetailLevels(3);
46 $this->allow_moving = false;
47
48 $lng->loadLanguageModule("wiki");
49 }
50
56 static function getBlockType()
57 {
58 return self::$block_type;
59 }
60
66 static function isRepositoryObject()
67 {
68 return false;
69 }
70
74 static function getScreenMode()
75 {
76 return IL_SCREEN_SIDE;
77 }
78
79 public function setObject($a_wiki_ref_id, $a_wiki_obj_id, $a_page_id)
80 {
81 $this->ref_id = $a_wiki_ref_id;
82 $this->obj_id = $a_wiki_obj_id;
83 $this->page_id = $a_page_id;
84 }
85
89 function &executeCommand()
90 {
91 global $ilCtrl;
92
93 $next_class = $ilCtrl->getNextClass();
94 $cmd = $ilCtrl->getCmd("getHTML");
95
96 switch ($next_class)
97 {
98 default:
99 return $this->$cmd();
100 }
101 }
102
106 function getHTML($a_export = false)
107 {
108 global $ilCtrl, $lng, $ilAccess;
109
110 $this->export = $a_export;
111
112 $has_write = $ilAccess->checkAccess("write", "", $this->ref_id);
113
114 if ($this->isHidden())
115 {
116 #16029 - hide completely
117 return;
118 }
119
120 if (!$this->export && $has_write)
121 {
122 $this->addBlockCommand(
123 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "editAdvancedMetaData"),
124 $lng->txt("edit"), "_top");
125
126 if (!$this->isHidden())
127 {
128 $this->addBlockCommand(
129 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "hideAdvancedMetaData"),
130 $lng->txt("hide"), "_top");
131 }
132 /* #16029 - moved to page actions
133 else
134 {
135 $this->addBlockCommand(
136 $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData"),
137 $lng->txt("show"), "_top");
138 }
139 */
140 }
141
142 return parent::getHTML();
143 }
144
150 protected function isHidden()
151 {
152 if($this->adv_md_hidden === null)
153 {
154 $this->adv_md_hidden = ilWikiPage::lookupAdvancedMetadataHidden($this->page_id);
155 }
157 }
158
163 {
164 global $lng;
165
166 $btpl = new ilTemplate("tpl.wiki_advmd_block.html", true, true, "Modules/Wiki");
167
168 // see ilAdvancedMDRecordGUI::parseInfoPage()
169
172
173 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
174 include_once('Services/ADT/classes/class.ilADTFactory.php');
175
176 $values = new ilAdvancedMDValues($this->record->getRecordId(), $this->obj_id, "wpg", $this->page_id);
177
178 // this correctly binds group and definitions
179 $values->read();
180
181 $defs = $values->getDefinitions();
182 foreach($values->getADTGroup()->getElements() as $element_id => $element)
183 {
184 $btpl->setCurrentBlock("item");
185 $btpl->setVariable("CAPTION", $defs[$element_id]->getTitle());
186 if($element->isNull())
187 {
188 $value = "-";
189 }
190 else
191 {
192 $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element);
193
194 if($element instanceof ilADTLocation)
195 {
196 $value->setSize("100%", "200px");
197 }
198
199 $value = $value->getHTML();
200 }
201 $btpl->setVariable("VALUE", $value);
202 $btpl->parseCurrentBlock();
203 }
204
205 /*
206 if ($this->isHidden())
207 {
208 $btpl->setVariable("HIDDEN_INFO", $lng->txt("wiki_adv_md_hidden"));
209 }
210 */
211
212 $this->setDataSection($btpl->get());
213
215
216 return;
217 }
218
219 public static function getRecords($a_wiki_obj_id)
220 {
221 if(!array_key_exists($a_wiki_obj_id, self::$records))
222 {
223 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
224 self::$records[$a_wiki_obj_id] = ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $a_wiki_obj_id, "wpg");
225 }
226 return self::$records[$a_wiki_obj_id];
227 }
228
229 public static function isActive($a_wiki_obj_id)
230 {
231 return (bool)sizeof(self::getRecords($a_wiki_obj_id));
232 }
233}
234
235?>
const IL_SCREEN_SIDE
static getInstance()
Get singleton.
static _getSelectedRecordsByObject($a_obj_type, $a_obj_id, $a_sub_type="")
Get selected records by object.
This class represents a block method of a block.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
addBlockCommand($a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
getTitle()
Get Title.
setTitle($a_title)
Set Title.
setBlockId($a_block_id=0)
Set Block Id.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
special template class to simplify handling of ITX/PEAR
getHTML($a_export=false)
Get block HTML code.
setObject($a_wiki_ref_id, $a_wiki_obj_id, $a_page_id)
static isRepositoryObject()
Is this a repository object.
static getScreenMode()
Get Screen Mode for current command.
__construct(ilAdvancedMDRecord $a_record)
Constructor.
static lookupAdvancedMetadataHidden($a_page_id)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$records
Definition: simple_test.php:17