ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\COPage\PC\PCFactory Class Reference
+ Collaboration diagram for ILIAS\COPage\PC\PCFactory:

Public Member Functions

 __construct (PCDefinition $pc_definition)
 
 getByNode (?\DOMNode $node, \ilPageObject $page_object)
 

Protected Attributes

ilLogger $log
 
PCDefinition $pc_definition
 

Detailed Description

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

Definition at line 28 of file class.PCFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\PC\PCFactory::__construct ( PCDefinition  $pc_definition)

Definition at line 33 of file class.PCFactory.php.

References $DIC, and ILIAS\COPage\PC\PCFactory\$pc_definition.

34  {
35  global $DIC;
36 
37  $this->pc_definition = $pc_definition;
38  $this->log = $DIC->copage()->internal()->domain()->log();
39  }
global $DIC
Definition: shib_login.php:26

Member Function Documentation

◆ getByNode()

ILIAS\COPage\PC\PCFactory::getByNode ( ?\DOMNode  $node,
\ilPageObject  $page_object 
)

Definition at line 41 of file class.PCFactory.php.

References ilObject\_lookupType(), ILIAS\Repository\int(), and null.

44  : ?\ilPageContent {
45  if (is_null($node)) {
46  return null;
47  }
48  $a_hier_id = $node->getAttribute("HierId");
49  $a_pc_id = $node->getAttribute("PCID");
50  $child_node = null;
51  if (!is_object($node)) {
52  $this->log->debug("No node passed.");
53  return null;
54  }
55  $node_name = $node->nodeName;
56  if (in_array($node_name, ["PageObject", "TableRow"])) {
57  $this->log->debug("$node_name -> return.");
58  return null;
59  }
60  if ($node_name == "PageContent") {
61  $child_node = $node->firstChild;
62  $node_name = $child_node->nodeName;
63  }
64 
65  // table extra handling (@todo: get rid of it)
66  if ($node_name == "Table") {
67  if ($child_node->getAttribute("DataTable") == "y") {
68  $tab = new \ilPCDataTable($page_object);
69  } else {
70  $tab = new \ilPCTable($page_object);
71  }
72  $tab->setDomNode($node);
73  $tab->setHierId($a_hier_id);
74  $tab->setPcId($a_pc_id);
75  $this->log->debug("return table.");
76  return $tab;
77  }
78 
79  // media extra handling (@todo: get rid of it)
80  if ($node_name == "MediaObject") {
81  $mal_node = $child_node->firstChild;
82  //echo "ilPageObject::getContentObject:nodename:".$mal_node->node_name().":<br>";
83  $id_arr = explode("_", $mal_node->getAttribute("OriginId"));
84  $mob_id = (int) $id_arr[count($id_arr) - 1];
85 
86  // see also #32331
87  if (\ilObject::_lookupType($mob_id) !== "mob") {
88  $mob_id = 0;
89  }
90 
91  //$mob = new ilObjMediaObject($mob_id);
92  $mob = new \ilPCMediaObject($page_object);
93  $mob->readMediaObject($mob_id);
94 
95  //$mob->setDom($this->dom);
96  $mob->setDomNode($node);
97  $mob->setHierId($a_hier_id);
98  $mob->setPcId($a_pc_id);
99  $this->log->debug("return media.");
100  return $mob;
101  }
102 
103  //
104  // generic procedure
105  //
106 
107  $pc_def = $this->pc_definition->getPCDefinitionByName($node_name);
108 
109  // check if pc definition has been found
110  if (!is_array($pc_def)) {
111  throw new \ilCOPageUnknownPCTypeException('Unknown PC Name "' . $node_name . '".');
112  }
113  $pc_class = "ilPC" . $pc_def["name"];
114  $pc_path = "./" . $pc_def["component"] . "/" . $pc_def["directory"] . "/class." . $pc_class . ".php";
115  //require_once($pc_path);
116  $pc = new ("\\" . $pc_class)($page_object);
117  if (!in_array(
118  $node->nodeName,
119  ["PageContent", "TableData", "FileItem", "ListItem"]
120  )) {
121  $this->log->debug("returning null.");
122  return null;
123  }
124  $pc->setDomNode($node);
125  $pc->setHierId($a_hier_id);
126  $pc->setPcId($a_pc_id);
127  //$this->log->debug("returning $pc_class.");
128  return $pc;
129  }
Content object of ilPageObject (see ILIAS DTD).
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $log

ilLogger ILIAS\COPage\PC\PCFactory::$log
protected

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

◆ $pc_definition

PCDefinition ILIAS\COPage\PC\PCFactory::$pc_definition
protected

Definition at line 31 of file class.PCFactory.php.

Referenced by ILIAS\COPage\PC\PCFactory\__construct().


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