00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00040 include_once 'Services/Tracking/classes/class.ilLPFilter.php';
00041
00042
00043 class ilLPFilterGUI
00044 {
00045 var $usr_id = null;
00046 var $tpl = null;
00047 var $lng = null;
00048 var $ctrl = null;
00049
00050 function ilLPFilterGUI($a_usr_id)
00051 {
00052 global $lng,$ilCtrl,$tpl;
00053
00054 $this->ctrl =& $ilCtrl;
00055 $this->lng =& $lng;
00056 $this->tpl =& $tpl;
00057 $this->usr_id = $a_usr_id;
00058 $this->__initFilter();
00059 }
00060
00064 function &executeCommand()
00065 {
00066 $this->ctrl->setReturn($this, "");
00067 switch($this->ctrl->getNextClass())
00068 {
00069 default:
00070 $cmd = $this->ctrl->getCmd() ? $this->ctrl->getCmd() : 'show';
00071 $this->$cmd();
00072
00073 }
00074 return true;
00075 }
00076
00077
00078 function getUserId()
00079 {
00080 return $this->usr_id;
00081 }
00082
00083
00084 function getHTML()
00085 {
00086 global $ilObjDataCache;
00087
00088 $tpl = new ilTemplate('tpl.lp_filter.html',true,true,'Services/Tracking');
00089
00090 $tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
00091 $tpl->setVariable("TBL_TITLE",$this->lng->txt('trac_lp_filter'));
00092 $tpl->setVariable("TXT_AREA",$this->lng->txt('trac_filter_area'));
00093
00094
00095
00096 if($this->filter->getRootNode() == ROOT_FOLDER_ID)
00097 {
00098 $tpl->setVariable("FILTER_AREA",$this->lng->txt('trac_filter_repository'));
00099 }
00100 else
00101 {
00102 $text = $this->lng->txt('trac_below')." '";
00103 $text .= $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->filter->getRootNode()));
00104 $text .= "'";
00105 $tpl->setVariable("FILTER_AREA",$text);
00106 }
00107
00108 $tpl->setVariable("TXT_QUERY",$this->lng->txt('trac_query'));
00109 $tpl->setVariable("QUERY",ilUtil::prepareFormOutput($this->filter->getQueryString()));
00110
00111 $tpl->setVariable("UPDATE_AREA",$this->lng->txt('change'));
00112 $tpl->setVariable("TYPES",$this->lng->txt('obj_types'));
00113 $tpl->setVariable("TYPE_SELECTOR",ilUtil::formSelect($this->filter->getFilterType(),
00114 'type',
00115 $this->__getPossibleTypes(),
00116 false,
00117 true));
00118 $tpl->setVariable("TXT_HIDDEN",$this->lng->txt('trac_filter_hidden'));
00119
00120 if(count($hidden = $this->__prepareHidden()))
00121 {
00122 $tpl->setVariable("HIDDEN_SELECTOR",ilUtil::formSelect(0,'hide',$hidden,false,true));
00123 $tpl->setCurrentBlock("editable");
00124 $tpl->setVariable("BTN_SHOW",$this->lng->txt('trac_show_hidden'));
00125 $tpl->parseCurrentBlock();
00126 }
00127 else
00128 {
00129 $tpl->setVariable("HIDDEN_SELECTOR",$this->lng->txt('trac_filter_none'));
00130 }
00131 $tpl->setVariable("HREF_UPDATE_AREA",$this->ctrl->getLinkTargetByClass('illpfiltergui','selector'));
00132 $tpl->setVariable("DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
00133 $tpl->setVariable("BTN_REFRESH",$this->lng->txt('trac_refresh'));
00134
00135 return $tpl->get();
00136 }
00137
00138 function getFO()
00139 {
00140 global $ilObjDataCache,$ilUser;
00141
00142 $tpl = new ilTemplate('tpl.lp_filter.xml',true,true,'Services/Tracking');
00143
00144 if(strlen($this->filter->getQueryString()))
00145 {
00146 $tpl->setCurrentBlock("filter_title");
00147 $tpl->setVariable("TXT_TITLE",ilXmlWriter::_xmlEscapeData($this->lng->txt('trac_query')));
00148 $tpl->setVariable("TITLE",ilXmlWriter::_xmlEscapeData($this->filter->getQueryString()));
00149 $tpl->parseCurrentBlock();
00150 }
00151
00152 $tpl->setVariable("TXT_FILTER",ilXmlWriter::_xmlEscapeData($this->lng->txt('trac_lp_filter')));
00153 $tpl->setVariable("TXT_TYPE",ilXmlWriter::_xmlEscapeData($this->lng->txt('obj_types')));
00154 $tpl->setVariable("TYPE",ilXmlWriter::_xmlEscapeData($this->lng->txt('objs_'.$this->filter->getFilterType())));
00155 $tpl->setVariable("TXT_AREA",ilXmlWriter::_xmlEscapeData($this->lng->txt('trac_filter_area')));
00156 $tpl->setVariable("FILTER_LANG",ilXmlWriter::_xmlEscapeData($ilUser->getLanguage()));
00157 if($this->filter->getRootNode() == ROOT_FOLDER_ID)
00158 {
00159 $tpl->setVariable("AREA",ilXmlWriter::_xmlEscapeData($this->lng->txt('trac_filter_repository')));
00160 }
00161 else
00162 {
00163 $text = $this->lng->txt('trac_below')." '";
00164 $text .= $ilObjDataCache->lookupTitle($ilObjDataCache->lookupObjId($this->filter->getRootNode()));
00165 $text .= "'";
00166 $tpl->setVariable("AREA",ilXmlWriter::_xmlEscapeData($text));
00167 }
00168 return $tpl->get();
00169 }
00170
00171
00172 function hideSelected()
00173 {
00174 if(!count($_POST['item_id']))
00175 {
00176 sendInfo($this->lng->txt('trac_select_one'),true);
00177 $this->ctrl->returnToParent($this);
00178 }
00179 foreach($_POST['item_id'] as $item_id)
00180 {
00181 $this->filter->addHidden((int) $item_id);
00182 }
00183 $this->filter->update();
00184 sendInfo($this->lng->txt('trac_added_no_shown_list'),true);
00185 $this->ctrl->returnToParent($this);
00186 }
00187
00188
00189 function hide()
00190 {
00191 $this->filter->addHidden((int) $_GET['hide']);
00192 $this->filter->update();
00193 sendInfo($this->lng->txt('trac_added_no_shown_list'),true);
00194 $this->ctrl->returnToParent($this);
00195 }
00196
00197 function updateHidden()
00198 {
00199 if(!$_POST['hide'])
00200 {
00201 sendInfo($this->lng->txt('trac_select_one'),true);
00202 $this->ctrl->returnToParent($this);
00203 }
00204 $this->filter->removeHidden((int) $_POST['hide']);
00205 $this->filter->update();
00206 sendInfo($this->lng->txt('trac_modifications_saved'),true);
00207 $this->ctrl->returnToParent($this);
00208
00209 }
00210
00211 function refresh()
00212 {
00213 $this->filter->setFilterType($_POST['type']);
00214 $this->filter->setQueryString(ilUtil::stripSlashes($_POST['query']));
00215 $this->filter->update();
00216 $this->ctrl->returnToParent($this);
00217
00218 return true;
00219 }
00220
00221 function selector()
00222 {
00223 global $tree;
00224
00225 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.trac_root_selector.html','Services/Tracking');
00226
00227 include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
00228
00229 sendInfo($this->lng->txt('search_area_info'));
00230
00231 $exp = new ilSearchRootSelector($this->ctrl->getLinkTargetByClass('illpfiltergui','selector'));
00232 $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $tree->readRootId());
00233 $exp->setExpandTarget($this->ctrl->getLinkTargetByClass('illpfiltergui','selector'));
00234 $exp->setTargetClass('illpfiltergui');
00235 $exp->setCmd('selectRoot');
00236
00237
00238 $exp->setOutput(0);
00239
00240 $this->tpl->setVariable("EXPLORER",$exp->getOutput());
00241
00242
00243 }
00244
00245 function selectRoot()
00246 {
00247 $this->filter->setRootNode((int) $_GET['root_id']);
00248 $this->filter->update();
00249 sendInfo($this->lng->txt('trac_modifications_saved'),true);
00250 $this->ctrl->returnToParent($this);
00251 }
00252
00253
00254 function __initFilter()
00255 {
00256 global $ilUser;
00257
00258 $this->filter = new ilLPFilter($ilUser->getId());
00259 return true;
00260 }
00261
00262 function __getPossibleTypes()
00263 {
00264 return array('lm' => $this->lng->txt('learning_resources'),
00265 'crs' => $this->lng->txt('objs_crs'),
00266 'tst' => $this->lng->txt('objs_tst'),
00267 'grp' => $this->lng->txt('objs_grp'),
00268 'exc' => $this->lng->txt('objs_exc'));
00269
00270 }
00271
00272 function __prepareHidden()
00273 {
00274 $types = $this->filter->prepareType();
00275
00276
00277 global $ilObjDataCache;
00278
00279 foreach($this->filter->getHidden() as $obj_id)
00280 {
00281 if(in_array($ilObjDataCache->lookupType($obj_id),$types))
00282 {
00283 $hidden[$obj_id] = $ilObjDataCache->lookupTitle($obj_id);
00284 }
00285 }
00286 return $hidden ? $hidden : array();
00287 }
00288 }
00289 ?>