当前位置: 首页>>代码示例>>C++>>正文


C++ WApplication::encodeUntrustedUrl方法代码示例

本文整理汇总了C++中WApplication::encodeUntrustedUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ WApplication::encodeUntrustedUrl方法的具体用法?C++ WApplication::encodeUntrustedUrl怎么用?C++ WApplication::encodeUntrustedUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WApplication的用法示例。


在下文中一共展示了WApplication::encodeUntrustedUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateDom

void WImage::updateDom(DomElement& element, bool all)
{
  DomElement *img = &element;
  if (all && element.type() == DomElement_SPAN) {
    DomElement *map = map_->createSDomElement(WApplication::instance());
    element.addChild(map);

    img = DomElement::createNew(DomElement_IMG);
    img->setId("i" + id());
  }

  if (flags_.test(BIT_IMAGE_LINK_CHANGED) || all) {
    if (!imageLink_.isNull()) {
      std::string url = resolveRelativeUrl(imageLink_.url());

      WApplication *app = WApplication::instance();
      url = app->encodeUntrustedUrl(url);

      img->setProperty(Wt::PropertySrc, url);
    } else
      img->setProperty(Wt::PropertySrc, "#");

    flags_.reset(BIT_IMAGE_LINK_CHANGED);
  }

  if (flags_.test(BIT_ALT_TEXT_CHANGED) || all) {
    img->setAttribute("alt", altText_.toUTF8());
    flags_.reset(BIT_ALT_TEXT_CHANGED);
  }

  if (flags_.test(BIT_MAP_CREATED) || (all && map_)) {
    img->setAttribute("usemap", '#' + map_->id());
    flags_.reset(BIT_MAP_CREATED);
  }

  WInteractWidget::updateDom(*img, all);

  if (&element != img)
    element.addChild(img);
}
开发者ID:NeilNienaber,项目名称:wt,代码行数:40,代码来源:WImage.C

示例2: updateDom

void WAnchor::updateDom(DomElement& element, bool all)
{
  if (element.type() != DomElement_A) {
    WContainerWidget::updateDom(element, all);
    return;
  }

  if (flags_.test(BIT_CHANGE_TAG)) {
    if (!all)
      element.callJavaScript(WT_CLASS ".changeTag(" + jsRef() + ",'a');");

    flags_.reset(BIT_CHANGE_TAG);
  }

  bool needsUrlResolution = false;

  if (flags_.test(BIT_LINK_CHANGED) || all) {
    WApplication *app = WApplication::instance();

    std::string url = link_.resolveUrl(app);

    /*
     * From 但浩亮: setRefInternalPath() and setTarget(TargetNewWindow)
     * does not work without the check below:
     */
    if (target_ == TargetSelf)
      changeInternalPathJS_
	= link_.manageInternalPathChange(app, this, changeInternalPathJS_);
    else {
      delete changeInternalPathJS_;
      changeInternalPathJS_ = 0;
    }

    url = app->encodeUntrustedUrl(url);

    std::string href = resolveRelativeUrl(url);
    element.setAttribute("href", href);

    needsUrlResolution = !app->environment().hashInternalPaths()
      && href.find("://") == std::string::npos && href[0] != '/';

    flags_.reset(BIT_LINK_CHANGED);
  }

  if (flags_.test(BIT_TARGET_CHANGED) || all) {
    switch (target_) {
    case TargetSelf:
      if (!all)
	element.setProperty(PropertyTarget, "_self");
      break;
    case TargetThisWindow:
      element.setProperty(PropertyTarget, "_top");
      break;
    case TargetNewWindow:
      element.setProperty(PropertyTarget, "_blank");
    }
    flags_.reset(BIT_TARGET_CHANGED);
  }

  WContainerWidget::updateDom(element, all);

  if (needsUrlResolution) {
    if (all)
      element.setProperty(PropertyClass,
			  Utils::addWord(styleClass().toUTF8(), "Wt-rr"));
    else
      element.callJavaScript("$('#" + id() + "').addClass('Wt-rr');");
  }
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:69,代码来源:WAnchor.C


注:本文中的WApplication::encodeUntrustedUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。