Beispiel #1
0
   /**
    * Generate the widget and return it as string
    *
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'drag', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           $this->import('Database');
           switch (\Input::get($strCommand)) {
               case 'copy':
                   $this->varValue = array_duplicate($this->varValue, \Input::get('cid'));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || empty($this->varValue)) {
           $this->varValue = array('');
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       $return = '<ul id="ctrl_' . $this->strId . '" class="tl_listwizard" data-tabindex="' . $tabindex . '">';
       // Add input fields
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $return .= '
   <li><input type="text" name="' . $this->strId . '[]" class="tl_text" tabindex="' . $tabindex++ . '" value="' . specialchars($this->varValue[$i]) . '"' . $this->getAttributes() . '> ';
           // Add buttons
           foreach ($arrButtons as $button) {
               $class = $button == 'up' || $button == 'down' ? ' class="button-move"' : '';
               if ($button == 'drag') {
                   $return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } else {
                   $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['lw_' . $button]) . '" onclick="Backend.listWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['lw_' . $button], 'class="tl_listwizard_img"') . '</a> ';
               }
           }
           $return .= '</li>';
       }
       // Store the tab index
       \Cache::set('tabindex', $tabindex);
       return $return . '
 </ul>';
   }
 /**
  * Generate the widget and return it as string
  *
  * @return string
  */
 public function generate()
 {
     $arrButtons = array('up', 'down');
     $strCommand = 'cmd_' . $this->strField;
     if (!is_array($this->varValue)) {
         $this->varValue = array($this->varValue);
     }
     // Change the order
     if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
         $this->import('Database');
         switch (\Input::get($strCommand)) {
             case 'up':
                 $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                 break;
             case 'down':
                 $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                 break;
         }
         $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
         $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
     }
     // Sort options
     if ($this->varValue) {
         $arrOptions = array();
         $arrTemp = $this->arrOptions;
         // Move selected and sorted options to the top
         foreach ($this->arrOptions as $i => $arrOption) {
             if (($intPos = array_search($arrOption['value'], $this->varValue)) !== false) {
                 $arrOptions[$intPos] = $arrOption;
                 unset($arrTemp[$i]);
             }
         }
         ksort($arrOptions);
         $this->arrOptions = array_merge($arrOptions, $arrTemp);
     }
     $blnCheckAll = true;
     $arrOptions = array();
     // Generate options and add buttons
     foreach ($this->arrOptions as $i => $arrOption) {
         $strButtons = \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
         foreach ($arrButtons as $strButton) {
             $strButtons .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $strButton . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" class="button-move" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['move_' . $strButton][1]) . '" onclick="Backend.checkboxWizard(this,\'' . $strButton . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($strButton . '.gif', $GLOBALS['TL_LANG']['MSC']['move_' . $strButton][0], 'class="tl_checkbox_wizard_img"') . '</a> ';
         }
         $arrOptions[] = $this->generateCheckbox($arrOption, $i, $strButtons);
     }
     // Add a "no entries found" message if there are no options
     if (empty($arrOptions)) {
         $arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
         $blnCheckAll = false;
     }
     return sprintf('<fieldset id="ctrl_%s" class="tl_checkbox_container tl_checkbox_wizard%s"><legend>%s%s%s%s</legend><input type="hidden" name="%s" value="">%s<div class="sortable">%s</div></fieldset>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->xlabel, $this->strName, $blnCheckAll ? '<span class="fixed"><input type="checkbox" id="check_all_' . $this->strId . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this,\'ctrl_' . $this->strId . '\')"> <label for="check_all_' . $this->strId . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label></span>' : '', implode('', $arrOptions), $this->wizard);
 }
Beispiel #3
0
   /**
    * Generate the widget and return it as string
    *
    * @return string
    */
   public function generate()
   {
       $this->import('Database');
       $arrButtons = array('edit', 'copy', 'delete', 'enable', 'drag', 'up', 'down');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           switch (\Input::get($strCommand)) {
               case 'copy':
                   $this->varValue = array_duplicate($this->varValue, \Input::get('cid'));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
       }
       // Get all modules of the current theme
       $objModules = $this->Database->prepare("SELECT id, name, type FROM tl_module WHERE pid=(SELECT pid FROM " . $this->strTable . " WHERE id=?) ORDER BY name")->execute($this->currentRecord);
       // Add the articles module
       $modules[] = array('id' => 0, 'name' => $GLOBALS['TL_LANG']['MOD']['article'][0], 'type' => 'article');
       if ($objModules->numRows) {
           $modules = array_merge($modules, $objModules->fetchAllAssoc());
       }
       $GLOBALS['TL_LANG']['FMD']['article'] = $GLOBALS['TL_LANG']['MOD']['article'];
       // Add the module type (see #3835)
       foreach ($modules as $k => $v) {
           $v['type'] = $GLOBALS['TL_LANG']['FMD'][$v['type']][0];
           $modules[$k] = $v;
       }
       $objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->currentRecord);
       // Show all columns and filter in PageRegular (see #3273)
       $cols = array('header', 'left', 'right', 'main', 'footer');
       $arrSections = trimsplit(',', $objRow->sections);
       // Add custom page sections
       if (!empty($arrSections) && is_array($arrSections)) {
           $cols = array_merge($cols, $arrSections);
       }
       // Get the new value
       if (\Input::post('FORM_SUBMIT') == $this->strTable) {
           $this->varValue = \Input::post($this->strId);
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array('');
       } else {
           $arrCols = array();
           // Initialize the sorting order
           foreach ($cols as $col) {
               $arrCols[$col] = array();
           }
           foreach ($this->varValue as $v) {
               $arrCols[$v['col']][] = $v;
           }
           $this->varValue = array();
           foreach ($arrCols as $arrCol) {
               $this->varValue = array_merge($this->varValue, $arrCol);
           }
       }
       // Save the value
       if (\Input::get($strCommand) || \Input::post('FORM_SUBMIT') == $this->strTable) {
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           // Reload the page
           if (is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
               $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
           }
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       // Add the label and the return wizard
       $return = '<table id="ctrl_' . $this->strId . '" class="tl_modulewizard">
 <thead>
 <tr>
   <th>' . $GLOBALS['TL_LANG']['MSC']['mw_module'] . '</th>
   <th>' . $GLOBALS['TL_LANG']['MSC']['mw_column'] . '</th>
   <th>&nbsp;</th>
 </tr>
 </thead>
 <tbody class="sortable" data-tabindex="' . $tabindex . '">';
       // Add the input fields
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $options = '';
           // Add modules
           foreach ($modules as $v) {
               $options .= '<option value="' . specialchars($v['id']) . '"' . static::optionSelected($v['id'], $this->varValue[$i]['mod']) . '>' . $v['name'] . ' [' . $v['type'] . ']</option>';
           }
           $return .= '
 <tr>
   <td><select name="' . $this->strId . '[' . $i . '][mod]" class="tl_select tl_chosen" tabindex="' . $tabindex++ . '" onfocus="Backend.getScrollOffset()" onchange="Backend.updateModuleLink(this)">' . $options . '</select></td>';
           $options = '';
           // Add columns
           foreach ($cols as $v) {
               $options .= '<option value="' . specialchars($v) . '"' . static::optionSelected($v, $this->varValue[$i]['col']) . '>' . (isset($GLOBALS['TL_LANG']['COLS'][$v]) && !is_array($GLOBALS['TL_LANG']['COLS'][$v]) ? $GLOBALS['TL_LANG']['COLS'][$v] : $v) . '</option>';
           }
           $return .= '
   <td><select name="' . $this->strId . '[' . $i . '][col]" class="tl_select_column" tabindex="' . $tabindex++ . '" onfocus="Backend.getScrollOffset()">' . $options . '</select></td>
   <td>';
           // Add buttons
           foreach ($arrButtons as $button) {
               $class = $button == 'up' || $button == 'down' ? ' class="button-move"' : '';
               if ($button == 'edit') {
                   $return .= ' <a href="contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->varValue[$i]['mod'] . '&amp;popup=1&amp;rt=' . REQUEST_TOKEN . '&amp;nb=1" title="' . specialchars($GLOBALS['TL_LANG']['tl_layout']['edit_module']) . '" class="module_link" ' . ($this->varValue[$i]['mod'] > 0 ? '' : ' style="display:none"') . ' onclick="Backend.openModalIframe({\'width\':768,\'title\':\'' . specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['tl_layout']['edit_module'])) . '\',\'url\':this.href});return false">' . \Image::getHtml('edit.gif') . '</a>' . \Image::getHtml('edit_.gif', '', 'class="module_image"' . ($this->varValue[$i]['mod'] > 0 ? ' style="display:none"' : ''));
               } elseif ($button == 'drag') {
                   $return .= ' ' . \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } elseif ($button == 'enable') {
                   $return .= ' ' . \Image::getHtml($this->varValue[$i]['enable'] ? 'visible.gif' : 'invisible.gif', '', 'class="mw_enable" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['mw_enable']) . '"') . '<input name="' . $this->strId . '[' . $i . '][enable]" type="checkbox" class="tl_checkbox mw_enable" value="1" tabindex="' . $tabindex++ . '" onfocus="Backend.getScrollOffset()"' . ($this->varValue[$i]['enable'] ? ' checked' : '') . '>';
               } else {
                   $return .= ' <a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['mw_' . $button]) . '" onclick="Backend.moduleWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['mw_' . $button], 'class="tl_listwizard_img"') . '</a>';
               }
           }
           $return .= '</td>
 </tr>';
       }
       // Store the tab index
       \Cache::set('tabindex', $tabindex);
       return $return . '
 </tbody>
 </table>';
   }
    /**
     * Generate the widget and return it as string
     * @return string
     */
    public function generate()
    {
        // load the callback data if there's any (do not do this in __set() already because then we don't have access to currentRecord)
        if (is_array($this->arrCallback)) {
            $this->import($this->arrCallback[0]);
            $this->columnFields = $this->{$this->arrCallback[0]}->{$this->arrCallback[1]}($this);
        }
        // use BE script in FE for now
        $GLOBALS['TL_JAVASCRIPT']['mcw'] = $GLOBALS['TL_CONFIG']['debugMode'] ? 'system/modules/multicolumnwizard/html/js/multicolumnwizard_be_src.js' : 'system/modules/multicolumnwizard/html/js/multicolumnwizard_be.js';
        $GLOBALS['TL_CSS']['mcw'] = $GLOBALS['TL_CONFIG']['debugMode'] ? 'system/modules/multicolumnwizard/html/css/multicolumnwizard_src.css' : 'system/modules/multicolumnwizard/html/css/multicolumnwizard.css';
        $this->strCommand = 'cmd_' . $this->strField;
        // Change the order
        if ($this->Input->get($this->strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
            switch ($this->Input->get($this->strCommand)) {
                case 'copy':
                    $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                    break;
                case 'up':
                    $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                    break;
                case 'down':
                    $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                    break;
                case 'delete':
                    $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                    break;
            }
            // Save in File
            if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'File') {
                $this->Config->update(sprintf("\$GLOBALS['TL_CONFIG']['%s']", $this->strField), serialize($this->varValue));
                // Reload the page
                $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
            } else {
                if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'Table') {
                    if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'])) {
                        $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'];
                        // If less than 3.X, we must load the class by hand.
                        if (version_compare(VERSION, '3.0', '<')) {
                            require_once sprintf('%s/system/drivers/%s.php', TL_ROOT, $dataContainer);
                        }
                        $dc = new $dataContainer($this->strTable);
                        $dc->field = $objWidget->id;
                        $dc->inputName = $objWidget->id;
                        foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'] as $callback) {
                            $this->import($callback[0]);
                            $this->{$callback}[0]->{$callback}[1](serialize($this->varValue), $dc);
                        }
                    } else {
                        $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
                    }
                    // Reload the page
                    $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
                } else {
                    // What to do here?
                }
            }
        }
        $arrUnique = array();
        $arrDatepicker = array();
        $arrColorpicker = array();
        $arrTinyMCE = array();
        $arrHeaderItems = array();
        foreach ($this->columnFields as $strKey => $arrField) {
            // Store unique fields
            if ($arrField['eval']['unique']) {
                $arrUnique[] = $strKey;
            }
            // Store date picker fields
            if ($arrField['eval']['datepicker']) {
                $arrDatepicker[] = $strKey;
            }
            // Store color picker fields
            if ($arrField['eval']['colorpicker']) {
                $arrColorpicker[] = $strKey;
            }
            // Store tiny mce fields
            if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) {
                foreach ($this->varValue as $row => $value) {
                    $tinyId = 'ctrl_' . $this->strField . '_row' . $row . '_' . $strKey;
                    $GLOBALS['TL_RTE']['tinyMCE'][$tinyId] = array('id' => $tinyId, 'file' => 'tinyMCE', 'type' => null);
                }
                $arrTinyMCE[] = $strKey;
            }
            if ($arrField['inputType'] == 'hidden') {
                continue;
            }
        }
        $intNumberOfRows = max(count($this->varValue), 1);
        // always show the minimum number of rows if set
        if ($this->minCount && $intNumberOfRows < $this->minCount) {
            $intNumberOfRows = $this->minCount;
        }
        $arrItems = array();
        $arrHiddenHeader = array();
        // Add input fields
        for ($i = 0; $i < $intNumberOfRows; $i++) {
            $this->activeRow = $i;
            $strHidden = '';
            // Walk every column
            foreach ($this->columnFields as $strKey => $arrField) {
                $strWidget = '';
                $blnHiddenBody = false;
                if ($arrField['eval']['hideHead'] == true) {
                    $arrHiddenHeader[$strKey] = true;
                }
                // load row specific data (useful for example for default values in different rows)
                if (isset($this->arrRowSpecificData[$i][$strKey])) {
                    $arrField = array_merge($arrField, $this->arrRowSpecificData[$i][$strKey]);
                }
                $objWidget = $this->initializeWidget($arrField, $i, $strKey, $this->varValue[$i][$strKey]);
                // load errors if there are any
                if (!empty($this->arrWidgetErrors[$strKey][$i])) {
                    foreach ($this->arrWidgetErrors[$strKey][$i] as $strErrorMsg) {
                        $objWidget->addError($strErrorMsg);
                    }
                }
                if ($objWidget === null) {
                    continue;
                } elseif (is_string($objWidget)) {
                    $strWidget = $objWidget;
                } elseif ($arrField['inputType'] == 'hidden') {
                    $strHidden .= $objWidget->generate();
                    continue;
                } elseif ($arrField['eval']['hideBody'] == true || $arrField['eval']['hideHead'] == true) {
                    if ($arrField['eval']['hideBody'] == true) {
                        $blnHiddenBody = true;
                    }
                    $strWidget = $objWidget->parse();
                } else {
                    $datepicker = '';
                    $colorpicker = '';
                    $tinyMce = '';
                    // Datepicker
                    if ($arrField['eval']['datepicker']) {
                        $rgxp = $arrField['eval']['rgxp'];
                        $format = $GLOBALS['TL_CONFIG'][$rgxp . 'Format'];
                        switch ($rgxp) {
                            case 'datim':
                                $time = ",\n      timePicker:true";
                                break;
                            case 'time':
                                $time = ",\n      timePickerOnly:true";
                                break;
                            default:
                                $time = '';
                                break;
                        }
                        $datepicker = ' <img src="system/modules/multicolumnwizard/html/img/datepicker.gif" width="20" height="20" alt="" id="toggle_' . $objWidget->id . '" style="vertical-align:-6px;">
                          <script>
							  window.datepicker_' . $this->strName . '_' . $strKey . ' = new DatePicker(\'#ctrl_' . $objWidget->id . '\', {
							  allowEmpty:true,
							  toggleElements:\'#toggle_' . $objWidget->id . '\',
							  pickerClass:\'datepicker_dashboard\',
							  format:\'' . $format . '\',
							  inputOutputFormat:\'' . $format . '\',
							  positionOffset:{x:130,y:-185}' . $time . ',
							  startDay:' . $GLOBALS['TL_LANG']['MSC']['weekOffset'] . ',
							  days:[\'' . implode("','", $GLOBALS['TL_LANG']['DAYS']) . '\'],
							  dayShort:' . $GLOBALS['TL_LANG']['MSC']['dayShortLength'] . ',
							  months:[\'' . implode("','", $GLOBALS['TL_LANG']['MONTHS']) . '\'],
							  monthShort:' . $GLOBALS['TL_LANG']['MSC']['monthShortLength'] . '
                          });
                          </script>';
                        $datepicker = $this->getMcWDatePickerString($objWidget->id, $strKey, $rgxp);
                        /* $datepicker = '<script>
                           window.addEvent(\'domready\', function() {
                           ' . sprintf($this->getDatePickerString(), 'ctrl_' . $objWidget->strId) . '
                           });
                           </script>'; */
                    }
                    // Color picker
                    if ($arrField['eval']['colorpicker']) {
                        // Support single fields as well (see #5240)
                        //$strKey = $arrData['eval']['multiple'] ? $this->strField . '_0' : $this->strField;
                        $colorpicker = ' ' . \Image::getHtml('pickcolor.gif', $GLOBALS['TL_LANG']['MSC']['colorpicker'], 'style="vertical-align:top;cursor:pointer" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['colorpicker']) . '" id="moo_' . $objWidget->id . '"') . '
			  <script>
				window.addEvent("domready", function() {
				  new MooRainbow("moo_' . $objWidget->id . '", {
					id: "ctrl_' . $objWidget->id . '",
					startColor: ((cl = $("ctrl_' . $objWidget->id . '").value.hexToRgb(true)) ? cl : [255, 0, 0]),
					imgPath: "assets/mootools/colorpicker/' . $GLOBALS['TL_ASSETS']['COLORPICKER'] . '/images/",
					onComplete: function(color) {
					  $("ctrl_' . $objWidget->id . '").value = color.hex.replace("#", "");
					}
				  });
				});
			  </script>';
                    }
                    // Tiny MCE
                    if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) {
                        $tinyMce = $this->getMcWTinyMCEString($objWidget->id, $arrField);
                        $arrField['eval']['tl_class'] .= ' tinymce';
                    }
                    // Add custom wizard
                    if (is_array($arrField['wizard'])) {
                        $wizard = '';
                        $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'];
                        // If less than 3.X, we must load the class by hand.
                        if (version_compare(VERSION, '3.0', '<')) {
                            require_once sprintf('%s/system/drivers/%s.php', TL_ROOT, $dataContainer);
                        }
                        $dc = new $dataContainer($this->strTable);
                        $dc->field = $objWidget->id;
                        $dc->inputName = $objWidget->id;
                        $dc->value = $objWidget->value;
                        foreach ($arrField['wizard'] as $callback) {
                            $this->import($callback[0]);
                            $wizard .= $this->{$callback}[0]->{$callback}[1]($dc, $objWidget);
                        }
                        $objWidget->wizard = $wizard;
                    }
                    $strWidget = $objWidget->parse() . $datepicker . $colorpicker . $tinyMce;
                }
                // Build array of items
                if ($arrField['eval']['columnPos'] != '') {
                    $arrItems[$i][$objWidget->columnPos]['entry'] .= $strWidget;
                    $arrItems[$i][$objWidget->columnPos]['valign'] = $arrField['eval']['valign'];
                    $arrItems[$i][$objWidget->columnPos]['tl_class'] = $arrField['eval']['tl_class'];
                    $arrItems[$i][$objWidget->columnPos]['hide'] = $blnHiddenBody;
                } else {
                    $arrItems[$i][$strKey] = array('entry' => $strWidget, 'valign' => $arrField['eval']['valign'], 'tl_class' => $arrField['eval']['tl_class'], 'hide' => $blnHiddenBody);
                }
            }
        }
        $strOutput = '';
        if ($this->blnTableless) {
            $strOutput = $this->generateDiv($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader);
        } else {
            if ($this->columnTemplate != '') {
                $strOutput = $this->generateTemplateOutput($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader);
            } else {
                $strOutput = $this->generateTable($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader);
            }
        }
        return $strOutput;
    }
