Example #1
0
 /**
  * Calculates the charge and delivery time for
  * a parcel.
  * 
  * @param	array	$parcel
  * @throws	Kohana_Exception
  * @return	array	Delivery charge and number of days
  */
 public static function delivery_info($parcel)
 {
     // Check required fields exist
     foreach (Kohana::config('auspost.fields') as $key) {
         if (!array_key_exists($key, $parcel)) {
             throw new Kohana_Exception('Missing key in $parcel array: ' . $key);
         }
     }
     // Build URL
     $url = Kohana::config('auspost.url') . url::query($parcel, FALSE);
     // Retrieve URL
     $response = Request::factory($url)->execute()->body();
     // Split into lines
     $lines = explode("\r\n", trim($response));
     // Split lines into key / value pairs
     $data = array();
     foreach ($lines as $line) {
         list($key, $val) = explode("=", $line);
         $data[$key] = $val;
     }
     // Return Data
     return $data;
 }
Example #2
0
 public static function queryToString($query = null)
 {
     if (is_null($query)) {
         $query = url::query();
     }
     return http_build_query($query);
 }
Example #3
0
<?php

defined('SYSPATH') or die('No direct script access.');
/**
 * @version SVN: $Id:$
 */
echo form::input($name, $value);
?>
<script type="text/javascript">
$(document).ready(function(){
	$('[name=<?php 
echo $name;
?>
]').autocomplete( {
		source: '<?php 
echo url::query(array('select_autocomplete' => $name));
?>
',
		mustMatch: true
	});
});
</script>
Example #4
0
echo url::base(FALSE, 'ftp');
?>

<br/>

<?php 
echo url::site('controller/action');
?>

<br/>

<?php 
echo url::site('controller/action', 'ftp');
?>

<br/>

<?php 
echo url::query();
?>

<br/>

<?php 
echo url::query(array('bar' => 'foo'));
?>

<br/>

<?php 
echo url::title('This is my title');
Example #5
0
 /**
  * Handles test running interface
  */
 public function action_run()
 {
     $this->template->body = View::factory('unittest/results');
     // Get the test suite and work out which groups we're testing
     $suite = Unittest_tests::suite();
     $group = (array) Arr::get($_GET, 'group', array());
     // Stop phpunit from interpretting "all groups" as "no groups"
     if (empty($group) or empty($group[0])) {
         $group = array();
     }
     // Only collect code coverage if the user asked for it
     $collect_cc = (bool) Arr::get($_GET, 'collect_cc', FALSE);
     if ($collect_cc and Arr::get($_GET, 'use_whitelist', FALSE)) {
         $whitelist = $this->whitelist(Arr::get($_GET, 'whitelist', array()));
     }
     $runner = new Kohana_Unittest_Runner($suite);
     try {
         $runner->run($group, $collect_cc);
         if ($collect_cc) {
             $this->template->body->set('coverage', $runner->calculate_cc_percentage());
         }
         if (isset($whitelist)) {
             $this->template->body->set('coverage_explanation', $this->nice_whitelist_explanation($whitelist));
         }
     } catch (Kohana_Exception $e) {
         // Code coverage is not allowed, possibly xdebug disabled?
         // TODO: Tell the user this?
         $runner->run($group);
     }
     // Show some results
     $this->template->body->set('results', $runner->results)->set('totals', $runner->totals)->set('time', $this->nice_time($runner->time))->set('group', Arr::get($this->get_groups_list($suite), reset($group), 'All groups'))->set('groups', $this->get_groups_list($suite))->set('run_uri', $this->request->uri())->set('report_uri', $this->report_uri . url::query())->set('whitelistable_items', $this->get_whitelistable_items())->set('whitelisted_items', isset($whitelist) ? array_keys($whitelist) : array())->set('whitelist', !empty($whitelist));
 }
Example #6
0
 /**
  * Returns a page url for any given page number
  * 
  * @param int $page The page number
  * @return string The url
  */
 public function pageURL($page)
 {
     if ($this->options['method'] == 'query') {
         $query = url::query();
         if ($page == 1) {
             unset($query[$this->options['variable']]);
         } else {
             $query[$this->options['variable']] = $page;
         }
         return url::build(array('query' => $query));
     } else {
         $params = url::params();
         if ($page == 1) {
             unset($params[$this->options['variable']]);
         } else {
             $params[$this->options['variable']] = $page;
         }
         return url::build(array('params' => $params));
     }
 }
Example #7
0
 public function query()
 {
     return new Request\Query(url::query());
 }