Skip to content

Commit

Permalink
Hack articles to use the new primary_attachment_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpalmer committed Jun 13, 2007
1 parent 1752b88 commit 4505032
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
23 changes: 16 additions & 7 deletions BitArticle.php
@@ -1,6 +1,6 @@
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticle.php,v 1.113 2007/06/10 14:33:48 squareing Exp $
* @version $Header: /cvsroot/bitweaver/_bit_articles/BitArticle.php,v 1.114 2007/06/13 00:43:54 nickpalmer Exp $
* @package article
*
* Copyright( c )2004 bitweaver.org
Expand All @@ -9,14 +9,14 @@
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
* $Id: BitArticle.php,v 1.113 2007/06/10 14:33:48 squareing Exp $
* $Id: BitArticle.php,v 1.114 2007/06/13 00:43:54 nickpalmer Exp $
*
* Article class is used when accessing BitArticles. It is based on TikiSample
* and builds on core bitweaver functionality, such as the Liberty CMS engine.
*
* created 2004/8/15
* @author wolffy <wolff_borg@yahoo.com.au>
* @version $Revision: 1.113 $ $Date: 2007/06/10 14:33:48 $ $Author: squareing $
* @version $Revision: 1.114 $ $Date: 2007/06/13 00:43:54 $ $Author: nickpalmer $
*/

