/** * Fieldtypes Manager */ function fieldtypes_manager($standalone = TRUE, $SD = NULL) { global $DB, $DSP, $LANG, $IN, $PREFS, $SD; if (!$SD) { // initialize Fieldframe_SettingsDisplay $SD = new Fieldframe_SettingsDisplay(); } if ($standalone) { // save submitted settings if ($this->save_fieldtypes_manager()) { $DSP->body .= $DSP->qdiv('box', $DSP->qdiv('success', $LANG->line('settings_update'))); } // load language file $LANG->fetch_language_file('fieldframe'); // Breadcrumbs $DSP->crumbline = TRUE; $DSP->title = $LANG->line('fieldtypes_manager'); $DSP->crumb = $DSP->anchor(BASE . AMP . 'C=admin' . AMP . 'area=utilities', $LANG->line('utilities')) . $DSP->crumb_item($LANG->line('fieldtypes_manager')); // open form $DSP->body .= $DSP->form_open(array('action' => 'C=admin' . AMP . 'M=utilities' . AMP . 'P=fieldtypes_manager', 'name' => 'settings_subtext', 'id' => 'ffsettings'), array('name' => strtolower(FF_CLASS))); } // fieldtype settings $DSP->body .= $SD->block('fieldtypes_manager', 5); // initialize fieldtypes if ($ftypes = $this->_get_all_installed_ftypes()) { // add the headers $DSP->body .= $SD->heading_row(array($LANG->line('fieldtype'), $LANG->line('fieldtype_enabled'), $LANG->line('settings'), $LANG->line('documentation'))); $row_ids = array(); foreach ($ftypes as $class_name => $ftype) { $row_id = 'ft_' . $ftype->_class_name; $row_ids[] = '"' . $row_id . '"'; if (method_exists($ftype, 'display_site_settings')) { if (!$ftype->info['no_lang']) { $LANG->fetch_language_file($class_name); } $site_settings = $ftype->display_site_settings(); } else { $site_settings = FALSE; } $DSP->body .= $SD->row(array($SD->label($ftype->info['name'] . NBS . $DSP->qspan('xhtmlWrapperLight defaultSmall', $ftype->info['version']), $ftype->info['desc']), $ftype->_requires ? '--' : $SD->radio_group('ftypes[' . $class_name . '][enabled]', $ftype->_is_enabled ? 'y' : 'n', array('y' => 'yes', 'n' => 'no')), $site_settings ? '<a class="toggle show" id="' . $row_id . '_show"><img src="' . $PREFS->ini('theme_folder_url', 1) . 'cp_global_images/expand.gif" border="0"> ' . $LANG->line('show') . '</a>' . '<a class="toggle hide" id="' . $row_id . '_hide"><img src="' . $PREFS->ini('theme_folder_url', 1) . 'cp_global_images/collapse.gif" border="0"> ' . $LANG->line('hide') . '</a>' : '--', $ftype->info['docs_url'] ? '<a href="' . stripslashes($ftype->info['docs_url']) . '">' . $LANG->line('documentation') . '</a>' : '--'), NULL, array('id' => $row_id)); if ($ftype->_requires) { $data = '<p>' . $ftype->info['name'] . ' ' . $LANG->line('requires') . ':</p>' . '<ul>'; foreach ($ftype->_requires as $dependency => $version) { $data .= '<li class="default">' . $dependency . ' ' . $version . ' ' . $LANG->line('or_later') . '</li>'; } $data .= '</ul>'; $DSP->body .= $SD->row(array('', $data), $SD->row_class); } else { if ($site_settings) { $data = '<div class="ftsettings">' . $this->_group_ftype_inputs($ftype->_class_name, $site_settings) . $DSP->div_c(); $DSP->body .= $SD->row(array($data), '', array('id' => $row_id . '_settings', 'style' => 'display:none;')); } } } $js = '<script type="text/javascript" charset="utf-8">' . NL . ' function ffEnable(ft) {' . NL . ' ft.show.className = "toggle show";' . NL . ' ft.show.onclick = function() {' . NL . ' ft.show.style.display = "none";' . NL . ' ft.hide.style.display = "block";' . NL . ' ft.settings.style.display = "table-row";' . NL . ' };' . NL . ' ft.hide.onclick = function() {' . NL . ' ft.show.style.display = "block";' . NL . ' ft.hide.style.display = "none";' . NL . ' ft.settings.style.display = "none";' . NL . ' };' . NL . ' }' . NL . ' function ffDisable(ft) {' . NL . ' ft.show.className = "toggle show disabled";' . NL . ' ft.show.onclick = null;' . NL . ' ft.show.style.display = "block";' . NL . ' ft.hide.style.display = "none";' . NL . ' ft.settings.style.display = "none";' . NL . ' }' . NL . ' function ffInitRow(rowId) {' . NL . ' var ft = {' . NL . ' tr: document.getElementById(rowId),' . NL . ' show: document.getElementById(rowId+"_show"),' . NL . ' hide: document.getElementById(rowId+"_hide"),' . NL . ' settings: document.getElementById(rowId+"_settings")' . NL . ' };' . NL . ' if (ft.settings) {' . NL . ' ft.toggles = ft.tr.getElementsByTagName("input");' . NL . ' ft.toggles[0].onchange = function() { ffEnable(ft); };' . NL . ' ft.toggles[1].onchange = function() { ffDisable(ft); };' . NL . ' if (ft.toggles[0].checked) ffEnable(ft);' . NL . ' else ffDisable(ft);' . NL . ' }' . NL . ' }' . NL . ' var ffRowIds = [' . implode(',', $row_ids) . '];' . NL . ' for (var i = 0; i < ffRowIds.length; i++) {' . NL . ' ffInitRow(ffRowIds[i]);' . NL . ' }' . NL . '</script>'; $this->snippets['body'][] = $js; } else { if (!defined('FT_PATH')) { $DSP->body .= $SD->info_row('no_fieldtypes_path'); } else { if (in_array('bad_ft_path', $this->errors)) { $DSP->body .= $SD->info_row('bad_fieldtypes_path'); } else { $DSP->body .= $SD->info_row('no_fieldtypes'); } } } $DSP->body .= $SD->block_c(); if ($standalone) { // Close form $DSP->body .= $DSP->qdiv('itemWrapperTop', $DSP->input_submit($LANG->line('apply'))) . $DSP->form_c(); } // CSS $css = '<style type="text/css" charset="utf-8">' . NL . ' #ffsettings a.toggle { display:block; cursor:pointer; }' . NL . ' #ffsettings a.toggle.hide { display:none; }' . NL . ' #ffsettings a.toggle.disabled { color:#000; opacity:0.4; cursor:default; }' . ' #ffsettings .ftsettings { margin:-3px -1px -1px; }' . ' #ffsettings .ftsettings, #ffsettings .ftsettings * { background:#262e33; color:#999; }' . NL . ' #ffsettings .ftsettings input.input, #ffsettings .ftsettings textarea { background:#fff; color:#333; }' . NL . ' #ffsettings .ftsettings table { border:none; }' . NL . ' #ffsettings .ftsettings table tr td { border-top:1px solid #1d2326; padding-left:8px; padding-right:8px; }' . ' #ffsettings .ftsettings table tr td.tableHeading { color:#ddd; background:#232a2e; }' . NL . ' #ffsettings .ftsettings .defaultBold { color:#ccc; }' . NL . ' #ffsettings .ftsettings .box { border-color:transparent; }' . NL . ' #ffsettings .ftsettings .tableCellOne, #ffsettings .ftsettings .tableCellOneBold, #ffsettings .ftsettings .tableCellTwo, #ffsettings .ftsettings .tableCellTwoBold { border-bottom:none; }' . NL . '</style>'; $this->snippets['head'][] = $css; }