function initChecker($aValues = array(), $aSpecificValues = array()) { parent::initChecker($aValues, $aSpecificValues); $CNF =& $this->_oModule->_oConfig->CNF; foreach ($this->_aImageFields as $sField => $aVals) { if (!isset($this->aInputs[$sField])) { continue; } if ($aValues && !empty($aValues[$CNF['FIELD_ID']])) { $this->aInputs[$sField]['content_id'] = $aValues[$CNF['FIELD_ID']]; } $sErrorString = ''; $this->aInputs[$sField]['file_id'] = $this->_processFile($sField, isset($aValues[$sField]) ? $aValues[$sField] : 0, $sErrorString); if ($sErrorString) { $this->aInputs[$sField]['error'] = $sErrorString; $this->setValid(false); } if (!isset($this->aInputs[$aVals['field_preview']]) || !empty($this->aInputs[$aVals['field_preview']]['content'])) { continue; } $oTranscoder = BxDolImageTranscoder::getObjectInstance($aVals['images_transcoder']); $aVars = array('bx_if:picture' => array('condition' => $oTranscoder && isset($aValues[$sField]) && $aValues[$sField] ? true : false, 'content' => array('picture_url' => $oTranscoder && isset($aValues[$sField]) && $aValues[$sField] ? $oTranscoder->getImageUrl($aValues[$sField]) : '')), 'bx_if:no_picture' => array('condition' => !$oTranscoder || !isset($aValues[$sField]) || !$aValues[$sField] ? true : false, 'content' => array())); $this->aInputs[$aVals['field_preview']]['content'] = $this->_oModule->_oTemplate->parseHtmlByName('picture_preview.html', $aVars); } }
/** * page code function */ function PageCompMainCode() { ob_start(); $iProfileId = 123; bx_import('BxDolImageTranscoder'); $oTranscoder = BxDolImageTranscoder::getObjectInstance('sample'); if (!$oTranscoder) { die('Transcoder object isn\'t defined'); } echo "registerHandlers: [" . $oTranscoder->registerHandlers() . "] <hr />\n"; echo "\n<script>\n\$(document).ready(function () {\n \$('img').on('load', function () {\n \$(this).after(' <span>size: <b>' + \$(this).width() + 'x' + \$(this).height() + '</b></span>')\n });\n});\n</script>\n"; $oStorage = $oTranscoder->getStorage(); if (isset($_POST['delete'])) { foreach ($_POST['file_id'] as $iFileId) { $bRet = $oStorage->deleteFile($iFileId, $iProfileId); if ($bRet) { echo "<hr />deleted file id: " . $iFileId . "<hr />"; } else { echo "<hr />file deleting error: " . $oStorage->getErrorString() . "<hr />"; } } } else { $sPath = BX_DIRECTORY_PATH_ROOT . 'samples/img/'; $h = opendir($sPath); while (false !== ($sFile = readdir($h))) { if ('.' == $sFile[0] || !is_file($sPath . $sFile)) { continue; } $sUrl = $oTranscoder->getImageUrl($sFile); echo $sFile . ' : <img src="' . $sUrl . '" /> <br /> ' . $sUrl . ' <hr />'; } } $a = $oStorage->getFilesAll(); echo "<hr /> <h2>Files List:</h2>"; echo '<form method="POST">'; foreach ($a as $r) { echo '<input type="checkbox" name="file_id[]" value="' . $r['id'] . '" /> ' . $r['file_name'] . '<br />'; } echo '<input type="submit" name="delete" value="Delete" />'; echo '</form>'; $s = ob_get_clean(); return DesignBoxContent("Sample transcoder", $s, BX_DB_PADDING_DEF); }
protected function _getCommonData(&$aEvent) { $oModule = $this->getModule(); $sJsObject = $this->_oConfig->getJsObject('view'); $sPrefix = $this->_oConfig->getPrefix('common_post'); $sType = str_replace($sPrefix, '', $aEvent['type']); $aResult = array('owner_id' => $aEvent['object_id'], 'content_type' => $sType, 'content' => array('sample' => '_bx_timeline_txt_sample', 'url' => $this->_oConfig->getItemViewUrl($aEvent)), 'votes' => '', 'comments' => '', 'title' => '', 'description' => ''); switch ($sType) { case BX_TIMELINE_PARSE_TYPE_POST: if (!empty($aEvent['content'])) { $aResult['content'] = array_merge($aResult['content'], unserialize($aEvent['content'])); } $aLinks = $this->_oDb->getLinks($aEvent['id']); if (!empty($aLinks) && is_array($aLinks)) { foreach ($aLinks as $aLink) { $aResult['content']['links'][] = array('url' => $aLink['url'], 'title' => $aLink['title'], 'text' => $aLink['text']); } } $aPhotos = $this->_oDb->getPhotos($aEvent['id']); if (!empty($aPhotos) && is_array($aPhotos)) { bx_import('BxDolStorage'); $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage')); bx_import('BxDolImageTranscoder'); $oTranscoder = BxDolImageTranscoder::getObjectInstance($this->_oConfig->getObject('transcoder_view')); foreach ($aPhotos as $iPhotoId) { $iPhotoIndex = array_search($iPhotoId, $aPhotos); $sPhotoSrcOrig = $oStorage->getFileUrlById($iPhotoId); $aResult['content']['images'][] = array('src' => $oTranscoder->getImageUrl($iPhotoId), 'src_orig' => $sPhotoSrcOrig, 'title' => '', 'onclick' => $sJsObject . '.showPhoto(this, \'' . $sPhotoSrcOrig . '\')'); } } break; case BX_TIMELINE_PARSE_TYPE_SHARE: if (empty($aEvent['content'])) { return array(); } $aContent = unserialize($aEvent['content']); if (!$this->_oConfig->isSystem($aContent['type'], $aContent['action'])) { $aShared = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $aContent['object_id'])); $aShared = $this->_getCommonData($aShared); } else { $aShared = $this->_getSystemData($aContent); } if (empty($aShared) || !is_array($aShared)) { return array(); } $aResult['content'] = array_merge($aContent, $aShared['content']); $aResult['content']['parse_type'] = !empty($aShared['content_type']) ? $aShared['content_type'] : BX_TIMELINE_PARSE_TYPE_DEFAULT; $aResult['content']['owner_id'] = $aShared['owner_id']; list($aResult['content']['owner_name'], $aResult['content']['owner_url']) = $oModule->getUserInfo($aShared['owner_id']); list($sUserName) = $oModule->getUserInfo($aEvent['object_id']); $sSample = !empty($aResult['content']['sample']) ? $aResult['content']['sample'] : '_bx_timeline_txt_sample'; $aResult['title'] = _t('_bx_timeline_txt_user_shared_sample', $sUserName, $aResult['content']['owner_name'], _t($sSample)); $aResult['description'] = ''; break; } $sSystem = $this->_oConfig->getSystemName('vote'); if ($oModule->getVoteObject($sSystem, $aEvent['id']) !== false) { $aResult['votes'] = array('system' => $sSystem, 'object_id' => $aEvent['id'], 'count' => $aEvent['votes']); } $sSystem = $this->_oConfig->getSystemName('comment'); if ($oModule->getCmtsObject($sSystem, $aEvent['id']) !== false) { $aResult['comments'] = array('system' => $sSystem, 'object_id' => $aEvent['id'], 'count' => $aEvent['comments']); } return $aResult; }
/** * Called automatically, upon original file deletetion. */ public static function onAlertResponseFileDeleteOrig($oAlert, $sObject) { $oTranscoder = BxDolImageTranscoder::getObjectInstance($sObject); if (!$oTranscoder) { return; } if ($oAlert->sAction != 'file_deleted') { return; } $oTranscoder->onDeleteFileOrig($oAlert->iObject); }
/** * get one just posted comment * * @param int $iCmtId - comment id * @return string */ function getComment($mixedCmt, $aBp = array(), $aDp = array()) { $oTemplate = BxDolTemplate::getInstance(); $iUserId = $this->_getAuthorId(); $aCmt = !is_array($mixedCmt) ? $this->getCommentRow((int) $mixedCmt) : $mixedCmt; list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($aCmt['cmt_author_id']); $sClass = ''; if (isset($aCmt['vote_rate']) && (double) $aCmt['vote_rate'] < $this->_aSystem['viewing_threshold']) { $oTemplate->pareseHtmlByName('comment_hidden.html', array('js_object' => $this->_sJsObjName, 'id' => $aCmt['cmt_id'], 'title' => bx_process_output(_t('_hidden_comment', $sAuthorName)), 'bx_if:show_replies' => array('condition' => $aCmt['cmt_replies'] > 0, 'content' => array('replies' => _t('_Show N replies', $aCmt['cmt_replies']))))); $sClass = ' cmt-hidden'; } if ($aCmt['cmt_author_id'] == $iUserId) { $sClass .= ' cmt-mine'; } $sActions = $this->_getActionsBox($aCmt, $aDp); $sText = $aCmt['cmt_text']; $sTextMore = ''; $iMaxLength = (int) $this->_aSystem['chars_display_max']; if (strlen($sText) > $iMaxLength) { $iLength = strpos($sText, ' ', $iMaxLength); $sTextMore = trim(substr($sText, $iLength)); $sText = trim(substr($sText, 0, $iLength)); } $sText = $this->_prepareTextForOutput($sText); $sTextMore = $this->_prepareTextForOutput($sTextMore); $aTmplReplyTo = array(); if ((int) $aCmt['cmt_parent_id'] != 0) { $aParent = $this->getCommentRow($aCmt['cmt_parent_id']); list($sParAuthorName, $sParAuthorLink, $sParAuthorIcon) = $this->_getAuthorInfo($aParent['cmt_author_id']); $aTmplReplyTo = array('style_prefix' => $this->_sStylePrefix, 'par_cmt_link' => $this->getBaseUrl() . '#' . $this->_sSystem . $aCmt['cmt_parent_id'], 'par_cmt_author' => $sParAuthorName); } $aTmplImages = array(); if ($this->isAttachImageEnabled()) { $aImages = $this->_oQuery->getImages($this->_aSystem['system_id'], $aCmt['cmt_id']); if (!empty($aImages) && is_array($aImages)) { bx_import('BxDolStorage'); $oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject); bx_import('BxDolImageTranscoder'); $oTranscoder = BxDolImageTranscoder::getObjectInstance($this->_sTranscoderPreview); foreach ($aImages as $aImage) { $aTmplImages[] = array('style_prefix' => $this->_sStylePrefix, 'js_object' => $this->_sJsObjName, 'image' => $oTranscoder->getImageUrl($aImage['image_id']), 'image_orig' => $oStorage->getFileUrlById($aImage['image_id'])); } } } $sReplies = ''; if ((int) $aCmt['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED) { $sReplies = $this->getComments(array('parent_id' => $aCmt['cmt_id'], 'vparent_id' => $aCmt['cmt_id'], 'type' => $aBp['type']), $aDp); } $bAuthorIcon = !empty($sAuthorIcon); return $oTemplate->parseHtmlByName('comment.html', array('system' => $this->_sSystem, 'style_prefix' => $this->_sStylePrefix, 'js_object' => $this->_sJsObjName, 'id' => $aCmt['cmt_id'], 'class' => $sClass, 'bx_if:show_icon' => array('condition' => $bAuthorIcon, 'content' => array('author_icon' => $sAuthorIcon)), 'bx_if:show_icon_empty' => array('condition' => !$bAuthorIcon, 'content' => array()), 'bx_if:show_author_link' => array('condition' => !empty($sAuthorLink), 'content' => array('author_link' => $sAuthorLink, 'author_name' => $sAuthorName)), 'bx_if:show_author_text' => array('condition' => empty($sAuthorLink), 'content' => array('author_name' => $sAuthorName)), 'bx_if:show_reply_to' => array('condition' => !empty($aTmplReplyTo), 'content' => $aTmplReplyTo), 'text' => $sText, 'bx_if:show_more' => array('condition' => !empty($sTextMore), 'content' => array('style_prefix' => $this->_sStylePrefix, 'js_object' => $this->_sJsObjName, 'text_more' => $sTextMore)), 'bx_if:show_attached' => array('condition' => !empty($aTmplImages), 'content' => array('style_prefix' => $this->_sStylePrefix, 'bx_repeat:attached' => $aTmplImages)), 'actions' => $sActions, 'replies' => $sReplies)); }
function entryAttachments($aData) { $oModule = BxDolModule::getInstance($this->MODULE); $CNF =& $oModule->_oConfig->CNF; bx_import('BxTemplFunctions'); bx_import('BxDolStorage'); bx_import('BxDolImageTranscoder'); $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']); $oTranscoder = BxDolImageTranscoder::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']); $aGhostFiles = $oStorage->getGhosts($aData[$CNF['FIELD_AUTHOR']], $aData[$CNF['FIELD_ID']]); if (!$aGhostFiles) { return false; } foreach ($aGhostFiles as $k => $a) { $isImage = $oTranscoder && 0 == strncmp('image/', $a['mime_type'], 6); // preview for images only and transcoder object for preview must be defined $sUrlOriginal = $oStorage->getFileUrlById($a['id']); $sImgPopupId = 'bx-messages-atachment-popup-' . $a['id']; // images are displayed with preview and popup upon clicking $aGhostFiles[$k]['bx_if:image'] = array('condition' => $isImage, 'content' => array('url_original' => $sUrlOriginal, 'attr_file_name' => bx_html_attribute($a['file_name']), 'popup_id' => $sImgPopupId, 'url_preview' => $oTranscoder->getImageUrl($a['id']), 'popup' => BxTemplFunctions::getInstance()->transBox($sImgPopupId, '<img src="' . $sUrlOriginal . '" />', true, true))); // non-images are displayed as text links to original file $aGhostFiles[$k]['bx_if:not_image'] = array('condition' => !$isImage, 'content' => array('url_original' => $sUrlOriginal, 'attr_file_name' => bx_html_attribute($a['file_name']), 'file_name' => bx_process_output($a['file_name']))); } $aVars = array('bx_repeat:attachments' => $aGhostFiles); return $this->parseHtmlByName('attachments.html', $aVars); }
/** * Display uploaded, but not saved files - ghosts * @return HTML or JSON string */ public function getGhosts($iProfileId, $sFormat, $sImagesTranscoder = false, $iContentId = false) { bx_import('BxDolStorage'); $oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject); $oImagesTranscoder = false; if ($sImagesTranscoder) { bx_import('BxDolImageTranscoder'); $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance($sImagesTranscoder); } $a = ''; $aGhosts = $oStorage->getGhosts($iProfileId, $iContentId); foreach ($aGhosts as $aFile) { $sFileIcon = $oImagesTranscoder && 0 == strncmp($aFile['mime_type'], 'image/', 6) ? $oImagesTranscoder->getImageUrl($aFile['id']) : $this->_oTemplate->getIconUrl($oStorage->getIconNameByFileName($aFile['file_name'])); $a[$aFile['id']] = array('file_id' => $aFile['id'], 'file_name' => $aFile['file_name'], 'file_title' => $oStorage->getFileTitle($aFile['file_name']), 'file_icon' => $sFileIcon, 'file_url' => $oStorage->getFileUrlById($aFile['id']), 'js_instance_name' => $this->_sUploaderJsInstance); } if ('json' == $sFormat) { return json_encode($a); } else { // html format is not suported for this data type return false; } }
/** * Get HTML code for meta icons. * @return HTML string to insert into HEAD section */ function getMetaIcons() { $iId = (int) getParam('sys_site_icon'); $sImageUrlFav = $sImageUrlFcb = $sImageUrlApl = ''; if (!empty($iId)) { bx_import('BxDolImageTranscoder'); // favicon icon $oTranscoder = BxDolImageTranscoder::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_FAVICON); $sImageUrlFav = $oTranscoder->getImageUrl($iId); // facebook icon $oTranscoder = BxDolImageTranscoder::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK); $sImageUrlFcb = $oTranscoder->getImageUrl($iId); // apple touch icon $oTranscoder = BxDolImageTranscoder::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_APPLE); $sImageUrlApl = $oTranscoder->getImageUrl($iId); } if (empty($sImageUrlFav)) { $sImageUrlFav = $this->_oTemplate->getIconUrl('favicon.png'); } if (empty($sImageUrlFcb)) { $sImageUrlFcb = $this->_oTemplate->getIconUrl('facebook-icon.png'); } if (empty($sImageUrlApl)) { $sImageUrlApl = $this->_oTemplate->getIconUrl('apple-touch-icon.png'); } $sRet = ''; $sRet .= '<link rel="icon" sizes="16x16" type="image/png" href="' . $sImageUrlFav . '" />'; $sRet .= '<link rel="image_src" sizes="100x100" href="' . $sImageUrlFcb . '" />'; $sRet .= '<link rel="apple-touch-icon" sizes="152x152" href="' . $sImageUrlApl . '" />'; return $sRet; }
protected function getIcon() { $oTemplate = BxDolStudioTemplate::getInstance(); $sPreview = ""; $aTmplVars = array('bx_repeat:images' => array()); if (($iId = (int) getParam('sys_site_icon')) != 0) { $aTranscoders = array(BX_DOL_TRANSCODER_OBJ_ICON_APPLE => '_adm_dsg_txt_icon_apple', BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK => '_adm_dsg_txt_icon_facebook', BX_DOL_TRANSCODER_OBJ_ICON_FAVICON => '_adm_dsg_txt_icon_favicon'); bx_import('BxDolImageTranscoder'); foreach ($aTranscoders as $sTranscoder => $sTitle) { $oTranscoder = BxDolImageTranscoder::getObjectInstance($sTranscoder); $sImageUrl = $oTranscoder->getImageUrl($iId); if ($sImageUrl === false) { setParam('sys_site_icon', 0); break; } $aTmplVars['bx_repeat:images'][] = array('caption' => _t($sTitle), 'url' => $sImageUrl); } $sPreview = $oTemplate->parseHtmlByName('dsr_icon_preview.html', $aTmplVars); } $aForm = array('form_attrs' => array('id' => $this->sIconFormId, 'name' => $this->sIconFormId, 'action' => BX_DOL_URL_STUDIO . 'designer.php', 'method' => 'post', 'enctype' => 'multipart/form-data', 'target' => $this->sIconIframeId), 'params' => array('db' => array('table' => '', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'save')), 'inputs' => array('page' => array('type' => 'hidden', 'name' => 'page', 'value' => $this->sPage), 'preview' => array('type' => 'custom', 'name' => 'preview', 'content' => $sPreview), 'image' => array('type' => 'file', 'name' => 'image', 'caption' => _t('_adm_dsg_txt_upload_icon')), 'save' => array('type' => 'submit', 'name' => 'save', 'value' => _t('_adm_btn_designer_submit')))); $oForm = new BxTemplStudioFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { echo $this->submitIcon($oForm); exit; } $aTmplVars = array('js_object' => $this->getPageJsObject(), 'bx_repeat:blocks' => array(array('caption' => '', 'panel_top' => '', 'items' => $oTemplate->parseHtmlByName('dsr_icon.html', array('icon_iframe_id' => $this->sIconIframeId, 'form' => $oForm->getCode())), 'panel_bottom' => ''))); return $oTemplate->parseHtmlByName('designer.html', $aTmplVars); }
* @{ */ if (isset($_GET['devicePixelRatio'])) { $sDpr = $_GET['devicePixelRatio']; if ('' . ceil(intval($sDpr)) !== $sDpr) { $sDpr = '1'; } setcookie('devicePixelRatio', $sDpr, time() + 60 * 60 * 24 * 365); exit; } ob_start(); require_once './inc/header.inc.php'; $sTranscoderObject = bx_process_input(bx_get('o')); $sHandler = bx_process_input(bx_get('h')); bx_import('BxDolImageTranscoder'); $oTranscoder = BxDolImageTranscoder::getObjectInstance($sTranscoderObject); if (!$oTranscoder) { ob_end_clean(); bx_transcoder_error_occured(); exit; } ob_end_clean(); if (!$oTranscoder->isImageReady($sHandler) && !$oTranscoder->transcode($sHandler)) { bx_transcoder_error_occured(); exit; } $sImageUrl = $oTranscoder->getImageUrl($sHandler); if (!$sImageUrl) { bx_transcoder_error_occured(); exit; }
/** * Get profile picture icon url */ function _image($sField, $sTranscodeObject, $sNoImage, $aData, $bSubstituteNoImage = true) { $sImageUrl = false; if ($aData[$sField]) { bx_import('BxDolImageTranscoder'); $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance($sTranscodeObject); if ($oImagesTranscoder) { $sImageUrl = $oImagesTranscoder->getImageUrl($aData[$sField]); } } return $bSubstituteNoImage && !$sImageUrl ? $this->getImageUrl($sNoImage) : $sImageUrl; }