diff --git a/oss/joomla/trunk/administrator/components/com_config/admin.config.php b/oss/joomla/trunk/administrator/components/com_config/admin.config.php new file mode 100644 index 00000000..8b5950ac --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/admin.config.php @@ -0,0 +1,45 @@ +authorize( 'com_config', 'manage' )) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +// Require specific controller if requested +if($controller = JRequest::getWord('controller', 'application')) { + $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; + if (file_exists($path)) { + require_once $path; + } else { + $controller = ''; + } +} + +// Create the controller +$classname = 'ConfigController'.ucfirst($controller); +$controller = new $classname( ); + +JResponse::setHeader( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true ); + +// Perform the Request task +$controller->execute( JRequest::getCmd( 'task' ) ); +$controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/config.xml b/oss/joomla/trunk/administrator/components/com_config/config.xml new file mode 100644 index 00000000..5371d229 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/config.xml @@ -0,0 +1,12 @@ + + + Configuration Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Configuration Manager + diff --git a/oss/joomla/trunk/administrator/components/com_config/controller.php b/oss/joomla/trunk/administrator/components/com_config/controller.php new file mode 100644 index 00000000..fb7e5f90 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/controller.php @@ -0,0 +1,29 @@ +registerTask( 'apply', 'save' ); + } + + /** + * Show the configuration edit form + * @param string The URL option + */ + function showConfig() + { + // Initialize some variables + $db =& JFactory::getDBO(); + $row = new JConfig(); + + // compile list of the languages + $langs = array (); + $menuitems = array (); + $lists = array (); + + // PRE-PROCESS SOME LIST + + // -- Editors -- + + // compile list of the editors + $query = 'SELECT element AS value, name AS text' + .' FROM #__plugins' + .' WHERE folder = "editors"' + .' AND published = 1' + .' ORDER BY ordering, name' + ; + $db->setQuery($query); + $edits = $db->loadObjectList(); + + // -- Show/Hide -- + + $show_hide = array (JHTML::_('select.option', 1, JText::_('Hide')), JHTML::_('select.option', 0, JText::_('Show')),); + + $show_hide_r = array (JHTML::_('select.option', 0, JText::_('Hide')), JHTML::_('select.option', 1, JText::_('Show')),); + + // -- menu items -- + + $query = 'SELECT id AS value, name AS text FROM #__menu' + .' WHERE ( type="content_section" OR type="components" OR type="content_typed" )' + .' AND published = 1' + .' AND access = 0' + .' ORDER BY name' + ; + $db->setQuery($query); + $menuitems = array_merge($menuitems, $db->loadObjectList()); + + // SITE SETTINGS + $lists['offline'] = JHTML::_('select.booleanlist', 'offline', 'class="inputbox"', $row->offline); + if (!$row->editor) { + $row->editor = ''; + } + // build the html select list + $lists['editor'] = JHTML::_('select.genericlist', $edits, 'editor', 'class="inputbox" size="1"', 'value', 'text', $row->editor); + $listLimit = array (JHTML::_('select.option', 5, 5), JHTML::_('select.option', 10, 10), JHTML::_('select.option', 15, 15), JHTML::_('select.option', 20, 20), JHTML::_('select.option', 25, 25), JHTML::_('select.option', 30, 30), JHTML::_('select.option', 50, 50), JHTML::_('select.option', 100, 100),); + $lists['list_limit'] = JHTML::_('select.genericlist', $listLimit, 'list_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->list_limit ? $row->list_limit : 50)); + + jimport('joomla.language.help'); + $helpsites = array (); + $helpsites = JHelp::createSiteList(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $row->helpurl); + array_unshift($helpsites, JHTML::_('select.option', '', JText::_('local'))); + $lists['helpsites'] = JHTML::_('select.genericlist', $helpsites, 'helpurl', ' class="inputbox"', 'value', 'text', $row->helpurl); + + // DEBUG + $lists['debug'] = JHTML::_('select.booleanlist', 'debug', 'class="inputbox"', $row->debug); + $lists['debug_lang'] = JHTML::_('select.booleanlist', 'debug_lang', 'class="inputbox"', $row->debug_lang); + + // DATABASE SETTINGS + + // SERVER SETTINGS + $lists['gzip'] = JHTML::_('select.booleanlist', 'gzip', 'class="inputbox"', $row->gzip); + $errors = array (JHTML::_('select.option', -1, JText::_('System Default')), JHTML::_('select.option', 0, JText::_('None')), JHTML::_('select.option', E_ERROR | E_WARNING | E_PARSE, JText::_('Simple')), JHTML::_('select.option', E_ALL, JText::_('Maximum'))); + $lists['xmlrpc_server'] = JHTML::_('select.booleanlist', 'xmlrpc_server', 'class="inputbox"', $row->xmlrpc_server); + $lists['error_reporting'] = JHTML::_('select.genericlist', $errors, 'error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->error_reporting); + $lists['enable_ftp'] = JHTML::_('select.booleanlist', 'ftp_enable', 'class="inputbox"', intval($row->ftp_enable)); + + $forceSSL = array( + JHTML::_('select.option', 0, JText::_('None')), + JHTML::_('select.option', 1, JText::_('Administrator Only')), + JHTML::_('select.option', 2, JText::_('Entire Site')), + ); + $lists['force_ssl'] = JHTML::_('select.genericlist', $forceSSL, 'force_ssl', 'class="inputbox" size="1"', 'value', 'text', @$row->force_ssl); + + // LOCALE SETTINGS + $timeoffset = array ( + JHTML::_('select.option', -12, JText::_('(UTC -12:00) International Date Line West')), + JHTML::_('select.option', -11, JText::_('(UTC -11:00) Midway Island, Samoa')), + JHTML::_('select.option', -10, JText::_('(UTC -10:00) Hawaii')), + JHTML::_('select.option', -9.5, JText::_('(UTC -09:30) Taiohae, Marquesas Islands')), + JHTML::_('select.option', -9, JText::_('(UTC -09:00) Alaska')), + JHTML::_('select.option', -8, JText::_('(UTC -08:00) Pacific Time (US & Canada)')), + JHTML::_('select.option', -7, JText::_('(UTC -07:00) Mountain Time (US & Canada)')), + JHTML::_('select.option', -6, JText::_('(UTC -06:00) Central Time (US & Canada), Mexico City')), + JHTML::_('select.option', -5, JText::_('(UTC -05:00) Eastern Time (US & Canada), Bogota, Lima')), + JHTML::_('select.option', -4.5, JText::_('(UTC -04:30) Venezuela')), + JHTML::_('select.option', -4, JText::_('(UTC -04:00) Atlantic Time (Canada), Caracas, La Paz')), + JHTML::_('select.option', -3.5, JText::_('(UTC -03:30) St. John\'s, Newfoundland, Labrador')), + JHTML::_('select.option', -3, JText::_('(UTC -03:00) Brazil, Buenos Aires, Georgetown')), + JHTML::_('select.option', -2, JText::_('(UTC -02:00) Mid-Atlantic')), + JHTML::_('select.option', -1, JText::_('(UTC -01:00) Azores, Cape Verde Islands')), + JHTML::_('select.option', 0, JText::_('(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca')), + JHTML::_('select.option', 1, JText::_('(UTC +01:00) Amsterdam, Berlin, Brussels, Copenhagen, Madrid, Paris')), + JHTML::_('select.option', 2, JText::_('(UTC +02:00) Istanbul, Jerusalem, Kaliningrad, South Africa')), + JHTML::_('select.option', 3, JText::_('(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg')), + JHTML::_('select.option', 3.5, JText::_('(UTC +03:30) Tehran')), + JHTML::_('select.option', 4, JText::_('(UTC +04:00) Abu Dhabi, Muscat, Baku, Tbilisi')), + JHTML::_('select.option', 4.5, JText::_('(UTC +04:30) Kabul')), + JHTML::_('select.option', 5, JText::_('(UTC +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent')), + JHTML::_('select.option', 5.5, JText::_('(UTC +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo')), + JHTML::_('select.option', 5.75, JText::_('(UTC +05:45) Kathmandu')), + JHTML::_('select.option', 6, JText::_('(UTC +06:00) Almaty, Dhaka')), + JHTML::_('select.option', 6.30, JText::_('(UTC +06:30) Yagoon')), + JHTML::_('select.option', 7, JText::_('(UTC +07:00) Bangkok, Hanoi, Jakarta')), + JHTML::_('select.option', 8, JText::_('(UTC +08:00) Beijing, Perth, Singapore, Hong Kong')), + JHTML::_('select.option', 8.75, JText::_('(UTC +08:00) Western Australia')), + JHTML::_('select.option', 9, JText::_('(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk')), + JHTML::_('select.option', 9.5, JText::_('(UTC +09:30) Adelaide, Darwin, Yakutsk')), + JHTML::_('select.option', 10, JText::_('(UTC +10:00) Eastern Australia, Guam, Vladivostok')), + JHTML::_('select.option', 10.5, JText::_('(UTC +10:30) Lord Howe Island (Australia)')), + JHTML::_('select.option', 11, JText::_('(UTC +11:00) Magadan, Solomon Islands, New Caledonia')), + JHTML::_('select.option', 11.30, JText::_('(UTC +11:30) Norfolk Island')), + JHTML::_('select.option', 12, JText::_('(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka')), + JHTML::_('select.option', 12.75, JText::_('(UTC +12:45) Chatham Island')), + JHTML::_('select.option', 13, JText::_('(UTC +13:00) Tonga')), + JHTML::_('select.option', 14, JText::_('(UTC +14:00) Kiribati')),); + $lists['offset'] = JHTML::_('select.genericlist', $timeoffset, 'offset', 'class="inputbox" size="1"', 'value', 'text', $row->offset); + + // MAIL SETTINGS + $mailer = array ( + JHTML::_('select.option', 'mail', JText::_('PHP mail function')), + JHTML::_('select.option', 'sendmail', JText::_('Sendmail')), + JHTML::_('select.option', 'smtp', JText::_('SMTP Server'))); + $lists['mailer'] = JHTML::_('select.genericlist', $mailer, 'mailer', 'class="inputbox" size="1"', 'value', 'text', $row->mailer); + $smtpsecure = array ( + JHTML::_('select.option', 'none', JText::_('None')), + JHTML::_('select.option', 'ssl', 'SSL'), + JHTML::_('select.option', 'tls', 'TLS')); + $lists['smtpsecure'] = JHTML::_('select.genericlist', $smtpsecure, 'smtpsecure', 'class="inputbox" size="1"', 'value', 'text', (isset($row->smtpsecure) ? $row->smtpsecure : '')); + $lists['smtpauth'] = JHTML::_('select.booleanlist', 'smtpauth', 'class="inputbox"', $row->smtpauth); + + // CACHE SETTINGS + $lists['caching'] = JHTML::_('select.booleanlist', 'caching', 'class="inputbox"', $row->caching); + jimport('joomla.cache.cache'); + $stores = JCache::getStores(); + $options = array(); + foreach($stores as $store) { + $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) ); + } + $lists['cache_handlers'] = JHTML::_('select.genericlist', $options, 'cache_handler', 'class="inputbox" size="1"', 'value', 'text', $row->cache_handler); + + // MEMCACHE SETTINGS + if (!empty($row->memcache_settings) && !is_array($row->memcache_settings)) { + $row->memcache_settings = unserialize(stripslashes($row->memcache_settings)); + } + $lists['memcache_persist'] = JHTML::_('select.booleanlist', 'memcache_settings[persistent]', 'class="inputbox"', @$row->memcache_settings['persistent']); + $lists['memcache_compress'] = JHTML::_('select.booleanlist', 'memcache_settings[compression]', 'class="inputbox"', @$row->memcache_settings['compression']); + + // META SETTINGS + $lists['MetaAuthor'] = JHTML::_('select.booleanlist', 'MetaAuthor', 'class="inputbox"', $row->MetaAuthor); + $lists['MetaTitle'] = JHTML::_('select.booleanlist', 'MetaTitle', 'class="inputbox"', $row->MetaTitle); + + // SEO SETTINGS + $lists['sef'] = JHTML::_('select.booleanlist', 'sef', 'class="inputbox"', $row->sef); + $lists['sef_rewrite'] = JHTML::_('select.booleanlist', 'sef_rewrite', 'class="inputbox"', $row->sef_rewrite); + $lists['sef_suffix'] = JHTML::_('select.booleanlist', 'sef_suffix', 'class="inputbox"', $row->sef_suffix); + + // FEED SETTINGS + $formats = array (JHTML::_('select.option', 'RSS2.0', JText::_('RSS')), JHTML::_('select.option', 'Atom', JText::_('Atom'))); + $summary = array (JHTML::_('select.option', 1, JText::_('Full Text')), JHTML::_('select.option', 0, JText::_('Intro Text')),); + $lists['feed_limit'] = JHTML::_('select.genericlist', $listLimit, 'feed_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->feed_limit ? $row->feed_limit : 10)); + $emailOptions = array ( JHTML::_('select.option', 'author', JText::_('Author Email')), + JHTML::_('select.option', 'site', JText::_('Site Email'))); + $lists['feed_email'] = JHTML::_('select.genericlist', $emailOptions, 'feed_email', 'class="inputbox" size="1"', 'value', 'text', (@$row->feed_email) ? $row->feed_email : 'author'); + + // SESSION SETTINGS + $stores = JSession::getStores(); + $options = array(); + foreach($stores as $store) { + $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) ); + } + $lists['session_handlers'] = JHTML::_('select.genericlist', $options, 'session_handler', 'class="inputbox" size="1"', 'value', 'text', $row->session_handler); + + // SHOW EDIT FORM + ConfigApplicationView::showConfig($row, $lists); + } + + /** + * Save the configuration + */ + function save() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + //Save user and media manager settings + $table =& JTable::getInstance('component'); + + $userpost['params'] = JRequest::getVar('userparams', array(), 'post', 'array'); + $userpost['option'] = 'com_users'; + $table->loadByOption( 'com_users' ); + $table->bind( $userpost ); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + $mediapost['params'] = JRequest::getVar('mediaparams', array(), 'post', 'array'); + $mediapost['option'] = 'com_media'; + //Sanitize $file_path and $image_path + $file_path = $mediapost['params']['file_path']; + $image_path = $mediapost['params']['image_path']; + if(strpos($file_path, '/') === 0 || strpos($file_path, '\\') === 0) { + //Leading slash. Kill it and default to /media + $file_path = 'images'; + } + if(strpos($image_path, '/') === 0 || strpos($image_path, '\\') === 0) { + //Leading slash. Kill it and default to /media + $image_path = 'images/stories'; + } + if(strpos($file_path, '..') !== false) { + //downward directories. Kill it and default to images/ + $file_path = 'images'; + } + if(strpos($image_path, '..') !== false) { + //downward directories Kill it and default to images/stories + $image_path = 'images/stories'; + } + $mediapost['params']['file_path'] = $file_path; + $mediapost['params']['image_path'] = $image_path; + + $table->loadByOption( 'com_media' ); + $table->bind( $mediapost ); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + $config = new JRegistry('config'); + $config_array = array(); + + // SITE SETTINGS + $config_array['offline'] = JRequest::getVar('offline', 0, 'post', 'int'); + $config_array['editor'] = JRequest::getVar('editor', 'tinymce', 'post', 'cmd'); + $config_array['list_limit'] = JRequest::getVar('list_limit', 20, 'post', 'int'); + $config_array['helpurl'] = JRequest::getVar('helpurl', 'http://help.joomla.org', 'post', 'string'); + + // DEBUG + $config_array['debug'] = JRequest::getVar('debug', 0, 'post', 'int'); + $config_array['debug_lang'] = JRequest::getVar('debug_lang', 0, 'post', 'int'); + + // SEO SETTINGS + $config_array['sef'] = JRequest::getVar('sef', 0, 'post', 'int'); + $config_array['sef_rewrite'] = JRequest::getVar('sef_rewrite', 0, 'post', 'int'); + $config_array['sef_suffix'] = JRequest::getVar('sef_suffix', 0, 'post', 'int'); + + // FEED SETTINGS + $config_array['feed_limit'] = JRequest::getVar('feed_limit', 10, 'post', 'int'); + $config_array['feed_email'] = JRequest::getVar('feed_email', 'author', 'post', 'word'); + + // SERVER SETTINGS + $config_array['secret'] = JRequest::getVar('secret', 0, 'post', 'string'); + $config_array['gzip'] = JRequest::getVar('gzip', 0, 'post', 'int'); + $config_array['error_reporting'] = JRequest::getVar('error_reporting', -1, 'post', 'int'); + $config_array['xmlrpc_server'] = JRequest::getVar('xmlrpc_server', 0, 'post', 'int'); + $config_array['log_path'] = JRequest::getVar('log_path', JPATH_ROOT.DS.'logs', 'post', 'string'); + $config_array['tmp_path'] = JRequest::getVar('tmp_path', JPATH_ROOT.DS.'tmp', 'post', 'string'); + $config_array['live_site'] = rtrim(JRequest::getVar('live_site','','post','string'), '/\\'); + $config_array['force_ssl'] = JRequest::getVar('force_ssl', 0, 'post', 'int'); + + // LOCALE SETTINGS + $config_array['offset'] = JRequest::getVar('offset', 0, 'post', 'float'); + + // CACHE SETTINGS + $config_array['caching'] = JRequest::getVar('caching', 0, 'post', 'int'); + $config_array['cachetime'] = JRequest::getVar('cachetime', 900, 'post', 'int'); + $config_array['cache_handler'] = JRequest::getVar('cache_handler', 'file', 'post', 'word'); + $config_array['memcache_settings'] = JRequest::getVar('memcache_settings', array(), 'post'); + + // FTP SETTINGS + $config_array['ftp_enable'] = JRequest::getVar('ftp_enable', 0, 'post', 'int'); + $config_array['ftp_host'] = JRequest::getVar('ftp_host', '', 'post', 'string'); + $config_array['ftp_port'] = JRequest::getVar('ftp_port', '', 'post', 'int'); + $config_array['ftp_user'] = JRequest::getVar('ftp_user', '', 'post', 'string'); + $config_array['ftp_pass'] = JRequest::getVar('ftp_pass', '', 'post', 'string', JREQUEST_ALLOWRAW); + $config_array['ftp_root'] = JRequest::getVar('ftp_root', '', 'post', 'string'); + + // DATABASE SETTINGS + $config_array['dbtype'] = JRequest::getVar('dbtype', 'mysql', 'post', 'word'); + $config_array['host'] = JRequest::getVar('host', 'localhost', 'post', 'string'); + $config_array['user'] = JRequest::getVar('user', '', 'post', 'string'); + $config_array['db'] = JRequest::getVar('db', '', 'post', 'string'); + $config_array['dbprefix'] = JRequest::getVar('dbprefix', 'jos_', 'post', 'string'); + + // MAIL SETTINGS + $config_array['mailer'] = JRequest::getVar('mailer', 'mail', 'post', 'word'); + $config_array['mailfrom'] = JRequest::getVar('mailfrom', '', 'post', 'string'); + $config_array['fromname'] = JRequest::getVar('fromname', 'Joomla 1.5', 'post', 'string'); + $config_array['sendmail'] = JRequest::getVar('sendmail', '/usr/sbin/sendmail', 'post', 'string'); + $config_array['smtpauth'] = JRequest::getVar('smtpauth', 0, 'post', 'int'); + $config_array['smtpsecure'] = JRequest::getVar('smtpsecure', 'none', 'post', 'word'); + $smtpport = JRequest::getVar('smtpport', '', 'post', 'int'); + $config_array['smtpport'] = $smtpport ? $smtpport : '25'; + $config_array['smtpuser'] = JRequest::getVar('smtpuser', '', 'post', 'string'); + $config_array['smtppass'] = JRequest::getVar('smtppass', '', 'post', 'string', JREQUEST_ALLOWRAW); + $config_array['smtphost'] = JRequest::getVar('smtphost', '', 'post', 'string'); + + // META SETTINGS + $config_array['MetaAuthor'] = JRequest::getVar('MetaAuthor', 1, 'post', 'int'); + $config_array['MetaTitle'] = JRequest::getVar('MetaTitle', 1, 'post', 'int'); + + // SESSION SETTINGS + $config_array['lifetime'] = JRequest::getVar('lifetime', 0, 'post', 'int'); + $config_array['session_handler'] = JRequest::getVar('session_handler', 'none', 'post', 'word'); + + //LANGUAGE SETTINGS + //$config_array['lang'] = JRequest::getVar('lang', 'none', 'english', 'cmd'); + //$config_array['language'] = JRequest::getVar('language', 'en-GB', 'post', 'cmd'); + + $config->loadArray($config_array); + + //override any possible database password change + $config->setValue('config.password', $mainframe->getCfg('password')); + + // handling of special characters + $sitename = htmlspecialchars( JRequest::getVar( 'sitename', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); + $config->setValue('config.sitename', $sitename); + + $MetaDesc = htmlspecialchars( JRequest::getVar( 'MetaDesc', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); + $config->setValue('config.MetaDesc', $MetaDesc); + + $MetaKeys = htmlspecialchars( JRequest::getVar( 'MetaKeys', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); + $config->setValue('config.MetaKeys', $MetaKeys); + + // handling of quotes (double and single) and amp characters + // htmlspecialchars not used to preserve ability to insert other html characters + $offline_message = JRequest::getVar( 'offline_message', '', 'post', 'string' ); + $offline_message = JFilterOutput::ampReplace( $offline_message ); + $offline_message = str_replace( '"', '"', $offline_message ); + $offline_message = str_replace( "'", ''', $offline_message ); + $config->setValue('config.offline_message', $offline_message); + + //purge the database session table (only if we are changing to a db session store) + if($mainframe->getCfg('session_handler') != 'database' && $config->getValue('session_handler') == 'database') + { + $table =& JTable::getInstance('session'); + $table->purge(-1); + } + + // Get the path of the configuration file + $fname = JPATH_CONFIGURATION.DS.'configuration.php'; + + // Update the credentials with the new settings + $oldconfig =& JFactory::getConfig(); + $oldconfig->setValue('config.ftp_enable', $config_array['ftp_enable']); + $oldconfig->setValue('config.ftp_host', $config_array['ftp_host']); + $oldconfig->setValue('config.ftp_port', $config_array['ftp_port']); + $oldconfig->setValue('config.ftp_user', $config_array['ftp_user']); + $oldconfig->setValue('config.ftp_pass', $config_array['ftp_pass']); + $oldconfig->setValue('config.ftp_root', $config_array['ftp_root']); + JClientHelper::getCredentials('ftp', true); + + if(!$config->get('caching') && $oldconfig->get('caching')) { + $cache = JFactory::getCache(); + $cache->clean(); + } + + // Try to make configuration.php writeable + jimport('joomla.filesystem.path'); + if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) { + JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable'); + } + + // Get the config registry in PHP class format and write it to configuation.php + jimport('joomla.filesystem.file'); + if (JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) { + $msg = JText::_('The Configuration Details have been updated'); + } else { + $msg = JText::_('ERRORCONFIGFILE'); + } + + // Redirect appropriately + $task = $this->getTask(); + switch ($task) { + case 'apply' : + $this->setRedirect('index.php?option=com_config', $msg); + break; + + case 'save' : + default : + $this->setRedirect('index.php', $msg); + break; + } + + // Try to make configuration.php unwriteable + //if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) { + if ($config_array['ftp_enable']==0 && !$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) { + JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php unwritable'); + } + } + + /** + * Cancel operation + */ + function cancel() + { + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + $this->setRedirect( 'index.php' ); + } + + function refreshHelp() + { + jimport('joomla.filesystem.file'); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + if (($data = file_get_contents('http://help.joomla.org/helpsites-15.xml')) === false ) { + $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR FETCH'), 'error'); + } else if (!JFile::write(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $data)) { + $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR STORE'), 'error'); + } else { + $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH SUCCESS')); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_config/controllers/component.php b/oss/joomla/trunk/administrator/components/com_config/controllers/component.php new file mode 100644 index 00000000..ecf2bada --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/controllers/component.php @@ -0,0 +1,116 @@ +registerTask( 'apply', 'save' ); + } + + /** + * Show the configuration edit form + * @param string The URL option + */ + function edit() + { + JRequest::setVar('tmpl', 'component'); //force the component template + $component = JRequest::getCmd( 'component' ); + + if (empty( $component )) + { + JError::raiseWarning( 500, 'Not a valid component' ); + return false; + } + + // load the component's language file + $lang = & JFactory::getLanguage(); + $lang->load( $component ); + + $model = $this->getModel('Component' ); + $table =& JTable::getInstance('component'); + + if (!$table->loadByOption( $component )) + { + JError::raiseWarning( 500, 'Not a valid component' ); + return false; + } + + $view = new ConfigViewComponent( ); + $view->assignRef('component', $table); + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Save the configuration + */ + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $component = JRequest::getCmd( 'component' ); + + $table =& JTable::getInstance('component'); + if (!$table->loadByOption( $component )) + { + JError::raiseWarning( 500, 'Not a valid component' ); + return false; + } + + $post = JRequest::get( 'post' ); + $post['option'] = $component; + $table->bind( $post ); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + //$this->setRedirect( 'index.php?option=com_config', $msg ); + $this->edit(); + } + + /** + * Cancel operation + */ + function cancel() + { + $this->setRedirect( 'index.php' ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/controllers/index.html b/oss/joomla/trunk/administrator/components/com_config/controllers/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/index.html b/oss/joomla/trunk/administrator/components/com_config/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/models/component.php b/oss/joomla/trunk/administrator/components/com_config/models/component.php new file mode 100644 index 00000000..8a788b7a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/models/component.php @@ -0,0 +1,57 @@ +loadByOption( $component ); + + // work out file path + if ($path = JRequest::getString( 'path' )) { + $path = JPath::clean( JPATH_SITE.DS.$path ); + JPath::check( $path ); + } else { + $option = preg_replace( '#\W#', '', $table->option ); + $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; + } + + if (file_exists( $path )) { + $instance = new JParameter( $table->params, $path ); + } else { + $instance = new JParameter( $table->params ); + } + } + return $instance; + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/models/index.html b/oss/joomla/trunk/administrator/components/com_config/models/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php b/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php new file mode 100644 index 00000000..ab10a629 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_cache.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_cache.php new file mode 100644 index 00000000..54692535 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_cache.php @@ -0,0 +1,71 @@ + +
+ + + + + + + + + + + + + + + + + cache_handler == 'memcache' || $row->session_handler == 'memcache') : ?> + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + +
+ + + + + +
+ + + +
+ + + +
+ + + : + +

+ : + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_database.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_database.php new file mode 100644 index 00000000..a4b03750 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_database.php @@ -0,0 +1,63 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +   + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_debug.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_debug.php new file mode 100644 index 00000000..d367229a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_debug.php @@ -0,0 +1,29 @@ + +
+ + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_ftp.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_ftp.php new file mode 100644 index 00000000..d15dc420 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_ftp.php @@ -0,0 +1,70 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_locale.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_locale.php new file mode 100644 index 00000000..f98ea0a4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_locale.php @@ -0,0 +1,19 @@ + +
+ + + + + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_mail.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_mail.php new file mode 100644 index 00000000..5eff01f8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_mail.php @@ -0,0 +1,110 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_metadata.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_metadata.php new file mode 100644 index 00000000..cab378da --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_metadata.php @@ -0,0 +1,50 @@ + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_seo.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_seo.php new file mode 100644 index 00000000..f57a9ac8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_seo.php @@ -0,0 +1,43 @@ + +
+ + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_server.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_server.php new file mode 100644 index 00000000..9d8fe6a0 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_server.php @@ -0,0 +1,50 @@ + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_session.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_session.php new file mode 100644 index 00000000..92d2d64e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_session.php @@ -0,0 +1,30 @@ + +
+ + + + + + + + + + + + +
+ + + + + +    +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_site.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_site.php new file mode 100644 index 00000000..8a5fb70c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_site.php @@ -0,0 +1,81 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_system.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_system.php new file mode 100644 index 00000000..a4a3c9cb --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/config_system.php @@ -0,0 +1,51 @@ + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + secret; ?> +
+ + + + + +
+ + + + + +
+ + + + + + +
+
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/ftp.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/ftp.php new file mode 100644 index 00000000..28dc308a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/ftp.php @@ -0,0 +1,33 @@ + +
+ + + + + ftp)): ?> +

