ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjLinkResource Class Reference

Class ilObjLinkResource. More...

+ Inheritance diagram for ilObjLinkResource:
+ Collaboration diagram for ilObjLinkResource:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 
 create ($a_upload=false)
 
 update ()
 
 delete ()
 
 cloneObject (int $target_id, int $copy_id=0, bool $omit_tree=false)
 
 toXML (ilXmlWriter $writer, bool $skip_lom=false)
 
- Public Member Functions inherited from ilObject
 getObjectProperties ()
 
 flushObjectProperties ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $description)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Protected Member Functions

 getWebLinkRepo ()
 
 doMDUpdateListener (string $a_element)
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Protected Attributes

LOMServices $lom_services
 
ilWebLinkDatabaseRepository $repo
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
LOMServices $lom_services
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Additional Inherited Members

- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", ?int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static getIconForType (string $type)
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, ?\ilDBInterface $ilDB=null)
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Detailed Description

Class ilObjLinkResource.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilObjLinkResource::__construct ( int  $a_id = 0,
bool  $a_call_by_reference = true 
)

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

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

33  {
34  global $DIC;
35 
36  $this->type = "webr";
37  parent::__construct($a_id, $a_call_by_reference);
38 
39  $this->lom_services = $DIC->learningObjectMetadata();
40  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ cloneObject()

ilObjLinkResource::cloneObject ( int  $target_id,
int  $copy_id = 0,
bool  $omit_tree = false 
)

Definition at line 129 of file class.ilObjLinkResource.php.

References $container, ilObjLinkResourceAccess\_getFirstLink(), ilObject\cloneMetaData(), ilWebLinkDatabaseRepository\createAllItemsInDraftContainer(), and getWebLinkRepo().

133  : ?ilObject {
134  $new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);
135  $this->cloneMetaData($new_obj);
136 
137  // object created, now copy items and parameters
138  $items = $this->getWebLinkRepo()->getAllItemsAsContainer()->getItems();
140 
141  foreach ($items as $item) {
142  $draft = new ilWebLinkDraftItem(
143  $item->isInternal(),
144  $item->getTitle(),
145  $item->getDescription(),
146  $item->getTarget(),
147  $item->isActive(),
148  $item->getParameters()
149  );
150 
151  $container->addItem($draft);
152  }
153 
154  $new_web_link_repo = new ilWebLinkDatabaseRepository($new_obj->getId());
155  $new_web_link_repo->createAllItemsInDraftContainer($container);
156 
157  // append copy info weblink title
158  if ($new_web_link_repo->doesOnlyOneItemExist(true)) {
159  $item = ilObjLinkResourceAccess::_getFirstLink($new_obj->getId());
160  $draft = new ilWebLinkDraftItem(
161  $item->isInternal(),
162  $new_obj->getTitle(),
163  $new_obj->getDescription(),
164  $item->getTarget(),
165  $item->isActive(),
166  $item->getParameters()
167  );
168  $new_web_link_repo->updateItem($item, $draft);
169  }
170 
171  // make the new object a list if needed
172  if ($this->getWebLinkRepo()->doesListExist()) {
173  $draft_list = new ilWebLinkDraftList(
174  $new_obj->getTitle(),
175  $new_obj->getDescription()
176  );
177  $new_web_link_repo->createList($draft_list);
178  }
179 
180  return $new_obj;
181  }
createAllItemsInDraftContainer(ilWebLinkDraftItemsContainer $container)
$container
Definition: wac.php:36
cloneMetaData(ilObject $target_obj)
Copy meta data.
Container class for drafted Web Link items.
Draft class for creating or updating a Web Link list.
Draft class for creating and updating a Web Link item.
static _getFirstLink(int $a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one...
+ Here is the call graph for this function:

◆ create()

ilObjLinkResource::create (   $a_upload = false)
Todo:
how to handle this meta data switch

Definition at line 53 of file class.ilObjLinkResource.php.

References ilObject\createMetaData().

53  : int
54  {
55  $new_id = parent::create();
56  if (!$a_upload) {
57  $this->createMetaData();
58  }
59  return $new_id;
60  }
+ Here is the call graph for this function:

◆ delete()

ilObjLinkResource::delete ( )

Definition at line 110 of file class.ilObjLinkResource.php.

References ilObject\deleteMetaData(), and getWebLinkRepo().

110  : bool
111  {
112  // always call parent delete function first!!
113  if (!parent::delete()) {
114  return false;
115  }
116 
117  // delete items and list
118  $this->getWebLinkRepo()->deleteAllItems();
119  if ($this->getWebLinkRepo()->doesListExist()) {
120  $this->getWebLinkRepo()->deleteList();
121  }
122 
123  // delete meta data
124  $this->deleteMetaData();
125 
126  return true;
127  }
+ Here is the call graph for this function:

◆ doMDUpdateListener()

ilObjLinkResource::doMDUpdateListener ( string  $a_element)
protected

Definition at line 68 of file class.ilObjLinkResource.php.

References ilObject\$title, ilObject\getId(), ilObject\getType(), and getWebLinkRepo().

68  : void
69  {
70  if ($a_element !== 'General') {
71  return;
72  }
73 
74  $paths = $this->lom_services->paths();
75  $reader = $this->lom_services->read(
76  $this->getId(),
77  0,
78  $this->getType(),
79  $paths->custom()->withNextStep('general')->get()
80  );
81 
82  $title = $reader->firstData($paths->title())->value();
83  $description = $reader->firstData($paths->firstDescription())->value();
84 
85  if (
86  !$this->getWebLinkRepo()->doesListExist() &&
87  $this->getWebLinkRepo()->doesOnlyOneItemExist()
88  ) {
89  $item = $this->getWebLinkRepo()->getAllItemsAsContainer()->getFirstItem();
90  $draft = new ilWebLinkDraftItem(
91  $item->isInternal(),
92  $title,
93  $description,
94  $item->getTarget(),
95  $item->isActive(),
96  $item->getParameters()
97  );
98  $this->getWebLinkRepo()->updateItem($item, $draft);
99  }
100  if ($this->getWebLinkRepo()->doesListExist()) {
101  $list = $this->getWebLinkRepo()->getList();
102  $draft = new ilWebLinkDraftList(
103  $title,
104  $description
105  );
106  $this->getWebLinkRepo()->updateList($list, $draft);
107  }
108  }
string $title
Draft class for creating or updating a Web Link list.
Draft class for creating and updating a Web Link item.
+ Here is the call graph for this function:

◆ getWebLinkRepo()

ilObjLinkResource::getWebLinkRepo ( )
protected

Definition at line 42 of file class.ilObjLinkResource.php.

References $repo, and ilObject\getId().

Referenced by cloneObject(), delete(), doMDUpdateListener(), and toXML().

43  {
44  if (isset($this->repo)) {
45  return $this->repo;
46  }
47  return $this->repo = new ilWebLinkDatabaseRepository($this->getId());
48  }
ilWebLinkDatabaseRepository $repo
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

ilObjLinkResource::toXML ( ilXmlWriter  $writer,
bool  $skip_lom = false 
)

Definition at line 183 of file class.ilObjLinkResource.php.

References ilContainerSortingSettings\_lookupSortMode(), ilXmlWriter\appendXML(), ilObject\getDescription(), ilObject\getId(), ilObject\getTitle(), getWebLinkRepo(), IL_INST_ID, ilContainer\SORT_MANUAL, ilContainer\SORT_TITLE, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

183  : void
184  {
185  $attribs = array("obj_id" => "il_" . IL_INST_ID . "_webr_" . $this->getId(
186  )
187  );
188 
189  $writer->xmlStartTag('WebLinks', $attribs);
190 
191  if (!$skip_lom) {
192  // LOM MetaData
193  $md2xml = new ilMD2XML($this->getId(), $this->getId(), 'webr');
194  $md2xml->startExport();
195  $writer->appendXML($md2xml->getXML());
196  }
197 
198  // Sorting
201  $writer->xmlElement(
202  'Sorting',
203  array('type' => 'Manual')
204  );
205  break;
206 
208  default:
209  $writer->xmlElement(
210  'Sorting',
211  array('type' => 'Title')
212  );
213  break;
214  }
215 
216  if ($this->getWebLinkRepo()->doesListExist()) {
217  $writer->xmlStartTag('ListSettings');
218  $writer->xmlElement('ListTitle', [], $this->getTitle());
219  $writer->xmlElement('ListDescription', [], $this->getDescription());
220  $writer->xmlEndTag('ListSettings');
221  }
222 
223  // All items
224  $items = $this->getWebLinkRepo()->getAllItemsAsContainer()
225  ->sort()
226  ->getItems();
227 
228  $position = 0;
229  foreach ($items as $item) {
230  ++$position;
231  $item->toXML($writer, $position);
232  }
233 
234  $writer->xmlEndTag('WebLinks');
235  }
const IL_INST_ID
Definition: constants.php:40
appendXML(string $a_str)
append xml string to document
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ update()

ilObjLinkResource::update ( )

Definition at line 62 of file class.ilObjLinkResource.php.

References ilObject\updateMetaData().

62  : bool
63  {
64  $this->updateMetaData();
65  return parent::update();
66  }
+ Here is the call graph for this function:

Field Documentation

◆ $lom_services

LOMServices ilObjLinkResource::$lom_services
protected

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

◆ $repo

ilWebLinkDatabaseRepository ilObjLinkResource::$repo
protected

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

Referenced by getWebLinkRepo().


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