예제 #1
0
    private function sendNotificationEmail($list,$user,$criteria){
        $app_email_name = Yii::app()->params['app_email_name'];
        $app_email = Yii::app()->params['app_email'];
        $email_prefix = Yii::app()->params['email_prefix'];
        $headers = "From: $app_email_name <$app_email>\r\n"; //optional header fields
        $headers .= "Content-type: text/html\r\n";
        ini_set('sendmail_from', $app_email);

        $listurl="";
        foreach ($list as $key => $value) {
            $model = Dataset::model()->findByPk($value);
            $url = Yii::app()->params['home_url']."/dataset/".$model->identifier;
            $author_list = '';
            if (count($model->authors) > 0) {
                  $i = 0;
                foreach( $model->authors as $key => $author){
                    if (++$i < count($model->authors)) $author_list .= $author->name.';'; else $author_list .= $author->name.' ';
                }
            }
            $listurl .= <<<EO_LU
<span style='font-weight:bold;'>{$model->title}</span><br>
{$author_list}<br>
<a href='{$url}'>{$url}</a><br><br>
EO_LU;
        }

        $recipient = Yii::app()->params['notify_email'];
        $subject = "GigaDB has new content which matches your interest";

        $body = CController::renderInternal(Yii::app()->basePath.'/views/search/emailMatchedSearches.php',array('listurl'=>$listurl,'criteria'=>$criteria),true);

        mail($user->email, $subject, $body, $headers);
        Yii::log(__FUNCTION__."> Sent email to $recipient, $subject");
    }
예제 #2
0
 public static function getPlainTextVersion($message, $params)
 {
     $path = Yii::getPathOfAlias(Yii::app()->mail->viewPath);
     $plainViewPath = $path . DIRECTORY_SEPARATOR . $message->view . '.plain.php';
     if (!file_exists($plainViewPath)) {
         return strip_tags(strtr($message->getBody(), array("\t" => '', '&nbsp;' => ' ', '<br>' => "\n", '<br/>' => "\n", '<br />' => "\n", '</p>' => "\n\n")));
     }
     if (isset(Yii::app()->controller)) {
         $controller = Yii::app()->controller;
     } else {
         $controller = new CController('YiiMail');
     }
     $body = $controller->renderInternal($plainViewPath, $params, true);
     $footer = $controller->renderInternal($path . DIRECTORY_SEPARATOR . 'footer.plain.php', null, true);
     return $body . PHP_EOL . PHP_EOL . $footer;
 }
예제 #3
0
 public function renderMessage($view, array $data = array())
 {
     $controller = new \CController('SmsSender');
     $viewPath = \Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
     $viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
     $body = $controller->renderInternal($viewFile, $data, true);
     return $body;
 }
 public function generate()
 {
     $model = new MainAccountModel();
     $model->save();
     $ccc = new CController('context');
     $fileName = tempnam(sys_get_temp_dir(), "asd");
     $fileName .= ".html";
     $htmlOutput = $ccc->renderInternal(Yii::getPathOfAlias("application.views.templates") . '/index.php', $model->attributes, true);
     file_put_contents($fileName, $htmlOutput);
     return $fileName;
 }
예제 #5
0
 /**
  * Set the body of this entity, either as a string, or array of view
  * variables if a view is set, or as an instance of
  * {@link Swift_OutputByteStream}.
  *
  * @param mixed the body of the message.  If a $this->view is set and this
  * is a string, this is passed to the view as $body.  If $this->view is set
  * and this is an array, the array values are passed to the view like in the
  * controller render() method
  * @param string content type optional. For html, set to 'html/text'
  * @param string charset optional
  */
 public function setBody($body = '', $contentType = null, $charset = null)
 {
     if ($this->view !== null) {
         if (!is_array($body)) {
             $body = array('body' => $body);
         }
         // if Yii::app()->controller doesn't exist create a dummy
         // controller to render the view (needed in the console app)
         if (isset(Yii::app()->controller)) {
             $controller = Yii::app()->controller;
         } else {
             $controller = new CController('YiiMail');
         }
         // File Path to Template
         $viewPath = "";
         // Name of current theme if enabled
         $themeName = "";
         if (Yii::app() instanceof CConsoleApplication) {
             if (Yii::app()->theme && Yii::app()->theme != "") {
                 $themeName = Yii::app()->theme;
             }
         } else {
             // WebApplication
             if (($theme = Yii::app()->getTheme()) !== null) {
                 $themeName = $theme->getName();
             }
         }
         // When ThemeName is speified
         if ($themeName != "") {
             $viewThemed = str_replace('application.views.', 'webroot.themes.' . $themeName . '.views.', $this->view);
             $viewThemed = preg_replace('/application\\.modules(?:_core)?\\.(.*?)\\.views\\.(.*)/i', 'webroot.themes.' . $themeName . '.views.\\1.\\2', $viewThemed);
             if (file_exists(Yii::getPathOfAlias($viewThemed) . ".php")) {
                 $viewPath = Yii::getPathOfAlias($viewThemed) . ".php";
             }
         }
         // Use orginal view name, if not set yet
         if ($viewPath == "") {
             $viewPath = Yii::getPathOfAlias($this->view) . ".php";
         }
         $body = $controller->renderInternal($viewPath, array_merge($body, array('mail' => $this)), true);
     }
     return $this->message->setBody($body, $contentType, $charset);
 }
