Example #1
0
function display_page_content()
{
    ?>
	
				
	<div id="edit-header" class="aliasnav">
		<h1>Alias List</h1>
	</div>
	
	<p><strong>An Alias</strong> is a meta-redirect &ndash; one address can forward to another. In the first column are your current redirect addresses, and in the second column is the page/event/blog post/etc... that the alias will redirect to. </p>
	
<?php 
    $alias = Alias::FindAll();
    if (count($alias) > 0) {
        ?>
			
	<div id="table-header" class="alias">
		<strong class="item-link">Alias Link</strong>
		<span class="item-filename">Alias Destination</span>
		<span class="item-viewlink">Test the Alias</span>
	</div>
	
	<ul class="managelist"> 
<?php 
        foreach ($alias as $entry) {
            $slash = "/";
            if (substr($entry->alias, 0, 1) == "/") {
                $slash = "";
            }
            ?>

		<li>
			<a class="item-link" href="<?php 
            echo get_link("/admin/alias_edit/" . $entry->id);
            ?>
"><?php 
            echo SITE_URL . $slash . $entry->alias;
            ?>
</a>
			<span class="item-filename"><?php 
            echo $entry->path;
            ?>
</span>
			<span class="item-viewlink"><a href="<?php 
            echo "http://" . SITE_URL . $slash . $entry->alias;
            ?>
" target="_blank">Open</a></span>
		</li>
<?php 
        }
        echo "</ul>\n";
    } else {
        echo "<h3 class=\"empty-list\">There are no Alias' to edit. <a href=\"" . get_link("admin/alias_add") . "\">Please add one</a>. </h3>";
    }
}
Example #2
0
function display_page($params = array())
{
    // canonicalize the input
    $area_name = $page_name = "";
    // GET /
    if (count($params) == 0) {
        $area_name = "index";
        $page_name = "index";
    }
    // GET /area_name
    if (count($params) == 1) {
        $area_name = $params[0];
        $page_name = "index";
    }
    // GET /area_name/page_name
    if (count($params) > 1) {
        $area_name = $params[0];
        $page_name = $params[1];
    }
    if (ALIAS_INSTALL) {
        // Test the MyActiveRecord connection
        if (mysql_num_rows(mysql_query("SHOW TABLES LIKE 'alias'")) == 1) {
            // check the alias' in the database and see if there is a match
            $alias = Alias::FindAll();
            /* die(print_r($alias)); */
            foreach ($alias as $entry) {
                if ($entry->alias == $area_name || $entry->alias == "/" . $area_name) {
                    redirect($entry->path);
                }
            }
        }
    }
    // check the routes to see if the requested page has an explicit route setup
    $page_options = $GLOBALS['ROUTES'];
    if (isset($page_options["/" . $area_name . "/" . $page_name])) {
        $page = StaticPage::FindByAreaAndName($area_name, $page_name);
        if (isset($page)) {
            display_admin_with_template($page);
            return true;
        }
    }
    // check for pages that are in the "global" area and have params (ie /calendar/2008/1)
    $global_area = Areas::FindByName('index');
    $possible_page = Pages::FindByAreaAndName($global_area, $page_name) ? Pages::FindByAreaAndName($global_area, $area_name) : '';
    if (!empty($possible_page)) {
        $area = $global_area;
        $page = $possible_page;
    } else {
        // for now, just include the first page that comes back. later we can handle multiple pages
        $area = Areas::FindByName($area_name);
        if (!isset($area)) {
            return false;
        }
        if (strstr($area_name, "-portfolio")) {
            if ($page_name != "index") {
                $page = Sections::FindByName($page_name);
            } else {
                $pages = $area->getSections();
                $page = array_shift($pages);
            }
        } else {
            $page = Pages::FindPageOrIndex($area, $page_name);
        }
    }
    if (!isset($page)) {
        return false;
    }
    // check if the page is public or not
    $is_admin = false;
    $user = Users::GetCurrentUser();
    if ($user) {
        $logged_in = true;
    }
    if ($page->public || !$page->public && $logged_in) {
        display_with_template($area, $page);
    } else {
        return false;
    }
    return true;
}