Beispiel #5
0
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
           $this->import('Database');
           switch ($this->Input->get($strCommand)) {
               case 'copy':
                   $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || count($this->varValue) < 1) {
           $this->varValue = array('');
       }
       $tabindex = 0;
       $return .= '<ul id="ctrl_' . $this->strId . '" class="tl_listwizard">';
       // Add input fields
       for ($i = 0; $i < count($this->varValue); $i++) {
           $return .= '
   <li><input type="text" name="' . $this->strId . '[]" class="tl_text" tabindex="' . ++$tabindex . '" value="' . specialchars($this->varValue[$i]) . '"' . $this->getAttributes() . '> ';
           // Add buttons
           foreach ($arrButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['lw_' . $button]) . '" onclick="Backend.listWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG']['MSC']['lw_' . $button], 'class="tl_listwizard_img"') . '</a> ';
           }
           $return .= '</li>';
       }
       return $return . '
 </ul>';
   }
Beispiel #6
0
 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     $this->import('Database');
     $this->objActiveRecord = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->execute($this->currentRecord);
     $this->arrDisabledFields = $GLOBALS['ISO_PRODUCT'][$this->objActiveRecord->class]['disabledFields'];
     $this->arrOptions = $this->getOptions();
     $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/isotope/html/backend.js';
     $arrButtons = array('up', 'down');
     $strCommand = 'cmd_' . $this->strField;
     // Change the order
     if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
         $this->import('Database');
         switch ($this->Input->get($strCommand)) {
             case 'up':
                 $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                 break;
             case 'down':
                 $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                 break;
         }
         $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
         $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
     }
     $state = $this->Session->get('checkbox_groups');
     // Toggle checkbox group
     if ($this->Input->get('cbc')) {
         $state[$this->Input->get('cbc')] = isset($state[$this->Input->get('cbc')]) && $state[$this->Input->get('cbc')] == 1 ? 0 : 1;
         $this->Session->set('checkbox_groups', $state);
         $this->redirect(preg_replace('/(&(amp;)?|\\?)cbc=[^& ]*/i', '', $this->Environment->request));
     }
     // Sort options
     if ($this->varValue) {
         $arrOptions = array();
         // Move selected and sorted options to the top
         foreach ($this->arrOptions as $i => $arrOptionGroup) {
             $arrOptions[$i] = array();
             $arrTemp = $this->arrOptions[$i];
             foreach ($arrOptionGroup as $k => $arrOption) {
                 if ($this->varValue[$arrOption['value']]['enabled']) {
                     $arrOptions[$i][$this->varValue[$arrOption['value']]['position']] = $arrOption;
                     unset($arrTemp[$k]);
                 }
             }
             ksort($arrOptions[$i]);
             $arrOptions[$i] = array_merge($arrOptions[$i], $arrTemp);
         }
         $this->arrOptions = $arrOptions;
     }
     $cid = 0;
     $blnFirst = true;
     $blnCheckAll = true;
     $arrOptions = array();
     foreach ($this->arrOptions as $i => $arrOptionGroup) {
         $id = 'cbc_' . $this->strId . '_' . standardize($i, true);
         $img = 'folPlus';
         $display = 'none';
         if (!isset($state[$id]) || !empty($state[$id])) {
             $img = 'folMinus';
             $display = 'block';
         }
         $arrOptions[] = '<div class="checkbox_toggler' . ($blnFirst ? '_first' : '') . '"><a href="' . $this->addToUrl('cbc=' . $id) . '" onclick="AjaxRequest.toggleCheckboxGroup(this, \'' . $id . '\'); Backend.getScrollOffset(); return false;"><img src="system/themes/' . $this->getTheme() . '/images/' . $img . '.gif" alt="toggle checkbox group"></a>' . $GLOBALS['TL_LANG']['tl_iso_products'][$i] . '</div><div id="' . $id . '" class="checkbox_options" style="display:' . $display . ';"><span class="fixed"><input type="checkbox" id="check_all_' . $id . '" class="tl_checkbox" onclick="Isotope.toggleCheckboxGroup(this, \'' . $id . '\')"> <label for="check_all_' . $id . '" style="color:#a6a6a6;"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label></span>';
         foreach ($arrOptionGroup as $arrOption) {
             $strButtons = '';
             $k = is_array($this->varValue) && in_array($arrOption['value'], $this->varValue) ? $cid++ : '';
             foreach ($arrButtons as $strButton) {
                 $strButtons .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $strButton . '&amp;cid=' . $k . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable][$strButton][0]) . '" onclick="Isotope.attributeWizard(this, \'' . $strButton . '\', \'' . $id . '\'); return false;">' . $this->generateImage($strButton . '.gif', $GLOBALS['TL_LANG'][$this->strTable][$strButton][0], 'class="tl_checkbox_wizard_img"') . '</a> ';
             }
             $arrOptions[] = $this->generateCheckbox($arrOption, $i, $strButtons, $cid);
         }
         $arrOptions[] = '</div>';
         $blnFirst = false;
         $blnCheckAll = false;
     }
     // Add a "no entries found" message if there are no options
     if (!count($arrOptions)) {
         $arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
         $blnCheckAll = false;
     }
     return sprintf('%s<div id="ctrl_%s" class="%s%s">%s%s</div>%s', $this->generateInfoBar(), $this->strId, 'tl_checkbox_container tl_checkbox_wizard tl_attributewizard', strlen($this->strClass) ? ' ' . $this->strClass : '', $blnCheckAll ? '<span class="fixed"><input type="checkbox" id="check_all_' . $this->strId . '" class="tl_checkbox" onclick="Isotope.toggleCheckboxGroup(this, \'ctrl_' . $this->strId . '\')"> <label for="check_all_' . $this->strId . '" style="color:#a6a6a6;"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label></span>' : '', implode('', $arrOptions), $this->wizard);
 }
 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     $return = '';
     $arrButtons = array('up', 'down');
     $strCommand = 'cmd_' . $this->strField;
     // Add JavaScript and css
     if (TL_MODE == 'BE') {
         $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/imagesortwizard/assets/js/imagesortwizard.min.js';
         $GLOBALS['TL_CSS'][] = 'system/modules/imagesortwizard/assets/css/imagesortwizard.min.css|screen';
     }
     // Change the order
     if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
         $this->import('Database');
         switch ($this->Input->get($strCommand)) {
             case 'up':
                 $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                 break;
             case 'down':
                 $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                 break;
         }
         $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
         $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
     }
     $tabindex = 0;
     $return .= '<div id="ctrl_' . $this->strId . '" class="tl_imagesortwizard">';
     $return .= '<ul class="sortable">';
     // Get sort Images
     $this->sortImages = $this->getSortedImages();
     // Make sure there is at least an empty array
     if (!is_array($this->varValue) || count($this->varValue) < 1) {
         $this->varValue = array();
     }
     // Set var sortImages as array if there is none
     if (!is_array($this->sortImages) || count($this->sortImages) < 1) {
         $this->sortImages = array();
     }
     // Set var value
     $newVarValue = array();
     // Remove old Images
     if (count($this->varValue) > 0) {
         $objFiles = \FilesModel::findMultipleByUuids($this->varValue);
         if ($objFiles !== null) {
             while ($objFiles->next()) {
                 if (in_array($objFiles->uuid, $this->sortImages) || in_array($objFiles->id, $this->sortImages)) {
                     // Backwards compatibility (id)
                     $newVarValue[] = $objFiles->uuid;
                 }
             }
         }
     }
     // Set newVarValue in varValue
     $this->varValue = $newVarValue;
     // Add new Images
     if (count($this->sortImages) > 0) {
         $objFiles = \FilesModel::findMultipleByUuids($this->sortImages);
         if ($objFiles !== null) {
             while ($objFiles->next()) {
                 if (!in_array($objFiles->uuid, $this->varValue)) {
                     $this->varValue[] = $objFiles->uuid;
                 }
             }
         }
     }
     $objFiles = \FilesModel::findMultipleByUuids($this->varValue);
     if ($objFiles !== null) {
         $i = 0;
         $rows = $objFiles->count() - 1;
         while ($objFiles->next()) {
             $objFile = new \File($objFiles->path);
             // Generate thumbnail
             if ($objFile->isGdImage && $objFile->height > 0) {
                 if ($GLOBALS['TL_CONFIG']['thumbnails'] && $objFile->height <= $GLOBALS['TL_CONFIG']['gdMaxImgHeight'] && $objFile->width <= $GLOBALS['TL_CONFIG']['gdMaxImgWidth']) {
                     $_width = $objFile->width < 80 ? $objFile->width : 80;
                     $_height = $objFile->height < 60 ? $objFile->height : 60;
                     $thumbnail = '<img src="' . TL_FILES_URL . $this->getImage($objFiles->path, $_width, $_height, 'center_center') . '" alt="thumbnail">';
                 }
             }
             $return .= '<li>';
             $return .= $thumbnail;
             $return .= '<input type="hidden" name="' . $this->strId . '[]" class="tl_text" tabindex="' . ++$tabindex . '" value="' . specialchars(\String::binToUuid($objFiles->uuid)) . '"' . $this->getAttributes() . '>';
             $return .= '</li>';
             $i++;
         }
     }
     $return .= '</ul>';
     $return .= '</div>';
     return $return;
 }
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
           $this->import('Database');
           switch ($this->Input->get($strCommand)) {
               case 'copy':
                   array_insert($this->varValue, $this->Input->get('cid'), array($this->varValue[$this->Input->get('cid')]));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array(array(''));
       }
       // Begin table
       $return .= '<table class="tl_optionwizard" id="ctrl_' . $this->strId . '">
 <thead>
   <tr>
     <th>' . $GLOBALS['TL_LANG']['MSC']['ow_key'] . '</th>
     <th>' . $GLOBALS['TL_LANG']['MSC']['ow_value'] . '</th>
     <th>&nbsp;</th>
   </tr>
 </thead>
 <tbody>';
       $tabindex = 0;
       // Add fields
       for ($i = 0; $i < count($this->varValue); $i++) {
           $return .= '
   <tr>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][key]" id="' . $this->strId . '_key_' . $i . '" class="tl_text_2" tabindex="' . ++$tabindex . '" value="' . specialchars($this->varValue[$i]['key']) . '"></td>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][value]" id="' . $this->strId . '_value_' . $i . '" class="tl_text_2" tabindex="' . ++$tabindex . '" value="' . specialchars($this->varValue[$i]['value']) . '"></td>';
           // Add row buttons
           $return .= '
     <td style="white-space:nowrap; padding-left:3px;">';
           foreach ($arrButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '" onclick="Backend.keyValueWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '</a> ';
           }
           $return .= '</td>
   </tr>';
       }
       return $return . '
 </tbody>
 </table>';
   }
