From b0eb5ba9e171b584c517623a70d0af8c5da36f5a Mon Sep 17 00:00:00 2001 From: Alex Lewis Date: Fri, 28 Sep 2012 21:05:33 +1000 Subject: [PATCH] Django import Django import --- django/.gitignore | 5 + web/css/variables.css => django/__init__.py | 0 django/app/__init__.py | 0 django/app/forms.py | 91 + django/app/models.py | 8 + django/app/views.py | 113 + django/manage.py | 14 + django/settings.py | 153 + django/templates/app/editProfile.html | 35 + django/templates/app/landing.html | 8 + django/templates/app/member.html | 312 + django/templates/app/profile.html | 311 + django/templates/auth/login.html | 30 + django/templates/base.html | 60 + django/templates/navbar.html | 44 + django/urls.py | 20 + {app => symfony/app}/AppCache.php | 18 +- {app => symfony/app}/AppKernel.php | 76 +- {app => symfony/app}/SymfonyRequirements.php | 1276 +-- {app => symfony/app}/autoload.php | 32 +- {app => symfony/app}/check.php | 110 +- {app => symfony/app}/config/config.yml | 116 +- {app => symfony/app}/config/config_dev.yml | 52 +- {app => symfony/app}/config/config_prod.yml | 38 +- {app => symfony/app}/config/config_test.yml | 28 +- {app => symfony/app}/config/parameters.yml | 30 +- {app => symfony/app}/config/routing.yml | 26 +- {app => symfony/app}/config/routing_dev.yml | 28 +- {app => symfony/app}/config/security.yml | 98 +- {app => symfony/app}/console | 44 +- {app => symfony/app}/phpunit.xml.dist | 82 +- composer.json => symfony/composer.json | 90 +- {src => symfony/src}/BodyRep/BodyRep.php | 18 +- .../BodyRep/Controller/AuthController.php | 134 +- .../BodyRep/Controller/CommentController.php | 130 +- .../BodyRep/Controller/LandingController.php | 86 +- .../BodyRep/Controller/MemberController.php | 384 +- .../BodyRep/Controller/ProfileController.php | 130 +- .../DependencyInjection/BodyRepExtension.php | 44 +- .../src}/BodyRep/Entity/Comment.php | 228 +- .../src}/BodyRep/Entity/Member.php | 298 +- .../src}/BodyRep/Entity/Profile.php | 254 +- {src => symfony/src}/BodyRep/Entity/User.php | 218 +- .../src}/BodyRep/Entity/UserRepository.php | 30 +- .../BodyRep/EventListener/CommentListener.php | 62 +- .../EventListener/ControllerListener.php | 92 +- .../BodyRep/EventListener/KernelListener.php | 38 +- .../BodyRep/EventListener/LoginListener.php | 90 +- {src => symfony/src}/BodyRep/Form/Profile.php | 50 +- .../BodyRep/Resources/config/services.xml | 34 +- .../Resources/views/Auth/login.html.twig | 68 +- .../Resources/views/Auth}/navbar.html.twig | 70 +- .../Resources/views/Landing/about.html.twig | 16 +- .../Resources/views/Landing/index.html.twig | 24 +- .../Resources/views/Landing/navbar.html.twig | 34 +- .../views/Member/editProfile.html.twig | 50 +- .../Resources/views/Member/index.html.twig | 26 +- .../Resources/views/Member/layout.html.twig | 8 +- .../Resources/views/Member/login.html.twig | 50 +- .../Resources/views/Member}/navbar.html.twig | 70 +- .../Resources/views/Member/profile.html.twig | 626 +- .../Resources/views/Member/search.html.twig | 30 +- .../Resources/views/Profile/comment.html.twig | 22 +- .../Resources/views/Profile/index.html.twig | 638 +- .../views/Profile/reputation.html.twig | 20 +- .../BodyRep/Resources/views/layout.html.twig | 136 +- .../Tests/Controller/AuthControllerTest.php | 94 +- .../Controller/LandingControllerTest.php | 38 +- .../Tests/Controller/MemberControllerTest.php | 90 +- .../Controller/ProfileControllerTest.php | 102 +- .../Twig/Extension/TemplateExtension.php | 66 +- {web => symfony/web}/app.php | 48 +- {web => symfony/web}/app_dev.php | 26 +- {web => symfony/web}/apple-touch-icon.png | Bin .../web}/css/bootstrap-responsive.css | 1630 ++-- .../web}/css/bootstrap-responsive.min.css | 18 +- {web => symfony/web}/css/bootstrap.css | 8562 ++++++++--------- {web => symfony/web}/css/bootstrap.min.css | 18 +- {web => symfony/web}/css/chosen.css | 792 +- {web => symfony/web}/css/site.css | 0 symfony/web/css/variables.css | 0 {web => symfony/web}/favicon.ico | Bin {web => symfony/web}/img/arrowup.PNG | Bin .../web}/img/glyphicons-halflings-white.png | Bin .../web}/img/glyphicons-halflings.png | Bin {web => symfony/web}/img/glyphicons-white.png | Bin {web => symfony/web}/img/glyphicons.png | Bin {web => symfony/web}/img/icon-apps.png | Bin {web => symfony/web}/img/icon-community.png | Bin {web => symfony/web}/img/icon-learning.png | Bin {web => symfony/web}/img/icon-meals.png | Bin {web => symfony/web}/img/icon-profile.png | Bin {web => symfony/web}/img/icon-shopping.png | Bin {web => symfony/web}/img/icon-workout.png | Bin {web => symfony/web}/img/logo-nav-text.png | Bin {web => symfony/web}/img/logo-nav.png | Bin {web => symfony/web}/img/nav-cal.png | Bin {web => symfony/web}/img/nav-down-arrow.png | Bin {web => symfony/web}/img/nav-envelope.png | Bin {web => symfony/web}/img/nav-person.png | Bin {web => symfony/web}/img/nav-search-icon.png | Bin {web => symfony/web}/img/profile-pic.png | Bin {web => symfony/web}/img/progress.gif | Bin .../web}/img/sicon-bodyreputation.png | Bin {web => symfony/web}/img/sicon-bodystats.png | Bin {web => symfony/web}/img/sicon-challenges.png | Bin {web => symfony/web}/img/user1.jpg | Bin {web => symfony/web}/img/user2.jpg | Bin {web => symfony/web}/index.php | 10 +- {web => symfony/web}/js/LAB-debug.min.js | 8 +- {web => symfony/web}/js/LAB.js | 8 +- {web => symfony/web}/js/LAB.min.js | 8 +- {web => symfony/web}/js/LAB.src.js | 1026 +- {web => symfony/web}/js/application.js | 0 {web => symfony/web}/js/bootstrap.js | 3648 +++---- {web => symfony/web}/js/bootstrap.min.js | 10 +- {web => symfony/web}/js/jquery.chosen.min.js | 18 +- {web => symfony/web}/robots.txt | 8 +- 118 files changed, 12494 insertions(+), 11290 deletions(-) create mode 100644 django/.gitignore rename web/css/variables.css => django/__init__.py (100%) create mode 100644 django/app/__init__.py create mode 100644 django/app/forms.py create mode 100644 django/app/models.py create mode 100644 django/app/views.py create mode 100644 django/manage.py create mode 100644 django/settings.py create mode 100644 django/templates/app/editProfile.html create mode 100644 django/templates/app/landing.html create mode 100644 django/templates/app/member.html create mode 100644 django/templates/app/profile.html create mode 100644 django/templates/auth/login.html create mode 100644 django/templates/base.html create mode 100644 django/templates/navbar.html create mode 100644 django/urls.py rename {app => symfony/app}/AppCache.php (94%) rename {app => symfony/app}/AppKernel.php (97%) rename {app => symfony/app}/SymfonyRequirements.php (97%) rename {app => symfony/app}/autoload.php (96%) rename {app => symfony/app}/check.php (96%) rename {app => symfony/app}/config/config.yml (96%) rename {app => symfony/app}/config/config_dev.yml (95%) rename {app => symfony/app}/config/config_prod.yml (95%) rename {app => symfony/app}/config/config_test.yml (94%) rename {app => symfony/app}/config/parameters.yml (96%) rename {app => symfony/app}/config/routing.yml (95%) rename {app => symfony/app}/config/routing_dev.yml (96%) rename {app => symfony/app}/config/security.yml (96%) rename {app => symfony/app}/console (97%) rename {app => symfony/app}/phpunit.xml.dist (97%) rename composer.json => symfony/composer.json (97%) rename {src => symfony/src}/BodyRep/BodyRep.php (92%) rename {src => symfony/src}/BodyRep/Controller/AuthController.php (96%) rename {src => symfony/src}/BodyRep/Controller/CommentController.php (97%) rename {src => symfony/src}/BodyRep/Controller/LandingController.php (95%) rename {src => symfony/src}/BodyRep/Controller/MemberController.php (96%) rename {src => symfony/src}/BodyRep/Controller/ProfileController.php (97%) rename {src => symfony/src}/BodyRep/DependencyInjection/BodyRepExtension.php (96%) rename {src => symfony/src}/BodyRep/Entity/Comment.php (94%) rename {src => symfony/src}/BodyRep/Entity/Member.php (94%) rename {src => symfony/src}/BodyRep/Entity/Profile.php (94%) rename {src => symfony/src}/BodyRep/Entity/User.php (94%) rename {src => symfony/src}/BodyRep/Entity/UserRepository.php (94%) rename {src => symfony/src}/BodyRep/EventListener/CommentListener.php (96%) rename {src => symfony/src}/BodyRep/EventListener/ControllerListener.php (97%) rename {src => symfony/src}/BodyRep/EventListener/KernelListener.php (97%) rename {src => symfony/src}/BodyRep/EventListener/LoginListener.php (95%) rename {src => symfony/src}/BodyRep/Form/Profile.php (94%) rename {src => symfony/src}/BodyRep/Resources/config/services.xml (97%) rename {src => symfony/src}/BodyRep/Resources/views/Auth/login.html.twig (96%) rename {src/BodyRep/Resources/views/Member => symfony/src/BodyRep/Resources/views/Auth}/navbar.html.twig (98%) rename {src => symfony/src}/BodyRep/Resources/views/Landing/about.html.twig (95%) rename {src => symfony/src}/BodyRep/Resources/views/Landing/index.html.twig (94%) rename {src => symfony/src}/BodyRep/Resources/views/Landing/navbar.html.twig (97%) rename {src => symfony/src}/BodyRep/Resources/views/Member/editProfile.html.twig (96%) rename {src => symfony/src}/BodyRep/Resources/views/Member/index.html.twig (95%) rename {src => symfony/src}/BodyRep/Resources/views/Member/layout.html.twig (94%) rename {src => symfony/src}/BodyRep/Resources/views/Member/login.html.twig (96%) rename {src/BodyRep/Resources/views/Auth => symfony/src/BodyRep/Resources/views/Member}/navbar.html.twig (98%) rename {src => symfony/src}/BodyRep/Resources/views/Member/profile.html.twig (97%) rename {src => symfony/src}/BodyRep/Resources/views/Member/search.html.twig (92%) rename {src => symfony/src}/BodyRep/Resources/views/Profile/comment.html.twig (97%) rename {src => symfony/src}/BodyRep/Resources/views/Profile/index.html.twig (97%) rename {src => symfony/src}/BodyRep/Resources/views/Profile/reputation.html.twig (93%) rename {src => symfony/src}/BodyRep/Resources/views/layout.html.twig (96%) rename {src => symfony/src}/BodyRep/Tests/Controller/AuthControllerTest.php (96%) rename {src => symfony/src}/BodyRep/Tests/Controller/LandingControllerTest.php (95%) rename {src => symfony/src}/BodyRep/Tests/Controller/MemberControllerTest.php (95%) rename {src => symfony/src}/BodyRep/Tests/Controller/ProfileControllerTest.php (96%) rename {src => symfony/src}/BodyRep/Twig/Extension/TemplateExtension.php (95%) rename {web => symfony/web}/app.php (96%) rename {web => symfony/web}/app_dev.php (96%) rename {web => symfony/web}/apple-touch-icon.png (100%) rename {web => symfony/web}/css/bootstrap-responsive.css (94%) rename {web => symfony/web}/css/bootstrap-responsive.min.css (99%) rename {web => symfony/web}/css/bootstrap.css (95%) rename {web => symfony/web}/css/bootstrap.min.css (99%) rename {web => symfony/web}/css/chosen.css (97%) rename {web => symfony/web}/css/site.css (100%) create mode 100644 symfony/web/css/variables.css rename {web => symfony/web}/favicon.ico (100%) rename {web => symfony/web}/img/arrowup.PNG (100%) rename {web => symfony/web}/img/glyphicons-halflings-white.png (100%) rename {web => symfony/web}/img/glyphicons-halflings.png (100%) rename {web => symfony/web}/img/glyphicons-white.png (100%) rename {web => symfony/web}/img/glyphicons.png (100%) rename {web => symfony/web}/img/icon-apps.png (100%) rename {web => symfony/web}/img/icon-community.png (100%) rename {web => symfony/web}/img/icon-learning.png (100%) rename {web => symfony/web}/img/icon-meals.png (100%) rename {web => symfony/web}/img/icon-profile.png (100%) rename {web => symfony/web}/img/icon-shopping.png (100%) rename {web => symfony/web}/img/icon-workout.png (100%) rename {web => symfony/web}/img/logo-nav-text.png (100%) rename {web => symfony/web}/img/logo-nav.png (100%) rename {web => symfony/web}/img/nav-cal.png (100%) rename {web => symfony/web}/img/nav-down-arrow.png (100%) rename {web => symfony/web}/img/nav-envelope.png (100%) rename {web => symfony/web}/img/nav-person.png (100%) rename {web => symfony/web}/img/nav-search-icon.png (100%) rename {web => symfony/web}/img/profile-pic.png (100%) rename {web => symfony/web}/img/progress.gif (100%) rename {web => symfony/web}/img/sicon-bodyreputation.png (100%) rename {web => symfony/web}/img/sicon-bodystats.png (100%) rename {web => symfony/web}/img/sicon-challenges.png (100%) rename {web => symfony/web}/img/user1.jpg (100%) rename {web => symfony/web}/img/user2.jpg (100%) rename {web => symfony/web}/index.php (89%) rename {web => symfony/web}/js/LAB-debug.min.js (99%) mode change 100755 => 100644 rename {web => symfony/web}/js/LAB.js (99%) mode change 100755 => 100644 rename {web => symfony/web}/js/LAB.min.js (99%) mode change 100755 => 100644 rename {web => symfony/web}/js/LAB.src.js (97%) mode change 100755 => 100644 rename {web => symfony/web}/js/application.js (100%) rename {web => symfony/web}/js/bootstrap.js (96%) rename {web => symfony/web}/js/bootstrap.min.js (99%) rename {web => symfony/web}/js/jquery.chosen.min.js (99%) rename {web => symfony/web}/robots.txt (96%) diff --git a/django/.gitignore b/django/.gitignore new file mode 100644 index 0000000..9bcaa37 --- /dev/null +++ b/django/.gitignore @@ -0,0 +1,5 @@ +*.pyc +*.pyo +utils +img +media diff --git a/web/css/variables.css b/django/__init__.py similarity index 100% rename from web/css/variables.css rename to django/__init__.py diff --git a/django/app/__init__.py b/django/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django/app/forms.py b/django/app/forms.py new file mode 100644 index 0000000..7b6d435 --- /dev/null +++ b/django/app/forms.py @@ -0,0 +1,91 @@ +import datetime +from django import forms +from django.utils.translation import ugettext_lazy as _ +from django.contrib.auth.models import User +from django.contrib.auth import authenticate +from django.db.models import Q +from app.models import Members + +class LoginForm(forms.Form): + username = forms.CharField(label=_("Username"), max_length=30, + widget=forms.TextInput(attrs={'tabindex': 1, 'class': 'NB-input'}), + error_messages={'required': 'Please enter a username.'}) + password = forms.CharField(label=_("Password"), + widget=forms.PasswordInput(attrs={'tabindex': 2, 'class': 'NB-input'}), + required=False) + # error_messages={'required': 'Please enter a password.'}) + + def __init__(self, *args, **kwargs): + self.user_cache = None + super(LoginForm, self).__init__(*args, **kwargs) + + def clean(self): + username = self.cleaned_data.get('username', '').lower() + password = self.cleaned_data.get('password', '') + + user = User.objects.filter(Q(username__iexact=username) | Q(email=username)) + if username and user: + self.user_cache = authenticate(username=user[0].username, password=password) + if self.user_cache is None: + self.user_cache = authenticate(username=user[0].username, password="") + if self.user_cache is None: + email_username = User.objects.filter(email=username) + if email_username: + self.user_cache = authenticate(username=email_username[0].username, password=password) + if self.user_cache is None: + self.user_cache = authenticate(username=email_username[0].username, password="") + if self.user_cache is None: + # logging.info(" ***> [%s] Bad Login: TRYING JK-LESS PASSWORD" % username) + jkless_password = password.replace('j', '').replace('k', '') + self.user_cache = authenticate(username=username, password=jkless_password) + if self.user_cache is None: + #logging.info(" ***> [%s] Bad Login" % username) + raise forms.ValidationError(_("Whoopsy-daisy. Try again.")) + else: + # Supreme fuck-up. Accidentally removed the letters J and K from + # all user passwords. Re-save with correct password. + #logging.info(" ***> [%s] FIXING JK-LESS PASSWORD" % username) + self.user_cache.set_password(password) + self.user_cache.save() + if not self.user_cache.is_active: + raise forms.ValidationError(_("This account is inactive.")) + elif username and not user: + raise forms.ValidationError(_("That username is not registered. Create an account with it instead.")) + + return self.cleaned_data + + def get_user_id(self): + if self.user_cache: + return self.user_cache.id + return None + + def get_user(self): + return self.user_cache + +class EditProfileForm(forms.Form): + firstname = forms.CharField(label=_("First Name"), max_length=30, + widget=forms.TextInput(attrs={'tabindex': 1, 'class': 'NB-input'}), + error_messages={'required': 'Please enter a first name'}) + lastname = forms.CharField(label=_("LastName"), + widget=forms.TextInput(attrs={'tabindex': 2, 'class': 'NB-input'}), + error_messages={'required': 'Please enter a last name.'}) + + def __init__(self, *args, **kwargs): + super(EditProfileForm, self).__init__(*args, **kwargs) + + def clean(self): + firstname = self.cleaned_data.get('firstname', '') + lastname = self.cleaned_data.get('lastname', '') + + return self.cleaned_data + + def save(self, username): + firstname = self.cleaned_data['firstname'] + lastname = self.cleaned_data['lastname'] + + member = Members.objects.get(username=username) + member.firstname = firstname + member.lastname = lastname + member.save() + + return member \ No newline at end of file diff --git a/django/app/models.py b/django/app/models.py new file mode 100644 index 0000000..611fde0 --- /dev/null +++ b/django/app/models.py @@ -0,0 +1,8 @@ +from django.db import models +from django.contrib import admin +from django.contrib.auth.models import User, UserManager + +class Members(models.Model): + username = models.CharField(max_length = 30) + firstname = models.CharField(max_length=30) + lastname = models.CharField(max_length=30) diff --git a/django/app/views.py b/django/app/views.py new file mode 100644 index 0000000..00bc12c --- /dev/null +++ b/django/app/views.py @@ -0,0 +1,113 @@ +import datetime +import time +import sys +from django.shortcuts import get_object_or_404 +from django.shortcuts import render, render_to_response +from django.contrib.auth.decorators import login_required +from django.template.loader import render_to_string +from django.db import IntegrityError +from django.views.decorators.cache import never_cache +from django.core.urlresolvers import reverse +from django.contrib.auth import login as login_user +from django.contrib.auth import logout as logout_user +from django.contrib.auth.models import User +from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404 +from django.conf import settings +from django.core.mail import mail_admins +from django.core.validators import email_re +from django.core.mail import EmailMultiAlternatives +from django.contrib.sites.models import Site +from neh.app.forms import LoginForm, EditProfileForm +from django.core.context_processors import csrf +from django.template import RequestContext +from annoying.decorators import render_to, ajax_request + +from app.models import Members + +from utils.user_functions import get_user, ajax_login_required +from utils.view_functions import get_argument_or_404, render_to, is_true +#from utils.ratelimit import ratelimit + +@render_to('app/landing.html') +def index(request): + return {} + +@render_to('app/member.html') +def mprofile(request): + if request.user.is_anonymous(): + return login(request) + else: + member = Members.objects.get(username=request.user.username) + return {'member': member} + +@render_to('app/profile.html') +def vprofile(request, username): + member = Members.objects.get(username=username) + + if request.user.is_anonymous(): + return login(request) + else: + return { 'user': request.user, 'member': member } + +@never_cache +@render_to('auth/login.html') +def login(request): + if not request.user.is_anonymous(): + return HttpResponseRedirect(reverse('mprofile')) + + if request.method == "POST": + if request.POST.get('submit', '').startswith('log'): + login_form = LoginForm(request.POST, prefix='login') + else: + login_form = LoginForm(prefix='login') + else: + login_form = LoginForm(prefix='login') + + + return {'login_form':login_form} + + +@never_cache +def dologin(request): + code = -1 + message = "" + if request.method == "POST": + form = LoginForm(request.POST, prefix='login') + if form.is_valid(): + login_user(request, form.get_user()) + return HttpResponseRedirect(reverse('mprofile')) + else: + message = form.errors.items()[0][1][0] + +@never_cache +def logout(request): + logout_user(request) + + if request.GET.get('api'): + return HttpResponse(json.encode(dict(code=1)), mimetype='application/json') + else: + return HttpResponseRedirect(reverse('index')) + + +@ajax_request +@render_to('app/editProfile.html') +def edit(request): + if request.user.is_anonymous(): + return login(request) + else: + + member = Members.objects.get(username=request.user.username) + + mdata = {'firstname': member.firstname, 'lastname': member.lastname } + + edit_form = EditProfileForm(initial=mdata, prefix='edit') + return { 'edit_form': edit_form } + +@ajax_request +def save(request): + edit_form = EditProfileForm(data=request.POST,prefix = 'edit') + if edit_form.is_valid(): + edit_form.save(request.user.username) + return { 'result': 1 } + else: + return { 'result': 0 } diff --git a/django/manage.py b/django/manage.py new file mode 100644 index 0000000..3e4eedc --- /dev/null +++ b/django/manage.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +import imp +try: + imp.find_module('settings') # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__) + sys.exit(1) + +import settings + +if __name__ == "__main__": + execute_manager(settings) diff --git a/django/settings.py b/django/settings.py new file mode 100644 index 0000000..8bf1222 --- /dev/null +++ b/django/settings.py @@ -0,0 +1,153 @@ +import os +import logging + +DEBUG = True +TEMPLATE_DEBUG = DEBUG +DIRNAME = os.path.abspath(os.path.dirname(__file__)) + +ADMINS = ( + # ('Your Name', 'your_email@example.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'test', # Or path to database file if using sqlite3. + 'USER': 'site', # Not used with sqlite3. + 'PASSWORD': 'suppity', # Not used with sqlite3. + 'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# On Unix systems, a value of None will cause Django to use the same +# timezone as the operating system. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'UTC' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale +USE_L10N = True + +# Absolute filesystem path to the directory that will hold user-uploaded files. +# Example: "/home/media/media.lawrence.com/media/" +MEDIA_ROOT = '' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +# Examples: "http://media.lawrence.com/media/", "http://example.com/media/" +MEDIA_URL = '' + +# Absolute path to the directory static files should be collected to. +# Don't put anything in this directory yourself; store your static files +# in apps' "static/" subdirectories and in STATICFILES_DIRS. +# Example: "/home/media/media.lawrence.com/static/" +STATIC_ROOT = DIRNAME + +# URL prefix for static files. +# Example: "http://media.lawrence.com/static/" +STATIC_URL = '/static/' +PASSWORD_HASHERS = ( + 'django.contrib.auth.hashers.BCryptPasswordHasher', +) +# URL prefix for admin static files -- CSS, JavaScript and images. +# Make sure to use a trailing slash. +# Examples: "http://foo.com/static/admin/", "/static/admin/". +ADMIN_MEDIA_PREFIX = '/static/admin/' + +# Additional locations of static files +STATICFILES_DIRS = ( + # Put strings here, like "/home/html/static" or "C:/www/django/static". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +# List of finder classes that know how to find static files in +# various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +# 'django.contrib.staticfiles.finders.DefaultStorageFinder', +) + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '!@)1ngg_(jtlt!7yj4jkxtg@pf^1=w1!9qz*g$1!o-%(^gdv!u' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +#TEMPLATE_CONTEXT_PROCESSORS = ( +# 'django.core.context_processors.auth', +#) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', +) + +ROOT_URLCONF = 'neh.urls' + +TEMPLATE_DIRS = ( + DIRNAME + '/templates' +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django_extensions', + 'annoying', + 'utils', + 'app', + 'django.contrib.admin', + 'django.contrib.admindocs', +) + +# A sample logging configuration. The only tangible logging +# performed by this configuration is to send an email to +# the site admins on every HTTP 500 error. +# See http://docs.djangoproject.com/en/dev/topics/logging for +# more details on how to customize your logging configuration. +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} diff --git a/django/templates/app/editProfile.html b/django/templates/app/editProfile.html new file mode 100644 index 0000000..a795eb1 --- /dev/null +++ b/django/templates/app/editProfile.html @@ -0,0 +1,35 @@ +{% block content %} + +