/**
Expand Down Expand Up @@ -103,7 +103,9 @@ function load( $pVersion = 0 ) {
$this->mInfo = $result->fetchRow();

// if a custom image for the article exists, use that, then use an attachment, then use the topic image
$this->mInfo['image_url'] = BitArticle::getImageUrl( $this->mInfo );
$isTopicImage = false;
$this->mInfo['image_url'] = BitArticle::getImageUrl( $this->mInfo, $isTopicImage);
$this->mInfo['image_url_is_topic'] = $isTopicImage;

$this->mContentId = $this->mInfo['content_id'];
$this->mArticleId = $this->mInfo['article_id'];
Expand Down Expand Up @@ -473,7 +475,9 @@ function preparePreview( $pParamHash ) {
LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_files` lf ON( lf.`file_id` = la.`foreign_id` )
WHERE la.attachment_id=?";
$data['image_storage_path'] = $this->mDb->getOne( $query, array( $data['image_attachment_id'] ) );
$data['image_url'] = BitArticle::getImageUrl( $data );
$isTopicUrl = false;
$data['image_url'] = BitArticle::getImageUrl( $data , $isTopicUrl);
$data['image_url_is_topic'] = $isTopicUrl;
}

if( !empty( $_FILES['article_image']['name'] ) ) {
Expand Down Expand Up @@ -535,7 +539,7 @@ function getImagePath() {
* @return url to image
* @access public
**/
function getImageUrl( $pParamHash ) {
function getImageUrl( $pParamHash, &$pIsTopicImage) {
$ret = NULL;
// if a custom image for the article exists, use that, then use an attachment, then use the topic image
if( @$this->verifyId( $pParamHash['article_id'] ) && BitArticle::getArticleImageStorageUrl( $pParamHash['article_id'] ) ) {
Expand All @@ -551,6 +555,9 @@ function getImageUrl( $pParamHash ) {
}
} elseif( !empty( $pParamHash['has_topic_image'] ) && $pParamHash['has_topic_image'] == 'y' ) {
$ret = BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
if ($pIsTopicImage) {
$pIsTopicImage = true;
}
}
return $ret;
}
Expand Down Expand Up @@ -710,7 +717,9 @@ function getList( &$pParamHash ) {
// get this stuff parsed
$res = array_merge( $this->parseSplit( $res, $gBitSystem->getConfig( 'articles_description_length', 500 )), $res );

$res['image_url'] = BitArticle::getImageUrl( $res );
$isTopicUrl = false;
$res['image_url'] = BitArticle::getImageUrl( $res , $isTopicUrl);
$res['image_url_is_topic'] = $isTopicUrl;
$res['num_comments'] = $comment->getNumComments( $res['content_id'] );
$res['display_url'] = $this->getDisplayUrl( $res['article_id'] );
$res['display_link'] = $this->getDisplayLink( $res['title'], $res );
Expand Down
13 changes: 11 additions & 2 deletions templates/article_display.tpl
@@ -1,4 +1,4 @@
{* $Header: /cvsroot/bitweaver/_bit_articles/templates/article_display.tpl,v 1.36 2007/05/27 18:29:11 laetzer Exp $ *}
{* $Header: /cvsroot/bitweaver/_bit_articles/templates/article_display.tpl,v 1.37 2007/06/13 00:43:54 nickpalmer Exp $ *}
{strip}
{if !$showDescriptionsOnly}
{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='nav' serviceHash=$article}
Expand Down Expand Up @@ -38,7 +38,16 @@
<div class="body"{if $gBitUser->getPreference( 'users_double_click' ) and $gBitUser->hasPermission( 'p_articles_edit' )} ondblclick="location.href='{$smarty.const.ARTICLES_PKG_URL}edit.php?article_id={$article.article_id}';"{/if}>
<div class="content">
{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$article}
{if $article.show_image eq 'y' && $article.image_url}
{* If there is a custom primary override *}
{if !empty($article.primary_attachment_id)}
<div class="image">
{if $showDescriptionsOnly and $article.has_more}<a href="{$article.display_url}">{/if}
{assign var=image value=$gContent->mStorage[$article.primary_attachment_id]}
{jspopup notra=1 href=$image.source_url alt=$article.topic_name|default:$article.title|escape title=$article.topic_name|default:$article.title|escape" img=$image.thumbnail_url.small}
{if $showDescriptionsOnly and $article.has_more}</a>{/if}
</div>
{elseif $article.show_image eq 'y' && $article.image_url}
{* Support for legacy images and topic images. *}
<div class="image">
{if $showDescriptionsOnly and $article.has_more}<a href="{$article.display_url}">{/if}
<img class="icon" alt="{$article.topic_name|default:$article.title|escape}" title="{$article.topic_name|default:$article.title|escape}" src="{$article.image_url}"/>
Expand Down
24 changes: 12 additions & 12 deletions templates/edit_article.tpl
Expand Up @@ -161,33 +161,33 @@
</div>
{/legend}
{legend legend="Custom article image"}
{if $article.image_url}
{legend legend="Custom Topic image"}
{if $article.image_url && !$article.image_url_is_topic}
<div class="row">
{formlabel label="Custom Image"}
{formlabel label="Old Custom Image"}
{forminput}
<img alt="{tr}Article image{/tr}" title="{$article.title|escape}" src="{$article.image_url}"/>
<br />
<input type="submit" name="remove_image" value="{tr}Remove Image{/tr}" />
{formhelp note="You can replace this image by uploading a new one."}
{formhelp note="You can replace this image by removing this image and uploading a new one below."}
{/forminput}
</div>
{/if}

<div class="row">
{formlabel label="Custom Image" for="upload"}
{formlabel label="Custom Topic Image" for="upload"}
{forminput}
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input type="file" id="upload" name="article_image"/>
{formhelp note="Use a custom image file for the article."}
{include file="bitpackage:liberty/edit_primary_attachment.tpl"}
{/forminput}
</div>
{/legend}
{/jstab}

{if $gBitUser->hasPermission('p_liberty_attach_attachments')}
{include file="bitpackage:liberty/edit_storage.tpl"}
{/if}
{jstab title="Attachment Browser"}
{legend legend="Attachment Browser"}
{include file="bitpackage:liberty/edit_storage.tpl"}
{/legend}
{/jstab}

{/jstabs}
{/form}

Expand Down

0 comments on commit 4505032

Please sign in to comment.