Пример #1
0
function display_todos($items)
{
    foreach ($items as $todo) {
        ?>
        <div>
        <?php 
        echo Form::checkbox('done', $todo->done, 'onclick="document.location.href=\'' . URL::create('todo', 'checkbox', array('id' => $todo->id)) . '\'"');
        ?>
                                
        <?php 
        echo $todo->description;
        ?>
        
        <?php 
        echo $todo->project->name;
        ?>
                    
        <a href="<?php 
        echo URL::create('todo', 'edit', array('id' => $todo->id));
        ?>
">Edit</a>
        <a 
            href="<?php 
        echo URL::create('todo', 'delete', array('id' => $todo->id));
        ?>
" 
            onclick="return confirm('Are you sure you want to delete this entry: <?php 
        echo $todo->description;
        ?>
');"
        >
        Distroy
        </a>

        </div>
        <br />
    <?php 
    }
}
Пример #2
0
 public static function redirect($controller, $action = null, array $args = array(), array $params = array(), $hard = false)
 {
     if (stristr($controller, 'http://') || stristr($controller, 'https://')) {
         //if page is a URL, then set $url as page
         $url = $controller;
     } else {
         //if page is NOT a URL, then set  generate a $url from page
         $url = URL::create($controller, $action, $args, $params);
     }
     Util::redirect($url, $hard);
     exit;
 }
Пример #3
0
 public function filter($action, array $args = array())
 {
     $this->action = $action;
     $this->args = $args ? $args : array();
     $this->extension = "json";
     $this->url = URL::create($this->slug, null, $this->args);
     $this->fullURL = URL::create($this->slug, null, $this->args, $this->get->toArray());
     // Remove empty values from the args array
     foreach ($this->args as $key => $arg) {
         if (empty($arg) || $arg == '') {
             unset($this->args[$key]);
         }
     }
     if (!in_array(strtolower($this->action), array('post', 'get', 'put', 'delete'))) {
         throw new RESTException("Invalid API verb: {$this->action}. Choose either 'POST', 'GET', 'PUT', 'DELETE'");
     }
     // Return a 404 for methods that don't exist
     if (!method_exists($this, $this->action)) {
         $this->status = 404;
         $this->message = "Method '{$this->action}' not supported on this resource";
     }
     // Hack PHP into supporting DELETE and PUT verbs
     // (Merge in the POST array because clients that don't support
     //  all of the RESTful verbs are going to POST to use PUT)
     if ($this->useDataStream && in_array(strtolower($this->action), array('delete', 'put'))) {
         $data = array();
         parse_str(file_get_contents('php://input'), $data);
         $this->{$action}->update(array_merge($this->post->toArray(), $data));
     }
     if ($this->beforeFilter() === false) {
         return;
     }
     call_user_method_array($this->action, $this, $this->args);
     if ($this->afterFilter() === false) {
         return;
     }
     $this->render();
 }
Пример #4
0
<form action="<?= URL::create('Match', 'process'); ?>" method="post" enctype="multipart/form-data">
	<label for="repository">GitHub Repository URL:</label>
	<input type="text" name="repository" id="repository" />
	<p id="or">- or -</p>
	<label for="file">Upload File:</label>
	<input type="file" name="file" id="file" />
	
	<input type="submit" name="search" value="Match" />
</form>
Пример #5
0
 public function get($uri, $params = null)
 {
     $url = \URL::create($uri, $params, $this->options['baseUrl']);
     return new RequestWrapper($this->getClient()->get($url, $this->getDefaultHeaders())->send());
 }
Пример #6
0
        <div class="container-fluid">
            <div class="row">
                <?php 
if (f('auth.authorize', '/menu')) {
    ?>
                <div class="col-sm-3 col-md-2 sidebar">
                    <ul class="nav nav-sidebar">
                        <?php 
    if (!empty($app->theme->options['menu'])) {
        ?>
                        <?php 
        foreach ($app->theme->options['menu'] as $menu) {
            ?>
                        <li><a href="<?php 
            echo URL::create($menu['url']);
            ?>
"><?php 
            echo $menu['label'];
            ?>
</a></li>
                        <?php 
        }
        ?>
                        <?php 
    }
    ?>
                    </ul>
                </div>
                <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                    <?php 
Пример #7
0
<ul>
	<li><a href="<?= URL::create(); ?>">Home</a></li>
	<li><a href="<?= URL::create('Landing', 'About'); ?>">About</li>
	<li><a href="mailto:nicky.leach@nyu.edu">Contact</a></li>
</ul>
Пример #8
0
	public static function redirect($controller, $action = null, $args = null, $params = null, $hard = false){
		$url = URL::create($controller, $action, $args, $params);
		
		// do actual redirect
		if($hard){
			header('HTTP/1.1 301 Moved Permanently');
		} else {
			header('Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0  ');
			header('Pragma: no-cache ');	   
		}
		
		header('Location: ' . $url);
		
		exit;
	}
Пример #9
0
 /**
  * Validate the requested URL. This will check if a secured hash is provided for the current URI.
  *
  * @param string|null $secret
  * @return bool
  */
 public static function validate($secret = null)
 {
     return URL::create(self::getRequestUri(), $_GET)->isValid($secret);
 }