Beispiel #9
0
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'drag', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           $this->import('Database');
           switch (\Input::get($strCommand)) {
               case 'copy':
                   array_insert($this->varValue, \Input::get('cid'), array($this->varValue[\Input::get('cid')]));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array(array(''));
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       // Begin the table
       $return = '<table class="tl_optionwizard" id="ctrl_' . $this->strId . '">
 <thead>
   <tr>
     <th>' . $GLOBALS['TL_LANG']['MSC']['ow_value'] . '</th>
     <th>' . $GLOBALS['TL_LANG']['MSC']['ow_label'] . '</th>
     <th>&nbsp;</th>
     <th>&nbsp;</th>
     <th>&nbsp;</th>
   </tr>
 </thead>
 <tbody class="sortable" data-tabindex="' . $tabindex . '">';
       // Add fields
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $return .= '
   <tr>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][value]" id="' . $this->strId . '_value_' . $i . '" class="tl_text_2" tabindex="' . $tabindex++ . '" value="' . specialchars($this->varValue[$i]['value']) . '"></td>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][label]" id="' . $this->strId . '_label_' . $i . '" class="tl_text_2" tabindex="' . $tabindex++ . '" value="' . specialchars($this->varValue[$i]['label']) . '"></td>
     <td><input type="checkbox" name="' . $this->strId . '[' . $i . '][default]" id="' . $this->strId . '_default_' . $i . '" class="fw_checkbox" tabindex="' . $tabindex++ . '" value="1"' . ($this->varValue[$i]['default'] ? ' checked="checked"' : '') . '> <label for="' . $this->strId . '_default_' . $i . '">' . $GLOBALS['TL_LANG']['MSC']['ow_default'] . '</label></td>
     <td><input type="checkbox" name="' . $this->strId . '[' . $i . '][group]" id="' . $this->strId . '_group_' . $i . '" class="fw_checkbox" tabindex="' . $tabindex++ . '" value="1"' . ($this->varValue[$i]['group'] ? ' checked="checked"' : '') . '> <label for="' . $this->strId . '_group_' . $i . '">' . $GLOBALS['TL_LANG']['MSC']['ow_group'] . '</label></td>';
           // Add row buttons
           $return .= '
     <td style="white-space:nowrap; padding-left:3px">';
           foreach ($arrButtons as $button) {
               $class = $button == 'up' || $button == 'down' ? ' class="button-move"' : '';
               if ($button == 'drag') {
                   $return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } else {
                   $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '" onclick="Backend.optionsWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '</a> ';
               }
           }
           $return .= '</td>
   </tr>';
       }
       // Store the tab index
       \Cache::set('tabindex', $tabindex);
       return $return . '
 </tbody>
 </table>';
   }
    /**
     * Generate the widget and return it as string
     * @return string
     */
    public function generate()
    {
        // load the callback data if there's any (do not do this in __set() already because then we don't have access to currentRecord)
        if (is_array($this->arrCallback)) {
            $this->import($this->arrCallback[0]);
            $this->columnFields = $this->{$this->arrCallback[0]}->{$this->arrCallback[1]}($this);
        }
        $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/multicolumnwizard/html/js/multicolumnwizard_' . strtolower(TL_MODE) . '.js';
        $GLOBALS['TL_CSS'][] = 'system/modules/multicolumnwizard/html/css/multicolumnwizard.css';
        $this->strCommand = 'cmd_' . $this->strField;
        // Change the order
        if ($this->Input->get($this->strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
            switch ($this->Input->get($this->strCommand)) {
                case 'copy':
                    $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                    break;
                case 'up':
                    $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                    break;
                case 'down':
                    $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                    break;
                case 'delete':
                    $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                    break;
            }
            if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'File') {
                $this->Config->update(sprintf("\$GLOBALS['TL_CONFIG']['%s']", $this->strField), serialize($this->varValue));
            } else {
                if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'])) {
                    $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'];
                    require_once sprintf('%s/system/drivers/%s.php', TL_ROOT, $dataContainer);
                    $dc = new $dataContainer($this->strTable);
                    $dc->field = $objWidget->id;
                    $dc->inputName = $objWidget->id;
                    foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'] as $callback) {
                        $this->import($callback[0]);
                        $this->{$callback}[0]->{$callback}[1](serialize($this->varValue), $dc);
                    }
                } else {
                    $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
                }
            }
            // Reload the page
            $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
        }
        $arrUnique = array();
        $arrDatepicker = array();
        $arrHeaderItems = array();
        foreach ($this->columnFields as $strKey => $arrField) {
            // Store unique fields
            if ($arrField['eval']['unique']) {
                $arrUnique[] = $strKey;
            }
            // Store date picker fields
            if ($arrField['eval']['datepicker']) {
                $arrDatepicker[] = $strKey;
            }
            if ($arrField['inputType'] == 'hidden') {
                continue;
            }
        }
        $intNumberOfRows = max(count($this->varValue), 1);
        // always show the minimum number of rows if set
        if ($this->minCount && $intNumberOfRows < $this->minCount) {
            $intNumberOfRows = $this->minCount;
        }
        $arrItems = array();
        // Add input fields
        for ($i = 0; $i < $intNumberOfRows; $i++) {
            $this->activeRow = $i;
            $strHidden = '';
            // Walk every column
            foreach ($this->columnFields as $strKey => $arrField) {
                $strWidget = '';
                // load row specific data (useful for example for default values in different rows)
                if (isset($this->arrRowSpecificData[$i][$strKey])) {
                    $arrField = array_merge($arrField, $this->arrRowSpecificData[$i][$strKey]);
                }
                $objWidget = $this->initializeWidget($arrField, $i, $strKey, $this->varValue[$i][$strKey]);
                // load errors if there are any
                if (!empty($this->arrWidgetErrors[$strKey][$i])) {
                    foreach ($this->arrWidgetErrors[$strKey][$i] as $strErrorMsg) {
                        $objWidget->addError($strErrorMsg);
                    }
                }
                if ($objWidget === null) {
                    continue;
                } elseif (is_string($objWidget)) {
                    $strWidget = $objWidget;
                } elseif ($arrField['inputType'] == 'hidden') {
                    $strHidden .= $objWidget->generate();
                    continue;
                } else {
                    $datepicker = '';
                    // Datepicker
                    if ($arrField['eval']['datepicker']) {
                        $rgxp = $arrField['eval']['rgxp'];
                        $format = $GLOBALS['TL_CONFIG'][$rgxp . 'Format'];
                        switch ($rgxp) {
                            case 'datim':
                                $time = ",\n      timePicker:true";
                                break;
                            case 'time':
                                $time = ",\n      timePickerOnly:true";
                                break;
                            default:
                                $time = '';
                                break;
                        }
                        $datepicker = ' <img src="plugins/datepicker/icon.gif" width="20" height="20" alt="" id="toggle_' . $objWidget->id . '" style="vertical-align:-6px;">
                          <script>

                          window.datepicker_' . $this->strName . '_' . $strKey . ' = new DatePicker(\'#ctrl_' . $objWidget->id . '\', {
                          allowEmpty:true,
                          toggleElements:\'#toggle_' . $objWidget->id . '\',
                          pickerClass:\'datepicker_dashboard\',
                          format:\'' . $format . '\',
                          inputOutputFormat:\'' . $format . '\',
                          positionOffset:{x:130,y:-185}' . $time . ',
                          startDay:' . $GLOBALS['TL_LANG']['MSC']['weekOffset'] . ',
                          days:[\'' . implode("','", $GLOBALS['TL_LANG']['DAYS']) . '\'],
                          dayShort:' . $GLOBALS['TL_LANG']['MSC']['dayShortLength'] . ',
                          months:[\'' . implode("','", $GLOBALS['TL_LANG']['MONTHS']) . '\'],
                          monthShort:' . $GLOBALS['TL_LANG']['MSC']['monthShortLength'] . '
                          });

                          </script>';
                        $datepicker = $this->getMcWDatePickerString($objWidget->id, $strKey, $rgxp);
                        /* $datepicker = '<script>
                           window.addEvent(\'domready\', function() {
                           ' . sprintf($this->getDatePickerString(), 'ctrl_' . $objWidget->strId) . '
                           });
                           </script>'; */
                    }
                    // Add custom wizard
                    if (is_array($arrField['wizard'])) {
                        $wizard = '';
                        $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'];
                        require_once sprintf('%s/system/drivers/%s.php', TL_ROOT, $dataContainer);
                        $dc = new $dataContainer($this->strTable);
                        $dc->field = $objWidget->id;
                        $dc->inputName = $objWidget->id;
                        foreach ($arrField['wizard'] as $callback) {
                            $this->import($callback[0]);
                            $wizard .= $this->{$callback}[0]->{$callback}[1]($dc, $objWidget);
                        }
                        $objWidget->wizard = $wizard;
                    }
                    $strWidget = $objWidget->parse() . $datepicker;
                }
                // Build array of items
                if ($arrField['eval']['columnPos'] != '') {
                    $arrItems[$i][$objWidget->columnPos]['entry'] .= $strWidget;
                    $arrItems[$i][$objWidget->columnPos]['valign'] = $arrField['eval']['valign'];
                    $arrItems[$i][$objWidget->columnPos]['tl_class'] = $arrField['eval']['tl_class'];
                } else {
                    $arrItems[$i][$strKey] = array('entry' => $strWidget, 'valign' => $arrField['eval']['valign'], 'tl_class' => $arrField['eval']['tl_class']);
                }
            }
        }
        return $this->blnTableless ? $this->generateDiv($arrUnique, $arrDatepicker, $strHidden, $arrItems) : $this->generateTable($arrUnique, $arrDatepicker, $strHidden, $arrItems);
    }
