Sfoglia il codice sorgente

Migrating to Ruby on Rails. Main page and single project view are almost done.

Iñigo Valentin 4 anni fa
parent
commit
fbe098a786
100 ha cambiato i file con 871 aggiunte e 2233 eliminazioni
  1. 10 0
      .gitattributes
  2. 33 33
      .gitignore
  3. 1 0
      .ruby-version
  4. 56 0
      Gemfile
  5. 231 0
      Gemfile.lock
  6. 6 0
      Rakefile
  7. 2 0
      app/assets/config/manifest.js
  8. 0 0
      app/assets/images/.keep
  9. 0 0
      app/assets/images/control/close.svg
  10. 0 0
      app/assets/images/control/slid_d.svg
  11. 0 0
      app/assets/images/control/slid_l.svg
  12. 0 0
      app/assets/images/control/slid_r.svg
  13. 0 0
      app/assets/images/control/slid_u.svg
  14. 0 0
      app/assets/images/home.svg
  15. 80 0
      app/assets/images/icon/home.svg
  16. 0 0
      app/assets/images/icon/profile.svg
  17. 0 0
      app/assets/images/icon/project.svg
  18. 0 0
      app/assets/images/lang/en.svg
  19. 0 0
      app/assets/images/lang/es.svg
  20. 0 0
      app/assets/images/lang/eu.svg
  21. 0 0
      app/assets/images/license/CC-0.svg
  22. 0 0
      app/assets/images/license/CC-BY-NC-ND.svg
  23. 0 0
      app/assets/images/license/CC-BY-NC-SA.svg
  24. 0 0
      app/assets/images/license/CC-BY-NC.svg
  25. 0 0
      app/assets/images/license/CC-BY-ND.svg
  26. 0 0
      app/assets/images/license/CC-BY.svg
  27. 0 0
      app/assets/images/license/GPLV3.svg
  28. 0 0
      app/assets/images/logo/logo.svg
  29. 0 0
      app/assets/images/social/app_store.svg
  30. 0 0
      app/assets/images/social/email.svg
  31. 0 0
      app/assets/images/social/facebook.svg
  32. 0 0
      app/assets/images/social/github.svg
  33. 0 0
      app/assets/images/social/google_play.svg
  34. 0 0
      app/assets/images/social/google_plus.svg
  35. 0 0
      app/assets/images/social/linkedin.svg
  36. 0 0
      app/assets/images/social/telegram.svg
  37. 0 0
      app/assets/images/social/twitter.svg
  38. 0 0
      app/assets/images/social/www.svg
  39. 14 0
      app/assets/stylesheets/application.css
  40. 0 0
      app/assets/stylesheets/main.css
  41. 3 0
      app/assets/stylesheets/profile.scss
  42. 0 1
      app/assets/stylesheets/project.css
  43. 3 0
      app/assets/stylesheets/projects.scss
  44. 56 3
      app/assets/stylesheets/ui.css
  45. 4 0
      app/channels/application_cable/channel.rb
  46. 4 0
      app/channels/application_cable/connection.rb
  47. 16 0
      app/controllers/application_controller.rb
  48. 0 0
      app/controllers/concerns/.keep
  49. 6 0
      app/controllers/main_controller.rb
  50. 5 0
      app/controllers/profile_controller.rb
  51. 8 0
      app/controllers/projects_controller.rb
  52. 2 0
      app/helpers/application_helper.rb
  53. 2 0
      app/helpers/profile_helper.rb
  54. 2 0
      app/helpers/projects_helper.rb
  55. 6 0
      app/javascript/channels/consumer.js
  56. 5 0
      app/javascript/channels/index.js
  57. 13 0
      app/javascript/packs/application.js
  58. 7 0
      app/jobs/application_job.rb
  59. 4 0
      app/mailers/application_mailer.rb
  60. 3 0
      app/models/application_record.rb
  61. 0 0
      app/models/concerns/.keep
  62. 4 0
      app/models/license.rb
  63. 3 0
      app/models/mail_adress.rb
  64. 15 0
      app/models/project.rb
  65. 4 0
      app/models/project_url.rb
  66. 6 0
      app/models/tag.rb
  67. 5 0
      app/models/technology.rb
  68. 3 0
      app/models/text.rb
  69. 9 0
      app/models/url_target.rb
  70. 11 0
      app/models/user.rb
  71. 39 0
      app/views/layouts/_footer.html.erb
  72. 19 0
      app/views/layouts/_header.html.erb
  73. 22 0
      app/views/layouts/application.html.erb
  74. 13 0
      app/views/layouts/mailer.html.erb
  75. 1 0
      app/views/layouts/mailer.text.erb
  76. 58 0
      app/views/main/index.html.erb
  77. 13 0
      app/views/profile/index.html.erb
  78. 10 0
      app/views/projects/index.html.erb
  79. 54 0
      app/views/projects/show.html.erb
  80. 0 26
      application/Application.php
  81. 0 68
      application/Context.php
  82. 0 362
      application/Controller.php
  83. 0 14
      application/config/config.ini
  84. 0 44
      application/config/config.php
  85. 0 58
      application/entity/Cv.php
  86. 0 24
      application/entity/Entity.php
  87. 0 56
      application/entity/Lang.php
  88. 0 120
      application/entity/License.php
  89. 0 412
      application/entity/Project.php
  90. 0 102
      application/entity/Project_Image.php
  91. 0 37
      application/entity/Project_Tag.php
  92. 0 86
      application/entity/Project_Type.php
  93. 0 102
      application/entity/Project_Url.php
  94. 0 63
      application/entity/Project_Url_Type.php
  95. 0 126
      application/helper/DB_Helper.php
  96. 0 97
      application/helper/HTML_Helper.php
  97. 0 20
      application/helper/Helper.php
  98. 0 59
      application/helper/NET_Helper.php
  99. 0 276
      application/helper/TEXT_Helper.php
  100. 0 44
      application/helper/db.php

+ 10 - 0
.gitattributes

