getBackendURLForBlock() public static method

Creates a Backend URL for a given action and module If you don't specify a language the current language will be used.
public static getBackendURLForBlock ( string $action, string $module, string $language = null, array $parameters = null, boolean $urlencode = true ) : string
$action string The action to build the URL for.
$module string The module to build the URL for.
$language string The language to use, if not provided we will use the working language.
$parameters array GET-parameters to use.
$urlencode boolean Should the parameters be urlencoded?
return string
示例#1
0
文件: Model.php 项目: forkcms/forkcms
 /**
  * Notify the admin
  *
  * @param array $comment The comment that was submitted.
  */
 public static function notifyAdmin(array $comment)
 {
     // don't notify admin in case of spam
     if ($comment['status'] == 'spam') {
         return;
     }
     // get settings
     $notifyByMailOnComment = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment', false);
     $notifyByMailOnCommentToModerate = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment_to_moderate', false);
     // create URLs
     $url = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail') . '/' . $comment['post_url'] . '#comment-' . $comment['id'];
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('comments', 'Blog') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnComment) {
         // init var
         $variables = null;
         // comment to moderate
         if ($comment['status'] == 'moderation') {
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $url, $comment['post_title'], $backendURL));
         } elseif ($comment['status'] == 'published') {
             // comment was published
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewComment'), array($comment['author'], $url, $comment['post_title']));
         }
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml('/Core/Layout/Templates/Mails/Notification.html.twig', $variables, true);
         FrontendModel::get('mailer')->send($message);
     } elseif ($notifyByMailOnCommentToModerate && $comment['status'] == 'moderation') {
         // only notify on new comments to moderate and if the comment is one to moderate
         // set variables
         $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $url, $comment['post_title'], $backendURL));
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml('/Core/Layout/Templates/Mails/Notification.html.twig', $variables, true);
         FrontendModel::get('mailer')->send($message);
     }
 }
示例#2
0
 /**
  * Notify the admin
  *
  * @param array $comment The comment that was submitted.
  */
 public static function notifyAdmin(array $comment)
 {
     // don't notify admin in case of spam
     if ($comment['status'] == 'spam') {
         return;
     }
     // build data for push notification
     if ($comment['status'] == 'moderation') {
         $key = 'BLOG_COMMENT_MOD';
     } else {
         $key = 'BLOG_COMMENT';
     }
     $author = $comment['author'];
     if (mb_strlen($author) > 20) {
         $author = mb_substr($author, 0, 19) . '…';
     }
     $text = $comment['text'];
     if (mb_strlen($text) > 50) {
         $text = mb_substr($text, 0, 49) . '…';
     }
     $alert = array('loc-key' => $key, 'loc-args' => array($author, $text));
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'id' => $comment['id']);
     // push it
     FrontendModel::pushToAppleApp($alert, null, 'default', $data);
     // get settings
     $notifyByMailOnComment = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment', false);
     $notifyByMailOnCommentToModerate = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment_to_moderate', false);
     // create URLs
     $URL = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail') . '/' . $comment['post_url'] . '#comment-' . $comment['id'];
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('comments', 'Blog') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnComment) {
         // init var
         $variables = null;
         // comment to moderate
         if ($comment['status'] == 'moderation') {
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL));
         } elseif ($comment['status'] == 'published') {
             // comment was published
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewComment'), array($comment['author'], $URL, $comment['post_title']));
         }
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', $variables, true);
         FrontendModel::get('mailer')->send($message);
     } elseif ($notifyByMailOnCommentToModerate && $comment['status'] == 'moderation') {
         // only notify on new comments to moderate and if the comment is one to moderate
         // set variables
         $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL));
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', $variables, true);
         FrontendModel::get('mailer')->send($message);
     }
 }
示例#3
0
 /**
  * Notify the admin
  *
  * @param array $subscription The subscription that was submitted.
  */
 public static function notifyAdmin(array $subscription)
 {
     // don't notify admin in case of spam
     if ($subscription['status'] == 'spam') {
         return;
     }
     // build data for push notification
     if ($subscription['status'] == 'moderation') {
         $key = 'AGENDA_SUBSCRIPTION_MOD';
     } else {
         $key = 'AGENDA_SUBSCRIPTION';
     }
     $name = $subscription['name'];
     if (mb_strlen($name) > 20) {
         $name = mb_substr($name, 0, 19) . '…';
     }
     $alert = array('loc-key' => $key, 'loc-args' => array($name));
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'id' => $subscription['id']);
     // push it
     FrontendModel::pushToAppleApp($alert, null, 'default', $data);
     // get settings
     $notifyByMailOnSubscription = FrontendModel::get('fork.settings')->get('Agenda', 'notify_by_email_on_new_subscription', false);
     $notifyByMailOnSubscription = FrontendModel::get('fork.settings')->get('Agenda', 'notify_by_email_on_new_subscription_to_moderate', false);
     // create URLs
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('subscriptions', 'agenda') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnSubscription) {
         // init var
         $message = null;
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         if ($subscription['status'] == 'moderation') {
             $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'), array($subscription['name'], $subscription['agenda_title'], $backendURL))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         } elseif ($subscription['status'] == 'published') {
             $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscription'), array($subscription['name'], $subscription['agenda_title']))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         }
         FrontendModel::get('mailer')->send($message);
         // send the mail
         //            FrontendModel::get('mailer')->addEmail(
         //                FL::msg('NotificationSubject'),
         //                FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl',
         //                $variables,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                true
         //            );
     } elseif ($notifyByMailOnSubscriptionToModerate && $subscription['status'] == 'moderation') {
         $message = null;
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'), array($subscription['name'], $subscription['agenda_title'], $backendURL))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         FrontendModel::get('mailer')->send($message);
         // set variables
         //            $variables['message'] = vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'),
         //                array($subscription['name'], $subscription['agenda_title'], $backendURL));
         //
         //            // send the mail
         //            FrontendModel::get('mailer')->addEmail(
         //                FL::msg('NotificationSubject'),
         //                FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl',
         //                $variables,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                true
         //            );
     }
 }