/** * Display the feed editor. * * @param int $fid feed id (0 for new feeds) * @param string $type type of feed, e.g. 'article' * @return string HTML for the feed editor * */ function FEED_edit($fid = 0, $type = '') { global $_CONF, $_TABLES, $LANG33, $LANG_ADMIN, $MESSAGE, $_IMAGE_TYPE; USES_lib_admin(); if ($fid > 0) { $result = DB_query("SELECT *,UNIX_TIMESTAMP(updated) AS date FROM {$_TABLES['syndication']} WHERE fid = '{$fid}'"); $A = DB_fetchArray($result); $fid = $A['fid']; } if ($fid == 0) { if (!empty($type)) { // set defaults $A['fid'] = $fid; $A['type'] = $type; $A['topic'] = '::all'; $A['header_tid'] = 'none'; $A['format'] = 'RSS-2.0'; $A['limits'] = $_CONF['rdf_limit']; $A['content_length'] = $_CONF['rdf_storytext']; $A['title'] = $_CONF['site_name']; $A['description'] = $_CONF['site_slogan']; $A['feedlogo'] = ''; $A['filename'] = ''; $A['charset'] = $_CONF['default_charset']; $A['language'] = $_CONF['rdf_language']; $A['is_enabled'] = 1; $A['updated'] = ''; $A['update_info'] = ''; $A['date'] = time(); } else { return COM_refresh($_CONF['site_admin_url'] . '/syndication.php'); } } $retval = ''; $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/syndication.php', 'text' => $LANG33[57]), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $feed_template = new Template($_CONF['path_layout'] . 'admin/syndication'); $feed_template->set_file('editor', 'feededitor.thtml'); $feed_template->set_var('start_feed_editor', COM_startBlock($LANG33[24], '', COM_getBlockTemplate('_admin_block', 'header'))); $feed_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $feed_template->set_var('lang_feedtitle', $LANG33[25]); $feed_template->set_var('lang_enabled', $LANG33[19]); $feed_template->set_var('lang_format', $LANG33[17]); $feed_template->set_var('lang_limits', $LANG33[26]); $feed_template->set_var('lang_content_length', $LANG33[27]); $feed_template->set_var('lang_clen_explain', $LANG33[28]); $feed_template->set_var('lang_description', $LANG33[29]); $feed_template->set_var('lang_feedlogo', $LANG33[49]); $feed_template->set_var('lang_feedlogo_explain', $LANG33[50]); $feed_template->set_var('lang_filename', $LANG33[16]); $feed_template->set_var('lang_updated', $LANG33[30]); $feed_template->set_var('lang_type', $LANG33[15]); $feed_template->set_var('lang_charset', $LANG33[31]); $feed_template->set_var('lang_language', $LANG33[32]); $feed_template->set_var('lang_topic', $LANG33[33]); $feed_template->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG33[58], $_CONF['layout_url'] . '/images/icons/syndication.' . $_IMAGE_TYPE)); if ($A['header_tid'] == 'all') { $feed_template->set_var('all_selected', 'selected="selected"'); } elseif ($A['header_tid'] == 'none') { $feed_template->set_var('none_selected', 'selected="selected"'); } $feed_template->set_var('lang_header_all', $LANG33[43]); $feed_template->set_var('lang_header_none', $LANG33[44]); $feed_template->set_var('lang_header_topic', $LANG33[45]); $feed_template->set_var('header_topic_options', COM_topicList('tid,topic', $A['header_tid'], 1, true)); $feed_template->set_var('lang_save', $LANG_ADMIN['save']); $feed_template->set_var('lang_cancel', $LANG_ADMIN['cancel']); if ($A['fid'] > 0) { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . '/>'; $jsconfirm = ' onclick="return confirm(\'' . $LANG33[56] . '\');"'; $feed_template->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $feed_template->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); $feed_template->set_var('delete_button', true); $feed_template->set_var('lang_delete_confirm', $LANG33[56]); $feed_template->set_var('lang_delete', $LANG_ADMIN['delete']); } $feed_template->set_var('feed_id', $A['fid']); $feed_template->set_var('feed_title', $A['title']); $feed_template->set_var('feed_description', $A['description']); $feed_template->set_var('feed_logo', $A['feedlogo']); $feed_template->set_var('feed_content_length', $A['content_length']); $feed_template->set_var('feed_filename', $A['filename']); $feed_template->set_var('feed_type', $A['type']); if ($A['type'] == 'article') { $feed_template->set_var('feed_type_display', $LANG33[55]); } else { $feed_template->set_var('feed_type_display', ucwords($A['type'])); } $feed_template->set_var('feed_charset', $A['charset']); $feed_template->set_var('feed_language', $A['language']); $nicedate = COM_getUserDateTimeFormat($A['date']); $feed_template->set_var('feed_updated', $nicedate[0]); $formats = FEED_findFormats(); $selection = '<select name="format">' . LB; foreach ($formats as $f) { // if one changes this format below ('name-version'), also change parsing // in COM_siteHeader. It uses explode( "-" , $string ) $selection .= '<option value="' . $f['name'] . '-' . $f['version'] . '"'; if ($A['format'] == $f['name'] . '-' . $f['version']) { $selection .= ' selected="selected"'; } $selection .= '>' . ucwords($f['name'] . ' ' . $f['version']) . '</option>' . LB; } $selection .= '</select>' . LB; $feed_template->set_var('feed_format', $selection); $limits = $A['limits']; $hours = false; if (substr($A['limits'], -1) == 'h') { $limits = substr($A['limits'], 0, -1); $hours = true; } $selection = '<select name="limits_in">' . LB; $selection .= '<option value="0"'; if (!$hours) { $selection .= ' selected="selected"'; } $selection .= '>' . $LANG33[34] . '</option>' . LB; $selection .= '<option value="1"'; if ($hours) { $selection .= ' selected="selected"'; } $selection .= '>' . $LANG33[35] . '</option>' . LB; $selection .= '</select>' . LB; $feed_template->set_var('feed_limits', $limits); $feed_template->set_var('feed_limits_what', $selection); if ($A['type'] == 'article') { $options = FEED_getArticleFeeds(); } else { $result = DB_query("SELECT pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name='{$A['type']}'"); if ($result) { $P = DB_fetchArray($result); if ($P['pi_enabled'] == 0) { COM_setMessage(80); echo COM_refresh($_CONF['site_admin_url'] . '/syndication.php'); exit; } } $options = PLG_getFeedNames($A['type']); } $selection = '<select name="topic">' . LB; foreach ($options as $o) { $selection .= '<option value="' . $o['id'] . '"'; if ($A['topic'] == $o['id']) { $selection .= ' selected="selected"'; } $selection .= '>' . $o['name'] . '</option>' . LB; } $selection .= '</select>' . LB; $feed_template->set_var('feed_topic', $selection); if ($A['is_enabled'] == 1) { $feed_template->set_var('is_enabled', 'checked="checked"'); } else { $feed_template->set_var('is_enabled', ''); } $security_token = SEC_createToken(); $feed_template->set_var('sec_token_name', CSRF_TOKEN); $feed_template->set_var('sec_token', $security_token); //depreciated $feed_template->set_var('gltoken_name', CSRF_TOKEN); $feed_template->set_var('gltoken', $security_token); //end of depreciated $retval .= $feed_template->finish($feed_template->parse('output', 'editor')); return $retval; }
/** * Display the feed editor. * * @param int $fid feed id (0 for new feeds) * @param string $type type of feed, e.g. 'article' * @return string HTML for the feed editor * */ function editfeed($fid = 0, $type = '') { global $_CONF, $_TABLES, $LANG33, $LANG_ADMIN, $MESSAGE; if ($fid > 0) { $result = DB_query("SELECT *,UNIX_TIMESTAMP(updated) AS date FROM {$_TABLES['syndication']} WHERE fid = '{$fid}'"); $A = DB_fetchArray($result); $fid = $A['fid']; } if ($fid == 0) { if (!empty($type)) { // set defaults $A['fid'] = $fid; $A['type'] = $type; $A['topic'] = '::all'; $A['header_tid'] = 'none'; $A['format'] = 'RSS-2.0'; $A['limits'] = $_CONF['rdf_limit']; $A['content_length'] = $_CONF['rdf_storytext']; $A['title'] = $_CONF['site_name']; $A['description'] = $_CONF['site_slogan']; $A['feedlogo'] = ''; $A['filename'] = ''; $A['charset'] = $_CONF['default_charset']; $A['language'] = $_CONF['rdf_language']; $A['is_enabled'] = 1; $A['updated'] = ''; $A['update_info'] = ''; $A['date'] = time(); } else { COM_redirect($_CONF['site_admin_url'] . '/syndication.php'); } } $retval = ''; $token = SEC_createToken(); $feed_template = COM_newTemplate($_CONF['path_layout'] . 'admin/syndication'); $feed_template->set_file('editor', 'feededitor.thtml'); $start_block = COM_startBlock($LANG33[24], '', COM_getBlockTemplate('_admin_block', 'header')); $start_block .= SEC_getTokenExpiryNotice($token); $feed_template->set_var('start_feed_editor', $start_block); $feed_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'))); $feed_template->set_var('lang_feedtitle', $LANG33[25]); $feed_template->set_var('lang_enabled', $LANG33[19]); $feed_template->set_var('lang_format', $LANG33[17]); $feed_template->set_var('lang_limits', $LANG33[26]); $feed_template->set_var('lang_content_length', $LANG33[27]); $feed_template->set_var('lang_clen_explain', $LANG33[28]); $feed_template->set_var('lang_description', $LANG33[29]); $feed_template->set_var('lang_feedlogo', $LANG33[49]); $feed_template->set_var('lang_feedlogo_explain', $LANG33[50]); $feed_template->set_var('lang_filename', $LANG33[16]); $feed_template->set_var('lang_updated', $LANG33[30]); $feed_template->set_var('lang_type', $LANG33[15]); $feed_template->set_var('lang_charset', $LANG33[31]); $feed_template->set_var('lang_language', $LANG33[32]); $feed_template->set_var('lang_topic', $LANG33[33]); $feed_template->set_var('lang_header_topic', $LANG33[45]); $feed_template->set_var('header_topic_options', TOPIC_getTopicListSelect($A['header_tid'], 6, true)); $feed_template->set_var('lang_save', $LANG_ADMIN['save']); $feed_template->set_var('lang_cancel', $LANG_ADMIN['cancel']); if ($A['fid'] > 0) { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $feed_template->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $feed_template->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); $feed_template->set_var('allow_delete', true); $feed_template->set_var('lang_delete', $LANG_ADMIN['delete']); $feed_template->set_var('confirm_message', $MESSAGE[76]); } $feed_template->set_var('feed_id', $A['fid']); $feed_template->set_var('feed_title', $A['title']); $feed_template->set_var('feed_description', $A['description']); $feed_template->set_var('feed_logo', $A['feedlogo']); $feed_template->set_var('feed_content_length', $A['content_length']); $feed_template->set_var('feed_filename', $A['filename']); $feed_template->set_var('feed_type', $A['type']); $feed_template->set_var('feed_type_display', ucwords($A['type'])); $feed_template->set_var('feed_charset', $A['charset']); $feed_template->set_var('feed_language', $A['language']); if ($A['is_enabled'] == 1 && !empty($A['updated'])) { $nicedate = COM_getUserDateTimeFormat($A['date']); $feed_template->set_var('feed_updated', $nicedate[0]); } else { $feed_template->set_var('feed_updated', $LANG_ADMIN['na']); } $formats = find_feedFormats(); $selection = '<select name="format">' . LB; foreach ($formats as $f) { // if one changes this format below ('name-version'), also change parsing // in COM_createHTMLDocument. It uses explode( "-" , $string ) $selection .= '<option value="' . $f['name'] . '-' . $f['version'] . '"'; if ($A['format'] == $f['name'] . '-' . $f['version']) { $selection .= ' selected="selected"'; } $selection .= '>' . ucwords($f['name'] . ' ' . $f['version']) . '</option>' . LB; } $selection .= '</select>' . LB; $feed_template->set_var('feed_format', $selection); $limits = $A['limits']; $hours = false; if (substr($A['limits'], -1) == 'h') { $limits = substr($A['limits'], 0, -1); $hours = true; } $selection = '<select name="limits_in">' . LB; $selection .= '<option value="0"'; if (!$hours) { $selection .= ' selected="selected"'; } $selection .= '>' . $LANG33[34] . '</option>' . LB; $selection .= '<option value="1"'; if ($hours) { $selection .= ' selected="selected"'; } $selection .= '>' . $LANG33[35] . '</option>' . LB; $selection .= '</select>' . LB; $feed_template->set_var('feed_limits', $limits); $feed_template->set_var('feed_limits_what', $selection); if ($A['type'] != 'article' and $A['type'] != 'comment') { $result = DB_query("SELECT pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name='{$A['type']}'"); if ($result) { $P = DB_fetchArray($result); if ($P['pi_enabled'] == 0) { COM_redirect($_CONF['site_admin_url'] . '/syndication.php?msg=80'); } } } $options = PLG_getFeedNames($A['type']); $selection = '<select name="topic">' . LB; foreach ($options as $o) { $selection .= '<option value="' . $o['id'] . '"'; if ($A['topic'] == $o['id']) { $selection .= ' selected="selected"'; } $selection .= '>' . $o['name'] . '</option>' . LB; } $selection .= '</select>' . LB; $feed_template->set_var('feed_topic', $selection); if ($A['is_enabled'] == 1) { $feed_template->set_var('is_enabled', 'checked="checked"'); } else { $feed_template->set_var('is_enabled', ''); } $feed_template->set_var('gltoken_name', CSRF_TOKEN); $feed_template->set_var('gltoken', $token); $retval .= $feed_template->finish($feed_template->parse('output', 'editor')); return $retval; }