@@ -0,0 +1,10 @@
+# See https://git-scm.com/docs/gitattributes for more about git attribute files.
+
+# Mark the database schema as having been generated.
+db/schema.rb linguist-generated
+
+# Mark the yarn lockfile as having been generated.
+yarn.lock linguist-generated
+
+# Mark any vendored files as having been vendored.
+vendor/* linguist-vendored

+ 33 - 33
.gitignore

@@ -1,38 +1,38 @@
-#OS files
-.directory
-.DS_Store
-.DS_Store?
-._*
-.Trashes
-ehthumbs.db
-Thumbs.db
-*.swp
+# See https://help.github.com/articles/ignoring-files for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+#   git config --global core.excludesfile '~/.gitignore_global'
 
-#IDE files
-.kateproject.d/
-.kateproject
-.project
-.settings
-.externalToolBuilders
+# Ignore bundler config.
+/.bundle
+
+# Ignore all logfiles and tempfiles.
+/log/*
+/tmp/*
+!/log/.keep
+!/tmp/.keep
 
-#Local server and deploy tools
-deploy
-server_*
-.php_pid
+# Ignore pidfiles, but keep the directory.
+/tmp/pids/*
+!/tmp/pids/
+!/tmp/pids/.keep
 
-#SQL custom data
-sql/DES/
-sql/PRE/
-sql/DBG/
+# Ignore uploaded files in development.
+/storage/*
+!/storage/.keep
+/custom_data
+/public/assets
+.byebug_history
 
-#Passwords file
-.htpasswd*
-application/config/auth.php_*
+# Ignore master key for decrypting credentials and more.
+/config/master.key
 
-#Content images
-public/img/content/*.png
-public/img/content/*.svg
-public/img/content/*/*.png
-public/img/content/*/*.svg
-public/img/content/*/*/*.png
-public/img/content/*/*/*.svg
+/public/packs
+/public/packs-test
+/node_modules
+/yarn-error.log
+yarn-debug.log*
+.yarn-integrity
+.project
+.custom-data

+ 1 - 0
.ruby-version

@@ -0,0 +1 @@
+ruby-2.7.4

+ 56 - 0
Gemfile

@@ -0,0 +1,56 @@
+source 'https://rubygems.org'
+git_source(:github) { |repo| "https://github.com/#{repo}.git" }
+
+ruby '2.7.4'
+
+# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
+gem 'rails', '~> 6.1.4', '>= 6.1.4.1'
+# Use mysql as the database for Active Record
+gem 'mysql2', '~> 0.5'
+# Use Puma as the app server
+gem 'puma', '~> 5.0'
+# Use SCSS for stylesheets
+gem 'sass-rails', '>= 6'
+# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
+gem 'webpacker', '~> 5.0'
+# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
+gem 'turbolinks', '~> 5'
+# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
+gem 'jbuilder', '~> 2.7'
+# Use Redis adapter to run Action Cable in production
+# gem 'redis', '~> 4.0'
+# Use Active Model has_secure_password
+# gem 'bcrypt', '~> 3.1.7'
+
+# Use Active Storage variant
+# gem 'image_processing', '~> 1.2'
+
+# Reduces boot times through caching; required in config/boot.rb
+gem 'bootsnap', '>= 1.4.4', require: false
+
+group :development, :test do
+  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
+end
+
+group :development do
+  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
+  gem 'web-console', '>= 4.1.0'
+  # Display performance information such as SQL time and flame graphs for each request in your browser.
+  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
+  gem 'rack-mini-profiler', '~> 2.0'
+  gem 'listen', '~> 3.3'
+  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
+  gem 'spring'
+end
+
+group :test do
+  # Adds support for Capybara system testing and selenium driver
+  gem 'capybara', '>= 3.26'
+  gem 'selenium-webdriver'
+  # Easy installation and use of web drivers to run system tests with browsers
+  gem 'webdrivers'
+end
+
+# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
+gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

+ 231 - 0
Gemfile.lock

@@ -0,0 +1,231 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    actioncable (6.1.4.1)
+      actionpack (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      nio4r (~> 2.0)
+      websocket-driver (>= 0.6.1)
+    actionmailbox (6.1.4.1)
+      actionpack (= 6.1.4.1)
+      activejob (= 6.1.4.1)
+      activerecord (= 6.1.4.1)
+      activestorage (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      mail (>= 2.7.1)
+    actionmailer (6.1.4.1)
+      actionpack (= 6.1.4.1)
+      actionview (= 6.1.4.1)
+      activejob (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      mail (~> 2.5, >= 2.5.4)
+      rails-dom-testing (~> 2.0)
+    actionpack (6.1.4.1)
+      actionview (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      rack (~> 2.0, >= 2.0.9)
+      rack-test (>= 0.6.3)
+      rails-dom-testing (~> 2.0)
+      rails-html-sanitizer (~> 1.0, >= 1.2.0)
+    actiontext (6.1.4.1)
+      actionpack (= 6.1.4.1)
+      activerecord (= 6.1.4.1)
+      activestorage (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      nokogiri (>= 1.8.5)
+    actionview (6.1.4.1)
+      activesupport (= 6.1.4.1)
+      builder (~> 3.1)
+      erubi (~> 1.4)
+      rails-dom-testing (~> 2.0)
+      rails-html-sanitizer (~> 1.1, >= 1.2.0)
+    activejob (6.1.4.1)
+      activesupport (= 6.1.4.1)
+      globalid (>= 0.3.6)
+    activemodel (6.1.4.1)
+      activesupport (= 6.1.4.1)
+    activerecord (6.1.4.1)
+      activemodel (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+    activestorage (6.1.4.1)
+      actionpack (= 6.1.4.1)
+      activejob (= 6.1.4.1)
+      activerecord (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      marcel (~> 1.0.0)
+      mini_mime (>= 1.1.0)
+    activesupport (6.1.4.1)
+      concurrent-ruby (~> 1.0, >= 1.0.2)
+      i18n (>= 1.6, < 2)
+      minitest (>= 5.1)
+      tzinfo (~> 2.0)
+      zeitwerk (~> 2.3)
+    addressable (2.8.0)
+      public_suffix (>= 2.0.2, < 5.0)
+    bindex (0.8.1)
+    bootsnap (1.9.3)
+      msgpack (~> 1.0)
+    builder (3.2.4)
+    byebug (11.1.3)
+    capybara (3.36.0)
+      addressable
+      matrix
+      mini_mime (>= 0.1.3)
+      nokogiri (~> 1.8)
+      rack (>= 1.6.0)
+      rack-test (>= 0.6.3)
+      regexp_parser (>= 1.5, < 3.0)
+      xpath (~> 3.2)
+    childprocess (4.1.0)
+    concurrent-ruby (1.1.9)
+    crass (1.0.6)
+    erubi (1.10.0)
+    ffi (1.15.4)
+    globalid (1.0.0)
+      activesupport (>= 5.0)
+    i18n (1.8.11)
+      concurrent-ruby (~> 1.0)
+    jbuilder (2.11.3)
+      activesupport (>= 5.0.0)
+    listen (3.7.0)
+      rb-fsevent (~> 0.10, >= 0.10.3)
+      rb-inotify (~> 0.9, >= 0.9.10)
+    loofah (2.12.0)
+      crass (~> 1.0.2)
+      nokogiri (>= 1.5.9)
+    mail (2.7.1)
+      mini_mime (>= 0.1.1)
+    marcel (1.0.2)
+    matrix (0.4.2)
+    method_source (1.0.0)
+    mini_mime (1.1.2)
+    mini_portile2 (2.6.1)
+    minitest (5.14.4)
+    msgpack (1.4.2)
+    mysql2 (0.5.3)
+    nio4r (2.5.8)
+    nokogiri (1.12.5)
+      mini_portile2 (~> 2.6.1)
+      racc (~> 1.4)
+    public_suffix (4.0.6)
+    puma (5.5.2)
+      nio4r (~> 2.0)
+    racc (1.6.0)
+    rack (2.2.3)
+    rack-mini-profiler (2.3.3)
+      rack (>= 1.2.0)
+    rack-proxy (0.7.0)
+      rack
+    rack-test (1.1.0)
+      rack (>= 1.0, < 3)
+    rails (6.1.4.1)
+      actioncable (= 6.1.4.1)
+      actionmailbox (= 6.1.4.1)
+      actionmailer (= 6.1.4.1)
+      actionpack (= 6.1.4.1)
+      actiontext (= 6.1.4.1)
+      actionview (= 6.1.4.1)
+      activejob (= 6.1.4.1)
+      activemodel (= 6.1.4.1)
+      activerecord (= 6.1.4.1)
+      activestorage (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      bundler (>= 1.15.0)
+      railties (= 6.1.4.1)
+      sprockets-rails (>= 2.0.0)
+    rails-dom-testing (2.0.3)
+      activesupport (>= 4.2.0)
+      nokogiri (>= 1.6)
+    rails-html-sanitizer (1.4.2)
+      loofah (~> 2.3)
+    railties (6.1.4.1)
+      actionpack (= 6.1.4.1)
+      activesupport (= 6.1.4.1)
+      method_source
+      rake (>= 0.13)
+      thor (~> 1.0)
+    rake (13.0.6)
+    rb-fsevent (0.11.0)
+    rb-inotify (0.10.1)
+      ffi (~> 1.0)
+    regexp_parser (2.2.0)
+    rexml (3.2.5)
+    rubyzip (2.3.2)
+    sass-rails (6.0.0)
+      sassc-rails (~> 2.1, >= 2.1.1)
+    sassc (2.4.0)
+      ffi (~> 1.9)
+    sassc-rails (2.1.2)
+      railties (>= 4.0.0)
+      sassc (>= 2.0)
+      sprockets (> 3.0)
+      sprockets-rails
+      tilt
+    selenium-webdriver (4.1.0)
+      childprocess (>= 0.5, < 5.0)
+      rexml (~> 3.2, >= 3.2.5)
+      rubyzip (>= 1.2.2)
+    semantic_range (3.0.0)
+    spring (3.1.1)
+    sprockets (4.0.2)
+      concurrent-ruby (~> 1.0)
+      rack (> 1, < 3)
+    sprockets-rails (3.4.1)
+      actionpack (>= 5.2)
+      activesupport (>= 5.2)
+      sprockets (>= 3.0.0)
+    thor (1.1.0)
+    tilt (2.0.10)
+    turbolinks (5.2.1)
+      turbolinks-source (~> 5.2)
+    turbolinks-source (5.2.0)
+    tzinfo (2.0.4)
+      concurrent-ruby (~> 1.0)
+    web-console (4.2.0)
+      actionview (>= 6.0.0)
+      activemodel (>= 6.0.0)
+      bindex (>= 0.4.0)
+      railties (>= 6.0.0)
+    webdrivers (5.0.0)
+      nokogiri (~> 1.6)
+      rubyzip (>= 1.3.0)
+      selenium-webdriver (~> 4.0)
+    webpacker (5.4.3)
+      activesupport (>= 5.2)
+      rack-proxy (>= 0.6.1)
+      railties (>= 5.2)
+      semantic_range (>= 2.3.0)
+    websocket-driver (0.7.5)
+      websocket-extensions (>= 0.1.0)
+    websocket-extensions (0.1.5)
+    xpath (3.2.0)
+      nokogiri (~> 1.8)
+    zeitwerk (2.5.1)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  bootsnap (>= 1.4.4)
+  byebug
+  capybara (>= 3.26)
+  jbuilder (~> 2.7)
+  listen (~> 3.3)
+  mysql2 (~> 0.5)
+  puma (~> 5.0)
+  rack-mini-profiler (~> 2.0)
+  rails (~> 6.1.4, >= 6.1.4.1)
+  sass-rails (>= 6)
+  selenium-webdriver
+  spring
+  turbolinks (~> 5)
+  tzinfo-data
+  web-console (>= 4.1.0)
+  webdrivers
+  webpacker (~> 5.0)
+
+RUBY VERSION
+   ruby 2.7.4p191
+
+BUNDLED WITH
+   2.1.4

+ 6 - 0
Rakefile

@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative "config/application"
+
+Rails.application.load_tasks

+ 2 - 0
app/assets/config/manifest.js

@@ -0,0 +1,2 @@
+//= link_tree ../images
+//= link_directory ../stylesheets .css

+ 0 - 0
application/resources/text/HELP_INFO_TEXT__EN → app/assets/images/.keep


+ 0 - 0
public/img/layout/control/close.svg → app/assets/images/control/close.svg


+ 0 - 0
public/img/layout/control/slid_d.svg → app/assets/images/control/slid_d.svg


+ 0 - 0
public/img/layout/control/slid_l.svg → app/assets/images/control/slid_l.svg


+ 0 - 0
public/img/layout/control/slid_r.svg → app/assets/images/control/slid_r.svg


+ 0 - 0
public/img/layout/control/slid_u.svg → app/assets/images/control/slid_u.svg


+ 0 - 0
public/img/layout/icon/home.svg → app/assets/images/home.svg


+ 80 - 0
app/assets/images/icon/home.svg

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="500mm"
+   height="500mm"
+   viewBox="0 0 500 500"
+   version="1.1"
+   id="svg131"
+   inkscape:version="0.92.3 (2405546, 2018-03-11)"
+   sodipodi:docname="home.svg">
+  <defs
+     id="defs125" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.175"
+     inkscape:cx="865.65656"
+     inkscape:cy="1130.6199"
+     inkscape:document-units="mm"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1680"
+     inkscape:window-height="964"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata128">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Capa 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,203)">
+    <rect
+       style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.85208333;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect6097"
+       width="529.16669"
+       height="527.65479"
+       x="-12.095284"
+       y="-215.53572" />
+    <rect
+       style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:13.22916667;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect133-2"
+       width="448.15552"
+       height="448.15549"
+       x="25.922247"
+       y="-177.07774"
+       ry="24.897526" />
+    <rect
+       style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:11.70093155;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect133-2-8"
+       width="308.29907"
+       height="308.29907"
+       x="95.850464"
+       y="-107.14954"
+       ry="17.127728" />
+  </g>
+</svg>

+ 0 - 0
public/img/layout/icon/profile.svg → app/assets/images/icon/profile.svg


+ 0 - 0
public/img/layout/icon/project.svg → app/assets/images/icon/project.svg


+ 0 - 0
public/img/layout/lang/en.svg → app/assets/images/lang/en.svg


+ 0 - 0
public/img/layout/lang/es.svg → app/assets/images/lang/es.svg


+ 0 - 0
public/img/layout/lang/eu.svg → app/assets/images/lang/eu.svg


+ 0 - 0
public/img/layout/license/CC-0.svg → app/assets/images/license/CC-0.svg


+ 0 - 0
public/img/layout/license/CC-BY-NC-ND.svg → app/assets/images/license/CC-BY-NC-ND.svg


+ 0 - 0
public/img/layout/license/CC-BY-NC-SA.svg → app/assets/images/license/CC-BY-NC-SA.svg


+ 0 - 0
public/img/layout/license/CC-BY-NC.svg → app/assets/images/license/CC-BY-NC.svg


+ 0 - 0
public/img/layout/license/CC-BY-ND.svg → app/assets/images/license/CC-BY-ND.svg


+ 0 - 0
public/img/layout/license/CC-BY.svg → app/assets/images/license/CC-BY.svg


+ 0 - 0
public/img/layout/license/GPLV3.svg → app/assets/images/license/GPLV3.svg


+ 0 - 0
public/img/layout/logo/logo.svg → app/assets/images/logo/logo.svg


+ 0 - 0
public/img/layout/social/app_store.svg → app/assets/images/social/app_store.svg


+ 0 - 0
public/img/layout/social/email.svg → app/assets/images/social/email.svg


+ 0 - 0
public/img/layout/social/facebook.svg → app/assets/images/social/facebook.svg


+ 0 - 0
public/img/layout/social/github.svg → app/assets/images/social/github.svg


+ 0 - 0
public/img/layout/social/google_play.svg → app/assets/images/social/google_play.svg


+ 0 - 0
public/img/layout/social/google_plus.svg → app/assets/images/social/google_plus.svg


+ 0 - 0
public/img/layout/social/linkedin.svg → app/assets/images/social/linkedin.svg


+ 0 - 0
public/img/layout/social/telegram.svg → app/assets/images/social/telegram.svg


+ 0 - 0
public/img/layout/social/twitter.svg → app/assets/images/social/twitter.svg


+ 0 - 0
public/img/layout/social/www.svg → app/assets/images/social/www.svg


+ 14 - 0
app/assets/stylesheets/application.css

@@ -0,0 +1,14 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *
+ *= require_self
+ */

+ 0 - 0
public/css/home.css → app/assets/stylesheets/main.css


+ 3 - 0
app/assets/stylesheets/profile.scss

@@ -0,0 +1,3 @@
+// Place all the styles related to the Profile controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: https://sass-lang.com/

+ 0 - 1
public/css/project.css → app/assets/stylesheets/project.css

@@ -86,7 +86,6 @@ div#info_details div#tags{
 div#info_details div#links a.link{
     display: block;
     margin-bottom: 1em;
-    font-size: 70%;
 }
 
 div#info_details div#links a.link img.link{

+ 3 - 0
app/assets/stylesheets/projects.scss

@@ -0,0 +1,3 @@
+// Place all the styles related to the Projects controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: https://sass-lang.com/

+ 56 - 3
public/css/ui.css → app/assets/stylesheets/ui.css

