Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • CoreConfigRequirement
  • DatabaseForm
  • DatabaseOperation
  • DocumentDecorator
  • InstallForm
  • InstallOperation
  • InstallRequirements
  • LanguageElement
  • Operation
  • PanelDecorator
  • PanelForm
  • PDODriversRequirement
  • RepositoryRequirement
  • Requirement
  • Requirements
  • RequirementsOperation
  • SiteForm
  • SiteOperation
  • StepsController
  • TellMeMore
  • UserConfigRequirement
  • UserForm
  • UserOperation
  • WelcomePanel
  • WelcomeRequirements

Functions

  • t
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee/Installer package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Installer;
 13 
 14 use ICanBoogie\ActiveRecord\Connection;
 15 use ICanBoogie\ActiveRecord\ConnectionNotEstablished;
 16 use ICanBoogie\I18n;
 17 
 18 class DatabaseOperation extends Operation
 19 {
 20     protected function get_controls()
 21     {
 22         return array
 23         (
 24             self::CONTROL_FORM => true
 25         )
 26 
 27         + parent::get_controls();
 28     }
 29 
 30     protected function get_form()
 31     {
 32         return new DatabaseForm;
 33     }
 34 
 35     protected function validate(\ICanBoogie\Errors $errors)
 36     {
 37         $request = $this->request;
 38 
 39         $name = $request['name'];
 40         $username = $request['username'];
 41         $password = $request['password'];
 42         $host = $request['host'];
 43         $prefix = $request['prefix'];
 44 
 45         try
 46         {
 47             $connection = new Connection
 48             (
 49                 "mysql:dbname=$name;host=$host", $username, $password, array
 50                 (
 51                     Connection::TABLE_NAME_PREFIX => $prefix
 52                 )
 53             );
 54         }
 55         catch (\PDOException $e)
 56         {
 57             $code = $e->getCode();
 58 
 59             if ($code == 1049)
 60             {
 61                 $errors['name'] = I18n\t('panel.database.error.name');
 62             }
 63             else if ($code == 1045)
 64             {
 65                 $errors['username'] = I18n\t('panel.database.error.username_password');
 66                 $errors['password'] = true;
 67             }
 68             else if ($code == 2005)
 69             {
 70                 $errors['host'] = I18n\t('panel.database.error.host');
 71             }
 72             else
 73             {
 74                 throw $e;
 75             }
 76         }
 77 
 78         return $errors;
 79     }
 80 
 81     protected function process()
 82     {
 83         global $core;
 84 
 85         $request = $this->request;
 86 
 87         $core->session->install['database'] = array
 88         (
 89             'name' => $request['name'],
 90             'username' => $request['username'],
 91             'password' => $request['password'],
 92             'host' => $request['host'],
 93             'prefix' => $request['prefix']
 94         );
 95 
 96         $this->response->message = I18n\t('panel.database.success');
 97 
 98         return parent::process();
 99     }
100 }
Autodoc API documentation generated by ApiGen 2.8.0