/** * This method provides a item detail view. * * @param string $tpl Name of alternative template (to be used instead of the default template). * @param boolean $raw Optional way to display a template instead of fetching it (required for standalone output). * * @return mixed Output. */ public function display() { $legacyControllerType = $this->request->query->filter('lct', 'user', FILTER_SANITIZE_STRING); System::queryStringSetVar('type', $legacyControllerType); $this->request->query->set('type', $legacyControllerType); $controllerHelper = new MUVideo_Util_Controller($this->serviceManager); // parameter specifying which type of objects we are treating $objectType = 'movie'; $utilArgs = array('controller' => 'movie', 'action' => 'display'); $permLevel = $legacyControllerType == 'admin' ? ACCESS_ADMIN : ACCESS_READ; $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', '::', $permLevel), LogUtil::getErrorMsgPermission()); $entityClass = $this->name . '_Entity_' . ucwords($objectType); $repository = $this->entityManager->getRepository($entityClass); $repository->setControllerArguments(array()); $idFields = ModUtil::apiFunc($this->name, 'selection', 'getIdFields', array('ot' => $objectType)); // retrieve identifier of the object we wish to view $idValues = $controllerHelper->retrieveIdentifier($this->request, array(), $objectType, $idFields); $hasIdentifier = $controllerHelper->isValidIdentifier($idValues); $this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.')); $selectionArgs = array('ot' => $objectType, 'id' => $idValues); $entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', $selectionArgs); $this->throwNotFoundUnless($entity != null, $this->__('No such item.')); unset($idValues); $entity->initWorkflow(); // build ModUrl instance for display hooks; also create identifier for permission check $currentUrlArgs = $entity->createUrlArgs(); $instanceId = $entity->createCompositeIdentifier(); $currentUrlArgs['id'] = $instanceId; // TODO remove this $currentUrlObject = new Zikula_ModUrl($this->name, 'movie', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs); $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucwords($objectType) . ':', $instanceId . '::', $permLevel), LogUtil::getErrorMsgPermission()); $viewHelper = new MUVideo_Util_View($this->serviceManager); $templateFile = $viewHelper->getViewTemplate($this->view, $objectType, 'display', array()); // set cache id $component = $this->name . ':' . ucwords($objectType) . ':'; $instance = $instanceId . '::'; $accessLevel = ACCESS_READ; if (SecurityUtil::checkPermission($component, $instance, ACCESS_COMMENT)) { $accessLevel = ACCESS_COMMENT; } if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) { $accessLevel = ACCESS_EDIT; } $this->view->setCacheId($objectType . '|' . $instanceId . '|a' . $accessLevel); // assign output data to view object. $this->view->assign($objectType, $entity)->assign('currentUrlObject', $currentUrlObject)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs)); // initialize $youtubeId = ''; // we get the id from the url $youtubeId = explode('=', $entity['urlOfYoutube']); // assign to template $this->view->assign('youtubeId', $youtubeId[1]); // fetch and return the appropriate template return $viewHelper->processTemplate($this->view, $objectType, 'display', array(), $templateFile); }
/** * This method takes care of the application configuration. * * @return string Output */ public function getVideos() { // DEBUG: permission check aspect starts $this->throwForbiddenUnless(SecurityUtil::checkPermission('MUVideo::', '::', ACCESS_EDIT)); // DEBUG: permission check aspect ends // parameter specifying which type of objects we are treating $objectType = isset($args['ot']) && !empty($args['ot']) ? $args['ot'] : $this->request->getGet()->filter('ot', 'collection', FILTER_SANITIZE_STRING); $utilArgs = array('controller' => 'user', 'action' => 'getVideos'); if (!in_array($objectType, MUVideo_Util_Controller::getObjectTypes('controllerAction', $utilArgs))) { $objectType = MUVideo_Util_Controller::getDefaultObjectType('controllerAction', $utilArgs); } // create new Form reference $view = FormUtil::newForm($this->name, $this); // build form handler class name $handlerClass = 'MUVideo_Form_Handler_' . ucfirst($objectType) . '_GetVideos'; // determine the output template $viewHelper = new MUVideo_Util_View($this->serviceManager); $template = $viewHelper->getViewTemplate($this->view, $objectType, 'getVideos', array()); // execute form using supplied template and page event handler return $view->execute($template, new $handlerClass()); }
/** * This method provides a handling of edit requests. * * @param string $tpl Name of alternative template (to be used instead of the default template). * @param boolean $raw Optional way to display a template instead of fetching it (required for standalone output). * * @return mixed Output. */ public function edit() { $legacyControllerType = $this->request->query->filter('lct', 'user', FILTER_SANITIZE_STRING); System::queryStringSetVar('type', $legacyControllerType); $this->request->query->set('type', $legacyControllerType); $controllerHelper = new MUVideo_Util_Controller($this->serviceManager); // parameter specifying which type of objects we are treating $objectType = 'movie'; $utilArgs = array('controller' => 'movie', 'action' => 'edit'); $permLevel = $legacyControllerType == 'admin' ? ACCESS_ADMIN : ACCESS_EDIT; $this->throwForbiddenUnless(SecurityUtil::checkPermission($this->name . ':' . ucfirst($objectType) . ':', '::', $permLevel), LogUtil::getErrorMsgPermission()); // create new Form reference $view = FormUtil::newForm($this->name, $this); // build form handler class name $handlerClass = $this->name . '_Form_Handler_Movie_Edit'; // determine the output template $viewHelper = new MUVideo_Util_View($this->serviceManager); $template = $viewHelper->getViewTemplate($this->view, $objectType, 'edit', array()); // execute form using supplied template and page event handler return $view->execute($template, new $handlerClass()); }