Skip to content

Commit

Permalink
Images in Articles are now styled in story templates
Browse files Browse the repository at this point in the history
Feature request #780
Style images depending in storytext.thtml, featuredstorytext.thtml, and
archivestorytext.thtml,
  • Loading branch information
eSilverStrike committed May 10, 2017
1 parent 3713531 commit 02c33b2
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 38 deletions.
2 changes: 1 addition & 1 deletion language/english.php
Expand Up @@ -946,7 +946,7 @@
54 => 'Attached Images Not Used',
55 => 'The following errors occurred while trying to save your story. Please correct these errors before saving',
56 => 'Show Topic Icon',
57 => 'View unscaled image',
57 => 'View original image',
58 => 'Archive Options',
59 => 'Option',
60 => '',
Expand Down
2 changes: 1 addition & 1 deletion language/english_utf-8.php
Expand Up @@ -946,7 +946,7 @@
54 => 'Attached Images Not Used',
55 => 'The following errors occurred while trying to save your story. Please correct these errors before saving',
56 => 'Show Topic Icon',
57 => 'View unscaled image',
57 => 'View original image',
58 => 'Archive Options',
59 => 'Option',
60 => '',
Expand Down
4 changes: 3 additions & 1 deletion public_html/docs/english/theme.html
Expand Up @@ -206,7 +206,9 @@ <h2><a id="changes">Changes</a></h2>
<h2><a name="changes213">Theme changes in Geeklog 2.1.3</a></h2>

<ul>
<li>Removed {copyright_notice} from <span class="tt">footer.thtml</span> since it contained embedded HTML tags and the same message can be created from {copyright_msg} and {trademark_msg} template variables</li>
<li>Removed {copyright_notice} from <span class="tt">footer.thtml</span> since it contained embedded HTML tags and the same message can be created from {copyright_msg} and {trademark_msg} template variables.</li>
<li>Removed from the users directory the files <span class="tt">storyrow.thtml</span>, <span class="tt">commentrow.thtml</span>, and <span class="tt">email.thtml</span>. Added additional blocks to <span class="tt">profile.thtml</span> to take into account removed files.</li>
<li>Added 3 blocks to <span class="tt">storytext.thtml</span>, <span class="tt">featuredstorytext.thtml</span>, and <span class="tt">archivestorytext.thtml</span> to control how left aligned, right aligned, and non aligned images are displayed in articles (using the [imageX], [imageX_right], and [imageX_left] tags).</li>
</ul>

<h2><a name="changes212">Theme changes in Geeklog 2.1.2</a></h2>
Expand Down
26 changes: 25 additions & 1 deletion public_html/layout/denim/archivestorytext.thtml
Expand Up @@ -49,4 +49,28 @@
{!endif}
</article>