예제 #6
0
 public function setBody($body = '', $contentType = null, $charset = null)
 {
     if ($this->view !== null) {
         if (!is_array($body)) {
             $body = array('body' => $body);
         }
         // if Yii::app()->controller doesn't exist create a dummy
         // controller to render the view (needed in the console app)
         if (isset(Yii::app()->controller)) {
             $controller = Yii::app()->controller;
         } else {
             $controller = new CController('YiiMail');
         }
         // renderPartial won't work with CConsoleApplication, so use
         // renderInternal - this requires that we use an actual path to the
         // view rather than the usual alias
         $viewPath = Yii::app()->theme->getBasePath() . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . Yii::app()->mail->viewPath . DIRECTORY_SEPARATOR . $this->view . '.php';
         $body = $controller->renderInternal($viewPath, array_merge($body, array('mail' => $this)), true);
     }
     return $this->message->setBody($body, $contentType, $charset);
 }
예제 #7
0
 /**
  * Render the view file
  * @param string $viewName Name of the view
  * @param array $viewData Data for extraction
  * @return string The rendered result
  * @throws CException
  */
 public function renderView($viewName, $viewData = null)
 {
     //resolve the file name
     if (($viewFile = $this->getViewFile($viewName)) !== false) {
         //use controller instance if available or create dummy controller for console applications
         if (isset(Yii::app()->controller)) {
             $controller = Yii::app()->controller;
         } else {
             $controller = new CController(__CLASS__);
         }
         //render and return the result
         return $controller->renderInternal($viewFile, $viewData, true);
     } else {
         //file name does not exist
         throw new CException('View "' . $viewName . '" does not exist!');
     }
 }
예제 #8
0
파일: MailgunYii.php 프로젝트: newga/newga
 /**
  * Render message view
  * @param $view
  * @param array $params
  * @return string
  */
 protected function _render($view, $params = array())
 {
     if (isset(Yii::app()->controller)) {
         $controller = Yii::app()->controller;
     } else {
         $controller = new CController(get_class());
     }
     $viewPath = Yii::app()->findLocalizedFile(Yii::getPathOfAlias($this->_viewPath . '.' . $view) . '.php');
     return $controller->renderInternal($viewPath, $params, true);
 }
예제 #9
0
 /**
  * @param $model CModel
  * @param $attribute string
  * @param array $htmlOptions array
  * @return string
  */
 public static function checkBox($model, $attribute, $htmlOptions = array())
 {
     return CController::renderInternal('./application/protected/components/decorators/backend/form/views/checkbox.php', array('model' => $model, 'attribute' => $attribute, 'htmlOptions' => $htmlOptions), TRUE);
 }
 /**
  * @param string $view
  * @param string $layout
  * @param array  $data
  *
  * @return string
  */
 public function renderBody($view, $layout = '//layouts/main', array $data = array())
 {
     $controller = new CController('SwiftMailerComponent');
     $viewPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
     $viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
     $layoutFile = $controller->resolveViewFile($layout, $viewPath, $viewPath);
     $body = $controller->renderInternal($viewFile, $data, true);
     if (null !== $layout) {
         $body = $controller->renderInternal($layoutFile, array('content' => $body), true);
     }
     return $body;
 }
 /**
  * generate the email text for the given side.
  *
  * @param CController $controller
  * @param array       $template_data
  * @param string      $side
  *
  * @return string
  */
 protected function generateEmailForSide(CController $controller, array $template_data, $side)
 {
     if ($template_data['compliant']) {
         $file = 'email_compliant.php';
     } else {
         $file = 'email_noncompliant.php';
     }
     $view = $this->getViewPath() . DIRECTORY_SEPARATOR . $file;
     return $controller->renderInternal($view, $template_data, true);
 }
예제 #12
0
 /**
  * @return string
  */
 protected function renderTemplate()
 {
     $controller = new \CController('message');
     return $controller->renderInternal(\Yii::getPathOfAlias($this->messageTemplate) . '.php', $this->messageData, true);
 }