@@ -83,7 +83,6 @@ a{
 img.slider{
     width: 1em;
     height: 1em;
-    vertial-align: middle;
     transition: all .3s ease-in-out;
 }
 
@@ -601,7 +600,6 @@ img.comment_image{
     max-height: 6em;
     max-width: 60%;
     display: block;
-    vertical-align: top;
     border: 0.133em solid black;
     margin-left: 0.938em;
     margin-bottom: 0.938em;
@@ -610,7 +608,6 @@ img.comment_image{
 
 /* Paragraph with the comment text */
 p.comment_text{
-    vertical-align: top;
     width: auto;
     display: block;
     margin-top: 0.938em;
@@ -684,3 +681,59 @@ a.share img.share:hover{
     box-shadow: 0 0 0.7em #005500;
     border-radius: 0.7em;
 }
+
+span.technology{
+    display: inline-block;
+}
+
+span.technology img.technology_logo{
+    display: inline-block;
+    position:relative;
+    vertical-align: middle;
+    border-radius: 50%;
+    border-width: 0.2em;
+    z-index: 2;
+    background-color: #ffffff;
+    border-style: solid;
+    border-color: #000000;
+    height: 1.5em;
+    width: 1.5em;
+}
+span.technology span.technology_name{
+    display: inline-block;
+    position:relative;
+    vertical-align: middle;
+    border-radius: 15%;
+    border-width: 0.2em;
+    border-style: solid;
+    padding: 0.1em 0.2em 0.1em 1.1em;
+    z-index: 1;
+    background-color: #ffffff;
+    border-color: #000000;
+    margin-left: -1.3em;
+    font-size: 70%;
+    font-weight: bold;
+}
+
+span.technology_1 span.technology_name{
+    background-color: #f4a4a4;
+}
+span.technology_2 span.technology_name{
+    background-color: #ffc898;
+}
+span.technology_3 span.technology_name{
+    background-color: #a4c3f4;
+}
+span.technology_4 span.technology_name{
+    background-color: #f4a4e4;
+}
+span.technology_5 span.technology_name{
+    background-color: #a4f4a9;
+}
+span.technology_6 span.technology_name{
+    background-color: #f4e8a4;
+}
+
+
+
+

+ 4 - 0
app/channels/application_cable/channel.rb

@@ -0,0 +1,4 @@
+module ApplicationCable
+  class Channel < ActionCable::Channel::Base
+  end
+end

+ 4 - 0
app/channels/application_cable/connection.rb

@@ -0,0 +1,4 @@
+module ApplicationCable
+  class Connection < ActionCable::Connection::Base
+  end
+end

+ 16 - 0
app/controllers/application_controller.rb

@@ -0,0 +1,16 @@
+class ApplicationController < ActionController::Base
+
+    before_action :set_locale
+
+    private
+    def set_locale
+        I18n.locale = extract_locale || I18n.default_locale
+        logger.debug "LOCALE SET TO " + I18n.locale.to_s
+    end
+
+    def extract_locale
+        logger.debug "Extracting locale: "
+        parsed_locale = params[:locale]
+        I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
+    end
+end

+ 0 - 0
application/resources/text/HELP_INFO_TEXT__ES → app/controllers/concerns/.keep


+ 6 - 0
app/controllers/main_controller.rb

@@ -0,0 +1,6 @@
+class MainController < ApplicationController
+    def index
+        @user = User.find(1)
+        @projects = Project.where(user_id: @user.id).order(priority: :desc).limit(3)
+    end
+end

+ 5 - 0
app/controllers/profile_controller.rb

@@ -0,0 +1,5 @@
+class ProfileController < ApplicationController
+    def index
+        @user = User.find(1)
+    end
+end

+ 8 - 0
app/controllers/projects_controller.rb

@@ -0,0 +1,8 @@
+class ProjectsController < ApplicationController
+    def index
+        @projects = Project.all
+    end
+    def show
+        @project = Project.where(permalink: params[:permalink])[0]
+    end
+end

+ 2 - 0
app/helpers/application_helper.rb

@@ -0,0 +1,2 @@
+module ApplicationHelper
+end

+ 2 - 0
app/helpers/profile_helper.rb

@@ -0,0 +1,2 @@
+module ProfileHelper
+end

+ 2 - 0
app/helpers/projects_helper.rb

@@ -0,0 +1,2 @@
+module ProjectsHelper
+end

+ 6 - 0
app/javascript/channels/consumer.js

@@ -0,0 +1,6 @@
+// Action Cable provides the framework to deal with WebSockets in Rails.
+// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
+
+import { createConsumer } from "@rails/actioncable"
+
+export default createConsumer()

+ 5 - 0
app/javascript/channels/index.js

@@ -0,0 +1,5 @@
+// Load all the channels within this directory and all subdirectories.
+// Channel files must be named *_channel.js.
+
+const channels = require.context('.', true, /_channel\.js$/)
+channels.keys().forEach(channels)

+ 13 - 0
app/javascript/packs/application.js

@@ -0,0 +1,13 @@
+// This file is automatically compiled by Webpack, along with any other files
+// present in this directory. You're encouraged to place your actual application logic in
+// a relevant structure within app/javascript and only use these pack files to reference
+// that code so it'll be compiled.
+
+import Rails from "@rails/ujs"
+import Turbolinks from "turbolinks"
+import * as ActiveStorage from "@rails/activestorage"
+import "channels"
+
+Rails.start()
+Turbolinks.start()
+ActiveStorage.start()

+ 7 - 0
app/jobs/application_job.rb

@@ -0,0 +1,7 @@
+class ApplicationJob < ActiveJob::Base
+  # Automatically retry jobs that encountered a deadlock
+  # retry_on ActiveRecord::Deadlocked
+
+  # Most jobs are safe to ignore if the underlying records are no longer available
+  # discard_on ActiveJob::DeserializationError
+end

+ 4 - 0
app/mailers/application_mailer.rb

@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+  default from: 'from@example.com'
+  layout 'mailer'
+end

+ 3 - 0
app/models/application_record.rb

@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+  self.abstract_class = true
+end

+ 0 - 0
application/resources/text/HELP_INFO_TEXT__EU → app/models/concerns/.keep


+ 4 - 0
app/models/license.rb

@@ -0,0 +1,4 @@
+class License < ApplicationRecord
+    has_many :project
+  has_one_attached :logo
+end

+ 3 - 0
app/models/mail_adress.rb

@@ -0,0 +1,3 @@
+class MailAdress < ApplicationRecord
+  belongs_to :user
+end

+ 15 - 0
app/models/project.rb

@@ -0,0 +1,15 @@
+class Project < ApplicationRecord
+    has_one_attached :logo
+    has_and_belongs_to_many :technologies
+    has_many :projectUrls
+    belongs_to :license
+    def i18n_title
+        return Text.where(user_id: self.user_id, language: I18n.locale, key: self.title)[0].text
+    end
+    def i18n_header
+        return Text.where(user_id: self.user_id, language: I18n.locale, key: self.header)[0].text
+    end
+    def i18n_text
+        return Text.where(user_id: self.user_id, language: I18n.locale, key: self.text)[0].text
+    end
+end

+ 4 - 0
app/models/project_url.rb

@@ -0,0 +1,4 @@
+class ProjectUrl < ApplicationRecord
+  belongs_to :project
+  belongs_to :urlTarget
+end

+ 6 - 0
app/models/tag.rb

@@ -0,0 +1,6 @@
+class Tag < ApplicationRecord
+    belongs_to :project_id
+    def i18n_tag
+        return t(self.tag)
+    end
+end

+ 5 - 0
app/models/technology.rb

@@ -0,0 +1,5 @@
+class Technology < ApplicationRecord
+    has_one_attached :logo
+    has_and_belongs_to_many :users
+    has_and_belongs_to_many :projects
+end

+ 3 - 0
app/models/text.rb

@@ -0,0 +1,3 @@
+class Text < ApplicationRecord
+  belongs_to :user
+end

+ 9 - 0
app/models/url_target.rb

@@ -0,0 +1,9 @@
+class UrlTarget < ApplicationRecord
+    has_one_attached :logo
+    def i18n_name
+        return Text.where(language: I18n.locale, key: self.name)[0].text
+    end
+    def i18n_summary
+        return Text.where(language: I18n.locale, key: self.summary)[0].text
+    end
+end

+ 11 - 0
app/models/user.rb

@@ -0,0 +1,11 @@
+class User < ApplicationRecord
+    has_many :mail_adresses
+    has_many_attached :picture
+    has_and_belongs_to_many :technologies
+    def i18n_tagline
+        return Text.where(user_id: self.id, language: I18n.locale, key: self.tagline)[0].text
+    end
+    def i18n_bio
+        return Text.where(user_id: self.id, language: I18n.locale, key: self.bio)[0].text
+    end
+end

+ 39 - 0
app/views/layouts/_footer.html.erb

@@ -0,0 +1,39 @@
+<footer>
+    <hr id='footer_separator'/>
+    <br/>
+    <table id='footer_table'>
+        <tr>
+            <td id='footer_left'>
+                <span id='footer_follow' class='desktop'>
+                    <%= t('footer.follow') %>
+                </span>
+                <a target='_blank' title='eMail' href='mailto:i@inigovalentin.com'>
+                    <%= image_tag ("social/email.svg"), class: "footer_social_icon", alt: t('social.mail') , title: t('social.mail') %>
+                </a>
+                <a target='_blank' title='Telegram' href='https://telegram.me/InigoValentin'>
+                    <%= image_tag ("social/telegram.svg"), class: "footer_social_icon", alt: t('social.telegram') , title: t('social.telegram') %>
+                </a>
+                <a target='_blank' title='Github' href='https://github.com/InigoValentin'>
+                    <%= image_tag ("social/github.svg"), class: "footer_social_icon", alt: t('social.github') , title: t('social.github') %>
+                </a>
+                <a target='_blank' title='LinkedIn' href='https://www.linkedin.com/in/ivalentin'>
+                    <%= image_tag ("social/linkedin.svg"), class: "footer_social_icon", alt: t('social.linkedin') , title: t('social.linkedin') %>
+                </a>
+            </td>
+            <td id='footer_center'>
+                <%= t('footer.copy', year: Date.today.year) %>
+            </td>
+            <td id='footer_right'>
+                <a id='footer_help' href='<?=URL::BASE?>/help/'>
+                    <%= t('footer.help') %>
+                </a>
+                <br/><br/>
+                <% I18n.available_locales.each do |locale| %>
+                    <a class='lang' href='<?=$dest?>'>
+                        <%= image_tag ("lang/" + locale.to_s + ".svg") %>
+                    </a>
+                <% end %>
+            </td>
+        </tr>
+    </table>
+</footer>

+ 19 - 0
app/views/layouts/_header.html.erb

@@ -0,0 +1,19 @@
+<header>
+    <div id='logo'>
+        inigoValentin
+    </div>
+    <nav>
+        <%= link_to(
+            image_tag("icon/home.svg") + t('header.home'),
+            main_path()
+        ) %>
+        <%= link_to(
+            image_tag("icon/profile.svg") + t('header.profile'),
+            profile_path()
+        ) %>
+        <%= link_to(
+            image_tag("icon/project.svg") + t('header.projects'),
+            projects_path()
+        ) %>
+    </nav>
+</header>

+ 22 - 0
app/views/layouts/application.html.erb

@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>InigoValentin</title>
+        <meta name="viewport" content="width=device-width,initial-scale=1">
+        <%= csrf_meta_tags %>
+        <%= csp_meta_tag %>
+
+        <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
+        <%= stylesheet_link_tag 'ui', media: 'all', 'data-turbolinks-track': 'reload' %>
+        <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+        <%= yield(:head) %>
+    </head>
+
+    <body>
+        <%= render "layouts/header" %>
+        <main>
+            <%= yield %>
+        </main>
+        <%= render "layouts/footer" %>
+  </body>
+</html>

+ 13 - 0
app/views/layouts/mailer.html.erb

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <style>
+      /* Email styles need to be inline */
+    </style>
+  </head>
+
+  <body>
+    <%= yield %>
+  </body>
+</html>

+ 1 - 0
app/views/layouts/mailer.text.erb

@@ -0,0 +1 @@
+<%= yield %>

+ 58 - 0
app/views/main/index.html.erb

@@ -0,0 +1,58 @@
+<% content_for :head do %>
+    <%= stylesheet_link_tag 'main', media: 'all', 'data-turbolinks-track': 'reload' %>
+<% end %>
+<section id='profile'>
+    <h3>
+        <%= @user.full_name %>
+    </h3>
+    <article>
+        <%=image_tag(@user.picture[0], id: "profile_image")%>
+        <div id='profile_content'>
+            <h4 id='tagline'><%= @user.i18n_tagline %></h4>
+            <p id='bio'><%= @user.i18n_bio %></p>
+        </div>
+        <div class='buttons'>
+            <a class='a_button' title='eMail' href='mailto:<%=@user.mail_adresses[0].address%>'>
+                <%= image_tag (
+                        "social/email.svg"
+                    ),
+                    class: "footer_social_icon",
+                    alt: t('social.mail'),
+                    title: t('social.mail')
+                %>
+            </a>
+            <%= link_to(
+                t('index.profile_more'), profile_path(), class: "a_button"
+            ) %>
+        </div>
+    </article>
+</section>
+<section id='projects'>
+    <h3>
+        <%= t('index.projects') %>
+    </h3>
+    <% @projects.each do |project| %>
+        <article class='project'>
+            <table>
+                <tr>
+                    <td>
+                        <% if project.logo.attached? %>
+                            <%= link_to(
+                                image_tag(project.logo, class: "project_image"),
+                                project_show_path(permalink: project.permalink)
+                            ) %>
+                        <% end %>
+                    </td>
+                    <td class='project_details'>
+                        <h4 class='project_name'>
+                            <%= link_to(project.i18n_title, project_show_path(permalink: project.permalink)) %>
+                        </h4>
+                        <span>
+                            <%= project.i18n_header %>
+                        </span>
+                    </td>
+                </tr>
+            </table>
+        </article>
+    <% end %>
+</section>

+ 13 - 0
app/views/profile/index.html.erb

@@ -0,0 +1,13 @@
+<% content_for :head do %>
+    <%= stylesheet_link_tag 'profile', media: 'all', 'data-turbolinks-track': 'reload' %>
+<% end %>
+<section id='info'>
+    <h3>
+        <%= @user.full_name %>
+    </h3>
+    <article>
+        <%=image_tag(@user.picture[0], id: "profile_image")%>
+        <div id='social'>
+        </div>
+    </article>
+</section>

+ 10 - 0
app/views/projects/index.html.erb

@@ -0,0 +1,10 @@
+<h1>Projects#index</h1>
+<p>Find me in app/views/projects/index.html.erb</p>
+<h2>Projects</h2>
+    <ul>
+        <% @projects.each do |project| %>
+            <li>
+                <%= project.title %>
+            </li>
+        <% end %>
+    </ul>

+ 54 - 0
app/views/projects/show.html.erb

@@ -0,0 +1,54 @@
+<% content_for :head do %>
+    <%= stylesheet_link_tag 'project', media: 'all', 'data-turbolinks-track': 'reload' %>
+<% end %>
+<section>
+    <h3>
+        <%= @project.i18n_title %>
+    </h3>
+    <article>
+        <div id='info_summary'>
+            <h4>
+                <%= @project.i18n_header %>
+            </h4>
+            <p id='text'>
+                <% if @project.logo.attached? %>
+                    <%= image_tag(@project.logo, class: "project_image", id: "logo") %>
+                <% end %>
+                <%= @project.i18n_text.html_safe %>
+            </p>
+        </div>
+        <div id='info_details'>
+            <div id='links' class='details'>
+                <% @project.projectUrls.each do |url| %>
+                    <%= link_to(
+                        image_tag(url.urlTarget.logo, class: "link", title: url.urlTarget.i18n_summary, alt: url.urlTarget.i18n_summary) + url.urlTarget.i18n_name,
+                        url.url,
+                        class: "link",
+                        target: "_blank",
+                        title: url.urlTarget.i18n_summary
+                    ) %>
+                <% end %>
+            </div>
+            <hr class='details_separator'/>
+            <div id='technologies' class='details'>
+                <% @project.technologies.each do |technology| %>
+                    <span class='technology technology_<%=technology.nature%>'>
+                        <%= image_tag(technology.logo, class: "technology_logo") %>
+                        <span class='technology_name'>
+                            <%= technology.name %>
+                        </span>
+                    </span>
+                <% end %>
+            </div>
+            <div id='license' class='details'>
+                <%= t("project.license") %>:
+                <%= link_to(
+                    image_tag(@project.license.logo, title: @project.license.name, alt: @project.license.name),
+                    @project.license.url,
+                    target: "_blank",
+                    title: @project.license.name
+                ) %>
+            </div> <!-- #license -->
+        </div> <!-- #info_details -->
+    </article>
+</section>

+ 0 - 26
application/Application.php

@@ -1,26 +0,0 @@
-<?php
-/**
- * Constants file.
- *
- * Provides some predefined values.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IV
- */
-
-    class URL{
-        //static $BASE = Net.get_protocol() . $_SERVER["HTTP_HOST"];
-        //static $STATIC = Net.get_protocol() . $_SERVER["HTTP_HOST"];
-        //static $BASE = ((1 == 1) ? 1 : 0);
-        //static $BASE = $_SERVER["HTTP_HOST"];
-    }
-    
-    final class EXCEPTION_CODE{
-        const PDO_UNSUPPORTED = 800001;
-        const PDO_MYSQL_HOSTNAME = 807701;
-        const PDO_MYSQL_DBNAME = 807702;
-        const PDO_MYSQL_PORT = 807703;
-    }
-
-?>

+ 0 - 68
application/Context.php

@@ -1,68 +0,0 @@
-<?php
-/**
- * Context file.
- *
- * Provides a handy class with usefull data to be accessible from anywhere in the app.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IV
- */
-
-/**
- * Application context.
- *
- * Stores usefull data to be retrieved anywhere in the app.
- *
- * @category Context
- */
-class Context {
-
-    /**
-     * @var SQLITE3 Database connection.
-     */
-    private $db;
-
-    /**
-     * Retrieves the database connection.
-     *
-     * @return SQLITE3 The database connection.
-     */
-    public function get_db(){
-        return $this->db;
-    }
-
-    /**
-     * Sets the database connection
-     *
-     * @param SQLITE3 Database connection.
-     */
-    protected function set_db($db){
-        $this->db = $db;
-        Log::debug("Context database is set and accesible.");
-        if ($this->db == null){
-            Log::debug("It is null");
-        }
-    }
-    
-    /**
-     * Retrieves the language.
-     * 
-     * @todo Implement
-     * @return string Two letter language code.
-     */
-    public function get_lang(){
-        return "es";
-    }
-    
-    /**
-     * Retrieves the list of available languages.
-     *
-     * @todo Implement
-     * @return string Two letter language code.
-     */
-    public function get_available_langs(){
-        return [];
-    }
-
-}

+ 0 - 362
application/Controller.php

@@ -1,362 +0,0 @@
-<?php
-/**
- * Controller file.
- *
- * Provides a class to handle all posible request.
- * 
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IVV
- */
-
-require_once(__DIR__ . "/Context.php");
-require_once(__DIR__ . "/helper/DB_Helper.php");
-require_once(__DIR__ . "/helper/TEXT_Helper.php");
-require_once(__DIR__ . "/helper/NET_Helper.php");
-require_once(__DIR__ . "/helper/HTML_Helper.php");
-require_once(__DIR__ . "/util/Log.php");
-require_once(__DIR__ . "/util/Path.php");
-require_once(__DIR__ . "/util/URL.php");
-//require_once(__DIR__ . "/helper/net.php");
-//require_once(__DIR__ . "/Application.php");
-//require_once(__DIR__ . "/util/Log.php");
-
-
-/**
- * Application controller.
- *
- * Handles every request, creating the required models and selecting the
- * view.
- *
- * @category Controller
- */
-class Controller extends Context{
-
-    /**
-     * @var string[] GET parameters received by the controller.
-     */
-    private $params = [];
-
-    /**
-     * @var Context Publicly available context.
-     */
-    private $context;
-    
-    private $command = "";
-    
-    private $status = 201;
-    private $message = "OK";
-    
-
-    /**
-     * Retrieves the application context.
-     * 
-     * @return Context The context.
-     */
-    public function get_context(){
-        return $this->context;
-    }
-    
-    /**
-     * Controller constructor.
-     *
-     * Initializes a database connection and sets up the public context.
-     */
-    public function __construct(){
-        $this->context = new Context();
-        session_start();
-        $configuration = parse_ini_file(__DIR__ . "/config/config.ini", true);
-        $this->db = DB::start($configuration["database"]);
-        $this->context->set_db($this->db);
-        Log::debug("Controller created succesfully");
-    }
-    
-    private function execute_action($action){
-        require_once(PATH::ACTION . $action . ".php");
-        action();
-        return;
-    }
-    
-    /**
-     * Handles the request parameters.
-     *
-     * Receives the request params and gets itself ready. Authenticates the user (if needed)
-     * and validates the URL.
-     *
-     * @param string[] $params GET parameters of the request.
-     */
-    public function prepare($params){
-
-        // Parse parameters.
-        foreach($params as $p){
-            if (strlen($p) > 0){
-                Log::debug("Controller parameter: $p");
-                array_push($this->params, $p);
-            }
-        }
-        
-        // Obtain the command and process it
-        if (sizeof($this->params) > 0){
-            $this->command = strtoupper($this->params[0]);
-        }
-        Log::debug("Controller command set: '" . $this->command . "'");
-        switch ($this->command){
-            case "": // Main page
-                break;
-            case "API": // An API call
-                return; // End preparation here, the API controller will deal with everything.
-                break;
-            case "ACTION": // Execute an action
-                //$auth_required = true;
-                break;
-            case "PLAYER": // A player page
-                if (sizeof($this->params) > 1){
-                    $player_id = $this->params[1];
-                }
-                else{
-                    $this->status = 400;
-                    $this->message = "Bad request";
-                    return;
-                }
-                break;
-            case "LOGIN": // The login page
-                break;
-            case "REGISTER": // Registration page
-                break;
-            case "SEARCH": // Search results
-                break;
-            case "DUNGEON": // Dungeon static pages
-                break;
-            case "BUILDING": // Building static pages
-                break;
-            case "FUSION": // Fusion static pages
-                break;
-            case "HELP": // Help static page
-                break;
-            case "ERROR": // Error page
-                break;
-            default: // Unknown page
-                
-        }
-    }
-    
-    /**
-     * Executes the required action.
-     *
-     * Must be called after {@see Controller::prepare()}.
-     * @return void|number
-     */
-    public function action(){
-        
-        Log::debug("Executing action");
-        
-        // If there was an error in preparation, it's time to throw it.
-        if ($this->status >= 400 && $this->status < 500){
-            Log::debug("Executing action error code: " . $this->status);
-            require_once(PATH::PAGE . "Error_Page.php");
-            $page = new Error_Page($this->status, $this->message);
-            require_once($page->get_view());
-            http_response_code($this->status);
-            return $this->status;
-        }
-        
-        // Process the command
-        $page = null;
-        switch ($this->command){
-            case "": // Main page
-                require_once(PATH::PAGE . "Home_Page.php");
-                $page = new Home_Page();
-                break;
-            case "ACTION": // Execute an action
-                // If no action specified
-                if (sizeof($this->params) < 2){
-                    require_once(PATH::PAGE . "Error_Page.php");
-                    $page = new Error_Page(400, "No action specified.");
-                    require_once($page->get_view());
-                    http_response_code(400);
-                    return 400;
-                }
-                
-                // Process action
-                $action = strtoupper($this->params[1]);
-                switch ($action){
-                    // Special cases where the output must be printed:
-                    case "OPTIMIZE_LIST":
-                        require_once(PATH::ACTION . "Optimize_List_Action.php");
-                        $action = new Optimize_List_Action();
-                        break;
-                    default:
-                        require_once(PATH::PAGE . "Error_Page.php");
-                        $page = new Error_Page(404, "Action not found");
-                        require_once($page->get_view());
-                        http_response_code(404);
-                        return;
-                }
-                $action->execute();
-                if (strlen($action->get_output()) > 0){
-                    echo($action->get_output());
-                }
-                http_response_code($action->get_code());
-                return $action->get_code();
-                break;
-            case "PLAYER": // A player page
-                if ($this->context->get_player() == null || $this->context->get_player()->get_id() == null){
-                    require_once(PATH::PAGE . "Error_Page.php");
-                    $page = new Error_Page(404, "Player not found");
-                    require_once($page->get_view());
-                    http_response_code(404);
-                    return;
-                }
-                if (
-                  $this->context->get_player()->is_public() == false &&
-                  (
-                      $this->context->get_user() == null ||
-                    $this->context->get_player()->get_user() != $this->context->get_user()->get_id()
-                  )
-                ){
-                    require_once(PATH::PAGE . "Error_Page.php");
-                    $page = new Error_Page(401, "Player profile set to private");
-                    require_once($page->get_view());
-                    http_response_code(401);
-                }
-                $subcommand = "";
-                if (sizeof($this->params) > 2){
-                    $subcommand = strtoupper($this->params[2]);
-                }
-                $page = null;
-                switch ($subcommand){
-                    case "": // Player profile
-                        require_once(PATH::PAGE . "Player_Page.php");
-                        $page = new Player_Page($this->context->get_player()->get_id());
-                        break;
-                    
-                    case "TEAMS":
-                        require_once(PATH::PAGE . "Teams_Page.php");
-                        $page = new Teams_Page();
-                        break;
-                }
-                break;
-            
-            case "BUILDINGS": // Building static pages
-                if (sizeof($this->params) > 1){
-                    require_once(PATH::PAGE . "Building_Page.php");
-                    $page = new Building_Page($this->params[1]);
-                }
-                else{
-                    require_once(PATH::PAGE . "Buildings_Page.php");
-                    $page = new Buildings_Page();
-                }
-                break;
-                break;
-            /*case "FUSION": // Fusion static pages
-                require_once(PATH::PAGE . "Fusion_Page.php");
-                $page = new Fusion_Page();
-                break;*/
-            case "HELP": // Help static page
-                require_once(PATH::PAGE . "Help_Page.php");
-                $page = new Help_Page();
-                break;
-        }
-        
-        // If page is not set, it's a not found.
-        if ($page == null){
-            require_once(PATH::PAGE . "Error_Page.php");
-            $page = new Error_Page(404, "Page not found");
-        }
-        
-        // Once the page is loaded, chack if it can be seen
-        // TODO verify
-        if ($page->get_code() >= 400 && $page->get_code() < 600){
-            require_once(PATH::PAGE . "Error_Page.php");
-            $page = new Error_Page($page->get_code(), $page->get_message());
-            http_response_code($page->get_code());
-        }
-        
-        
-        // Load the view, or set an error code.
-        Log::debug("Loading view: " . $page->get_view());
-        require_once($page->get_view());
-        http_response_code($page->get_code());
-    }
-
-        /**
-         * Constructor.
-         *
-         * Handles every request, creating the required models and selecting the
-         * view.
-         */
-        /*public function __construct($params){
-
-            global $path;
-            global $base_url;
-            global $static;
-            global $static_url;
-            global $base_dir;
-            $page;
-            
-            header("Content-Type: text/html; charset=utf8");
-            
-            // Read configuration
-            // TODO: Read the other params and do something with them.
-            $configuration = parse_ini_file(__DIR__ . "/config/config.ini", true);
-            $db = DB::start($configuration["database"]);
-
-            // Parse parameters, get lang and build the route.
-            $pars = [];
-            foreach($params as $p){
-                if (strlen($p) > 0){
-                    array_push($pars, $p);
-                }
-            }
-            $route = [];
-            if (sizeof($pars) > 0 && preg_match("/^[a-zA-Z]{2}$/", $pars[0])){
-                $lang = $pars[0];
-                array_splice($pars, 0, 1);
-                // Override global to include language in URL
-                $base_url = get_protocol() . $_SERVER["HTTP_HOST"] . "/" . $lang;
-            }
-            else{
-                $lang = select_language($db);
-            }
-            foreach($pars as $p){
-                array_push($route, $p);
-            }
-
-            // Select the model to load.
-            if (sizeof($route) == 0){
-                require_once($path["page"] . "Home_Page.php");
-                $page = new Home_Page($db, $lang);
-            }
-            else{
-                if (strtoupper($route[0]) == "HELP"){
-                    require_once($path["page"] . "Help_Page.php");
-                    $page = new Help_Page($db, $lang);
-                }
-                if (strtoupper($route[0]) == "PROFILE"){
-                    require_once($path["page"] . "Profile_Page.php");
-                    $page = new Profile_Page($db, $lang);
-                }
-                elseif (strtoupper($route[0]) == "PROJECT"){
-                    if (sizeof($route) > 1){
-                        // Project page
-                        require_once($path["page"] . "Project_Page.php");
-                        $page = new Project_Page($db, $lang, $route[1]);
-                    }
-                    else{
-                        // Project list page
-                        require_once($path["page"] . "Projects_Page.php");
-                        $page = new Projects_Page($db, $lang);
-                    }
-                }
-            }
-
-            // Load the view, or set an error code.
-            if (!isset($page)){
-                http_response_code(404);
-                require_once($path["page"] . "Error_Page.php");
-                $page = new Error_Page($db, $lang);
-            }
-            require_once($page->view);
-        }*/
-    }
-?>

+ 0 - 14
application/config/config.ini

@@ -1,14 +0,0 @@
-[database]
-type = "mysql"
-host = "localhost"
-port = "3306"
-name = "web"
-user = "web"
-pass = "XXX"
-
-[language]
-available = "en|es|eu"
-default = "es"
-
-[maintenance]
-enable = false

+ 0 - 44
application/config/config.php

@@ -1,44 +0,0 @@
-<?php
-
-    require_once(__DIR__ . "/../helper/net.php");
-
-    /**
-     * Server base url, including protocol, without language indicator.
-     * It may be overwritten by the controller to add the language.
-     */
-    $base_url = get_protocol() . $_SERVER["HTTP_HOST"];
-    $static_url = get_protocol() . $_SERVER["HTTP_HOST"];
-
-    /**
-     * Static url, absolute, language independant.
-     */
-    $static = [
-        "layout" => $static_url . "/img/layout/",
-        "content" => $static_url . "/img/content/",
-        "fonts" => $static_url . "/fonts/",
-        "css" => $static_url . "/css/",
-        "demo" => $static_url . "/demo/",
-        "js" => $static_url . "/js/",
-        "cv" => $static_url . "/cv/"
-    ];
-
-    /**
-     * Server document root.
-     */
-    $base_dir = $_SERVER["DOCUMENT_ROOT"];
-
-    /**
-     * Paths within the server.
-     */
-    $path = [
-        "application" => $base_dir . "/../application/",
-        "controller" => $base_dir . "/../application/Controller.php",
-        "entity" => $base_dir . "/../application/entity/",
-        "page" => $base_dir . "/../application/page/",
-        "helper" => $base_dir . "/../application/helper/",
-        "view" => $base_dir . "/../application/view/",
-        "inc" => $base_dir . "/../application/view/inc/",
-        "string" => $base_dir . "/../application/view/string/"
-    ];
-
-?>

+ 0 - 58
application/entity/Cv.php

@@ -1,58 +0,0 @@
-<?php
-
-    require_once($path["entity"] . "Entity.php");
-    require_once($path["entity"] . "Lang.php");
-
-
-    /**
-     * CV file.
-     *
-     * Represents an object from the table 'cv'.
-     */
-    class Cv extends Entity{
-
-        /**
-         * CV file identifier.
-         */
-        public $id;
-
-        /**
-         * CV {@see Lang}.
-         */
-        public $lang;
-
-        /**
-         * Filename.
-         */
-        public $file;
-
-
-        /**
-         * Constructor.
-         *
-         * Searches the database and retrieves the information about the
-         * object, populating it.
-         *
-         * @param MySQL_connection $db Connection to the database.
-         * @param int $id Database identifier of the language.
-         */
-        public function __construct($db, $id){
-            parent::__construct($db, null);
-            $s =
-              "SELECT " .
-              "  lang, " .
-              "  file " .
-              "FROM cv " .
-              "WHERE " .
-              "  id = '$id'; ";
-            error_log($s);
-            $q = mysqli_query($this->db, $s);
-            if (mysqli_num_rows($q) > 0){
-                $r = mysqli_fetch_array($q);
-                $this->id = $id;
-                $this->lang = new Lang($this->db, $r["lang"]);
-                $this->file = $r["file"];
-            }
-        }
-    }
-?>

+ 0 - 24
application/entity/Entity.php

@@ -1,24 +0,0 @@
-<?php
-
-/**
- * Entity superclass.
- *
- * Every other entity must inherit from this one. It represents a database
- * entity.
- */
-abstract class Entity{
-    protected $loaded = false;
-    protected $complete = false;
-    protected function mark_as_loaded($loaded){
-        $this->loaded = (bool) $loaded;
-    }
-    protected function mark_as_complete($complete){
-        $this->complete = (bool) $complete;
-    }
-    public function is_loaded(){
-        return $this->loaded;
-    }
-    public function is_complete(){
-        return $this->complete;
-    }
-}

+ 0 - 56
application/entity/Lang.php

@@ -1,56 +0,0 @@
-<?php
-
-    require_once($path["entity"] . "Entity.php");
-
-
-    /**
-     * Language.
-     *
-     * Represents an object from the table 'lang'.
-     */
-    class Lang extends Entity{
-
-        /**
-         * Lowercase, two-letter language code.
-         */
-        public $code;
-
-        /**
-         * Language name, in it's own language.
-         */
-        public $name;
-
-        /**
-         * Indictes wether the language is offered in this language.
-         */
-        public $active;
-
-        /**
-         * Constructor.
-         *
-         * Searches the database and retrieves the information about the
-         * object, populating it.
-         *
-         * @param MySQL_connection $db Connection to the database.
-         * @param int $id Database identifier of the language.
-         */
-        public function __construct($db, $id){
-            parent::__construct($db, null);
-            $s =
-              "SELECT " .
-              "  code, " .
-              "  name, " .
-              "  active " .
-              "FROM lang " .
-              "WHERE " .
-              "  code = '$id'; ";
-            $q = mysqli_query($this->db, $s);
-            if (mysqli_num_rows($q) > 0){
-                $r = mysqli_fetch_array($q);
-                $this->code = $r["code"];
-                $this->name = $r["name"];
-                $this->active = $r["active"];
-            }
-        }
-    }
-?>

+ 0 - 120
application/entity/License.php

@@ -1,120 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-
-
-/**
- * License.
- *
- * Represents an object from the table 'license'.
- */
-class License extends Entity{
-
-    /**
-     * @var string License identifier. Usually an abbreviation.
-     */
-    private $id;
-
-    /**
-     * @var string Short, easily readable text summarizing the full text of
-     * the license.
-     */
-    private $summary;
-
-    /**
-     * @var string Full text of the license.
-     */
-    private $legal;
-
-    /**
-     * @var string License logo.
-     */
-    private $logo;
-
-    /**
-     * @var string License icon, small.
-     */
-    private $icon;
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * object, populating it.
-     *
-     * @param string $id Identifier of the license.
-     */
-    public function __construct($id){
-        $statement = get_context()->get_db()->prepare("
-          SELECT
-            id
-            summary
-            legal
-            logo
-            icon
-          FROM license
-          WHERE id = :id
-        ");
-        $statement->bindValue(':id', $id, PDO::PARAM_INT);
-        $statement->execute();
-        $r_license = $statement->fetch(PDO::FETCH_ASSOC);
-        if ($r_license !== false){
-            $this->id = $r_license["id"];
-            $this->summary = TEXT::get($r_license["summary"]);
-            $this->legal = TEXT::get($r_license["legal"]);
-            $this->logo = $r_license["logo"];
-            $this->icon = $r_license["icon"];
-            $this->mark_as_loaded(true);
-            $this->mark_as_complete(true);
-        }
-        else{
-            Log::warn("License with id '$id' doesn't exist");
-        }
-    }
-    
-    /**
-     * Retrieves the license identifier
-     *
-     * @return string License ID.
-     */
-    public function get_id(){
-        return $this->id;
-    }
-    
-    /**
-     * Retrieves a short, easily readable text summarizing the full text of
-     * the license.
-     *
-     * @return string License summary.
-     */
-    public function get_summary(){
-        return $this->summary;
-    }
-    
-    /**
-     * Retrieves the full text of the license
-     *
-     * @return string License legal text.
-     */
-    public function get_legal(){
-        return $this->legal;
-    }
-    
-    /**
-     * Retrieves the license logo.
-     *
-     * @return string The logo filename.
-     */
-    public function get_logo(){
-        return $this->logo;
-    }
-    
-    /**
-     * Retrieves the license icon.
-     *
-     * @return string The icon filename.
-     */
-    public function get_icon(){
-        return $this->icon;
-    }
-}

+ 0 - 412
application/entity/Project.php

@@ -1,412 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-require_once(PATH::ENTITY . "License.php");
-require_once(PATH::ENTITY . "Project_Type.php");
-require_once(PATH::ENTITY . "Project_Image.php");
-require_once(PATH::ENTITY . "Project_Url.php");
-
-
-/**
- * Project.
- *
- * Represents an object from the table 'project'.
- */
-class Project extends Entity{
-
-    /**
-     * @var int Project identifier.
-     */
-    private $id;
-
-    /**
-     * @var string Permalink for linking the project (relative).
-     */
-    private $permalink;
-
-    /**
-     * @var int Project index for sorting.
-     */
-    private $index;
-
-    /**
-     * @var int Project type identifier.
-     */
-    private $type_id;
-    
-    /**
-     * @var Project_Type Type of project.
-     */
-    private $type;
-
-    /**
-     * @var string Project title in the selected language.
-     */
-    private $title;
-
-    /**
-     * @var string Project logo filename.
-     */
-    private $logo;
-
-    /**
-     * @var string Project summary in the selected language.
-     */
-    private $header;
-
-    /**
-     * @var String Project description in the selected language.
-     */
-    private $text;
-    
-    /**
-     * @var int License identifier.
-     */
-    private $license_id;
-
-    /**
-     * @var License Project license.
-     */
-    private $license;
-
-    /**
-     * @var Project_Image[] List of project images.
-     */
-    private $images = [];
-
-    /**
-     * @var Project_Tag[] List of project tags.
-     */
-    private $tags = [];
-
-    /**
-     * @var Project_URL[] List of the project URLs
-     */
-    private $urls = [];
-    
-    /**
-     * @var bool[] Control flags to check loading status.
-     */
-    private $load_flags = [
-        "type" => false,
-        "images" => false,
-        "tags" => false,
-        "urls" => false
-    ];
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * project, populating it and it's items.
-     *
-     * @param string $id Identifier or permalink of the project.
-     */
-    public function __construct($id){
-        Log::debug("Loading project with ID: " . $id);
-        $statement = get_context()->get_db()->prepare("
-          SELECT
-            id,
-            permalink,
-            idx,
-            type,
-            title,
-            logo,
-            header,
-            text,
-            license
-          FROM project
-          WHERE
-            id = :id OR
-            permalink = :permalink
-          LIMIT 1
-        ");
-        $statement->bindValue(':id', $id, PDO::PARAM_INT);
-        $statement->bindValue(':permalink', $id, PDO::PARAM_STR);
-        $statement->execute();
-        $r_project = $statement->fetch(PDO::FETCH_ASSOC);
-        if ($r_project !== false){
-            $this->id = $r_project["id"];
-            $this->permalink = $r_project["permalink"];
-            $this->idx = $r_project["idx"];
-            $this->title = Text::get($r_project["title"]);
-            $this->logo = $r_project["logo"];
-            $this->header = Text::get($r_project["header"]);
-            $this->text = Text::get($r_project["text"]);
-            $this->type_id = $r_project["type"];
-            $this->license_id = $r_project["license"];
-            $this->mark_as_loaded(true);
-        }
-        else{
-            Log::debug("Project with id '$id' doesn't exist");
-        }
-    }
-
-    /**
-     * Retrieves the project identifier
-     *
-     * @return int Project ID.
-     */
-    public function get_id(){
-        return $this->id;
-    }
-
-    /**
-     * Retrieves the project permalink
-     *
-     * @return string Project permalink
-     */
-    public function get_permalink(){
-        return $this->permalink;
-    }
-
-    /**
-     * Retrieves the project index for sorting purpuses.
-     *
-     * @return int Project index
-     */
-    public function get_index(){
-        return $this->index;
-    }
-
-    /**
-     * Loads the project type information.
-     * 
-     * Not exposed, must be called before accessing the project type.
-     */
-    private function load_type(){
-        if ($this->get_flag("type") === false){
-            $this->type = new Project_Type($this->type_id);
-            $this->set_flag("type", true);
-        }
-    }
-    
-    /**
-     * Retrieves the project type.
-     *
-     * @return Project_Type The project type.
-     */
-    public function get_type(){
-        if ($this->get_flag("type") === false){
-            $this->load_type();
-        }
-        return $this->type;
-    }
-
-    /**
-     * Retrieves the project title.
-     *
-     * @return string Title.
-     */
-    public function get_title(){
-        return $this->title;
-    }
-
-    /**
-     * Retrieves the project logo.
-     *
-     * @return string The logo filename.
-     */
-    public function get_logo(){
-        return $this->logo;
-    }
-
-    /**
-     * Retrieves a short project description.
-     *
-     * @return string Project header.
-     */
-    public function get_header(){
-        return $this->header;
-    }
-
-    /**
-     * Retrieves the project description.
-     *
-     * @return string Project description text.
-     */
-    public function get_text(){
-        return $this->text;
-    }
-    
-    /**
-     * Loads the project license information.
-     *
-     * Not exposed, must be called before accessing the project license.
-     */
-    private function load_license(){
-        if ($this->get_flag("license") === false){
-            $this->type = new License($this->licenses_id);
-            $this->set_flag("license", true);
-        }
-    }
-
-    /**
-     * Retrieves the project license.
-     *
-     * @return License Project license.
-     */
-    public function get_license(){
-        if ($this->get_flag("license") === false){
-            $this->load_license();
-        }
-        return $this->license;
-    }
-    
-    /**
-     * Loads the project images.
-     *
-     * Not exposed, must be called before accessing the project images.
-     */
-    private function load_images(){
-        if ($this->get_flag("images") === false){
-            $statement = get_context()->get_db()->prepare("
-              SELECT id 
-              FROM project_image
-              WHERE project = :id
-              ORDER BY idx
-            ");
-            $statement->bindValue(':id', $this->id, PDO::PARAM_INT);
-            $statement->execute();
-            while ($r_image = $statement->fetch(PDO::FETCH_ASSOC)){
-                array_push($this->images, new Project_Image($r_image["id"]));
-            }
-            $this->set_flag("images", true);
-        }
-    }
-
-    /**
-     * Retrieves the projcet images
-     *
-     * @return Project_Image[] List of the project images.
-     */
-    public function get_images(){
-        if ($this->get_flag("images") === false){
-            $this->load_images();
-        }
-        return $this->images;
-    }
-    
-    /**
-     * Loads the project tags.
-     *
-     * Not exposed, must be called before accessing the project tags.
-     */
-    private function load_tags(){
-        if ($this->get_flag("tags") === false){
-            $statement = get_context()->get_db()->prepare("
-              SELECT id
-              FROM project_tag
-              WHERE project = :id
-            ");
-            $statement->bindValue(':id', $this->id, PDO::PARAM_INT);
-            $statement->execute();
-            while ($r_tag = $statement->fetch(PDO::FETCH_ASSOC)){
-                array_push($this->tags, Text::get($r_tag["id"]));
-            }
-            $this->set_flag("tags", true);
-        }
-    }
-
-    /**
-     * Retrieves the project tags.
-     *
-     * @return Project_Tag[] Project tags. 
-     */
-    public function get_tags(){
-        if ($this->get_flag("tags") === false){
-            $this->load_tags();
-        }
-        return $this->tags;
-    }
-    
-    /**
-     * Loads the project URLs.
-     *
-     * Not exposed, must be called before accessing the project URLs.
-     */
-    private function load_urls(){
-        if ($this->get_flag("urls") === false){
-            $statement = get_context()->get_db()->prepare("
-              SELECT id
-              FROM project_url
-              WHERE project = :id
-            ");
-            $statement->bindValue(':id', $this->id, PDO::PARAM_INT);
-            $statement->execute();
-            while ($r_url = $statement->fetch(PDO::FETCH_ASSOC)){
-                array_push($this->urls, new Project_Url($r_url["id"]));
-            }
-            $this->set_flag("urls", true);
-        }
-    }
-
-    /**
-     * Retrieves the project URLs
-     *
-     * @return Project_URL[] List of the project URLs. 
-     */
-    public function get_urls(){
-        if ($this->get_flag("urls") === false){
-            $this->load_urls();
-        }
-        return $this->urls;
-    }
-
-    /**
-     * Retrieves a state flag
-     *
-     * @return boolean Flag value, false if it doesn't exist. 
-     */
-    private function get_flag($flag){
-        $value = false;
-        if (array_key_exists($flag , $this->load_flags)){
-            $value = $this->load_flags[$flag];
-        }
-        return $value;
-    }
-
-    /**
-     * Sets a load status flag.
-     * 
-     * If, once set, all flags are set to true, mark_as_complete(true)
-     * will be automatically called.
-     * 
-     * @param string $flag Flag name.
-     * @param boolean $value Flag name.
-     */
-    private function set_flag($flag, $value){
-        $key_found = false;
-        $keys = array_keys($this->load_flags);
-        foreach($keys as $key){
-            if ($key === $flag){
-                $key_found = true;
-                break;
-            }
-        }
-        if ($key_found == false){
-            Log::warn("Trying to set non-existing flag '$flag' in project");
-            return false;
-        }
-        else{
-            if ($value !== true && $value !== false){
-                Log::warn("Trying to set project flag '$flag' to an invalid value: " . $value);
-                return false;
-            }
-            else{
-                $this->load_flags[$flag] = $value;
-                
-                // Once set, loop all keys to check if they are all true
-                $all_loaded = true;
-                foreach($this->load_flags as $value){
-                    if ($value !== true){
-                        $all_loaded = false;
-                        break;
-                    }
-                }
-                $this->mark_as_complete($all_loaded);
-                return true;
-            }
-        }
-    }
-}

+ 0 - 102
application/entity/Project_Image.php

@@ -1,102 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-
-
-/**
- * Image of a project.
- *
- * Represents an object from the table 'project_image'.
- */
-class Project_Image extends Entity{
-
-    /**
-     * @var int Image identifier.
-     */
-    private $id;
-
-    /**
-     * @var int Project identifier.
-     */
-    private $project;
-
-    /**
-     * @var int Indicates the order position among other images.
-     */
-    private $idx;
-
-    /**
-     * @var int Filename of the image.
-     */
-    private $image;
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * image, populating it.
-     *
-     * @param int $id Identifier of the image.
-     */
-    public function __construct($id){
-        $statement = get_context()->get_db()->prepare("
-          SELECT
-            id,
-            project,
-            idx,
-            image
-          FROM project_image
-          WHERE id = :id
-        ");
-        $statement->bindValue(':id', $id, PDO::PARAM_INT);
-        $statement->execute();
-        $r_image = $statement->fetch(PDO::FETCH_ASSOC);
-        if ($r_image !== false){
-            $this->id = $r_image["id"];
-            $this->project = $r_image["title"];
-            $this->idx = $r_image["idx"];
-            $this->image = $r_image["image"];
-            $this->mark_as_loaded(true);
-            $this->mark_as_complete(true);
-        }
-        else{
-            Log::warn("Project image with id '$id' doesn't exist");
-        }
-    }
-    
-    /**
-     * Retrieves the image identifier
-     *
-     * @return int Image ID.
-     */
-    public function get_id(){
-        return $this->id;
-    }
-    
-    /**
-     * Retrieves the project identifier
-     *
-     * @return int Project ID.
-     */
-    public function get_project(){
-        return $this->project;
-    }
-    
-    /**
-     * Retrieves the image index for sorting.
-     *
-     * @return int Image index.
-     */
-    public function get_idx(){
-        return $this->idx;
-    }
-    
-    /**
-     * Retrieves the image filename.
-     *
-     * @return string Image filename.
-     */
-    public function get_image(){
-        return $this->image;
-    }
-}

+ 0 - 37
application/entity/Project_Tag.php

@@ -1,37 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-
-
-/**
- * Tag of a project.
- *
- * Represents an object from the table 'project_tag'.
- */
-class Project_Tag extends Entity{
-
-    /**
-     * Identifier of the project the tag belongs to.
-     */
-    public $project;
-
-    /**
-     * Tag text.
-     */
-    public $tag;
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * tag, populating it.
-     *
-     * @param int $project Identifier of the project the tag belongs to.
-     * @param string $tag Tag identifier. Same as it's text.
-     */
-    public function __construct($db, $lang, $project, $tag){
-        parent::__construct($db, $lang);
-        $this->project = $project;
-        $this->tag = text($this, $tag);
-    }
-}

+ 0 - 86
application/entity/Project_Type.php

@@ -1,86 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-
-
-/**
- * Type of a project.
- *
- * Represents an object from the table 'project_type'.
- */
-class Project_Type extends Entity{
-
-    /**
-     * @var int Identifier of the project type.
-     */
-    private $id;
-
-    /**
-     * @var String Type denomination, in the defined language.
-     */
-    private $title;
-
-    /**
-     * @var String Type description, in the defined language.
-     */
-    private $summary;
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * type, populating it.
-     *
-     * @param string $id Identifier of the project type.
-     */
-    public function __construct($id){
-        $statement = get_context()->get_db()->prepare("
-          SELECT
-            id,
-            title,
-            summary
-          FROM project_type
-          WHERE id = :id;
-        ");
-        $statement->bindValue(':id', $id, PDO::PARAM_INT);
-        $statement->execute();
-        $r_type = $statement->fetch(PDO::FETCH_ASSOC);
-        if ($r_type !== false){
-            $this->id = $r_type["id"];
-            $this->title = TEXT::get($r_type["title"]);
-            $this->summary = TEXT::get($$r_type["summary"]);
-            $this->mark_as_loaded(true);
-            $this->mark_as_complete(true);
-        }
-        else{
-            Log::warn("Project type with id '$id' doesn't exist");
-        }
-    }
-    
-    /**
-     * Retrieves the project type identifier
-     *
-     * @return int Project type ID.
-     */
-    public function get_id(){
-        return $this->id;
-    }
-    
-    /**
-     * Retrieves the project type title.
-     *
-     * @return string Type name.
-     */
-    public function get_title(){
-        return $this->title;
-    }
-    
-    /**
-     * Retrieves the project type description.
-     *
-     * @return string Type summary.
-     */
-    public function get_summary(){
-        return $this->summary;
-    }
-}

+ 0 - 102
application/entity/Project_Url.php

@@ -1,102 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-
-
-/**
- * URL related to a project.
- *
- * Represents an object from the table 'project_url'.
- */
-class Project_Url extends Entity{
-
-    /**
-     * @var int Identifier of the URL.
-     */
-    private $id;
-
-    /**
-     * @var int Identifier of the project the URL is related to.
-     */
-    private $project;
-
-    /**
-     * @var Project_Url_Type URL type.
-     */
-    private $type;
-
-    /**
-     * @var string Full URL address.
-     */
-    private $url;
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * url, populating it and its items.
-     *
-     * @param int $id Identifier of the URL.
-     */
-    public function __construct($id){
-        $statement = get_context()->get_db()->prepare("
-          SELECT
-            id
-            project
-            type
-            url
-          FROM project_url
-          WHERE id = :id
-        ");
-        $statement->bindValue(':id', $id, PDO::PARAM_INT);
-        $statement->execute();
-        $r_url = $statement->fetch(PDO::FETCH_ASSOC);
-        if ($r_url !== false){
-            $this->id = $r_url["id"];
-            $this->project = $r_url["project"];
-            $this->type = new Project_Url_Type($r_url["type"]);
-            $this->url = $r_url["url"];
-            $this->mark_as_loaded(true);
-            $this->mark_as_complete(true);
-        }
-        else{
-            Log::warn("Project URL with id '$id' doesn't exist");
-        }
-    }
-    
-    /**
-     * Retrieves the URL identifier
-     *
-     * @return int URL ID.
-     */
-    public function get_id(){
-        return $this->id;
-    }
-    
-    /**
-     * Retrieves the project identifier
-     *
-     * @return int Project ID.
-     */
-    public function get_project(){
-        return $this->project;
-    }
-    
-    /**
-     * Retrieves the url type.
-     *
-     * @return Project_Url_Type URL type.
-     */
-    public function get_type(){
-        return $this->type;
-    }
-    
-    /**
-     * Retrieves the URL
-     *
-     * @return string The URL.
-     */
-    public function get_url(){
-        return $this->url;
-    }
-}

+ 0 - 63
application/entity/Project_Url_Type.php

@@ -1,63 +0,0 @@
-<?php
-
-require_once(PATH::ENTITY . "Entity.php");
-
-
-/**
- * Type of URL.
- *
- * Represents an object from the table 'project_url_type'.
- */
-class Project_Url_Type extends Entity{
-
-    /**
-     * URL type identifier.
-     */
-    public $id;
-
-    /**
-     * URL denomination, in the defined language.
-     */
-    public $title;
-
-    /**
-     * URL short explanation, in the defined language.
-     */
-    public $summary;
-
-    /**
-     * Filename of the logo of the URL. Usually, the logo of the site it
-     * points to.
-     */
-    public $logo;
-
-    /**
-     * Constructor.
-     *
-     * Searches the database and retrieves the information about the
-     * url type, populating it and its items.
-     *
-     * @param MySQL_connection $db Connection to the database.
-     * @param string $lang Lowercase, two-letter language code.
-     * @param int $id Identifier of the url type.
-     */
-    public function __construct($db, $lang, $id){
-        parent::__construct($db, $lang);
-        $s =
-          "SELECT " .
-          "  id, " .
-          "  title, " .
-          "  summary, " .
-          "  logo " .
-          "FROM project_url_type " .
-          "WHERE id = '$id' ;";
-        $q = mysqli_query($this->db, $s);
-        if (mysqli_num_rows($q) > 0){
-            $r = mysqli_fetch_array($q);
-            $this->id = $r["id"];
-            $this->title = text($this, $r["title"]);
-            $this->summary = text($this, $r["summary"]);
-            $this->logo = $r["logo"];
-        }
-    }
-}

+ 0 - 126
application/helper/DB_Helper.php

@@ -1,126 +0,0 @@
-<?php
-/**
- * DB helper file.
- *
- * Provides a helper to perform database operations.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IV
- */
-
-require_once(__DIR__ . "/Helper.php");
-
-/**
- * Database helper.
- *
- * Contains database utilities to connect.
- *
- * @category Helper.
- */
-final class DB extends Helper{
-
-    private static function generate_dsn($db_configuration){
-        
-        $type = $db_configuration["type"];
-        $host = $db_configuration["host"];
-        $port = $db_configuration["port"];
-        $name = $db_configuration["name"];
-        Log::debug("Database type: $type");
-        Log::debug("Database host: $host");
-        Log::debug("Database port: $port");
-        Log::debug("Database name: $name");
-        $dsn = "";
-        switch ($type){
-            case "mysql":
-                $dsn = "mysql:";
-                if (filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) == false){
-                    Log::fatal(
-                      "MySQL driver specified, but hostname is invalid: $host",
-                      EXCEPTION_CODE::PDO_MYSQL_HOSTNAME
-                      );
-                    throw new UnexpectedValueException(
-                      "MySQL driver specified, but hostname is invalid: $host",
-                      EXCEPTION_CODE::PDO_MYSQL_HOSTNAME
-                    );
-                }
-                else{
-                    $dsn .= "host=$host;";
-                }
-                if (
-                  strlen($name) > 64 ||
-                  strpos($name, "\\") !== false ||
-                  strpos($name, "/") !== false ||
-                  strpos($name, ".") !== false
-                ){
-                    Log::fatal(
-                      "MySQL driver specified, but database name is invalid: $name",
-                      EXCEPTION_CODE::PDO_MYSQL_DBNAME
-                    );
-                    throw new UnexpectedValueException(
-                      "MySQL driver specified, but database name is invalid: $name",
-                      EXCEPTION_CODE::PDO_MYSQL_DBNAME
-                    );
-                }
-                else{
-                    $dsn .= "dbname=$name;";
-                }
-                if (intval($port) != 0){
-                    $port = intval($port);
-                    if ($port < 1 || $port > 65534){
-                        Log::fatal(
-                          "MySQL driver specified, but port number name is invalid: $port",
-                          EXCEPTION_CODE::PDO_MYSQL_PORT
-                        );
-                        throw new UnexpectedValueException(
-                          "MySQL driver specified, but port number name is invalid: $port",
-                          EXCEPTION_CODE::PDO_MYSQL_PORT
-                        );
-                    }
-                    else{
-                        $dsn .= "port=$port;";
-                    }
-                }
-                
-                if ($host != null && strlen($host) > 0){
-                    $dsn .= "host=$host;";
-                }
-                break;
-            default:
-                Log::fatal(
-                  "Unsupported batabase driver '$type'.",
-                  EXCEPTION_CODE::PDO_UNSUPPORTED
-                );
-                throw new UnexpectedValueException(
-                  "Unsupported batabase driver '$type'.",
-                  EXCEPTION_CODE::PDO_UNSUPPORTED
-                );
-        }
-        $dsn .= "charset=UTF8;";
-        Log::debug("Database dsn: $dsn");
-        return $dsn;
-    }
-    
-    /**
-     * Creates a database connection using the data in the config files.
-     * 
-     * @return resource Connection to the database.
-     */
-    public static function start($db_configuration){
-        //ini_set('mssql.charset', 'UTF8');
-        $dsn = DB::generate_dsn($db_configuration);
-        $user = $db_configuration["user"];
-        $pass = $db_configuration["pass"];
-        
-        try{
-            $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT => true));
-            Log::info("Successfully connected with database");
-            //$db->exec('SET NAMES utf8');
-            //$db->exec('SET CHARACTER SET utf8');
-            return $db;
-        }
-        catch(Exception $e){
-            Log::fatal("Connection failed" . $e->getMessage());
-        }
-    }
-}

+ 0 - 97
application/helper/HTML_Helper.php

@@ -1,97 +0,0 @@
-<?php
-/**
- * HTML helper file.
- *
- * Provides utilities to generate HTML content.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IV
- */
-
-require_once(__DIR__ . "/Helper.php");
-
-
-/**
- * HTML helper.
- *
- * Contains utilities to generate HTML content.
- *
- * @category Helper.
- */
-final class HTML extends Helper{
-
-    /**
-     * This function closes all the opened HTML tags in a given string.
-     * 
-     * @param string html The string with HTML tags.
-     * @return string HTML with closed tags.
-     */
-    public static function close_tags($html) {
-        $result = [];
-        preg_match_all("#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU", $html, $result);
-        $openedtags = $result[1];
-        preg_match_all("#</([a-z]+)>#iU", $html, $result);
-        $closedtags = $result[1];
-        $len_opened = count($openedtags);
-        if (count($closedtags) == $len_opened) {
-            return $html;
-        }
-        $openedtags = array_reverse($openedtags);
-        for ($i=0; $i < $len_opened; $i++) {
-            if (!in_array($openedtags[$i], $closedtags)) {
-                $html .= "</".$openedtags[$i].">";
-            } else {
-                unset($closedtags[array_search($openedtags[$i], $closedtags)]);
-            }
-        }
-        return $html;
-    }
-
-
-    /**
-     * Text shortener. Given a string, it trims in the proximity of the
-     * desired string, up to the next white character. If indicated, it will
-     * append a link to the full text.
-     * 
-     * @param string $text The text to shorten.
-     * @param int $length The desired length.
-     * @param string $link_text Text for the link. Optional.
-     * @param string $link URI of the link.
-     * @return string Shortened text.
-     */
-     function cut_text($text, $length, $link_text = "", $link = ""){
-        if (strlen($text) < $length){
-            return $text;
-        }
-        $cut = substr($text, 0, strpos($text, " ", $length));
-        $cut = close_tags($cut);
-        if (strlen($cut) == 0){
-            $cut = $text;
-        }
-        if (strlen($text) != strlen($cut) && strlen($link) > 0 && strlen($link_text) > 0){
-            $cut = $cut . "... <a href='$link'>$link_text</a>";
-        }
-        return $cut;
-    }
-
-    /**
-     * Creates the srcset attribute for content images.
-     * Creates 9 different resolutions, from 100px to 900px.
-     * 
-     * @param string $file Path to the file, relative to $path["img"]["content"]).
-     * @return string srcset atttribute content.
-     */
-    public static function srcset($file){
-        global $static;
-        $srcset = "";
-        $dir = dirname($file);
-        $name = basename($file);
-        foreach (range(1, 9) as $d) {
-            $srcset = $srcset . URL::IMG["CONTENT"] . $dir . "/x" . $d . "00/" . $name . " " . $d . "00px, ";
-        }
-        $srcset = rtrim($srcset, ", ");
-        return $srcset;
-    }
-
-}

+ 0 - 20
application/helper/Helper.php

@@ -1,20 +0,0 @@
-<?php
-/**
- * Base helper file.
- *
- * Provides an empty helper.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- */
-
-/**
- * Helper superclass.
- *
- * Every other entity must inherit from this one. 
- * 
- * @abstract
- * @category Helper
- */
-abstract class Helper{}

+ 0 - 59
application/helper/NET_Helper.php

@@ -1,59 +0,0 @@
-<?php
-/**
- * Netowrk helper file.
- *
- * Provides a helper to perform network operations.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IV
- */
-
-require_once(__DIR__ . "/Helper.php");
-
-/**
- * Netowrk helper.
- *
- * Contains netowrk related utilities.
- *
- * @category Helper.
- */
-final class NET extends Helper{
-    
-    /**
-     * Finds out the protocol the user is connecting to the site with.
-     *
-     * @return string "http://" or "https://".
-     */
-    public static function get_protocol(){
-        if (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == 1) || isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https") {
-            $protocol = "https://";
-        }
-        else {
-            $protocol = "http://";
-        }
-        return $protocol;
-    }
-    
-    /**
-     * Finds out the IP address of the client.
-     *
-     * @return string Client IP address.
-     */
-    public static function get_ip(){
-        $client  = @$_SERVER["HTTP_CLIENT_IP"];
-        $forward = @$_SERVER["HTTP_X_FORWARDED_FOR"];
-        $remote  = $_SERVER["REMOTE_ADDR"];
-        if(filter_var($client, FILTER_VALIDATE_IP)){
-            $ip = $client;
-        }
-        elseif(filter_var($forward, FILTER_VALIDATE_IP)){
-            $ip = $forward;
-        }
-        else{
-            $ip = $remote;
-        }
-        return $ip;
-    }
-    
-}

+ 0 - 276
application/helper/TEXT_Helper.php

@@ -1,276 +0,0 @@
-<?php
-/**
- * DB helper file.
- *
- * Provides a helper to perform database operations.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package IV
- */
-
-require_once(__DIR__ . "/Helper.php");
-
-
-/**
- * Text helper.
- *
- * Contains utilities to show and manipulate texts.
- *
- * @category Helper.
- */
-final class TEXT extends Helper{
-
-    /**
-     * Selects the language the page will be displayed on.
-     * 
-     * First, it tries to read the language cookie in the client. If none is
-     * set, get the browser language preference list. If none is provided or
-     * they are not supported, it will use the default language.
-     * 
-     * @return string Lowercase, two-letter language code.
-     */
-    function select_language(){
-
-        // Get available languages from db
-        $available_languages = array();
-        $q_lang = mysqli_query($db, "SELECT code FROM lang WHERE active = 1;");
-        while ($r_lang = mysqli_fetch_array($q_lang)){
-            array_push($available_languages, $r_lang["code"]);
-        }
-
-        // Is there a language cookie installed on the client?.
-        header("Cache-control: private");
-        if (isSet($_COOKIE["lang"])){
-            $lang = $_COOKIE["lang"];
-            if (in_array($lang, $available_languages)){
-                return $lang;
-            }
-        }
-
-        // If no cookie, select from client browser preferences.
-        $lang = prefered_language($available_languages, $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
-        if (in_array($lang, $available_languages)){
-            return $lang;
-        }
-
-        // If no method was succesfull, default language
-        $lang = $available_languages[0];
-        return $lang;
-    }
-
-
-    /**
-     * Parses the language prefrences of the client broser, comparing them to
-     * the languages offered by the site and selects the prefered one among
-     * the ones supported.
-     * 
-     * @param string[] available_languages List of lowercase, two-letter
-     *                                      language codes allowed by the site.
-     * @param string http_accept_language Raw header with info about client
-     *                                    language preferences.
-     * @return string Lowercase, two-letter code of the prefered available
-     *                language.
-     */
-    function prefered_language(array $available_languages, $http_accept_language) {
-
-        $available_languages = array_flip($available_languages);
-
-        $langs;
-        preg_match_all("~([\w-]+)(?:[^,\d]+([\d.]+))?~", strtolower($http_accept_language), $matches, PREG_SET_ORDER);
-        foreach($matches as $match) {
-
-            list($a, $b) = explode("-", $match[1]) + array("", "");
-            $value = isset($match[2]) ? (float) $match[2] : 1.0;
-
-            if(isset($available_languages[$match[1]])) {
-                $langs[$match[1]] = $value;
-                continue;
-            }
-
-            if(isset($available_languages[$a])) {
-                $langs[$a] = $value - 0.1;
-            }
-
-        }
-        if (count($langs) > 0){
-            arsort($langs);
-            //return $langs[0];
-            array_values($langs)[0];
-        }
-        else{
-            return 'en';
-        }
-    }
-
-
-    /**
-     * Tturns a date string into a human readable string on the specified
-     * language. Only works for spanish, basque and english.
-     * 
-     * @param string $str_date Date string ('yyyy-mm-dd' or 'yyyy-mm-dd HH:MM:SS')
-     * @param string $lang Language code (es, en, eu).
-     * @param string $time Append the time at the end.
-     * @return string Formatted date string.
-     */
-    function format_date($str_date, $lang, $time = true){
-        $date = strtotime($str_date);
-        $year = date("o", $date);
-        $month = date("n", $date);
-        $month --;
-        $day = date("j", $date);
-        $wday = date("N", $date);
-        $wday --;
-        $hour = date("H", $date);
-        $minute = date("i", $date);
-        switch ($lang){
-            case "en":
-                $week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
-                $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
-                if ($time){
-                    $str = "$week[$wday], $months[$month] $day, $year at $hour:$minute";
-                }
-                else{
-                    $str = "$week[$wday], $months[$month] $day, $year";
-                }
-                break;
-            case "eu":
-                $week = ["astelehena", "asteartea", "asteazkena", "osteguna", "ostirala", "larumbata", "igandea"];
-                $months = ["urtarrilaren", "otsailaren", "martxoaren", "apirilaren", "maiatzaren", "ekainaren", "uztailaren", "abuztuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"];
-                if ($time){
-                    $str = $year . "ko $months[$month] $day" . "an, $week[$wday], $hour:$minute";
-                }
-                else{
-                    $str = $year . "ko $months[$month] $day" . "an, $week[$wday]";
-                }
-                break;
-            default:
-                $week = ["Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "S&aacute;bado", "Domingo"];
-                $months = ["enero", " febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"];
-                if ($time){
-                    $str = "$week[$wday] $day de $months[$month] de $year a las $hour:$minute";
-                }
-                else{
-                    $str = "$week[$wday] $day de $months[$month] de $year";
-                }
-        }
-        return $str;
-    }
-
-
-    /**
-     * Retrieves a text fragment from the database.
-     * 
-     * @param string $id Text identifier.
-     * @param bool $html True to decode for HTML.
-     * @returns string The text.
-     */
-    public static function get($id, $html = true){
-        $statement = get_context()->get_db()->prepare("
-          SELECT
-            text,
-            file
-          FROM text
-          WHERE
-            id = :id AND
-            lang = :lang
-        ");
-        $statement->bindValue(':id', $id, PDO::PARAM_STR);
-        $statement->bindValue(':lang', get_context()->get_lang(), PDO::PARAM_STR);
-        $statement->execute();
-        $row = $statement->fetch(PDO::FETCH_ASSOC);
-        if ($row !== false){
-            $text = "";
-            if (strlen($row["file"]) > 0){
-                $text = file_get_contents(PATH::TEXT . $row["file"]);
-            }
-            else{
-                $text = $row["text"];
-            }
-            $text = utf8_decode($text);
-            if ($html === true){
-                $text = htmlentities($text, ENT_QUOTES);
-            }
-            return $text;
-        }
-        else{
-            Log::error("Text resource with id '$id' not found.");
-            return false;
-        }
-    }
-
-
-    /**
-     * This function closes all the opened HTML tags in a given string.
-     * 
-     * @param string html The string with HTML tags.
-     * @return string HTML with closed tags.
-     */
-    function close_tags($html) {
-        $result = [];
-        preg_match_all("#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?<![/|/ ])>#iU", $html, $result);
-        $openedtags = $result[1];
-        preg_match_all("#</([a-z]+)>#iU", $html, $result);
-        $closedtags = $result[1];
-        $len_opened = count($openedtags);
-        if (count($closedtags) == $len_opened) {
-            return $html;
-        }
-        $openedtags = array_reverse($openedtags);
-        for ($i=0; $i < $len_opened; $i++) {
-            if (!in_array($openedtags[$i], $closedtags)) {
-                $html .= "</".$openedtags[$i].">";
-            } else {
-                unset($closedtags[array_search($openedtags[$i], $closedtags)]);
-            }
-        }
-        return $html;
-    }
-
-
-    /**
-     * Text shortener. Given a string, it trims in the proximity of the
-     * desired string, up to the next white character. If indicated, it will
-     * append a link to the full text.
-     * 
-     * @param string $text The text to shorten.
-     * @param int $length The desired length.
-     * @param string $link_text Text for the link. Optional.
-     * @param string $link URI of the link.
-     * @return string Shortened text.
-     */
-     function cut_text($text, $length, $link_text = "", $link = ""){
-        if (strlen($text) < $length){
-            return $text;
-        }
-        $cut = substr($text, 0, strpos($text, " ", $length));
-        $cut = close_tags($cut);
-        if (strlen($cut) == 0){
-            $cut = $text;
-        }
-        if (strlen($text) != strlen($cut) && strlen($link) > 0 && strlen($link_text) > 0){
-            $cut = $cut . "... <a href='$link'>$link_text</a>";
-        }
-        return $cut;
-    }
-
-    /**
-     * Creates the srcset attribute for content images.
-     * Creates 9 different resolutions, from 100px to 900px.
-     * 
-     * @param string $file Path to the file, relative to $path["img"]["content"]).
-     * @return string srcset atttribute content.
-     */
-    public static function srcset($file){
-        global $static;
-        $srcset = "";
-        $dir = dirname($file);
-        $name = basename($file);
-        foreach (range(1, 9) as $d) {
-            $srcset = $srcset . $static["content"] . $dir . "/x" . $d . "00/" . $name . " " . $d . "00px, ";
-        }
-        $srcset = rtrim($srcset, ", ");
-        return $srcset;
-    }
-
-}

+ 0 - 44
application/helper/db.php

@@ -1,44 +0,0 @@
-<?php
-
-    /**
-     * Creates a database connection using the data in the config files.
-     * 
-     * @return MySQL_connection Connection to the database.
-     */
-    function start_db($db_configuration){
-        $type = $db_configuration["type"];
-        $host = $db_configuration["host"];
-        $port = $db_configuration["port"];
-        $name = $db_configuration["name"];
-        $user = $db_configuration["user"];
-        $pass = $db_configuration["pass"];
-        
-        $dbHost="localhost";
-        $dbName="myDB";
-        $dbUser="root";      //by default root is user name.
-        $dbPassword="";     //password is blank by default
-        try{
-            $dbConn= new PDO("mysql:host=$dbHost;dbname=$dbName",$dbUser,$dbPassword);
-            Echo "Successfully connected with myDB database";
-        } catch(Exception $e){
-            Echo "Connection failed" . $e->getMessage();
-        }  
-        
-        
-        // TODO: Types and port
-        $db = mysqli_connect($auth["host"], $auth["user"], $auth["pass"], $auth["name"]);
-
-        // Check connection
-        if (mysqli_connect_errno()){
-            error_log("Failed to connect to database: " . mysqli_connect_error());
-            return -1;
-        }
-
-        //Set encoding options
-        mysqli_set_charset($db, "utf-8");
-        mysqli_query($db, "SET NAMES utf8;");
-
-        return $db;
-    }
-
-?>

Some files were not shown because too many files changed in this diff