Exemplo n.º 1
0
 function getEnlacesPaginas($enlace, $pagina = 1)
 {
     $query = new QueryString();
     $parametrosAdd = ['page' => $pagina];
     $parametrosDelete = ['page' => $pagina];
     return $enlace . '?' . $query->getParams($parametrosAdd, $parametrosDelete);
 }
Exemplo n.º 2
0
 /**
  * Parse a query string into a QueryString object
  *
  * @param string $query Query string
  *
  * @return QueryString
  */
 public static function parseQuery($query)
 {
     $q = new QueryString();
     foreach (explode('&', $query) as $kvp) {
         $parts = explode('=', $kvp);
         $key = rawurldecode($parts[0]);
         if (substr($key, -2) == '[]') {
             $key = substr($key, 0, -2);
         }
         $value = array_key_exists(1, $parts) ? rawurldecode($parts[1]) : null;
         $q->add($key, $value);
     }
     return $q;
 }
Exemplo n.º 3
0
 /**
  * Import from an array
  *
  * @param array $array
  *
  * @return Uri
  */
 protected function fromArray($array)
 {
     if (empty($array)) {
         return $this;
     }
     $this->query = new QueryString();
     if (!empty($array['query'])) {
         $this->query->import($array['query']);
     }
     $keys = array('scheme', 'host', 'port', 'user', 'pass', 'path', 'fragment', 'dirname', 'basename', 'extension', 'filename');
     foreach ($keys as $key) {
         if (!isset($array[$key])) {
             continue;
         }
         $this->{$key} = $array[$key];
         if ($key === 'path') {
             $this->parsePath($this->path);
         }
     }
     $this->buildPath();
     return $this;
 }
Exemplo n.º 4
0
 public function testVacant()
 {
     $this->queryString->set('q2', null);
     $this->assertFalse($this->queryString->vacant('q1'));
     $this->assertTrue($this->queryString->vacant('q2'));
 }
Exemplo n.º 5
0
<?php 
        }
    }
    if ($current_page < $total_pages) {
        ?>
  <a href="<?php 
        print $this->url_to(array('query_string' => QueryString::replace('page', $current_page + 1)));
        ?>
">&gt;</a>&nbsp;
<?php 
    }
    if ($current_page < $total_pages - 5) {
        ?>
  <a href="<?php 
        print $this->url_to(array('query_string' => QueryString::replace('page', $current_page + 5)));
        ?>
">&gt;&gt;</a>&nbsp;
<?php 
    }
    if ($current_page < $total_pages) {
        ?>
  <a href="<?php 
        print $this->url_to(array('query_string' => QueryString::replace('page', $total_pages)));
        ?>
">&gt;|</a>&nbsp;
<?php 
    }
    ?>
</div>
<?php 
}
Exemplo n.º 6
0
 /**
  * Get the page sequence of the current link's relation
  *
  * @param string $which The relation of which to extract the page
  * @return int The current page sequence
  */
 function getPage($which)
 {
     if ($link = $this->{"get{$which}"}()) {
         $url = new Url($link, null, 0);
         $qry = new QueryString($url->query);
         return $qry->getInt("page", 1);
     }
     return 1;
 }
Exemplo n.º 7
0
 function Execute($layout_override = NULL, $target_override = NULL, $action_override = NULL, $view_override = NULL, $block_override = NULL)
 {
     // try the application block first
     $block = BlockManager::LoadBlockAt(getcwd());
     $appblock = $block;
     if (!is_null($block_override) && $block_override instanceof WaxBlock) {
         // designate a different block as the holder of the necessary files
         $block = $block_override;
     }
     $router = new QueryString();
     $route = $router->Analyze($_SERVER['QUERY_STRING']);
     $context_name = 'Default';
     if (!is_null($target_override)) {
         $context_name = $target_override;
     } else {
         if (isset($route['context']) && !empty($route['context'])) {
             $context_name = $route['context'];
             unset($route['context']);
         }
     }
     $action = 'index';
     if (!is_null($action_override)) {
         $action = $action_override;
     } else {
         if (isset($route['action']) && !empty($route['action'])) {
             $action = $route['action'];
             unset($route['action']);
         }
     }
     $context = $context_name . "Ctx";
     // verify that the controllercontext is in the same block as the views
     if (!file_exists($block->GetBaseDir() . "/contexts/" . $context . ".php")) {
         throw new TargetContextNotFoundException($context);
     } else {
         if (class_exists($context)) {
             $ctrl = new $context();
             if (!$ctrl instanceof ControllerCtx) {
                 throw new InvalidContextException($context);
             }
         } else {
             throw new TargetContextNotFoundException($context);
         }
     }
     $data_for_view = $ctrl->Execute($action, $route);
     $view_ctx = new ViewRenderCtx();
     $viewname = "{$context_name}/{$action}";
     if (!is_null($view_override)) {
         $viewname = $view_override;
     }
     $content_for_layout = $view_ctx->Execute(new View($block, $viewname), $data_for_view);
     $layoutctx = new LayoutRenderCtx();
     $layout = "layout";
     if (!is_null($layout_override)) {
         $layout = $layout_override;
     }
     try {
         return $layoutctx->Execute(new View($block, $layout), $content_for_layout);
     } catch (ViewNotFoundException $vnfe) {
         return $layoutctx->Execute(new View($appblock, $layout), $content_for_layout);
     }
 }
