Ejemplo n.º 1
0
 /**
  * Assign a new position to an existing record
  * @param boolean
  */
 public function cut($blnDoNotRedirect = false)
 {
     if ($this->intId > 0) {
         $time = time();
         // Empty clipboard
         $arrClipboard = $this->Session->get('CLIPBOARD');
         $arrClipboard[$this->strTable] = array();
         $this->Session->set('CLIPBOARD', $arrClipboard);
         $objRecord = $this->Database->prepare("SELECT pid FROM {$this->strTable} WHERE id=?")->limit(1)->execute($this->intId);
         // Update only the variant
         if ($objRecord->pid > 0) {
             $this->Database->prepare("UPDATE {$this->strTable} SET tstamp=?, gid=?, pid=? WHERE id=?")->execute($time, $this->intGroupId, \Input::get('pid'), $this->intId);
         } else {
             $this->Database->prepare("UPDATE {$this->strTable} SET tstamp=?, gid=? WHERE id=? OR pid=?")->execute($time, $this->intGroupId, $this->intId, $this->intId);
         }
         // Call the oncut_callback
         if (is_array($GLOBALS['TL_DCA'][$this->strTable]['config']['oncut_callback'])) {
             foreach ($GLOBALS['TL_DCA'][$this->strTable]['config']['oncut_callback'] as $callback) {
                 if (is_array($callback)) {
                     $this->import($callback[0]);
                     $this->{$callback}[0]->{$callback}[1]($this);
                 } elseif (is_callable($callback)) {
                     call_user_func($callback, $this);
                 }
             }
         }
         if (!$blnDoNotRedirect) {
             \Controller::redirect(\System::getReferer());
         }
         return;
     }
     parent::cut($blnDoNotRedirect);
 }
Ejemplo n.º 2
0
 /**
  * Delete child-records from tl_content
  *
  * @param DataContainer $dc
  * @throws Exception
  * @return void
  */
 public function deleteChildRecords(DataContainer $dc)
 {
     // only valid if tl_content is a ctable for $dc->table (the table which ondelete_callback executs this function)
     if ($dc->table == 'tl_content' || !in_array('tl_content', $GLOBALS['TL_DCA'][$dc->table]['config']['ctable'])) {
         throw new Exception("{$dc->table} has not tl_content as ctable!");
     }
     $objChilds = $this->Database->prepare('SELECT id FROM tl_content WHERE pid=? AND do=?')->execute($dc->id, $this->Input->get('do'));
     while ($objChilds->next()) {
         $this->Input->setGet('id', $objChilds->id);
         $dc = new DC_Table('tl_content');
         $dc->delete(true);
     }
     $this->Input->setGet('id', $dc->id);
 }
Ejemplo n.º 3
0
 /**
  * Move all selected records
  */
 public function copyAll()
 {
     // GID tells about paste into a group
     if ($this->Input->get('gid') != '') {
         $arrClipboard = $this->Session->get('CLIPBOARD');
         if (isset($arrClipboard[$this->strTable]) && is_array($arrClipboard[$this->strTable]['id'])) {
             $arrIds = array();
             foreach ($arrClipboard[$this->strTable]['id'] as $id) {
                 $this->intId = $id;
                 $arrIds[] = $this->copy(true);
             }
             $this->Database->query("UPDATE {$this->strTable} SET gid=" . (int) $this->Input->get('gid') . " WHERE id IN (" . implode(',', $arrIds) . ")");
         }
         $this->redirect($this->getReferer());
     }
     return parent::copyAll();
 }
Ejemplo n.º 4
0
 /**
  * Show header of the parent table and list all records of the current table
  * @return string
  */
 protected function parentView()
 {
     $strParentView = parent::parentView();
     $arrButtons = array();
     // Added by Patrick Kahl
     // HOOK: call the hooks for clipboardActSelectButtons
     if (isset($GLOBALS['TL_HOOKS']['clipboardActSelectButtonsParentView']) && is_array($GLOBALS['TL_HOOKS']['clipboardActSelectButtonsParentView'])) {
         foreach ($GLOBALS['TL_HOOKS']['clipboardActSelectButtonsParentView'] as $callback) {
             $this->import($callback[0]);
             $arrButtons[] = $this->{$callback}[0]->{$callback}[1]($this);
         }
     }
     return preg_replace('/<div.*class="tl_submit_container".*>/', "\$0" . implode('', $arrButtons), $strParentView, 1);
 }