/**
  * Handles the word entry form
  *
  * @param	string	$mode	Either add or edit
  * @return	@e void
  */
 public function handleWordEntryForm($mode = 'add')
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $lang_id = intval($this->request['id']);
     $word_id = intval($this->request['word_id']);
     $LATESTVERSION = IPSLib::fetchVersionNumber();
     //-----------------------------------------
     // Error checking
     //-----------------------------------------
     if (!$this->request['word_pack_db']) {
         $this->registry->output->global_error = $this->lang->words['l_packreq'];
         $this->languageWordEntryForm($mode);
         return;
     }
     if (!$this->request['word_key']) {
         $this->registry->output->global_error = $this->lang->words['l_keyreq'];
         $this->languageWordEntryForm($mode);
         return;
     }
     if (!$this->request['word_default']) {
         $this->registry->output->global_error = $this->lang->words['l_textreq'];
         $this->languageWordEntryForm($mode);
         return;
     }
     $this->request['word_app'] = strtolower($this->request['word_app']);
     $this->request['word_pack_db'] = str_replace('/', '_', strtolower($this->request['word_pack_db']));
     if ($this->request['word_pack_db'] == 'admin_js' or $this->request['word_pack_db'] == 'public_js') {
         $this->request['word_app'] = 'core';
     }
     //-----------------------------------------
     // Build DB insert array
     //-----------------------------------------
     $db_array = array('lang_id' => $lang_id, 'word_app' => $this->request['word_app'], 'word_pack' => $this->request['word_pack_db'], 'word_key' => $this->request['word_key'], 'word_default' => IPSText::formToText($_POST['word_default']));
     //-----------------------------------------
     // Add or update
     //-----------------------------------------
     if ($mode == 'add') {
         /* Check for a duplicate */
         $_check = $this->DB->buildAndFetch(array('select' => 'word_id', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}' AND word_key='{$db_array['word_key']}'"));
         if ($_check['word_id']) {
             $this->registry->output->global_error = $this->lang->words['l_textexistsalready'];
             $this->languageWordEntryForm($mode);
             return;
         }
         $this->DB->insert('core_sys_lang_words', $db_array);
         $text = $this->lang->words['l_added'];
     } else {
         $this->DB->update('core_sys_lang_words', $db_array, "word_id={$word_id}");
         $text = $this->lang->words['l_updated'];
     }
     //-----------------------------------------
     // Recache and redirect
     //-----------------------------------------
     $this->cacheToDisk($lang_id);
     $this->registry->output->redirect("{$this->settings['base_url']}&module=languages&section=manage_languages&do=list_word_packs&id={$lang_id}", $text);
 }
Beispiel #2
0
 protected function _getTemplateContent()
 {
     if (!$this->_template) {
         return false;
     }
     if ($this->_content === null) {
         if ($this->_group != 'css') {
             $template = $this->skinFunctions->fetchTemplateBitForEdit($this->_template['template_id'], $this->_skinSet['set_id']);
             $data = $template['template_data'];
             if (!empty($data)) {
                 $template['_template_content'] = '<ips:template parameters="' . IPSText::formToText($data) . '" />' . "\n" . $template['_template_content'];
             }
             $this->_content = isset($template['_template_content']) ? $template['_template_content'] : false;
         } else {
             $template = $this->skinFunctions->fetchCSSForEdit($this->_template['css_id'], $this->_skinSet['set_id']);
             $this->_content = isset($template['css_content']) ? $template['css_content'] : false;
         }
     }
     return $this->_content;
 }