Exemplo n.º 8
0
 public function timeline()
 {
     $isin = isset($_REQUEST['id']) ? $_REQUEST['id'] : $_REQUEST['isin'];
     $conn = $this->get_connection();
     $transaction_factory = new Transaction();
     $transaction = $transaction_factory->find_all(array('where_clause' => "`isin` = '{$conn->escape($isin)}'", 'order_by' => '`data` ASC', 'limit' => 1))[0];
     if ($transaction) {
         $month_from = date('Y-m-01', strtotime($transaction->data));
     } else {
         $month_from = date('Y-m-01');
     }
     $bond = new Bond();
     $bond->find_by_id($isin);
     // print_r($bond);
     $month_to = date('Y-m-d', mktime(0, 0, 0, date('m', strtotime($bond->scadenza)) + 1, 0, date('Y', strtotime($bond->scadenza))));
     // FIXME: avoid redirects
     $this->redirect_to(array('action' => 'index', 'query_string' => QueryString::from_assoc(array('isin' => $isin, 'month-from' => $month_from, 'month-to' => $month_to))));
 }
Exemplo n.º 9
0
 /**
  * Builds a URL with added/merged query parameters
  * @param array $queryParameters
  */
 public function getUrlForMergedParameters($queryParameters)
 {
     if ($this->hasQueryString()) {
         $querystring = new QueryString($this->getQueryString());
         $querystring->addParameters($queryParameters);
         $queryParameters = $querystring->toArray();
     }
     return $this->getUrlForParameters($queryParameters);
 }
Exemplo n.º 10
0
 protected function pager($count, $limit)
 {
     $pager = '';
     if (!is_null($limit)) {
         $prev = isset($_GET['page']) ? $_GET['page'] - 1 : 0;
         $next = isset($_GET['page']) ? $_GET['page'] + 1 : 2;
         $self = URLs::getInstance()->getURI() . '?' . QueryString::remove('page', $_SERVER['QUERY_STRING']) . '&page=';
         $self = Config::getInstance()->app_root . $self;
         if ($prev > 0) {
             $pager = '<li class="previous"><a href="' . $self . $prev . '">&larr; Newer</a></li>';
         }
         if ($next <= ceil($count / $limit)) {
             $pager .= '<li class="next"><a href="' . $self . $next . '">Older &rarr;</a></li>';
         }
         $pager = '<ul class="pager">' . $pager . '</ul>';
         $pager = '<div class="row"><div class="col-md-12">' . $pager . '</div></div>';
     }
     return $pager;
 }
Exemplo n.º 11
0
 /**
  *  @fn browse
  *  @short Browses an instrument
  *  @details Action to browse an instrument, rendering the graph of the stock
  *  value, as well as specialized views for the instrument type, e.g. issue,
  *  expiration and payment dates for bonds, etc.
  */
 public function browse()
 {
     $conn = $this->get_connection();
     if (!isset($_REQUEST['id'])) {
         $_REQUEST['id'] = $_REQUEST['isin'];
     }
     $this->stock = new Stock();
     if ($this->stock->find_by_id($_REQUEST['id'])) {
         $this->inspect();
         $this->redirect_to(array('action' => 'browse', 'id' => $_REQUEST['id'], 'query_string' => $this->request->querystring, 'after' => 300));
     } else {
         $this->flash('Titolo non trovato. Vuoi aggiungerlo?');
         $this->redirect_to(array('action' => 'add', 'query_string' => QueryString::from_assoc(array('isin' => $_REQUEST['id']))));
     }
 }
Exemplo n.º 12
0
 private function __buildQuery()
 {
     self::$QueryString = http_build_query(self::$QueryStringArray, false, '&', PHP_QUERY_RFC3986);
 }
Exemplo n.º 13
0
    ?>
  </style>
  <div class="by-month">