Beispiel #11
0
    /**
     * Generate the widget and return it as string
     * @return string
     */
    public function generate()
    {
        $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/isotope/html/backend.js';
        $this->import('Database');
        //allows us to set which buttons can be enabled for this widget.
        /*foreach($this->enabledFunctions as $v)
        		{
        			$arrButtons[] = $v;
        		}*/
        $strCommand = 'cmd_' . $this->strField;
        // Change the order
        if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
            switch ($this->Input->get($strCommand)) {
                case 'copy':
                    $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                    break;
                case 'up':
                    $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                    break;
                case 'down':
                    $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                    break;
                case 'delete':
                    $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                    break;
            }
        }
        $objTaxClasses = $this->Database->execute("SELECT id, name FROM tl_iso_tax_class");
        if ($objTaxClasses->numRows) {
            $arrTaxClasses = $objTaxClasses->fetchAllAssoc();
        }
        if (!is_array($arrTaxClasses) || !count($arrTaxClasses)) {
            $arrTaxClasses = array('');
        }
        // Get new value
        if ($this->Input->post('FORM_SUBMIT') == $this->strTable) {
            $varValue = $this->Input->post($this->strId);
        }
        // Make sure there is at least an empty array
        if (!is_array($this->varValue) || !$this->varValue[0]) {
            //$this->varValue = array('');
        } else {
            /*foreach($this->varValue as $v)
            			{
            
            
            			}*/
        }
        // Save the value
        if ($this->Input->get($strCommand) || $this->Input->post('FORM_SUBMIT') == $this->strTable) {
            $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
            // Reload the page
            if (is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
                $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
            }
        }
        // Add label and return wizard
        $return .= '<table class="tl_optionwizard" id="ctrl_' . $this->strId . '">
  <thead>';
        if (is_array($this->varValue) && count($this->varValue)) {
            $return .= '
    <tr>
      <th><strong>' . $GLOBALS['TL_LANG'][$this->strTable]['opLabel'] . '</strong></th>
      <th><strong>' . $GLOBALS['TL_LANG'][$this->strTable]['opPrice'] . '</strong></th>
      <th><strong>' . $GLOBALS['TL_LANG'][$this->strTable]['opTaxClass'] . '</strong></th>
      <th>&nbsp;</th>
    </tr>
  </thead>
  <tbody>';
            // Add rows
            for ($i = 0; $i < count($this->varValue); $i++) {
                $arrRow = array();
                $arrRow = $this->varValue[$i];
                $blnEditable = false;
                if (is_array($arrRow)) {
                    $blnEditable = true;
                } else {
                    continue;
                }
                $return .= '<tr>';
                $return .= '	<td>' . $this->varValue[$i]['label'] . '<input type="hidden" name="' . $this->strId . '[' . $i . '][label]" id="' . $this->strId . '_label_' . $i . '" value="' . $this->varValue[$i]['label'] . '"></td>';
                $return .= '	<td>' . ($blnEditable ? '<input type="text" name="' . $this->strId . '[' . $i . '][total_price]" id="' . $this->strId . '_total_price_' . $i . '" class="tl_text_3" value="' . specialchars(round($this->varValue[$i]['total_price'], 2)) . '">' : round($this->varValue[$i]['total_price'], 2)) . '</td>';
                $options = '';
                $options = '<option value=""' . $this->optionSelected(NULL, $this->varValue[$i]['tax_class']) . '>-</option>';
                // Add Tax Classes
                foreach ($arrTaxClasses as $v) {
                    $options .= '<option value="' . specialchars($v['id']) . '"' . $this->optionSelected($v['id'], $this->varValue[$i]['tax_class']) . '>' . $v['name'] . '</option>';
                    if ($v['id'] == $this->varValue[$i]['tax_class']) {
                        $strTaxLabel = $v['name'];
                    }
                }
                $return .= '
      <td>' . ($blnEditable ? '<select name="' . $this->strId . '[' . $i . '][tax_class]" class="tl_select_2" onfocus="Backend.getScrollOffset();">' . $options . '</select>' : $strTaxLabel) . '</td>';
                $return .= '<td>';
                if (is_array($arrButtons)) {
                    foreach ($arrButtons as $button) {
                        $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['wz_' . $button]) . '" onclick="Isotope.surchargeWizard(this, \'' . $button . '\',  \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG'][$this->strTable]['wz_' . $button], 'class="tl_listwizard_img"') . '</a> ';
                    }
                } else {
                    $return .= '&nbsp;';
                }
                $return .= '
      </td>
	</tr>';
            }
        } else {
            $return .= '
    <tr>
      <th>&nbsp;</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>' . $GLOBALS['TL_LANG']['MSC']['noSurcharges'] . '</td>
    </tr>';
        }
        return $return . '
  </tbody>
</table>';
    }
Beispiel #12
0
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrColButtons = array('ccopy', 'cmovel', 'cmover', 'cdelete');
       $arrRowButtons = array('rcopy', 'rup', 'rdown', 'rdelete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
           $this->import('Database');
           switch ($this->Input->get($strCommand)) {
               case 'ccopy':
                   for ($i = 0; $i < count($this->varValue); $i++) {
                       $this->varValue[$i] = array_duplicate($this->varValue[$i], $this->Input->get('cid'));
                   }
                   break;
               case 'cmovel':
                   for ($i = 0; $i < count($this->varValue); $i++) {
                       $this->varValue[$i] = array_move_up($this->varValue[$i], $this->Input->get('cid'));
                   }
                   break;
               case 'cmover':
                   for ($i = 0; $i < count($this->varValue); $i++) {
                       $this->varValue[$i] = array_move_down($this->varValue[$i], $this->Input->get('cid'));
                   }
                   break;
               case 'cdelete':
                   for ($i = 0; $i < count($this->varValue); $i++) {
                       $this->varValue[$i] = array_delete($this->varValue[$i], $this->Input->get('cid'));
                   }
                   break;
               case 'rcopy':
                   $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                   break;
               case 'rup':
                   $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                   break;
               case 'rdown':
                   $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                   break;
               case 'rdelete':
                   $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || count($this->varValue) < 1) {
           $this->varValue = array(array(''));
       }
       // Begin table
       $return .= '<div id="tl_tablewizard">
 <table id="ctrl_' . $this->strId . '" class="tl_tablewizard">
 <tbody>
   <tr>';
       // Add column buttons
       for ($i = 0; $i < count($this->varValue[0]); $i++) {
           $return .= '
     <td style="text-align:center; white-space:nowrap;">';
           // Add column buttons
           foreach ($arrColButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_' . $button]) . '" onclick="Backend.tableWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage(substr($button, 1) . '.gif', $GLOBALS['TL_LANG']['MSC']['tw_' . $button], 'class="tl_tablewizard_img"') . '</a> ';
           }
           $return .= '</td>';
       }
       $return .= '
     <td></td>
   </tr>';
       $tabindex = 0;
       // Add rows
       for ($i = 0; $i < count($this->varValue); $i++) {
           $return .= '
   <tr>';
           // Add cells
           for ($j = 0; $j < count($this->varValue[$i]); $j++) {
               $return .= '
     <td class="tcontainer"><textarea name="' . $this->strId . '[' . $i . '][' . $j . ']" class="tl_textarea" tabindex="' . ++$tabindex . '" rows="' . $this->intRows . '" cols="' . $this->intCols . '"' . $this->getAttributes() . '>' . specialchars($this->varValue[$i][$j]) . '</textarea></td>';
           }
           $return .= '
     <td style="white-space:nowrap;">';
           // Add row buttons
           foreach ($arrRowButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_' . $button]) . '" onclick="Backend.tableWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage(substr($button, 1) . '.gif', $GLOBALS['TL_LANG']['MSC']['tw_' . $button], 'class="tl_tablewizard_img"') . '</a> ';
           }
           $return .= '</td>
   </tr>';
       }
       $return .= '
 </tbody>
 </table>
 </div>
 <script>
 Backend.tableWizardResize();
 </script>';
       return $return;
   }
 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     // load the callback data if there's any (do not do this in __set() already because then we don't have access to currentRecord)
     if (is_array($this->arrCallback)) {
         $this->import($this->arrCallback[0]);
         $this->columnFields = $this->{$this->arrCallback[0]}->{$this->arrCallback[1]}($this);
     }
     $this->strCommand = 'cmd_' . $this->strField;
     // TODO: Actions
     if ($this->Input->get($this->strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
         switch ($this->Input->get($this->strCommand)) {
             case 'copy':
                 $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                 break;
             case 'up':
                 $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                 break;
             case 'down':
                 $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                 break;
             case 'delete':
                 $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                 break;
         }
         // Save in File
         if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'File') {
             $this->Config->update(sprintf("\$GLOBALS['TL_CONFIG']['%s']", $this->strField), serialize($this->varValue));
             // Reload the page
             $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
         } else {
             if ($GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'] == 'Table') {
                 if (is_array($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'])) {
                     $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$this->strTable]['config']['dataContainer'];
                     // If less than 3.X, we must load the class by hand.
                     if (version_compare(VERSION, '3.0', '<')) {
                         require_once sprintf('%s/system/drivers/%s.php', TL_ROOT, $dataContainer);
                     }
                     $dc = new $dataContainer($this->strTable);
                     $dc->field = $objWidget->id;
                     $dc->inputName = $objWidget->id;
                     foreach ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['save_callback'] as $callback) {
                         $this->import($callback[0]);
                         $this->{$callback}[0]->{$callback}[1](serialize($this->varValue), $dc);
                     }
                 } else {
                     $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
                 }
                 // Reload the page
                 $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($this->strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
             } else {
                 // What to do here?
             }
         }
     }
     $arrUnique = array();
     $arrDatepicker = array();
     $arrTinyMCE = array();
     $arrHeaderItems = array();
     foreach ($this->columnFields as $strKey => $arrField) {
         // Store unique fields
         if ($arrField['eval']['unique']) {
             $arrUnique[] = $strKey;
         }
         // Store date picker fields
         if ($arrField['eval']['datepicker']) {
             $arrDatepicker[] = $strKey;
         }
         // Store tiny mce fields
         if ($arrField['eval']['rte'] && strncmp($arrField['eval']['rte'], 'tiny', 4) === 0) {
             foreach ($this->varValue as $row => $value) {
                 $tinyId = 'ctrl_' . $this->strField . '_row' . $row . '_' . $strKey;
                 $GLOBALS['TL_RTE']['tinyMCE'][$tinyId] = array('id' => $tinyId, 'file' => 'tinyMCE', 'type' => null);
             }
             $arrTinyMCE[] = $strKey;
         }
         if ($arrField['inputType'] == 'hidden') {
             continue;
         }
     }
     $intNumberOfRows = max(count($this->varValue), 1);
     // always show the minimum number of rows if set
     if ($this->minCount && $intNumberOfRows < $this->minCount) {
         $intNumberOfRows = $this->minCount;
     }
     $arrHidden = array();
     $arrItems = array();
     $arrHiddenHeader = array();
     // Add input fields
     for ($i = 0; $i < $intNumberOfRows; $i++) {
         $this->activeRow = $i;
         $strHidden = '';
         // Walk every column
         foreach ($this->columnFields as $strKey => $arrField) {
             $strWidget = '';
             $blnHiddenBody = false;
             if ($arrField['eval']['hideHead'] == true) {
                 $arrHiddenHeader[$strKey] = true;
             }
             // load row specific data (useful for example for default values in different rows)
             if (isset($this->arrRowSpecificData[$i][$strKey])) {
                 $arrField = array_merge($arrField, $this->arrRowSpecificData[$i][$strKey]);
             }
             // styles not needed in frontend, done per css
             unset($arrField['eval']['style']);
             $objWidget = $this->initializeWidget($arrField, $i, $strKey, $this->varValue[$i][$strKey]);
             // load errors if there are any
             if (!empty($this->arrWidgetErrors[$strKey][$i])) {
                 foreach ($this->arrWidgetErrors[$strKey][$i] as $strErrorMsg) {
                     $objWidget->addError($strErrorMsg);
                 }
             }
             if ($objWidget === null) {
                 continue;
             } elseif ($arrField['inputType'] == 'hidden') {
                 $arrHidden[] = $objWidget;
                 continue;
             }
             $arrItems[$i][$strKey] = array('field' => $objWidget);
         }
     }
     if ($this->formTemplate != '') {
         $strOutput = $this->generateTemplateOutput($arrUnique, $arrDatepicker, $arrHidden, $arrItems, $arrHiddenHeader);
     } else {
         $strOutput = $this->generateTable($arrUnique, $arrDatepicker, $arrHidden, $arrItems, $arrHiddenHeader);
     }
     return $strOutput;
 }
