/** * Finish invocation. * @return Texy\HtmlElement|FALSE */ public function solve(Texy\HandlerInvocation $invocation, $emoticon, $raw) { $texy = $this->texy; $file = $this->icons[$emoticon]; $el = new Texy\HtmlElement('img'); $el->attrs['src'] = Texy\Helpers::prependRoot($file, $this->root === NULL ? $texy->imageModule->root : $this->root); $el->attrs['alt'] = $raw; $el->attrs['class'][] = $this->class; // file path $file = rtrim($this->fileRoot === NULL ? $texy->imageModule->fileRoot : $this->fileRoot, '/\\') . '/' . $file; if (@is_file($file)) { // intentionally @ $size = @getImageSize($file); // intentionally @ if (is_array($size)) { $el->attrs['width'] = $size[0]; $el->attrs['height'] = $size[1]; } } $texy->summary['images'][] = $el->attrs['src']; return $el; }
/** * Converts cite source to URL. * @param string * @return string|NULL */ public function citeLink($link) { $texy = $this->texy; if ($link == NULL) { return NULL; } if ($link[0] === '[') { // [ref] $link = substr($link, 1, -1); $ref = $texy->linkModule->getReference($link); if ($ref) { return Texy\Helpers::prependRoot($ref->URL, $texy->linkModule->root); } } // special supported case if (strncasecmp($link, 'www.', 4) === 0) { return 'http://' . $link; } return Texy\Helpers::prependRoot($link, $texy->linkModule->root); }
/** * Finish invocation. * * @param Texy\HtmlElement|string $content * @return Texy\HtmlElement|string */ public function solve(HandlerInvocation $invocation = NULL, Link $link, $content = NULL) { if ($link->URL == NULL) { return $content; } $texy = $this->texy; $el = new Texy\HtmlElement('a'); if (empty($link->modifier)) { $nofollow = $popup = FALSE; } else { $nofollow = isset($link->modifier->classes['nofollow']); $popup = isset($link->modifier->classes['popup']); unset($link->modifier->classes['nofollow'], $link->modifier->classes['popup']); $el->attrs['href'] = NULL; // trick - move to front $link->modifier->decorate($texy, $el); } if ($link->type === Link::IMAGE) { // image $el->attrs['href'] = Texy\Helpers::prependRoot($link->URL, $texy->imageModule->linkedRoot); if ($this->imageClass) { $el->attrs['class'][] = $this->imageClass; } else { $el->attrs['onclick'] = $this->imageOnClick; } } else { $el->attrs['href'] = Texy\Helpers::prependRoot($link->URL, $this->root); // rel="nofollow" if ($nofollow || $this->forceNoFollow && strpos($el->attrs['href'], '//') !== FALSE) { $el->attrs['rel'] = 'nofollow'; } } // popup on click if ($popup) { $el->attrs['onclick'] = $this->popupOnClick; } if ($content !== NULL) { $el->add($content); } $texy->summary['links'][] = $el->attrs['href']; return $el; }
/** * Finish invocation. * @return Texy\HtmlElement|FALSE */ public function solve(Texy\HandlerInvocation $invocation = NULL, Image $image, Texy\Link $link = NULL) { if ($image->URL == NULL) { return FALSE; } $texy = $this->texy; $mod = $image->modifier; $alt = $mod->title; $mod->title = NULL; $hAlign = $mod->hAlign; $mod->hAlign = NULL; $el = new Texy\HtmlElement('img'); $el->attrs['src'] = NULL; // trick - move to front $mod->decorate($texy, $el); $el->attrs['src'] = Helpers::prependRoot($image->URL, $this->root); if (!isset($el->attrs['alt'])) { $el->attrs['alt'] = $alt === NULL ? $this->defaultAlt : $texy->typographyModule->postLine($alt); } if ($hAlign) { $var = $hAlign . 'Class'; // leftClass, rightClass if (!empty($this->{$var})) { $el->attrs['class'][] = $this->{$var}; } elseif (empty($texy->alignClasses[$hAlign])) { $el->attrs['style']['float'] = $hAlign; } else { $el->attrs['class'][] = $texy->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 (Helpers::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)) { $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 (!empty($texy->allowed['image/hover']) && $image->overURL !== NULL) { $overSrc = Helpers::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); $texy->summary['preload'][] = $overSrc; } $texy->summary['images'][] = $el->attrs['src']; if ($link) { return $texy->linkModule->solve(NULL, $link, $el); } return $el; }