{# end {templatelocation} #}
<!-- BEGIN image_noalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_noalign -->

<!-- BEGIN image_leftalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail uk-align-left" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail uk-align-left"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_leftalign -->

<!-- BEGIN image_rightalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail uk-align-right" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail uk-align-right"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_rightalign -->

{# end {templatelocation} #}
26 changes: 25 additions & 1 deletion public_html/layout/denim/featuredstorytext.thtml
Expand Up @@ -54,4 +54,28 @@
{!endif}
</article>

{# end {templatelocation} #}
<!-- BEGIN image_noalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_noalign -->

<!-- BEGIN image_leftalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail uk-align-left" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail uk-align-left"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_leftalign -->

<!-- BEGIN image_rightalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail uk-align-right" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail uk-align-right"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_rightalign -->

{# end {templatelocation} #}
1 change: 1 addition & 0 deletions public_html/layout/denim/functions.php
Expand Up @@ -56,6 +56,7 @@ function theme_config_denim()
'form_password' => 0,
'form_select' => 0,
'htmleditor' => 0,
'lightbox' => 1,
'nestable' => 0,
'notify' => 0,
'placeholder' => 0,
Expand Down
26 changes: 25 additions & 1 deletion public_html/layout/denim/storytext.thtml
Expand Up @@ -54,4 +54,28 @@
{!endif}
</article>

{# end {templatelocation} #}
<!-- BEGIN image_noalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_noalign -->

<!-- BEGIN image_leftalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail uk-align-left" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail uk-align-left"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_leftalign -->

<!-- BEGIN image_rightalign -->
{!if link_url}
<a href="{link_url}" title="{link_title}" class="uk-thumbnail uk-align-right" data-uk-lightbox><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></a>
{!else}
<div class="uk-thumbnail uk-align-right"><img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}></div>
{!endif}
<!-- END image_rightalign -->

{# end {templatelocation} #}
20 changes: 19 additions & 1 deletion public_html/layout/modern_curve/archivestorytext.thtml
Expand Up @@ -54,4 +54,22 @@
{!endif}
</div>

{# end {templatelocation} #}
<!-- BEGIN image_noalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_noalign -->

<!-- BEGIN image_leftalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} class="floatleft" src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_leftalign -->

<!-- BEGIN image_rightalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} class="floatright" src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_rightalign -->

{# end {templatelocation} #}
20 changes: 19 additions & 1 deletion public_html/layout/modern_curve/featuredstorytext.thtml
Expand Up @@ -59,4 +59,22 @@
{!endif}
</div>

{# end {templatelocation} #}
<!-- BEGIN image_noalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_noalign -->

<!-- BEGIN image_leftalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} class="floatleft" src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_leftalign -->

<!-- BEGIN image_rightalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} class="floatright" src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_rightalign -->

{# end {templatelocation} #}
20 changes: 19 additions & 1 deletion public_html/layout/modern_curve/storytext.thtml
Expand Up @@ -59,4 +59,22 @@
{!endif}
</div>

{# end {templatelocation} #}
<!-- BEGIN image_noalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_noalign -->

<!-- BEGIN image_leftalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} class="floatleft" src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_leftalign -->

<!-- BEGIN image_rightalign -->
{!if link_url}<a href="{link_url}" title="{link_title}" target="_blank">{!endif}
<img {sizeAttributes} class="floatright" src="{imgSrc}" alt=""{XHTML}>
{!if link_url}</a>{!endif}
<!-- END image_rightalign -->

{# end {templatelocation} #}
90 changes: 61 additions & 29 deletions system/classes/story.class.php
Expand Up @@ -1210,6 +1210,28 @@ public function renderImageTags($text)
} else {
$ai_sid = $this->_sid;
}

// Figure out story type normal, featured or archived (grabbed from render article in lib-story)
if ($this->DisplayElements('featured') == 1) {
$article_filevar = 'featuredstorytext.thtml';
} elseif ($this->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $this->DisplayElements('expire') <= time()) {
$article_filevar = 'archivestorytext.thtml';
} else {
$article_filevar = 'storytext.thtml';
}

if (empty($storyTpl)) {
$storyTpl = 'storytext.thtml';
}

$article = COM_newTemplate($_CONF['path_layout']);
$article->set_file(array(
'article' => $article_filevar
));
$blocks = array('image_noalign', 'image_rightalign', 'image_leftalign');
foreach ($blocks as $block) {
$article->set_block('article', $block);
}

$result = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} "
. "WHERE ai_sid = '{$ai_sid}' ORDER BY ai_img_num");
Expand Down Expand Up @@ -1239,15 +1261,14 @@ public function renderImageTags($text)
} else {
$imgSrc = $_CONF['site_url'] . '/getimage.php?mode=articles&amp;image=' . $A['ai_filename'];
}
$article->set_var('imgSrc', $imgSrc);

$sizeAttributes = COM_getImgSizeAttributes($_CONF['path_images'] . 'articles/' . $A['ai_filename']);

// Build image tags for each flavour of the image:
$img_noalign = '<img ' . $sizeAttributes . 'src="' . $imgSrc . '" alt=""' . XHTML . '>';
$img_leftalgn = '<img ' . $sizeAttributes . 'class="floatleft" src="' . $imgSrc . '" alt=""' . XHTML . '>';
$img_rightalgn = '<img ' . $sizeAttributes . 'class="floatright" src="' . $imgSrc . '" alt=""' . XHTML . '>';
$article->set_var('sizeAttributes', $sizeAttributes);

// Are we keeping unscaled images?
$link_url = '';
$link_title = '';
if ($_CONF['keep_unscaled_image'] == 1) {
// Yes we are, so, we need to find out what the filename
// of the original, unscaled image is:
Expand All @@ -1267,47 +1288,58 @@ public function renderImageTags($text)
// And finally, replace the [imageX_mode] tags with the
// image and its hyperlink (only when the large image
// actually exists)
$lLink_url = '';
$lLink_attr = '';
if (file_exists($lFilename_large_complete)) {
$lLink_url = $lFilename_large_URL;
$lLink_attr = array('title' => $LANG24[57]);
$link_url = $lFilename_large_URL;
$link_title = $LANG24[57];
}
}

$norm = '[image' . $i . ']';
$left = '[image' . $i . '_left]';
$right = '[image' . $i . '_right]';

if (!empty($lLink_url)) {
$text = str_replace($norm, COM_createLink($img_noalign, $lLink_url, $lLink_attr), $text);
$text = str_replace($left, COM_createLink($img_leftalgn, $lLink_url, $lLink_attr), $text);
$text = str_replace($right, COM_createLink($img_rightalgn, $lLink_url, $lLink_attr), $text);
} else {
// We aren't wrapping our image tags in hyperlinks, so
// just replace the [imagex_mode] tags with the image:
$text = str_replace($norm, $img_noalign, $text);
$text = str_replace($left, $img_leftalgn, $text);
$text = str_replace($right, $img_rightalgn, $text);
}


$article->set_var('link_url', $link_url);
$article->set_var('link_title', $link_title);

$article->parse('output', 'image_noalign');
$img_noalign = $article->finish($article->get_var('output'));
$text = str_replace($norm, $img_noalign, $text);

$article->parse('output', 'image_rightalign');
$img_rightalgn = $article->finish($article->get_var('output'));
$text = str_replace($right, $img_rightalgn, $text);

$article->parse('output', 'image_leftalign');
$img_leftalgn = $article->finish($article->get_var('output'));
$text = str_replace($left, $img_leftalgn, $text);

// And insert the unscaled mode images:
if (($_CONF['allow_user_scaling'] == 1) && ($_CONF['keep_unscaled_image'] == 1)) {
if (file_exists($lFilename_large_complete)) {
$imgSrc = $lFilename_large_URL;
$sizeAttributes = COM_getImgSizeAttributes($lFilename_large_complete);

$article->set_var('imgSrc', $imgSrc);
$article->set_var('sizeAttributes', $sizeAttributes);
}
$article->set_var('link_url', '');
$article->set_var('link_title', '');

$unscaledNorm = '[unscaled' . $i . ']';
$unscaledLeft = '[unscaled' . $i . '_left]';
$unscaledRight = '[unscaled' . $i . '_right]';

$text = str_replace($unscaledNorm,
'<img ' . $sizeAttributes . 'src="' . $imgSrc . '" alt=""' . XHTML . '>', $text);
$text = str_replace($unscaledLeft,
'<img ' . $sizeAttributes . 'align="left" src="' . $imgSrc . '" alt=""' . XHTML . '>', $text);
$text = str_replace($unscaledRight,
'<img ' . $sizeAttributes . 'align="right" src="' . $imgSrc . '" alt=""' . XHTML . '>', $text);

$article->parse('output', 'image_noalign');
$img_noalign = $article->finish($article->get_var('output'));
$text = str_replace($unscaledNorm, $img_noalign, $text);

$article->parse('output', 'image_rightalign');
$img_rightalgn = $article->finish($article->get_var('output'));
$text = str_replace($unscaledRight, $img_rightalgn, $text);

$article->parse('output', 'image_leftalign');
$img_leftalgn = $article->finish($article->get_var('output'));
$text = str_replace($unscaledLeft, $img_leftalgn, $text);
}
}

Expand Down

0 comments on commit 02c33b2

Please sign in to comment.