Exemplo n.º 1
0
 /**
  *
  *
  * @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", "");
     }
 }
Exemplo n.º 2
0
 /**
  * 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 __construct($view, \Admin\Core\Helper $helper, \TYPO3\FLOW3\Object\ObjectManagerInterface $objectManager)
 {
     $this->helper = $helper;
     $this->view = $view;
     $this->objectManager = $objectManager;
     $partial = $this->getName();
     $replacements = array("@partial" => $partial, "@package" => $this->helper->getPackageByClassName(get_class($this)), "@being" => \Admin\Core\Helper::getShortName(\Admin\Core\API::get("being")), "@action" => $partial);
     $template = $this->helper->getPathByPatternFallbacks("DashboardWidgets", $replacements);
     $this->view->setTemplatePathAndFilename($template);
     $this->initializeWidget();
 }
Exemplo n.º 4
0
 public function renderPartial($variant = "Default")
 {
     $replacements = array("@partial" => "Field", "@package" => \Admin\Core\API::get("package"), "@being" => \Admin\Core\Helper::getShortName(\Admin\Core\API::get("being")), "@action" => "Field", "@variant" => $variant);
     $cache = $this->cacheManager->getCache('Admin_TemplateCache');
     $identifier = str_replace("\\", "_", implode("-", $replacements));
     $identifier = str_replace(".", "_", $identifier);
     if (!$cache->has($identifier)) {
         $template = $this->helper->getPathByPatternFallbacks("Partials", $replacements);
         $cache->set($identifier, $template);
     } else {
         $template = $cache->get($identifier);
     }
     $this->view = $this->viewHelperVariableContainer->getView();
     $this->view->setTemplatePathAndFilename($template);
     return $this->view->render();
 }
Exemplo n.º 5
0
 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));
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 public function getFilter($selected = array())
 {
     $filters = array();
     foreach ($this->objects as $object) {
         $being = $this->helper->getBeing($object);
         foreach ($being->properties as $property) {
             if (isset($property->_filter)) {
                 if (!isset($filters[$property->name])) {
                     $filters[$property->name] = new \Admin\Core\Filter();
                 }
                 if (isset($selected[$property->name]) && $selected[$property->name] == $property->__toString()) {
                     $property->selected = true;
                 }
                 #$string = $property->getString();
                 #if(!empty($string))
                 $filters[$property->name]->addProperty($property);
             }
         }
     }
     return $filters;
 }
Exemplo n.º 8
0
 /**
  *
  * @param object $value
  * @param string $partial
  * @param string $fallbacks
  * @param array $vars
  * @param string $section
  * @param mixed $optional
  * @param string $variant
  * @return string Rendered string
  * @author Marc Neuhaus <*****@*****.**>
  * @api
  */
 public function render($value = '', $partial = '', $fallbacks = '', $vars = array(), $section = null, $optional = false, $variant = "Default")
 {
     if ($value !== '') {
         return $value;
     }
     if ($partial !== '') {
         if ($fallbacks !== '') {
             $replacements = array("@partial" => $partial, "@package" => \Admin\Core\API::get("package"), "@being" => \Admin\Core\Helper::getShortName(\Admin\Core\API::get("being")), "@action" => $partial, "@variant" => $variant);
             $cache = $this->cacheManager->getCache('Admin_TemplateCache');
             $identifier = str_replace("\\", "_", implode("-", $replacements));
             $identifier = str_replace(".", "_", $identifier);
             $identifier = str_replace("/", "_", $identifier);
             if (!$cache->has($identifier)) {
                 $template = $this->helper->getPathByPatternFallbacks($fallbacks, $replacements);
                 $cache->set($identifier, $template);
             } else {
                 $template = $cache->get($identifier);
             }
             if (empty($vars)) {
                 $this->view = $this->viewHelperVariableContainer->getView();
                 $this->view->setTemplatePathAndFilename($template);
                 if (!empty($template)) {
                     return $this->view->render();
                 }
             } else {
                 $partial = $this->parseTemplate($template);
                 $variableContainer = $this->objectManager->create('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', $vars);
                 $renderingContext = $this->buildRenderingContext($variableContainer);
                 return $partial->render($renderingContext);
             }
         }
     }
     if ($section !== null) {
         $output = $this->viewHelperVariableContainer->getView()->renderSection($section, $vars, $optional);
         if (strlen($output) < 1) {
             $output = $this->renderChildren();
         }
         return $output;
     }
 }
Exemplo n.º 9
0
 public function getIds()
 {
     $value = $this->getValue();
     $ids = array();
     if (\Admin\Core\Helper::isIteratable($value)) {
         foreach ($value as $object) {
             $ids[] = $this->parentProperty->adapter->getId($object);
         }
     } else {
         if (is_object($value)) {
             $ids[] = $this->parentProperty->adapter->getId($value);
         }
     }
     return $ids;
 }
