Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Pastebin / functions.custom.php

<?php
if (!defined('COT_CODE')) { die('Wrong URL.'); }

/**
 * Changes  to / for List URLS
 *
 * @param array $args Args passed over from cot_url
 * @return string
 */
function list_url_structure(&$args)
{
	global $structure;
	
	$url = (preg_match('#^docs-#', $args['c'])) ? str_replace('-', '/', $args['c']).'/' : str_replace('.', '/', $structure['page'][$args['c']]['path']).'/';
	unset($args['c']);
	
	return $url;
}

/**
 * Changes to / for Page URLS
 *
 * @param array $args Args passed over from cot_url
 * @return string
 */
function page_url_structure(&$args)
{
	global $structure, $pag, $row, $rpagecat, $c, $newpagecat;

	if(preg_match('#^docs-#', $pag['page_cat']) || preg_match('#^docs-#', $row['page_cat']) || preg_match('#^docs-#', $rpagecat))
	{
		$page_cat = (!empty($rpagecat) && empty($page_cat)) ? $rpagecat : $page_cat;
		$page_cat = (!empty($pag['page_cat']) && empty($page_cat)) ? $pag['page_cat'] : $page_cat;
		$page_cat = (!empty($row['page_cat']) && empty($page_cat)) ? $row['page_cat'] : $page_cat;
		//$page_cat = (!empty($args['c']) && empty($page_cat)) ? $args['c'] : $page_cat;
		$page_cat = (!empty($newpagecat) && empty($page_cat)) ? $newpagecat : $page_cat;
	}
	else
	{
		$page_cat = (!empty($structure['page'][$rpagecat]['path']) && empty($page_cat)) ? $structure['page'][$rpagecat]['path'] : $page_cat;
		$page_cat = (!empty($structure['page'][$pag['page_cat']]['path']) && empty($page_cat)) ? $structure['page'][$pag['page_cat']]['path'] : $page_cat;
		$page_cat = (!empty($structure['page'][$row['page_cat']]['path']) && empty($page_cat)) ? $structure['page'][$row['page_cat']]['path'] : $page_cat;
		//$page_cat = (!empty($structure['page'][$args['c']]['path']) && empty($page_cat)) ? $structure['page'][$args['c']]['path'] : $page_cat;
		$page_cat = (!empty($structure['page'][$newpagecat]['path']) && empty($page_cat)) ? $structure['page'][$newpagecat]['path'] : $page_cat;
	}

	if (empty($page_cat)) $page_cat = 'articles';
	if($args['id'])
	{
		$url = (preg_match('#^docs-#', $page_cat)) ? str_replace('-', '/', $page_cat).'/' : str_replace('.', '/', $page_cat).'/';
		$url .= $args['id'];
		unset($args['id']);
	}
	elseif($args['al'])
	{
		$url = (preg_match('#^docs-#', $page_cat)) ? str_replace('-', '/', $page_cat).'/' : str_replace('.', '/', $page_cat).'/';
		$url .= urlencode($args['al']);
		unset($args['al']);
	}
	elseif($args['m'] == 'add')
	{
		$args['c'] = (!empty($args['c'])) ? $args['c'] : $c;
		$url = (preg_match('#^docs-#', $args['c'])) ? str_replace('-', '/', $args['c']).'/' : str_replace('.', '/', $structure['page'][$args['c']]['path']).'/';
		$url .= 'add';
		unset($args['c'], $args['m']);
	}
	return $url;
}

/**
 * Changes  to / for UserName URLS
 *
 * @param array $args Args passed over from cot_url
 * @return string
 */
function username_url_structure(&$args)
{
	$url = 'users/'.$args['u'];
	unset($args['m'], $args['id'], $args['u']);
	return $url;
}
?>

Tags:

Siena  Urls