Beispiel #14
0
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $this->import('Database');
       $arrButtons = array('copy', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
           switch ($this->Input->get($strCommand)) {
               case 'copy':
                   $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                   break;
           }
       }
       // Get all modules of the current theme
       $objModules = $this->Database->prepare("SELECT id, name, type FROM tl_module WHERE pid=(SELECT pid FROM " . $this->strTable . " WHERE id=?) ORDER BY name")->execute($this->currentRecord);
       // Add the articles module
       $modules[] = array('id' => 0, 'name' => $GLOBALS['TL_LANG']['MOD']['article'][0], 'type' => 'article');
       if ($objModules->numRows) {
           $modules = array_merge($modules, $objModules->fetchAllAssoc());
       }
       $GLOBALS['TL_LANG']['FMD']['article'] = $GLOBALS['TL_LANG']['MOD']['article'];
       // Add the module type (see #3835)
       foreach ($modules as $k => $v) {
           $v['type'] = $GLOBALS['TL_LANG']['FMD'][$v['type']][0];
           $modules[$k] = $v;
       }
       $objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($this->currentRecord);
       // Show all columns and filter in PageRegular (see #3273)
       $cols = array('header', 'left', 'right', 'main', 'footer');
       $arrSections = deserialize($objRow->sections);
       // Add custom page sections
       if (is_array($arrSections) && !empty($arrSections)) {
           $cols = array_merge($cols, $arrSections);
       }
       // Get the new value
       if ($this->Input->post('FORM_SUBMIT') == $this->strTable) {
           $this->varValue = $this->Input->post($this->strId);
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array('');
       } else {
           // Initialize the sorting order
           foreach ($cols as $col) {
               $arrCols[$col] = array();
           }
           foreach ($this->varValue as $v) {
               $arrCols[$v['col']][] = $v;
           }
           $this->varValue = array();
           foreach ($arrCols as $arrCol) {
               $this->varValue = array_merge($this->varValue, $arrCol);
           }
       }
       // Save the value
       if ($this->Input->get($strCommand) || $this->Input->post('FORM_SUBMIT') == $this->strTable) {
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           // Reload the page
           if (is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
               $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
           }
       }
       // Add label and return wizard
       $return .= '<table id="ctrl_' . $this->strId . '" class="tl_modulewizard">
 <thead>
 <tr>
   <th>' . $GLOBALS['TL_LANG']['MSC']['mw_module'] . '</th>
   <th>&nbsp;</th>
   <th>' . $GLOBALS['TL_LANG']['MSC']['mw_column'] . '</th>
   <th>&nbsp;</th>
 </tr>
 </thead>
 <tbody>';
       // Load the tl_article language file
       $this->loadLanguageFile('tl_article');
       $tabindex = 0;
       // Add the input fields
       for ($i = 0; $i < count($this->varValue); $i++) {
           $options = '';
           // Add modules
           foreach ($modules as $v) {
               $options .= '<option value="' . specialchars($v['id']) . '"' . $this->optionSelected($v['id'], $this->varValue[$i]['mod']) . '>' . $v['name'] . ' // ' . $v['type'] . '</option>';
           }
           $return .= '
 <tr>
   <td><select name="' . $this->strId . '[' . $i . '][mod]" class="tl_select tl_chosen" tabindex="' . ++$tabindex . '" onfocus="Backend.getScrollOffset()" onchange="Backend.updateModuleLink(this)">' . $options . '</select></td>
   <td><a href="contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->varValue[$i]['mod'] . '" title="' . specialchars($GLOBALS['TL_LANG']['tl_layout']['edit_module']) . '" class="module_link" style="display:' . ($this->varValue[$i]['mod'] > 0 ? 'inline' : 'none') . '">' . $this->generateImage('edit.gif') . '</a>' . $this->generateImage('edit_.gif', '', 'class="module_image" style="display:' . ($this->varValue[$i]['mod'] > 0 ? 'none' : 'inline') . '"') . '</td>';
           $options = '';
           // Add columns
           foreach ($cols as $v) {
               $options .= '<option value="' . specialchars($v) . '"' . $this->optionSelected($v, $this->varValue[$i]['col']) . '>' . (isset($GLOBALS['TL_LANG']['tl_article'][$v]) && !is_array($GLOBALS['TL_LANG']['tl_article'][$v]) ? $GLOBALS['TL_LANG']['tl_article'][$v] : $v) . '</option>';
           }
           $return .= '
   <td><select name="' . $this->strId . '[' . $i . '][col]" class="tl_select_column" tabindex="' . ++$tabindex . '" onfocus="Backend.getScrollOffset()">' . $options . '</select></td>
   <td>';
           // Add buttons
           foreach ($arrButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['mw_' . $button]) . '" onclick="Backend.moduleWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG']['MSC']['mw_' . $button], 'class="tl_listwizard_img"') . '</a> ';
           }
           $return .= '</td>
 </tr>';
       }
       return $return . '
 </tbody>
 </table>';
   }
