/**
 * build_settings_formtype
 * 
 * 
 * 
 */
function build_settings_formtype($setting_data)
{
    // options for themes dropdown
    if ($setting_data['property_name'] == 'theme') {
        $theme_dir = WW_ROOT . "/ww_view/themes/";
        $themes = get_folders($theme_dir);
        $setting_data['options'] = '/' . implode(',/', $themes);
    }
    switch ($setting_data['formtype']) {
        // text
        case 'text':
        case 'custom':
            $default = !empty($setting_data['default_value']) ? $setting_data['default_value'] : '[no default]';
            $default = $setting_data['formtype'] == 'custom' ? '[custom field]' : $default;
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<input type="text"
						name="' . $setting_data['property_name'] . '" 
						id="' . $setting_data['property_name'] . '" 
						value="' . $setting_data['property_value'] . '"/>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
            // textarea
        // textarea
        case 'textarea':
            $default = !empty($setting_data['default_value']) ? $setting_data['default_value'] : '[no default]';
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<textarea name="' . $setting_data['property_name'] . '"
						id="' . $setting_data['property_name'] . '" 
						cols="50" rows="3">' . $setting_data['property_value'] . '</textarea>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
            // select
        // select
        case 'select':
            $default = !empty($setting_data['default_value']) ? $setting_data['default_value'] : '[no default]';
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<select name="' . $setting_data['property_name'] . '"
						id="' . $setting_data['property_name'] . '" >
							<option value="">select...</option>';
            //options for front article dropdown
            if ($setting_data['property_name'] == 'article_id') {
                $articles = get_articles_basic('', '', 'date_uploaded DESC', 25);
                foreach ($articles as $article) {
                    $selected = $article['id'] == $setting_data['property_value'] ? ' selected="selected"' : '';
                    $form_field .= '
								<option value="' . $article['id'] . '"' . $selected . '>' . $article['title'] . '</option>';
                }
            } else {
                // generic options
                $options = explode(",", $setting_data['options']);
                foreach ($options as $option) {
                    $option = trim($option);
                    $selected = $option == $setting_data['property_value'] ? ' selected="selected"' : '';
                    $form_field .= '
								<option value="' . $option . '"' . $selected . '>' . $option . '</option>';
                }
            }
            $form_field .= '
					</select>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
            // checkbox
            /*	
            	case 'checkbox':
            		$checked = (!empty($setting_data['property_value'])) ? ' checked="checked"' : '' ;
            		$default = (!empty($setting_data['default_value'])) ? 'yes' : 'no' ;
            		$form_field = '
            		<p>
            			<label for="'.$setting_data['property_name'].'">
            				'.str_replace('_',' ',$setting_data['property_name']).'
            			</label>
            			<span class="checkbox">
            			<input type="'.$setting_data['formtype'].'"
            				name="'.$setting_data['property_name'].'" 
            				id="'.$setting_data['property_name'].'" 
            				value="1"'.$checked.'/>
            			</span>
            			<span class="default">'.$default.'</span>
            			<span class="note">'.$setting_data['summary'].'</span>
            		</p>';
            		break;
            */
        // checkbox
        /*	
        	case 'checkbox':
        		$checked = (!empty($setting_data['property_value'])) ? ' checked="checked"' : '' ;
        		$default = (!empty($setting_data['default_value'])) ? 'yes' : 'no' ;
        		$form_field = '
        		<p>
        			<label for="'.$setting_data['property_name'].'">
        				'.str_replace('_',' ',$setting_data['property_name']).'
        			</label>
        			<span class="checkbox">
        			<input type="'.$setting_data['formtype'].'"
        				name="'.$setting_data['property_name'].'" 
        				id="'.$setting_data['property_name'].'" 
        				value="1"'.$checked.'/>
        			</span>
        			<span class="default">'.$default.'</span>
        			<span class="note">'.$setting_data['summary'].'</span>
        		</p>';
        		break;
        */
        case 'checkbox':
            $yes_selected = !empty($setting_data['property_value']) ? ' selected="selected"' : '';
            $no_selected = empty($setting_data['property_value']) ? ' selected="selected"' : '';
            $default = !empty($setting_data['default_value']) ? 'yes' : 'no';
            $opt_class = !empty($setting_data['property_value']) ? ' opt_yes' : '';
            $form_field = '
				<p>
					<label for="' . $setting_data['property_name'] . '">
						' . str_replace('_', ' ', $setting_data['property_name']) . '
					</label>
					<select name="' . $setting_data['property_name'] . '"
						id="' . $setting_data['property_name'] . '" class="select_checkbox' . $opt_class . '">
						<option value="0"' . $no_selected . '>No</option>
						<option value="1"' . $yes_selected . '>Yes</option>
					</select>
					<span class="default">' . $default . '</span>
					<span class="note">' . $setting_data['summary'] . '</span>
				</p>';
            break;
        default:
            $form_field = '';
    }
    // end switch
    return $form_field;
}
<?php