Update Profile

+ + +
+
+ {% if edit_form.errors %} + {% for field, error in edit_form.errors.items %} + {{ error|safe }} + {% endfor %} + {% endif %} +
+
+ {{ edit_form.firstname.label_tag }} + {{ edit_form.firstname }} +
+ +
+ {{ edit_form.lastname.label_tag }} + {{ edit_form.lastname }} +
+
 
+
+
+
+ +
+
 
+ + + {% csrf_token %} + +
+{% endblock %} diff --git a/django/templates/app/landing.html b/django/templates/app/landing.html new file mode 100644 index 0000000..b843409 --- /dev/null +++ b/django/templates/app/landing.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}BodyRep - Welcome{% endblock %} + +{% block content %} +{% include "navbar.html" %} +Landing Page +{% endblock %} diff --git a/django/templates/app/member.html b/django/templates/app/member.html new file mode 100644 index 0000000..9cb516a --- /dev/null +++ b/django/templates/app/member.html @@ -0,0 +1,312 @@ +{% extends 'base.html' %} + +{% block title %}BodyRep{% endblock %} + +{% block content %} +{% include 'navbar.html' %} + +
+
+ +
+
+
+

{{ member.firstname }} {{ member.lastname }}

+ Edit Profile + +
+
+ Weight: 100kg (
0)
+ Bodyfat: 20% (
2)
+ Measurements: 400cm (
15)
+
+
+ Lives in Calgary, Alberta + Trains at Talisman Center,Fitness First + Hobbies: Skiing, and (5) other ... + Professionals: Heath Spence,Steve Baudo see more... +
+
+
+
Filters:
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ + 565 +
+
+ Breakfast: 30g Oats, 1x Banana, 5x Egg Whites +
+ +
+
+ Brian Goff +

Good to see you're keeping up the good work mate. Keep us posted ;)

+ +
+
+
+ Alex Zborowski +

Well it's not easy but you do your best every day and you judge every action.

+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + 45 + + 900 +
+
+ Workout at Talisman Center with Brian Goff +
+ +
+
+
+
+
+ +
+
+
+
+ + 90 + + 720 +
+
+ Workout at Talisman Center +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ You commented on Brian Goff's workout +
+ +
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + 30 + + 450 +
+
+ Workout using Runtracker with Brian Goff +
+ +
+ +
+
+
+
+ +
+
+
+ +
+
+ Brian Goff +

Hey "mate"! Want to train at the Talisman again tonight?

+
+ + +
+
+ Alex Zborowski +

Sorry Brian, working on the BodyREP pitch tonight.

+ +
+
+
+ Brian Goff +

No worries "mate", maybe next time.

+ +
+ +
+
+
+
+

Hello, world!

+

This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.

+

Learn more »

+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/django/templates/app/profile.html b/django/templates/app/profile.html new file mode 100644 index 0000000..218ec77 --- /dev/null +++ b/django/templates/app/profile.html @@ -0,0 +1,311 @@ +{% extends 'base.html' %} + +{% block title %}BodyRep{% endblock %} + +{% block content %} +{% include 'navbar.html' %} + +
+
+ +
+
+
+

{{ member.firstname }} {{ member.lastname }}

