/** * Show Documentation * * @param string $lang * @param string $doc * @param string $page * @return void * @author Marc Neuhaus */ public function indexAction($lang = "en", $doc = "Manual", $page = "index.html") { \Admin\Core\API::addTitleSegment("Documentation"); \Admin\Core\API::addTitleSegment($page); if ($this->request->hasArgument("subpage1")) { $c = 1; $directories = array($page); while ($c < 10) { if ($this->request->hasArgument("subpage" . $c)) { $directories[] = $this->request->getArgument("subpage" . $c); } else { break; } $c++; } $page = implode("/", $directories); } if (!stristr($page, ".html")) { $page .= ".html"; } $page = urldecode($page); if ($lang == "index") { $lang = "en"; } $package = $this->packageManager->getPackage("Admin"); $path = "resource://Admin/Private/Docs/"; $template = $path . $doc . "/" . $lang . "/html/" . $page; $this->view->setTemplatePathAndFilename($template); $this->view->assign("base", "/admin/doc/en/"); $content = $this->view->render(); $content = preg_replace('/internal" href="([A-Za-z0-9])/', 'internal" href="/admin/doc/' . $lang . '/\\1', $content); $content = str_replace('href="#', 'href="/admin/doc/' . $lang . '/' . $page . '#', $content); $content = str_replace('{ ', '{', $content); return $content; }
/** * 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); } } }
/** * * * @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", ""); } }
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(); }
/** * * @param string $file * @param string $dependencies * @return string */ public function render($add = null, $render = null) { if ($add !== null) { \Admin\Core\API::add("WidgetResources", $add, $this->renderChildren()); return ""; } if ($render !== null && $render == true) { $resources = \Admin\Core\API::get("WidgetResources"); if (is_array($resources)) { return implode("\n", $resources); } } }
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(); }
/** * Create objects * * @param string $being * @param array $ids * @author Marc Neuhaus <*****@*****.**> * */ public function execute($being, $ids = null) { $object = $this->adapter->getBeing($being); if ($this->request->hasArgument("create")) { $result = $this->adapter->createObject($being, $this->request->getArgument("item")); if (is_a($result, $being)) { $this->controller->addLog(); $arguments = array("being" => \Admin\Core\API::get("classShortNames", $being)); $this->controller->redirect('list', NULL, NULL, $arguments); } else { $object->setErrors($result); $object->setObject($this->request->getArgument("item")); } } $this->view->assign("being", $object); }
/** * Iterates through elements of $each and renders child nodes * * @param string $get * @param string $as * @return string Rendered string * @author Marc Neuhaus <*****@*****.**> * @api */ public function render($get, $as = null) { if ($as == null) { $as = $get; } if (\Admin\Core\API::has($get)) { $this->templateVariableContainer->add($as, \Admin\Core\API::get($get)); } elseif (is_callable("\\Admin\\Core\\Api::get" . ucfirst($get))) { $function = "get" . ucfirst($get); $result = call_user_func("\\Admin\\Core\\Api::get" . ucfirst($get)); $this->templateVariableContainer->add($as, $result); } $output = $this->renderChildren(); $this->templateVariableContainer->remove($as); return $output; }
/** * Delete objects * * @param string $being * @param array $ids * @author Marc Neuhaus <*****@*****.**> * */ public function execute($being, $ids = null) { $this->being = $being; $this->view->assign('className', $being); $this->settings = $this->getSettings(); $this->handleBulkActions(); $this->adapter->initQuery($being); $results = $this->adapter->getQuery()->execute(); $this->view->assign("objects", $results); // Redirect to creating a new Object if there aren't any (Clean Slate) if ($results->count() < 1) { $arguments = array("being" => \Admin\Core\API::get("classShortNames", $being)); $this->controller->redirect("create", NULL, NULL, $arguments); } $listActions = $this->controller->getActions("list", $being, true); $this->view->assign('listActions', $listActions); }
/** * Delete objects * * @param string $being * @param array $ids * @author Marc Neuhaus <*****@*****.**> * */ public function execute($being, $ids = null) { if (is_array($ids)) { if ($this->request->hasArgument("confirm")) { foreach ($ids as $id) { $this->adapter->deleteObject($being, $id); } $this->controller->addLog(); $arguments = array("being" => \Admin\Core\API::get("classShortNames", $being)); $this->controller->redirect('list', NULL, NULL, $arguments); } else { $arguments = $this->request->getArguments(); $arguments["id"] = implode(",", $ids); $this->controller->redirect('confirm', NULL, NULL, $arguments); } } }
/** * Edit objects * * @param string $being * @param array $ids * @author Marc Neuhaus <*****@*****.**> * */ public function execute($being, $ids = null) { if ($this->request->hasArgument("update")) { $result = $this->adapter->updateObject($being, current($ids), $this->request->getArgument("item")); if (is_a($result, $being)) { $arguments = array("being" => \Admin\Core\API::get("classShortNames", $being)); $this->controller->addLog(); $this->controller->redirect('list', NULL, NULL, $arguments); } else { # foreach ($attributeSets as $set => $attributes) { # foreach ($attributes as $key => $attribute) { # if(array_key_exists($attribute["name"],$errors)){ # $attributeSets[$set][$key]["error"] = $errors[$attribute["name"]]; # } # } # } } } $object = $this->adapter->getBeing($being, current($ids)); $this->view->assign("being", $object); }
/** * * @param string $position * @param mixed $items * @param string $as * @return string Rendered string * @author Marc Neuhaus <*****@*****.**> * @api */ public function render($position, $items = false, $as = "navBar") { if ($items == false) { # $items = $this->configurationManager->getConfiguration(\TYPO3\FLOW3\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $namespace); $items = \Admin\Core\API::getNagigationItems($position); } $content = ""; foreach ($items as $name => $arguments) { $arguments["arguments"] = array_merge($this->defaults, $arguments); $arguments = array_merge($this->defaults, $arguments); $variables = array("link" => $this->getLink($arguments["action"], $arguments["arguments"], $arguments["controller"], $arguments["package"], $arguments["subpackage"]), "name" => $name, "hasChildren" => false, "arguments" => $arguments, "children" => array()); if (count($arguments["children"]) > 0) { $variables["children"] = $this->render($position, $arguments["children"], $as); $variables["hasChildren"] = true; } $this->templateVariableContainer->add($as, $variables); $content .= $this->renderChildren(); $this->templateVariableContainer->remove($as); } return $content; }
/** * * @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; } }
/** * Render the link. * * @param string $action Target action * @param array $arguments Arguments * @param string $being * @param string $shortcut * @param string $selectionShortcut * @param string $controller Target controller. If NULL current controllerName is used * @param string $package Target package. if NULL current package is used * @param string $subpackage Target subpackage. if NULL current subpackage is used * @param string $section The anchor to be added to the URI * @param string $format The requested format, e.g. ".html" * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments) * @param boolean $addQueryString If set, the current query parameters will be kept in the URI * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE * @return string The rendered link * @api */ public function render($action = NULL, $arguments = array(), $being = NULL, $selectionShortcut = false, $shortcut = false, $controller = NULL, $package = NULL, $subpackage = NULL, $section = '', $format = '', array $additionalParams = array(), $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array(), $overrule = array()) { $uriBuilder = $this->controllerContext->getUriBuilder(); if ($being !== NULL) { $arguments["being"] = \Admin\Core\API::get("classShortNames", $being); } try { $uri = $uriBuilder->reset()->setSection($section)->setCreateAbsoluteUri(TRUE)->setArguments($additionalParams)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setFormat($format)->uriFor($action, $arguments, $controller, $package, $subpackage); $this->tag->addAttribute('href', $uri); if ($shortcut) { $this->tag->addAttribute("data-klove-shortcut", $shortcut); } if ($selectionShortcut) { $this->tag->addAttribute("data-klove-row-shortcut", $selectionShortcut); } } catch (\TYPO3\FLOW3\Exception $exception) { throw new \TYPO3\Fluid\Core\ViewHelper\Exception($exception->getMessage(), $exception->getCode(), $exception); } $this->tag->setContent($this->renderChildren()); $this->tag->forceClosingTag(TRUE); return $this->tag->render(); }
public function getArguments() { return array("id" => $this->getIdentity(), "being" => "Admin\\Security\\User", "adapter" => \Admin\Core\API::get("adapter")); }
public function addEditor($editor, $width = 500) { $editor = strtolower($editor); switch ($editor) { case 'bbcode': case 'dotclear': case 'markdown': case 'textile': case 'texy': case 'wiki': $markitup = '<script src="' . $this->getResourceUri('admin/js/markitup/jquery.markitup.pack.js') . '"></script> <link rel="stylesheet" type="text/css" href="' . $this->getResourceUri('admin/js/markitup/skins/simple/style.css') . '" />'; \Admin\Core\API::add("WidgetResources", "MarkItUp", $markitup); $settings = ' <script src="' . $this->getResourceUri('admin/js/markitup/sets/' . $editor . '/set.js') . '"></script> <link rel="stylesheet" type="text/css" href="' . $this->getResourceUri('admin/js/markitup/sets/' . $editor . '/style.css') . '" /> <script type="text/javascript" charset="utf-8"> jQuery(document).ready(function(){ jQuery("[data-editor=' . $editor . ']").markItUp(' . $editor . 'Settings); }); </script> <style type="text/css" media="screen"> .markItUpEditor {width: ' . $width . 'px;} </style> '; \Admin\Core\API::add("WidgetResources", $editor, $settings); break; case 'rte': case 'richtext': $html = ' <script src="' . $this->getResourceUri('admin/js/ckeditor/ckeditor.js') . '"></script> <script src="' . $this->getResourceUri('admin/js/ckeditor/adapters/jquery.js') . '"></script> <script type="text/javascript" charset="utf-8"> jQuery(document).ready(function(){ var config = { toolbar:[ ["Bold","Italic","Underline","Strike","-","Subscript","Superscript"], ["NumberedList", "BulletedList", "-", "Link", "Unlink"], ["Source"], ], width: ' . ($width + 15) . ' }; jQuery("[data-editor=richtext]").ckeditor(config); }); </script> '; \Admin\Core\API::add("WidgetResources", "richtext", $html); default: # code... break; } }
public function setTemplate($action) { $replacements = array("@action" => ucfirst($action), "@variant" => "Default", "@package" => "Admin"); if (!empty($this->being)) { if (class_exists($this->being, false)) { $replacements["@package"] = $this->helper->getPackageByClassName($this->being) ? $this->helper->getPackageByClassName($this->being) : "Admin"; $replacements["@being"] = \Admin\Core\Helper::getShortName($this->being); $being = $this->helper->getBeing($this->being); $replacements["@variant"] = $being->variant->getVariant($action); } } if ($this->request->hasArgument("variant")) { $replacements["@variant"] = $this->request->getArgument("variant"); } $cache = $this->cacheManager->getCache('Admin_TemplateCache'); $identifier = str_replace(".", "_", implode("-", $replacements)); $noTemplate = false; if (!$cache->has($identifier)) { try { $template = $this->helper->getPathByPatternFallbacks("Views", $replacements); } catch (\Exception $e) { $noTemplate = true; } if (!$noTemplate) { $cache->set($identifier, $template); } } else { $template = $cache->get($identifier); } if (!$noTemplate) { $this->view->setTemplatePathAndFilename($template); if ($this->request->hasArgument("being")) { $meta["being"]["identifier"] = $this->request->getArgument("being"); $meta["being"]["name"] = $this->request->getArgument("being"); \Admin\Core\API::set("package", $replacements["@package"]); } } }
public function getArguments() { return array("id" => $this->getIdentity(), "being" => get_class($this), "adapter" => \Admin\Core\API::get("adapter")); }
public function createBeing($being, $id = null) { $realAction = \Admin\Core\API::get("action"); \Admin\Core\API::set("action", "inline"); $b = $this->adapter->getBeing($this->being, $id); \Admin\Core\API::set("action", $realAction); $b->prefix = $this->getPrefix(); if (!empty($id)) { # $identity = array( $this->getPrefix() . "[__identity]" => $id ); $b->addHiddenProperty($this->getPrefix() . "[__identity]", $id); } return $b; }
/** * checks the conf if the element should be ignored * * @param string $conf * @return void * @author Marc Neuhaus */ public function shouldBeIgnored($annotations, $property) { if (in_array($property, explode(",", $this->ignoredProperties))) { return true; } if (isset($annotations["inject"])) { return true; } if (!isset($annotations["ignore"])) { return false; } else { $ignore = current($annotations["ignore"]); if (empty($ignore->views) || $ignore->views === true) { return true; } else { $actions = explode(",", $ignore->views); $action = \Admin\Core\API::get("action"); return in_array($action, $actions); } } return false; }