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


PHP Texy::isRelative方法代码示例

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


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

示例1: wiki_texy_phraseHandler

function wiki_texy_phraseHandler($invocation, $phrase, $content, $modifier, $link)
{
    if (!$link) {
        return $invocation->proceed();
    }
    if (Texy::isRelative($link->URL)) {
        $link->URL = '?page=' . urlencode($link->URL);
    } elseif (substr($link->URL, 0, 5) === 'wiki:') {
        $link->URL = 'http://en.wikipedia.org/wiki/Special:Search?search=' . urlencode(substr($link->URL, 5));
    } elseif (substr($link->URL, 0, 4) === 'url:') {
        $link->URL = substr($link->URL, 4);
    }
    return $invocation->proceed();
}
开发者ID:Harvie,项目名称:haiwiki,代码行数:14,代码来源:texy.mod.php

示例2: phraseHandler

/**
 * @param TexyHandlerInvocation  handler invocation
 * @param string
 * @param string
 * @param TexyModifier
 * @param TexyLink
 * @return TexyHtml|string|FALSE
 */
function phraseHandler($invocation, $phrase, $content, $modifier, $link)
{
    // is there link?
    if (!$link) {
        return $invocation->proceed();
    }
    if (Texy::isRelative($link->URL)) {
        // modifiy link
        $link->URL = 'index?page=' . urlencode($link->URL);
    } elseif (substr($link->URL, 0, 5) === 'wiki:') {
        // modifiy link
        $link->URL = 'http://en.wikipedia.org/wiki/Special:Search?search=' . urlencode(substr($link->URL, 5));
    }
    return $invocation->proceed();
}
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:23,代码来源:demo.php

示例3: solve

 public function solve($invocation, TexyImage $image, $link)
 {
     if ($image->URL == NULL) {
         return FALSE;
     }
     $tx = $this->texy;
     $mod = $image->modifier;
     $alt = $mod->title;
     $mod->title = NULL;
     $hAlign = $mod->hAlign;
     $mod->hAlign = NULL;
     $el = TexyHtml::el('img');
     $el->attrs['src'] = NULL;
     $mod->decorate($tx, $el);
     $el->attrs['src'] = Texy::prependRoot($image->URL, $this->root);
     if (!isset($el->attrs['alt'])) {
         if ($alt !== NULL) {
             $el->attrs['alt'] = $tx->typographyModule->postLine($alt);
         } else {
             $el->attrs['alt'] = $this->defaultAlt;
         }
     }
     if ($hAlign) {
         $var = $hAlign . 'Class';
         if (!empty($this->{$var})) {
             $el->attrs['class'][] = $this->{$var};
         } elseif (empty($tx->alignClasses[$hAlign])) {
             $el->attrs['style']['float'] = $hAlign;
         } else {
             $el->attrs['class'][] = $tx->alignClasses[$hAlign];
         }
     }
     if (!is_int($image->width) || !is_int($image->height) || $image->asMax) {
         if ($this->fileRoot === NULL && isset($_SERVER['SCRIPT_FILENAME'])) {
             $this->fileRoot = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $this->root;
         }
         if (Texy::isRelative($image->URL) && strpos($image->URL, '..') === FALSE) {
             $file = rtrim($this->fileRoot, '/\\') . '/' . $image->URL;
             if (@is_file($file)) {
                 $size = getImageSize($file);
                 if (is_array($size)) {
                     if ($image->asMax) {
                         $ratio = 1;
                         if (is_int($image->width)) {
                             $ratio = min($ratio, $image->width / $size[0]);
                         }
                         if (is_int($image->height)) {
                             $ratio = min($ratio, $image->height / $size[1]);
                         }
                         $image->width = round($ratio * $size[0]);
                         $image->height = round($ratio * $size[1]);
                     } elseif (is_int($image->width)) {
                         $ratio = round($size[1] / $size[0] * $image->width);
                         $image->height = round($size[1] / $size[0] * $image->width);
                     } elseif (is_int($image->height)) {
                         $image->width = round($size[0] / $size[1] * $image->height);
                     } else {
                         $image->width = $size[0];
                         $image->height = $size[1];
                     }
                 }
             }
         }
     }
     $el->attrs['width'] = $image->width;
     $el->attrs['height'] = $image->height;
     if ($image->overURL !== NULL) {
         $overSrc = Texy::prependRoot($image->overURL, $this->root);
         $el->attrs['onmouseover'] = 'this.src=\'' . addSlashes($overSrc) . '\'';
         $el->attrs['onmouseout'] = 'this.src=\'' . addSlashes($el->attrs['src']) . '\'';
         $el->attrs['onload'] = str_replace('%i', addSlashes($overSrc), $this->onLoad);
         $tx->summary['preload'][] = $overSrc;
     }
     $tx->summary['images'][] = $el->attrs['src'];
     if ($link) {
         return $tx->linkModule->solve(NULL, $link, $el);
     }
     return $el;
 }