Beispiel #15
0
 public function generate()
 {
     $arrButtons = array('drag', 'up', 'down');
     $strCommand = 'cmd_' . $this->strField;
     if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
         $this->import('Database');
         switch (\Input::get($strCommand)) {
             case 'up':
                 $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                 break;
             case 'down':
                 $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                 break;
         }
         $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
         $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
     }
     //no selected list
     if (!$this->filterFields) {
         return '<p>' . $GLOBALS['TL_LANG']['MSC']['fm_ff_no_list'] . '</p>';
     }
     if (!is_array($this->varValue)) {
         $this->varValue = $this->filterFields;
     }
     if (count($this->varValue) != count($this->filterFields)) {
         $this->varValue = $this->filterFields;
     }
     $values = $this->varValue;
     if (!\Cache::has('tabindex')) {
         \Cache::set('tabindex', 1);
     }
     $tabindex = \Cache::get('tabindex');
     $strBodyTemplate = '';
     foreach ($values as $key => $value) {
         $widgetArr = $this->getTemplateGroup('fm_widget_' . $value['type']);
         $widgetsOptionsTemplate = '';
         foreach ($widgetArr as $widget) {
             $arrReplace = array('#', '<', '>', '(', ')', '\\', '=');
             $arrSearch = array('&#35;', '&#60;', '&#62;', '&#40;', '&#41;', '&#92;', '&#61;');
             $strVal = str_replace($arrSearch, $arrReplace, $value['used_templates']);
             $widgetsOptionsTemplate .= '<option value="' . $widget . '" ' . ($strVal == $widget ? 'selected' : '') . '>' . $widget . '</option>';
         }
         $selectOptionsTemplate = '<option value="default" selected >Standard</option>';
         $appearance = is_string($value['appearance']) ? deserialize($value['appearance']) : $value['appearance'];
         if ($appearance) {
             $selectOptionsTemplate = '';
             foreach ($appearance as $v => $label) {
                 $selectOptionsTemplate .= '<option value="' . $v . '" ' . ($value['used_appearance'] == $v ? 'selected' : '') . '>' . $label . '</option>';
             }
             if ($value['type'] == 'multi_choice') {
                 $selectOptionsTemplate .= '<option value="select" ' . ($value['used_appearance'] == 'select' ? 'selected' : '') . '>Select</option>';
             }
         }
         // get all field names
         $strFieldOptions = '<option value="">-</option>';
         if (is_array($this->filterFields)) {
             foreach ($this->filterFields as $arrField) {
                 $strFieldOptions .= '<option value="' . $arrField['fieldID'] . '" ' . ($arrField['fieldID'] == $value['dependsOn'] ? 'selected' : '') . ' >' . $arrField['title'] . '</option>';
             }
         }
         $strAppearance = $appearance != '' ? serialize($appearance) : '';
         $dragBtnTemplate = '';
         foreach ($arrButtons as $button) {
             $class = $button == 'up' || $button == 'down' ? ' class="button-move"' : '';
             if ($button == 'drag') {
                 $dragBtnTemplate .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
             } else {
                 $dragBtnTemplate .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $key . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '" onclick="Backend.optionsWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG']['MSC']['ow_' . $button]) . '</a> ';
             }
         }
         $strFieldTemplate = '<div class="fm_field_block">' . '<input type="hidden" value="' . $value['id'] . '" name="' . $this->strName . '[' . $key . '][objID]">' . '<input type="hidden" value="' . $value['title'] . '" name="' . $this->strName . '[' . $key . '][title]">' . '<input type="hidden" value="' . $this->currentListID . '" name="' . $this->strName . '[' . $key . '][currentID]">' . '<input type="hidden" value="' . $value['fieldID'] . '" name="' . $this->strName . '[' . $key . '][fieldID]">' . '<input type="hidden" value="' . $value['type'] . '" name="' . $this->strName . '[' . $key . '][type]">' . '<input type="hidden" value="' . htmlspecialchars($strAppearance) . '" name="' . $this->strName . '[' . $key . '][appearance]">' . '<input type="hidden" value="' . $value['isInteger'] . '" name="' . $this->strName . '[' . $key . '][isInteger]">' . '<input type="hidden" value="' . $value['addTime'] . '" name="' . $this->strName . '[' . $key . '][addTime]">' . '<input type="hidden" value="' . $value['from_field'] . '" name="' . $this->strName . '[' . $key . '][from_field]">' . '<input type="hidden" value="' . $value['to_field'] . '" name="' . $this->strName . '[' . $key . '][to_field]">' . '<input type="hidden" value="' . $value['description'] . '" name="' . $this->strName . '[' . $key . '][description]">' . '<input type="hidden" value="' . $value['dataFromTaxonomy'] . '" name="' . $this->strName . '[' . $key . '][dataFromTaxonomy]">' . '<input type="hidden" value="' . $value['reactToTaxonomy'] . '" name="' . $this->strName . '[' . $key . '][reactToTaxonomy]">' . '<input type="hidden" value="' . $value['reactToField'] . '" name="' . $this->strName . '[' . $key . '][reactToField]">' . '<h3 class="fm_field_block_headline collapsed" onclick="fmToggleFieldBlock(this)">' . $value['title'] . '<span class="fm_field_block_drag">' . $dragBtnTemplate . '</span></h3>' . '<div class="fm_field_block_item collapsed">' . '<div class="w50">' . '<h3><label>' . $GLOBALS['TL_LANG']['MSC']['fm_ff_form_type'][0] . '</label></h3>' . '<select tabindex="' . $tabindex++ . '" name="' . $this->strName . '[' . $key . '][used_appearance]" id="ctrl_' . $this->strId . '[' . $key . '][appearance]" class="tl_select" >' . $selectOptionsTemplate . '</select>' . '<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_form_type'][1] . '</p>' . '</div>' . '<div  class="w50">' . '<h3><label>' . $GLOBALS['TL_LANG']['MSC']['fm_ff_template'][0] . '</label></h3>' . '<select tabindex="' . $tabindex++ . '" name="' . $this->strName . '[' . $key . '][used_templates]" id="ctrl_' . $this->strId . '[' . $key . '][template]" class="tl_select" >' . $widgetsOptionsTemplate . '</select>' . '<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_template'][1] . '</p>' . '</div>' . '<div  class="w50">' . '<h3><label for="ctrl_' . $this->strId . '[' . $key . '][cssClass]">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_class'][0] . '</label></h3>' . '<input type="text" tabindex="' . $tabindex++ . '" value="' . $value['cssClass'] . '" name="' . $this->strName . '[' . $key . '][cssClass]" id="ctrl_' . $this->strId . '[' . $key . '][cssClass]" class="tl_text"/>' . '<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_class'][1] . '</p>' . '</div>' . '<div  class="w50">' . '<h3><label>' . $GLOBALS['TL_LANG']['MSC']['fm_ff_dependsOn'][0] . '</label></h3>' . '<select tabindex="' . $tabindex++ . '" name="' . $this->strName . '[' . $key . '][dependsOn]" id="ctrl_' . $this->strId . '[' . $key . '][dependsOn]" class="tl_select" >' . $strFieldOptions . '</select>' . '<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_dependsOn'][1] . '</p>' . '</div>' . ($value['type'] == 'multi_choice' || $value['type'] == 'simple_choice' ? '<div class="clr">' . '<div class="tl_checkbox_single_container">' . '<input type="checkbox" tabindex="' . $tabindex++ . '" name="' . $this->strName . '[' . $key . '][changeOnSubmit]" value="1" id="ctrl_' . $this->strId . '[' . $key . '][changeOnSubmit]" class="tl_checkbox" ' . ($value['changeOnSubmit'] ? 'checked="checked"' : '') . ' />' . ' <label for="ctrl_' . $this->strId . '[' . $key . '][changeOnSubmit]">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_changeOnSubmit'][0] . '</label>' . '<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_changeOnSubmit'][1] . '</p>' . '</div>' . '</div>' : '') . '<div class="clr">' . '<div class="tl_checkbox_single_container">' . '<input type="checkbox" tabindex="' . $tabindex++ . '" name="' . $this->strName . '[' . $key . '][active]" value="1" id="ctrl_' . $this->strId . '[' . $key . '][active]" class="tl_checkbox" ' . ($value['active'] ? 'checked="checked"' : '') . ' />' . ' <label for="ctrl_' . $this->strId . '[' . $key . '][active]">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_active'][0] . '</label>' . '<p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['MSC']['fm_ff_active'][1] . '</p>' . '</div>' . '</div>' . '</div>' . '</div>';
         $strBodyTemplate .= $strFieldTemplate;
     }
     $strWidget = '<div class="tl_optionwizard tl_filter_fields" id="ctrl_' . $this->strId . '"><div class="sortable" data-tabindex="' . $tabindex . '">' . $strBodyTemplate . '</div></div>';
     $strJS = '<script>
            function fmToggleFieldBlock(e) {   
               if(typeof $ != "undefined") {
                  var tab = $(e);
                  var block = tab.getNext();
                  var isCollapsed = typeof tab.hasClass("collapsed") != "boolean" ? tab.hasClass("collapsed")[0] : tab.hasClass("collapsed");                   
                  if(isCollapsed) {
                     tab.removeClass("collapsed");
                     block.removeClass("collapsed");
                  }else{
                     tab.addClass("collapsed");
                     block.addClass("collapsed");
                  }                 
               }                   
            } 
         </script>';
     \Cache::set('tabindex', $tabindex);
     return $strWidget . $strJS;
 }
Beispiel #16
0
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('up', 'down');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
           $this->import('Database');
           switch ($this->Input->get($strCommand)) {
               case 'up':
                   $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
       }
       // Sort options
       if ($this->varValue) {
           $arrOptions = array();
           $arrTemp = $this->arrOptions;
           // Move selected and sorted options to the top
           foreach ($this->varValue as $i => $arrOption) {
               $arrOptions[$i] = $arrOption['value'];
               unset($this->arrOptions[array_search($arrOption['value'], $this->arrOptions)]);
           }
           ksort($arrOptions);
           $this->arrOptions = array_merge($arrOptions, $this->arrOptions);
       }
       // Begin table
       $return .= '<table class="tl_optionwizard" id="ctrl_' . $this->strId . '">
 <thead>
   <tr>
     <th>' . $this->generateImage('show.gif', '', 'title="' . $GLOBALS['TL_LANG'][$this->strTable]['fwEnabled'] . '"') . '</th>
     <th>&nbsp;</th>
     <th>' . $this->generateImage('show.gif', '', 'title="' . $GLOBALS['TL_LANG'][$this->strTable]['fwLabel'] . '"') . '</th>
     <th>' . $this->generateImage('show.gif', '', 'title="' . $GLOBALS['TL_LANG'][$this->strTable]['fwMandatory'] . '"') . '</th>
     <th>&nbsp;</th>
   </tr>
 </thead>
 <tbody>';
       $tabindex = 0;
       // Add fields
       foreach ($this->arrOptions as $i => $option) {
           $return .= '
   <tr>
     <td><input type="hidden" name="' . $this->strId . '[' . $i . '][enabled]" value=""><input type="checkbox" name="' . $this->strId . '[' . $i . '][enabled]" id="' . $this->strId . '_enabled_' . $i . '" class="fw_checkbox" tabindex="' . ++$tabindex . '" value="1"' . ($this->varValue[$i]['enabled'] ? ' checked="checked"' : '') . '></td>
     <td><input type="hidden" name="' . $this->strId . '[' . $i . '][value]" value="' . $option . '">' . $GLOBALS['TL_DCA'][$this->table]['fields'][$option]['label'][0] . '</td>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][label]" id="' . $this->strId . '_label_' . $i . '" class="tl_text_4" tabindex="' . ++$tabindex . '" value="' . specialchars($this->varValue[$i]['label']) . '"></td>
     <td><input type="hidden" name="' . $this->strId . '[' . $i . '][mandatory]" value=""><input type="checkbox" name="' . $this->strId . '[' . $i . '][mandatory]" id="' . $this->strId . '_mandatory_' . $i . '" class="fw_checkbox" tabindex="' . ++$tabindex . '" value="1"' . ($this->varValue[$i]['mandatory'] ? ' checked="checked"' : '') . '> <label for="' . $this->strId . '_mandatory_' . $i . '"></label></td>';
           // Add row buttons
           $return .= '
     <td style="white-space:nowrap; padding-left:3px;">';
           foreach ($arrButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable][$button][0]) . '" onclick="Isotope.fieldWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG'][$this->strTable][$button][0]) . '</a> ';
           }
           $return .= '</td>
   </tr>';
       }
       return $return . '
 </tbody>
 </table>';
   }
