当前位置: 首页>>代码示例>>PHP>>正文


PHP array_move_up函数代码示例

本文整理汇总了PHP中array_move_up函数的典型用法代码示例。如果您正苦于以下问题:PHP array_move_up函数的具体用法?PHP array_move_up怎么用?PHP array_move_up使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_move_up函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

   /**
    * 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>';
   }
开发者ID:Mozan,项目名称:core-bundle,代码行数:59,代码来源:ListWizard.php

示例2: generate

 /**
  * 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 = '';
         foreach ($arrButtons as $strButton) {
             $strButtons .= '<a href="' . $this->addToUrl('&amp;' . $strCommand . '=' . $strButton . '&amp;cid=' . $i . '&amp;id=' . $this->currentRecord) . '" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['move_' . $strButton][1]) . '" onclick="Backend.checkboxWizard(this,\'' . $strButton . '\',\'ctrl_' . $this->strId . '\');return false">' . $this->generateImage($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%s</fieldset>%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->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);
 }
开发者ID:rburch,项目名称:core,代码行数:56,代码来源:CheckBoxWizard.php

示例3: generate

   /**
    * 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>
//.........这里部分代码省略.........
开发者ID:bytehead,项目名称:contao-core,代码行数:101,代码来源:TableWizard.php

示例4: generate

   /**
    * 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 .= '
//.........这里部分代码省略.........
开发者ID:Mozan,项目名称:core-bundle,代码行数:101,代码来源:ModuleWizard.php

示例5: generate

   /**
    * 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>';
   }
开发者ID:rburch,项目名称:core-1,代码行数:68,代码来源:FieldWizard.php

示例6: generate

   /**
    * 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>';
   }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:47,代码来源:ListWizard.php

示例7: generate

    /**
     * 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++) {
//.........这里部分代码省略.........
开发者ID:Addictic,项目名称:MultiColumnWizard,代码行数:101,代码来源:MultiColumnWizard.php

示例8: generate

   /**
    * 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>';
//.........这里部分代码省略.........
开发者ID:jens-wetzel,项目名称:use2,代码行数:101,代码来源:ModuleWizard.php

示例9: generate

 /**
  * 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);
 }
开发者ID:rikaix,项目名称:core-1,代码行数:84,代码来源:AttributeWizard.php

示例10: generate

 /**
  * 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();
 }
开发者ID:jens-wetzel,项目名称:use2,代码行数:59,代码来源:MultiTextWizard.php

示例11: generate

   /**
    * 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>';
   }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:62,代码来源:KeyValueWizard.php

示例12: generate

    /**
     * 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
//.........这里部分代码省略.........
开发者ID:nrunde,项目名称:MultiColumnWizard,代码行数:101,代码来源:MultiColumnWizard.php

示例13: generate

   /**
    * 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)) {
//.........这里部分代码省略.........
开发者ID:Aziz-JH,项目名称:core,代码行数:101,代码来源:MediaManager.php

示例14: generate

    /**
     * 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) {
//.........这里部分代码省略.........
开发者ID:rburch,项目名称:core-1,代码行数:101,代码来源:SurchargeWizard.php

示例15: generate

   /**
    * 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;
   }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:99,代码来源:TableWizard.php


注:本文中的array_move_up函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。