public function index($params) { $document = OW::getDocument(); $menu = UHEADER_CTRL_Admin::getMenu(); $menu->getElement("gallery")->setActive(true); $this->addComponent("menu", $menu); $tplId = empty($params["tplId"]) ? null : $params["tplId"]; $roleId = empty($_GET["role"]) ? null : $_GET["role"]; UHEADER_CLASS_Plugin::getInstance()->includeStatic(); UHEADER_CLASS_Plugin::getInstance()->includeStaticFile("admin.css"); $uniqId = uniqid("uheader-cg-"); if (empty($roleId) && !empty($tplId)) { $roles = $this->service->findRoleIdsByTemplateId($tplId); if (!empty($roles)) { $roleId = reset($roles); } } $roleIds = $roleId === null ? null : array($roleId); $list = $this->service->findTemplateList($roleIds); $tplList = array(); foreach ($list as $template) { /*@var $template UHEADER_BOL_Template */ $tplList[$template->id] = $this->getTplInfo($template); } $currentItem = $tplId === null || empty($tplList[$tplId]) ? reset($tplList) : $tplList[$tplId]; $this->assign("list", $tplList); $this->assign("current", $currentItem); $this->assign("uploader", OW::getRouter()->urlFor(__CLASS__, "templateUploader")); $this->assign("uniqId", $uniqId); $config = array(); $config['avatarSize'] = $this->config['avatar_big_size']; $config['coverHeight'] = $this->config["cover_height"]; $config['previewHeight'] = self::ITEM_WIDTH / self::CANVAS_WIDTH * $config['coverHeight']; $this->assign("config", $config); $this->addComponent("contextToolbar", $this->getContextToolbar()); $settings = array("rsp" => OW::getRouter()->urlFor(__CLASS__, "rsp"), "current" => $currentItem); $js = UTIL_JsGenerator::newInstance(); $js->newObject(array("UHEADER", "activeGallery"), "UHEADER.AdminGallery", array($uniqId, $settings)); $document->addOnloadScript($js); $roles = BOL_AuthorizationService::getInstance()->findNonGuestRoleList(); $tplRoles = array(); foreach ($roles as $role) { /* @var $role BOL_AuthorizationRole */ $roleLabel = BOL_AuthorizationService::getInstance()->getRoleLabel($role->name); $tplRoles[] = array("id" => $role->id, "selected" => $roleId == $role->id, "label" => $roleLabel, "url" => OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute("uheader-settings-gallery"), array("role" => $role->id))); } $this->assign("currentRoleId", $roleId); $this->assign("roleList", $tplRoles); $this->assign("allListUrl", OW::getRouter()->urlForRoute("uheader-settings-gallery")); $this->assign("previewWidth", self::ITEM_WIDTH); $this->initInfoLines(); $this->assign("pluginUrl", UHEADER_CTRL_Admin::PLUGIN_STORE_URL); }