Beispiel #17
0
   /**
    * Generate the widget and return it as string
    *
    * @return string
    */
   public function generate()
   {
       $arrColButtons = array('ccopy', 'cmovel', 'cmover', 'cdelete');
       $arrRowButtons = array('rcopy', 'rdrag', 'rup', 'rdown', 'rdelete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           $this->import('Database');
           switch (\Input::get($strCommand)) {
               case 'ccopy':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_duplicate($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'cmovel':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_move_up($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'cmover':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_move_down($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'cdelete':
                   for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
                       $this->varValue[$i] = array_delete($this->varValue[$i], \Input::get('cid'));
                   }
                   break;
               case 'rcopy':
                   $this->varValue = array_duplicate($this->varValue, \Input::get('cid'));
                   break;
               case 'rup':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'rdown':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'rdelete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || empty($this->varValue)) {
           $this->varValue = array(array(''));
       }
       // Initialize the tab index
       if (!\Cache::has('tabindex')) {
           \Cache::set('tabindex', 1);
       }
       $tabindex = \Cache::get('tabindex');
       // Begin the table
       $return = '<div id="tl_tablewizard">
 <table id="ctrl_' . $this->strId . '" class="tl_tablewizard">
 <thead>
   <tr>';
       // Add column buttons
       for ($i = 0, $c = count($this->varValue[0]); $i < $c; $i++) {
           $return .= '
     <td style="text-align:center; white-space:nowrap">';
           // Add column buttons
           foreach ($arrColButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_' . $button]) . '" onclick="Backend.tableWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml(substr($button, 1) . '.gif', $GLOBALS['TL_LANG']['MSC']['tw_' . $button], 'class="tl_tablewizard_img"') . '</a> ';
           }
           $return .= '</td>';
       }
       $return .= '
     <td></td>
   </tr>
 </thead>
 <tbody class="sortable" data-tabindex="' . $tabindex . '">';
       // Add rows
       for ($i = 0, $c = count($this->varValue); $i < $c; $i++) {
           $return .= '
   <tr>';
           // Add cells
           for ($j = 0, $d = count($this->varValue[$i]); $j < $d; $j++) {
               $return .= '
     <td class="tcontainer"><textarea name="' . $this->strId . '[' . $i . '][' . $j . ']" class="tl_textarea noresize" tabindex="' . $tabindex++ . '" rows="' . $this->intRows . '" cols="' . $this->intCols . '"' . $this->getAttributes() . '>' . specialchars($this->varValue[$i][$j]) . '</textarea></td>';
           }
           $return .= '
     <td style="white-space:nowrap">';
           // Add row buttons
           foreach ($arrRowButtons as $button) {
               $class = $button == 'rup' || $button == 'rdown' ? ' class="button-move"' : '';
               if ($button == 'rdrag') {
                   $return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } else {
                   $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG']['MSC']['tw_' . $button]) . '" onclick="Backend.tableWizard(this,\'' . $button . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml(substr($button, 1) . '.gif', $GLOBALS['TL_LANG']['MSC']['tw_' . $button], 'class="tl_tablewizard_img"') . '</a> ';
               }
           }
           $return .= '</td>
   </tr>';
       }
       // Store the tab index
       \Cache::set('tabindex', $tabindex);
       $return .= '
 </tbody>
 </table>
 </div>
 <script>Backend.tableWizardResize()</script>';
       return $return;
   }
Beispiel #18
0
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrFallback = $this->getFallbackData();
       // Adapt the temporary files
       if (is_array($this->varValue['files']) && !empty($this->varValue['files'])) {
           foreach ($this->varValue['files'] as $v) {
               if (!is_file(TL_ROOT . '/' . $this->getFilePath($v))) {
                   continue;
               }
               $this->varValue[] = array('src' => $v, 'alt' => '', 'desc' => '', 'link' => '', 'translate' => '');
           }
           unset($this->varValue['files']);
       }
       // Merge parent record data
       if ($arrFallback !== false) {
           $blnLanguage = true;
           $this->varValue = Gallery::mergeMediaData($this->varValue, $arrFallback);
       }
       $arrButtons = array('up', 'down', 'delete', 'drag');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           switch (\Input::get($strCommand)) {
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           \Database::getInstance()->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           \Controller::redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
       }
       $blnIsAjax = \Environment::get('isAjaxRequest');
       $return = '';
       $upload = '';
       if (!$blnIsAjax) {
           $return .= '<div id="ctrl_' . $this->strId . '" class="tl_mediamanager">';
           $extensions = trimsplit(',', $GLOBALS['TL_CONFIG']['validImageTypes']);
           $upload .= '<div id="fineuploader_' . $this->strId . '" class="upload_container"></div>
 <script>
   window.addEvent("domready", function() {
     Isotope.MediaManager.init($("fineuploader_' . $this->strId . '"), "' . $this->strId . '", ' . json_encode($extensions) . ');
   });
 </script>
 <script type="text/template" id="qq-template">
   <div class="qq-uploader-selector qq-uploader">
       <div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
           <span>' . $GLOBALS['TL_LANG']['MSC']['mmDrop'] . '</span>
       </div>
       <div class="qq-upload-button-selector qq-upload-button">
           <div class="tl_submit">' . $GLOBALS['TL_LANG']['MSC']['mmUpload'] . '</div>
       </div>
       <span class="qq-drop-processing-selector qq-drop-processing">
           <span>' . $GLOBALS['TL_LANG']['MSC']['mmProcessing'] . '</span>
           <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
       </span>
       <ul class="qq-upload-list-selector qq-upload-list">
           <li>
               <div class="qq-progress-bar-container-selector">
                   <div class="qq-progress-bar-selector qq-progress-bar"></div>
               </div>
               <span class="qq-upload-spinner-selector qq-upload-spinner"></span>
               <span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>
               <span class="qq-upload-file-selector qq-upload-file"></span>
               <input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
               <span class="qq-upload-size-selector qq-upload-size"></span>
               <span class="qq-upload-status-text-selector qq-upload-status-text"></span>
           </li>
       </ul>
   </div>
 </script>';
       }
       $return .= '<div>';
       if (!is_array($this->varValue) || empty($this->varValue)) {
           return $return . $GLOBALS['TL_LANG']['MSC']['mmNoUploads'] . '</div>' . $upload . (!$blnIsAjax ? '</div>' : '');
       }
       // Add label and return wizard
       $return .= '<table>
 <thead>
 <tr>
   <td class="col_0 col_first">' . $GLOBALS['TL_LANG'][$this->strTable]['mmSrc'] . '</td>
   <td class="col_1">' . $GLOBALS['TL_LANG'][$this->strTable]['mmAlt'] . ' / ' . $GLOBALS['TL_LANG'][$this->strTable]['mmLink'] . '</td>
   <td class="col_2">' . $GLOBALS['TL_LANG'][$this->strTable]['mmDesc'] . '</td>
   <td class="col_3">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslate'] . '</td>
   <td class="col_4 col_last">&nbsp;</td>
 </tr>
 </thead>
 <tbody class="sortable">';
       // Add input fields
       for ($i = 0, $count = count($this->varValue); $i < $count; $i++) {
           $strFile = $this->getFilePath($this->varValue[$i]['src']);
           if (!is_file(TL_ROOT . '/' . $strFile)) {
               continue;
           }
           $objFile = new \File($strFile);
           if ($objFile->isGdImage) {
               $strPreview = \Image::get($strFile, 50, 50, 'box');
           } else {
               $strPreview = 'system/themes/' . $this->getTheme() . '/images/' . $objFile->icon;
           }
           $strTranslateText = $blnLanguage && $this->varValue[$i]['translate'] != 'all' ? ' disabled="disabled"' : '';
           $strTranslateNone = $blnLanguage && $this->varValue[$i]['translate'] == 'none' ? ' disabled="disabled"' : '';
           $return .= '
 <tr>
   <td class="col_0 col_first"><input type="hidden" name="' . $this->strName . '[' . $i . '][src]" value="' . specialchars($this->varValue[$i]['src']) . '"><a href="' . $strFile . '" onclick="Backend.openModalImage({\'width\':' . $objFile->width . ',\'title\':\'' . str_replace("'", "\\'", $GLOBALS['TL_LANG'][$this->strTable]['mmSrc']) . '\',\'url\':\'' . $strFile . '\'});return false"><img src="' . $strPreview . '" alt="' . specialchars($this->varValue[$i]['src']) . '"></a></td>
   <td class="col_1"><input type="text" class="tl_text_2" name="' . $this->strName . '[' . $i . '][alt]" value="' . specialchars($this->varValue[$i]['alt'], true) . '"' . $strTranslateNone . '><br><input type="text" class="tl_text_2" name="' . $this->strName . '[' . $i . '][link]" value="' . specialchars($this->varValue[$i]['link'], true) . '"' . $strTranslateText . '></td>
   <td class="col_2"><textarea name="' . $this->strName . '[' . $i . '][desc]" cols="40" rows="3" class="tl_textarea"' . $strTranslateNone . ' >' . specialchars($this->varValue[$i]['desc']) . '</textarea></td>
   <td class="col_3">
       ' . ($blnLanguage ? '<input type="hidden" name="' . $this->strName . '[' . $i . '][translate]" value="' . $this->varValue[$i]['translate'] . '">' : '') . '
       <fieldset class="radio_container">
           <span>
               <input id="' . $this->strName . '_' . $i . '_translate_none" name="' . $this->strName . '[' . $i . '][translate]" type="radio" class="tl_radio" value="none"' . $this->optionChecked('none', $this->varValue[$i]['translate']) . ($blnLanguage ? ' disabled="disabled"' : '') . '>
               <label for="' . $this->strName . '_' . $i . '_translate_none" title="' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateNone'][1] . '">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateNone'][0] . '</label></span>
           <span>
               <input id="' . $this->strName . '_' . $i . '_translate_text" name="' . $this->strName . '[' . $i . '][translate]" type="radio" class="tl_radio" value="text"' . $this->optionChecked('text', $this->varValue[$i]['translate']) . ($blnLanguage ? ' disabled="disabled"' : '') . '>
               <label for="' . $this->strName . '_' . $i . '_translate_text" title="' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateText'][1] . '">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateText'][0] . '</label></span>
           <span>
               <input id="' . $this->strName . '_' . $i . '_translate_all" name="' . $this->strName . '[' . $i . '][translate]" type="radio" class="tl_radio" value="all"' . $this->optionChecked('all', $this->varValue[$i]['translate']) . ($blnLanguage ? ' disabled="disabled"' : '') . '>
               <label for="' . $this->strName . '_' . $i . '_translate_all" title="' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateAll'][1] . '">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateAll'][0] . '</label></span>
       </fieldset>
   </td>
   <td class="col_4 col_last">';
           // Add buttons
           foreach ($arrButtons as $button) {
               if ($button == 'delete' && $blnLanguage && $this->varValue[$i]['translate'] != 'all') {
                   continue;
               }
               $class = $button == 'up' || $button == 'down' ? ' class="button-move"' : '';
               if ($button == 'drag') {
                   $return .= \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
               } else {
                   $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '"' . $class . ' title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['wz_' . $button]) . '" onclick="Isotope.MediaManager.act(this, \'' . $button . '\',  \'ctrl_' . $this->strId . '\'); return false;">' . \Image::getHtml($button . '.gif', $GLOBALS['TL_LANG'][$this->strTable]['wz_' . $button], 'class="tl_listwizard_img"') . '</a> ';
               }
           }
           $return .= '</td>
 </tr>';
       }
       return $return . '
 </tbody>
 </table>
 </div>' . $upload . (!$blnIsAjax ? '</div>' : '');
   }
Beispiel #19
0
 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     if (is_array($GLOBALS['TL_JAVASCRIPT'])) {
         array_insert($GLOBALS['TL_JAVASCRIPT'], 1, 'system/modules/MultiTextWizard/html/js/multitext.js');
     } else {
         $GLOBALS['TL_JAVASCRIPT'] = array('system/modules/MultiTextWizard/html/js/multitext.js');
     }
     $arrButtons = array('rnew', 'rcopy', 'rup', 'rdown', 'rdelete');
     $strCommand = 'cmd_' . $this->strField;
     $emptyarray = array();
     for ($i = 0; $i < count($this->arrColumns); $i++) {
         array_push($emptyarray, '');
     }
     // Change the order
     if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
         $this->import('Database');
         switch ($this->Input->get($strCommand)) {
             case 'rnew':
                 array_insert($this->varValue, $this->Input->get('cid') + 1, array($emptyarray));
                 break;
             case 'rcopy':
                 $this->varValue = array_duplicate($this->varValue, $this->Input->get('cid'));
                 break;
             case 'rup':
                 $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                 break;
             case 'rdown':
                 $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                 break;
             case 'rdelete':
                 $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                 break;
         }
         $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
         $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
     }
     // Make sure there is at least an empty array
     if (!is_array($this->varValue) || !$this->varValue[0]) {
         $this->varValue = array($emptyarray);
     }
     $objTemplate = new BackendTemplate($this->strMultitextTemplate);
     $objTemplate->strId = $this->strId;
     $objTemplate->attributes = $this->getAttributes();
     $objTemplate->arrColumns = $this->arrColumns;
     $objTemplate->varValue = $this->varValue;
     $objTemplate->arrMultiErrors = $this->arrMultiErrors;
     $buttons = array();
     $hasTitles = array_key_exists('buttonTitles', $this->arrConfiguration) && is_array($this->arrConfiguration['buttonTitles']);
     foreach ($arrButtons as $button) {
         $buttontitle = $hasTitles && array_key_exists($button, $this->arrConfiguration['buttonTitles']) ? $this->arrConfiguration['buttonTitles'][$button] : $GLOBALS['TL_LANG'][$this->strTable][$button][0];
         array_push($buttons, array('href' => $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=%s&amp;id=' . $this->currentRecord), 'title' => specialchars($buttontitle), 'onclick' => 'MultiText.multitextWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;', 'img' => $this->generateImage(substr($button, 1) . '.gif', $GLOBALS['TL_LANG'][$this->strTable][$button][0], 'class="tl_multitextwizard_img"')));
     }
     $objTemplate->arrButtons = $buttons;
     return $objTemplate->parse();
 }
 /**
  * Generate the widget and return it as string
  * @return string
  */
 public function generate()
 {
     $arrButtons = array('up', 'down');
     $strCommand = 'cmd_' . $this->strField;
     // Add JavaScript and css
     if (TL_MODE == 'BE') {
         $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/sortwizard/assets/js/sortwizard.min.js';
         $GLOBALS['TL_CSS'][] = 'system/modules/sortwizard/assets/css/sortwizard.min.css|screen';
     }
     // Use only multiple
     $this->multiple = true;
     if (!is_array($this->varValue)) {
         $this->varValue = array($this->varValue);
     }
     // Change the order
     if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
         $this->import('Database');
         switch (\Input::get($strCommand)) {
             case 'up':
                 $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                 break;
             case 'down':
                 $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                 break;
         }
         $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
         $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', \Environment::get('request'))));
     }
     // Sort options
     if ($this->varValue) {
         $arrOptions = array();
         $arrTemp = $this->arrOptions;
         // Move selected and sorted options to the top
         foreach ($this->arrOptions as $i => $arrOption) {
             if (($intPos = array_search($arrOption['value'], $this->varValue)) !== false) {
                 $arrOptions[$intPos] = $arrOption;
                 unset($arrTemp[$i]);
             }
         }
         ksort($arrOptions);
         $this->arrOptions = array_merge($arrOptions, $arrTemp);
     }
     $arrOptions = array();
     // Generate options and add buttons
     foreach ($this->arrOptions as $i => $arrOption) {
         $strButtons = \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
         foreach ($arrButtons as $strButton) {
             $strButtons .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $strButton . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" class="button-move" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['move_' . $strButton][1]) . '" onclick="Backend.SortWizard(this,\'' . $strButton . '\',\'ctrl_' . $this->strId . '\');return false">' . \Image::getHtml($strButton . '.gif', $GLOBALS['TL_LANG']['MSC']['move_' . $strButton][0], 'class="tl_sortwizard_img"') . '</a> ';
         }
         $arrOptions[] = $this->generateSortfield($arrOption, $i, $strButtons);
     }
     // Add a "no entries found" message if there are no options
     if (empty($arrOptions)) {
         $arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
     }
     return sprintf('<div id="ctrl_%s" class="tl_sortwizard_container tl_sortwizard%s"><h3><label>%s%s%s%s</label>%s</h3><input type="hidden" name="%s" value=""><div class="sortable">%s</div></div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->required ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . '</span> ' : '', $this->strLabel, $this->required ? '<span class="mandatory">*</span>' : '', $this->xlabel, $this->reloadButton ? '<a href="javascript: Backend.autoSubmit(' . "'" . $this->strTable . "'" . ');" class="sortwizard-update-list-button" title="' . $GLOBALS['TL_LANG']['MSC']['sortwizard_update_list_button'] . '"><img src="system/modules/sortwizard/images/reload.gif" width="16" height="16" alt="' . $GLOBALS['TL_LANG']['MSC']['sortwizard_update_list_button'] . '" style="vertical-align:text-bottom"></a>' : '', $this->strName, implode('', $arrOptions), $this->wizard);
 }
Beispiel #21
0
    /**
     * Generate the widget and return it as string
     * @return string
     */
    public function generate()
    {
        $blnLanguage = false;
        $this->import('Database');
        // Merge parent record data
        if ($_SESSION['BE_DATA']['language'][$this->strTable][$this->currentRecord] != '') {
            $blnLanguage = true;
            $objParent = $this->Database->execute("SELECT * FROM {$this->strTable} WHERE id={$this->currentRecord}");
            $arrParent = deserialize($objParent->{$this->strField});
            $this->import('Isotope');
            $this->varValue = $this->Isotope->mergeMediaData($this->varValue, $arrParent);
        }
        $GLOBALS['TL_CSS'][] = TL_PLUGINS_URL . 'plugins/mediabox/' . MEDIABOX . '/css/mediaboxAdvBlack21.css|screen';
        $GLOBALS['TL_JAVASCRIPT'][] = TL_PLUGINS_URL . 'plugins/mediabox/' . MEDIABOX . '/js/mediabox.js';
        $GLOBALS['TL_JAVASCRIPT'][] = TL_PLUGINS_URL . 'system/modules/isotope/html/mediabox_init.js';
        $arrButtons = array('up', 'down', 'delete');
        $strCommand = 'cmd_' . $this->strField;
        // Change the order
        if ($this->Input->get($strCommand) && is_numeric($this->Input->get('cid')) && $this->Input->get('id') == $this->currentRecord) {
            switch ($this->Input->get($strCommand)) {
                case 'up':
                    $this->varValue = array_move_up($this->varValue, $this->Input->get('cid'));
                    break;
                case 'down':
                    $this->varValue = array_move_down($this->varValue, $this->Input->get('cid'));
                    break;
                case 'delete':
                    $this->varValue = array_delete($this->varValue, $this->Input->get('cid'));
                    break;
            }
            $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
            $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
        }
        $upload = sprintf('<h3><label for="ctrl_%s_upload">%s</label></h3><p><input type="file" name="%s" id="ctrl_%s_upload" class="upload%s"></p>', $this->strId, $GLOBALS['TL_LANG']['MSC']['mmUpload'], $this->strName, $this->strId, strlen($this->strClass) ? ' ' . $this->strClass : '');
        $return = '<div id="ctrl_' . $this->strId . '">';
        if (!is_array($this->varValue) || !count($this->varValue)) {
            return $return . $GLOBALS['TL_LANG']['MSC']['mmNoUploads'] . $upload . '</div>';
        }
        // Add label and return wizard
        $return .= '<table class="tl_mediamanager">
  <thead>
  <tr>
    <td class="col_0 col_first">' . $GLOBALS['TL_LANG'][$this->strTable]['mmSrc'] . '</td>
    <td class="col_1">' . $GLOBALS['TL_LANG'][$this->strTable]['mmAlt'] . ' / ' . $GLOBALS['TL_LANG'][$this->strTable]['mmLink'] . '</td>
    <td class="col_2">' . $GLOBALS['TL_LANG'][$this->strTable]['mmDesc'] . '</td>
    <td class="col_3">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslate'] . '</td>
    <td class="col_4 col_last">&nbsp;</td>
  </tr>
  </thead>
  <tbody>';
        // Add input fields
        for ($i = 0; $i < count($this->varValue); $i++) {
            $strFile = 'isotope/' . strtolower(substr($this->varValue[$i]['src'], 0, 1)) . '/' . $this->varValue[$i]['src'];
            if (!is_file(TL_ROOT . '/' . $strFile)) {
                continue;
            }
            $objFile = new File($strFile);
            if ($objFile->isGdImage) {
                $strPreview = $this->getImage($strFile, 50, 50, 'box');
            } else {
                $strPreview = 'system/themes/' . $this->getTheme() . '/images/' . $objFile->icon;
            }
            $strTranslateText = $blnLanguage && $this->varValue[$i]['translate'] != 'all' ? ' disabled="disabled"' : '';
            $strTranslateNone = $blnLanguage && !$this->varValue[$i]['translate'] ? ' disabled="disabled"' : '';
            $return .= '
  <tr>
    <td class="col_0 col_first"><input type="hidden" name="' . $this->strName . '[' . $i . '][src]" value="' . specialchars($this->varValue[$i]['src']) . '"><a href="' . $strFile . '" rel="lightbox"><img src="' . $strPreview . '" alt="' . specialchars($this->varValue[$i]['src']) . '"></a></td>
    <td class="col_1"><input type="text" class="tl_text_2" name="' . $this->strName . '[' . $i . '][alt]" value="' . specialchars($this->varValue[$i]['alt']) . '"' . $strTranslateNone . '><br><input type="text" class="tl_text_2" name="' . $this->strName . '[' . $i . '][link]" value="' . specialchars($this->varValue[$i]['link']) . '"' . $strTranslateText . '></td>
    <td class="col_2"><textarea name="' . $this->strName . '[' . $i . '][desc]" cols="40" rows="3" class="tl_textarea"' . $strTranslateNone . ' >' . specialchars($this->varValue[$i]['desc']) . '</textarea></td>
    <td class="col_3">
    	' . ($blnLanguage ? '<input type="hidden" name="' . $this->strName . '[' . $i . '][translate]" value="' . $this->varValue[$i]['translate'] . '"' : '') . '
    	<fieldset class="radio_container">
	    	<span>
	    		<input id="' . $this->strName . '_' . $i . '_translate_none" name="' . $this->strName . '[' . $i . '][translate]" type="radio" class="tl_radio" value=""' . $this->optionChecked('', $this->varValue[$i]['translate']) . ($blnLanguage ? ' disabled="disabled"' : '') . '>
	    		<label for="' . $this->strName . '_' . $i . '_translate_none" title="' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateNone'][1] . '">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateNone'][0] . '</label></span>
	    	<span>
	    		<input id="' . $this->strName . '_' . $i . '_translate_text" name="' . $this->strName . '[' . $i . '][translate]" type="radio" class="tl_radio" value="text"' . $this->optionChecked('text', $this->varValue[$i]['translate']) . ($blnLanguage ? ' disabled="disabled"' : '') . '>
	    		<label for="' . $this->strName . '_' . $i . '_translate_text" title="' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateText'][1] . '">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateText'][0] . '</label></span>
	    	<span>
	    		<input id="' . $this->strName . '_' . $i . '_translate_all" name="' . $this->strName . '[' . $i . '][translate]" type="radio" class="tl_radio" value="all"' . $this->optionChecked('all', $this->varValue[$i]['translate']) . ($blnLanguage ? ' disabled="disabled"' : '') . '>
	    		<label for="' . $this->strName . '_' . $i . '_translate_all" title="' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateAll'][1] . '">' . $GLOBALS['TL_LANG'][$this->strTable]['mmTranslateAll'][0] . '</label></span>
    	</fieldset>
    </td>
    <td class="col_4 col_last">';
            foreach ($arrButtons as $button) {
                if ($button == 'delete' && $blnLanguage && $this->varValue[$i]['translate'] != 'all') {
                    continue;
                }
                $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable]['wz_' . $button]) . '" onclick="Isotope.mediaManager(this, \'' . $button . '\',  \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG'][$this->strTable]['wz_' . $button], 'class="tl_listwizard_img"') . '</a> ';
            }
            $return .= '</td>
  </tr>';
        }
        return $return . '
  </tbody>
  </table>' . $upload . '</div>';
    }
   /**
    * Generate the widget and return it as string
    * @return string
    */
   public function generate()
   {
       $arrButtons = array('copy', 'up', 'down', 'delete');
       $strCommand = 'cmd_' . $this->strField;
       // Change the order
       if (\Input::get($strCommand) && is_numeric(\Input::get('cid')) && \Input::get('id') == $this->currentRecord) {
           $this->import('Database');
           switch (\Input::get($strCommand)) {
               case 'copy':
                   array_insert($this->varValue, \Input::get('cid'), array($this->varValue[\Input::get('cid')]));
                   break;
               case 'up':
                   $this->varValue = array_move_up($this->varValue, \Input::get('cid'));
                   break;
               case 'down':
                   $this->varValue = array_move_down($this->varValue, \Input::get('cid'));
                   break;
               case 'delete':
                   $this->varValue = array_delete($this->varValue, \Input::get('cid'));
                   break;
           }
           $this->Database->prepare("UPDATE " . $this->strTable . " SET " . $this->strField . "=? WHERE id=?")->execute(serialize($this->varValue), $this->currentRecord);
           $this->redirect(preg_replace('/&(amp;)?cid=[^&]*/i', '', preg_replace('/&(amp;)?' . preg_quote($strCommand, '/') . '=[^&]*/i', '', $this->Environment->request)));
       }
       // Make sure there is at least an empty array
       if (!is_array($this->varValue) || !$this->varValue[0]) {
           $this->varValue = array(array(''));
       }
       // Begin table
       $return .= '<table cellspacing="0" cellpadding="0" class="tl_optionwizard" id="ctrl_' . $this->strId . '" summary="Field wizard">
 <thead>
   <tr>
     <th>' . $GLOBALS['TL_LANG'][$this->strTable]['opReference'] . '</th>
     <th>' . $GLOBALS['TL_LANG'][$this->strTable]['opValueProtected'] . '</th>
     <th>' . $GLOBALS['TL_LANG'][$this->strTable]['opLabel'] . '</th>
     <th>&nbsp;</th>
     <th>&nbsp;</th>
     <th>&nbsp;</th>
   </tr>
 </thead>
 <tbody>';
       // Add fields
       for ($i = 0; $i < count($this->varValue); $i++) {
           $return .= '
   <tr>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][reference]" id="' . $this->strId . '_reference_' . $i . '" class="tl_text_4" value="' . specialchars($this->varValue[$i]['reference']) . '" /></td>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][value]" id="' . $this->strId . '_value_' . $i . '" class="tl_text_2" value="' . specialchars($this->varValue[$i]['value']) . '" /></td>
     <td><input type="text" name="' . $this->strId . '[' . $i . '][label]" id="' . $this->strId . '_label_' . $i . '" class="tl_text_2" value="' . specialchars($this->varValue[$i]['label']) . '" /></td>
     <td><input type="checkbox" name="' . $this->strId . '[' . $i . '][default]" id="' . $this->strId . '_default_' . $i . '" class="fw_checkbox" value="1"' . ($this->varValue[$i]['default'] ? ' checked="checked"' : '') . ' /> <label for="' . $this->strId . '_default_' . $i . '">' . $GLOBALS['TL_LANG'][$this->strTable]['opDefault'] . '</label></td>
     <td><input type="checkbox" name="' . $this->strId . '[' . $i . '][group]" id="' . $this->strId . '_group_' . $i . '" class="fw_checkbox" value="1"' . ($this->varValue[$i]['group'] ? ' checked="checked"' : '') . ' /> <label for="' . $this->strId . '_group_' . $i . '">' . $GLOBALS['TL_LANG'][$this->strTable]['opGroup'] . '</label></td>';
           // Add row buttons
           $return .= '
     <td style="white-space:nowrap; padding-left:3px;">';
           foreach ($arrButtons as $button) {
               $return .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $button . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG'][$this->strTable][$button][0]) . '" onclick="Backend.optionsWizard(this, \'' . $button . '\', \'ctrl_' . $this->strId . '\'); return false;">' . $this->generateImage($button . '.gif', $GLOBALS['TL_LANG'][$this->strTable][$button][0]) . '</a> ';
           }
           $return .= '</td>
   </tr>';
       }
       return $return . '
 </tbody>
 </table>';
   }