/** * Fetch template bit for editing * * @access public * @param int Template ID * @param int Template Set ID * @return array ..of data * <code> * Exception Codes: * NO_SUCH_TEMPLATE: Could not locate template id# * </code> */ public function fetchTemplateBitForEdit($templateID, $setID) { //----------------------------------------- // INIT //----------------------------------------- $templateID = intval($templateID); //----------------------------------------- // Fetch template data //----------------------------------------- $template = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_templates', 'where' => 'template_id=' . $templateID)); if (!$template['template_id']) { throw new Exception('NO_SUCH_TEMPLATE'); } //----------------------------------------- // Get skin data //----------------------------------------- $skinSetData = $this->registry->output->allSkins[$setID]; //----------------------------------------- // Update data //----------------------------------------- $template['_actualSetID'] = $template['template_set']; $template['_belongsSetID'] = $setID; $template['_template_content'] = $template['template_content']; $template['_template_data'] = $template['template_data']; $template['_isMaster'] = $template['template_master_key'] ? 1 : 0; //----------------------------------------- // Update content for editing //----------------------------------------- $template['template_content'] = IPSText::textToForm($template['template_content']); //----------------------------------------- // Update function data for editing //----------------------------------------- $template['template_data'] = IPSText::textToForm($template['template_data']); //----------------------------------------- // Return it //----------------------------------------- return $template; }
/** * Format Merge: Edit * * @access public * @param string Content from DB * @return string Content suitable for editing in a text area */ public function formatMergeForEdit($text) { /* Re-format mark-up for preview */ preg_match_all("#<ips:conflict id=\"([0-9]+?)\">(.+?)</ips:conflict>#s", $text, $matches); if (is_array($matches[1]) and count($matches[1])) { foreach ($matches[1] as $index => $m) { /* Yeah, I like readable code */ $_all = $matches[0][$index]; $_id = $matches[1][$index]; $_content = $matches[2][$index]; if ($_id != null and $_content) { /* Format old default block */ $_content = preg_replace("#(?:\n)?<ips:cblock type=\"original\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "~~~~~~~~~~ CUSTOM CONTENT\n\\1", $_content); /* Format custom block */ $_content = preg_replace("#(?:\n)?<ips:cblock type=\"new\">(?:\n)?(.+?)(?:\n)?</ips:cblock>#s", "\n===================\n\\1\n^^^^^^^^^^ NEW DEFAULT\n", $_content); $text = str_replace($_all, $_content, $text); } } } /* Encode */ $text = IPSText::textToForm($text); /* Convert special place holders */ $text = str_replace('~~~~~~~~~~', '<<<<<<<<<<', $text); $text = str_replace('^^^^^^^^^^', '>>>>>>>>>>', $text); return $text; }
/** * Show the mediatag add/edit form * * @param string [$type='add'] * @param array [Optional] array of errors * @return @e void */ protected function _mediaTagForm($type = 'add', $errors = array()) { /* Check form type */ if ($type == 'add') { /* Data */ $data = array('mediatag_name' => $this->request['mediatag_name'], 'mediatag_match' => rtrim(str_replace('\', '\\', str_replace(''', "'", trim(IPSText::stripslashes($_POST['mediatag_match'])))), ','), 'mediatag_replace' => rtrim(str_replace('\', '\\', str_replace(''', "'", trim(IPSText::stripslashes($_POST['mediatag_replace'])))), ',')); } else { /* Data */ $id = intval($this->request['id']); $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bbcode_mediatag', 'where' => "mediatag_id={$id}")); /* Set Defaults */ $data['mediatag_name'] = !empty($this->request['mediatag_name']) ? $this->request['mediatag_name'] : $data['mediatag_name']; $data['mediatag_match'] = !empty($this->request['mediatag_match']) ? IPSText::textToForm($this->request['mediatag_match']) : IPSText::textToForm($data['mediatag_match']); $data['mediatag_replace'] = !empty($this->request['mediatag_replace']) ? IPSText::textToForm($this->request['mediatag_replace']) : IPSText::textToForm($data['mediatag_replace']); } /* Setup Form */ $this->registry->output->html .= $this->html->mediaTagForm($type, $data, $errors); }
/** * Process an individual setting for display * * @param array Setting record * @return @e void */ public function _processSettingEntry($r) { /* Init editor class */ if (!is_object($this->editor)) { $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite'); $this->editor = new $classToLoad(); } /* Init vars */ $tempSkinUrl = $this->settings['skin_app_url']; $this->settings['skin_app_url'] = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/applications/core/skin_cp/'; $form_element = ""; $form_type = 'normal'; $dropdown = array(); $start = ""; $revert_button = ""; $key = $r['conf_key']; $value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default']; $value = $value == "{blank}" ? '' : $value; $show = 1; //----------------------------------------------- // Default? //----------------------------------------------- $css = ""; if ($r['conf_value'] != "" and $r['conf_value'] != $r['conf_default']) { $revert_button = "<li class='i_revert'><a href='" . $this->settings['_base_url'] . "&app=core&{$this->form_code}&do=setting_revert&id={$r['conf_id']}&conf_group={$r['conf_group']}&search=" . $this->request['search'] . "' title='{$this->lang->words['s_revertback']}'>{$this->lang->words['revert']}</a></li>"; } //----------------------------------------------- // Evil eval //----------------------------------------------- if ($r['conf_evalphp']) { $r['conf_evalphp'] = str_replace('\', '\\', $r['conf_evalphp']); $show = 1; eval($r['conf_evalphp']); } if (!$show && !IN_DEV) { return ''; } switch ($r['conf_type']) { case 'input': $form_element = $this->registry->output->formInput($key, str_replace("'", "'", $value)); break; case 'textarea': $form_element = $this->registry->output->formTextarea($key, str_replace("&#092;", "\", IPSText::textToForm($value)), 45); break; case 'editor': //$this->editor->setIsHtml( true ); $this->editor->setContent($value); $form_element = $this->editor->show($key, array('minimize' => 1)); $form_type = 'rte'; break; case 'yes_no': $form_element = $this->registry->output->formYesNo($key, $value); break; case 'name_autocomplete': $form_element = $this->html->nameAutoCompleteField($key, $value); break; default: if ($r['conf_extra']) { if ($r['conf_extra'] == '#show_forums#') { //----------------------------------------- // Require the library // (Not a building with books) //----------------------------------------- require_once IPSLib::getAppDir('forums') . '/sources/classes/forums/class_forums.php'; /*noLibHook*/ $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/forums/admin_forum_functions.php', 'admin_forum_functions', 'forums'); $aff = new $classToLoad($this->registry); $aff->forumsInit(); $dropdown = $aff->adForumsForumList(1); } else { if ($r['conf_extra'] == '#show_groups#') { $this->DB->build(array('select' => '*', 'from' => 'groups', 'order' => 'g_title ASC')); $this->DB->execute(); while ($row = $this->DB->fetch()) { if ($row['g_access_cp']) { $row['g_title'] .= ' ' . $this->lang->words['setting_staff_tag'] . ' '; } $dropdown[] = array($row['g_id'], $row['g_title']); } } else { if ($r['conf_extra'] == '#show_applications#') { foreach (ipsRegistry::$applications as $app) { $dropdown[] = array($app['app_directory'], $app['app_title']); } } else { if ($r['conf_extra'] == '#show_skins#') { $dropdown = $this->registry->output->generateSkinDropdown(); } else { foreach (explode("\n", $r['conf_extra']) as $l) { list($k, $v) = explode("=", $l); if ($k != "" and $v != "") { $dropdown[] = array(trim($k), trim($v)); } } } } } } } if ($r['conf_type'] == 'dropdown') { $form_element = $this->registry->output->formDropdown($key, $dropdown, $value); } else { $form_element = $this->registry->output->formMultiDropdown($key, $dropdown, explode(",", $value)); } break; } $delete = "<li class='i_delete'><a href='#' onclick='return acp.confirmDelete(\"{$this->settings['_base_url']}&app=core&{$this->form_code}&do=setting_delete&id={$r['conf_id']}\");' title='key: {$r['conf_key']}'>{$this->lang->words['delete']}</a></li>"; $edit = "<li class='i_edit'><a href='" . $this->settings['_base_url'] . "&app=core&{$this->form_code}&do=setting_showedit&id={$r['conf_id']}' title='id: {$r['conf_id']}'>{$this->lang->words['edit']}</a></li>"; if ($r['conf_protected'] and !IN_DEV) { $delete = ""; $edit = ""; } if ($r['conf_start_group']) { $start = $this->html->settings_row_start_group($r); } $r['conf_description'] = str_replace('{ACP_URL}', $this->settings['_base_url'], $r['conf_description']); //----------------------------------------------- // Search hi-lite //----------------------------------------------- if ($this->request['search']) { $_replacements = array(); preg_match_all("/(&([a-zA-Z0-9]+);)/i", $r['conf_title'], $matches); if (count($matches[0])) { for ($i = 0, $cnt = count($matches[0]); $i <= $cnt; $i++) { $r['conf_title'] = str_replace($matches[0][$i], '{{{' . $i . '}}}', $r['conf_title']); } } $r['conf_title'] = preg_replace("/(" . str_replace('/', '\\/', $this->request['search']) . ")/i", "<span style='background:#FCFDD7'>\\1</span>", $r['conf_title']); if (count($matches[0])) { for ($i = 0, $cnt = count($matches); $i <= $cnt; $i++) { $r['conf_title'] = str_replace('{{{' . $i . '}}}', $matches[0][$i], $r['conf_title']); } } /** * Ok this is just annoying.... */ $_did = 0; preg_match_all("/(href=['\"].*?[\"'])/i", $r['conf_description'], $matches); if (count($matches[0])) { for ($i = $_did, $cnt = count($matches[0]); $i <= $cnt; $i++) { $r['conf_description'] = str_replace($matches[0][$i], '{{{' . $i . '}}}', $r['conf_description']); $_replacements[$i] = $matches[0][$i]; $_did++; } } preg_match_all("/(&([a-zA-Z0-9]+);)/i", $r['conf_description'], $matches); if (count($matches[0])) { for ($i = $_did, $cnt = count($matches[0]); $i <= $cnt; $i++) { $r['conf_description'] = str_replace($matches[0][$i], '{{{' . $i . '}}}', $r['conf_description']); $_replacements[$i] = $matches[0][$i]; $_did++; } } $r['conf_description'] = preg_replace("/(" . str_replace('/', '\\/', $this->request['search']) . ")/i", "<span style='background:#FCFDD7'>\\1</span>", $r['conf_description']); if (count($_replacements)) { foreach ($_replacements as $index => $val) { $r['conf_description'] = str_replace('{{{' . $index . '}}}', $val, $r['conf_description']); } } } $html .= $start . $this->html->settings_view_row($r, $edit, $delete, $form_element, $revert_button, $form_type); $this->key_array[] = preg_replace('/\\[\\]$/', "", $key); $this->settings['skin_app_url'] = $tempSkinUrl; return $html; }