/**
  * Constructor of the class
  *
  * @param blogInfo A valid BlogInfo object representing the blog to which this View belongs
  * @param templateName A template name
  * @param cachingEnabled either SMARTY_VIEW_CACHE_ENABLED, SMARTY_VIEW_CACHED_DISABLED, SMARTY_VIEW_CACHE_CHECK.
  * If left as SMARTY_VIEW_CACHE_CHECK, the blog settings will checked to determine whether caching is enabled
  * or not.
  * @param data Data that will be used to generate a unique id for the cached view (it will be ignored
  * if caching is not enabled)
  */
 function SmartyView($blogInfo, $templateName, $cachingEnabled = SMARTY_VIEW_CACHE_CHECK, $data = array())
 {
     // parent constructor
     $this->View();
     if ($cachingEnabled == SMARTY_VIEW_CACHE_CHECK) {
         // detect whether caching should be enabled or not
         $config =& Config::getConfig();
         $cachingEnabled = $config->getValue("template_cache_enabled");
     }
     // whether caching is enabled or not
     $this->_cachingEnabled = $cachingEnabled;
     // save the blogInfo object
     $this->_blogInfo = $blogInfo;
     // name of the tepmlate
     $this->_templateName = $templateName;
     // get the right CachedTemplate or Template object
     $blogSettings = $this->_blogInfo->getSettings();
     $ts = new TemplateService();
     if ($this->isCachingEnabled()) {
         // get a CachedTemplate object
         $this->_template = $ts->CachedTemplate($this->_templateName, $blogSettings->getValue('template'), $this->_blogInfo);
         // data used to calculate the view id
         $this->_data = $data;
         // and generate the right cache id for it
         $this->_data["blogId"] = $blogInfo->getId();
         $this->_viewId = $this->generateCacheId();
     } else {
         $this->_template = $ts->Template($this->_templateName, $blogSettings->getValue('template'), $this->_blogInfo);
     }
 }
 function render()
 {
     parent::render();
     $templateService = new TemplateService();
     $template = $templateService->Template($this->_templateName, "admin/xml");
     $template->assign($this->_params->getAsArray());
     print $template->fetch();
 }
 function renderBodyTemplate($templateid, $templateFolder)
 {
     // create a new template service
     $ts = new TemplateService();
     $messageTemplate = $ts->Template($templateid, $templateFolder);
     $messageTemplate->assign("username", $this->username);
     $messageTemplate->assign("activeCode", $this->activeCode);
     $messageTemplate->assign("activeLink", $this->activeLink);
     // FIXME: use which locale?
     $locale =& Locales::getLocale();
     $messageTemplate->assign("locale", $locale);
     // render and return the contents
     return $messageTemplate->fetch();
 }
 /**
  * Renders the view. It simply gets all the parameters we've been adding to it
  * and puts them in the context of the template renderer so that they can be accessed
  * as normal parameters from within the template
  */
 function render()
 {
     // set the view character set based on the default locale
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $this->setValue('version', Version::getVersion());
     $this->setCharset($locale->getCharset());
     parent::render();
     // to find the template we need, we can use the TemplateService
     $ts = new TemplateService();
     $template = $ts->Template(DEFAULTADMIN_TEMPLATE, "admin");
     $this->setValue("locale", $locale);
     // assign all the values
     $template->assign($this->_params->getAsArray());
     // and send the results
     print $template->fetch();
 }
 function render()
 {
     // set the view character set based on the default locale
     $config =& Config::getConfig();
     $locale =& Locales::getLocale($config->getValue("default_locale"));
     $this->setValue('version', Version::getVersion());
     $this->setCharset($locale->getCharset());
     parent::render();
     // load the contents into the template context
     $ts = new TemplateService();
     $template = $ts->Template(ADMINSIMPLEMESSAGE_TEMPLATE, "admin");
     $this->setValue("locale", $locale);
     // and pass the values to the template
     $template->assign($this->_params->getAsArray());
     // finally, send the results
     print $template->fetch();
 }
 /**
  * sends the email with the request
  * @private
  */
 function sendResetEmail($userInfo, $url)
 {
     // prepare the template
     $templateService = new TemplateService();
     $template = $templateService->Template("resetpasswordemail", "summary");
     $template->assign("locale", $this->_locale);
     $template->assign("reseturl", $url);
     // render it and keep its contents
     $emailBody = $template->fetch();
     $message = new EmailMessage();
     $config =& Config::getConfig();
     $message->setFrom($config->getValue("post_notification_source_address"));
     $message->addTo($userInfo->getEmail());
     $message->setSubject("pLog Password Reset Request");
     $message->setBody($emailBody);
     $service = new EmailService();
     return $service->sendMessage($message);
 }
 /**
  * Renders the template at templates/misc/email_notifier.template
  */
 function renderMessageTemplate($article, $blogInfo)
 {
     // create a new template service
     $ts = new TemplateService();
     $messageTemplate = $ts->Template(EMAILNOTIFIER_TEMPLATE, "misc");
     // add these two useful objects
     $rg =& RequestGenerator::getRequestGenerator($blogInfo);
     // disable the xhtml mode, as some email clients cannot deal with it
     $rg->setXHTML(false);
     $messageTemplate->assign("url", $rg);
     $messageTemplate->assign("post", $article);
     // render and return the contents
     return $messageTemplate->fetch();
 }