Ejemplo n.º 1
0
$oTA = new WYTextArea('TEXT', $bNewImage ? '' : $oElement->sTextForID($iImageID));
$oTA->setWidth(30);
$oTA->setHeight(7);
$oFU = new WYFileUpload('IMAGE_FILE', $bNewImage);
$oFP = od_nil;
$sResponse = '';
$iNrOfErrors = 0;
if ($oEditor->bSave) {
    // if about to save, ...
    if ($bNewImage) {
        // ...and there is at least one new image, ...
        for ($j = 0; $j < $oFU->iNrOfFiles; $j++) {
            // ...save ALL files, ...
            $bHasError = false;
            $iImageID++;
            if ($oFU->bFileUploaded($j) && !$oFU->bUploadOK($j)) {
                $sResponse .= $oFU->sErrorMessage(true, $j);
                $iNrOfErrors++;
                $iImageID--;
                $bHasError = true;
            } else {
                // ...which DONT have errors
                if ($oFU->bFileUploaded($j)) {
                    $oFP =& $oFU->oFilePath($j);
                    $oOFP =& $oFU->oOriginalFilename($j);
                    if ($oOFP->bCheck(WYPATH_CHECK_JUSTIMAGE | WYPATH_CHECK_NOPATH)) {
                        $oElement->newImageAfter($iImageID - 1);
                        // insert new slot, only if upload happened AND is ok
                        $oElement->useUploadedImageFileForID($oFP, $oOFP, $iImageID);
                    } else {
                        $goApp->log('Illegal file/type on image upload: ' . $oOFP->sPath);
Ejemplo n.º 2
0
$oTFURL = new WYTextField("LINK_URL");
$oTFURL->setWidth(40);
$oTFAltText = new WYTextField("ALT_TEXT");
$oTFAltText->setWidth(40);
$oElement = new WYImageElement($oEditor->sFieldName, $oEditor->bGlobal, "", "", "", (int) $oHFImageWidth->sValue(), (int) $oHFImageHeight->sValue(), (int) $oHFIsThumb->sValue() == 1 ? true : false, (int) $oHFThumbWidth->sValue(), (int) $oHFThumbHeight->sValue());
$oFP = od_nil;
$sMaxUpload = $goApp->sFormattedByteSizeString($goApp->iMaxUploadBytes());
if ((int) $oHFDelete->sValue() == 1) {
    $oElement->deleteThumbnail();
    $oElement->deleteImage();
    // implicit save
    $sResponse = WYTS("ImageDeleted");
    $bOK = true;
} else {
    if ($oEditor->bSave) {
        if ($oFU->bFileUploaded()) {
            if ($oFU->bUploadOK()) {
                $oFP =& $oFU->oFilePath();
                $oOFP =& $oFU->oOriginalFilename();
                if ($oOFP->bCheck(WYPATH_CHECK_JUSTIMAGE | WYPATH_CHECK_NOPATH)) {
                    if ($oElement->bUseUploadedImageFile($oFP, $oOFP)) {
                        $oElement->setLinkURL($oTFURL->sValue());
                        $oElement->setAltText($oTFAltText->sValue());
                        $oElement->save();
                        $sResponse = WYTS("ImageSaved");
                        $bOK = true;
                    } else {
                        $sResponse = WYTS("ImageStoreFailed");
                        $bOK = false;
                    }
                } else {