开发者ID:radimklaska,项目名称:Drupal.cz,代码行数:79,代码来源:texy.compact.5.php

示例4: solve

	/**
	 * Finish invocation.
	 *
	 * @param  TexyHandlerInvocation  handler invocation
	 * @param  TexyImage
	 * @param  TexyLink
	 * @return TexyHtml|FALSE
	 */
	public function solve($invocation, TexyImage $image, $link)
	{
		if ($image->URL == NULL) return FALSE;

		$tx = $this->texy;

		$mod = $image->modifier;
		$alt = $mod->title;
		$mod->title = NULL;
		$hAlign = $mod->hAlign;
		$mod->hAlign = NULL;

		$el = TexyHtml::el('img');
		$el->attrs['src'] = NULL; // trick - move to front
		$mod->decorate($tx, $el);
		$el->attrs['src'] = Texy::prependRoot($image->URL, $this->root);
		if (!isset($el->attrs['alt'])) {
			if ($alt !== NULL) $el->attrs['alt'] = $tx->typographyModule->postLine($alt);
			else $el->attrs['alt'] = $this->defaultAlt;
		}

		if ($hAlign) {
			$var = $hAlign . 'Class'; // leftClass, rightClass
			if (!empty($this->$var)) {
				$el->attrs['class'][] = $this->$var;

			} elseif (empty($tx->alignClasses[$hAlign])) {
				$el->attrs['style']['float'] = $hAlign;

			} else {
				$el->attrs['class'][] = $tx->alignClasses[$hAlign];
			}
		}

		if (!is_int($image->width) || !is_int($image->height) || $image->asMax) {
			// autodetect fileRoot
			if ($this->fileRoot === NULL && isset($_SERVER['SCRIPT_FILENAME'])) {
				$this->fileRoot = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $this->root;
			}

			// detect dimensions
			// absolute URL & security check for double dot
			if (Texy::isRelative($image->URL) && strpos($image->URL, '..') === FALSE) {
				$file = rtrim($this->fileRoot, '/\\') . '/' . $image->URL;
				if (@is_file($file)) { // intentionally @
					$size = @getImageSize($file); // intentionally @
					if (is_array($size)) {
						if ($image->asMax) {
							$ratio = 1;
							if (is_int($image->width)) $ratio = min($ratio, $image->width / $size[0]);
							if (is_int($image->height)) $ratio = min($ratio, $image->height / $size[1]);
							$image->width = round($ratio * $size[0]);
							$image->height = round($ratio * $size[1]);

						} elseif (is_int($image->width)) {
							$ratio = round($size[1] / $size[0] * $image->width);
							$image->height = round($size[1] / $size[0] * $image->width);

						} elseif (is_int($image->height)) {
							$image->width = round($size[0] / $size[1] * $image->height);

						} else {
							$image->width = $size[0];
							$image->height = $size[1];
						}
					}
				}
			}
		}

		$el->attrs['width'] = $image->width;
		$el->attrs['height'] = $image->height;
		$tx->summary['images'][] = $el->attrs['src'];

		if ($link) return $tx->linkModule->solve(NULL, $link, $el);

		return $el;
	}