예제 #13
0
파일: Activity.php 프로젝트: ahdail/humhub
 /**
  * Returns Mail Output for that activity
  *
  * @return type
  */
 public function getMailOut()
 {
     $controller = new CController('MailX');
     // Determine View
     $view = 'application.modules_core.activity.views.activities.' . $this->type . "_mail";
     if ($this->module != "") {
         $view = 'application.modules_core.' . $this->module . '.views.activities.' . $this->type . "_mail";
         $viewPath = Yii::getPathOfAlias($view) . '.php';
         // Seems not exists, try 3rd party module folder
         if (!file_exists($viewPath)) {
             $view = 'application.modules.' . $this->module . '.views.activities.' . $this->type . "_mail";
         }
     }
     $viewPath = Yii::getPathOfAlias($view) . '.php';
     $underlyingObject = $this->getUnderlyingObject();
     $workspace = null;
     if ($this->content->space_id != "") {
         $workspace = Space::model()->findByPk($this->content->space_id);
     }
     $user = $this->content->user;
     if ($user == null) {
         return;
     }
     return $controller->renderInternal($viewPath, array('activity' => $this, 'wallEntryId' => 0, 'user' => $user, 'target' => $underlyingObject, 'workspace' => $workspace), true);
 }
예제 #14
0
 /**
  * Set the body of this entity, either as a string, or array of view
  * variables if a view is set, or as an instance of
  * {@link Swift_OutputByteStream}.
  *
  * @param mixed the body of the message.  If a $this->view is set and this
  * is a string, this is passed to the view as $body.  If $this->view is set
  * and this is an array, the array values are passed to the view like in the
  * controller render() method
  * @param string content type optional. For html, set to 'html/text'
  * @param string charset optional
  */
 public function setBody($body = '', $contentType = null, $charset = null)
 {
     if ($this->view !== null) {
         if (!is_array($body)) {
             $body = array('body' => $body);
         }
         // if Yii::app()->controller doesn't exist create a dummy
         // controller to render the view (needed in the console app)
         if (isset(Yii::app()->controller)) {
             $controller = Yii::app()->controller;
         } else {
             $controller = new CController('YiiMail');
         }
         // renderPartial won't work with CConsoleApplication, so use
         // renderInternal - this requires that we use an actual path to the
         // view rather than the usual alias
         //Поменял Yii::app()->mail на Yii::app()->mailer, т.к. уже есть модуль mail
         $viewPath = Yii::getPathOfAlias(Yii::app()->mailer->viewPath . '.' . $this->view) . '.php';
         $body = $controller->renderInternal($viewPath, array_merge($body, array('mail' => $this)), true);
     }
     return $this->message->setBody($body, $contentType, $charset);
 }
예제 #15
0
 /**
  * Render a view file and return result
  *
  * If $controller is not set, the (localized) view file is searched in $viewPath
  * and the layout in $layoutFile is applied, if set.
  *
  * @param string $view name of view to render
  * @param array $data view data
  * @return string rendered content
  */
 private function render($view, $data = array())
 {
     if (($controller = $this->controller) === null) {
         static $controller;
         if ($controller === null) {
             $controller = new CController('pdffile');
         }
         $controller->layout = $this->layout;
         // Required to make console app play nicely during rendering
         Yii::app()->attachBehavior('consoleWorkaround', array('class' => 'ConsoleAppWorkaround', '_viewPath' => $this->baseViewPath, '_layoutPath' => $this->layoutPath));
         $file = Yii::app()->findLocalizedFile($this->viewPath . '/' . $view . '.php');
         if ($file === false) {
             throw new CException('Could not find view file ' . $view);
         }
         ini_set('implicit_flush', false);
         $content = $controller->renderInternal($file, $data, true);
         if ($controller->layout === null) {
             return $content;
         }
         return $controller->renderInternal($controller->getLayoutFile($controller->layout), array('content' => $content), true);
     } else {
         return $controller->render($view, $data, true);
     }
 }
 private function generateEmail($listDataset){
     return CController::renderInternal(Yii::app()->basePath.'/views/search/emailNewDatasets.php',array('listDataset'=>$listDataset),true);
 }
예제 #17
0
 /**
  * Generates Mail Output for this notification
  *
  * @return type
  */
 public function getMailOut()
 {
     $controller = new CController('MailX');
     $viewPath = Yii::getPathOfAlias($this->mailView) . '.php';
     if ($viewPath == ".php") {
         return "not found: " . $this->mailView;
     }
     return $controller->renderInternal($viewPath, array('notification' => $this, 'sourceObject' => $this->getSourceObject(), 'targetObject' => $this->getTargetObject(), 'creator' => $this->getCreator()), true);
 }