예제 #1
0
 /**
  * Renders menu
  *
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 public function render(ItemInterface $item, array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     if ($options['clear_matcher']) {
         $this->matcher->clear();
     }
     //render html
     $html = $this->engine->render($options['template'], array('item' => $item, 'options' => $options, 'matcher' => $this->matcher));
     return $html;
 }
예제 #2
0
 /**
  * Renders menu
  *
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 public function render(ItemInterface $item, array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     if ($options['clear_matcher']) {
         $this->matcher->clear();
     }
     $manipulator = new MenuManipulator();
     if ($options["menu"] == "admin") {
         //render html
         $html = $this->engine->render("MauticCoreBundle:Menu:admin.html.php", array("item" => $item, "options" => $options, "matcher" => $this->matcher));
     } else {
         //render html
         $html = $this->engine->render("MauticCoreBundle:Menu:main.html.php", array("item" => $item, "options" => $options, "matcher" => $this->matcher));
     }
     return $html;
 }
예제 #3
0
 /**
  * Send invite email to new user
  *
  * @param User   $user
  * @param string $plainPassword
  *
  * @throws \RuntimeException
  */
 protected function sendInviteMail(User $user, $plainPassword)
 {
     if (in_array(null, [$this->cm, $this->mailer, $this->templating], true)) {
         throw new \RuntimeException('Unable to send invitation email, unmet dependencies detected.');
     }
     $senderEmail = $this->cm->get('oro_notification.email_notification_sender_email');
     $senderName = $this->cm->get('oro_notification.email_notification_sender_name');
     $message = \Swift_Message::newInstance()->setSubject('Invite user')->setFrom($senderEmail, $senderName)->setTo($user->getEmail())->setBody($this->templating->render('OroUserBundle:Mail:invite.html.twig', ['user' => $user, 'password' => $plainPassword]), 'text/html');
     $this->mailer->send($message);
 }
예제 #4
0
 /**
  * @param $c
  * @param $buttonCount
  *
  * @return string
  */
 public function buildCustom($c, $buttonCount)
 {
     $buttons = '';
     //Wrap links in a tag
     if ($this->groupType == 'dropdown' || $this->groupType == 'button-dropdown' && $buttonCount > 0) {
         $this->wrapOpeningTag = "<li>\n";
         $this->wrapClosingTag = "</li>\n";
     }
     if (isset($c['confirm'])) {
         if ($this->groupType == 'group' || $this->groupType == 'button-dropdown' && $buttonCount === 0) {
             if (isset($c['confirm']['btnClass']) && !strstr($c['confirm']['btnClass'], 'btn-')) {
                 $c['confirm']['btnClass'] .= ' btn btn-default';
             } elseif (!isset($c['confirm']['btnClass'])) {
                 $c['confirm']['btnClass'] = 'btn btn-default';
             }
         } elseif (in_array($this->groupType, array('button-dropdown', 'dropdown'))) {
             if (!isset($c['confirm']['btnClass'])) {
                 $c['confirm']['btnClass'] = '';
             } elseif ($this->groupType == 'button-dropdown') {
                 $search = array('btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn');
                 $c['confirm']['btnClass'] = str_replace($search, '', $c['attr']['class']);
             }
         }
         $buttons .= $this->wrapOpeningTag . $this->templating->render('MauticCoreBundle:Helper:confirm.html.php', $c['confirm']) . "{$this->wrapClosingTag}\n";
     } else {
         $attr = $this->menuLink;
         if (!isset($c['attr'])) {
             $c['attr'] = array();
         }
         if (isset($c['btnClass'])) {
             $c['attr']['class'] = $c['btnClass'];
         }
         if ($this->groupType == 'group' || $this->groupType == 'button-dropdown' && $buttonCount === 0) {
             if (!isset($c['attr']['class'])) {
                 $c['attr']['class'] = 'btn btn-default';
             } elseif (!strstr($c['attr']['class'], 'btn-')) {
                 $c['attr']['class'] .= ' btn btn-default';
             }
         } elseif (($this->groupType == 'dropdown' || $this->groupType == 'button-dropdown' && $buttonCount > 0) && isset($c['attr']['class'])) {
             // Remove btn classes
             $search = array('btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn');
             $c['attr']['class'] = str_replace($search, '', $c['attr']['class']);
         }
         if (!isset($c['attr']['data-toggle'])) {
             $c['attr']['data-toggle'] = 'ajax';
         }
         $tooltipAttr = '';
         if (isset($c['tooltip'])) {
             $tooltipAttr .= ' data-toggle="tooltip"';
             if (is_array($c['tooltip'])) {
                 foreach ($c['tooltip'] as $k => $v) {
                     if ($k == 'title') {
                         $v = $this->translator->trans($v);
                     }
                     $tooltipAttr .= " {$k}=" . '"' . $v . '"';
                 }
             } else {
                 $tooltipAttr .= ' title="' . $this->translator->trans($c['tooltip']) . '" data-placement="left"';
             }
         }
         foreach ($c['attr'] as $k => $v) {
             $attr .= " {$k}=" . '"' . $v . '"';
         }
         $buttonContent = isset($c['iconClass']) ? '<i class="' . $c['iconClass'] . '"></i> ' : '';
         if (!empty($c['btnText'])) {
             $buttonContent .= $this->translator->trans($c['btnText']);
         }
         $buttons .= "{$this->wrapOpeningTag}<a{$attr}><span{$tooltipAttr}>{$buttonContent}</span></a>{$this->wrapClosingTag}\n";
     }
     return $buttons;
 }