Exemplo n.º 10
0
 public function getChildren()
 {
     if ($this->inline && empty($this->children)) {
         $values = $this->getValue();
         $beings = array();
         $amountOfInlines = 0;
         $realAction = \Admin\Core\API::get("action");
         \Admin\Core\API::set("action", "inline");
         if (\Admin\Core\Helper::isIteratable($values)) {
             foreach ($values as $value) {
                 if (is_object($value)) {
                     $id = $this->adapter->getId($value);
                     $being = $this->createBeing($this->being, $id);
                     $beings[] = $being;
                 }
                 $this->counter++;
             }
         } elseif (!empty($values) && is_object($values)) {
             $id = $this->adapter->getId($values);
             $being = $this->createBeing($this->being, $id);
             $beings[] = $being;
             $this->counter++;
         } else {
             $amountOfInlines = 1;
         }
         if ($this->mode == self::INLINE_MULTIPLE_MODE) {
             $amountOfInlines = 1;
         }
         for ($index = 0; $index < $amountOfInlines; $index++) {
             $being = $this->createBeing($this->being);
             if ($this->mode == self::INLINE_MULTIPLE_MODE) {
                 $being->unusedClass = "inline-unused";
             }
             $beings[] = $being;
             $this->counter++;
         }
         foreach ($beings as $key => $being) {
             $beings[$key]->parentProperty = $this;
         }
         \Admin\Core\API::set("action", $realAction);
         $this->children = $beings;
     }
     return $this->children;
 }
Exemplo n.º 11
0
 /**
  * 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);
     }
 }
Exemplo n.º 12
0
 /**
  * Actually convert from $source to $targetType, by doing a typecast.
  *
  * @param string $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration
  * @return float
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), \TYPO3\FLOW3\Property\PropertyMappingConfigurationInterface $configuration = NULL)
 {
     if (method_exists($source, "__toString")) {
         return strval($source);
     }
     if ($string = $this->getStringByAnnotation($source)) {
         return $string;
     }
     if ($string = $this->getStringByGuessing($source)) {
         return $string;
     }
     if ($string = $this->getStringByProperties($source)) {
         return $string;
     }
     if ($this->nestingLevel > 0) {
         return null;
     }
     return sprintf("Object (%s)", \Admin\Core\Helper::getShortName(get_class($this)));
 }
Exemplo n.º 13
0
 public function getActionByShortName($action = null)
 {
     $actions = array();
     foreach ($this->reflectionService->getAllImplementationClassNamesForInterface('Admin\\Core\\Actions\\ActionInterface') as $actionClassName) {
         $actionName = \Admin\Core\Helper::getShortName($actionClassName);
         if (strtolower($actionName) == strtolower($action)) {
             return $this->objectManager->create($actionClassName, $this->getAdapter(), $this->request, $this->view, $this);
         }
     }
     return null;
 }
Exemplo n.º 14
0
 public function __construct(\Admin\Core\Helper $helper)
 {
     $this->settings = $helper->getSettings();
 }
Exemplo n.º 15
0
 public function getRepositoryForModel($model)
 {
     $configuration = $this->configurationManager->getClassConfiguration($model);
     if (isset($configuration["repository"])) {
         $annotation = current($configuration["repository"]);
         $repository = $annotation->class;
     } else {
         $repository = \Admin\Core\Helper::getModelRepository($model);
     }
     return $repository;
 }
Exemplo n.º 16
0
 public function __toString()
 {
     if (is_object($this->objectManager)) {
         $reflectionService = $this->objectManager->get("TYPO3\\FLOW3\\Reflection\\ReflectionService");
         $class = get_class($this);
         if ($this instanceof \Doctrine\ORM\Proxy\Proxy) {
             $class = get_parent_class($this);
         }
         $properties = $reflectionService->getClassPropertyNames($class);
         $identity = array();
         $title = array();
         $goodGuess = null;
         $usualSuspects = array("title", "name");
         foreach ($properties as $property) {
             $tags = $reflectionService->getPropertyTagsValues($class, $property);
             if (in_array("title", array_keys($tags))) {
                 $title[] = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($this, $property);
             }
             if (in_array("identity", array_keys($tags))) {
                 $value = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($this, $property);
                 if (!is_object($value)) {
                     $identity[] = $value;
                 }
             }
             if (in_array($property, $usualSuspects) && $goodGuess === null) {
                 $value = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($this, $property);
                 if (!is_object($value)) {
                     $goodGuess[] = $value;
                 }
             }
         }
         if (count($title) > 0) {
             $string = implode(", ", $title);
         }
         if (count($identity) > 0 && empty($string)) {
             $string = implode(", ", $identity);
         }
         if ($goodGuess !== null && empty($string)) {
             $string = implode(",", $goodGuess);
         }
     } else {
         $myProperties = get_object_vars($this);
         $strings = array();
         foreach ($myProperties as $key => $value) {
             if (is_string($value) && $key !== "FLOW3_Persistence_Identifier") {
                 $strings[] = $value;
             }
         }
         $string = implode(", ", $strings);
     }
     if (empty($string)) {
         return sprintf("Object (%s)", \Admin\Core\Helper::getShortName(get_class($this)));
     } else {
         return $string;
     }
 }
Exemplo n.º 17
0
 /**
  * Initialize the Adapter
  *
  * @author Marc Neuhaus <*****@*****.**>
  * */
 public function init()
 {
     $this->settings = $this->helper->getSettings("Admin");
 }