protected final function addComponent(Component &$component) { if ($this->childExists($component->getId())) { throw new \RuntimeException(sprintf("Component %s already has a child with id %s", $this->getId(), $component->getId())); } if ($component->added) { throw new \RuntimeException(sprintf("Component %s has already been added to another", $component->getId())); } if ($component == $this) { throw new \RuntimeException(sprintf("Component %s cannot be added to itself.", $component->getId())); } $this->children[$component->getId()] = $component; $this->onComponentAdded($component); }
public function onInherit(Component &$component) { if (!PropertyResolver::hasProperty($this->getModelObject(), $component->getId())) { return null; } return new WrappedCompoundModel($this); }
/** * Returns whether the component is installed for the given course * * Called when this component receives an HTTP GET request to * /link/exists/course/$courseid(/). * * @param int $courseid A course id. */ public function getExistsCourse($courseid) { $result = Request::routeRequest('GET', '/process/course/' . $courseid . '/component/' . $this->_conf->getId(), $this->app->request->headers->all(), '', $this->_getProcess, 'process'); if (isset($result['status']) && $result['status'] >= 200 && $result['status'] <= 299 && isset($result['content']) && $this->_conf !== null && $this->_conf->getId() !== null) { $this->app->response->setStatus(200); $this->app->stop(); } $this->app->response->setStatus(409); }
public function renderHead(Component $component, HeaderContainer $headerContainer, HeaderResponse $headerResponse) { $markup = $component->loadAssociatedMarkup(); $heads = $this->findHead(array($markup)); foreach ($heads as $index => $head) { $id = $component->getId() . '_head_' . $index; $headerPart = new HeaderPartContainer($id, $head); $headerPart->render(); } }
public function getMarkup(MarkupContainer $container, Component $child) { $markup = $container->getMarkup(); if ($markup == null) { throw new \MarkupNotFoundException(sprintf("Markup for %s could not be found.", $child->getId())); } if ($child == null) { return $markup; } $m = MarkupUtils::findComponentTag($markup, $child->getId(), $container); if ($m == null) { foreach ($container->getChildren() as $ch) { if ($ch != $child && $ch instanceof MarkupContainer && $ch instanceof ComponentResolver) { $m = $ch->getMarkupForChild($child); if ($m != null) { return $m; } } } } return $m; }
/** * @param \PowerEcommerce\Framework\Routing\Component $target * * @return \PowerEcommerce\System\Object */ public function handle(Component $target) { /** @type \PowerEcommerce\Framework\Routing\Target $target */ !$target instanceof \PowerEcommerce\Framework\Routing\Target && $this->invalid(); /** @type \PowerEcommerce\Framework\Routing\Component $route */ foreach ($this->getComponents() as $route) { $pattern = '/' . addcslashes($route->getId(), '/') . '/' . $route->getModifiers(); if (preg_match($pattern, $target->getId()) || $route instanceof \PowerEcommerce\Framework\Routing\Router) { $route->handle($target); } } return $this; }
/** * Returns whether the component is installed for the given course * * Called when this component receives an HTTP GET request to * /link/exists/course/$courseid(/). * * @param int $courseid A course id. */ public function getExistsCourse($courseid) { // hier soll geprüft werden, ob ein entsprechender Eintrag für diese Komponente in der referenzierten Prozesstabelle besteht, // ob sie also als Verarbeitung registriert ist (dazu wird die ID dieser Komponente verwendet ($this->_conf->getId())) $result = Request::routeRequest('GET', '/process/course/' . $courseid . '/component/' . $this->_conf->getId(), array(), '', $this->_getProcess, 'process'); // wenn etwas für die ID dieser Komponente von der DB geantwortet wird, ist die Installation korrekt bzw. vorhanden. if (isset($result['status']) && $result['status'] >= 200 && $result['status'] <= 299 && isset($result['content']) && $this->_conf !== null && $this->_conf->getId() !== null) { $this->app->response->setStatus(200); $this->app->stop(); } // die Datenbank hat keinen Eintrag für diese Komponente geliefert oder ein sonstiger Fehler ist aufgetreten, daher // gilt die Installation als nicht vorhanden/korrekt $this->app->response->setStatus(409); }
private static function internalFindComponentTag(XmlElement $markup, $componentTagId, Component $component) { if ($markup instanceof ComponentTag && $markup->getComponentTagId() == $componentTagId) { return $markup; } else { if ($markup instanceof MarkupElement && $markup->hasChildren() && (!$markup instanceof ComponentTag || $component->getId() == $markup->getComponentTagId())) { $componentTag = null; foreach ($markup->getChildren() as $element) { if ($element instanceof MarkupElement) { $componentTag = self::internalFindComponentTag($element, $componentTagId, $component); if ($componentTag != null) { return $componentTag; } } } } return null; } }
/** * @param \PowerEcommerce\Framework\Security\Component $component * * @return $this */ public function detach(Component $component) { !$component instanceof \PowerEcommerce\Framework\Security\Privilege && $this->invalid(); return $this->del($component->getId()); }
/** * Add the component for invalidation * * @param Component $c * * @return void */ public function invalidate(Component $c) { $this->components[$c->getId()] = $c; }
/** * * @param Component $component * @return int id of the Component inserted in base. False if it didn't work. */ public static function flush($component) { $componentId = $component->getId(); $mark = $component->getMark(); $date = $component->getDate(); $isResit = $component->getIsResit(); $user = $component->getUser()->getId(); $componentLinked = $component->getComponent()->getId(); $module = $component->getModule()->getId(); $type = $component->getType()->getId(); if ($componentId > 0) { $sql = 'UPDATE component c SET ' . 'c.mark = ?, ' . 'c.date = ?, ' . 'c.is_resit = ?, ' . 'c.USER_id_user = ?, ' . 'c.COMPONENT_id_component = ?, ' . 'c.MODULE_id_module = ?, ' . 'c.TYPE_id_type= ? ' . 'WHERE c.id_component = ?'; $params = array('dsiiiiii', &$mark, &$date, &$isResit, &$user, &$componentLinked, &$module, &$type, &$componentId); } else { $sql = 'INSERT INTO component ' . '(mark, date, is_resit, ' . 'USER_id_user, COMPONENT_id_component, MODULE_id_module, TYPE_id_type ) ' . 'VALUES(?, ?, ?, ?, ?, ?, ?) '; $params = array('dsiiiii', &$mark, &$date, &$isResit, &$user, &$componentLinked, &$module, &$type); } $idInsert = BaseSingleton::insertOrEdit($sql, $params); if ($idInsert !== false && $componentId > 0) { $idInsert = $componentId; } return $idInsert; }
public function onNotAuthorised(Component $component) { throw new UnAuthorisdeException(sprintf('Not authorised for component %s', $component->getId())); }