Beispiel #3
0
 /**
  * Save changes to a custom media tag
  *
  * @param	string [$type='add']
  * @return	@e void
  */
 protected function _mediaTagSave($type = 'add')
 {
     /* INI */
     $errors = array();
     /* Check input */
     if (!$this->request['mediatag_name']) {
         $errors[] = $this->lang->words['m_error_name'];
     }
     if (!$this->request['mediatag_match']) {
         $errors[] = $this->lang->words['m_error_match'];
     }
     if (!$this->request['mediatag_replace']) {
         $errors[] = $this->lang->words['m_error_replace'];
     }
     if (count($errors)) {
         $this->_mediaTagForm($type, $errors);
         return;
     }
     /* Data */
     $data = array('mediatag_name' => $this->request['mediatag_name'], 'mediatag_match' => rtrim(str_replace('&#092;', '\\', str_replace('&#039', "'", trim(IPSText::stripslashes($_POST['mediatag_match'])))), ','), 'mediatag_replace' => IPSText::formToText(rtrim(str_replace('&#092;', '\\', str_replace('&#039', "'", trim(IPSText::stripslashes($_POST['mediatag_replace'])))), ',')));
     /* Check the type */
     if ($type == 'add') {
         /* Insert the record */
         $this->DB->insert('bbcode_mediatag', $data);
         /* Update cache */
         $this->recacheMediaTag();
         /* All done */
         $this->registry->output->global_message = sprintf($this->lang->words['m_tag_added'], $data['mediatag_name']);
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . "&amp;do=overview");
     } else {
         /* ID */
         $id = intval($this->request['id']);
         /* Update */
         $this->DB->update('bbcode_mediatag', $data, "mediatag_id={$id}");
         /* Recache */
         $this->recacheMediaTag();
         /* Done and done */
         $this->registry->output->global_message = sprintf($this->lang->words['m_tag_updated'], $data['mediatag_name']);
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . "&amp;do=overview");
     }
 }
 /**
  * Save template bit after edit
  *
  * @access	public
  * @param	int			Template ID
  * @param	int			Template Set ID
  * @param	string		Template content
  * @param	string		Template function data
  * @return	array 		..of data
  * <code>
  * Exception Codes:
  * NO_SUCH_TEMPLATE:		Could not locate template id#
  * SYNTAX_INCORRECT:		The template bit syntax is incorrect and would cause a parse error if saved
  * </code>
  */
 public function saveTemplateBitFromEdit($templateID, $setID, $template_content, $template_data)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $templateID = intval($templateID);
     $template_content = str_replace('\\"', '\\\\"', $template_content);
     //-----------------------------------------
     // 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];
     //-----------------------------------------
     // Fix up content
     //-----------------------------------------
     $template_content = IPSText::formToText($template_content);
     //-----------------------------------------
     // Fix up data
     //-----------------------------------------
     $template_data = IPSText::formToText($template_data);
     //-----------------------------------------
     // Test it..
     //-----------------------------------------
     if ($this->testTemplateBitSyntax($template['template_name'], $template_data, $template_content) !== TRUE) {
         throw new Exception("SYNTAX_INCORRECT");
     }
     //-----------------------------------------
     // Same template set?
     //-----------------------------------------
     if ($setID == $template['template_set_id']) {
         $this->DB->update('skin_templates', array('template_data' => $template_data, 'template_content' => $template_content, 'template_user_edited' => 1, 'template_updated' => time()), 'template_id=' . $templateID);
         $template_id_new = $templateID;
     } else {
         $this->DB->insert('skin_templates', array('template_set_id' => $setID, 'template_group' => $template['template_group'], 'template_content' => $template_content, 'template_name' => $template['template_name'], 'template_data' => $template_data, 'template_added_to' => $template['template_added_to'], 'template_user_added' => $template['template_user_added'], 'template_user_edited' => 1, 'template_removable' => 1, 'template_updated' => time()));
         $template_id_new = $this->DB->getInsertId();
         # Update count
         $this->_templateCount[$setID][$template['template_group']]['count']++;
     }
     /* If this is a user-added template bit and we're editing it in the same skin, update master */
     if ($template['template_id'] && $template['template_user_added'] && $template['template_added_to'] == $setID) {
         $this->DB->update('skin_templates', array('template_content' => $template_content), "template_set_id=0 AND template_group='" . $template['template_group'] . "' AND template_name='" . $template['template_name'] . "'");
     }
     //-----------------------------------------
     // Recache
     //-----------------------------------------
     $this->rebuildPHPTemplates($setID, $template['template_group']);
     //-----------------------------------------
     // Return
     //-----------------------------------------
     return $template_id_new;
 }
 /**
  * Save diff
  *
  * @return	@e void
  */
 protected function _saveEdit()
 {
     $change_id = trim($this->request['change_id']);
     $content = $_POST['content'];
     /* Re-format */
     $content = str_replace('\\"', '\\\\"', $content);
     $content = IPSText::formToText($content);
     /* Load item from DB */
     $item = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_merge_changes', 'where' => 'change_id=' . intval($change_id)));
     if (!$item) {
         /* Oops */
         $this->returnJsonError($this->lang->words['ajax_nosuchitemid']);
     }
     /* Save to db */
     $this->DB->update('skin_merge_changes', array('change_final_content' => $content), 'change_id=' . intval($change_id));
     /* Done */
     $this->returnJsonArray(array('ok' => true, 'desc' => $this->_buildDescString($item)));
 }