public function processData(\IRequestObject $requestObject) { $objectId = $requestObject->getId(); $steam = $GLOBALS["STEAM"]; $extensionMaster = \ExtensionMaster::getInstance(); $portalColumnExtension = $extensionMaster->getExtensionById("PortalColumn"); $this->getExtension()->addCSS(); $htmlBody = ""; $portalColumnObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectId); $portlets = $portalColumnObject->get_inventory(); //handle column size $columnWidthPx = trim($portalColumnObject->get_attribute("bid:portal:column:width")); if (strEndsWith($columnWidthPx, "px")) { $columnWidth = str_replace("px", "", $columnWidthPx); $columnWidthExt = "px"; } else { if (strEndsWith($columnWidthPx, "%")) { $columnWidth = str_replace("%", "", $columnWidthPx); $columnWidthExt = "%"; } else { $columnWidth = $columnWidthPx; $columnWidthExt = "px"; } } if ((int) $columnWidth > 0) { $columnWidthPx = $columnWidth . $columnWidthExt; } else { $columnWidthPx = "200px"; } $this->rawHtmlWidget = new \Widgets\RawHtml(); $htmlBody .= '<div class="column" style="width:' . $columnWidthPx . ';">'; //popupmenu $popupmenu = new \Widgets\PopupMenu(); $popupmenu->setCommand("GetPopupMenu"); $popupmenu->setData($portalColumnObject); $popupmenu->setNamespace("PortalColumn"); $popupmenu->setElementId("portal-overlay"); $htmlBody .= '<h2 class="editbutton columnheadline"><div class="editbutton">' . $popupmenu->getHtml() . '</div><div style="margin-left:3px;">Spalte</div></h2>'; foreach ($portlets as $portlet) { //handle link objects as portlets $params = array(); if ($portlet instanceof \steam_link) { $params["referenced"] = true; $params["referenceId"] = $portlet->get_id(); $portlet = $portlet->get_link_object(); if ($portlet == NULL) { continue; } } $widgets = $extensionMaster->getWidgetsByObjectId($portlet->get_id(), "view", $params); $this->rawHtmlWidget->addWidgets($widgets); $data = \Widgets\Widget::getData($widgets); $htmlBody .= $data["html"]; } $htmlBody .= "</div>"; $this->rawHtmlWidget->setHtml($htmlBody); }
public function processData(\IRequestObject $requestObject) { if ($requestObject instanceof \UrlRequestObject) { $this->params = $requestObject->getParams(); isset($this->params[0]) ? $this->id = $this->params[0] : ""; } else { if ($requestObject instanceof \IdRequestObject) { $this->id = $requestObject->getId(); } } $steam = $GLOBALS["STEAM"]; //get singleton and portlet path $portalInstance = \Portal::getInstance(); $portalPath = $portalInstance->getExtensionPath(); //template $templateFileName = $portalPath . "/ui/html/index.html"; $tmpl = new \HTML_TEMPLATE_IT(); $tmpl->loadTemplateFile($templateFileName); $this->getExtension()->addCSS(); $this->getExtension()->addJS(); $currentUser = $GLOBALS["STEAM"]->get_current_steam_user(); $object = $currentUser->get_workroom(); $objectId = $this->id; //get the portal object $this->portalObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectId); $type = getObjectType($this->portalObject); if (!($type === "portal")) { \ExtensionMaster::getInstance()->send404Error(); die; } \Portal::getInstance()->setPortalObject($this->portalObject); //get the content of the portal object $portalColumns = $this->portalObject->get_inventory(); $htmlBody = ""; $extensionMaster = \ExtensionMaster::getInstance(); $count = 0; $htmlCollectorColRow[][] = array(); $col = 0; $row = 0; $this->rawHtmlWidget = new \Widgets\RawHtml(); foreach ($portalColumns as $columnObject) { $columnObjectId = $columnObject->get_id(); $widgets = $extensionMaster->getWidgetsByObjectId($columnObjectId, "view"); $this->rawHtmlWidget->addWidgets($widgets); $data = \Widgets\Widget::getData($widgets); $htmlBody .= $data["html"]; $count++; } $currentUser = $GLOBALS["STEAM"]->get_current_steam_user(); if (isset($this->portalObject) && $this->portalObject->check_access_write($currentUser)) { $htmlBody .= "<script>if (readCookie(\"portalEditMode\") === \"{$objectId}\") {portalLockButton({$objectId})}</script>"; } $tmpl->setVariable("BODY", $htmlBody); $htmlBodyTemplated = $tmpl->get(); $this->rawHtmlWidget->setHtml($htmlBodyTemplated); }
public function handleRequest($pathArray) { $frame = lms_portal::get_instance(); //$frame->initialize(GUEST_NOT_ALLOWED, false); $frame->init_login(GUEST_ALLOWED, false); lms_steam::connect(STEAM_SERVER, STEAM_PORT, $frame->get_user()->get_login(), $frame->get_user()->get_password()); $urlRequestObject = new UrlRequestObject(); $urlRequestObject->setParams($pathArray); $command = new \Wave\Commands\Index(); if ($command->validateData($urlRequestObject)) { $command->processData($urlRequestObject); try { $frameResponeObject = $command->frameResponse(new FrameResponseObject()); } catch (steam_exception $e) { if ($e->get_code() === 300) { die("no read access"); } } $data = \Widgets\Widget::getData($frameResponeObject->getWidgets()); echo $data["html"]; } }
public function handleRequest(AjaxRequestObject $ajaxRequestObject, AjaxResponseObject $ajaxResponseObject) { $response = new HttpResponse(); $extension = ExtensionMaster::getInstance()->getExtensionForNamespace($ajaxRequestObject->getNamespace()); if (isset($extension)) { if ($extension instanceof ICommandAdapter) { if ($ajaxRequestObject->getCommand() != "") { if ($ajaxRequestObject->getCommand() == "databinding") { $command = new Databinding(); } else { if ($extension->isValidCommand($ajaxRequestObject->getCommand())) { $command = $extension->getCommand($ajaxRequestObject->getCommand()); } } if ($command instanceof IAjaxCommand && $command->validateData($ajaxRequestObject)) { try { $command->processData($ajaxRequestObject); $ajaxResponseObject = $command->ajaxResponse($ajaxResponseObject); } catch (Exception $e) { $response->setStatus("400 Bad Request"); $response->write("Command processing error: \"{$e->getMessage()}\""); $response->flush(); if (DEVELOPMENT_MODE) { throw $e; } exit; } if ($ajaxResponseObject instanceof AjaxResponseObject) { $data = \Widgets\Widget::getData($ajaxResponseObject->getWidgets()); $stat = ""; if ($_SESSION["STATISTICS_LEVEL"] > 0) { $stat = "console.log('Serveranfragen: " . $GLOBALS["STEAM"]->get_request_count() . " / " . $GLOBALS["STEAM"]->get_globalrequest_count() . "');"; } if ($_SESSION["STATISTICS_LEVEL"] > 1 && isset($GLOBALS["page_time_start"])) { $requestMap = $GLOBALS["STEAM"]->get_globalrequest_map(); $requestTime = $GLOBALS["STEAM"]->get_globalrequest_time(); $requestString = ""; foreach ($requestMap as $method => $count) { $requestString .= "console.log('Methode {$method} -> {$count} mal in " . round($requestTime[$method] * 1000) . " ms');"; } $stat .= "console.log('Zeit: " . round((microtime(TRUE) - $GLOBALS["page_time_start"]) * 1000) . " ms');" . $requestString; } header("Content-type: text/plain"); $response->write(json_encode(array("status" => $ajaxResponseObject->getStatus(), "html" => $data["html"], "data" => $ajaxResponseObject->getData(), "css" => $data["css"], "js" => $data["js"] . $stat, "postjs" => $data["postjs"]))); $response->flush(); exit; } else { $response->setStatus("400 Bad Request"); $response->write("Wrong response type for \"{$ajaxRequestObject->getCommand()}\""); $response->flush(); exit; } } else { $response->setStatus("400 Bad Request"); $response->write("Command \"{$ajaxRequestObject->getCommand()}\" not valid."); $response->flush(); exit; } } else { $response->setStatus("400 Bad Request"); $response->write("Command parameter missing."); $response->flush(); exit; } } else { $response->setStatus("400 Bad Request"); $response->write("Extension doesn't support commands."); $response->flush(); exit; } } else { $response->setStatus("400 Bad Request"); $response->write("Not extension found for url"); $response->flush(); exit; } }
public function handleRequest($pathArray) { // handel Frame Requests $urlRequestObject = new UrlRequestObject(); if (isset($pathArray[0])) { $urlRequestObject->setNamespace($pathArray[0]); } if (isset($pathArray[1])) { $urlRequestObject->setCommand($pathArray[1]); } if (count($pathArray) > 2) { $params = array(); for ($i = 2; $i < count($pathArray); $i++) { $params[] = $pathArray[$i]; } $urlRequestObject->setParams($params); } $namespaceExtension = ExtensionMaster::getInstance()->getExtensionForNamespace($urlRequestObject->getNamespace()); if (isset($namespaceExtension)) { if ($urlRequestObject->getCommand() == "") { $urlRequestObject->setCommand($namespaceExtension->getDefaultCommandName($urlRequestObject->getNamespace())); } $command = $namespaceExtension->getCommand($urlRequestObject->getCommand()); if ($command == null) { if (strtolower($urlRequestObject->getCommand()) == "asset") { $command = new Asset(); } else { if (strtolower($urlRequestObject->getCommand()) == "css") { $command = new Css(); } else { if (strtolower($urlRequestObject->getCommand()) == "js") { $command = new Js(); } } } } if ($command == null) { if (DEVELOPMENT_MODE) { throw new Exception("Command {$urlRequestObject->getCommand()} not found."); } else { ExtensionMaster::getInstance()->send404Error(); } } //init commands extension $command->getExtension(); if ($command->httpAuth($urlRequestObject)) { include_once PATH_LIB . "http_auth_handling.inc.php"; if (!http_auth()) { die("Bitte anmelden."); } } $frame = lms_portal::get_instance(); if ($command instanceof IResourcesCommand) { if ($command->validateData($urlRequestObject)) { if ($command->isGuestAllowed($urlRequestObject)) { $frame->initialize(GUEST_ALLOWED, $command->workOffline($urlRequestObject)); } else { $frame->initialize(GUEST_NOT_ALLOWED, $command->workOffline($urlRequestObject)); } ExtensionMaster::getInstance()->getExtensionById("Chronic")->setCurrentObject($namespaceExtension->getCurrentObject($urlRequestObject)); $command->processData($urlRequestObject); $command->resourcesResponse(); die; } } else { if ($command instanceof IFrameCommand) { if ($command->validateData($urlRequestObject)) { if ($command->isGuestAllowed($urlRequestObject)) { $frame->initialize(GUEST_ALLOWED, $command->workOffline($urlRequestObject)); } else { $frame->initialize(GUEST_NOT_ALLOWED, $command->workOffline($urlRequestObject)); } ExtensionMaster::getInstance()->getExtensionById("Chronic")->setCurrentObject($namespaceExtension->getCurrentObject($urlRequestObject)); $command->processData($urlRequestObject); $frameResponeObject = $command->frameResponse(new FrameResponseObject()); if ($command->embedContent($urlRequestObject)) { $data = \Widgets\Widget::getData($frameResponeObject->getWidgets()); $frame->add_css_style($data["css"]); $frame->add_javascript_code("Widgets", $data["js"]); $frame->set_page_main($frameResponeObject->getHeadline(), $data["html"] . "<script type=\"text/javascript\">{$data["postjs"]}</script>", ""); $frame->set_page_title($frameResponeObject->getTitle()); $frame->set_confirmation($frameResponeObject->getConfirmText()); $frame->set_problem_description($frameResponeObject->getProblemDescription(), $frameResponeObject->getProblemSolution()); $frame->show_html(); die; } else { $data = \Widgets\Widget::getData($frameResponeObject->getWidgets()); echo $data["html"]; die; } } } } if (DEVELOPMENT_MODE) { throw new Exception("Command {$urlRequestObject->getCommand()} execution error."); } else { ExtensionMaster::getInstance()->send404Error(); } } ExtensionMaster::getInstance()->send404Error(); }