BxDolImageResize::instance PHP Method

instance() public static method

Get singleton instance of the class
public static instance ( )
    public static function instance()
    {
        if (!isset($GLOBALS['bxDolClasses'][__CLASS__])) {
            $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolImageResize();
        }
        return $GLOBALS['bxDolClasses'][__CLASS__];
    }

Usage Example

Ejemplo n.º 1
0
 function actionCropPerform($iPhotoID)
 {
     header('Content-Type:text/html; charset=utf-8');
     $aInfo = $this->_oDb->getFileInfo(array('fileId' => $iPhotoID));
     if (empty($aInfo)) {
         die(json_encode(array('status' => 'error', 'message' => _t('_sys_media_not_found'))));
     }
     if (!$this->isAllowedEdit($aInfo)) {
         die(json_encode(array('status' => 'error', 'message' => _t('_Access denied'))));
     }
     $o = BxDolImageResize::instance();
     $sSrcFileName = $this->_oConfig->getFilesPath() . $aInfo['medID'] . str_replace('{ext}', $aInfo['medExt'], $this->_oConfig->aFilesConfig['original']['postfix']);
     $sTmpFileName = tempnam(BX_DIRECTORY_PATH_TMP, $this->_oConfig->getMainPrefix());
     $bCropResult = $o->crop((double) $_POST['imgW'], (double) $_POST['imgH'], (double) $_POST['imgX1'], (double) $_POST['imgY1'], (double) $_POST['cropW'], (double) $_POST['cropH'], -(double) $_POST['rotation'], $sSrcFileName, $sTmpFileName);
     if (IMAGE_ERROR_SUCCESS !== $bCropResult) {
         die(json_encode(array('status' => 'error', 'message' => $o->getError())));
     }
     $_POST['extra_param_album'] = $aInfo['albumUri'];
     $aInfo['Categories'] = preg_split('/[' . CATEGORIES_DIVIDER . ']/', $aInfo['Categories'], 0, PREG_SPLIT_NO_EMPTY);
     bx_import('Uploader', $this->_aModule);
     $sClassName = $this->_oConfig->getClassPrefix() . 'Uploader';
     $oUploader = new $sClassName();
     $a = $oUploader->performUpload($sTmpFileName, pathinfo($sSrcFileName, PATHINFO_BASENAME), $aInfo, false);
     @unlink($sTmpFileName);
     if (!empty($a['error'])) {
         die(json_encode(array('status' => 'error', 'message' => $a['error'])));
     }
     $aInfoNew = $this->_oDb->getFileInfo(array('fileId' => $a['id']));
     bx_import('Search', $this->_aModule);
     $oSearch = new BxPhotosSearch();
     $sImgUrl = $oSearch->getImgUrl($aInfoNew['Hash'], 'file');
     echo json_encode(array('status' => 'success', 'url' => $sImgUrl, 'redirect_url' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aInfoNew['medUri']));
 }
All Usage Examples Of BxDolImageResize::instance