<?php 
    $month = date('Y-m', strtotime($_REQUEST['month-from']));
    while ($month <= date('Y-m', strtotime($_REQUEST['month-to']))) {
        $month_t = strtotime($month);
        $count = isset($cedole_by_month[$month]) ? $cedole_by_month[$month] : 0;
        $importo = isset($importo_by_month[$month]) ? $importo_by_month[$month] : array();
        ?>
  <div title="<?php 
        printf('%s: %s cedole (%.2f EUR)', $month, $count, $importo);
        ?>
">
    <a href="<?php 
        print $this->url_to(array('query_string' => QueryString::from_assoc(array('month-from' => date('Y-m-d', mktime(0, 0, 0, date('m', $month_t), 1, date('Y', $month_t))), 'month-to' => date('Y-m-d', mktime(0, 0, 0, date('m', $month_t) + 1, 0, date('Y', $month_t)))))));
        ?>
"
      class="month-<?php 
        echo explode('-', $month)[1];
        ?>
 size-<?php 
        echo $month;
        ?>
 <?php 
        if ($month > date('Y-m')) {
            echo 'future';
        }
        ?>
"></a>
    <span><?php 
Exemplo n.º 14
0
?>
">
  <td class="cell10"><input type="checkbox" name="isin[]" value="<?php 
echo $payment->stock->isin;
?>
" /></td>
  <td class="cell10">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
      <tr>
        <td><?php 
print $this->link_to($payment->portfolio_stock->isin, array('controller' => 'titoli', 'action' => 'browse', 'id' => $payment->portfolio_stock->isin));
?>
</td>
        <td>&nbsp;</td>
        <td align="right"><a href="<?php 
echo $this->url_to(array('query_string' => QueryString::from_assoc(array('isin' => $payment->portfolio_stock->isin, 'month-from' => $_REQUEST['month-from'], 'month-to' => $_REQUEST['month-to']))));
?>
"><img src="/img/circled_arrow.png" alt="Filtra" /></a></td>
      </tr>
    </table>
  </td>
  <td class="cell10">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
      <tr>
        <td><?php 
print $this->link_to($payment->stock->title, array('controller' => 'titoli', 'action' => 'browse', 'id' => $payment->stock->isin));
?>
</td>
        <td>&nbsp;</td>
        <td align="right"><?php 
print a('<img src="/img/circled_arrow.png" alt="Modifica" />', array('href' => $this->url_to(array('controller' => 'titoli', 'action' => 'edit', 'id' => $payment->stock->isin))));
Exemplo n.º 15
0
?>
			</td>
			<td>
				<input type="button" onclick="successivo();return false" title="Successivo [N]" value="&rarr;" />
			</td>
		</tr>
	</table>
	<div class="bucket_nw">
		<div class="bucket_ne">
			<div class="bucket_n"></div>
		</div>
	</div>
	<div class="bucket_w">
		<div class="bucket_e">
			<img id="qimg" src="<?php 
print $this->url_to(array('controller' => 'graph', 'action' => 'quotazione', 'id' => @$_REQUEST['id'], 'query_string' => QueryString::from_assoc(array('view' => @$_REQUEST['view'], 'day' => @$_REQUEST['day'], 'month' => @$_REQUEST['month'], 'year' => @$_REQUEST['year']))));
?>
" alt="Grafico" />

			<p style="text-align:right;margin:0">
				<label for="f_day">Periodo:</label>
				<input type="button" value="&larr;" onclick="prima()" title="Indietro [&larr;]" />
<?php 
$days = array();
for ($i = 1; $i <= 31; $i++) {
    $days[$i] = $i;
}
print select('day', $days, isset($_REQUEST['day']) && !empty($_REQUEST['day']) ? $_REQUEST['day'] : date("d"), array('id' => 'f_day', 'onchange' => "this.form.submit()"));
$months = array();
for ($i = 1; $i <= 12; $i++) {
    $months[$i] = date("F", mktime(0, 0, 0, $i, 1, 0));
Exemplo n.º 16
0
 protected function pager($model)
 {
     $pager = '';
     if (!array_key_exists('paging', $model->config) || $model->config['paging']) {
         if (!is_null($model->limit)) {
             $prev = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] - 1 : 0;
             $next = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] + 1 : 2;
             $self = URLs::getInstance()->getURI() . '?' . QueryString::remove('page', $_SERVER['QUERY_STRING']) . '&page=';
             $self = Config::getInstance()->app_root . $self;
             if ($prev > 0) {
                 $pager = '<li class="previous"><a href="' . $self . $prev . '"><i class="fa fa-chevron-left"></i> Newer</a></li>';
             }
             if ($next <= ceil($model->count / $model->limit)) {
                 $pager .= '<li class="next"><a href="' . $self . $next . '">Older <i class="fa fa-chevron-right"></i></a></li>';
             }
             $pager = '<ul class="pager">' . $pager . '</ul>';
             $pager = '<div class="row"><div class="col-md-12">' . $pager . '</div></div>';
         }
     }
     return $pager;
 }