예제 #1
0
void WTemplate::setTemplateText(const WString& text, TextFormat textFormat)
{
  text_ = text;

  if (textFormat == XHTMLText && text_.literal()) {
    if (!removeScript(text_))
      text_ = escapeText(text_, true);
  } else if (textFormat == PlainText)
    text_ = escapeText(text_, true);

  if (!text_.literal() && !text_.isLanguage())
  {
	  WLocalizedStrings *ls = 0;
	  WApplication *app = WApplication::instance();
	  if (app)
		  ls = app->localizedStrings();

	  if (!ls) {
		  WServer *server = WServer::instance();
		  if (server)
			  ls = server->localizedStrings();
	  }
	  ls->loadTemplateStyleSheet(text_.key(), text_.moduleAuthorId());
  }

  changed_ = true;
  repaint(RepaintSizeAffected);
}
예제 #2
0
파일: WString.C 프로젝트: traw/WebWidgets
std::string WString::resolveKey() const
{
  std::string result;
  WLocalizedStrings *ls = 0;

  WApplication *app = WApplication::instance();
  if (app)
    ls = app->localizedStrings_;

  if (!ls) {
    WServer *server = WServer::instance();
    if (server)
      ls = server->localizedStrings();
  }

  if(ls)
  {
	  //Check weather language or template
	  if(impl_->isLanguage)
	  {
		  //Weather plural or singular
		  if(impl_->n_ == -1)
		  {
			  //Weather module id was provided
			  if(impl_->moduleAuthorId_ == -1) //get<1> = moduleId
			  {
				  if(ls->resolveKey(impl_->key_, result)) //get<0> = key(language key)
					  return result;
			  }
			  else
			  {
				  if(ls->resolveKey(impl_->key_, impl_->moduleAuthorId_, result))
					  return result;
			  }
		  }
		  else
		  {
			  if(impl_->moduleAuthorId_ == -1)
			  {
				  if(ls->resolvePluralKey(impl_->key_, result, impl_->n_))
					  return result;
			  }
			  else
			  {
				  if(ls->resolvePluralKey(impl_->key_, impl_->moduleAuthorId_, result, impl_->n_))
					  return result;
			  }
		  }
	  }
	  else
	  {
		  if(ls->resolveTemplateKey(impl_->key_, impl_->moduleAuthorId_, result))
		  {
			  return result;
		  }
		  else if(ls->resolveTemplateKey(impl_->key_, impl_->moduleAuthorId_, result))
		  {
			  return result;
		  }
	  }
  }

  if(impl_->isLanguage)
  {
	  if(impl_->moduleAuthorId_ == -1)
		  return "??" + impl_->key_ + "??";
	  else
		  return "??" + impl_->key_ + "(" + boost::lexical_cast<std::string>(impl_->moduleAuthorId_) + ")??";
  }
  else
  {
	  return "???" + impl_->key_ + "(" + boost::lexical_cast<std::string>(impl_->moduleAuthorId_) + ")???";
  }
}