Skip to content

Commit 67e297c

Browse files
author
James Wigger
authored
Merge pull request #26 from RootStudio/v3.0.0-dev
v3.0.0
2 parents 8f0339c + de837c5 commit 67e297c

30 files changed

+532
-305
lines changed

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# Perch Locator v2.1
1+
# Perch Locator v3.0.0
22

33
Perch Locator is an app to manage locatable resources within Perch CMS. Addresses are Geocoded and can be searched using coordinates or by a valid address to allow users to find places of interest near to them.
44

55
## Installation
66

7+
### Perch 2.x
8+
9+
If you still wish to use this application on Perch 2 please see the [v2.x branch](https://github.com/RootStudio/Perch-Locator/tree/v2.x). All active development will now take place on Perch 3.
10+
711
### Fresh Install
812
Upload the `root_locator` directory to `perch/addons/apps` and add `root_locator` to your `config/apps.php` file.
913

@@ -208,6 +212,43 @@ These are in addition to the ones listed for `perch_content_custom()`.
208212

209213
---
210214

215+
## Locator Field Type
216+
217+
The locator field type can be used to include processed addresses in other Perch content types.
218+
219+
### Installation
220+
221+
Copy the entire `locator` directory to `perch/addons/fieldtypes`.
222+
223+
### Requirements
224+
225+
In order for the field type to work, you must have already installed and configured the main Locator app. This includes setting a Google API key.
226+
227+
### Usage
228+
229+
The locator field type works very similarly to the Pages field type. Including it within your templates will give you a list of geocoded addresses:
230+
231+
```html
232+
<perch:content id="venue" type="locator" label="Venue" />
233+
```
234+
The example above will output the title of the address that is selected.
235+
236+
Additionally, using the `output` attribute, you can include other fields from the address:
237+
238+
```html
239+
<perch:content id="venue" type="locator" label="Venue" output="title" />
240+
<perch:content id="venue" type="locator" label="Venue" output="building" />
241+
<perch:content id="venue" type="locator" label="Venue" output="street" />
242+
<perch:content id="venue" type="locator" label="Venue" output="town" />
243+
<perch:content id="venue" type="locator" label="Venue" output="region" />
244+
<perch:content id="venue" type="locator" label="Venue" output="country" />
245+
<perch:content id="venue" type="locator" label="Venue" output="postcode" />
246+
<perch:content id="venue" type="locator" label="Venue" output="latitude" />
247+
<perch:content id="venue" type="locator" label="Venue" output="longitude" />
248+
```
249+
250+
---
251+
211252
## License
212253

213254
The MIT License (MIT)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
include(__DIR__ . '/lib/vendor/autoload.php');
4+
5+
spl_autoload_register(function ($class_name) {
6+
if (strpos($class_name, 'API_RootLocator') > 0) {
7+
include(PERCH_PATH . '/addons/apps/root_locator/lib/api/' . $class_name . '.class.php');
8+
9+
return true;
10+
}
11+
12+
if (strpos($class_name, 'RootLocator') === 0) {
13+
include(PERCH_PATH . '/addons/apps/root_locator/lib/' . $class_name . '.class.php');
14+
15+
return true;
16+
}
17+
18+
return false;
19+
});
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$this->add_setting('root_locator_address_url', 'Address URL', 'text', '/locations/view.php?s={addressSlug}');
4+
$this->add_setting('root_locator_address_slug', 'Slug format', 'text', '{addressTitle}-{addressPostcode}');
5+
6+
$this->add_setting('root_locator_batch_size', 'Batch Size', 'select', 25, array(
7+
array('label' => '10 Locations', 'value' => 10),
8+
array('label' => '25 Locations', 'value' => 25),
9+
array('label' => '50 Locations', 'value' => 50),
10+
array('label' => '100 Locations', 'value' => 100)
11+
));
12+
13+
$this->add_setting('root_locator_google_api_key', 'API key', 'text');

perch/addons/apps/root_locator/activate.php

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,8 @@
44
exit;
55
}
66

