本文整理汇总了PHP中array_move_down函数的典型用法代码示例。如果您正苦于以下问题:PHP array_move_down函数的具体用法?PHP array_move_down怎么用?PHP array_move_down使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_move_down函数的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('&' . $strCommand . '=' . $button . '&cid=' . $i . '&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>';
}
示例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 = \Image::getHtml('drag.gif', '', 'class="drag-handle" title="' . sprintf($GLOBALS['TL_LANG']['MSC']['move']) . '"');
foreach ($arrButtons as $strButton) {
$strButtons .= '<a href="' . $this->addToUrl('&' . $strCommand . '=' . $strButton . '&cid=' . $i . '&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);
}
示例3: 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> </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 .= '
//.........这里部分代码省略.........
示例4: 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++) {
//.........这里部分代码省略.........
示例5: 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('&' . $strCommand . '=' . $button . '&cid=' . $i . '&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>';
}
示例6: 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('&' . $strCommand . '=' . $strButton . '&cid=' . $k . '&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);
}
示例7: generate
/**
* 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;
}
示例8: 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> </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('&' . $strCommand . '=' . $button . '&cid=' . $i . '&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>';
}
示例9: 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':
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> </th>
<th> </th>
<th> </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('&' . $strCommand . '=' . $button . '&cid=' . $i . '&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>';
}
示例10: 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
//.........这里部分代码省略.........
示例11: 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> </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) {
//.........这里部分代码省略.........
示例12: 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('&' . $strCommand . '=' . $button . '&cid=' . $i . '&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('&' . $strCommand . '=' . $button . '&cid=' . $i . '&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;
}
示例13: 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);
}
$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) {
//.........这里部分代码省略.........
示例14: 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> </th>
<th>' . $GLOBALS['TL_LANG']['MSC']['mw_column'] . '</th>
<th> </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&table=tl_module&act=edit&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>';
//.........这里部分代码省略.........
示例15: generate
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('#', '<', '>', '(', ')', '\', '=');
$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('&' . $strCommand . '=' . $button . '&cid=' . $key . '&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;
}