diff options
| author | Nick Palmer <nick@sluggardy.net> | 2007-04-06 14:19:18 +0000 |
|---|---|---|
| committer | Nick Palmer <nick@sluggardy.net> | 2007-04-06 14:19:18 +0000 |
| commit | e9b05de00b8d166641e267439c5960816d12f48e (patch) | |
| tree | c9b2e874d226cf50f75e50d49a064a9874261d74 | |
| parent | 214609e976052b0a84e0a294ca365dc53489b9c1 (diff) | |
| download | liberty-e9b05de00b8d166641e267439c5960816d12f48e.tar.gz liberty-e9b05de00b8d166641e267439c5960816d12f48e.tar.bz2 liberty-e9b05de00b8d166641e267439c5960816d12f48e.zip | |
Add preview function to liberty content and improve generic display_content.
| -rw-r--r-- | LibertyContent.php | 32 | ||||
| -rw-r--r-- | templates/display_content.tpl | 36 |
2 files changed, 64 insertions, 4 deletions
diff --git a/LibertyContent.php b/LibertyContent.php index c6e2399..fe1b029 100644 --- a/LibertyContent.php +++ b/LibertyContent.php @@ -3,7 +3,7 @@ * Management of Liberty content * * @package liberty -* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.196 2007/04/05 16:02:20 bitweaver Exp $ +* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.197 2007/04/06 14:19:18 nickpalmer Exp $ * @author spider <spider@steelsun.com> */ @@ -2499,5 +2499,35 @@ class LibertyContent extends LibertyBase { return( $this->mDb->getAssoc( "SELECT `content_status_id`, `content_status_name` FROM `".BIT_DB_PREFIX."liberty_content_status` WHERE `content_status_id` > ? AND `content_status_id` < ? ORDER BY `content_status_id`", array($pUserMinimum, $pUserMaximum))); } } + + /** + * getPreview -- Returns a string with a preview of the content. Default implementation runs getRenderFile() with preview set in the context and gBitSystem set to only render the content. + * + * @access public + * @return the preview string + **/ + function getPreview() { + global $gBitSystem, $gContent, $gBitSmarty; + // Tell gBitSystem not to do modules and such + $gBitSystem->onlyRenderContent(); + // Tell the content we are previewing (in case they care) + $gBitSmarty->assign('preview', true); + // Save current gContent + $oldGContent = $gContent; + // Make us the content + $gContent = $this; + + $ret = get_include_contents($this->getRenderFile()); + + // Return gBitSystem to full render mode + $gBitSystem->onlyRenderContent(false); + // Clear the preview flag + $gBitSmarty->assign('preview', false); + // Restore gContent + $gContent = $oldGContent; + + return $ret; + } + } ?> diff --git a/templates/display_content.tpl b/templates/display_content.tpl index 18e291d..7901cfa 100644 --- a/templates/display_content.tpl +++ b/templates/display_content.tpl @@ -1,3 +1,33 @@ -Generic Content display template. -<br /> -Title: {$pageInfo.title|escape} +{strip} +<div class="display content"> +{if $gContent->isValid()} + <div class="floaticon"> + {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='icon' serviceHash=$gContent->mInfo} + </div><!-- end .floaticon --> + + <div class="header"> + <h1>{$gContent->mInfo.title|default:"No Title"}</h1> + {* creator_user not yet forced by liberty so check. *} + {if !$preview && !empty($gContent->mInfo.creator_user)} + <div class="date"> + {tr}Created by {displayname user=$gContent->mInfo.creator_user user_id=$gContent->mInfo.creator_user_id real_name=$gContent->mInfo.creator_real_name}, Last modification by {displayname user=$gContent->mInfo.modifier_user user_id=$gContent->mInfo.modifier_user_id real_name=$gContent->mInfo.modifier_real_name} on {$gContent->mInfo.last_modified|bit_long_datetime}{/tr} + </div> + {/if} + </div><!-- end .header --> + + <div class="body"> + {include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$gContent->mInfo} + {if !empty($gContent->mInfo.parsed_data)} + <div class="content"> + {$gContent->mInfo.parsed_data} + </div><!-- end .content --> + {/if} + </div><!-- end .body --> +{if !$preview} +{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='view' serviceHash=$gContent->mInfo} +{/if} +{else} + <div class=error>No such Content.</div> +{/if} +</div> +{/strip} |
