Example #1
0
 function dispatchEditAction()
 {
     global $goApp;
     $sAction = $goApp->sCurrentAction();
     $sFieldName = $goApp->sFormFieldValue(WY_QK_EDITOR_FIELDNAME, "");
     $iLoopID = (int) $goApp->sFormFieldValue(WY_QK_LOOP_ID, 0);
     $aLoopIDs = $this->_aLoopIDs();
     $iCount = count($aLoopIDs);
     $iNewID = 0;
     $iPos = 0;
     $bChanged = false;
     if ($sFieldName != $this->sName) {
         return;
     }
     if ($sAction == WY_QV_LOOP_ADD) {
         if ($iCount) {
             $iNewID = max($aLoopIDs) + 1;
             $this->iEditedID = $iNewID;
             $iPos = array_search($iLoopID, $aLoopIDs);
             if ($iPos !== false) {
                 // should be in there, but who knows...
                 $iOffset = $goApp->sFormFieldValue(WY_QK_LOOP_ADD_ABOVE) ? 0 : 1;
                 $iPos += $iOffset;
                 if ($iPos < 0) {
                     $iPos = 0;
                 }
                 if ($iPos >= $iCount) {
                     $aLoopIDs[] = $iNewID;
                 } else {
                     webyep_array_insert($aLoopIDs, $iPos, $iNewID);
                 }
             } else {
                 $aLoopIDs[] = $iNewID;
             }
         } else {
             $aLoopIDs = array(1);
         }
         $this->enableLoopID($iNewID);
         $bChanged = true;
     } else {
         if ($sAction == WY_QV_LOOP_REMOVE) {
             if ($iCount > 1) {
                 $iPos = array_search($iLoopID, $aLoopIDs);
                 if ($iPos !== false) {
                     array_splice($aLoopIDs, $iPos, 1);
                     $this->enableLoopID($iLoopID);
                 }
                 if (isset($aLoopIDs[$iPos])) {
                     $this->iEditedID = $aLoopIDs[$iPos];
                 } else {
                     if (isset($aLoopIDs[$iPos - 1])) {
                         $this->iEditedID = $aLoopIDs[$iPos - 1];
                     }
                 }
                 $bChanged = true;
             }
             $this->iLoopIDJustDeleted = $iLoopID;
         } else {
             if ($sAction == WY_QV_LOOP_UP) {
                 $this->iEditedID = $iLoopID;
                 $iPos = array_search($iLoopID, $aLoopIDs);
                 if ($iCount > 1 && $iPos !== false && $iPos > 0) {
                     array_splice($aLoopIDs, $iPos, 1);
                     webyep_array_insert($aLoopIDs, $iPos - 1, $iLoopID);
                     $bChanged = true;
                 }
             } else {
                 if ($sAction == WY_QV_LOOP_DOWN) {
                     $this->iEditedID = $iLoopID;
                     $iPos = array_search($iLoopID, $aLoopIDs);
                     if ($iCount > 1 && $iPos !== false && $iPos < $iCount - 1) {
                         array_splice($aLoopIDs, $iPos, 1);
                         webyep_array_insert($aLoopIDs, $iPos + 1, $iLoopID);
                         $bChanged = true;
                     }
                 } else {
                     if ($sAction == WY_QV_LOOP_DISABLE) {
                         $this->iEditedID = $iLoopID;
                         $this->disableLoopID($iLoopID);
                         $bChanged = true;
                     } else {
                         if ($sAction == WY_QV_LOOP_ENABLE) {
                             $this->iEditedID = $iLoopID;
                             $this->enableLoopID($iLoopID);
                             $bChanged = true;
                         }
                     }
                 }
             }
         }
     }
     if ($bChanged) {
         $this->_setLoopIDs($aLoopIDs);
         $this->save();
     }
 }
Example #2
0
 /**
  * Führt eine angeforderte Editieraktion durch.
  * 
  *	Mögliche Aktionen sind:
  *	- Bild löschen
  *	- Bild nach oben verschieben
  *	- Bild nach unten verschieben
  */
 function dispatchEditAction()
 {
     global $goApp;
     $sAction = $goApp->sCurrentAction();
     $sFieldName = $goApp->sFormFieldValue(WY_QK_EDITOR_FIELDNAME, "");
     $iImageID = (int) $goApp->sFormFieldValue(WY_QK_GALLERY_IMAGE_ID, 0);
     $iLoopID = (int) $goApp->sFormFieldValue(WY_QK_LOOP_ID, 0);
     $aItems =& $this->_aItems();
     $aTempItems = array();
     $dItem = array();
     $iCount = count($aItems);
     $iNewIndex = 0;
     $bChanged = false;
     if ($sFieldName != $this->sName) {
         return;
     }
     if ($iLoopID != $goApp->oDocument->iLoopID()) {
         return;
     }
     if ($sAction == WY_QV_GALLERY_REMOVE) {
         if ($iCount > 0) {
             $this->_deleteImageFilesForID($iImageID);
             array_splice($aItems, $iImageID, 1);
             if (isset($aItems[$iImageID])) {
                 $this->iEditedID = $iImageID;
             } else {
                 if (isset($aItems[$iImageID - 1])) {
                     $this->iEditedID = $iImageID - 1;
                 }
             }
             $bChanged = true;
         }
     } else {
         if ($sAction == WY_QV_GALLERY_UP) {
             if ($iCount > 1 && $iImageID > 0) {
                 $aTempItems = array_splice($aItems, $iImageID, 1);
                 webyep_array_insert($aItems, $iImageID - 1, $aTempItems[0]);
                 $this->iEditedID = $iImageID - 1;
                 $bChanged = true;
             }
         } else {
             if ($sAction == WY_QV_GALLERY_DOWN) {
                 if ($iCount > 1 && $iImageID < $iCount - 1) {
                     $aTempItems = array_splice($aItems, $iImageID, 1);
                     webyep_array_insert($aItems, $iImageID + 1, $aTempItems[0]);
                     $this->iEditedID = $iImageID + 1;
                     $bChanged = true;
                 }
             }
         }
     }
     if ($bChanged) {
         $this->save();
     }
 }