Skip to content
Permalink
Browse files

finished implementation of field notes feature, removed test controll…

…er and template, add translation handling
  • Loading branch information...
mirsch committed Jun 17, 2016
1 parent 00c8091 commit 50a776f1c7d45c0ded61b21a5328ac816a42507e
Showing with 1,439 additions and 222 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 Vagrantfile
  3. +5 −0 bin/provision.sh
  4. +22 −4 htdocs/app/AppKernel.php
  5. +4 −0 htdocs/app/Migrations/Version20160607213541.php
  6. +6 −0 htdocs/app/Resources/translations/constants.en.yml
  7. +0 −14 htdocs/app/Resources/translations/messages.de.xlf
  8. +55 −0 htdocs/app/Resources/translations/messages.en.yml
  9. +0 −13 htdocs/app/Resources/views/default/index.html.twig
  10. +49 −26 htdocs/app/Resources/views/field-notes/index.html.twig
  11. +32 −0 htdocs/app/Resources/views/macros/geocache.twig
  12. +10 −0 htdocs/app/config/config.yml
  13. +15 −0 htdocs/app/config/services.yml
  14. +3 −1 htdocs/composer.json
  15. +173 −2 htdocs/composer.lock
  16. +11 −0 htdocs/crowdin.yaml
  17. +55 −4 htdocs/log.php
  18. +7 −0 htdocs/resource2/ocstyle/css/style_screen.css
  19. +73 −66 htdocs/resource2/ocstyle/js/tools.js
  20. +60 −11 htdocs/src/AppBundle/Controller/FieldNotes/FieldNotesController.php
  21. +0 −52 htdocs/src/AppBundle/Controller/SymfonyTestController.php
  22. +5 −0 htdocs/src/AppBundle/Entity/FieldNote.php
  23. +19 −4 htdocs/src/AppBundle/Entity/Geocache.php
  24. +608 −0 htdocs/src/AppBundle/Entity/GeocacheLog.php
  25. +2 −2 htdocs/src/AppBundle/Entity/User.php
  26. +42 −0 htdocs/src/AppBundle/Form/DataProvider/UploadFieldNotesDataProvider.php
  27. +54 −1 htdocs/src/AppBundle/Form/UploadFieldNotesType.php
  28. +0 −4 htdocs/src/AppBundle/Legacy/User/LegacyUser.php
  29. +57 −17 htdocs/src/AppBundle/Service/FieldNoteService.php
  30. +16 −0 htdocs/src/AppBundle/Service/Interfaces/ErrorInterface.php
  31. +32 −0 htdocs/src/AppBundle/Service/Interfaces/FieldNoteServiceInterface.php
  32. +20 −0 htdocs/src/AppBundle/Util/DateUtil.php
  33. +1 −0 htdocs/templates2/ocstyle/log_cache.tpl
@@ -49,3 +49,5 @@
Thumbs.db
/bin/phpzip.php
parameters.yml
.crowdin.yaml
htdocs/app/Resources/translations
@@ -2,7 +2,7 @@
# vi: set ft=ruby :

VM_IP = "10.10.0.101" # IP of the VM, must be unique in your network
VM_MEMORY = 512
VM_MEMORY = 1024
VM_CPUS = 1
VM_NAME = "OpenCaching DEV VM"
VM_HOST = "local.opencaching.de"
@@ -30,7 +30,10 @@ yum -y install php epel-release php-devel ImageMagick-devel ImageMagick gcc
yum -y install php-gd php-odbc php-pear php-xml php-xmlrpc php-mbstring
yum -y install php-snmp php-soap curl curl-devel php-mysql php-pdo php-pecl-zip
yum -y install vim vim-common mutt mlocate man-pages zip mod_ssl patch
yum -y install gcc-c++ ruby ruby-devel

label "Install crowdin-cli"
gem install crowdin-cli

label "Adjust Apache and MariaDB configuration"
# set max_allowed_packet
@@ -234,6 +237,8 @@ chmod 0777 /usr/bin/composer
label "Composer install"
cd /var/www/html/htdocs && composer install