7-
$sql = "
8-
CREATE TABLE `__PREFIX__root_locator_addresses` (
9-
`addressID` int(11) unsigned NOT NULL AUTO_INCREMENT,
10-
`addressTitle` varchar(255) NOT NULL DEFAULT '',
11-
`addressBuilding` varchar(255) DEFAULT '',
12-
`addressStreet` varchar(255) DEFAULT '',
13-
`addressTown` varchar(255) DEFAULT '',
14-
`addressRegion` varchar(255) DEFAULT '',
15-
`addressPostcode` varchar(15) DEFAULT '',
16-
`addressCountry` varchar(3) DEFAULT '',
17-
`addressLatitude` decimal(9,6),
18-
`addressLongitude` decimal(9,6),
19-
`addressError` varchar(255),
20-
`addressDynamicFields` text,
21-
`addressUpdated` datetime NOT NULL,
22-
PRIMARY KEY (`addressID`),
23-
FULLTEXT KEY `root_locator_search_index` (`addressTitle`,`addressBuilding`,`addressStreet`,`addressPostcode`)
24-
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
25-
26-
CREATE TABLE `__PREFIX__root_locator_index` (
27-
`indexID` int(10) NOT NULL AUTO_INCREMENT,
28-
`itemKey` char(64) NOT NULL DEFAULT '-',
29-
`itemID` int(10) NOT NULL DEFAULT '0',
30-
`indexKey` char(64) NOT NULL DEFAULT '-',
31-
`indexValue` char(255) NOT NULL DEFAULT '',
32-
PRIMARY KEY (`indexID`),
33-
KEY `idx_fk` (`itemKey`,`itemID`),
34-
KEY `idx_key` (`indexKey`),
35-
KEY `idx_key_val` (`indexKey`,`indexValue`),
36-
KEY `idx_keys` (`itemKey`,`indexKey`)
37-
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
38-
39-
CREATE TABLE `__PREFIX__root_locator_tasks` (
40-
`taskID` int(11) unsigned NOT NULL AUTO_INCREMENT,
41-
`taskKey` VARCHAR(255) NOT NULL,
42-
`addressID` int(11) unsigned NOT NULL,
43-
`taskAttempt` int(1) unsigned NOT NULL DEFAULT 1,
44-
`taskStart` datetime NOT NULL,
45-
PRIMARY KEY (`taskID`)
46-
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
47-
";
48-
7+
$sql = file_get_contents(__DIR__ . '/sql/schema.sql');
8+
$sql = file_get_contents(__DIR__ . '/sql/3.0.0.sql');
499
$sql = str_replace('__PREFIX__', PERCH_DB_PREFIX, $sql);
5010

5111
// Install

perch/addons/apps/root_locator/admin.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
<?php
22

33
if ($CurrentUser->logged_in() && $CurrentUser->has_priv('root_locator')) {
4-
$this->register_app('root_locator', 'Locator', 1, 'Provide location based listings for your site', '2.1.0');
5-
$this->require_version('root_locator', '2.8.31');
4+
$this->register_app('root_locator', 'Locator', 1, 'Provide location based listings for your site', '3.0.0');
5+
$this->require_version('root_locator', '3.0.3');
66
$this->add_create_page('root_locator', 'edit');
77

8-
$this->add_setting('root_locator_batch_size', 'Batch Size', 'select', 25, array(
9-
array('label' => '10 Locations', 'value' => 10),
10-
array('label' => '25 Locations', 'value' => 25),
11-
array('label' => '50 Locations', 'value' => 50),
12-
array('label' => '100 Locations', 'value' => 100)
13-
));
8+
require __DIR__ . '/_autoload.php';
149

15-
$this->add_setting('root_locator_google_api_key', 'API key', 'text');
10+
require __DIR__ . '/_settings.php';
1611

17-
include(__DIR__ . '/lib/vendor/autoload.php');
18-
19-
spl_autoload_register(function ($class_name) {
20-
if (strpos($class_name, 'RootLocator') === 0) {
21-
include(PERCH_PATH . '/addons/apps/root_locator/lib/' . $class_name . '.class.php');
22-
23-
return true;
24-
}
25-
26-
return false;
27-
});
12+
require __DIR__ . '/_fieldtypes.php';
2813

2914
// Search handler
3015
PerchSystem::register_admin_search_handler('RootLocator_SearchHandler');

perch/addons/apps/root_locator/assets/css/locator.css

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,10 @@
22
display: block;
33
border: 1px dotted #E5E5E5;
44
padding: 5px;
5-
margin: 15px 0 0 240px;
5+
margin: 0 24px 12px 24px;
66
max-width: 100%;
77
}
88

9-
@media screen and (max-width:1060px) {
10-
.sidebar-open .map-preview {
11-
margin-left: 0;
12-
}
13-
}
14-
15-
@media screen and (max-width:840px) {
16-
.sidebar-closed .map-preview {
17-
margin-left: 0;
18-
}
19-
}
20-
219
.status-icon {
2210
display: inline-block;
2311
vertical-align: middle;
@@ -53,9 +41,15 @@
5341
color: #fff;
5442
}
5543

56-
.importables li .status-message {
57-
float: right;
44+
.progress-item .status-message {
45+
display: block;
46+
padding-top: 5px;
5847
font-size: 12px;
5948
font-style: italic;
6049
padding-right: 10px;
6150
}
51+
52+
.progress-item.progress-failure {
53+
background-color: #EBDCDA;
54+
color: #C84043;
55+
}

perch/addons/apps/root_locator/delete/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$Perch->page_title = $Lang->get('Delete Address');
1515

1616
// Page Initialising
17+
include('../modes/_subnav.php');
1718
include('../modes/addresses.delete.pre.php');
1819

1920
// Perch Frame

perch/addons/apps/root_locator/edit/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
$Perch->add_css($API->app_path() . '/assets/css/locator.css');
1818

1919
// Page Initialising
20+
include('../modes/_subnav.php');
2021
include('../modes/addresses.edit.pre.php');
2122

2223
// Perch Frame

perch/addons/apps/root_locator/import/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
$Perch->add_css($API->app_path() . '/assets/css/locator.css');
2020

2121
// Page Initialising
22+
include('../modes/_subnav.php');
2223
include('../modes/import.pre.php');
2324

2425
// Perch Frame

0 commit comments

Comments
 (0)