开发者ID:JanTvrdik,项目名称:StaticWeb,代码行数:86,代码来源:TexyImageModule.php

示例5: solve

 /**
  * Finish invocation.
  *
  * @param  TexyHandlerInvocation  handler invocation
  * @param  TexyImage
  * @param  TexyLink
  *
  * @return TexyHtml|FALSE
  */
 public function solve($invocation, TexyImage $image, $link)
 {
     if ($image->URL == null) {
         return false;
     }
     $tx = $this->texy;
     $mod = $image->modifier;
     $alt = $mod->title;
     $mod->title = null;
     $hAlign = $mod->hAlign;
     $mod->hAlign = null;
     $el = TexyHtml::el('img');
     $el->attrs['src'] = null;
     // trick - move to front
     $mod->decorate($tx, $el);
     $el->attrs['src'] = Texy::prependRoot($image->URL, $this->root);
     if (!isset($el->attrs['alt'])) {
         if ($alt !== null) {
             $el->attrs['alt'] = $tx->typographyModule->postLine($alt);
         } else {
             $el->attrs['alt'] = $this->defaultAlt;
         }
     }
     if ($hAlign) {
         $var = $hAlign . 'Class';
         // leftClass, rightClass
         if (!empty($this->{$var})) {
             $el->attrs['class'][] = $this->{$var};
         } elseif (empty($tx->alignClasses[$hAlign])) {
             $el->attrs['style']['float'] = $hAlign;
         } else {
             $el->attrs['class'][] = $tx->alignClasses[$hAlign];
         }
     }
     if (!is_int($image->width) || !is_int($image->height) || $image->asMax) {
         // autodetect fileRoot
         if ($this->fileRoot === null && isset($_SERVER['SCRIPT_FILENAME'])) {
             $this->fileRoot = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $this->root;
         }
         // detect dimensions
         // absolute URL & security check for double dot
         if (Texy::isRelative($image->URL) && strpos($image->URL, '..') === false) {
             $file = rtrim($this->fileRoot, '/\\') . '/' . $image->URL;
             if (@is_file($file)) {
                 // intentionally @
                 $size = @getImageSize($file);
                 // intentionally @
                 if (is_array($size)) {
                     if ($image->asMax) {
                         $ratio = 1;
                         if (is_int($image->width)) {
                             $ratio = min($ratio, $image->width / $size[0]);
                         }
                         if (is_int($image->height)) {
                             $ratio = min($ratio, $image->height / $size[1]);
                         }
                         $image->width = round($ratio * $size[0]);
                         $image->height = round($ratio * $size[1]);
                     } elseif (is_int($image->width)) {
                         $ratio = round($size[1] / $size[0] * $image->width);
                         $image->height = round($size[1] / $size[0] * $image->width);
                     } elseif (is_int($image->height)) {
                         $image->width = round($size[0] / $size[1] * $image->height);
                     } else {
                         $image->width = $size[0];
                         $image->height = $size[1];
                     }
                 }
             }
         }
     }
     $el->attrs['width'] = $image->width;
     $el->attrs['height'] = $image->height;
     // onmouseover actions generate
     if ($image->overURL !== null) {
         $overSrc = Texy::prependRoot($image->overURL, $this->root);
         $el->attrs['onmouseover'] = 'this.src=\'' . addSlashes($overSrc) . '\'';
         $el->attrs['onmouseout'] = 'this.src=\'' . addSlashes($el->attrs['src']) . '\'';
         $el->attrs['onload'] = str_replace('%i', addSlashes($overSrc), $this->onLoad);
         $tx->summary['preload'][] = $overSrc;
     }
     $tx->summary['images'][] = $el->attrs['src'];
     if ($link) {
         return $tx->linkModule->solve(null, $link, $el);
     }
     return $el;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:96,代码来源:TexyImageModule.php


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