ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Style\Content\Object\ObjectManager Class Reference

Manages repository object related content style behaviour. More...

+ Collaboration diagram for ILIAS\Style\Content\Object\ObjectManager:

Public Member Functions

 __construct (InternalRepoService $repo_service, InternalDomainService $domain_service, int $ref_id, int $obj_id=0)
 
 getSelectableStyles ()
 Get all selectable styles. More...
 
 updateStyleId (int $style_id)
 
 setOwnerOfStyle (int $style_id)
 
 getStyleId ()
 
 cloneTo (int $obj_id)
 Clones a style to a new object (or references the same standard style) More...
 
 inheritFromParent ()
 Inherits a non local style from the parent container. More...
 
 getEffectiveStyleId ()
 
 isOwned (int $style_id)
 
 globalFixed ()
 
 getGlobalFixedTitle ()
 
 getGlobalDefaultTitle ()
 
 hasEffectiveIndividualStyle (int $current_style)
 
 canSelectStyle (int $current_style)
 

Protected Member Functions

 isSelectable (int $style_id)
 

Protected Attributes

ilLogger $log
 
ilSetting $settings
 
ObjectDBRepository $object_repo
 
int $obj_id
 
ContainerDBRepository $container_repo
 
int $ref_id
 
InternalRepoService $repo_service
 
InternalDomainService $domain_service
 

Detailed Description

Manages repository object related content style behaviour.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 35 of file class.ObjectManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\Content\Object\ObjectManager::__construct ( InternalRepoService  $repo_service,
InternalDomainService  $domain_service,
int  $ref_id,
int  $obj_id = 0 
)

Definition at line 46 of file class.ObjectManager.php.

References ILIAS\Style\Content\Object\ObjectManager\$domain_service, ILIAS\Style\Content\Object\ObjectManager\$ref_id, ILIAS\Style\Content\Object\ObjectManager\$repo_service, ilObject\_lookupObjId(), ILIAS\Style\Content\InternalRepoService\object(), ILIAS\Style\Content\InternalRepoService\repositoryContainer(), and ILIAS\Repository\settings().

51  {
52  $this->settings = $domain_service->settings();
53  $this->ref_id = $ref_id;
54  $this->obj_id = ($obj_id > 0)
55  ? $obj_id
57  $this->repo_service = $repo_service;
58  $this->domain_service = $domain_service;
59  $this->container_repo = $repo_service->repositoryContainer();
60  $this->object_repo = $repo_service->object();
61  $this->log = $this->domain_service->log();
62  }
static _lookupObjId(int $ref_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ canSelectStyle()

ILIAS\Style\Content\Object\ObjectManager::canSelectStyle ( int  $current_style)

Definition at line 237 of file class.ObjectManager.php.

References ILIAS\Style\Content\Object\ObjectManager\globalFixed(), and ILIAS\Style\Content\Object\ObjectManager\hasEffectiveIndividualStyle().

237  : bool
238  {
239  if ($this->globalFixed() || $this->hasEffectiveIndividualStyle($current_style)) {
240  return false;
241  }
242  return true;
243  }
+ Here is the call graph for this function:

◆ cloneTo()

ILIAS\Style\Content\Object\ObjectManager::cloneTo ( int  $obj_id)

Clones a style to a new object (or references the same standard style)

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

References ilObjStyleSheet\_lookupStandard(), ilObjectFactory\getInstanceByObjId(), ILIAS\Style\Content\Object\ObjectManager\getStyleId(), ilObjStyleSheet\writeOwner(), and ilObjStyleSheet\writeStyleUsage().

129  : void
130  {
131  $this->log->debug("Cloning style from ref id: " . $this->ref_id .
132  ", obj id: " . $this->obj_id . ", style id: " . $this->getStyleId() . ", to new obj id: " .
133  $obj_id);
134  $style_id = $this->getStyleId();
135  if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
136  $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
137  $new_id = $style_obj->ilClone();
140  } else {
142  }
143  }
static writeOwner($obj_id, $style_id)
static _lookupStandard(int $a_id)
Lookup standard flag.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static writeStyleUsage(int $a_obj_id, int $a_style_id)
Write style usage.
+ Here is the call graph for this function:

◆ getEffectiveStyleId()

ILIAS\Style\Content\Object\ObjectManager::getEffectiveStyleId ( )

Definition at line 164 of file class.ObjectManager.php.

References ILIAS\Style\Content\Object\ObjectManager\$settings, ilObject\_lookupType(), ilSetting\get(), ILIAS\Style\Content\Object\ObjectManager\getStyleId(), ILIAS\Repository\int(), ILIAS\Style\Content\Object\ObjectManager\isOwned(), and ILIAS\Style\Content\Object\ObjectManager\isSelectable().

