本文整理汇总了PHP中BxDolStorage::getObjectInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP BxDolStorage::getObjectInstance方法的具体用法?PHP BxDolStorage::getObjectInstance怎么用?PHP BxDolStorage::getObjectInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxDolStorage
的用法示例。
在下文中一共展示了BxDolStorage::getObjectInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genRowImageUploader
function genRowImageUploader(&$aInput)
{
$aTmplVarsPreview = array('bx_if:show_empty' => array('condition' => true, 'content' => array()), 'bx_if:show_image' => array('condition' => false, 'content' => array()));
if (($iId = (int) $aInput['value']) != 0) {
$sFileUrl = false;
if (!empty($aInput['transcoder_object'])) {
$oTranscoder = BxDolTranscoderImage::getObjectInstance($aInput['transcoder_object']);
$sFileUrl = $oTranscoder->getFileUrlNotReady($iId);
if (isset($aInput['transcoder_image_width']) && $aInput['transcoder_image_width'] > 0) {
$sFileUrl = bx_append_url_params($sFileUrl, array('x' => $aInput['transcoder_image_width']));
}
if (isset($aInput['transcoder_image_height']) && $aInput['transcoder_image_height'] > 0) {
$sFileUrl = bx_append_url_params($sFileUrl, array('y' => $aInput['transcoder_image_height']));
}
} else {
$sStorage = isset($aInput['storage_object']) && $aInput['storage_object'] != '' ? $aInput['storage_object'] : BX_DOL_STORAGE_OBJ_IMAGES;
$oStorage = BxDolStorage::getObjectInstance($sStorage);
$sFileUrl = $oStorage->getFileUrlById($iId);
}
if ($sFileUrl !== false) {
$aTmplVarsPreview['bx_if:show_empty']['condition'] = false;
$aTmplVarsPreview['bx_if:show_image'] = array('condition' => true, 'content' => array('url' => $sFileUrl, 'bx_if:show_action_delete' => array('condition' => isset($aInput['ajax_action_delete']) && $aInput['ajax_action_delete'] != "", 'content' => array('action' => $aInput['ajax_action_delete']))));
}
}
$sRow = '';
$aInputPreview = array('type' => 'custom', 'name' => 'preview', 'caption' => isset($aInput['caption_preview']) ? $aInput['caption_preview'] : _t('_adm_txt_form_view_iu_preview'), 'content' => $this->oTemplate->parseHtmlByName('form_view_iu_preview.html', $aTmplVarsPreview));
$sRow .= $this->genRow($aInputPreview);
$aInput['type'] = 'file';
$sRow .= $this->genRow($aInput);
return $sRow;
}
示例2: getFileUrl
/**
* Depending on original file mime type call appropriate transcoder
*/
public function getFileUrl($mixedHandler)
{
$oStorageOriginal = BxDolStorage::getObjectInstance($this->_aObject['source_params']['object']);
if (!$oStorageOriginal) {
return false;
}
$aFile = $oStorageOriginal->getFile($mixedHandler);
if (!$aFile) {
return false;
}
$sTranscoder = '';
if (0 === strncmp($aFile['mime_type'], 'image/', 6) && !empty($this->_aObject['source_params']['image'])) {
$sTranscoder = $this->_aObject['source_params']['image'];
} elseif (0 === strncmp($aFile['mime_type'], 'video/', 6) && !empty($this->_aObject['source_params']['video_poster'])) {
$sTranscoder = $this->_aObject['source_params']['video_poster'];
// if additional video transcoders provided call it to force video conversion
if (empty($this->_aObject['source_params']['video'])) {
continue;
}
foreach ($this->_aObject['source_params']['video'] as $sVideoTranscoder) {
if (!($oTranscoder = BxDolTranscoderImage::getObjectInstance($sVideoTranscoder))) {
continue;
}
$oTranscoder->getFileUrl($mixedHandler);
}
}
if (!$sTranscoder) {
return false;
}
if (!($oTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscoder))) {
return false;
}
return $oTranscoder->getFileUrl($mixedHandler);
}
示例3: performActionImport
public function performActionImport()
{
$iAffected = 0;
$aIds = bx_get('ids');
if (!$aIds || !is_array($aIds)) {
$this->_echoResultJson(array());
exit;
}
$aIdsAffected = array();
foreach ($aIds as $iId) {
$aItem = array();
$iItem = $this->oDb->getItems(array('type' => 'by_id', 'value' => (int) $iId), $aItem);
if ($iItem != 1 || empty($aItem)) {
continue;
}
$mixedIcon = 0;
if (is_numeric($aItem['icon']) && (int) $aItem['icon'] != 0) {
bx_import('BxDolStorage');
$oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
if (($mixedIcon = $oStorage->storeFileFromStorage(array('id' => (int) $aItem['icon']), false, 0)) === false) {
$this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_copy') . $oStorage->getErrorString()), true);
return;
}
$oStorage->afterUploadCleanup($mixedIcon, 0);
}
$iIdImported = (int) $aItem['id'];
$sTitleKey = $aItem['title'];
unset($aItem['id']);
$aItem['set_name'] = $this->sSet;
$aItem['module'] = BX_DOL_STUDIO_MODULE_CUSTOM;
$aItem['title'] .= '_' . time();
$aItem['icon'] = $mixedIcon != 0 ? $mixedIcon : '';
$aItem['active'] = 1;
$aItem['order'] = $this->oDb->getItemOrderMax($this->sSet) + 1;
if (($iIdAdded = (int) $this->oDb->addItem($aItem)) == 0) {
continue;
}
bx_import('BxDolStudioLanguagesUtils');
BxDolStudioLanguagesUtils::getInstance()->addLanguageString($aItem['title'], _t($sTitleKey));
$aIdsImported[] = $iIdImported;
$aIdsAdded[] = $iIdAdded;
$iAffected++;
}
$aResult = array('msg' => _t('_adm_nav_err_items_import'));
if ($iAffected) {
$oGrid = BxDolGrid::getObjectInstance('sys_studio_nav_items');
if ($oGrid !== false) {
$aResult = array('parent_grid' => $oGrid->getCode(false), 'parent_blink' => $aIdsAdded, 'disable' => $aIdsImported, 'eval' => $this->getJsObject() . '.onImport(oData)');
}
}
$this->_echoResultJson($aResult);
}
示例4: uninstall
function uninstall($aParams, $bDisable = false)
{
// check if module is already waiting while files are deleting
bx_import('BxDolInstallerUtils');
if (BxDolInstallerUtils::isModulePendingUninstall($this->_aConfig['home_uri'])) {
return array('message' => _t('_adm_err_modules_pending_uninstall_already'), 'result' => false);
}
// queue for deletion storage files
$bSetModulePendingUninstall = false;
foreach ($this->_aStorages as $s) {
if (($o = BxDolStorage::getObjectInstance($s)) && $o->queueFilesForDeletionFromObject()) {
$bSetModulePendingUninstall = true;
}
}
// delete comments and queue for deletion comments attachments
bx_import('BxDolCmts');
$iFiles = 0;
BxDolCmts::onModuleUninstall($this->_aConfig['name'], $iFiles);
if ($iFiles) {
$bSetModulePendingUninstall = true;
}
// if some files were added to the queue, set module as pending uninstall
if ($bSetModulePendingUninstall) {
BxDolInstallerUtils::setModulePendingUninstall($this->_aConfig['home_uri']);
return array('message' => _t('_adm_err_modules_pending_uninstall'), 'result' => false);
}
// delete associated connections
if ($this->_aConnections) {
bx_import('BxDolConnection');
foreach ($this->_aConnections as $sObjectConnections => $a) {
$o = BxDolConnection::getObjectInstance($sObjectConnections);
if (!$o) {
continue;
}
$sFuncSuffix = 'DeleteInitiatorAndContent';
if (isset($a['conn']) && 'initiator' == $a['conn']) {
$sFuncSuffix = 'DeleteInitiator';
} elseif (isset($a['conn']) && 'content' == $a['conn']) {
$sFuncSuffix = 'DeleteContent';
}
if (isset($a['type']) && 'profiles' == $a['type']) {
$sFunc = 'onModuleProfile' . $sFuncSuffix;
$o->{$sFunc}($this->_aConfig['name']);
} else {
$sFunc = 'onModule' . $sFuncSuffix;
$o->{$sFunc}($a['table'], $a['field_id']);
}
}
}
return parent::uninstall($aParams, $bDisable);
}
示例5: deleteByItem
function deleteByItem(&$aItem)
{
if (is_numeric($aItem['icon']) && (int) $aItem['icon'] != 0) {
if (!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int) $aItem['icon'], 0)) {
return false;
}
}
if ((int) $this->_delete($aItem['id']) <= 0) {
return false;
}
$oLanguage = BxDolStudioLanguagesUtils::getInstance();
$oLanguage->deleteLanguageString($aItem['title_system']);
$oLanguage->deleteLanguageString($aItem['title']);
return true;
}
示例6: metaAdd
/**
* Add all available meta tags to the head section
* @return number of successfully added metas
*/
public function metaAdd($iId, $mixedImage = false)
{
$i = 0;
foreach ($this->_aMetas as $sMeta) {
$sFunc = $sMeta . 'AddMeta';
$i += $this->{$sFunc}($iId);
}
if ($mixedImage && is_array($mixedImage)) {
bx_import('BxDolStorage');
$oStorage = BxDolStorage::getObjectInstance($mixedImage['object']);
$mixedImage = $oStorage ? $oStorage->getFileUrlById($mixedImage['id']) : false;
}
if ($mixedImage) {
BxDolTemplate::getInstance()->addPageMetaImage($mixedImage);
}
return $i;
}
示例7: actionDeleteProfileImg
public function actionDeleteProfileImg($iFileId, $iContentId, $sFieldPicture)
{
$aResult = array();
$CNF =& $this->_oConfig->CNF;
$oSrorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
if (!($aFile = $oSrorage->getFile((int) $iFileId)) || !($aContentInfo = $this->_oDb->getContentInfoById($iContentId)) || $aContentInfo[$sFieldPicture] != (int) $iFileId) {
$aResult = array('error' => 1, 'msg' => _t('_sys_storage_err_file_not_found'));
}
if (!$aResult && !isLogged() || !$aResult && $aFile['profile_id'] != bx_get_logged_profile_id() && !$this->_isModerator()) {
$aResult = array('error' => 2, 'msg' => _t('_Access denied'));
}
$oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD'], $this->_oTemplate);
if (!$aResult && !$oForm->_deleteFile($iContentId, $sFieldPicture, (int) $iFileId, true)) {
$aResult = array('error' => 3, 'msg' => _t('_Failed'));
} elseif (!$aResult) {
$aResult = array('error' => 0, 'msg' => '');
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($aResult);
}
示例8: handleUploads
/**
* Handle uploads here.
* @param $mixedFiles as usual $_FILES['some_name'] array, but maybe some other params depending on the uploader
* @return nothing, but if some files failed to upload, the actual error message can be determined by calling BxDolUploader::getUploadErrorMessages()
*/
public function handleUploads($iProfileId, $mixedFiles, $isMultiple = true, $iContentId = false, $bPrivate = true)
{
$oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject);
$iProfileId = bx_get_logged_profile_id();
if (!$isMultiple) {
$this->cleanupGhostsForProfile($iProfileId, $iContentId);
}
if (bx_get('qqfile')) {
$iId = $oStorage->storeFileFromXhr(bx_get('qqfile'), $bPrivate, $iProfileId, $iContentId);
} else {
$iId = $oStorage->storeFileFromForm($_FILES['qqfile'], $bPrivate, $iProfileId, $iContentId);
}
if ($iId) {
$aResponse = array('success' => 1);
} else {
$this->appendUploadErrorMessage(_t('_sys_uploader_err_msg', isset($_FILES['qqfile']['name']) ? $_FILES['qqfile']['name'] : bx_get('qqfile'), $oStorage->getErrorString()));
$aResponse = array('error' => $this->getUploadErrorMessages());
}
echo htmlspecialchars(json_encode($aResponse), ENT_NOQUOTES);
}
示例9: delete
protected function delete($iId)
{
$aLevel = array();
$iLevel = $this->oDb->getLevels(array('type' => 'by_id', 'value' => (int) $iId), $aLevel);
if ($iLevel != 1 || empty($aLevel)) {
return false;
}
if ($aLevel['removable'] != 'yes' || $this->oDb->isLevelUsed($aLevel['id'])) {
return false;
}
if (is_numeric($aLevel['icon'])) {
if (!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int) $aLevel['icon'], 0)) {
return false;
}
}
$oLanguage = BxDolStudioLanguagesUtils::getInstance();
$oLanguage->deleteLanguageString($aLevel['name']);
$oLanguage->deleteLanguageString($aLevel['description']);
return $this->oDb->deleteLevel(array('type' => 'by_id', 'value' => $aLevel['id']));
}
示例10: delete
function delete($iContentId, $aContentInfo = array())
{
$CNF =& $this->_oModule->_oConfig->CNF;
// delete associated files
if (!empty($CNF['OBJECT_STORAGE'])) {
bx_import('BxDolStorage');
$oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
if ($oStorage) {
$oStorage->queueFilesForDeletionFromGhosts($aContentInfo[$CNF['FIELD_AUTHOR']], $iContentId);
}
}
// delete associated objects data
if (!empty($CNF['OBJECT_VIEWS'])) {
bx_import('BxDolView');
$o = BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId);
if ($o) {
$o->onObjectDelete();
}
}
if (!empty($CNF['OBJECT_VOTES'])) {
bx_import('BxDolVote');
$o = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContentId);
if ($o) {
$o->onObjectDelete();
}
}
if (!empty($CNF['OBJECT_COMMENTS'])) {
bx_import('BxDolCmts');
$o = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId);
if ($o) {
$o->onObjectDelete();
}
}
if (!empty($CNF['OBJECT_METATAGS'])) {
bx_import('BxDolMetatags');
$oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
$oMetatags->onDeleteContent($iContentId);
}
// delete db record
return parent::delete($iContentId);
}
示例11: processImageUploaderSave
function processImageUploaderSave($sName, $iId = 0)
{
if ($this->aInputs[$sName]['type'] != 'image_uploader') {
return $iId;
}
$aInput = $this->aInputs[$sName];
if (!empty($_FILES[$sName]['tmp_name'])) {
$iProfileId = getLoggedId();
$sStorage = isset($aInput['storage_object']) && $aInput['storage_object'] != '' ? $aInput['storage_object'] : BX_DOL_STORAGE_OBJ_IMAGES;
$oStorage = BxDolStorage::getObjectInstance($sStorage);
if ((int) $iId != 0 && !$oStorage->deleteFile($iId)) {
return _t('_adm_err_form_view_iu_delete');
}
$iId = $oStorage->storeFileFromForm($_FILES[$aInput['name']], false, $iProfileId);
if ($iId === false) {
return _t('_adm_err_form_view_iu_save') . $oStorage->getErrorString();
}
$oStorage->afterUploadCleanup($iId, $iProfileId);
}
return (int) $iId;
}
示例12: actionProcessStorages
/**
*
* Storage objects to automatically delete files from upon module uninstallation.
* Note. Don't add storage objects used in transcoder objects.
* @param string $sOperation - operation type.
*/
protected function actionProcessStorages($sOperation)
{
if (empty($this->_aConfig['storages'])) {
return BX_DOL_STUDIO_INSTALLER_FAILED;
}
// check if module is already waiting while files are deleting
if (self::isModulePendingUninstall($this->_aConfig['home_uri'])) {
return array('code' => BX_DOL_STUDIO_INSTALLER_FAILED, 'content' => _t('_adm_err_modules_pending_uninstall_already'));
}
$bSetModulePendingUninstall = false;
// queue for deletion storage files
foreach ($this->_aConfig['storages'] as $s) {
if (($o = BxDolStorage::getObjectInstance($s)) && $o->queueFilesForDeletionFromObject()) {
$bSetModulePendingUninstall = true;
}
}
// delete comments and queue for deletion comments attachments
$iFiles = 0;
BxDolCmts::onModuleUninstall($this->_aConfig['name'], $iFiles);
if ($iFiles) {
$bSetModulePendingUninstall = true;
}
// if some files were added to the queue, set module as pending uninstall
if ($bSetModulePendingUninstall) {
self::setModulePendingUninstall($this->_aConfig['home_uri']);
return array('code' => BX_DOL_STUDIO_INSTALLER_FAILED, 'content' => _t('_adm_err_modules_pending_uninstall'));
}
return BX_DOL_STUDIO_INSTALLER_SUCCESS;
}
示例13: entryAttachments
function entryAttachments($aData)
{
$oModule = BxDolModule::getInstance($this->MODULE);
$CNF =& $oModule->_oConfig->CNF;
bx_import('BxTemplFunctions');
bx_import('BxDolStorage');
bx_import('BxDolTranscoderImage');
$oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
$oTranscoder = BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
$aTranscodersVideo = false;
if ($CNF['OBJECT_VIDEOS_TRANSCODERS']) {
$aTranscodersVideo = array('poster' => BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['poster']), 'mp4' => BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['mp4']), 'webm' => BxDolTranscoderImage::getObjectInstance($CNF['OBJECT_VIDEOS_TRANSCODERS']['webm']));
}
$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, transcoder object for preview must be defined
$isVideo = $aTranscodersVideo && 0 == strncmp('video/', $a['mime_type'], 6);
// preview for videos, transcoder object for video 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->getFileUrl($a['id']), 'popup' => BxTemplFunctions::getInstance()->transBox($sImgPopupId, '<img src="' . $sUrlOriginal . '" />', true, true)));
// videos are displayed inline
$aGhostFiles[$k]['bx_if:video'] = array('condition' => $isVideo, 'content' => array('video' => $aTranscodersVideo ? BxTemplFunctions::getInstance()->videoPlayer($aTranscodersVideo['poster']->getFileUrl($a['id']), $aTranscodersVideo['mp4']->getFileUrl($a['id']), $aTranscodersVideo['webm']->getFileUrl($a['id']), false, '') : ''));
// non-images are displayed as text links to original file
$aGhostFiles[$k]['bx_if:not_image'] = array('condition' => !$isImage && !$isVideo, '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);
}
示例14: getOrigFileUrl_Storage
protected function getOrigFileUrl_Storage($mixedHandler)
{
$oStorageOriginal = BxDolStorage::getObjectInstance($this->_aObject['source_params']['object']);
if (!$oStorageOriginal) {
return false;
}
return $oStorageOriginal->getFileUrlById($mixedHandler);
}
示例15: _getImage
protected function _getImage($sType, $mixedId, $aParams = array())
{
$sUrl = "";
$aType2Method = array('image' => 'getImageUrl', 'icon' => 'getIconUrl');
//--- Check in System Storage.
if (is_numeric($mixedId) && (int) $mixedId > 0) {
if (($sResult = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->getFileUrlById((int) $mixedId)) !== false) {
$sUrl = $sResult;
}
}
//--- Check in template folders.
if ($sUrl == "" && is_string($mixedId) && strpos($mixedId, '.') !== false) {
$sUrl = $this->{$aType2Method}[$sType]($mixedId);
}
if ($sUrl != "") {
$bClass = isset($aParams['class']) && !empty($aParams['class']);
return $this->parseHtmlByName('bx_img.html', array('bx_if:class' => array('condition' => $bClass, 'content' => array('content' => $bClass ? $aParams['class'] : '')), 'src' => $sUrl, 'alt' => isset($aParams['alt']) ? $aParams['alt'] : ''));
}
//--- Use iconic font.
return $this->parseHtmlByName('bx_icon.html', array('name' => $mixedId));
}