+ Edit Profile +
+
+ Weight: 100kg (
0)
+ Bodyfat: 20% (
2)
+ Measurements: 400cm (
15)
+
+
+ Lives in Calgary, Alberta + Trains at Talisman Center,Fitness First + Hobbies: Skiing, and (5) other ... + Professionals: Heath Spence,Steve Baudo see more... +
+
+
+
Filters:
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ + 565 +
+
+ Breakfast: 30g Oats, 1x Banana, 5x Egg Whites +
+ +
+
+ Brian Goff +

Good to see you're keeping up the good work mate. Keep us posted ;)

+ +
+
+
+ Alex Zborowski +

Well it's not easy but you do your best every day and you judge every action.

+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + 45 + + 900 +
+
+ Workout at Talisman Center with Brian Goff +
+ +
+
+
+
+
+ +
+
+
+
+ + 90 + + 720 +
+
+ Workout at Talisman Center +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ You commented on Brian Goff's workout +
+ +
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + 30 + + 450 +
+
+ Workout using Runtracker with Brian Goff +
+ +
+ +
+
+
+
+ +
+
+
+ +
+
+ Brian Goff +

Hey "mate"! Want to train at the Talisman again tonight?

+
+ + +
+
+ Alex Zborowski +

Sorry Brian, working on the BodyREP pitch tonight.

+ +
+
+
+ Brian Goff +

No worries "mate", maybe next time.

+ +
+ +
+
+
+
+

Hello, world!

+

This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.

+

Learn more »

+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/django/templates/auth/login.html b/django/templates/auth/login.html new file mode 100644 index 0000000..9bb6844 --- /dev/null +++ b/django/templates/auth/login.html @@ -0,0 +1,30 @@ +{% extends 'base.html' %} + +{% block content %} +{% include 'navbar.html' %} + +

Login