164  : int
165  {
167 
168  // the currently set/stored style for the object
169  $style_id = $this->getStyleId();
170 
171  // the set style must either be owned or be selectable
172  if (!$this->isOwned($style_id) && !$this->isSelectable($style_id)) {
173  $style_id = 0;
174  }
175 
176  // check global fixed content style, which overwrites anything
177  $fixed_style = (int) $settings->get("fixed_content_style_id");
178  if ($fixed_style > 0) {
179  $style_id = $fixed_style;
180  }
181 
182  // if no style id is set up to this point, check/use global default style
183  if ($style_id <= 0) {
184  $style_id = (int) $settings->get("default_content_style_id");
185  }
186 
187  if ($style_id > 0 && ilObject::_lookupType($style_id) === "sty") {
188  return $style_id;
189  }
190  return 0;
191  }
get(string $a_keyword, ?string $a_default_value=null)
get setting
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getGlobalDefaultTitle()

ILIAS\Style\Content\Object\ObjectManager::getGlobalDefaultTitle ( )

Definition at line 217 of file class.ObjectManager.php.

References ilObject\_lookupTitle(), ILIAS\Repository\int(), and ILIAS\Repository\settings().

217  : string
218  {
219  $style_id = (int) $this->settings->get("default_content_style_id");
220  if ($style_id > 0) {
221  return ilObject::_lookupTitle($style_id);
222  }
223  return "";
224  }
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:

◆ getGlobalFixedTitle()

ILIAS\Style\Content\Object\ObjectManager::getGlobalFixedTitle ( )

Definition at line 208 of file class.ObjectManager.php.

References ilObject\_lookupTitle(), ILIAS\Style\Content\Object\ObjectManager\globalFixed(), ILIAS\Repository\int(), and ILIAS\Repository\settings().

208  : string
209  {
210  if ($this->globalFixed()) {
211  $fixed_style = (int) $this->settings->get("fixed_content_style_id");
212  return ilObject::_lookupTitle($fixed_style);
213  }
214  return "";
215  }
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:

◆ getSelectableStyles()

ILIAS\Style\Content\Object\ObjectManager::getSelectableStyles ( )

Get all selectable styles.

If a global fixed style is set, this returns an empty array. If a ref id is provided for the manager, upper container will be searched for shared local content styles.

Definition at line 69 of file class.ObjectManager.php.

References ILIAS\Style\Content\Object\ObjectManager\$container_repo, $path, ILIAS\Style\Content\Object\ObjectManager\$settings, ilObjStyleSheet\_getStandardStyles(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\Style\Content\Container\ContainerDBRepository\filterByReuse(), and ilSetting\get().

Referenced by ILIAS\Style\Content\Object\ObjectManager\isSelectable().

69  : array
70  {
72  $tree = $this->domain_service->repositoryTree();
74 
75  $fixed_style = $settings->get("fixed_content_style_id");
76  if ($fixed_style > 0) {
77  return [];
78  } else {
80  true,
81  false,
82  $this->ref_id
83  );
84 
85  if ($this->ref_id > 0) {
86  $path = $tree->getPathId($this->ref_id);
87  $reuse_ref_ids = $container_repo->filterByReuse($path);
88  $container_obj_ids = array_map(function ($ref_id) {
90  }, $reuse_ref_ids);
91  foreach ($this->object_repo->getOwnedStyles($container_obj_ids) as $obj_id => $style_id) {
92  $st_styles[$style_id] =
93  ilObject::_lookupTitle($style_id) .
94  " (" . ilObject::_lookupTitle($obj_id) . ")";
95  }
96  }
97  }
98  ksort($st_styles);
99  return $st_styles;
100  }
get(string $a_keyword, ?string $a_default_value=null)
get setting
static _getStandardStyles(bool $a_exclude_default_style=false, bool $a_include_deactivated=false, int $a_scope=0)
Get standard styles.
$path
Definition: ltiservices.php:29
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
filterByReuse(array $ref_ids)
For an array of ref ids, return only the ref ids that have the reuse flag set.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStyleId()

ILIAS\Style\Content\Object\ObjectManager::getStyleId ( )

Definition at line 121 of file class.ObjectManager.php.

References ilObjStyleSheet\lookupObjectStyle().

Referenced by ILIAS\Style\Content\Object\ObjectManager\cloneTo(), and ILIAS\Style\Content\Object\ObjectManager\getEffectiveStyleId().

121  : int
122  {
123  return ilObjStyleSheet::lookupObjectStyle($this->obj_id);
124  }
static lookupObjectStyle(int $a_obj_id)
Lookup object style.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ globalFixed()

ILIAS\Style\Content\Object\ObjectManager::globalFixed ( )

Definition at line 199 of file class.ObjectManager.php.

References ILIAS\Repository\int(), and ILIAS\Repository\settings().

Referenced by ILIAS\Style\Content\Object\ObjectManager\canSelectStyle(), ILIAS\Style\Content\Object\ObjectManager\getGlobalFixedTitle(), and ILIAS\Style\Content\Object\ObjectManager\hasEffectiveIndividualStyle().

