/** * * * @return string */ public function indexAction() { \Admin\Core\API::addTitleSegment("Admin"); \Admin\Core\API::addTitleSegment("Login"); $users = $this->userRepository->findAll(); if ($users->count() < 1 || $this->helper->getSettings("Admin.DemoMode")) { $user = $this->objectManager->get("Admin\\Security\\User"); $username = "******"; if ($users->count() > 0) { $username .= $users->count() + 1; } $user->setAccountIdentifier($username); $user->setCredentialsSource("password"); $user->setAdmin(true); $this->userRepository->add($user); $message = new \TYPO3\FLOW3\Error\Message('A User has been Created: ' . $username . '/password'); $this->flashMessageContainer->addMessage($message); $message = new \TYPO3\FLOW3\Error\Warning('Please Change the Passwort after Login!'); $this->flashMessageContainer->addMessage($message); $this->view->assign("username", $username); $this->view->assign("password", "password"); } else { $this->view->assign("username", ""); $this->view->assign("password", ""); } }
/** * Add the Annotated Method to the Navigation * * @param \TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint * @FLOW3\Before("method(public .*\Controller\.*Controller->.*Action(.*))") * @return void */ public function addNavigationitem(\TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint) { $currentClassName = $joinPoint->getClassName(); $currentMethodName = $joinPoint->getMethodName(); $controllers = $this->reflectionService->getAllSubClassNamesForClass("\\TYPO3\\FLOW3\\MVC\\Controller\\ActionController"); foreach ($controllers as $className) { $methods = get_class_methods($className); if (is_array($methods)) { foreach ($methods as $methodName) { if ($this->reflectionService->isMethodAnnotatedWith($className, $methodName, "Admin\\Annotations\\Navigation")) { $annotations = $this->reflectionService->getMethodAnnotations($className, $methodName, "Admin\\Annotations\\Navigation"); foreach ($annotations as $annotation) { $action = str_replace("Action", "", $methodName); $controller = $this->helper->getControllerByClassName($className); $package = $this->objectManager->getPackageKeyByObjectName($className); $arguments = array("action" => $action, "controller" => $controller, "package" => $package); $title = !is_null($annotation->title) ? $annotation->title : sprintf("%s (%s)", $controller, $action); \Admin\Core\API::addNavigationitem($title, $annotation->position, $arguments, $annotation->priority, $annotation->parent); } } } } } $settings = $this->helper->getSettings("Admin.Navigation"); foreach ($settings as $position => $items) { foreach ($items as $title => $conf) { $priority = isset($conf["priority"]) ? $conf["priority"] : 100; $arguments = $conf["Arguments"]; \Admin\Core\API::addNavigationitem($title, strtolower($position), $arguments, $priority); } } }
public function getSettings($path = null) { $paths = array("Admin.ViewSettings"); $paths[] = ucfirst($this->getAction()); if (!is_null($path)) { $paths[] = $path; } return $this->helper->getSettings(implode(".", $paths)); }
public function getWidget() { $raw = $this->type; $widget = null; $default = "Textfield"; $mappings = $this->helper->getSettings("Admin.Mapping.Widgets"); if (!empty($mappings)) { if (isset($this->widget)) { $widget = $this->widget->name; } if (isset($this->editor)) { $widget = "Textarea"; } if ($widget === null && isset($mappings[$raw])) { $widget = $mappings[$raw]; } if ($widget === null && isset($mappings[strtolower($raw)])) { $widget = $mappings[$raw]; } if ($widget === null && isset($mappings[ucfirst($raw)])) { $widget = $mappings[$raw]; } if ($widget === null) { foreach ($mappings as $pattern => $widget) { if (preg_match("/" . $pattern . "/", $raw) > 0) { break; } } } } if ($widget === null && $default !== null) { $widget = $default; } if ($widget === null) { $widget = $raw; } return $widget; }
public function __construct(\Admin\Core\Helper $helper) { $this->settings = $helper->getSettings(); }
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); }
/** * Schedules a modified object for persistence. * * @param object $object The modified object * @throws \TYPO3\FLOW3\Persistence\Exception\IllegalObjectTypeException * @api */ public function remove($object) { if (!$this->helper->isDemoMode() || $object->__toString() != $this->helper->getSettings("Admin.SuperAdmin")) { parent::remove($object); } }
/** * Initialize the Adapter * * @author Marc Neuhaus <*****@*****.**> * */ public function init() { $this->settings = $this->helper->getSettings("Admin"); }