Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/152-links
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Janssens committed Dec 28, 2015
2 parents 20814f4 + 9417a42 commit c54dff9
Show file tree
Hide file tree
Showing 81 changed files with 613 additions and 269 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Screenshot](https://dl.dropboxusercontent.com/u/77404/timble/police/github/devices.jpg)
![Screenshot](screenshot.jpg)

# Belgian Police Internet Platform

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* @author Johan Janssens <http://nooku.assembla.com/profile/johanjanssens>
* @package Component\Activities
*/
class ActivitiesControllerPermissionDefault extends ApplicationControllerPermissionAbstract
class ActivitiesControllerPermissionActivity extends ApplicationControllerPermissionAbstract
{
public function canAdd()
{
return false;
return false;
}

public function canEdit()
{
return false;
{
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>

<head>
<base href="<?= url(); ?>" />
<base href="<?= escape(url()); ?>" />
<title><?= title().' - '. translate( 'Administration'); ?></title>

<meta content="text/html; charset=utf-8" http-equiv="content-type" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function render()
$model = $this->getModel();
$district = $model->getRow();

if(!$district->districts_district_id)
if(!$district->isNew())
{
$officers = $this->getObject('com:districts.model.districts_officers')
->district($district->id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<form action="" method="post" class="-koowa-form">
<div class="main">
<div class="title">
<input id="title" class="required" type="text" name="title" size="32" maxlength="250" value="<?= $district->title; ?>" />
<input id="title" class="required" type="text" name="title" size="32" maxlength="250" value="<?= $district->title; ?>" placeholder="<?= translate('Title') ?>" />
</div>

<div class="scrollable">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div>
<label for="tracking_number"><?= translate('Tracking number') ?></label>
<div>
<input type="text" name="tracking_number" value="<?= $item->tracking_number ?>" class="required" />
<input type="text" name="tracking_number" value="<?= $item->tracking_number ?>" class="required validate-digits" />
</div>
</div>
<div>
Expand Down
2 changes: 1 addition & 1 deletion application/admin/component/streets/model/streets.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
$languages = $this->getObject('application.languages');
$site = $this->getObject('application')->getSite();

if (!in_array($site, array('default', 'fed'))) {
if (!in_array($site, array('default', 'fed', '5806'))) {
$query->where('tbl.iso = :iso')->bind(array('iso' => $languages->getActive()->slug));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<form action="" method="post" class="-koowa-form">
<div class="main">
<div class="title">
<input disabled class="required" type="text" name="title" maxlength="255" value="<?= $street->title ?>" placeholder="<?= translate('Title') ?>" />
<input disabled class="required" type="text" name="title" maxlength="255" value="<?= escape($street->title) ?>" placeholder="<?= translate('Title') ?>" />
</div>

<div class="scrollable">
Expand All @@ -40,7 +40,7 @@
<?= translate( 'ISLP' ); ?>
</label>
<div>
<input type="text" name="islp" class="required" value="<?= $street->islp ?>" />
<input type="text" name="islp" class="required" value="<?= escape($street->islp) ?>" />
</div>
</div>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<a href="<?= route( 'view=article&task=edit&id='.$article->id ); ?>">
<?= escape($article->title) ?>
</a>
<? if($article->controlled && $article->in_violation) : ?>
<? if($article->controlled) : ?>
<span class="label label-info"><?= translate('Results') ?></span>
<? endif ?>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>

<head>
<base href="<?= url(); ?>" />
<base href="<?= escape(url()); ?>" />
<title><?= title().' - '. translate( 'Administration'); ?></title>

<meta content="text/html; charset=utf-8" http-equiv="content-type" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>

<head>
<base href="<?= url(); ?>" />
<base href="<?= escape(url()); ?>" />
<title><?= title().' - '. translate( 'Administration'); ?></title>

<meta content="text/html; charset=utf-8" http-equiv="content-type" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public function language($config = array())
$options[] = $this->option(array('label' => $this->translate( 'French' ) , 'value' => '2' ));
$options[] = $this->option(array('label' => $this->translate( 'Dutch & French' ), 'value' => '3' ));
$options[] = $this->option(array('label' => $this->translate( 'German' ), 'value' => '4' ));

$options[] = $this->option(array('label' => $this->translate( 'Dutch, French & German' ), 'value' => '7' ));

//Add the options to the config object
$config->options = $options;

Expand Down
74 changes: 74 additions & 0 deletions application/manager/component/streets/model/streets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* Belgian Police Web Platform - Streets Component
*
* @copyright Copyright (C) 2012 - 2013 Timble CVBA. (http://www.timble.net)
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link https://github.com/belgianpolice/internet-platform
*/

use Nooku\Library;

class StreetsModelStreets extends Library\ModelTable
{
public function __construct(Library\ObjectConfig $config)
{
parent::__construct($config);

$this->getState()
->insert('city' , 'int')
->insert('no_islp' , 'int')
->insert('title' , 'string')
->insert('sort' , 'cmd', 'title');
}

protected function _buildQueryColumns(Library\DatabaseQuerySelect $query)
{
parent::_buildQueryColumns($query);
$state = $this->getState();

$cities = $this->getObject('com:police.model.zones')->id($this->getObject('application')->getSite())->getRow()->cities;

$query->columns(array(
'title' => $cities !== '1' ? "CONCAT(tbl.title,' (',city.title,')')" : 'tbl.title',
'title_short' => 'tbl.title',
'city' => 'city.title',
'islp' => 'islps.islp'
));
}

protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
{
$state = $this->getState();

$languages = $this->getObject('application.languages');
$language = $languages->getActive()->slug;

// Join the ISLP ID
$query->join(array('islps' => 'data.streets_streets_islps'), 'islps.streets_street_identifier = tbl.streets_street_identifier');

$query->join(array('city' => $language == 'fr' ? 'data.fr-be_streets_cities' : 'data.streets_cities'), 'city.streets_city_id = tbl.streets_city_id');

parent::_buildQueryJoins($query);
}

protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
{
parent::_buildQueryWhere($query);
$state = $this->getState();

$site = $this->getObject('application')->getSite();

if ($state->search) {
$query->where('(tbl.title LIKE :search OR islps.islp LIKE :search OR tbl.streets_street_id LIKE :search)')->bind(array('search' => '%' . $state->search . '%'));
}

if ($state->city) {
$query->where('tbl.streets_city_id = :city')->bind(array('city' => $state->city));
}

if ($state->no_islp) {
$query->where('islps.islp IS NULL');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<form action="" method="post" class="-koowa-form">
<div class="main">
<div class="title">
<input disabled class="required" type="text" name="title" maxlength="255" value="<?= $street->title ?>" placeholder="<?= translate('Title') ?>" />
<input disabled class="required" type="text" name="title" maxlength="255" value="<?= escape($street->title) ?>" placeholder="<?= translate('Title') ?>" />
</div>

<div class="scrollable">
Expand All @@ -40,7 +40,7 @@
<?= translate( 'ISLP' ); ?>
</label>
<div>
<input type="text" name="islp" class="required" value="<?= $street->islp ?>" />
<input type="text" name="islp" class="required" value="<?= escape($street->islp) ?>" />
</div>
</div>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>

<head>
<base href="<?= url(); ?>" />
<base href="<?= escape(url()); ?>" />
<title><?= title() ?></title>

<meta content="text/html; charset=utf-8" http-equiv="content-type" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<? if($item->file->isImage()) : ?>
<img width="140" class="thumbnail" src="attachments://<?= $item->path ?>" />
<? endif ?>
<? else : ?>
<? elseif(!($officer->phone || $officer->mobile || $officer->email || $district->email)) : ?>
<img width="140" class="thumbnail" src="assets://districts/images/placeholder.png" />
<? endif ?>
<? endif ?>
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@
*/
?>

<?
$languages = $this->getObject('application.languages');
$language = $languages->getActive();
?>

<style src="assets://application/components/select2/select2.css" />

<script src="assets://application/components/jquery/dist/jquery.min.js" />
<script src="assets://application/components/select2/select2.js" />
<script src="assets://application/js/ie7.js" condition="if lte IE 7" />

<h1 class="article__header"><?= escape($params->get('page_title')); ?></h1>

<? if ($category->image || $category->description) : ?>
Expand All @@ -30,104 +19,6 @@
</div>
<? endif; ?>

<style>
.select2-offscreen[required], .select2-offscreen[required]:focus {
width: inherit !important;
height: inherit !important;
left: 0 !important;
top: 0px !important;
}
.contenedor-select2 {
position: relative;
}
</style>

<script data-inline>
$(document).ready(function() {
function format(item) { return item.title; };
$("#autocomplete__streets").select2({
placeholder: "<?= translate('Search your street') ?> ...",
minimumInputLength: 3,
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
url: "?view=streets&format=json&district=1",
dataType: 'json',
data: function (term) {
return {
search: term, // search term
page_limit: 10
};
},
results: function (data) { // parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to alter remote JSON data
var results = [];
$.each(data.items, function(i, item) {
results.push({"title": item.data.title, "id": item.data.streets_street_identifier});
});
return {results: results};
}
},
initSelection: function(element, callback) {
// the input tag has a value attribute preloaded that points to a preselected movie's id
// this function resolves that id attribute to an object that select2 can render
// using its formatResult renderer - that way the movie name is shown preselected
var id=$(element).val();
if (id!=="") {
$.ajax("?option=com_streets&view=streets&format=json&iso=<?= $language->slug ?>&source=1&identifier="+id, {
dataType: "json"
}).done(function(data) { callback(data.items[0].data); });
}
},
formatResult: format, // omitted for brevity, see the source of this page
formatSelection: format, // omitted for brevity, see the source of this page
dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
formatInputTooShort: false,
formatSearching: function () { return "<?= translate('Please wait') ?> ..."; },
formatNoMatches: function () { return "<?= translate('No matches found') ?>"; }
});
});
</script>

<div class="well">
<form action="" method="get" class="-koowa-form">
<div class="form__group<?= is_null($state->street) ? ' has-error' : '' ?>">
<label class="form__label" for="street"><?= @translate('Street') ?><sup>*</sup>:</label>
<div class="contenedor-select2">
<input required type="text" class="bigdrop form__input" id="autocomplete__streets" placeholder="<?= @translate('Search your street') ?> ..." tabindex="1" name="street" value="<?= $state->street != '0' ? $state->street : '' ?>">
</div>
</div>
<div class="form__group<?= !is_numeric($state->number) || is_null($state->number) ? ' has-error' : '' ?>">
<label class="form__label" for="number"><?= @translate('Street number') ?><sup>*</sup>:</label>
<input required class="form__input" type="number" min="1" placeholder="<?= @translate('Street number') ?>" tabindex="2" id="number" name="number" value="<?= $state->number != '0' ? $state->number : '' ?>">
<? if(is_null($state->number)) : ?>
<span class="form__feedback"><?= @translate('This field is required') ?>.</span>
<? elseif(!is_numeric($state->number)) : ?>
<span class="form__feedback"><?= @translate('Only numbers are allowed') ?>.</span>
<? endif ?>
</div>
<button type="submit" class="button button--primary" tabindex="3"><?= translate('Search') ?></button>
</form>
</div>

<? if ($state->street && is_numeric($state->number)) : ?>
<? if(count($relations)) : ?>
<ul>
<? foreach ($relations as $relation) : ?>
<li>
<a href="<?= helper('route.district', array('row' => $relation, 'state' => $state)) ?>">
<?= $relation->street ?> <?= helper('string.street', array('row' => $relation)) ?>
</a>
</li>
<? endforeach; ?>
</ul>
<?= helper('com:application.paginator.pagination', array('total' => $total, 'show_count' => false, 'show_limit' => false)) ?>
<? else : ?>
<h2 role="alert" style="text-align: center;margin: 60px 0"><?= translate('No neighbourhood officer found') ?>.</h2>
<? $zone = object('com:police.model.zone')->id($this->getObject('application')->getCfg('site' ))->getRow() ?>
<? $email = str_replace("@", "&#64;", $zone->email) ?>
<? $email = str_replace(".", "&#46;", $email) ?>

<div class="well well--small text-center">
<?= translate('Contact us at') ?> <a href="mailto:<?= $email ?>"><?= $email ?></a><? if($zone->phone_information) : ?> <?= translate('or') ?> <span class="nowrap"><?= $zone->phone_information ?></span><? endif ?>.
</div>
<? endif ?>
<? if(object('application')->getCfg('site') != '5455') : ?>
<?= import('default_search.html'); ?>
<? endif ?>
Loading

0 comments on commit c54dff9

Please sign in to comment.