Skip to content

Commit

Permalink
Cleaned up hard coded URL strings
Browse files Browse the repository at this point in the history
I did a search for BASE_URL and BASE_URI to find all the URLs that were pplain strings.  I think this covers all of the URLs that should have referenced the new routes.

Updates #281
  • Loading branch information
inghamn committed May 22, 2020
1 parent 3c16e4f commit 44cfdef
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 34 deletions.
6 changes: 3 additions & 3 deletions blocks/html/applicants/updateForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ $title = $id ? $this->_('applicant_edit') : $this->_('applicant_add');

foreach ($this->applicant->getFiles() as $f) {
$file_id = $f->getId();
$uri = BASE_URI.'/files/download?file_id='.$file_id;
$filename = self::escape($m->getFilename());
$filename = "<a href=\"$uri\" class=\"{$m->getMime_type()}\">$filename</a>";
$uri = parent::generateUri('applicantFiles.download').'?applicantFile_id='.$file_id;
$filename = self::escape($f->getFilename());
$filename = "<a href=\"$uri\" class=\"{$f->getMime_type()}\">$filename</a>";
echo "
<dl><dt><label for=\"applicantFile_$file_id\">$filename</label></dt>
<dd><input type=\"file\" name=\"applicantFile[$file_id]\" id=\"applicantFile_$file_id\" accept=\"$accept\" /></dd>
Expand Down
2 changes: 1 addition & 1 deletion blocks/html/committees/endDateForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<header>
<h1><?= $this->_('committee_end'); ?></h1>
</header>
<form method="post" action="<?= BASE_URI; ?>/committees/end">
<form method="post">
<fieldset>
<input name="committee_id" type="hidden" value="<?= $this->committee->getId(); ?>" />

Expand Down
2 changes: 1 addition & 1 deletion blocks/html/departments/updateForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $title = $this->department->getId() ? $this->_('department_edit') : $this->_('de
<header>
<h1><?= $title; ?></h1>
</header>
<form method="post" action="<?= BASE_URI; ?>/departments/update">
<form method="post">
<fieldset><legend><?= $name; ?></legend>
<input name="department_id" type="hidden" value="<?= $this->department->getId(); ?>" />
<?php
Expand Down
8 changes: 4 additions & 4 deletions blocks/html/errorMessages/notLoggedIn.inc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* @copyright 2018 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @copyright 2018-2020 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
*/
declare (strict_types=1);
$loginUrl = BASE_URI.'/login?return_url='.$_SERVER['REQUEST_URI'];

$h = $this->template->getHelper('buttonLink');
$button = $h->buttonLink(
BASE_URI.'/login?return_url='.$_SERVER['REQUEST_URI'],
parent::generateUri('login.index').'?return_url='.$_SERVER['REQUEST_URI'],
$this->_('login'),
'login'
);
Expand Down
6 changes: 3 additions & 3 deletions blocks/html/meetingFiles/addForm.inc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
/**
* @copyright 2017 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @copyright 2017-2020 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @param string $this->type
* @param Committee $this->committee
* @param string $this->eventId
* @param DateTime $this->date
*/
use Web\Url;
?>
<form method="post" action="<?= BASE_URI; ?>/meetingFiles/update" enctype="multipart/form-data">
<form method="post" enctype="multipart/form-data">
<fieldset>
<input name="committee_id" type="hidden" value="<?= $this->committee->getId(); ?>" />
<input name="eventId" type="hidden" value="<?= $this->eventId; ?>" />
Expand Down
2 changes: 1 addition & 1 deletion blocks/html/people/list.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use Web\Url;
<?php
if (Person::isAllowed('people', 'update')) {
// Preserve any extra parameters passed in
$url = new Url(BASE_URL.'/people/update');
$url = new Url(parent::generateUrl('people.update'));
$fields = ['firstname', 'lastname', 'email'];
foreach ($_REQUEST as $key=>$value) {
if (!in_array($key, $fields)) { $url->$key = $value; }
Expand Down
4 changes: 1 addition & 3 deletions blocks/html/seats/list.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ $title = $this->title ? self::escape($this->title) : $this->_(['seat', 'seats',
$code = self::escape($seat->getCode());
$name = self::escape($seat->getName());
$appointer = self::escape($seat->getAppointer());
$uri = BASE_URI."/seats/view?seat_id=$seat_id";


$uri = parent::generateUri('seats.view')."?seat_id=$seat_id";
echo "
<tr><td>$editButton</td>
<td>$code</td>
Expand Down
2 changes: 1 addition & 1 deletion blocks/html/terms/updateForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $helper = $this->template->getHelper('field');
<header>
<h1><?= $title; ?></h1>
</header>
<form method="post" action="<?= BASE_URI; ?>/terms/update" >
<form method="post">
<input name="term_id" type="hidden" value="<?= $this->term->getId(); ?>" />
<input name="seat_id" type="hidden" value="<?= $this->term->getSeat_id(); ?>" />
<?php
Expand Down
2 changes: 1 addition & 1 deletion blocks/html/users/list.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use Web\Url;
if ($userCanEdit) {
$helper = $this->template->getHelper('buttonLink');
echo $helper->buttonLink(
BASE_URI.'/users/update',
parent::generateUri('users.update'),
$this->translate('create_account'),
'add'
);
Expand Down
7 changes: 4 additions & 3 deletions blocks/txt/liaisons/applicationNotification.inc
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
/**
* @copyright 2017 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @copyright 2017-2020 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE
* @param Application $this->application
*/
declare (strict_types=1);
use Web\View;

$committee = $this->application->getCommittee()->getName();
$committee_id = $this->application->getCommittee_id();
$person = $this->application->getApplicant()->getFullname();
$message = sprintf($this->template->_('board_application_message', 'messages'), $person, $committee);
$url = BASE_URL.'/committees/applications?committee_id='.$committee_id;
$url = View::generateUrl('committees.applications').'?committee_id='.$committee_id;

echo "
$message
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Controllers/ApplicantsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function delete(): View

if (isset($applicant)) {
$applicant->delete();
header('Location: '.BASE_URL.'/applicants');
header('Location: '.View::generateUrl('applicants.index'));
exit();
}
else {
Expand Down
4 changes: 3 additions & 1 deletion src/Application/Models/Legislation/Legislation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Web\ActiveRecord;
use Web\Database;
use Web\View;

class Legislation extends ActiveRecord
{
Expand Down Expand Up @@ -229,9 +230,10 @@ public function toArray()
}

$files = [];
$url = View::generateUrl('legislationFiles.download');
foreach ($this->getFiles() as $f) {
$files[] = [
'url' => BASE_URL.'/legislationFiles/download?id='.$f->getId()
'url' => $url.'?legislationFile_id='.$f->getId()
];
}

Expand Down
5 changes: 3 additions & 2 deletions src/Application/Models/MeetingFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Web\ActiveRecord;
use Web\Database;
use Web\View;

class MeetingFile extends File
{
Expand Down Expand Up @@ -149,6 +150,6 @@ public function getEvent()
/**
* @return string
*/
public function getDownloadUrl() { return BASE_URL.'/meetingFiles/download?meetingFile_id='.$this->getId(); }
public function getDownloadUri() { return BASE_URI.'/meetingFiles/download?meetingFile_id='.$this->getId(); }
public function getDownloadUrl() { return View::generateUrl('meetingFiles.download').'?meetingFile_id='.$this->getId(); }
public function getDownloadUri() { return View::generateUri('meetingFiles.download').'?meetingFile_id='.$this->getId(); }
}
5 changes: 3 additions & 2 deletions src/Application/Models/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Web\ActiveRecord;
use Web\Database;
use Web\View;
use Web\Auth\ExternalIdentity;

class Person extends ActiveRecord
Expand Down Expand Up @@ -291,8 +292,8 @@ public function getFullname()
/**
* @return string
*/
public function getUrl() { return BASE_URL.'/people/view?person_id='.$this->getId(); }
public function getUri() { return BASE_URI.'/people/view?person_id='.$this->getId(); }
public function getUrl() { return View::generateUrl('people.view').'?person_id='.$this->getId(); }
public function getUri() { return View::generateUrl('people.view').'?person_id='.$this->getId(); }

/**
* @return Laminas\Db\ResultSet
Expand Down
9 changes: 2 additions & 7 deletions src/Application/Models/Reports/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Application\Models\Committee;
use Application\Models\File;
use Web\ActiveRecord;
use Web\View;

class Report extends File
{
Expand Down Expand Up @@ -64,20 +65,14 @@ public function setCommittee (Committee $o) { parent::setForeignKeyObject('\Appl

//----------------------------------------------------------------
//----------------------------------------------------------------
/**
* @return string
*/
public function getDownloadUrl() { return BASE_URL.'/reports/download?id='.$this->getId(); }
public function getDownloadUri() { return BASE_URI.'/reports/download?id='.$this->getId(); }

public function toArray()
{
return [
'id' => (int)$this->getId(),
'committee' => $this->getCommittee()->getName(),
'title' => $this->getTitle(),
'date' => $this->getReportDate(),
'url' => $this->getDownloadUrl()
'url' => View::generateUrl('reports.download').'?report_id='.$this->getId()
];
}
}

0 comments on commit 44cfdef

Please sign in to comment.