Ejemplo n.º 1
0
 disabled<?php 
}
?>
>
				<option value=0<?php 
if (!TBGSettings::isCommentImagePreviewEnabled()) {
    ?>
 selected<?php 
}
?>
><?php 
echo __("Don't show image previews of attached images in comments");
?>
</option>
				<option value=1<?php 
if (TBGSettings::isCommentImagePreviewEnabled()) {
    ?>
 selected<?php 
}
?>
><?php 
echo __('Show image previews of attached images in comments');
?>
</option>
			</select>
		</td>
	</tr>
	<tr>
		<td class="config_explanation" colspan="2"><?php 
echo __('If you have problems with spam images, turn this off');
?>
 protected function _parse_internallink($matches)
 {
     $href = html_entity_decode($matches[4]);
     if (isset($matches[6]) && $matches[6]) {
         $title = $matches[6];
     } else {
         $title = $href;
         if (isset($matches[7]) && $matches[7]) {
             $title .= $matches[7];
         }
     }
     $namespace = $matches[3];
     if (strtolower($namespace) == 'category') {
         if (substr($matches[2], 0, 1) != ':') {
             $this->addCategorizer($href);
             return '';
         }
     }
     if (strtolower($namespace) == 'wikipedia') {
         if (TBGContext::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = (array_key_exists(5, $matches) && strpos($matches[5], '|') !== false ? '' : $namespace . ':') . array_pop($options);
         return link_tag('http://en.wikipedia.org/wiki/' . $href, $title);
     }
     if (in_array(strtolower($namespace), array('image', 'file'))) {
         $retval = $namespace . ':' . $href;
         if (!TBGContext::isCLI()) {
             $options = explode('|', $title);
             $filename = $href;
             $issuemode = (bool) (isset($this->options['issue']) && $this->options['issue'] instanceof TBGIssue);
             $articlemode = (bool) (isset($this->options['article']) && $this->options['article'] instanceof TBGWikiArticle);
             $file = null;
             $file_link = $filename;
             $caption = $filename;
             if ($issuemode) {
                 $file = $this->options['issue']->getFileByFilename($filename);
             } elseif ($articlemode) {
                 $file = $this->options['article']->getFileByFilename($filename);
             }
             if ($file instanceof TBGFile) {
                 $caption = !empty($options) ? array_pop($options) : $file->getDescription();
                 $caption = $caption != '' ? $caption : $file->getOriginalFilename();
                 $file_link = make_url('showfile', array('id' => $file->getID()));
             }
             if (($file instanceof TBGFile && $file->isImage() || $articlemode) && (strtolower($namespace) == 'image' || $issuemode) && TBGSettings::isCommentImagePreviewEnabled()) {
                 $divclasses = array('image_container');
                 $style_dimensions = '';
                 foreach ($options as $option) {
                     $optionlen = strlen($option);
                     if (substr($option, $optionlen - 2) == 'px') {
                         if (is_numeric($option[0])) {
                             $style_dimensions = ' width: ' . $option[0] . ';';
                             break;
                         } else {
                             $style_dimensions = ' height: ' . substr($option[0], 1) . ';';
                             break;
                         }
                     }
                 }
                 if (in_array('thumb', $options)) {
                     $divclasses[] = 'thumb';
                 }
                 if (in_array('left', $options)) {
                     $divclasses[] = 'icleft';
                 }
                 if (in_array('center', $options)) {
                     $divclasses[] = 'iccenter';
                 }
                 if (in_array('right', $options)) {
                     $divclasses[] = 'icright';
                 }
                 $retval = '<div class="' . join(' ', $divclasses) . '"';
                 if ($issuemode) {
                     $retval .= ' style="float: left; clear: left;"';
                 }
                 $retval .= '>';
                 $retval .= image_tag($file_link, array('alt' => $caption, 'title' => $caption, 'style' => $style_dimensions, 'class' => 'image'), true);
                 if ($caption != '') {
                     $retval .= '<br>' . $caption;
                 }
                 $retval .= link_tag($file_link, image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open image in new window')));
                 $retval .= '</div>';
             } else {
                 $retval = link_tag($file_link, $caption . image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open file in new window')));
             }
         }
         return $retval;
         //$file_id = TBGFilesTable::get
     }
     if ($namespace == 'TBG') {
         if (TBGContext::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = array_pop($options);
         return link_tag(make_url($href), $title);
         // $this->parse_image($href,$title,$options);
     }
     if (substr($href, 0, 1) == '/') {
         if (TBGContext::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = array_pop($options);
         return link_tag($href, $title);
         // $this->parse_image($href,$title,$options);
     }
     $title = preg_replace('/\\(.*?\\)/', '', $title);
     $title = preg_replace('/^.*?\\:/', '', $title);
     if (!$namespace || !array_key_exists($namespace, array('ftp', 'http', 'https', 'gopher', 'mailto', 'news', 'nntp', 'telnet', 'wais', 'file', 'prospero', 'aim', 'webcal'))) {
         if ($namespace) {
             $href = $namespace . ':' . $href;
         }
         $href = $this->_wiki_link($href);
         $title = isset($title) ? $title : $href;
         $this->addInternalLinkOccurrence($href);
         if (TBGContext::isCLI()) {
             return $href;
         }
         $href = TBGContext::getRouting()->generate('publish_article', array('article_name' => $href));
     } else {
         $href = $namespace . ':' . $this->_wiki_link($href);
     }
     if (TBGContext::isCLI()) {
         return $href;
     }
     return link_tag($href, $title);
 }
Ejemplo n.º 3
0
 protected function _parse_internallink($matches)
 {
     $href = html_entity_decode($matches[4], ENT_QUOTES, 'UTF-8');
     if (isset($matches[6]) && $matches[6]) {
         $title = $matches[6];
     } else {
         $title = $href;
         if (isset($matches[7]) && $matches[7]) {
             $title .= $matches[7];
         }
     }
     $namespace = $matches[3];
     if (mb_strtolower($namespace) == 'category') {
         if (mb_substr($matches[2], 0, 1) != ':') {
             $this->addCategorizer($href);
             return '';
         }
     }
     if (mb_strtolower($namespace) == 'wikipedia') {
         if (TBGContext::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = (array_key_exists(5, $matches) && mb_strpos($matches[5], '|') !== false ? '' : $namespace . ':') . array_pop($options);
         return link_tag('http://en.wikipedia.org/wiki/' . $href, $title);
     }
     if (preg_match("/embed(\\s+url\\=)?/", mb_strtolower($namespace)) || preg_match("/embed((:)?|(\\s+url\\=)?)/", mb_strtolower($matches[0]))) {
         if (TBGContext::isCLI()) {
             return $href;
         }
         // if the name space is null more than likely the user is
         // using embed url= format without the http:// in front of the URL
         // and the href tag will contain "embed url=" and it must be removed
         if ($namespace == null) {
             $href = preg_replace("/embed(\\s+)url=/", "", $href);
         }
         // if the href is empty or set to 'embed' then stop processing
         // an empty embed tag was entered '[[embed]]'
         if ($href == 'embed' || $href == null) {
             return;
         }
         $options = explode('|', $title);
         // Default values
         $width = 500;
         $height = 400;
         $type = 'iframe';
         // if the link is a youtube link prepare it for embedding
         if (tbg_youtube_link($href)) {
             $href = tbg_youtube_prepare_link($href);
         }
         // check to see if any size options exist
         if (array_key_exists(0, $options)) {
             $settings = $options[0];
             // if width exists override default setting
             if (preg_match_all("/width=(\\d+)/", $settings, $width_matches)) {
                 if (!empty($width_matches)) {
                     $width = $width_matches[1][0];
                 }
             }
             // if height exists override default setting
             if (preg_match_all("/height=(\\d+)/", $settings, $height_matches)) {
                 if (!empty($height_matches)) {
                     $height = $height_matches[1][0];
                 }
             }
             // if type exists override default setting
             if (preg_match_all("/type=(iframe|object)/", $settings, $type_matches)) {
                 if (!empty($type_matches)) {
                     $type = $type_matches[1][0];
                 }
             }
         }
         if ($type == 'object') {
             $code = object_tag($href, $width, $height);
         } else {
             $code = iframe_tag($href, $width, $height);
         }
         return $code;
     }
     if (in_array(mb_strtolower($namespace), array('image', 'file'))) {
         $retval = $namespace . ':' . $href;
         if (!TBGContext::isCLI()) {
             $options = explode('|', $title);
             $filename = $href;
             $issuemode = (bool) (isset($this->options['issue']) && $this->options['issue'] instanceof TBGIssue);
             $articlemode = (bool) (isset($this->options['article']) && $this->options['article'] instanceof TBGWikiArticle);
             $file = null;
             $file_link = $filename;
             $caption = $filename;
             if ($issuemode) {
                 $file = $this->options['issue']->getFileByFilename($filename);
             } elseif ($articlemode) {
                 $file = $this->options['article']->getFileByFilename($filename);
             }
             if ($file instanceof TBGFile) {
                 $caption = !empty($options) ? array_pop($options) : htmlentities($file->getDescription(), ENT_COMPAT, TBGContext::getI18n()->getCharset());
                 $caption = $caption != '' ? $caption : htmlentities($file->getOriginalFilename(), ENT_COMPAT, TBGContext::getI18n()->getCharset());
                 $file_link = make_url('showfile', array('id' => $file->getID()));
             } else {
                 $caption = !empty($options) ? array_pop($options) : false;
             }
             if (($file instanceof TBGFile && $file->isImage() || $articlemode) && (mb_strtolower($namespace) == 'image' || $issuemode) && TBGSettings::isCommentImagePreviewEnabled()) {
                 $divclasses = array('image_container');
                 $style_dimensions = '';
                 foreach ($options as $option) {
                     $optionlen = mb_strlen($option);
                     if (mb_substr($option, $optionlen - 2) == 'px') {
                         if (is_numeric($option[0])) {
                             $style_dimensions = ' width: ' . $option . ';';
                             break;
                         } else {
                             $style_dimensions = ' height: ' . mb_substr($option, 1) . ';';
                             break;
                         }
                     }
                 }
                 if (in_array('thumb', $options)) {
                     $divclasses[] = 'thumb';
                 }
                 if (in_array('left', $options)) {
                     $divclasses[] = 'icleft';
                 }
                 if (in_array('center', $options)) {
                     $divclasses[] = 'iccenter';
                 }
                 if (in_array('right', $options)) {
                     $divclasses[] = 'icright';
                 }
                 $retval = '<div class="' . join(' ', $divclasses) . '"';
                 if ($issuemode) {
                     $retval .= ' style="float: left; clear: left;"';
                 }
                 $retval .= '>';
                 $retval .= image_tag($file_link, array('alt' => $caption, 'title' => $caption, 'style' => $style_dimensions, 'class' => 'image'), true);
                 if ($caption != '') {
                     $retval .= '<br>' . $caption;
                 }
                 $retval .= link_tag($file_link, image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open image in new window')));
                 $retval .= '</div>';
             } else {
                 $retval = link_tag($file_link, $caption . image_tag('icon_open_new.png', array('style' => 'margin-left: 5px;')), array('target' => 'new_window_' . rand(0, 10000), 'title' => __('Open file in new window')));
             }
         }
         return $retval;
         //$file_id = TBGFilesTable::get
     }
     if ($namespace == 'TBG') {
         if (TBGContext::isCLI()) {
             return $href;
         }
         if (!TBGContext::getRouting()->hasRoute($href)) {
             return $href;
         }
         $options = explode('|', $title);
         $title = array_pop($options);
         try {
             return link_tag(make_url($href), $title);
             // $this->parse_image($href,$title,$options);
         } catch (Exception $e) {
             return $href;
         }
     }
     if (mb_substr($href, 0, 1) == '/') {
         if (TBGContext::isCLI()) {
             return $href;
         }
         $options = explode('|', $title);
         $title = array_pop($options);
         return link_tag($href, $title);
         // $this->parse_image($href,$title,$options);
     }
     $title = preg_replace('/\\(.*?\\)/', '', $title);
     $title = preg_replace('/^.*?\\:/', '', $title);
     if (!$namespace || !array_key_exists($namespace, array('ftp', 'http', 'https', 'gopher', 'mailto', 'news', 'nntp', 'telnet', 'wais', 'file', 'prospero', 'aim', 'webcal'))) {
         if ($namespace) {
             $href = $namespace . ':' . $href;
         }
         $href = $this->_wiki_link($href);
         $title = isset($title) ? $title : $href;
         $this->addInternalLinkOccurrence($href);
         if (TBGContext::isCLI()) {
             return $href;
         }
         $href = TBGContext::getRouting()->generate('publish_article', array('article_name' => $href));
     } else {
         $href = $namespace . ':' . $this->_wiki_link($href);
     }
     if (TBGContext::isCLI()) {
         return $href;
     }
     return link_tag($href, $title);
 }