| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup Notes Notes
- * @ingroup DolphinModules
- *
- * @{
- */
- bx_import('BxDolModuleTemplate');
- /*
- * Notes module representation.
- */
- class BxNotesTemplate extends BxDolModuleTemplate {
- /**
- * Constructor
- */
- function __construct(&$oConfig, &$oDb) {
- parent::__construct($oConfig, $oDb);
- $this->addCss ('main.css');
- }
- function unit ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html') {
- $oModule = BxDolModule::getInstance('bx_notes');
- if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->isAllowedView($aData))) {
- $aVars = array (
- 'summary' => $sMsg,
- );
- return $this->parseHtmlByName('unit_private.html', $aVars);
- }
- // get thumb url
- $sPhotoThumb = '';
- if ($aData[BxNotesConfig::$FIELD_THUMB]) {
- bx_import('BxDolImageTranscoder');
- $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance(BxNotesConfig::$OBJECT_IMAGES_TRANSCODER_PREVIEW);
- if ($oImagesTranscoder)
- $sPhotoThumb = $oImagesTranscoder->getImageUrl($aData[BxNotesConfig::$FIELD_THUMB]);
- }
- // get note url
- bx_import('BxDolPermalinks');
- $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=view-note&id=' . $aData['id']);
- bx_import('BxDolProfile');
- $oProfile = BxDolProfile::getInstance($aData['author']);
- if (!$oProfile) {
- bx_import('BxDolProfileUndefined');
- $oProfile = BxDolProfileUndefined::getInstance();
- }
- $sSummary = $aData['summary'];
- if (!$sSummary) {
- $iLimitChars = (int)getParam('bx_notes_summary_chars');
- $sSummary = trim(strip_tags($aData['text']));
- $sLinkMore = '';
- if (mb_strlen($sSummary) > $iLimitChars) {
- $sSummary = mb_substr($sSummary, 0, $iLimitChars);
- $sLinkMore = ' <a title="' . bx_html_attribute(_t('_bx_notes_txt_read_more', $aData['title'])) . '" href="' . $sUrl . '"><i class="sys-icon ellipsis-horizontal"></i></a>';
- }
- $sSummary = htmlspecialchars_adv($sSummary) . $sLinkMore;
- }
- $sSummaryPlain = BxTemplFunctions::getInstance()->getStringWithLimitedLength(strip_tags($sSummary), 380);
- // generate html
- $aVars = array (
- 'id' => $aData['id'],
- 'content_url' => $sUrl,
- 'title' => bx_process_output($aData['title']),
- 'summary' => $sSummary,
- 'author' => $oProfile->getDisplayName(),
- 'author_url' => $oProfile->getUrl(),
- 'entry_posting_date' => bx_time_js($aData['added'], BX_FORMAT_DATE),
- 'bx_if:thumb' => array (
- 'condition' => $sPhotoThumb,
- 'content' => array (
- 'title' => bx_process_output($aData['title']),
- 'summary_attr' => bx_html_attribute($sSummaryPlain),
- 'content_url' => $sUrl,
- 'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',
- ),
- ),
- 'bx_if:no_thumb' => array (
- 'condition' => !$sPhotoThumb,
- 'content' => array (
- 'content_url' => $sUrl,
- 'summary_plain' => $sSummaryPlain,
- ),
- ),
- );
- return $this->parseHtmlByName($sTemplateName, $aVars);
- }
- function entryText ($aData, $sTemplateName = 'entry-text.html') {
- $aVars = $aData;
- $aVars['entry_title'] = $aData[BxNotesConfig::$FIELD_TITLE];
- $aVars['entry_text'] = $aData[BxNotesConfig::$FIELD_TEXT];
- return $this->parseHtmlByName($sTemplateName, $aVars);
- }
- function entryAuthor ($aData, $oProfile, $sTemplateName = 'author.html') {
- if (!$oProfile)
- return '';
- $aVars = array (
- 'author_url' => $oProfile->getUrl(),
- 'author_thumb_url' => $oProfile->getThumb(),
- 'author_title' => $oProfile->getDisplayName(),
- 'entry_posting_date' => bx_time_js($aData['added'], BX_FORMAT_DATE),
- );
- return $this->parseHtmlByName($sTemplateName, $aVars);
- }
- }
- /** @} */
|