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.º 2
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.º 3
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.º 4
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.º 5
0
 public function __toString()
 {
     $action = \Admin\Core\Helper::getShortName($this);
     $action = str_replace("Action", "", $action);
     return $action;
 }
Exemplo n.º 6
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.º 7
0
 public function getGroups()
 {
     $this->init();
     $groups = array();
     $classes = $this->configurationManager->getClassesAnnotatedWith(array("active"));
     foreach ($this->settings["Beings"] as $being => $conf) {
         if (isset($conf["active"]) && $conf["active"] == true) {
             if (isset($conf["group"])) {
                 $classes[$being] = $conf["group"];
             } else {
                 $classes[$being] = $this->objectManager->getPackageKeyByObjectName($being);
             }
         }
     }
     foreach ($classes as $class => $packageName) {
         $configuration = $this->configurationManager->getClassConfiguration($class);
         $repository = $this->getRepositoryForModel($class);
         if (class_exists($repository)) {
             $group = $packageName;
             $name = \Admin\Core\Helper::getShortName($class);
             if (isset($configuration["group"])) {
                 $group = strval(current($configuration["group"]));
             }
             if (isset($configuration["label"])) {
                 $name = strval(current($configuration["label"]));
             }
             $groups[$group][] = array("being" => $class, "name" => $name);
         }
     }
     return $groups;
 }
Exemplo n.º 8
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;
 }