AAAAhome/academiac/www/administrator/components/com_csvi/tables/settings.php000060400000001370151452624740022710 0ustar00home/academiac/www/administrator/components/com_csvi/controllers/settings.php000060400000002137151452714230024000 0ustar00getModel('settings'); if ($model->getResetSettings()) { $msg = JText::_('COM_CSVI_SETTINGS_RESET_SUCCESSFULLY'); $msgtype = ''; } else { $msg = JText::_('COM_CSVI_SETTINGS_NOT_RESET_SUCCESSFULLY'); $msgtype = 'error'; } $this->setRedirect('index.php?option=com_csvi&view=settings', $msg, $msgtype); } } ?> home/academiac/www/administrator/components/com_csvi/helpers/settings.php000060400000002312151453013770023071 0ustar00getQuery(true); $query->select('params'); $query->from('#__csvi_settings'); $query->where('id = 1'); $db->setQuery($query); $settings = $db->loadResult(); $registry = new JRegistry(); $registry->loadString($settings); $this->_params = $registry; } /** * Get a requested value * * @param string $setting the setting to get the value for * @param mixed $default the default value if no $setting is found */ public function get($setting, $default=false) { return $this->_params->get($setting, $default); } } ?>home/academiac/www/administrator/components/com_csvi/models/settings.php000060400000010534151453377300022721 0ustar00loadForm($this->context, 'settings', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) return false; return $form; } /** * Method to get the data that should be injected in the form. * * @copyright * @author RolandD * @todo * @see getForm() * @access protected * @param * @return mixed The data for the form * @since 1.0 */ protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_csvi.settings.data', array()); if (empty($data)) { $data = $this->getItem(); } return $data; } /** * Method to get a single record. * * @copyright * @author RolandD * @todo Load the attributes * @see * @access public * @param integer The id of the primary key * @return mixed Object on success | false on failure * @since 1.0 */ public function getItem($pk = null) { if (!$this->_params) { $row = $this->getTable('settings'); $row->load(1); $registry = new JRegistry(); $registry->loadString($row->params); $this->_params = $registry->toArray(); } return $this->_params; } /** * Store the settings * * @copyright * @author RolandD * @todo * @see CsviModelAvailablefields::prepareAvailableFields * @access public * @param * @return bool true on success | false on failure * @since 4.0 */ public function save($data) { $row = $this->getTable('settings'); $registry = new JRegistry(); $registry->loadArray($data); // Set the values $row->id = 1; $row->params = $registry->toString(); if ($row->store()) { $this->_params = $registry; // Add the custom tables to the template tables table $db = JFactory::getDbo(); $tables = $registry->get('tables.tablelist'); $q = "INSERT IGNORE INTO ".$db->quoteName('#__csvi_template_tables')." (".$db->quoteName('template_type_name').", ".$db->quoteName('template_table').", ".$db->quoteName('component').") VALUES "; $fields = array(); foreach ($tables as $table) { $fields[] = "(".$db->quote('customimport').", ".$db->quote($table).", ".$db->quote('com_csvi').")"; $fields[] = "(".$db->quote('customexport').", ".$db->quote($table).", ".$db->quote('com_csvi').")"; } $q .= implode(',', $fields); $db->setQuery($q); $db->query(); return true; } else { $this->setError($row->getError()); return false; } } /** * Get a list of custom tables for import/export * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return array of tables * @since 3.0 */ public function getTableList() { $db = JFactory::getDbo(); $tables = $db->getTableList(); $prefix = $db->getPrefix(); // Remove the table prefix foreach ($tables as $tkey => $table) { if (stristr($table, $prefix)) $tables[$tkey] = str_replace($prefix, '', $table); else unset($tables[$tkey]); } return $tables; } /** * Reset the settings * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return bool true if settings reset | false if settings not reset * @since 3.1.1 */ public function getResetSettings() { $row = $this->getTable('settings'); $row->id = 1; $row->params = ''; return $row->store(); } } ?>