本文整理汇总了PHP中BxDolStorage类的典型用法代码示例。如果您正苦于以下问题:PHP BxDolStorage类的具体用法?PHP BxDolStorage怎么用?PHP BxDolStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BxDolStorage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanDatabase
/**
* Clean database by deleting some expired data
*/
protected function cleanDatabase()
{
// clean expired membership levels
bx_import('BxDolAcl');
$oAcl = BxDolAcl::getInstance();
$iDeleteMemLevels = $oAcl ? $oAcl->maintenance() : 0;
//--- Clean sessions ---//
bx_import('BxDolSession');
$oSession = BxDolSession::getInstance();
$iSessions = $oSession ? $oSession->maintenance() : 0;
// clean old views
bx_import('BxDolView');
$iDeletedViews = BxDolView::maintenance();
// clean storage engine expired private file tokens
bx_import('BxDolStorage');
$iDeletedExpiredTokens = BxDolStorage::pruning();
// clean outdated transcoded images
bx_import('BxDolImageTranscoder');
$iDeletedTranscodedImages = BxDolImageTranscoder::pruning();
// clean expired keys
bx_import('BxDolKey');
$oKey = BxDolKey::getInstance();
$iDeletedKeys = $oKey ? $oKey->prune() : 0;
// clean old votes
bx_import('BxDolVote');
$iDeletedVotes = BxDolVote::maintenance();
echo _t('_sys_pruning_db', $iDeleteMemLevels, $iSessions, $iDeletedViews, $iDeletedVotes, $iDeletedKeys, $iDeletedExpiredTokens, $iDeletedTranscodedImages);
}
示例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: checkModulesPendingUninstall
/**
* Check all pending for uninstallation modules and uninstall them if no pending for deletion files are found
*/
public static function checkModulesPendingUninstall()
{
bx_import('BxDolModuleQuery');
$a = BxDolModuleQuery::getInstance()->getModules();
foreach ($a as $aModule) {
// after we make sure that all pending for deletion files are deleted
if (!$aModule['pending_uninstall'] || BxDolStorage::isQueuedFilesForDeletion($aModule['name'])) {
continue;
}
// remove pending uninstall flag
self::setModulePendingUninstall($aModule['uri'], false);
// perform uninstallation
bx_import('BxDolStudioInstallerUtils');
$aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
// send email nofitication
$aTemplateKeys = array('Module' => $aModule['title'], 'Result' => _t('_Success'), 'Message' => '');
if ($aResult['code'] > 0) {
$aTemplateKeys['Result'] = _t('_Failed');
$aTemplateKeys['Message'] = $aResult['message'];
}
bx_import('BxDolEmailTemplates');
$aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('t_DelayedModuleUninstall', $aTemplateKeys);
sendMail(getParam('site_email'), $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM);
}
}
示例4: 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;
}
示例5: processing
public function processing()
{
set_time_limit(36000);
ignore_user_abort();
if (BxDolStorage::pruneDeletions()) {
// if any files were deleted
BxDolInstallerUtils::checkModulesPendingUninstall();
}
// try to uninstall modules pending for uninstall
}
示例6: 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);
}
示例7: 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);
}
示例8: 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;
}
示例9: 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;
}
示例10: 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']));
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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;
}
示例15: BxDolStorageHelperStorage
function BxDolStorageHelperStorage($aParams)
{
$this->iFileId = $aParams['id'];
$this->oStorage = BxDolStorage::getObjectInstance($aParams['storage']);
$this->aFile = false;
if ($this->oStorage) {
$this->aFile = $this->oStorage->getFile($this->iFileId);
}
}