+ + {% if login_form.errors %} + {% for field, error in login_form.errors.items %} + {{ error|safe }} + {% endfor %} +{% endif %} +
+ +
+ {{ login_form.username.label_tag }} + {{ login_form.username }} +
+ +
+ {{ login_form.password.label_tag }} + {{ login_form.password }} +
+ + + + {% csrf_token %} + +
+{% endblock %} diff --git a/django/templates/base.html b/django/templates/base.html new file mode 100644 index 0000000..86c3ec7 --- /dev/null +++ b/django/templates/base.html @@ -0,0 +1,60 @@ + + + + + + + + + test + + + + + + + + + + + + + +
Loading
+ + + + diff --git a/django/templates/navbar.html b/django/templates/navbar.html new file mode 100644 index 0000000..d8062ce --- /dev/null +++ b/django/templates/navbar.html @@ -0,0 +1,44 @@ + diff --git a/django/urls.py b/django/urls.py new file mode 100644 index 0000000..fee6cc9 --- /dev/null +++ b/django/urls.py @@ -0,0 +1,20 @@ +from django.conf.urls.defaults import patterns, include, url +from app import views +from django.conf import settings +from django.contrib import admin + +admin.autodiscover() + +urlpatterns = patterns('', + url(r'^$', views.index, name='index'), + url(r'^m/profile/?$', views.mprofile, name='mprofile'), + url(r'^m/profile/save/?$', views.save, name='msave'), + url(r'^m/profile/edit/?$', views.edit, name='medit'), + url(r'^admin/doc/', include('django.contrib.admindocs.urls')), + url(r'^mgmt/', include(admin.site.urls)), + url(r'^logout$', views.logout, name='logout'), + url(r'^login$', views.login, name='login'), + url(r'^dologin$', views.dologin, name='dologin'), + url(r'^([a-zA-Z0-9]+)', views.vprofile), + +) diff --git a/app/AppCache.php b/symfony/app/AppCache.php similarity index 94% rename from app/AppCache.php rename to symfony/app/AppCache.php index ddb51db..28c7d61 100644 --- a/app/AppCache.php +++ b/symfony/app/AppCache.php @@ -1,9 +1,9 @@ -getEnvironment(), array('dev', 'test'))) { - $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); - $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); - $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); - } - - return $bundles; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); - } -} +getEnvironment(), array('dev', 'test'))) { + $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); + $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); + $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); + } + + return $bundles; + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); + } +} diff --git a/app/SymfonyRequirements.php b/symfony/app/SymfonyRequirements.php similarity index 97% rename from app/SymfonyRequirements.php rename to symfony/app/SymfonyRequirements.php index 4df46d1..75d783a 100644 --- a/app/SymfonyRequirements.php +++ b/symfony/app/SymfonyRequirements.php @@ -1,638 +1,638 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/* - * Users of PHP 5.2 should be able to run the requirements checks. - * This is why the file and all classes must be compatible with PHP 5.2+ - * (e.g. not using namespaces and closures). - * - * ************** CAUTION ************** - * - * DO NOT EDIT THIS FILE as it will be overriden by Composer as part of - * the installation/update process. The original file resides in the - * SensioDistributionBundle. - * - * ************** CAUTION ************** - */ - -/** - * Represents a single PHP requirement, e.g. an installed extension. - * It can be a mandatory requirement or an optional recommendation. - * There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. - * - * @author Tobias Schultze - */ -class Requirement -{ - private $fulfilled; - private $testMessage; - private $helpText; - private $helpHtml; - private $optional; - - /** - * Constructor that initializes the requirement. - * - * @param Boolean $fulfilled Whether the requirement is fulfilled - * @param string $testMessage The message for testing the requirement - * @param string $helpHtml The help text formatted in HTML for resolving the problem - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement - */ - public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) - { - $this->fulfilled = (Boolean) $fulfilled; - $this->testMessage = (string) $testMessage; - $this->helpHtml = (string) $helpHtml; - $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; - $this->optional = (Boolean) $optional; - } - - /** - * Returns whether the requirement is fulfilled. - * - * @return Boolean true if fulfilled, otherwise false - */ - public function isFulfilled() - { - return $this->fulfilled; - } - - /** - * Returns the message for testing the requirement. - * - * @return string The test message - */ - public function getTestMessage() - { - return $this->testMessage; - } - - /** - * Returns the help text for resolving the problem - * - * @return string The help text - */ - public function getHelpText() - { - return $this->helpText; - } - - /** - * Returns the help text formatted in HTML. - * - * @return string The HTML help - */ - public function getHelpHtml() - { - return $this->helpHtml; - } - - /** - * Returns whether this is only an optional recommendation and not a mandatory requirement. - * - * @return Boolean true if optional, false if mandatory - */ - public function isOptional() - { - return $this->optional; - } -} - -/** - * Represents a PHP requirement in form of a php.ini configuration. - * - * @author Tobias Schultze - */ -class PhpIniRequirement extends Requirement -{ - /** - * Constructor that initializes the requirement. - * - * @param string $cfgName The configuration name used for ini_get() - * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, - or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) - * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement - */ - public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) - { - $cfgValue = ini_get($cfgName); - - if (is_callable($evaluation)) { - if (null === $testMessage || null === $helpHtml) { - throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); - } - - $fulfilled = call_user_func($evaluation, $cfgValue); - } else { - if (null === $testMessage) { - $testMessage = sprintf('%s %s be %s in php.ini', - $cfgName, - $optional ? 'should' : 'must', - $evaluation ? 'enabled' : 'disabled' - ); - } - - if (null === $helpHtml) { - $helpHtml = sprintf('Set %s to %s in php.ini*.', - $cfgName, - $evaluation ? 'on' : 'off' - ); - } - - $fulfilled = $evaluation == $cfgValue; - } - - parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); - } -} - -/** - * A RequirementCollection represents a set of Requirement instances. - * - * @author Tobias Schultze - */ -class RequirementCollection implements IteratorAggregate -{ - private $requirements = array(); - - /** - * Gets the current RequirementCollection as an Iterator. - * - * @return Traversable A Traversable interface - */ - public function getIterator() - { - return new ArrayIterator($this->requirements); - } - - /** - * Adds a Requirement. - * - * @param Requirement $requirement A Requirement instance - */ - public function add(Requirement $requirement) - { - $this->requirements[] = $requirement; - } - - /** - * Adds a mandatory requirement. - * - * @param Boolean $fulfilled Whether the requirement is fulfilled - * @param string $testMessage The message for testing the requirement - * @param string $helpHtml The help text formatted in HTML for resolving the problem - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) - { - $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); - } - - /** - * Adds an optional recommendation. - * - * @param Boolean $fulfilled Whether the recommendation is fulfilled - * @param string $testMessage The message for testing the recommendation - * @param string $helpHtml The help text formatted in HTML for resolving the problem - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) - { - $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); - } - - /** - * Adds a mandatory requirement in form of a php.ini configuration. - * - * @param string $cfgName The configuration name used for ini_get() - * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, - or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) - * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) - { - $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); - } - - /** - * Adds an optional recommendation in form of a php.ini configuration. - * - * @param string $cfgName The configuration name used for ini_get() - * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, - or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement - * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. - This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. - Example: You require a config to be true but PHP later removes this config and defaults it to true internally. - * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) - * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) - * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) - */ - public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) - { - $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); - } - - /** - * Adds a requirement collection to the current set of requirements. - * - * @param RequirementCollection $collection A RequirementCollection instance - */ - public function addCollection(RequirementCollection $collection) - { - $this->requirements = array_merge($this->requirements, $collection->all()); - } - - /** - * Returns both requirements and recommendations. - * - * @return array Array of Requirement instances - */ - public function all() - { - return $this->requirements; - } - - /** - * Returns all mandatory requirements. - * - * @return array Array of Requirement instances - */ - public function getRequirements() - { - $array = array(); - foreach ($this->requirements as $req) { - if (!$req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns the mandatory requirements that were not met. - * - * @return array Array of Requirement instances - */ - public function getFailedRequirements() - { - $array = array(); - foreach ($this->requirements as $req) { - if (!$req->isFulfilled() && !$req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns all optional recommmendations. - * - * @return array Array of Requirement instances - */ - public function getRecommendations() - { - $array = array(); - foreach ($this->requirements as $req) { - if ($req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns the recommendations that were not met. - * - * @return array Array of Requirement instances - */ - public function getFailedRecommendations() - { - $array = array(); - foreach ($this->requirements as $req) { - if (!$req->isFulfilled() && $req->isOptional()) { - $array[] = $req; - } - } - - return $array; - } - - /** - * Returns whether a php.ini configuration is not correct. - * - * @return Boolean php.ini configuration problem? - */ - public function hasPhpIniConfigIssue() - { - foreach ($this->requirements as $req) { - if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { - return true; - } - } - - return false; - } - - /** - * Returns the PHP configuration file (php.ini) path. - * - * @return string|false php.ini file path - */ - public function getPhpIniConfigPath() - { - return get_cfg_var('cfg_file_path'); - } -} - -/** - * This class specifies all requirements and optional recommendations that - * are necessary to run the Symfony Standard Edition. - * - * @author Tobias Schultze - * @author Fabien Potencier - */ -class SymfonyRequirements extends RequirementCollection -{ - const REQUIRED_PHP_VERSION = '5.3.3'; - - /** - * Constructor that initializes the requirements. - */ - public function __construct() - { - /* mandatory requirements follow */ - - $installedPhpVersion = phpversion(); - - $this->addRequirement( - version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), - sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), - sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. - Before using Symfony, upgrade your PHP installation, preferably to the latest version.', - $installedPhpVersion, self::REQUIRED_PHP_VERSION), - sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) - ); - - $this->addRequirement( - version_compare($installedPhpVersion, '5.3.16', '!='), - 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', - 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' - ); - - $this->addRequirement( - is_dir(__DIR__.'/../vendor/composer'), - 'Vendor libraries must be installed', - 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. ' . - 'Then run "php composer.phar install" to install them.' - ); - - $baseDir = basename(__DIR__); - - $this->addRequirement( - is_writable(__DIR__.'/cache'), - "$baseDir/cache/ directory must be writable", - "Change the permissions of the \"$baseDir/cache/\" directory so that the web server can write into it." - ); - - $this->addRequirement( - is_writable(__DIR__.'/logs'), - "$baseDir/logs/ directory must be writable", - "Change the permissions of the \"$baseDir/logs/\" directory so that the web server can write into it." - ); - - $this->addPhpIniRequirement( - 'date.timezone', true, false, - 'date.timezone setting must be set', - 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' - ); - - if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { - $this->addRequirement( - (in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers())), - sprintf('Configured default timezone "%s" must be supported by your installation of PHP', date_default_timezone_get()), - 'Your default timezone is not supported by PHP. Check for typos in your php.ini file and have a look at the list of deprecated timezones at http://php.net/manual/en/timezones.others.php.' - ); - } - - $this->addRequirement( - function_exists('json_encode'), - 'json_encode() must be available', - 'Install and enable the JSON extension.' - ); - - $this->addRequirement( - function_exists('session_start'), - 'session_start() must be available', - 'Install and enable the session extension.' - ); - - $this->addRequirement( - function_exists('ctype_alpha'), - 'ctype_alpha() must be available', - 'Install and enable the ctype extension.' - ); - - $this->addRequirement( - function_exists('token_get_all'), - 'token_get_all() must be available', - 'Install and enable the Tokenizer extension.' - ); - - $this->addRequirement( - function_exists('simplexml_import_dom'), - 'simplexml_import_dom() must be available', - 'Install and enable the SimpleXML extension.' - ); - - if (function_exists('apc_store') && ini_get('apc.enabled')) { - $this->addRequirement( - version_compare(phpversion('apc'), '3.0.17', '>='), - 'APC version must be at least 3.0.17', - 'Upgrade your APC extension (3.0.17+).' - ); - } - - $this->addPhpIniRequirement('detect_unicode', false); - - if (extension_loaded('suhosin')) { - $this->addPhpIniRequirement( - 'suhosin.executor.include.whitelist', - create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), - false, - 'suhosin.executor.include.whitelist must be configured correctly in php.ini', - 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' - ); - } - - if (extension_loaded('xdebug')) { - $this->addPhpIniRequirement( - 'xdebug.show_exception_trace', false, true - ); - - $this->addPhpIniRequirement( - 'xdebug.scream', false, true - ); - } - - $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; - - $this->addRequirement( - null !== $pcreVersion && $pcreVersion > 8.0, - sprintf('PCRE extension must be available and at least 8.0 (%s installed)', $pcreVersion ? $pcreVersion : 'not'), - 'Upgrade your PCRE extension (8.0+).' - ); - - /* optional recommendations follow */ - - $this->addRecommendation( - file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), - 'Requirements file should be up-to-date', - 'Your requirements file is outdated. Run composer install and re-check your configuration.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.3.4', '>='), - 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', - 'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.3.8', '>='), - 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', - 'Install PHP 5.3.8 or newer if your project uses annotations.' - ); - - $this->addRecommendation( - version_compare($installedPhpVersion, '5.4.0', '!='), - 'You should not use PHP 5.4.0 due to the PHP bug #61453', - 'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.' - ); - - $this->addRecommendation( - class_exists('DomDocument'), - 'PHP-XML module should be installed', - 'Install and enable the PHP-XML module.' - ); - - $this->addRecommendation( - function_exists('mb_strlen'), - 'mb_strlen() should be available', - 'Install and enable the mbstring extension.' - ); - - $this->addRecommendation( - function_exists('iconv'), - 'iconv() should be available', - 'Install and enable the iconv extension.' - ); - - $this->addRecommendation( - function_exists('utf8_decode'), - 'utf8_decode() should be available', - 'Install and enable the XML extension.' - ); - - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->addRecommendation( - function_exists('posix_isatty'), - 'posix_isatty() should be available', - 'Install and enable the php_posix extension (used to colorize the CLI output).' - ); - } - - $this->addRecommendation( - class_exists('Locale'), - 'intl extension should be available', - 'Install and enable the intl extension (used for validators).' - ); - - if (class_exists('Collator')) { - $this->addRecommendation( - null !== new Collator('fr_FR'), - 'intl extension should be correctly configured', - 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' - ); - } - - if (class_exists('Locale')) { - if (defined('INTL_ICU_VERSION')) { - $version = INTL_ICU_VERSION; - } else { - $reflector = new ReflectionExtension('intl'); - - ob_start(); - $reflector->info(); - $output = strip_tags(ob_get_clean()); - - preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); - $version = $matches[1]; - } - - $this->addRecommendation( - version_compare($version, '4.0', '>='), - 'intl ICU version should be at least 4+', - 'Upgrade your intl extension with a newer ICU version (4+).' - ); - } - - $accelerator = - (function_exists('apc_store') && ini_get('apc.enabled')) - || - function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') - || - function_exists('xcache_set') - ; - - $this->addRecommendation( - $accelerator, - 'a PHP accelerator should be installed', - 'Install and enable a PHP accelerator like APC (highly recommended).' - ); - - $this->addPhpIniRecommendation('short_open_tag', false); - - $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); - - $this->addPhpIniRecommendation('register_globals', false, true); - - $this->addPhpIniRecommendation('session.auto_start', false); - - $this->addRecommendation( - class_exists('PDO'), - 'PDO should be installed', - 'Install PDO (mandatory for Doctrine).' - ); - - if (class_exists('PDO')) { - $drivers = PDO::getAvailableDrivers(); - $this->addRecommendation( - count($drivers), - sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), - 'Install PDO drivers (mandatory for Doctrine).' - ); - } - } -} + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/* + * Users of PHP 5.2 should be able to run the requirements checks. + * This is why the file and all classes must be compatible with PHP 5.2+ + * (e.g. not using namespaces and closures). + * + * ************** CAUTION ************** + * + * DO NOT EDIT THIS FILE as it will be overriden by Composer as part of + * the installation/update process. The original file resides in the + * SensioDistributionBundle. + * + * ************** CAUTION ************** + */ + +/** + * Represents a single PHP requirement, e.g. an installed extension. + * It can be a mandatory requirement or an optional recommendation. + * There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. + * + * @author Tobias Schultze + */ +class Requirement +{ + private $fulfilled; + private $testMessage; + private $helpText; + private $helpHtml; + private $optional; + + /** + * Constructor that initializes the requirement. + * + * @param Boolean $fulfilled Whether the requirement is fulfilled + * @param string $testMessage The message for testing the requirement + * @param string $helpHtml The help text formatted in HTML for resolving the problem + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement + */ + public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) + { + $this->fulfilled = (Boolean) $fulfilled; + $this->testMessage = (string) $testMessage; + $this->helpHtml = (string) $helpHtml; + $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; + $this->optional = (Boolean) $optional; + } + + /** + * Returns whether the requirement is fulfilled. + * + * @return Boolean true if fulfilled, otherwise false + */ + public function isFulfilled() + { + return $this->fulfilled; + } + + /** + * Returns the message for testing the requirement. + * + * @return string The test message + */ + public function getTestMessage() + { + return $this->testMessage; + } + + /** + * Returns the help text for resolving the problem + * + * @return string The help text + */ + public function getHelpText() + { + return $this->helpText; + } + + /** + * Returns the help text formatted in HTML. + * + * @return string The HTML help + */ + public function getHelpHtml() + { + return $this->helpHtml; + } + + /** + * Returns whether this is only an optional recommendation and not a mandatory requirement. + * + * @return Boolean true if optional, false if mandatory + */ + public function isOptional() + { + return $this->optional; + } +} + +/** + * Represents a PHP requirement in form of a php.ini configuration. + * + * @author Tobias Schultze + */ +class PhpIniRequirement extends Requirement +{ + /** + * Constructor that initializes the requirement. + * + * @param string $cfgName The configuration name used for ini_get() + * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, + or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) + * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement + */ + public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) + { + $cfgValue = ini_get($cfgName); + + if (is_callable($evaluation)) { + if (null === $testMessage || null === $helpHtml) { + throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); + } + + $fulfilled = call_user_func($evaluation, $cfgValue); + } else { + if (null === $testMessage) { + $testMessage = sprintf('%s %s be %s in php.ini', + $cfgName, + $optional ? 'should' : 'must', + $evaluation ? 'enabled' : 'disabled' + ); + } + + if (null === $helpHtml) { + $helpHtml = sprintf('Set %s to %s in php.ini*.', + $cfgName, + $evaluation ? 'on' : 'off' + ); + } + + $fulfilled = $evaluation == $cfgValue; + } + + parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); + } +} + +/** + * A RequirementCollection represents a set of Requirement instances. + * + * @author Tobias Schultze + */ +class RequirementCollection implements IteratorAggregate +{ + private $requirements = array(); + + /** + * Gets the current RequirementCollection as an Iterator. + * + * @return Traversable A Traversable interface + */ + public function getIterator() + { + return new ArrayIterator($this->requirements); + } + + /** + * Adds a Requirement. + * + * @param Requirement $requirement A Requirement instance + */ + public function add(Requirement $requirement) + { + $this->requirements[] = $requirement; + } + + /** + * Adds a mandatory requirement. + * + * @param Boolean $fulfilled Whether the requirement is fulfilled + * @param string $testMessage The message for testing the requirement + * @param string $helpHtml The help text formatted in HTML for resolving the problem + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) + { + $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); + } + + /** + * Adds an optional recommendation. + * + * @param Boolean $fulfilled Whether the recommendation is fulfilled + * @param string $testMessage The message for testing the recommendation + * @param string $helpHtml The help text formatted in HTML for resolving the problem + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) + { + $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); + } + + /** + * Adds a mandatory requirement in form of a php.ini configuration. + * + * @param string $cfgName The configuration name used for ini_get() + * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, + or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) + * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) + { + $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); + } + + /** + * Adds an optional recommendation in form of a php.ini configuration. + * + * @param string $cfgName The configuration name used for ini_get() + * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, + or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement + * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. + This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. + Example: You require a config to be true but PHP later removes this config and defaults it to true internally. + * @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) + * @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) + * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) + */ + public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) + { + $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); + } + + /** + * Adds a requirement collection to the current set of requirements. + * + * @param RequirementCollection $collection A RequirementCollection instance + */ + public function addCollection(RequirementCollection $collection) + { + $this->requirements = array_merge($this->requirements, $collection->all()); + } + + /** + * Returns both requirements and recommendations. + * + * @return array Array of Requirement instances + */ + public function all() + { + return $this->requirements; + } + + /** + * Returns all mandatory requirements. + * + * @return array Array of Requirement instances + */ + public function getRequirements() + { + $array = array(); + foreach ($this->requirements as $req) { + if (!$req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns the mandatory requirements that were not met. + * + * @return array Array of Requirement instances + */ + public function getFailedRequirements() + { + $array = array(); + foreach ($this->requirements as $req) { + if (!$req->isFulfilled() && !$req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns all optional recommmendations. + * + * @return array Array of Requirement instances + */ + public function getRecommendations() + { + $array = array(); + foreach ($this->requirements as $req) { + if ($req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns the recommendations that were not met. + * + * @return array Array of Requirement instances + */ + public function getFailedRecommendations() + { + $array = array(); + foreach ($this->requirements as $req) { + if (!$req->isFulfilled() && $req->isOptional()) { + $array[] = $req; + } + } + + return $array; + } + + /** + * Returns whether a php.ini configuration is not correct. + * + * @return Boolean php.ini configuration problem? + */ + public function hasPhpIniConfigIssue() + { + foreach ($this->requirements as $req) { + if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { + return true; + } + } + + return false; + } + + /** + * Returns the PHP configuration file (php.ini) path. + * + * @return string|false php.ini file path + */ + public function getPhpIniConfigPath() + { + return get_cfg_var('cfg_file_path'); + } +} + +/** + * This class specifies all requirements and optional recommendations that + * are necessary to run the Symfony Standard Edition. + * + * @author Tobias Schultze + * @author Fabien Potencier + */ +class SymfonyRequirements extends RequirementCollection +{ + const REQUIRED_PHP_VERSION = '5.3.3'; + + /** + * Constructor that initializes the requirements. + */ + public function __construct() + { + /* mandatory requirements follow */ + + $installedPhpVersion = phpversion(); + + $this->addRequirement( + version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), + sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), + sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. + Before using Symfony, upgrade your PHP installation, preferably to the latest version.', + $installedPhpVersion, self::REQUIRED_PHP_VERSION), + sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) + ); + + $this->addRequirement( + version_compare($installedPhpVersion, '5.3.16', '!='), + 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', + 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' + ); + + $this->addRequirement( + is_dir(__DIR__.'/../vendor/composer'), + 'Vendor libraries must be installed', + 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. ' . + 'Then run "php composer.phar install" to install them.' + ); + + $baseDir = basename(__DIR__); + + $this->addRequirement( + is_writable(__DIR__.'/cache'), + "$baseDir/cache/ directory must be writable", + "Change the permissions of the \"$baseDir/cache/\" directory so that the web server can write into it." + ); + + $this->addRequirement( + is_writable(__DIR__.'/logs'), + "$baseDir/logs/ directory must be writable", + "Change the permissions of the \"$baseDir/logs/\" directory so that the web server can write into it." + ); + + $this->addPhpIniRequirement( + 'date.timezone', true, false, + 'date.timezone setting must be set', + 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' + ); + + if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { + $this->addRequirement( + (in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers())), + sprintf('Configured default timezone "%s" must be supported by your installation of PHP', date_default_timezone_get()), + 'Your default timezone is not supported by PHP. Check for typos in your php.ini file and have a look at the list of deprecated timezones at http://php.net/manual/en/timezones.others.php.' + ); + } + + $this->addRequirement( + function_exists('json_encode'), + 'json_encode() must be available', + 'Install and enable the JSON extension.' + ); + + $this->addRequirement( + function_exists('session_start'), + 'session_start() must be available', + 'Install and enable the session extension.' + ); + + $this->addRequirement( + function_exists('ctype_alpha'), + 'ctype_alpha() must be available', + 'Install and enable the ctype extension.' + ); + + $this->addRequirement( + function_exists('token_get_all'), + 'token_get_all() must be available', + 'Install and enable the Tokenizer extension.' + ); + + $this->addRequirement( + function_exists('simplexml_import_dom'), + 'simplexml_import_dom() must be available', + 'Install and enable the SimpleXML extension.' + ); + + if (function_exists('apc_store') && ini_get('apc.enabled')) { + $this->addRequirement( + version_compare(phpversion('apc'), '3.0.17', '>='), + 'APC version must be at least 3.0.17', + 'Upgrade your APC extension (3.0.17+).' + ); + } + + $this->addPhpIniRequirement('detect_unicode', false); + + if (extension_loaded('suhosin')) { + $this->addPhpIniRequirement( + 'suhosin.executor.include.whitelist', + create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), + false, + 'suhosin.executor.include.whitelist must be configured correctly in php.ini', + 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' + ); + } + + if (extension_loaded('xdebug')) { + $this->addPhpIniRequirement( + 'xdebug.show_exception_trace', false, true + ); + + $this->addPhpIniRequirement( + 'xdebug.scream', false, true + ); + } + + $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; + + $this->addRequirement( + null !== $pcreVersion && $pcreVersion > 8.0, + sprintf('PCRE extension must be available and at least 8.0 (%s installed)', $pcreVersion ? $pcreVersion : 'not'), + 'Upgrade your PCRE extension (8.0+).' + ); + + /* optional recommendations follow */ + + $this->addRecommendation( + file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), + 'Requirements file should be up-to-date', + 'Your requirements file is outdated. Run composer install and re-check your configuration.' + ); + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.3.4', '>='), + 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', + 'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' + ); + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.3.8', '>='), + 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', + 'Install PHP 5.3.8 or newer if your project uses annotations.' + ); + + $this->addRecommendation( + version_compare($installedPhpVersion, '5.4.0', '!='), + 'You should not use PHP 5.4.0 due to the PHP bug #61453', + 'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.' + ); + + $this->addRecommendation( + class_exists('DomDocument'), + 'PHP-XML module should be installed', + 'Install and enable the PHP-XML module.' + ); + + $this->addRecommendation( + function_exists('mb_strlen'), + 'mb_strlen() should be available', + 'Install and enable the mbstring extension.' + ); + + $this->addRecommendation( + function_exists('iconv'), + 'iconv() should be available', + 'Install and enable the iconv extension.' + ); + + $this->addRecommendation( + function_exists('utf8_decode'), + 'utf8_decode() should be available', + 'Install and enable the XML extension.' + ); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->addRecommendation( + function_exists('posix_isatty'), + 'posix_isatty() should be available', + 'Install and enable the php_posix extension (used to colorize the CLI output).' + ); + } + + $this->addRecommendation( + class_exists('Locale'), + 'intl extension should be available', + 'Install and enable the intl extension (used for validators).' + ); + + if (class_exists('Collator')) { + $this->addRecommendation( + null !== new Collator('fr_FR'), + 'intl extension should be correctly configured', + 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' + ); + } + + if (class_exists('Locale')) { + if (defined('INTL_ICU_VERSION')) { + $version = INTL_ICU_VERSION; + } else { + $reflector = new ReflectionExtension('intl'); + + ob_start(); + $reflector->info(); + $output = strip_tags(ob_get_clean()); + + preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); + $version = $matches[1]; + } + + $this->addRecommendation( + version_compare($version, '4.0', '>='), + 'intl ICU version should be at least 4+', + 'Upgrade your intl extension with a newer ICU version (4+).' + ); + } + + $accelerator = + (function_exists('apc_store') && ini_get('apc.enabled')) + || + function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') + || + function_exists('xcache_set') + ; + + $this->addRecommendation( + $accelerator, + 'a PHP accelerator should be installed', + 'Install and enable a PHP accelerator like APC (highly recommended).' + ); + + $this->addPhpIniRecommendation('short_open_tag', false); + + $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); + + $this->addPhpIniRecommendation('register_globals', false, true); + + $this->addPhpIniRecommendation('session.auto_start', false); + + $this->addRecommendation( + class_exists('PDO'), + 'PDO should be installed', + 'Install PDO (mandatory for Doctrine).' + ); + + if (class_exists('PDO')) { + $drivers = PDO::getAvailableDrivers(); + $this->addRecommendation( + count($drivers), + sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), + 'Install PDO drivers (mandatory for Doctrine).' + ); + } + } +} diff --git a/app/autoload.php b/symfony/app/autoload.php similarity index 96% rename from app/autoload.php rename to symfony/app/autoload.php index a68e37f..0cb9887 100644 --- a/app/autoload.php +++ b/symfony/app/autoload.php @@ -1,16 +1,16 @@ -add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs'); -} - -AnnotationRegistry::registerLoader(array($loader, 'loadClass')); - -return $loader; +add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs'); +} + +AnnotationRegistry::registerLoader(array($loader, 'loadClass')); + +return $loader; diff --git a/app/check.php b/symfony/app/check.php similarity index 96% rename from app/check.php rename to symfony/app/check.php index daa6d0a..70dd852 100644 --- a/app/check.php +++ b/symfony/app/check.php @@ -1,55 +1,55 @@ -getPhpIniConfigPath(); - -echo "********************************\n"; -echo "* *\n"; -echo "* Symfony requirements check *\n"; -echo "* *\n"; -echo "********************************\n\n"; - -echo $iniPath ? sprintf("* Configuration file used by PHP: %s\n\n", $iniPath) : "* WARNING: No configuration file (php.ini) used by PHP!\n\n"; - -echo "** ATTENTION **\n"; -echo "* The PHP CLI can use a different php.ini file\n"; -echo "* than the one used with your web server.\n"; -if ('\\' == DIRECTORY_SEPARATOR) { - echo "* (especially on the Windows platform)\n"; -} -echo "* To be on the safe side, please also launch the requirements check\n"; -echo "* from your web server using the web/config.php script.\n"; - -echo_title('Mandatory requirements'); - -foreach ($symfonyRequirements->getRequirements() as $req) { - echo_requirement($req); -} - -echo_title('Optional recommendations'); - -foreach ($symfonyRequirements->getRecommendations() as $req) { - echo_requirement($req); -} - -/** - * Prints a Requirement instance - */ -function echo_requirement(Requirement $requirement) -{ - $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR'); - echo ' ' . str_pad($result, 9); - echo $requirement->getTestMessage() . "\n"; - - if (!$requirement->isFulfilled()) { - echo sprintf(" %s\n\n", $requirement->getHelpText()); - } -} - -function echo_title($title) -{ - echo "\n** $title **\n\n"; -} +getPhpIniConfigPath(); + +echo "********************************\n"; +echo "* *\n"; +echo "* Symfony requirements check *\n"; +echo "* *\n"; +echo "********************************\n\n"; + +echo $iniPath ? sprintf("* Configuration file used by PHP: %s\n\n", $iniPath) : "* WARNING: No configuration file (php.ini) used by PHP!\n\n"; + +echo "** ATTENTION **\n"; +echo "* The PHP CLI can use a different php.ini file\n"; +echo "* than the one used with your web server.\n"; +if ('\\' == DIRECTORY_SEPARATOR) { + echo "* (especially on the Windows platform)\n"; +} +echo "* To be on the safe side, please also launch the requirements check\n"; +echo "* from your web server using the web/config.php script.\n"; + +echo_title('Mandatory requirements'); + +foreach ($symfonyRequirements->getRequirements() as $req) { + echo_requirement($req); +} + +echo_title('Optional recommendations'); + +foreach ($symfonyRequirements->getRecommendations() as $req) { + echo_requirement($req); +} + +/** + * Prints a Requirement instance + */ +function echo_requirement(Requirement $requirement) +{ + $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR'); + echo ' ' . str_pad($result, 9); + echo $requirement->getTestMessage() . "\n"; + + if (!$requirement->isFulfilled()) { + echo sprintf(" %s\n\n", $requirement->getHelpText()); + } +} + +function echo_title($title) +{ + echo "\n** $title **\n\n"; +} diff --git a/app/config/config.yml b/symfony/app/config/config.yml similarity index 96% rename from app/config/config.yml rename to symfony/app/config/config.yml index 048a339..6c5f7d7 100644 --- a/app/config/config.yml +++ b/symfony/app/config/config.yml @@ -1,58 +1,58 @@ -imports: - - { resource: parameters.yml } - - { resource: security.yml } - -framework: - #esi: ~ - #translator: { fallback: %locale% } - secret: %secret% - router: - resource: "%kernel.root_dir%/config/routing.yml" - strict_requirements: %kernel.debug% - form: true - csrf_protection: true - validation: { enable_annotations: true } - templating: { engines: ['twig'] } #assets_version: SomeVersionScheme - default_locale: %locale% - trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP) - session: ~ - -# Twig Configuration -twig: - debug: %kernel.debug% - strict_variables: %kernel.debug% - -# Assetic Configuration -assetic: - debug: %kernel.debug% - use_controller: false - bundles: [ ] - #java: /usr/bin/java - filters: - cssrewrite: ~ - #closure: - # jar: %kernel.root_dir%/Resources/java/compiler.jar - #yui_css: - # jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar - -# Doctrine Configuration -doctrine: - dbal: - driver: pdo_pgsql - host: localhost - dbname: bodyrep - user: goo - password: - charset: UTF8 - - orm: - auto_generate_proxy_classes: %kernel.debug% - auto_mapping: true - -# Swiftmailer Configuration -swiftmailer: - transport: %mailer_transport% - host: %mailer_host% - username: %mailer_user% - password: %mailer_password% - spool: { type: memory } +imports: + - { resource: parameters.yml } + - { resource: security.yml } + +framework: + #esi: ~ + #translator: { fallback: %locale% } + secret: %secret% + router: + resource: "%kernel.root_dir%/config/routing.yml" + strict_requirements: %kernel.debug% + form: true + csrf_protection: true + validation: { enable_annotations: true } + templating: { engines: ['twig'] } #assets_version: SomeVersionScheme + default_locale: %locale% + trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP) + session: ~ + +# Twig Configuration +twig: + debug: %kernel.debug% + strict_variables: %kernel.debug% + +# Assetic Configuration +assetic: + debug: %kernel.debug% + use_controller: false + bundles: [ ] + #java: /usr/bin/java + filters: + cssrewrite: ~ + #closure: + # jar: %kernel.root_dir%/Resources/java/compiler.jar + #yui_css: + # jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_pgsql + host: localhost + dbname: bodyrep + user: goo + password: + charset: UTF8 + + orm: + auto_generate_proxy_classes: %kernel.debug% + auto_mapping: true + +# Swiftmailer Configuration +swiftmailer: + transport: %mailer_transport% + host: %mailer_host% + username: %mailer_user% + password: %mailer_password% + spool: { type: memory } diff --git a/app/config/config_dev.yml b/symfony/app/config/config_dev.yml similarity index 95% rename from app/config/config_dev.yml rename to symfony/app/config/config_dev.yml index b7e675d..910934c 100644 --- a/app/config/config_dev.yml +++ b/symfony/app/config/config_dev.yml @@ -1,26 +1,26 @@ -imports: - - { resource: config.yml } - -framework: - router: { resource: "%kernel.root_dir%/config/routing_dev.yml" } - profiler: { only_exceptions: false } - -web_profiler: - toolbar: true - intercept_redirects: false - -monolog: - handlers: - main: - type: stream - path: %kernel.logs_dir%/%kernel.environment%.log - level: debug - firephp: - type: firephp - level: info - -assetic: - use_controller: true - -#swiftmailer: -# delivery_address: me@example.com +imports: + - { resource: config.yml } + +framework: + router: { resource: "%kernel.root_dir%/config/routing_dev.yml" } + profiler: { only_exceptions: false } + +web_profiler: + toolbar: true + intercept_redirects: false + +monolog: + handlers: + main: + type: stream + path: %kernel.logs_dir%/%kernel.environment%.log + level: debug + firephp: + type: firephp + level: info + +assetic: + use_controller: true + +#swiftmailer: +# delivery_address: me@example.com diff --git a/app/config/config_prod.yml b/symfony/app/config/config_prod.yml similarity index 95% rename from app/config/config_prod.yml rename to symfony/app/config/config_prod.yml index 0b91d4d..e34e06f 100644 --- a/app/config/config_prod.yml +++ b/symfony/app/config/config_prod.yml @@ -1,19 +1,19 @@ -imports: - - { resource: config.yml } - -#doctrine: -# orm: -# metadata_cache_driver: apc -# result_cache_driver: apc -# query_cache_driver: apc - -monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - nested: - type: stream - path: %kernel.logs_dir%/%kernel.environment%.log - level: debug +imports: + - { resource: config.yml } + +#doctrine: +# orm: +# metadata_cache_driver: apc +# result_cache_driver: apc +# query_cache_driver: apc + +monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + nested: + type: stream + path: %kernel.logs_dir%/%kernel.environment%.log + level: debug diff --git a/app/config/config_test.yml b/symfony/app/config/config_test.yml similarity index 94% rename from app/config/config_test.yml rename to symfony/app/config/config_test.yml index e7f44e5..0b4d1b8 100644 --- a/app/config/config_test.yml +++ b/symfony/app/config/config_test.yml @@ -1,14 +1,14 @@ -imports: - - { resource: config_dev.yml } - -framework: - test: ~ - session: - storage_id: session.storage.mock_file - -web_profiler: - toolbar: false - intercept_redirects: false - -swiftmailer: - disable_delivery: true +imports: + - { resource: config_dev.yml } + +framework: + test: ~ + session: + storage_id: session.storage.mock_file + +web_profiler: + toolbar: false + intercept_redirects: false + +swiftmailer: + disable_delivery: true diff --git a/app/config/parameters.yml b/symfony/app/config/parameters.yml similarity index 96% rename from app/config/parameters.yml rename to symfony/app/config/parameters.yml index 6f0c6ee..f998e34 100644 --- a/app/config/parameters.yml +++ b/symfony/app/config/parameters.yml @@ -1,15 +1,15 @@ -parameters: - database_driver: pdo_mysql - database_host: localhost - database_port: ~ - database_name: symfony - database_user: root - database_password: ~ - - mailer_transport: smtp - mailer_host: localhost - mailer_user: ~ - mailer_password: ~ - - locale: en - secret: ThisTokenIsNotSoSecretChangeIt +parameters: + database_driver: pdo_mysql + database_host: localhost + database_port: ~ + database_name: symfony + database_user: root + database_password: ~ + + mailer_transport: smtp + mailer_host: localhost + mailer_user: ~ + mailer_password: ~ + + locale: en + secret: ThisTokenIsNotSoSecretChangeIt diff --git a/app/config/routing.yml b/symfony/app/config/routing.yml similarity index 95% rename from app/config/routing.yml rename to symfony/app/config/routing.yml index 2e6d48d..dc950b1 100644 --- a/app/config/routing.yml +++ b/symfony/app/config/routing.yml @@ -1,13 +1,13 @@ -_landing: - resource: "@BodyRep/Controller/LandingController.php" - type: annotation - prefix: / - -_profile: - pattern: /{username} - defaults: { _controller: BodyRep:Profile:index } - -_member: - resource: "@BodyRep/Controller/MemberController.php" - type: annotation - prefix: /m +_landing: + resource: "@BodyRep/Controller/LandingController.php" + type: annotation + prefix: / + +_profile: + pattern: /{username} + defaults: { _controller: BodyRep:Profile:index } + +_member: + resource: "@BodyRep/Controller/MemberController.php" + type: annotation + prefix: /m diff --git a/app/config/routing_dev.yml b/symfony/app/config/routing_dev.yml similarity index 96% rename from app/config/routing_dev.yml rename to symfony/app/config/routing_dev.yml index ff93a02..45e8681 100644 --- a/app/config/routing_dev.yml +++ b/symfony/app/config/routing_dev.yml @@ -1,14 +1,14 @@ -_wdt: - resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" - prefix: /_wdt - -_profiler: - resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" - prefix: /_profiler - -_configurator: - resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml" - prefix: /_configurator - -_main: - resource: routing.yml +_wdt: + resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" + prefix: /_wdt + +_profiler: + resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" + prefix: /_profiler + +_configurator: + resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml" + prefix: /_configurator + +_main: + resource: routing.yml diff --git a/app/config/security.yml b/symfony/app/config/security.yml similarity index 96% rename from app/config/security.yml rename to symfony/app/config/security.yml index 29b6467..5c54d58 100644 --- a/app/config/security.yml +++ b/symfony/app/config/security.yml @@ -1,49 +1,49 @@ -jms_security_extra: - secure_all_services: false - expressions: true - -security: - encoders: - Symfony\Component\Security\Core\User\User: plaintext - - role_hierarchy: - ROLE_ADMIN: ROLE_USER - ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] - - providers: - in_memory: - memory: - users: - alexzb: { password: d559ko54, roles: [ 'ROLE_ADMIN' ] } - alexl: { password: d559ko54, roles: [ 'ROLE_ADMIN' ] } - ghuntley: { password: d559ko54, roles: [ 'ROLE_ADMIN' ] } - - firewalls: - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - login: - pattern: ^/m/login$ - security: false - - landing: - pattern: ^/$ - security: false - - contact: - pattern: ^/contact$ - security: false - - secured_area: - pattern: ^/ - form_login: - check_path: /m/login_check - login_path: /m/login - logout: - path: /m/logout - target: / - - access_control: - #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https } - #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 } +jms_security_extra: + secure_all_services: false + expressions: true + +security: + encoders: + Symfony\Component\Security\Core\User\User: plaintext + + role_hierarchy: + ROLE_ADMIN: ROLE_USER + ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] + + providers: + in_memory: + memory: + users: + alexzb: { password: d559ko54, roles: [ 'ROLE_ADMIN' ] } + alexl: { password: d559ko54, roles: [ 'ROLE_ADMIN' ] } + ghuntley: { password: d559ko54, roles: [ 'ROLE_ADMIN' ] } + + firewalls: + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + login: + pattern: ^/m/login$ + security: false + + landing: + pattern: ^/$ + security: false + + contact: + pattern: ^/contact$ + security: false + + secured_area: + pattern: ^/ + form_login: + check_path: /m/login_check + login_path: /m/login + logout: + path: /m/logout + target: / + + access_control: + #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https } + #- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 } diff --git a/app/console b/symfony/app/console similarity index 97% rename from app/console rename to symfony/app/console index 1de6db4..ca3baf4 100644 --- a/app/console +++ b/symfony/app/console @@ -1,22 +1,22 @@ -#!/usr/bin/env php -getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); -$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; - -$kernel = new AppKernel($env, $debug); -$application = new Application($kernel); -$application->run($input); +#!/usr/bin/env php +getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); +$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; + +$kernel = new AppKernel($env, $debug); +$application = new Application($kernel); +$application->run($input); diff --git a/app/phpunit.xml.dist b/symfony/app/phpunit.xml.dist similarity index 97% rename from app/phpunit.xml.dist rename to symfony/app/phpunit.xml.dist index 1e31086..20c6ecf 100644 --- a/app/phpunit.xml.dist +++ b/symfony/app/phpunit.xml.dist @@ -1,41 +1,41 @@ - - - - - - - - ../src/*/*Bundle/Tests - ../src/*/Bundle/*Bundle/Tests - - - - - - - - ../src - - ../src/*/*Bundle/Resources - ../src/*/*Bundle/Tests - ../src/*/Bundle/*Bundle/Resources - ../src/*/Bundle/*Bundle/Tests - - - - - + + + + + + + + ../src/*/*Bundle/Tests + ../src/*/Bundle/*Bundle/Tests + + + + + + + + ../src + + ../src/*/*Bundle/Resources + ../src/*/*Bundle/Tests + ../src/*/Bundle/*Bundle/Resources + ../src/*/Bundle/*Bundle/Tests + + + + + diff --git a/composer.json b/symfony/composer.json similarity index 97% rename from composer.json rename to symfony/composer.json index d5490c7..25c59a1 100644 --- a/composer.json +++ b/symfony/composer.json @@ -1,45 +1,45 @@ -{ - "name": "symfony/framework-standard-edition", - "description": "The \"Symfony Standard Edition\" distribution", - "autoload": { - "psr-0": { "": "src/" } - }, - "require": { - "php": ">=5.3.3", - "symfony/symfony": "2.1.*", - "doctrine/orm": ">=2.2.3,<2.4-dev", - "doctrine/doctrine-bundle": "1.0.*", - "twig/extensions": "1.0.*", - "symfony/assetic-bundle": "2.1.*", - "symfony/swiftmailer-bundle": "2.1.*", - "symfony/monolog-bundle": "2.1.*", - "sensio/distribution-bundle": "2.1.*", - "sensio/framework-extra-bundle": "2.1.*", - "sensio/generator-bundle": "2.1.*", - "jms/security-extra-bundle": "1.2.*", - "jms/di-extra-bundle": "1.1.*", - "knplabs/doctrine-behaviors": "dev-master" - }, - "scripts": { - "post-install-cmd": [ - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" - ], - "post-update-cmd": [ - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", - "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" - ] - }, - "config": { - "bin-dir": "bin" - }, - "minimum-stability": "dev", - "extra": { - "symfony-app-dir": "app", - "symfony-web-dir": "web" - } -} +{ + "name": "symfony/framework-standard-edition", + "description": "The \"Symfony Standard Edition\" distribution", + "autoload": { + "psr-0": { "": "src/" } + }, + "require": { + "php": ">=5.3.3", + "symfony/symfony": "2.1.*", + "doctrine/orm": ">=2.2.3,<2.4-dev", + "doctrine/doctrine-bundle": "1.0.*", + "twig/extensions": "1.0.*", + "symfony/assetic-bundle": "2.1.*", + "symfony/swiftmailer-bundle": "2.1.*", + "symfony/monolog-bundle": "2.1.*", + "sensio/distribution-bundle": "2.1.*", + "sensio/framework-extra-bundle": "2.1.*", + "sensio/generator-bundle": "2.1.*", + "jms/security-extra-bundle": "1.2.*", + "jms/di-extra-bundle": "1.1.*", + "knplabs/doctrine-behaviors": "dev-master" + }, + "scripts": { + "post-install-cmd": [ + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" + ], + "post-update-cmd": [ + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", + "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" + ] + }, + "config": { + "bin-dir": "bin" + }, + "minimum-stability": "dev", + "extra": { + "symfony-app-dir": "app", + "symfony-web-dir": "web" + } +} diff --git a/src/BodyRep/BodyRep.php b/symfony/src/BodyRep/BodyRep.php similarity index 92% rename from src/BodyRep/BodyRep.php rename to symfony/src/BodyRep/BodyRep.php index dc6d9c9..fd6d7b2 100644 --- a/src/BodyRep/BodyRep.php +++ b/symfony/src/BodyRep/BodyRep.php @@ -1,9 +1,9 @@ -generateUrl('_login')); - } - - /** - /** - * @Route("/login", name="_login") - * @Template() - */ - public function loginAction() - { - $request = $this->getRequest(); - $session = $request->getSession(); - - // get the login error if there is one - if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) { - $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); - } else { - $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); - } - - return $this->render('BodyRep:Auth:login.html.twig', array( - // last username entered by the user - 'last_username' => $session->get(SecurityContext::LAST_USERNAME), - 'error' => $error, - )); - } - /** - * @Route("/login/check", name="_login_check") - * @Template() - */ - public function securityCheckAction() - { - // The security layer will intercept this request - } - /** - * @Route("/logout", name="_logout") - * @Template() - */ - public function logoutAction() - { - // The security layer will intercept this request - } - - public function navbarAction() - { - // The security layer will intercept this request - } +generateUrl('_login')); + } + + /** + /** + * @Route("/login", name="_login") + * @Template() + */ + public function loginAction() + { + $request = $this->getRequest(); + $session = $request->getSession(); + + // get the login error if there is one + if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) { + $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); + } else { + $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); + } + + return $this->render('BodyRep:Auth:login.html.twig', array( + // last username entered by the user + 'last_username' => $session->get(SecurityContext::LAST_USERNAME), + 'error' => $error, + )); + } + /** + * @Route("/login/check", name="_login_check") + * @Template() + */ + public function securityCheckAction() + { + // The security layer will intercept this request + } + /** + * @Route("/logout", name="_logout") + * @Template() + */ + public function logoutAction() + { + // The security layer will intercept this request + } + + public function navbarAction() + { + // The security layer will intercept this request + } } \ No newline at end of file diff --git a/src/BodyRep/Controller/CommentController.php b/symfony/src/BodyRep/Controller/CommentController.php similarity index 97% rename from src/BodyRep/Controller/CommentController.php rename to symfony/src/BodyRep/Controller/CommentController.php index 5e55ff7..f947f48 100644 --- a/src/BodyRep/Controller/CommentController.php +++ b/symfony/src/BodyRep/Controller/CommentController.php @@ -1,65 +1,65 @@ -getUser()->getUsername() == $username) - return new RedirectResponse($this->generateUrl('_member_profile')); - - $db = $this->getDoctrine()->getManager(); - - $query = $db->createQuery(' - SELECT p - FROM BodyRep:Profile p - WHERE p.username = :username') - ->setParameter('username', $username) - ->setMaxResults(1); - if (sizeof($query->getResult()) != 1) - throw $this->createNotFoundException("User '".$username."' not found"); - - $profile = $query->getSingleResult(); - $username = $this->getUser()->getUsername(); - $db = $this->getDoctrine()->getManager(); - $query = $db->createQuery(' - SELECT m - FROM BodyRep:Member m - WHERE m.username = :username') - ->setParameter('username', $username) - ->setMaxResults(1); - - if (sizeof($query->getResult()) != 1) - throw $this->createNotFoundException("User '".$username."' not found"); - - $member = $query->getSingleResult(); - - return (array('sFullName' => $profile->getFullName(), 'name' => $member->getFullName())); - - } - /** - * @Route("/rep", name="_profile_reputation") - * @Template() - */ - public function reputationAction($username) - { - return $this->indexAction($username); - } - - -} +getUser()->getUsername() == $username) + return new RedirectResponse($this->generateUrl('_member_profile')); + + $db = $this->getDoctrine()->getManager(); + + $query = $db->createQuery(' + SELECT p + FROM BodyRep:Profile p + WHERE p.username = :username') + ->setParameter('username', $username) + ->setMaxResults(1); + if (sizeof($query->getResult()) != 1) + throw $this->createNotFoundException("User '".$username."' not found"); + + $profile = $query->getSingleResult(); + $username = $this->getUser()->getUsername(); + $db = $this->getDoctrine()->getManager(); + $query = $db->createQuery(' + SELECT m + FROM BodyRep:Member m + WHERE m.username = :username') + ->setParameter('username', $username) + ->setMaxResults(1); + + if (sizeof($query->getResult()) != 1) + throw $this->createNotFoundException("User '".$username."' not found"); + + $member = $query->getSingleResult(); + + return (array('sFullName' => $profile->getFullName(), 'name' => $member->getFullName())); + + } + /** + * @Route("/rep", name="_profile_reputation") + * @Template() + */ + public function reputationAction($username) + { + return $this->indexAction($username); + } + + +} diff --git a/src/BodyRep/Controller/LandingController.php b/symfony/src/BodyRep/Controller/LandingController.php similarity index 95% rename from src/BodyRep/Controller/LandingController.php rename to symfony/src/BodyRep/Controller/LandingController.php index e72c501..9302857 100644 --- a/src/BodyRep/Controller/LandingController.php +++ b/symfony/src/BodyRep/Controller/LandingController.php @@ -1,43 +1,43 @@ -render('BodyRep:Landing:index.html.twig'); - } - - /** - * @Route("/about", name="_landing_about") - * @Template() - */ - public function aboutAction() - { - - /* - * The action's view can be rendered using render() method - * or @Template annotation as demonstrated in DemoController. - * - */ - return $this->render('BodyRep:Landing:about.html.twig'); - } -} +render('BodyRep:Landing:index.html.twig'); + } + + /** + * @Route("/about", name="_landing_about") + * @Template() + */ + public function aboutAction() + { + + /* + * The action's view can be rendered using render() method + * or @Template annotation as demonstrated in DemoController. + * + */ + return $this->render('BodyRep:Landing:about.html.twig'); + } +} diff --git a/src/BodyRep/Controller/MemberController.php b/symfony/src/BodyRep/Controller/MemberController.php similarity index 96% rename from src/BodyRep/Controller/MemberController.php rename to symfony/src/BodyRep/Controller/MemberController.php index be7d9db..7385c0a 100644 --- a/src/BodyRep/Controller/MemberController.php +++ b/symfony/src/BodyRep/Controller/MemberController.php @@ -1,192 +1,192 @@ -getUser(); - - if (method_exists($user, 'getUsername')) - { - $db = $this->getDoctrine()->getManager(); - $username = $this->getUser()->getUsername(); - - $query = $db->createQuery(' - SELECT m - FROM BodyRep:Member m - WHERE m.username = :username') - ->setParameter('username', $username) - ->setMaxResults(1); - - if (sizeof($query->getResult()) != 1) - throw $this->createNotFoundException("User '".$username."' not found"); - - $this->member = $query->getSingleResult(); - } - else - trigger_error("Container cannot determine member information"); - } - - - private function getMember() - { - return $this->member; - } - - public function navbarAction() - { - // The security layer will intercept this request - } - - /** - * @Route("/", name="_member") - * @Template() - */ - public function indexAction() - { - $username = $this->getUser()->getUsername(); - - - return array('name' => $this->getMember()->getFullName()); - } - - /** - * @Route("/profile/", name="_member_profile") - * @Template() - */ - public function profileAction() - { - $username = $this->getUser()->getUsername(); - - $db = $this->getDoctrine()->getManager(); - $query = $db->createQuery(' - SELECT p - FROM BodyRep:Profile p - WHERE p.username = :username') - ->setParameter('username', $username) - ->setMaxResults(1); - if (sizeof($query->getResult()) != 1) - throw $this->createNotFoundException("User '".$username."' not found"); - - $profile = $query->getSingleResult(); - - return (array('sFullName' => $profile->getFullName(), 'name' => $this->getMember()->getFullName())); - } - - /** - * @Route("/profile/edit", name="_member_profile_edit") - * @Template() - */ - public function editProfileAction() - { - $username = $this->getUser()->getUsername(); - $form = $this->get('form.factory')->create(new Profile(), array('fullname' => $this->getMember()->getFullName())); - $error = ''; - - return array('form' => $form->createView(), 'error' => ''); - } - - /** - * @Route("/profile/save", name="_member_profile_save") - */ - public function saveAction() - { - $username = $this->getUser()->getUsername(); - $db = $this->getDoctrine()->getManager(); - $json = array('result' => 0); - - $form = $this->get('form.factory')->create(new Profile()); - $request = $this->get('request'); - - - $form->bind($request); - $np1 = $request->get('_newpass1'); - $np2 = $request->get('_newpass2'); - // if (!empty($np1) && !$np1 != $np2) - // $form->get("fullname")->addError(new FormError('Passwords do not match')); - - if ($form->isValid() && sizeof($_POST) > 0) - { - $json['result'] = 1; - if (!empty($np1)) - { - $factory = $this->get('security.encoder_factory'); - $encoder = $factory->getEncoder($this->getUser()); - $password = $encoder->encodePassword($np1, $this->getUser()->getSalt()); - - $this->member->setPassword($password); - } - $d = $form->getClientData(); - $this->getMember()->setFullName($d['fullname']); - $db->persist($this->getMember()); - $db->flush(); - } - - $resp = new Response (json_encode($json)); - $resp->headers->set('Content-Type', 'application/json'); - - return $resp; - } - /** - * @Route("/search/{param}", name="_member_search", defaults={"param" = 0}) - * @Template() - */ - public function searchAction($param='') - { - - /* - * Integrated suggester response - * - */ - $em = $this->getDoctrine()->getManager(); - $query = $em->createQuery("SELECT m FROM BodyRep:Member m WHERE m.fullname ILIKE '%$param%'"); - - $res = $query->getResult(); - $resc = sizeof($res); - $sugg = array(); - /*if ($res > 0) - { - foreach ($res as $member) - { - $text = preg_replace('/]*>/i', "\n", $member->getFullname()); - $item['text'] = strip_tags($text); - $item['html'] = $text; - $item['data'] = array('username' => htmlspecialchars($member->getUsername())); - $sugg[] = $item; - } - } - if (!empty($param)) - { - $json = array('result' => 1, 'suggestions' => $sugg); - $resp = new Response (json_encode($json)); - $resp->headers->set('Content-Type', 'text/plain'); - return $resp; - } - else*/ - return array('search' => $res); - } -} +getUser(); + + if (method_exists($user, 'getUsername')) + { + $db = $this->getDoctrine()->getManager(); + $username = $this->getUser()->getUsername(); + + $query = $db->createQuery(' + SELECT m + FROM BodyRep:Member m + WHERE m.username = :username') + ->setParameter('username', $username) + ->setMaxResults(1); + + if (sizeof($query->getResult()) != 1) + throw $this->createNotFoundException("User '".$username."' not found"); + + $this->member = $query->getSingleResult(); + } + else + trigger_error("Container cannot determine member information"); + } + + + private function getMember() + { + return $this->member; + } + + public function navbarAction() + { + // The security layer will intercept this request + } + + /** + * @Route("/", name="_member") + * @Template() + */ + public function indexAction() + { + $username = $this->getUser()->getUsername(); + + + return array('name' => $this->getMember()->getFullName()); + } + + /** + * @Route("/profile/", name="_member_profile") + * @Template() + */ + public function profileAction() + { + $username = $this->getUser()->getUsername(); + + $db = $this->getDoctrine()->getManager(); + $query = $db->createQuery(' + SELECT p + FROM BodyRep:Profile p + WHERE p.username = :username') + ->setParameter('username', $username) + ->setMaxResults(1); + if (sizeof($query->getResult()) != 1) + throw $this->createNotFoundException("User '".$username."' not found"); + + $profile = $query->getSingleResult(); + + return (array('sFullName' => $profile->getFullName(), 'name' => $this->getMember()->getFullName())); + } + + /** + * @Route("/profile/edit", name="_member_profile_edit") + * @Template() + */ + public function editProfileAction() + { + $username = $this->getUser()->getUsername(); + $form = $this->get('form.factory')->create(new Profile(), array('fullname' => $this->getMember()->getFullName())); + $error = ''; + + return array('form' => $form->createView(), 'error' => ''); + } + + /** + * @Route("/profile/save", name="_member_profile_save") + */ + public function saveAction() + { + $username = $this->getUser()->getUsername(); + $db = $this->getDoctrine()->getManager(); + $json = array('result' => 0); + + $form = $this->get('form.factory')->create(new Profile()); + $request = $this->get('request'); + + + $form->bind($request); + $np1 = $request->get('_newpass1'); + $np2 = $request->get('_newpass2'); + // if (!empty($np1) && !$np1 != $np2) + // $form->get("fullname")->addError(new FormError('Passwords do not match')); + + if ($form->isValid() && sizeof($_POST) > 0) + { + $json['result'] = 1; + if (!empty($np1)) + { + $factory = $this->get('security.encoder_factory'); + $encoder = $factory->getEncoder($this->getUser()); + $password = $encoder->encodePassword($np1, $this->getUser()->getSalt()); + + $this->member->setPassword($password); + } + $d = $form->getClientData(); + $this->getMember()->setFullName($d['fullname']); + $db->persist($this->getMember()); + $db->flush(); + } + + $resp = new Response (json_encode($json)); + $resp->headers->set('Content-Type', 'application/json'); + + return $resp; + } + /** + * @Route("/search/{param}", name="_member_search", defaults={"param" = 0}) + * @Template() + */ + public function searchAction($param='') + { + + /* + * Integrated suggester response + * + */ + $em = $this->getDoctrine()->getManager(); + $query = $em->createQuery("SELECT m FROM BodyRep:Member m WHERE m.fullname ILIKE '%$param%'"); + + $res = $query->getResult(); + $resc = sizeof($res); + $sugg = array(); + /*if ($res > 0) + { + foreach ($res as $member) + { + $text = preg_replace('/]*>/i', "\n", $member->getFullname()); + $item['text'] = strip_tags($text); + $item['html'] = $text; + $item['data'] = array('username' => htmlspecialchars($member->getUsername())); + $sugg[] = $item; + } + } + if (!empty($param)) + { + $json = array('result' => 1, 'suggestions' => $sugg); + $resp = new Response (json_encode($json)); + $resp->headers->set('Content-Type', 'text/plain'); + return $resp; + } + else*/ + return array('search' => $res); + } +} diff --git a/src/BodyRep/Controller/ProfileController.php b/symfony/src/BodyRep/Controller/ProfileController.php similarity index 97% rename from src/BodyRep/Controller/ProfileController.php rename to symfony/src/BodyRep/Controller/ProfileController.php index f60a462..98ec25f 100644 --- a/src/BodyRep/Controller/ProfileController.php +++ b/symfony/src/BodyRep/Controller/ProfileController.php @@ -1,65 +1,65 @@ -getUser()->getUsername() == $username) - return new RedirectResponse($this->generateUrl('_member_profile')); - - $db = $this->getDoctrine()->getManager(); - - $query = $db->createQuery(' - SELECT p - FROM BodyRep:Profile p - WHERE p.username = :username') - ->setParameter('username', $username) - ->setMaxResults(1); - if (sizeof($query->getResult()) != 1) - throw $this->createNotFoundException("User '".$username."' not found"); - - $profile = $query->getSingleResult(); - $username = $this->getUser()->getUsername(); - $db = $this->getDoctrine()->getManager(); - $query = $db->createQuery(' - SELECT m - FROM BodyRep:Member m - WHERE m.username = :username') - ->setParameter('username', $username) - ->setMaxResults(1); - - if (sizeof($query->getResult()) != 1) - throw $this->createNotFoundException("User '".$username."' not found"); - - $member = $query->getSingleResult(); - - return (array('sFullName' => $profile->getFullName(), 'name' => $member->getFullName())); - - } - /** - * @Route("/rep", name="_profile_reputation") - * @Template() - */ - public function reputationAction($username) - { - return $this->indexAction($username); - } - - -} +getUser()->getUsername() == $username) + return new RedirectResponse($this->generateUrl('_member_profile')); + + $db = $this->getDoctrine()->getManager(); + + $query = $db->createQuery(' + SELECT p + FROM BodyRep:Profile p + WHERE p.username = :username') + ->setParameter('username', $username) + ->setMaxResults(1); + if (sizeof($query->getResult()) != 1) + throw $this->createNotFoundException("User '".$username."' not found"); + + $profile = $query->getSingleResult(); + $username = $this->getUser()->getUsername(); + $db = $this->getDoctrine()->getManager(); + $query = $db->createQuery(' + SELECT m + FROM BodyRep:Member m + WHERE m.username = :username') + ->setParameter('username', $username) + ->setMaxResults(1); + + if (sizeof($query->getResult()) != 1) + throw $this->createNotFoundException("User '".$username."' not found"); + + $member = $query->getSingleResult(); + + return (array('sFullName' => $profile->getFullName(), 'name' => $member->getFullName())); + + } + /** + * @Route("/rep", name="_profile_reputation") + * @Template() + */ + public function reputationAction($username) + { + return $this->indexAction($username); + } + + +} diff --git a/src/BodyRep/DependencyInjection/BodyRepExtension.php b/symfony/src/BodyRep/DependencyInjection/BodyRepExtension.php similarity index 96% rename from src/BodyRep/DependencyInjection/BodyRepExtension.php rename to symfony/src/BodyRep/DependencyInjection/BodyRepExtension.php index 52c0661..5c71113 100644 --- a/src/BodyRep/DependencyInjection/BodyRepExtension.php +++ b/symfony/src/BodyRep/DependencyInjection/BodyRepExtension.php @@ -1,22 +1,22 @@ -load('/data/www/br/src/BodyRep/Resources/config/services.yml'); - } - - public function getAlias() - { - return 'body_rep'; - } -} +load('/data/www/br/src/BodyRep/Resources/config/services.yml'); + } + + public function getAlias() + { + return 'body_rep'; + } +} diff --git a/src/BodyRep/Entity/Comment.php b/symfony/src/BodyRep/Entity/Comment.php similarity index 94% rename from src/BodyRep/Entity/Comment.php rename to symfony/src/BodyRep/Entity/Comment.php index 5c56dc3..abb8ba7 100644 --- a/src/BodyRep/Entity/Comment.php +++ b/symfony/src/BodyRep/Entity/Comment.php @@ -1,115 +1,115 @@ -id; - } - - /** - * Set author - * - * @param string $author - * @return Comment - */ - public function setAuthor($author) - { - $this->author = $author; - - return $this; - } - - /** - * Get author - * - * @return string - */ - public function getAuthor() - { - return $this->author; - } - - /** - * Set text - * - * @param string $text - * @return Comment - */ - public function setText($text) - { - $this->text = $text; - - return $this; - } - - /** - * Get text - * - * @return string - */ - public function getText() - { - return $this->text; - } - - /** - * Set created - * - * @param timestamp $created - * @return Comment - */ - public function setCreated(\timestamp $created) - { - $this->created = $created; - - return $this; - } - - /** - * Get created - * - * @return timestamp - */ - public function getCreated() - { - return $this->created; - } +id; + } + + /** + * Set author + * + * @param string $author + * @return Comment + */ + public function setAuthor($author) + { + $this->author = $author; + + return $this; + } + + /** + * Get author + * + * @return string + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Set text + * + * @param string $text + * @return Comment + */ + public function setText($text) + { + $this->text = $text; + + return $this; + } + + /** + * Get text + * + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Set created + * + * @param timestamp $created + * @return Comment + */ + public function setCreated(\timestamp $created) + { + $this->created = $created; + + return $this; + } + + /** + * Get created + * + * @return timestamp + */ + public function getCreated() + { + return $this->created; + } } \ No newline at end of file diff --git a/src/BodyRep/Entity/Member.php b/symfony/src/BodyRep/Entity/Member.php similarity index 94% rename from src/BodyRep/Entity/Member.php rename to symfony/src/BodyRep/Entity/Member.php index 83c0dce..3349dae 100644 --- a/src/BodyRep/Entity/Member.php +++ b/symfony/src/BodyRep/Entity/Member.php @@ -1,149 +1,149 @@ -username = $username; - $this->password = $password; - $this->salt = $salt; - $this->roles = $roles; - } - - /** - * @inheritDoc - */ - public function getUsername() - { - return $this->username; - } - - - /** - * @inheritDoc - */ - public function getSalt() - { - return $this->salt; - } - - /** - * @inheritDoc - */ - public function getPassword() - { - return $this->password; - } - - /** - * @inheritDoc - */ - public function getRoles() - { - return array('ROLE_USER'); - } - - /** - * @inheritDoc - */ - public function eraseCredentials() - { - } - - /** - * Set fullName - * - * @param string $fullname - * @return Member - */ - public function setfullname($fullname) - { - $this->fullname = $fullname; - - return $this; - } - - /** - * Set password - * - * @param string $password - * @return Member - */ - public function setPassword($password) - { - $this->password = $password; - - return $this; - } - - - /** - * Get fullName - * - * @return string - */ - public function getFullName() - { - return $this->fullname; - } - /** - * Get fullName - * - * @return string - */ - public function getLink() - { - return '/app_dev.php/' . $this->getUsername(); - } -} +username = $username; + $this->password = $password; + $this->salt = $salt; + $this->roles = $roles; + } + + /** + * @inheritDoc + */ + public function getUsername() + { + return $this->username; + } + + + /** + * @inheritDoc + */ + public function getSalt() + { + return $this->salt; + } + + /** + * @inheritDoc + */ + public function getPassword() + { + return $this->password; + } + + /** + * @inheritDoc + */ + public function getRoles() + { + return array('ROLE_USER'); + } + + /** + * @inheritDoc + */ + public function eraseCredentials() + { + } + + /** + * Set fullName + * + * @param string $fullname + * @return Member + */ + public function setfullname($fullname) + { + $this->fullname = $fullname; + + return $this; + } + + /** + * Set password + * + * @param string $password + * @return Member + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + + /** + * Get fullName + * + * @return string + */ + public function getFullName() + { + return $this->fullname; + } + /** + * Get fullName + * + * @return string + */ + public function getLink() + { + return '/app_dev.php/' . $this->getUsername(); + } +} diff --git a/src/BodyRep/Entity/Profile.php b/symfony/src/BodyRep/Entity/Profile.php similarity index 94% rename from src/BodyRep/Entity/Profile.php rename to symfony/src/BodyRep/Entity/Profile.php index 5cb0370..947d85b 100644 --- a/src/BodyRep/Entity/Profile.php +++ b/symfony/src/BodyRep/Entity/Profile.php @@ -1,127 +1,127 @@ -id; - } - - /** - * Set fullName - * - * @param string $fullname - * @return Profile - */ - public function setfullname($fullname) - { - $this->fullname = $fullname; - - return $this; - } - - /** - * Get fullName - * - * @return string - */ - public function getFullName() - { - return $this->fullname; - } - - /** - * Set userName - * - * @param string $username - * @return Profile - */ - public function setUserName($username) - { - $this->username = $userName; - - return $this; - } - - /** - * Get userName - * - * @return string - */ - public function getUserName() - { - return $this->username; - } - - /** - * Set currentWeight - * - * @param float $currentWeight - * @return Profile - */ - public function setCurrentWeight($currentWeight) - { - $this->currentweight = $currentWeight; - - return $this; - } - - /** - * Get currentWeight - * - * @return float - */ - public function getCurrentWeight() - { - return $this->currentweight; - } - -} +id; + } + + /** + * Set fullName + * + * @param string $fullname + * @return Profile + */ + public function setfullname($fullname) + { + $this->fullname = $fullname; + + return $this; + } + + /** + * Get fullName + * + * @return string + */ + public function getFullName() + { + return $this->fullname; + } + + /** + * Set userName + * + * @param string $username + * @return Profile + */ + public function setUserName($username) + { + $this->username = $userName; + + return $this; + } + + /** + * Get userName + * + * @return string + */ + public function getUserName() + { + return $this->username; + } + + /** + * Set currentWeight + * + * @param float $currentWeight + * @return Profile + */ + public function setCurrentWeight($currentWeight) + { + $this->currentweight = $currentWeight; + + return $this; + } + + /** + * Get currentWeight + * + * @return float + */ + public function getCurrentWeight() + { + return $this->currentweight; + } + +} diff --git a/src/BodyRep/Entity/User.php b/symfony/src/BodyRep/Entity/User.php similarity index 94% rename from src/BodyRep/Entity/User.php rename to symfony/src/BodyRep/Entity/User.php index 66e8cba..3254e99 100644 --- a/src/BodyRep/Entity/User.php +++ b/symfony/src/BodyRep/Entity/User.php @@ -1,110 +1,110 @@ -roles; - } - - public function getSalt() - { - return $this->salt; - } - - public function getUsername() - { - return $this->username; - } - - public function eraseCredentials() - { - } - - public function getPassword() - { - return $this->password; - } - - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * Set username - * - * @param string $username - * @return User - */ - public function setUsername($username) - { - $this->username = $username; - - return $this; - } - - /** - * Set password - * - * @param string $password - * @return User - */ - public function setPassword($password) - { - $this->password = $password; - - return $this; - } - - /** - * Set salt - * - * @param string $salt - * @return User - */ - public function setSalt($salt) - { - $this->salt = $salt; - - return $this; - } +roles; + } + + public function getSalt() + { + return $this->salt; + } + + public function getUsername() + { + return $this->username; + } + + public function eraseCredentials() + { + } + + public function getPassword() + { + return $this->password; + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set username + * + * @param string $username + * @return User + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Set password + * + * @param string $password + * @return User + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + /** + * Set salt + * + * @param string $salt + * @return User + */ + public function setSalt($salt) + { + $this->salt = $salt; + + return $this; + } } \ No newline at end of file diff --git a/src/BodyRep/Entity/UserRepository.php b/symfony/src/BodyRep/Entity/UserRepository.php similarity index 94% rename from src/BodyRep/Entity/UserRepository.php rename to symfony/src/BodyRep/Entity/UserRepository.php index 5e55cfd..d469a7b 100644 --- a/src/BodyRep/Entity/UserRepository.php +++ b/symfony/src/BodyRep/Entity/UserRepository.php @@ -1,15 +1,15 @@ -mailer = $mailer; - } - - public function onCommentEvent(CommentEvent $event) - { - $post = $event->getPost(); - $comment = $event->getComment(); - - foreach ($post->getSubscribers() as $subscriber) { - $message = Swift_Message::newInstance() - ->setSubject('New comment posted on ' . $post->getTitle()) - ->setFrom('send@example.com') - ->setTo($subscriber->getEmail()) - ->setBody("Hey, somebody left a new comment on a post you're subscribed to! It says: " . $comment->getBody()) - ; - $this->mailer->send($message); - } - } -} - +mailer = $mailer; + } + + public function onCommentEvent(CommentEvent $event) + { + $post = $event->getPost(); + $comment = $event->getComment(); + + foreach ($post->getSubscribers() as $subscriber) { + $message = Swift_Message::newInstance() + ->setSubject('New comment posted on ' . $post->getTitle()) + ->setFrom('send@example.com') + ->setTo($subscriber->getEmail()) + ->setBody("Hey, somebody left a new comment on a post you're subscribed to! It says: " . $comment->getBody()) + ; + $this->mailer->send($message); + } + } +} + ?> \ No newline at end of file diff --git a/src/BodyRep/EventListener/ControllerListener.php b/symfony/src/BodyRep/EventListener/ControllerListener.php similarity index 97% rename from src/BodyRep/EventListener/ControllerListener.php rename to symfony/src/BodyRep/EventListener/ControllerListener.php index a4f81fb..d12c8ca 100644 --- a/src/BodyRep/EventListener/ControllerListener.php +++ b/symfony/src/BodyRep/EventListener/ControllerListener.php @@ -1,46 +1,46 @@ -extension = $extension; - } - - public function onKernelController(FilterControllerEvent $event) - { - - if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { - $this->extension->setController($event->getController()); - } - } - public function preExecute(\Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event){ - //result returned by the controller - $data = $event->getControllerResult(); - - //Get the current route - $route = $event->getRequest()->get('_route'); - - /* @var $request \Symfony\Component\HttpFoundation\Request */ - $request = $event->getRequest(); - $template = $request->get('_template'); - $route = $request->get('_route'); - - if(substr($route,0,7) == 'mobile_'){ - $newTemplate = str_replace('html.twig','mobile.html.twig',$template); - - //Overwrite original template with the mobile one - $response = $this->templating->renderResponse($newTemplate, $data); - $event->setResponse($response); - } - } -} +extension = $extension; + } + + public function onKernelController(FilterControllerEvent $event) + { + + if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { + $this->extension->setController($event->getController()); + } + } + public function preExecute(\Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event){ + //result returned by the controller + $data = $event->getControllerResult(); + + //Get the current route + $route = $event->getRequest()->get('_route'); + + /* @var $request \Symfony\Component\HttpFoundation\Request */ + $request = $event->getRequest(); + $template = $request->get('_template'); + $route = $request->get('_route'); + + if(substr($route,0,7) == 'mobile_'){ + $newTemplate = str_replace('html.twig','mobile.html.twig',$template); + + //Overwrite original template with the mobile one + $response = $this->templating->renderResponse($newTemplate, $data); + $event->setResponse($response); + } + } +} diff --git a/src/BodyRep/EventListener/KernelListener.php b/symfony/src/BodyRep/EventListener/KernelListener.php similarity index 97% rename from src/BodyRep/EventListener/KernelListener.php rename to symfony/src/BodyRep/EventListener/KernelListener.php index f8f4989..9dc8c3c 100644 --- a/src/BodyRep/EventListener/KernelListener.php +++ b/symfony/src/BodyRep/EventListener/KernelListener.php @@ -1,20 +1,20 @@ -public function preExecute(\Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event){ - //result returned by the controller - $data = $event->getControllerResult(); - - //Get the current route - $route = $event->getRequest()->get('_route'); - - /* @var $request \Symfony\Component\HttpFoundation\Request */ - $request = $event->getRequest(); - $template = $request->get('_template'); - $route = $request->get('_route'); - - if(substr($route,0,7) == 'mobile_'){ - $newTemplate = str_replace('html.twig','mobile.html.twig',$template); - - //Overwrite original template with the mobile one - $response = $this->templating->renderResponse($newTemplate, $data); - $event->setResponse($response); - } +public function preExecute(\Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event){ + //result returned by the controller + $data = $event->getControllerResult(); + + //Get the current route + $route = $event->getRequest()->get('_route'); + + /* @var $request \Symfony\Component\HttpFoundation\Request */ + $request = $event->getRequest(); + $template = $request->get('_template'); + $route = $request->get('_route'); + + if(substr($route,0,7) == 'mobile_'){ + $newTemplate = str_replace('html.twig','mobile.html.twig',$template); + + //Overwrite original template with the mobile one + $response = $this->templating->renderResponse($newTemplate, $data); + $event->setResponse($response); + } } \ No newline at end of file diff --git a/src/BodyRep/EventListener/LoginListener.php b/symfony/src/BodyRep/EventListener/LoginListener.php similarity index 95% rename from src/BodyRep/EventListener/LoginListener.php rename to symfony/src/BodyRep/EventListener/LoginListener.php index 840f60a..a7d2c42 100644 --- a/src/BodyRep/EventListener/LoginListener.php +++ b/symfony/src/BodyRep/EventListener/LoginListener.php @@ -1,46 +1,46 @@ -context = $context; - $this->em = $doctrine->getEntityManager(); - } - - /** - * Do the magic. - * - * @param Event $event - */ - public function onSecurityInteractiveLogin(Event $event) - { - $user = $this->context->getToken()->getUser(); - - // do all your magic here - } -} - +context = $context; + $this->em = $doctrine->getEntityManager(); + } + + /** + * Do the magic. + * + * @param Event $event + */ + public function onSecurityInteractiveLogin(Event $event) + { + $user = $this->context->getToken()->getUser(); + + // do all your magic here + } +} + ?> \ No newline at end of file diff --git a/src/BodyRep/Form/Profile.php b/symfony/src/BodyRep/Form/Profile.php similarity index 94% rename from src/BodyRep/Form/Profile.php rename to symfony/src/BodyRep/Form/Profile.php index 44354ea..b8e9701 100644 --- a/src/BodyRep/Form/Profile.php +++ b/symfony/src/BodyRep/Form/Profile.php @@ -1,25 +1,25 @@ -add('fullname', 'text'); - - - //$builder->add('newpass1', 'text'); - //$builder->add('newpass2', 'text'); - - } - - public function getName() - { - return 'profile'; - } -} +add('fullname', 'text'); + + + //$builder->add('newpass1', 'text'); + //$builder->add('newpass2', 'text'); + + } + + public function getName() + { + return 'profile'; + } +} diff --git a/src/BodyRep/Resources/config/services.xml b/symfony/src/BodyRep/Resources/config/services.xml similarity index 97% rename from src/BodyRep/Resources/config/services.xml rename to symfony/src/BodyRep/Resources/config/services.xml index b8d5e58..5bc23aa 100644 --- a/src/BodyRep/Resources/config/services.xml +++ b/symfony/src/BodyRep/Resources/config/services.xml @@ -1,17 +1,17 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/BodyRep/Resources/views/Auth/login.html.twig b/symfony/src/BodyRep/Resources/views/Auth/login.html.twig similarity index 96% rename from src/BodyRep/Resources/views/Auth/login.html.twig rename to symfony/src/BodyRep/Resources/views/Auth/login.html.twig index 907d51c..1bdb8a5 100644 --- a/src/BodyRep/Resources/views/Auth/login.html.twig +++ b/symfony/src/BodyRep/Resources/views/Auth/login.html.twig @@ -1,34 +1,34 @@ -{% extends 'BodyRep::layout.html.twig' %} -{% block js %} - $(document).ready(function() - { - if($('#username').val().length > 0) - $('#password').focus(); - else - $('#username').focus(); - }); -{% endblock %} - -{% block content %} - - -

Login

- - {% if error %} -
{{ error.message }}
- {% endif %} - -
-
- - -
- -
- - -
- - -
-{% endblock %} +{% extends 'BodyRep::layout.html.twig' %} +{% block js %} + $(document).ready(function() + { + if($('#username').val().length > 0) + $('#password').focus(); + else + $('#username').focus(); + }); +{% endblock %} + +{% block content %} + + +

Login

+ + {% if error %} +
{{ error.message }}
+ {% endif %} + +
+
+ + +
+ +
+ + +
+ + +
+{% endblock %} diff --git a/src/BodyRep/Resources/views/Member/navbar.html.twig b/symfony/src/BodyRep/Resources/views/Auth/navbar.html.twig similarity index 98% rename from src/BodyRep/Resources/views/Member/navbar.html.twig rename to symfony/src/BodyRep/Resources/views/Auth/navbar.html.twig index 8324718..7d2b548 100644 --- a/src/BodyRep/Resources/views/Member/navbar.html.twig +++ b/symfony/src/BodyRep/Resources/views/Auth/navbar.html.twig @@ -1,35 +1,35 @@ - + diff --git a/src/BodyRep/Resources/views/Landing/about.html.twig b/symfony/src/BodyRep/Resources/views/Landing/about.html.twig similarity index 95% rename from src/BodyRep/Resources/views/Landing/about.html.twig rename to symfony/src/BodyRep/Resources/views/Landing/about.html.twig index 1346bdf..3089b85 100644 --- a/src/BodyRep/Resources/views/Landing/about.html.twig +++ b/symfony/src/BodyRep/Resources/views/Landing/about.html.twig @@ -1,9 +1,9 @@ -{% extends "BodyRep::layout.html.twig" %} - -{% block title "BodyRep - About Us" %} - -{% block content %} -{% include 'BodyRep:Landing:navbar.html.twig' %} - -About +{% extends "BodyRep::layout.html.twig" %} + +{% block title "BodyRep - About Us" %} + +{% block content %} +{% include 'BodyRep:Landing:navbar.html.twig' %} + +About {% endblock %} \ No newline at end of file diff --git a/src/BodyRep/Resources/views/Landing/index.html.twig b/symfony/src/BodyRep/Resources/views/Landing/index.html.twig similarity index 94% rename from src/BodyRep/Resources/views/Landing/index.html.twig rename to symfony/src/BodyRep/Resources/views/Landing/index.html.twig index 9008c6a..ebb5021 100644 --- a/src/BodyRep/Resources/views/Landing/index.html.twig +++ b/symfony/src/BodyRep/Resources/views/Landing/index.html.twig @@ -1,12 +1,12 @@ -{% extends 'BodyRep::layout.html.twig' %} - -{% block title %}BodyRep - Welcome{% endblock %} - -{% block content_header '' %} - - -{% block content %} -{% include 'BodyRep:Landing:navbar.html.twig' %} - -Landing Page -{% endblock %} +{% extends 'BodyRep::layout.html.twig' %} + +{% block title %}BodyRep - Welcome{% endblock %} + +{% block content_header '' %} + + +{% block content %} +{% include 'BodyRep:Landing:navbar.html.twig' %} + +Landing Page +{% endblock %} diff --git a/src/BodyRep/Resources/views/Landing/navbar.html.twig b/symfony/src/BodyRep/Resources/views/Landing/navbar.html.twig similarity index 97% rename from src/BodyRep/Resources/views/Landing/navbar.html.twig rename to symfony/src/BodyRep/Resources/views/Landing/navbar.html.twig index 23ddc09..d0a9a88 100644 --- a/src/BodyRep/Resources/views/Landing/navbar.html.twig +++ b/symfony/src/BodyRep/Resources/views/Landing/navbar.html.twig @@ -1,18 +1,18 @@ -