/** * @param int $page * * @return string */ public function getTokenContent($page = 1) { if (!$this->factory->getSecurity()->isGranted('lead:fields:full')) { return; } $session = $this->factory->getSession(); //set limits $limit = 5; $start = $page === 1 ? 0 : ($page - 1) * $limit; if ($start < 0) { $start = 0; } $request = $this->factory->getRequest(); $search = $request->get('search', $session->get('mautic.lead.emailtoken.filter', '')); $session->set('mautic.lead.emailtoken.filter', $search); $filter = array('string' => $search, 'force' => array(array('column' => 'f.isPublished', 'expr' => 'eq', 'value' => true))); $fields = $this->factory->getModel('lead.field')->getEntities(array('start' => $start, 'limit' => $limit, 'filter' => $filter, 'orderBy' => 'f.label', 'orderByDir' => 'ASC', 'hydration_mode' => 'HYDRATE_ARRAY')); $count = count($fields); if ($count && $count < $start + 1) { //the number of entities are now less then the current page so redirect to the last page if ($count === 1) { $page = 1; } else { $page = ceil($count / $limit) ?: 1; } $session->set('mautic.lead.emailtoken.page', $page); } return $this->factory->getTemplating()->render('MauticLeadBundle:SubscribedEvents\\EmailToken:list.html.php', array('items' => $fields, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search)); }
/** * @param MatcherInterface $matcher * @param MauticFactory $factory * @param string $charset * @param array $defaultOptions */ public function __construct(MatcherInterface $matcher, MauticFactory $factory, $charset, array $defaultOptions = array()) { $this->engine = $factory->getTemplating(); $this->matcher =& $matcher; $this->defaultOptions = array_merge(array('depth' => null, 'matchingDepth' => null, 'currentAsLink' => true, 'currentClass' => 'active', 'ancestorClass' => 'open', 'firstClass' => 'first', 'lastClass' => 'last', 'template' => 'MauticCoreBundle:Menu:main.html.php', 'compressed' => false, 'allow_safe_labels' => false, 'clear_matcher' => true), $defaultOptions); $this->charset = $charset; }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->factory = $factory; $this->templating = $factory->getTemplating(); $this->request = $factory->getRequest(); $this->security = $factory->getSecurity(); $this->serializer = $factory->getSerializer(); $this->params = $factory->getSystemParameters(); $this->dispatcher = $factory->getDispatcher(); $this->translator = $factory->getTranslator(); $this->init(); }
/** * @param Form $form * @param Asset $asset * @param MauticFactory $factory * @param $message * @param $messageMode * * @return RedirectResponse|Response */ public static function downloadFile(Form $form, Asset $asset, MauticFactory $factory, $message, $messengerMode) { /** @var \Mautic\AssetBundle\Model\AssetModel $model */ $model = $factory->getModel('asset'); $url = $model->generateUrl($asset, true, array('form', $form->getId())); if ($messengerMode) { return array('download' => $url); } $msg = $message . $factory->getTranslator()->trans('mautic.asset.asset.submitaction.downloadfile.msg', array('%url%' => $url)); $content = $factory->getTemplating()->renderResponse('MauticCoreBundle::message.html.php', array('message' => $msg, 'type' => 'notice', 'template' => $factory->getParameter('theme')))->getContent(); return new Response($content); }
/** * Use a template as the body * * @param string $template * @param array $vars * @param bool $returnContent * @param null $charset * * @return void */ public function setTemplate($template, $vars = array(), $returnContent = false, $charset = null) { if ($this->templating == null) { $this->templating = $this->factory->getTemplating(); } $content = $this->templating->renderResponse($template, $vars)->getContent(); unset($vars); if ($returnContent) { return $content; } $this->setBody($content, 'text/html', $charset); unset($content); }
/** * Sets a specific theme for the form * * @param Form $form * @param string $template * @param mixed $theme * * @return \Symfony\Component\Form\FormView */ protected function setFormTheme(Form $form, $template, $theme = null) { $formView = $form->createView(); if (empty($theme)) { return $formView; } $templating = $this->factory->getTemplating(); if ($templating instanceof DelegatingEngine) { $templating->getEngine($template)->get('form')->setTheme($formView, $theme); } else { $templating->get('form')->setTheme($formView, $theme); } return $formView; }
/** * @param int $page * @param array $entityArguments * @param array $viewParameters * * @return string */ public function getTokenContent($page = 1, $entityArguments = array(), $viewParameters = array()) { if (is_array($page)) { // Laziness $entityArguments = $page; $page = 1; } //set some permissions $permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY"); if (in_array(false, $permissions)) { return; } $session = $this->factory->getSession(); //set limits $limit = 5; $start = $page === 1 ? 0 : ($page - 1) * $limit; if ($start < 0) { $start = 0; } $request = $this->factory->getRequest(); $search = $request->get('search', $session->get('mautic' . $this->langVar . 'buildertoken.filter', '')); $session->set('mautic' . $this->langVar . 'buildertoken.filter', $search); $model = $this->factory->getModel($this->modelName); $repo = $model->getRepository(); $prefix = $repo->getTableAlias(); if (!empty($prefix)) { $prefix .= '.'; } $filter = array('string' => $search); $filter['force'] = isset($entityArguments['filter']['force']) ? $entityArguments['filter']['force'] : array(); if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) { $filter['force'][] = array('column' => $prefix . 'createdBy', 'expr' => 'eq', 'value' => $this->factory->getUser()->getId()); } $entityArguments['filter'] = $filter; $entityArguments = array_merge(array('start' => $start, 'limit' => $limit, 'orderByDir' => 'DESC'), $entityArguments); $items = $model->getEntities($entityArguments); $count = count($items); if ($count && $count < $start + 1) { //the number of entities are now less then the current page so redirect to the last page if ($count === 1) { $page = 1; } else { $page = ceil($count / $limit) ?: 1; } $session->set('mautic' . $this->langVar . 'buildertoken.page', $page); } return $this->factory->getTemplating()->render($this->bundleName . ':SubscribedEvents\\BuilderToken:list.html.php', array_merge($viewParameters, array('items' => $items, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search))); }
/** * @param Form $form * @param Asset $asset * @param MauticFactory $factory * @param $message * @param $messageMode * * @return RedirectResponse|Response */ public static function downloadFile(Form $form, Asset $asset, MauticFactory $factory, $message, $messengerMode) { /** @var \Mautic\AssetBundle\Model\AssetModel $model */ $model = $factory->getModel('asset'); $url = $model->generateUrl($asset, true, ['form', $form->getId()]); if ($messengerMode) { return ['download' => $url]; } $msg = $message . $factory->getTranslator()->trans('mautic.asset.asset.submitaction.downloadfile.msg', ['%url%' => $url]); $analytics = $factory->getHelper('template.analytics')->getCode(); if (!empty($analytics)) { $factory->getHelper('template.assets')->addCustomDeclaration($analytics); } $logicalName = $factory->getHelper('theme')->checkForTwigTemplate(':' . $factory->getParameter('theme') . ':message.html.php'); $content = $factory->getTemplating()->renderResponse($logicalName, ['message' => $msg, 'type' => 'notice', 'template' => $factory->getParameter('theme')])->getContent(); return new Response($content); }
/** * Gets an array of the HTML for share buttons */ public function getShareButtons() { static $shareBtns = array(); if (empty($shareBtns)) { $socialIntegrations = $this->getIntegrationObjects(null, array('share_button'), true); $templating = $this->factory->getTemplating(); /** * @var string $integration * @var \Mautic\PluginBundle\Integration\AbstractIntegration $details */ foreach ($socialIntegrations as $integration => $details) { /** @var \Mautic\PluginBundle\Entity\Integration $settings */ $settings = $details->getIntegrationSettings(); $featureSettings = $settings->getFeatureSettings(); $apiKeys = $details->decryptApiKeys($settings->getApiKeys()); $plugin = $settings->getPlugin(); $shareSettings = isset($featureSettings['shareButton']) ? $featureSettings['shareButton'] : array(); //add the api keys for use within the share buttons $shareSettings['keys'] = $apiKeys; $shareBtns[$integration] = $templating->render($plugin->getBundle() . ":Integration/{$integration}:share.html.php", array('settings' => $shareSettings)); } } return $shareBtns; }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->templating = $factory->getTemplating(); $this->translator = $factory->getTranslator(); }