ftp->message); ?>

+ + + + + + + + + + + + + +
+ + + +
+ + + +
+ +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/navigation.php b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/navigation.php new file mode 100644 index 00000000..5e0fa8b7 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/tmpl/navigation.php @@ -0,0 +1,13 @@ + + +
diff --git a/oss/joomla/trunk/administrator/components/com_config/views/application/view.php b/oss/joomla/trunk/administrator/components/com_config/views/application/view.php new file mode 100644 index 00000000..63f3cc7e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/application/view.php @@ -0,0 +1,135 @@ +loadByOption( 'com_users' ); + $userparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_users'.DS.'config.xml' ); + $table->loadByOption( 'com_media' ); + $mediaparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_media'.DS.'config.xml' ); + + // Build the component's submenu + $contents = ''; + $tmplpath = dirname(__FILE__).DS.'tmpl'; + ob_start(); + require_once($tmplpath.DS.'navigation.php'); + $contents = ob_get_contents(); + ob_end_clean(); + + // Set document data + $document =& JFactory::getDocument(); + $document->setBuffer($contents, 'modules', 'submenu'); + + // Load settings for the FTP layer + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + ?> +
+ +
+
+ + + + + +
+ + + + +
+
+
+ + + + + +
+ +
+ + render('userparams'); ?> +
+
+ + + + + + render('mediaparams'); ?> +
+
+ + + +
+
+
+ + + + + +
+ + + + + + +
+
+
+
+ + + + + + + +
+ '; + + return $tip; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_config/views/component/index.html b/oss/joomla/trunk/administrator/components/com_config/views/component/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/component/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/views/component/view.php b/oss/joomla/trunk/administrator/components/com_config/views/component/view.php new file mode 100644 index 00000000..3a7f280e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_config/views/component/view.php @@ -0,0 +1,70 @@ +getModel(); + $params = &$model->getParams(); + $component = JComponentHelper::getComponent(JRequest::getCmd( 'component' )); + + $document = & JFactory::getDocument(); + $document->setTitle( JText::_('Edit Preferences') ); + JHTML::_('behavior.tooltip'); +?> +
+
+
+ + +
+
+ component->name) ?> +
+
+ +
+ + + + render();?> +
+ + + + + + + + + +
+ \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/admin.frontpage.php b/oss/joomla/trunk/administrator/components/com_frontpage/admin.frontpage.php new file mode 100644 index 00000000..c0b714e6 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_frontpage/admin.frontpage.php @@ -0,0 +1,369 @@ +authorize( 'com_frontpage', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Set the table directory +JTable::addIncludePath(JPATH_COMPONENT.DS.DS.'tables'); + +// Set the helper directory +JHTML::addIncludePath( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_content'.DS.'helper' ); + +$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); +JArrayHelper::toInteger($cid, array(0)); + +switch ( JRequest::getCmd( 'task' ) ) +{ + case 'publish': + changeFrontPage( $cid, 1, $option ); + break; + + case 'unpublish': + changeFrontPage( $cid, 0, $option ); + break; + + case 'archive': + changeFrontPage( $cid, -1, $option ); + break; + + case 'remove': + removeFrontPage( $cid, $option ); + break; + + case 'orderup': + orderFrontPage( $cid[0], -1, $option ); + break; + + case 'orderdown': + orderFrontPage( $cid[0], 1, $option ); + break; + + case 'saveorder': + saveOrder( $cid ); + break; + + case 'accesspublic': + accessMenu( $cid[0], 0 ); + break; + + case 'accessregistered': + accessMenu( $cid[0], 1 ); + break; + + case 'accessspecial': + accessMenu( $cid[0], 2 ); + break; + + default: + viewFrontPage( $option ); + break; +} + + +/** +* Compiles a list of frontpage items +*/ +function viewFrontPage( $option ) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $filter_order = $mainframe->getUserStateFromRequest( $option.'.filter_order', 'filter_order', 'fpordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'.filter_state', 'filter_state', '', 'word' ); + $catid = $mainframe->getUserStateFromRequest( $option.'.catid', 'catid', 0, 'int' ); + $filter_authorid = $mainframe->getUserStateFromRequest( $option.'.filter_authorid', 'filter_authorid', 0, 'int' ); + $filter_sectionid = $mainframe->getUserStateFromRequest( $option.'.filter_sectionid', 'filter_sectionid', -1, 'int' ); + $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + JToolBarHelper::title( JText::_( 'Frontpage Manager' ), 'frontpage.png' ); + JToolBarHelper::archiveList(); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::custom('remove','delete.png','delete_f2.png','Remove', true); + JToolBarHelper::help( 'screen.frontpage' ); + + $where = array( + "c.state >= 0" + ); + + // used by filter + if ( $filter_sectionid >= 0 ) { + $where[] = 'c.sectionid = '.(int) $filter_sectionid; + } + if ( $catid > 0 ) { + $where[] = 'c.catid = '.(int) $catid; + } + if ( $filter_authorid > 0 ) { + $where[] = 'c.created_by = '. (int) $filter_authorid; + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'c.state = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'c.state = 0'; + } + } + + if ($search) { + $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', fpordering'; + + // get the total number of records + $query = 'SELECT count(*)' + . ' FROM #__content AS c' + . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' + . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' + . ' INNER JOIN #__content_frontpage AS f ON f.content_id = c.id' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT c.*, g.name AS groupname, cc.title as name, s.title AS sect_name, u.name AS editor, f.ordering AS fpordering, v.name AS author' + . ' FROM #__content AS c' + . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' + . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' + . ' INNER JOIN #__content_frontpage AS f ON f.content_id = c.id' + . ' INNER JOIN #__groups AS g ON g.id = c.access' + . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' + . ' LEFT JOIN #__users AS v ON v.id = c.created_by' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart,$pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // get list of categories for dropdown filter + $query = 'SELECT cc.id AS value, cc.title AS text, section' + . ' FROM #__categories AS cc' + . ' INNER JOIN #__sections AS s ON s.id = cc.section ' + . ' ORDER BY s.ordering, cc.ordering' + ; + $db->setQuery( $query ); + $categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Category' ) .' -' ); + $categories = array_merge( $categories, $db->loadObjectList() ); + $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $catid ); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript ); + + // get list of Authors for dropdown filter + $query = 'SELECT c.created_by, u.name' + . ' FROM #__content AS c' + . ' INNER JOIN #__sections AS s ON s.id = c.sectionid' + . ' LEFT JOIN #__users AS u ON u.id = c.created_by' + . ' WHERE c.state <> -1' + . ' AND c.state <> -2' + . ' GROUP BY u.name' + . ' ORDER BY u.name' + ; + $db->setQuery( $query ); + $authors[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Author' ) .' -', 'created_by', 'name' ); + $authors = array_merge( $authors, $db->loadObjectList() ); + $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once(JPATH_COMPONENT.DS.'views'.DS.'frontpage.php'); + FrontpageView::showList( $rows, $pageNav, $option, $lists ); +} + +/** +* Changes the state of one or more content pages +* @param array An array of unique category id numbers +* @param integer 0 if unpublishing, 1 if publishing +*/ +function changeFrontPage( $cid=null, $state=0, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); + JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__content' + . ' SET state = '.(int) $state + . ' WHERE id IN ( '. $cids .' )' + . ' AND ( checked_out = 0 OR ( checked_out = ' .(int) $user->get('id'). ' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('content'); + $row->checkin( $cid[0] ); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option='.$option ); +} + +function removeFrontPage( &$cid, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + if (!is_array( $cid ) || count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to delete', true ) ); + } + $fp =& JTable::getInstance('frontpage', 'Table'); + foreach ($cid as $id) { + if (!$fp->delete( $id )) { + JError::raiseError(500, $fp->getError() ); + } + $obj =& JTable::getInstance('content'); + $obj->load( $id ); + $obj->mask = 0; + if (!$obj->store()) { + JError::raiseError(500, $fp->getError() ); + } + } + $fp->reorder(); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option='.$option ); +} + +/** +* Moves the order of a record +* @param integer The increment to reorder by +*/ +function orderFrontPage( $uid, $inc, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + $fp =& JTable::getInstance('frontpage','Table'); + $fp->load( $uid ); + $fp->move( $inc ); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option='.$option ); +} + +/** +* @param integer The id of the article +* @param integer The new access level +* @param string The URL option +*/ +function accessMenu( $uid, $access ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db = & JFactory::getDBO(); + $row =& JTable::getInstance('content'); + $row->load( $uid ); + $row->access = $access; + + if ( !$row->check() ) { + return $row->getError(); + } + if ( !$row->store() ) { + return $row->getError(); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option=com_frontpage' ); +} + +function saveOrder( &$cid ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + + for( $i=0; $i < $total; $i++ ) + { + $query = 'UPDATE #__content_frontpage' + . ' SET ordering = ' . (int) $order[$i] + . ' WHERE content_id = ' . (int) $cid[$i]; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $msg = JText::_( 'New ordering saved' ); + $mainframe->redirect( 'index.php?option=com_frontpage', $msg ); +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml b/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml new file mode 100644 index 00000000..0274818b --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml @@ -0,0 +1,11 @@ + + + Frontpage + Joomla! Project + (C) 2005 - 2008 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This Component shows all the published Articles from your site marked Show on Front Page. + diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/index.html b/oss/joomla/trunk/administrator/components/com_frontpage/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_frontpage/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php b/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php new file mode 100644 index 00000000..bf4e665e --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/views/frontpage.php b/oss/joomla/trunk/administrator/components/com_frontpage/views/frontpage.php new file mode 100644 index 00000000..4146cf0a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_frontpage/views/frontpage.php @@ -0,0 +1,263 @@ +getNullDate(); + $config =& JFactory::getConfig(); + $now =& JFactory::getDate(); + + //Ordering allowed ? + $ordering = (($lists['order'] == 'fpordering')); + + JHTML::_('behavior.tooltip'); + ?> +
+ + + + + + +
+ : + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + id ); + + $publish_up =& JFactory::getDate($row->publish_up); + $publish_down =& JFactory::getDate($row->publish_down); + $publish_up->setOffset($config->getValue('config.offset')); + $publish_down->setOffset($config->getValue('config.offset')); + if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) { + $img = 'publish_y.png'; + $alt = JText::_( 'Published' ); + } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) { + $img = 'publish_g.png'; + $alt = JText::_( 'Published' ); + } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) { + $img = 'publish_r.png'; + $alt = JText::_( 'Expired' ); + } else if ( $row->state == 0 ) { + $img = 'publish_x.png'; + $alt = JText::_( 'Unpublished' ); + } else if ( $row->state == -1 ) { + $img = 'disabled.png'; + $alt = JText::_( 'Archived' ); + } + $times = ''; + if (isset($row->publish_up)) { + if ($row->publish_up == $nullDate) { + $times .= JText::_( 'Start: Always' ); + } else { + $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat(); + } + } + if (isset($row->publish_down)) { + if ($row->publish_down == $nullDate) { + $times .= "
". JText::_( 'Finish: No Expiry' ); + } else { + $times .= "
". JText::_( 'Finish' ) .": ". $publish_down->toFormat(); + } + } + + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + + if ( $user->authorize( 'com_users', 'manage' ) ) { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by ); + $author='' . + ''. $row->author .''; + } + } else { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $author = $row->author; + } + } + + // section handling + if ($row->sectionid) { + $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); + $title_sec = JText::_( 'Edit Section' ); + } + + // category handling + if ($row->catid) { + $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); + $title_cat = JText::_( 'Edit Category' ); + } + ?> + "> + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else { + ?> + + + title; ?> + + + + + <?php echo $alt;?> + + orderUpIcon( $i, true, 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, true, 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + id;?> + + sectionid) : ?> + + + sect_name; ?> + + + catid) : ?> + + + name; ?> + + + +
+ + + + + + + + +
+ \ No newline at end of file