label "Download translations from Crowdin"
cd /var/www/html/htdocs && crowdin-cli --identity=.crowdin.yaml download

label "Install Database Dump from '$DUMP_URL'"
label "Download SQL Dump"
@@ -1,10 +1,13 @@
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
/**
* @return array
*/
public function registerBundles()
{
$bundles = [
@@ -16,6 +19,7 @@ public function registerBundles()
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new JMS\TranslationBundle\JMSTranslationBundle(),
new AppBundle\AppBundle(),
];
@@ -29,23 +33,37 @@ public function registerBundles()
return $bundles;
}
/**
* @return string
*/
public function getRootDir()
{
return __DIR__;
}
/**
* @return string
*/
public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
}
/**
* @return string
*/
public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
return dirname(__DIR__) . '/var/logs';
}
/**
* @param \Symfony\Component\Config\Loader\LoaderInterface $loader
*
* @return void
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
}
}
@@ -21,6 +21,10 @@ public function up(Schema $schema)
$this->addSql('CREATE TABLE field_note (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, geocache_id INT DEFAULT NULL, type SMALLINT NOT NULL, date DATETIME NOT NULL, text VARCHAR(255) DEFAULT NULL, INDEX IDX_DC7193AEA76ED395 (user_id), INDEX IDX_DC7193AE67030974 (geocache_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ENGINE = MyISAM');
$this->addSql('ALTER TABLE field_note ADD CONSTRAINT FK_DC7193AEA76ED395 FOREIGN KEY (user_id) REFERENCES user (user_id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE field_note ADD CONSTRAINT FK_DC7193AE67030974 FOREIGN KEY (geocache_id) REFERENCES caches (cache_id) ON DELETE CASCADE');
// add menu item in legacy template
$this->addSql("INSERT INTO `sys_menu` (`id`, `id_string`, `title`, `title_trans_id`, `menustring`, `menustring_trans_id`, `access`, `href`, `visible`, `parent`, `position`, `color`, `sitemap`, `only_if_parent`)
VALUES (109, 'MNU_MYPROFILE_FIELD_NOTES', 'Field Notes', 0, 'Field Notes', 0, 0, '/field-notes/', 1, 9, 11, '', 1, NULL)");
}
/**
@@ -0,0 +1,6 @@
field_notes:
log_type:
1: 'Found'
2: 'Not found'
3: 'Write note'
1000: 'Needs maintainance'

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,55 @@
field_notes:
btn:
delete: Delete
delete_selected: 'Delete selected'
log_it: 'Log it'
upload: Upload

# Desc: Y-m-d H:i
date_format: 'Y-m-d H:i'

error:
# Desc: Geocache "%code%" not found.
geocache_not_found: 'Geocache "%code%" not found.'

# Desc: Log type "%type%" is not implemented.
log_type_not_implemented: 'Log type "%type%" is not implemented.'
wrong_file_format: 'This file seems not to be a field notes file.'

field_notes: 'Field Notes'

header:
actions: Actions
date: Date
geocache: Cache
log_type: 'Log type'

msg:
no_field_notes: 'You don''t have any Field Notes.'
upload_new_field_notes: 'Upload new Field Notes'

success:
deleted: 'Field Note successfully deleted.'
deleted_multiple: 'Field Notes successfully deleted.'

upload:
file: 'Field Notes file (geocache_visits.txt)'

label:
# Desc: Ignore Field Notes before %date%
ignore: 'Ignore Field Notes before %date%'

success: 'Field Notes successfully uploaded.'

geocache:
type:
drivein: 'Drive in Cache'
event: 'Event Cache'
math: 'Math/Physics Cache'
moving: 'Moving Cache'
multi: 'Multi Cache'
quiz: 'Quiz Cache'
traditional: 'Traditional Cache'
unknown: 'Unknown Cache'
virtual: 'Virtual Cache'
webcam: 'Webcam Cache'

This file was deleted.

Oops, something went wrong.
@@ -1,41 +1,64 @@
{% extends 'base.html.twig' %}

{% set page_title = "Field Notes" | trans %}
{% set page_title = 'field_notes.field_notes' | trans %}
{% set page_title_image = "resource2/ocstyle/images/misc/32x32-home.png" %}

{% import 'macros/geocache.twig' as geocache %}

{% block body %}
{% if fieldNotes %}
<font size="2">
<table class="searchtable" border="0" cellspacing="0" cellpadding="0" width="98.5%">
<thead>
<tr>
<th colspan="2">{% trans %}Cache{% endtrans %}</th>
<th class="nowrap">{% trans %}Date{% endtrans %}</th>
<th class="nowrap">{% trans %}Log Type{% endtrans %}</th>
<th class="nowrap">{% trans %}Actions{% endtrans %}</th>
</tr>
</thead>
<tbody>
{% for fieldNote in fieldNotes %}
<tr>
<td class="{{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}"><img src="resource2/ocstyle/images/cacheicon/traditional-s.gif" />{# @TODO #}</td>
<td class="{{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}"><a href="/viewcache.php?cacheid={{ fieldNote.geocache.cacheId }}">{{ fieldNote.geocache.name }}</a></td>
<td class="nowrap {{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}">{{ fieldNote.date | date('Y-m-d H:i:s') }}</td>
<td class="nowrap {{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}">{{ fieldNote.type }}</td>
<td class="nowrap {{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}"><a href="">Log it</a>&nbsp;|&nbsp;<a href="{{ path('field-notes.delete', {id: fieldNote.id}) }}">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
<form method="post" action="{{ path('field-notes.delete-multiple') }}">
<table class="searchtable field-notes-table" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th><input type="checkbox" id="checkall" onClick="toggleChecks(this, 'selected-field-notes[]')" /></th>
<th colspan="2">{{ 'field_notes.header.geocache' | trans }}</th>
<th class="nowrap">{{ 'field_notes.header.date' | trans }}</th>
<th class="nowrap">{{ 'field_notes.header.log_type' | trans }}</th>
<th class="nowrap">{{ 'field_notes.header.actions' | trans }}</th>
</tr>
</thead>
<tbody>
{% for fieldNote in fieldNotes %}
<tr>
<td class="{{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}"><input type="checkbox" name="selected-field-notes[]" value="{{ fieldNote.id }}" /></td>
<td class="{{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}">{{ geocache.geocacheIcon(fieldNote.geocache.type) }}</td>
<td class="{{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}"><a href="/viewcache.php?cacheid={{ fieldNote.geocache.cacheId }}">{{ fieldNote.geocache.name }}</a><br />{{ fieldNote.text | truncate(65, true) }}</td>
<td class="nowrap {{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}">{{ fieldNote.date | date('field_notes.date_format' | trans | desc('Y-m-d H:i')) }}</td>
<td class="nowrap {{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}">{{ ('field_notes.log_type.' ~ fieldNote.type) | trans({}, 'constants') }}</td>
<td class="nowrap {{ cycle(['search_listcolor1', 'search_listcolor2'], loop.index) }}"><a href="/log.php?fieldnoteid={{ fieldNote.id }}">{{ 'field_notes.btn.log_it' | trans }}</a>&nbsp;|&nbsp;<a href="{{ path('field-notes.delete', {id: fieldNote.id}) }}">{{ 'field_notes.btn.delete' | trans }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
<br />
<input type="submit" name="submit" class="btn btn-danger" value="{{ 'field_notes.btn.delete_selected' | trans }}" />
</form>
</font>
{% else %}
{% trans %}You don't have any Field Notes.{% endtrans %}
<h3>{{ 'field_notes.msg.no_field_notes' | trans }}</h3>
{% endif %}

<hr align="left" style="width:98%" />
<hr align="left" class="spacer" />

<h3>{{ 'field_notes.msg.upload_new_field_notes' | trans }}</h3>
{{ form_start(form) }}
{{ form_widget(form) }}
<input type="submit" value="{% trans %}Upload{% endtrans %}" class="btn btn-default"/>
{#{ form_widget(form) }#}
<div>
{{ form_widget(form.file) }}
{{ form_label(form.file) }}
{{ form_errors(form.file) }}
</div>

<div>
{{ form_widget(form.ignore) }}
{{ form_label(form.ignore) }}
{{ form_errors(form.ignore) }}
</div>
<div>
<input type="submit" value="{{ 'field_notes.btn.upload' | trans }}" class="btn btn-default"/>
</div>
{{ form_end(form) }}

{% endblock %}
@@ -0,0 +1,32 @@
{% macro geocacheIcon(type) %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_UNKNOWN') %}
<img src="resource2/ocstyle/images/cacheicon/unknown.gif" alt="{{ 'geocache.type.unknown' | trans }}" title="{{ 'geocache.type.unknown' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_TRADITIONAL') %}
<img src="resource2/ocstyle/images/cacheicon/traditional.gif" alt="{{ 'geocache.type.traditional' | trans }}" title="{{ 'geocache.type.traditional' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_MULTI') %}
<img src="resource2/ocstyle/images/cacheicon/multi.gif" alt="{{ 'geocache.type.multi' | trans }}" title="{{ 'geocache.type.multi' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_VIRTUAL') %}
<img src="resource2/ocstyle/images/cacheicon/virtual.gif" alt="{{ 'geocache.type.virtual' | trans }}" title="{{ 'geocache.type.virtual' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_WEBCAM') %}
<img src="resource2/ocstyle/images/cacheicon/webcam.gif" alt="{{ 'geocache.type.webcam' | trans }}" title="{{ 'geocache.type.webcam' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_EVENT') %}
<img src="resource2/ocstyle/images/cacheicon/event.gif" alt="{{ 'geocache.type.event' | trans }}" title="{{ 'geocache.type.event' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_QUIZ') %}
<img src="resource2/ocstyle/images/cacheicon/mystery.gif" alt="{{ 'geocache.type.quiz' | trans }}" title="{{ 'geocache.type.quiz' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_MATH') %}
<img src="resource2/ocstyle/images/cacheicon/mathe.gif" alt="{{ 'geocache.type.math' | trans }}" title="{{ 'geocache.type.math' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_MOVING') %}
<img src="resource2/ocstyle/images/cacheicon/moving.gif" alt="{{ 'geocache.type.moving' | trans }}" title="{{ 'geocache.type.moving' | trans }}" />
{% endif %}
{% if type == constant('AppBundle\\Entity\\Geocache::GEOCACHE_TYPE_DRIVE_IN') %}
<img src="resource2/ocstyle/images/cacheicon/drivein.gif" alt="{{ 'geocache.type.drivein' | trans }}" title="{{ 'geocache.type.drivein' | trans }}" />
{% endif %}
{% endmacro %}
@@ -73,3 +73,13 @@ swiftmailer:
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }

jms_translation:
configs:
app:
output_format: yml
dirs: ["%kernel.root_dir%", "%kernel.root_dir%/../src/AppBundle"]
output_dir: "%kernel.root_dir%/Resources/translations"
ignored_domains: [routes]
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]
@@ -10,6 +10,21 @@ services:
app.token_legacy_authenticator:
class: AppBundle\Legacy\Security\LegacyAuthenticator

app.form.upload_field_note:
class: AppBundle\Form\UploadFieldNotesType
arguments: ['@translator']
tags:
- { name: form.type }

app.service.field_note:
class: AppBundle\Service\FieldNoteService
arguments: ['@doctrine.orm.default_entity_manager', '@translator']

app.dataprovider.upload_field_note:
class: AppBundle\Form\DataProvider\UploadFieldNotesDataProvider
arguments: ['@app.service.field_note']

twig.extension.text:
class: Twig_Extensions_Extension_Text
tags:
- { name: twig.extension }
@@ -15,7 +15,9 @@
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"doctrine/doctrine-migrations-bundle": "^1.1"
"doctrine/doctrine-migrations-bundle": "^1.1",
"twig/extensions": "^1.3",
"jms/translation-bundle": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "4.*",
Oops, something went wrong.

0 comments on commit 50a776f

Please sign in to comment.
You can’t perform that action at this time.