Пример #1
0
 /**
  *
  * @param object $object
  * @param string $className
  * @param string $as
  * @param string $ignore
  * @return string Rendered string
  * @author Marc Neuhaus <*****@*****.**>
  * @api
  */
 public function render($object = null, $className = null, $as = "being", $ignore = null)
 {
     if (is_null($object) && !is_null($className)) {
         $object = new $className();
     }
     $being = new \Admin\Core\Being($this->helper->getAdapterByBeing(get_class($object)));
     $being->ignoredProperties = $ignore;
     $being->setClass(get_class($object));
     $being->setObject($object);
     if ($this->viewHelperVariableContainer->exists('TYPO3\\Fluid\\ViewHelpers\\FormViewHelper', 'fieldNamePrefix')) {
         $being->prefix = $this->viewHelperVariableContainer->get('TYPO3\\Fluid\\ViewHelpers\\FormViewHelper', 'fieldNamePrefix');
     }
     $validationResults = $this->controllerContext->getRequest()->getOriginalRequestMappingResults();
     $being->setErrors($validationResults->forProperty($being->prefix));
     $this->templateVariableContainer->add($as, $being);
     $content = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $content;
 }
Пример #2
0
 private function prepare($action)
 {
     $this->start = microtime();
     $this->adapters = $this->helper->getAdapters();
     $this->settings = $this->helper->getSettings();
     \Admin\Core\API::set("classShortNames", $this->compileShortNames());
     \Admin\Core\API::set("action", $action);
     if ($this->request->hasArgument("being")) {
         $this->being = $this->request->getArgument("being");
         if (!stristr($this->being, "\\")) {
             $this->being = \Admin\Core\API::get("classShortNames", $this->being);
         }
         \Admin\Core\API::set("being", $this->being);
         $this->adapter = $this->helper->getAdapterByBeing($this->being);
         \Admin\Core\API::set("adapter", $this->adapter);
         $this->group = $this->helper->getGroupByBeing($this->being);
         \Admin\Core\API::set("group", $this->group);
     }
     if ($this->request->hasArgument("id")) {
         $this->id = $this->request->getArgument("id");
         if (is_array($this->id)) {
             $this->id = implode(",", $this->id);
         }
     }
     $user = $this->securityManager->getUser();
     if (!isset($user) || !is_object($user)) {
         $this->securityManager->redirectToLogin();
     } else {
         $allowedBeings = array("view" => array());
         try {
             foreach ($user->getRoles() as $role) {
                 foreach ($role->getGrant() as $policy) {
                     $allowedBeings[$policy->getAction()][] = $policy->getBeing();
                 }
             }
         } catch (\Doctrine\ORM\EntityNotFoundException $e) {
             unset($user);
             $this->securityManager->redirectToLogin();
         }
         $this->user = $user;
     }
     $groups = $this->helper->getGroups();
     ksort($groups);
     foreach ($groups as $package => $group) {
         foreach ($group["beings"] as $key => $being) {
             if (!in_array($being["being"], $allowedBeings["view"])) {
                 if (!$user->isAdmin()) {
                     unset($groups[$package]["beings"][$key]);
                 }
             }
             if (!empty($this->adapter)) {
                 if ($being["being"] == $this->being && $being["adapter"] == $this->adapter) {
                     $groups[$package]["beings"][$key]["active"] = true;
                 } else {
                     $groups[$package]["beings"][$key]["active"] = false;
                 }
             }
         }
         if (empty($groups[$package]["beings"])) {
             unset($groups[$package]);
         }
     }
     $this->view = $this->resolveView();
     \Admin\Core\API::set("user", $user);
     if ($this->view !== NULL) {
         $this->view->assign('settings', $this->settings);
         $this->initializeView($this->view);
     }
     $this->view->assign('groups', $groups);
     $this->setTemplate($action);
     $context = getenv("FLOW3_CONTEXT") ? getenv("FLOW3_CONTEXT") : "Production";
     $this->view->assign("context", $context);
     $hasId = isset($this->id) ? true : false;
     $topBarActions = $this->getActions($action, $this->being, $hasId);
     $this->view->assign('topBarActions', $topBarActions);
 }