header('Content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" \nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \nxsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n";
// get site data and connections
include_once '../ww_config/model_functions.php';
include_once '../ww_config/controller_functions.php';
include_once '../ww_config/combined_functions.php';
$layout = get_settings('layout');
$url_style = $layout['layout']['url_style'];
// get all articles
$articles_xml_list = get_articles_basic($url_style, '', 'date_uploaded DESC');
if (empty($articles_xml_list)) {
    echo "</urlset>";
    exit;
}
// set sitemap header
$site_link = constant('WW_WEB_ROOT');
$most_recent_ts = strtotime($articles_xml_list[0]['date_uploaded']);
$most_recent = date('Y-m-d', $most_recent_ts);
echo "\n   <url>\n      <loc>" . WW_WEB_ROOT . "</loc>\n      <lastmod>" . $most_recent . "</lastmod>\n      <changefreq>weekly</changefreq>\n      <priority>0.8</priority>\n   </url>";
foreach ($articles_xml_list as $article) {
    echo "\n\t<url>\n\t\t<loc>" . $article['link'] . "</loc>\n\t\t<lastmod>" . date('Y-m-d', strtotime($article['date_uploaded'])) . "</lastmod>\n\t\t<priority>0.8</priority>\n\t\t<changefreq>weekly</changefreq>\n\t</url>";
}
// add category index
$cats_xml_list = get_categories_basic();
foreach ($cats_xml_list as $cat_xml) {
    echo "\n\t\t<url>\n\t\t\t<loc>" . $cat_xml['link'] . "</loc>\n\t\t\t<priority>0.3</priority>\n\t\t\t<changefreq>monthly</changefreq>\n\t\t</url>";
}
// add tag index
$tags_xml_list = get_tags();
/**
 * build_write_form
 * 
 * 
 * 
 * 
 * 
 * 
 */
function show_comment_form_admin($article_id = 0, $reply_id = 0)
{
    // validate params
    $article_id = isset($article_id) ? (int) $article_id : 0;
    $reply_id = isset($reply_id) ? (int) $reply_id : 0;
    $comment_body = isset($_POST['body']) ? $_POST['body'] : '';
    // work out how to display article_id elements on the form
    if (!empty($reply_id) && !empty($article_id)) {
        // hard code the parameters into the form
        $article_chunk = '
			<input name="article_id" id="article_id" value="' . $article_id . '" type="hidden">			
			';
    } else {
        $articles = $articles = get_articles_basic('', '', 'date_uploaded DESC', 0);
        $article_chunk = '
			<label for="article_id">Article</label>
			<select name="article_id">
				<option value="0">select article...</option>';
        foreach ($articles as $article) {
            $selected = $article['id'] == $article_id ? ' selected="selected"' : '';
            $article_chunk .= '
				<option value="' . $article['id'] . '"' . $selected . '>' . $article['title'] . '</option>
				';
        }
        $article_chunk .= '
			</select></p>
			<p>';
    }
    // start building main form
    $html = '
		<form action="' . current_url() . '" method="post" id="comment_form">
		
		<p><label for="body">Comment</label>
			<textarea name="body" title="your comment" id="body" cols="32" rows="8">' . $comment_body . '</textarea></p>
		<p>	
			' . $article_chunk . '
			<input name="reply_id" id="reply_id" value="' . $reply_id . '" type="hidden">
			<input name="title" id="title" value="" type="hidden">
			<input name="submit_comment" id="submit_comment" value="Submit" type="submit">
		</p>
		</form>
		';
    return $html;
}
$months_list = get_months();
$search_form = show_search_form();
$aside_snippet['twitter_feed'] = '';
if (!empty($config['connections']['twitter_username'])) {
    $twitter_username = $config['connections']['twitter_username'];
    $twitter_feed = get_twitter_feed($twitter_username);
    $aside_snippet['twitter_feed'] = build_snippet('Recent twitterings...', $twitter_feed);
}
// now use a ready made function to put the above data arrays into some drop down lists
$months_select_form = build_select_form('months_select_form', $months_list);
$categories_select_form = build_select_form('categories_select_form', $categories_list);
$authors_select_form = build_select_form('authors_select_form', $authors_list);
$tags_select_form = build_select_form('tags_select_form', $tags_list);
// get two lists of articles - the latest and the most popule
$latest_articles = get_articles_basic($config['layout']['url_style']);
$popular_articles = get_articles_basic($config['layout']['url_style'], '', 'view_count DESC', '5');
// feeds - this is slightly different - we'll write out the html and put it in a variable
$feeds_img = file_exists(WW_ROOT . '/ww_view/_img/feed-icon16x16.png') ? '<img src="' . WW_WEB_ROOT . '/ww_view/_img/feed-icon16x16.png" alt="RSS logo" width="16" height="16"/>' : '';
$feeds_list = '
		<ul>
			<li>
				<a href="' . WW_WEB_ROOT . '/rss/" rel="alternate" type="application/rss+xml">' . $feeds_img . 'Main feed</a>
			</li>
			<li>
				<a title="RSS feeds for ' . $config['site']['title'] . '" href="' . WW_WEB_ROOT . '/feeds/">Click here to view all available feeds</a>
			</li>
		</ul>';
// get content for menu aside
$aside_snippet['main_menu'] = '';
if ($config['layout']['main_menu'] == 'aside') {
    $menu_links = get_links('site_menu');