Bug #23421 » 15524.diff
typo3/sysext/wizard_crpages/class.tx_wizardcrpages_webfunc_2.php (working copy) | ||
---|---|---|
*/
|
||
class tx_wizardcrpages_webfunc_2 extends t3lib_extobjbase {
|
||
protected $loremIpsumObject = NULL;
|
||
protected $tsConfig = array();
|
||
protected $pagesTsConfig = array();
|
||
/**
|
||
* Adds menu items... but I think this is not used at all. Looks very much like some testing code. If anyone cares to check it we can remove it some day...
|
||
*
|
||
... | ... | |
$theCode='';
|
||
$this->tsConfig = t3lib_BEfunc::getPagesTSconfig($this->pObj->id);
|
||
$this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array();
|
||
// Create loremIpsum code:
|
||
if (t3lib_extMgm::isLoaded('lorem_ipsum')) {
|
||
$this->loremIpsumObject = t3lib_div::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz');
|
||
}
|
||
$m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(8); // create new pages here?
|
||
$pRec = t3lib_BEfunc::getRecord('pages',$this->pObj->id,'uid',' AND '.$m_perms_clause);
|
||
$sys_pages = t3lib_div::makeInstance('t3lib_pageSelect');
|
||
... | ... | |
}
|
||
$firstRecord = true;
|
||
$previousIdentifier = '';
|
||
foreach ($data['pages'] as $identifier => $dat) {
|
||
if (!trim($dat['title'])) {
|
||
unset($data['pages'][$identifier]);
|
||
... | ... | |
}
|
||
$theCode.= '<h4>' . $LANG->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines);
|
||
} else {
|
||
// Create loremIpsum code:
|
||
if (t3lib_extMgm::isLoaded('lorem_ipsum')) {
|
||
$loremIpsumObj = t3lib_div::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz');
|
||
}
|
||
// Display create form
|
||
$lines = array();
|
||
for ($a = 0; $a < 9; $a++) {
|
||
$lines[] = '<label for="page_new_' . $a . '"> ' . $LANG->getLL('wiz_newPages_page') .' '. ($a+1) .
|
||
': </label><input type="text" id="page_new_' . $a . '" name="data[pages][NEW' . $a . '][title]"' . $this->pObj->doc->formWidth(35) . ' />'.
|
||
(is_object($loremIpsumObj) ? '<a href="#" onclick="' . htmlspecialchars($loremIpsumObj->getHeaderTitleJS('document.forms[0][\'data[pages][NEW' . $a . '][title]\'].value', 'title')) . '">' . $loremIpsumObj->getIcon('', $this->pObj->doc->backPath) . '</a>' : '');
|
||
$lines[] = $this->getFormLine($a);
|
||
}
|
||
$theCode.= '<h4>'.$LANG->getLL('wiz_newPages').':</h4>'.implode('<br />',$lines).
|
||
$theCode .= '<h4>' . $LANG->getLL('wiz_newPages').':</h4>' .
|
||
'<div id="formFieldContainer">' . implode('', $lines) . '</div>' .
|
||
'<br class="clearLeft" />' .
|
||
'<input type="button" id="createNewFormFields" value="' . $LANG->getLL('wiz_newPages_addFields') . '" />' .
|
||
'<br /><br />
|
||
<input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">'.$LANG->getLL('wiz_newPages_listEnd').'</label><br />
|
||
<input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">'.$LANG->getLL('wiz_newPages_hidePages').'</label><br /><br />
|
||
<input type="submit" name="create" value="' . $LANG->getLL('wiz_newPages_lCreate') . '" onclick="return confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('wiz_newPages_lCreate_msg1')) . ')" /> <input type="reset" value="' . $LANG->getLL('wiz_newPages_lReset') . '" /><br />';
|
||
// Add ExtJS inlne code
|
||
$extCode = '
|
||
var tpl = "' . addslashes(str_replace(
|
||
array(LF, TAB),
|
||
array('', ''),
|
||
$this->getFormLine('#')
|
||
)) . '", i, line, div, bg, label;
|
||
var lineCounter = 9;
|
||
Ext.get("createNewFormFields").on("click", function() {
|
||
div = Ext.get("formFieldContainer");
|
||
for (i = 0; i < 5; i++) {
|
||
label = lineCounter + i + 1;
|
||
bg = label % 2 === 0 ? 6 : 4;
|
||
line = String.format(tpl, (lineCounter + i), label, bg);
|
||
div.insertHtml("beforeEnd", line);
|
||
}
|
||
lineCounter += 5;
|
||
});
|
||
';
|
||
/** @var t3lib_pageRenderer **/
|
||
$pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
|
||
$pageRenderer->loadExtJS();
|
||
$pageRenderer->addExtOnReadyCode($extCode);
|
||
$pageRenderer->addCssInlineBlock('tx_wizardcrpages_webfunc_2', '
|
||
#formFieldContainer {float: left;margin: 0 0 10px 0;}
|
||
.clearLeft {clear: left;}
|
||
#formFieldContainer label {width: 70px;display: inline-block;}
|
||
#formFieldContainer input {margin:4px 2px;padding:1px;vertical-align:middle}
|
||
#formFieldContainer span {padding: 0 3px;}
|
||
');
|
||
}
|
||
} else {
|
||
$theCode.=$GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_errorMsg1'));
|
||
... | ... | |
function helpBubble() {
|
||
return '<img src="'.$GLOBALS['BACK_PATH'].'gfx/helpbubble.gif" width="14" height="14" hspace="2" align="top"'.$this->pObj->doc->helpStyle().' alt="" />';
|
||
}
|
||
public function getFormLine($index) {
|
||
$backPath = $GLOBALS['BACK_PATH'];
|
||
if (is_numeric(($index))) {
|
||
$backgroundClass = $index % 2 === 0 ? 'bgColor4' : 'bgColor6';
|
||
$label = $index + 1;
|
||
} else {
|
||
// used as template for ExtJS
|
||
$index = '{0}';
|
||
$backgroundClass = 'bgColor{2}';
|
||
$label = '{1}';
|
||
}
|
||
$content = '<label for="page_new_' . $index . '"> ' . $GLOBALS['LANG']->getLL('wiz_newPages_page') .' '. $label;
|
||
$content .= ': </label>';
|
||
// title
|
||
$content .= '<input type="text" id="page_new_' . $index . '" name="data[pages][NEW' . $index . '][title]"' . $this->pObj->doc->formWidth(35) . ' /> ';
|
||
$content .= '<span>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.php:LGL.type') . '</span>';
|
||
$content .= '<select onchange="this.style.backgroundImage=this.options[this.selectedIndex].style.backgroundImage;if (this.options[this.selectedIndex].value==\'--div--\') {this.selectedIndex=1;}" ';
|
||
$content .= 'class="select icon-select" name="data[pages][NEW' . $index . '][doktype]" style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/pages.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); padding: 1px 1px 1px 24px;">';
|
||
// dokType
|
||
$types = $GLOBALS['PAGES_TYPES'];
|
||
unset($types['default']);
|
||
$types = array_keys($types);
|
||
$types[] = 1;
|
||
if (!$GLOBALS['BE_USER']->isAdmin() && isset($GLOBALS['BE_USER']->groupData['pagetypes_select'])) {
|
||
$types = t3lib_div::trimExplode(',', $GLOBALS['BE_USER']->groupData['pagetypes_select'], TRUE);
|
||
}
|
||
$removeItems = isset($this->pagesTsConfig['doktype.']['removeItems']) ? t3lib_div::trimExplode(',', $this->pagesTsConfig['doktype.']['removeItems'], TRUE) : array();
|
||
$group = '';
|
||
if (in_array(1, $types) && !in_array(1, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/pages.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" selected="selected" value="1">Standard</option>';
|
||
}
|
||
if (in_array(6, $types) && !in_array(6, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'gfx/i/be_users_section.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="6">Backend User Section</option>';
|
||
}
|
||
$content .= $group ? '<optgroup class="c-divider" label="Page">' . $group . '</optgroup>' : '';
|
||
$group = '';
|
||
if (in_array(4, $types) && !in_array(4, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/pages_shortcut.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="4">Shortcut</option>';
|
||
}
|
||
if (in_array(7, $types) && !in_array(7, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'gfx/i/pages_mountpoint.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="7">Mount Point</option>';
|
||
}
|
||
if (in_array(3, $types) && !in_array(3, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/pages_link.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="3">Link to external URL</option>';
|
||
}
|
||
$content .= $group ? '<optgroup class="c-divider" label="Link">' . $group . '</optgroup>' : '';
|
||
$group = '';
|
||
if (in_array(254, $types) && !in_array(254, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/sysf.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="254">SysFolder</option>';
|
||
}
|
||
if (in_array(255, $types) && !in_array(255, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/recycler.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="255">Recycler</option>';
|
||
}
|
||
if (in_array(199, $types) && !in_array(199, $removeItems)) {
|
||
$group .= '<option style="background: url("' . $backPath . 'sysext/t3skin/icons/gfx/i/spacer_icon.gif") no-repeat scroll 0% 50% rgb(255, 255, 255); height: 16px; padding-top: 2px; padding-left: 22px;" value="199">Visual menu separator</option>';
|
||
}
|
||
$content .= $group ? '<optgroup class="c-divider" label="Special">' . $group . '</optgroup>' : '';
|
||
$content .= '</select>';
|
||
$content .= (is_object($this->loremIpsumObject) ?
|
||
'<a href="#" onclick="' . htmlspecialchars($this->loremIpsumObject->getHeaderTitleJS('document.forms[0][\'data[pages][NEW' .
|
||
$index . '][title]\'].value', 'title')) . '">' . $this->loremIpsumObject->getIcon('', $this->pObj->doc->backPath) . '</a>'
|
||
: '');
|
||
return '<div id="form-line-' . $index . '" class="' . $backgroundClass . '">' . $content . '</div>';
|
||
}
|
||
}
|
||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wizard_crpages/class.tx_wizardcrpages_webfunc_2.php']) {
|
typo3/sysext/wizard_crpages/locallang.xml (working copy) | ||
---|---|---|
<label index="wiz_newPages_lReset">Clear fields</label>
|
||
<label index="wiz_newPages_noCreate">No pages were created!</label>
|
||
<label index="wiz_newPages_create">The pages were created!</label>
|
||
<label index="wiz_newPages_addFields">Add fields</label>
|
||
</languageKey>
|
||
</data>
|
||
</T3locallang>
|