199  : bool
200  {
201  $fixed_style = (int) $this->settings->get("fixed_content_style_id");
202  if ($fixed_style > 0) {
203  return true;
204  }
205  return false;
206  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasEffectiveIndividualStyle()

ILIAS\Style\Content\Object\ObjectManager::hasEffectiveIndividualStyle ( int  $current_style)

Definition at line 226 of file class.ObjectManager.php.

References ILIAS\Style\Content\Object\ObjectManager\globalFixed(), and ILIAS\Style\Content\Object\ObjectManager\isOwned().

Referenced by ILIAS\Style\Content\Object\ObjectManager\canSelectStyle().

226  : bool
227  {
228  if ($this->globalFixed()) {
229  return false;
230  }
231  if ($current_style > 0 && $this->isOwned($current_style)) {
232  return true;
233  }
234  return false;
235  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inheritFromParent()

ILIAS\Style\Content\Object\ObjectManager::inheritFromParent ( )

Inherits a non local style from the parent container.

Definition at line 148 of file class.ObjectManager.php.

References ilObject\_lookupObjId(), ilObjStyleSheet\_lookupStandard(), ilObjStyleSheet\lookupObjectStyle(), and ilObjStyleSheet\writeStyleUsage().

148  : void
149  {
150  if ($this->ref_id > 0) {
151  $tree = $this->domain_service->repositoryTree();
152  $parent_ref_id = $tree->getParentId($this->ref_id);
153  $parent_id = ilObject::_lookupObjId((int) $parent_ref_id);
154  $obj_id = ilObject::_lookupObjId($this->ref_id);
155  $style_id = ilObjStyleSheet::lookupObjectStyle($parent_id);
156  if ($style_id > 0) {
157  if (ilObjStyleSheet::_lookupStandard($style_id)) {
159  }
160  }
161  }
162  }
static _lookupObjId(int $ref_id)
static _lookupStandard(int $a_id)
Lookup standard flag.
static writeStyleUsage(int $a_obj_id, int $a_style_id)
Write style usage.
static lookupObjectStyle(int $a_obj_id)
Lookup object style.
+ Here is the call graph for this function:

◆ isOwned()

ILIAS\Style\Content\Object\ObjectManager::isOwned ( int  $style_id)

Definition at line 194 of file class.ObjectManager.php.

Referenced by ILIAS\Style\Content\Object\ObjectManager\getEffectiveStyleId(), and ILIAS\Style\Content\Object\ObjectManager\hasEffectiveIndividualStyle().

194  : bool
195  {
196  return $this->object_repo->isOwned($this->obj_id, $style_id);
197  }
+ Here is the caller graph for this function:

◆ isSelectable()

ILIAS\Style\Content\Object\ObjectManager::isSelectable ( int  $style_id)
protected

Definition at line 102 of file class.ObjectManager.php.

References ILIAS\Style\Content\Object\ObjectManager\getSelectableStyles().

Referenced by ILIAS\Style\Content\Object\ObjectManager\getEffectiveStyleId().

102  : bool
103  {
104  $sel_types = $this->getSelectableStyles();
105  if (isset($sel_types[$style_id])) {
106  return true;
107  }
108  return false;
109  }
getSelectableStyles()
Get all selectable styles.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOwnerOfStyle()

ILIAS\Style\Content\Object\ObjectManager::setOwnerOfStyle ( int  $style_id)

Definition at line 116 of file class.ObjectManager.php.

References ilObjStyleSheet\writeOwner().

116  : void
117  {
118  ilObjStyleSheet::writeOwner($this->obj_id, $style_id);
119  }
static writeOwner($obj_id, $style_id)
+ Here is the call graph for this function:

◆ updateStyleId()

ILIAS\Style\Content\Object\ObjectManager::updateStyleId ( int  $style_id)

Definition at line 111 of file class.ObjectManager.php.

References ilObjStyleSheet\writeStyleUsage().

111  : void
112  {
113  ilObjStyleSheet::writeStyleUsage($this->obj_id, $style_id);
114  }
static writeStyleUsage(int $a_obj_id, int $a_style_id)
Write style usage.
+ Here is the call graph for this function:

Field Documentation

◆ $container_repo

ContainerDBRepository ILIAS\Style\Content\Object\ObjectManager::$container_repo
protected

◆ $domain_service

InternalDomainService ILIAS\Style\Content\Object\ObjectManager::$domain_service
protected

◆ $log

ilLogger ILIAS\Style\Content\Object\ObjectManager::$log
protected

Definition at line 37 of file class.ObjectManager.php.

◆ $obj_id

int ILIAS\Style\Content\Object\ObjectManager::$obj_id
protected

Definition at line 40 of file class.ObjectManager.php.

◆ $object_repo

ObjectDBRepository ILIAS\Style\Content\Object\ObjectManager::$object_repo
protected

Definition at line 39 of file class.ObjectManager.php.

◆ $ref_id

int ILIAS\Style\Content\Object\ObjectManager::$ref_id
protected

◆ $repo_service

InternalRepoService ILIAS\Style\Content\Object\ObjectManager::$repo_service
protected

◆ $settings

ilSetting ILIAS\Style\Content\Object\ObjectManager::$settings
protected

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