public function testPathWithDefault()
 {
     $_SERVER['SCRIPT_NAME'] = '/default/index.php';
     $this->Dispatcher = Dispatcher::getInstance();
     $this->Dispatcher->setUrl('mycontroller/myaction/p1/1/p2/2/p3/3');
     $this->assertEqual(UrlComponent::path('default/index'), '/default/index');
 }
Beispiel #2
0
 public function __construct($message, $code = 0)
 {
     if (ini_get('display_errors') == 1) {
         return parent::__construct($message, $code);
     }
     switch ($code) {
         case 404:
             header('location:' . UrlComponent::path('/pages/page404/'));
             break;
         case 403:
             header('location:' . UrlComponent::path('/pages/page403/'));
             break;
         default:
             header('location:' . UrlComponent::path('/pages/page500/'));
     }
     exit;
 }
Beispiel #3
0
 static function orderBy($field, $label)
 {
     $Dispatcher = Dispatcher::getInstance();
     $params = $Dispatcher->getParams();
     $orderby = $field;
     $dir = 'asc';
     $reverse = 'desc';
     $class = '';
     $filter = Config::get('pagination.filter');
     $path = UrlComponent::whitelist(array_remove($filter, array('orderby', 'dir')));
     if (isset($params['orderby']) && $params['orderby'] == $field) {
         $orderby = $params['orderby'];
         if (isset($params['dir']) && $params['dir'] == 'asc') {
             $class = 'class="order-asc"';
             $reverse = 'desc';
         } else {
             $class = 'class="order-desc"';
             $reverse = 'asc';
         }
     }
     return '<a href="' . $path . '/orderby/' . $orderby . '/dir/' . $reverse . '" ' . $class . '>' . $label . '</a>';
 }
<? if (isset($Pager)) : ?>
<? if ($Pager->haveToPaginate()): 
   $range   = $Pager->getRange('Sliding', array('chunk' => Config::get('pagination.chunk')));
   $pages   = $range->rangeAroundPage();
   
   $filter  = Config::get('pagination.filter');
   $path    = UrlComponent::whitelist(array_remove($filter, 'page'));
?>
<ul class="pagination">
<? if ($Pager->getPage() > 1) : ?>
    <li class="previous"><a href="<?php 
echo $path;
?>
/page/<?php 
echo $Pager->getPreviousPage();
?>
">&laquo; Précédente</a></li>
<? else: ?>
    <li class="previous-off">&laquo; Précédente</li>
<? endif ?>
<? if (isset($pages[0]) && $pages[0] > 1) : ?>
   <li><a href="<?php 
echo $path;
?>
/page/1">1</a></li>
<? endif ?>
<? if (isset($pages[0]) && $pages[0] > 2) : ?>
	<li class="more">...</li>
<? endif ?>
<? foreach($pages as $page): ?>
<? if ($page == $Pager->getPage()): ?>
					<?php 
echo FormHelper::text('href', '', array('size' => '100'));
?>
<br />
					<?php 
echo FormHelper::checkbox('target', '_blank', '_blank');
?>
 Ouvrir dans une nouvelle fenêtre
				</div>
				</fieldset>	
				
				<div>
					<input class="button" type="submit" value="Insérer dans l'éditeur"> 
					ou
					<a class="cancel" href="<?php 
echo UrlComponent::path(array('action' => 'insertionIndex'));
?>
">Annuler</a> 
				</div>
			</form>
		
  	</div><!-- #main -->
</div><!-- #content -->

<script src="/admin/js/tinymce/tiny_mce_popup.js"></script>
<script>
//	try {
	$(function() {
		$('form').submit(function() {
			var name		= $('#name').val(),
				path		= $('#path').val(),
Beispiel #6
0
 public function redirect($path = null, $code = null)
 {
     switch ($code) {
         case 301:
             $message = '301 Moved Permanently';
             break;
         case 404:
             $message = '404 Not Found';
             $altpath = '/pages/page404/';
             break;
         case 403:
             $message = '403 Forbidden';
             $altpath = '/pages/page403/';
             break;
         case 500:
             $message = '500 Internal Server Error';
             $altpath = '/pages/page500/';
             break;
         case 503:
             $message = '503 Service Unavailable';
             $altpath = '/pages/page503/';
             break;
     }
     $this->View->setAutorender(false);
     if (isset($message)) {
         //				header($_SERVER['SERVER_PROTOCOL'].' '.$message);
         //				header('Status: '.$message);
     }
     if (isset($altpath) && !$path) {
         $path = $altpath;
     }
     header('location:' . UrlComponent::path($path));
     exit;
 }
Beispiel #7
0
 public function testUrlTranslation()
 {
     $url = UrlComponent::path('/app/controller/action/param/value');
     $this->assertEqual($url, '/application/controlleur/action/param/value');
 }