/**
 * get_category_id
 * 
 * takes a category url and matches it to the category id
 * 
 * secure method for validating string requests
 * 
 * @param	string	$url	category url
 * @return	int		$id		category id from database
 */
function get_category_id($url)
{
    if (empty($url)) {
        return false;
    }
    $categories = get_categories_basic();
    $data = array();
    foreach ($categories as $cat) {
        $data[$cat['id']] = strtolower($cat['url']);
    }
    $id = array_search($url, $data);
    return $id;
}
Exemple #2
0
			<input type="submit" name="create_file" value="create">
		</p>
		</form>
	';
// output aside content
$aside_content = build_snippet('Files for ' . $edit_theme, $list_files);
$aside_content .= build_snippet('Create new file', $create_file);
$aside_content .= build_snippet('Themes', $list_themes);
$aside_content .= '
		<h4>Suggestions</h4>
		<p>You can also create the following page and category specific stylesheets:</p>';
// get a list of page names
$page_names = array('feed', 'front', '404', 'article', 'listing');
$page_name_css = array();
foreach ($page_names as $page_name) {
    if (!file_exists(WW_ROOT . '/ww_view/themes/' . $edit_theme . '/' . $page_name . '.css')) {
        $new_link = $_SERVER["PHP_SELF"] . '?page_name=editor&amp;theme=' . $edit_theme . '&amp;create_file=';
        $page_name_css[] = array('title' => $page_name . '.css', 'link' => $new_link . $page_name . '.css');
    }
}
$aside_content .= build_snippet('', $page_name_css);
// get a list of categories
$categories_list = get_categories_basic();
$category_css = array();
foreach ($categories_list as $category) {
    if (!file_exists(WW_ROOT . '/ww_view/themes/' . $edit_theme . '/' . $category . '.css')) {
        $new_link = $_SERVER["PHP_SELF"] . '?page_name=editor&amp;theme=' . $edit_theme . '&amp;create_file=';
        $category_css[] = array('title' => $category . '.css', 'link' => $new_link . $category . '.css');
    }
}
$aside_content .= build_snippet('', $category_css);
// 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();
foreach ($tags_xml_list as $tag_xml) {
    echo "\n\t\t<url>\n\t\t\t<loc>" . $tag_xml['link'] . "</loc>\n\t\t\t<priority>0.3</priority>\n\t\t\t<changefreq>monthly</changefreq>\n\t\t</url>";
}
// add author index
$authors_xml_list = get_authors();
foreach ($authors_xml_list as $author_xml) {
    echo "\n\t\t<url>\n\t\t\t<loc>" . $author_xml['link'] . "</loc>\n\t\t\t<priority>0.3</priority>\n\t\t\t<changefreq>monthly</changefreq>\n\t\t</url>";
}
// end sitemap
echo "</urlset>";