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

  • ContactForm
  • DefaultsOperation
  • EditBlock
  • EmailComposer
  • Form
  • FormEditor
  • FormEditorElement
  • Hooks
  • ManageBlock
  • Model
  • Module
  • NotifyParams
  • PopForm
  • PostOperation
  • PressContactForm
  • QuickContactForm

Interfaces

  • AlterNotify
 1 <?php
 2 
 3 /*
 4  * This file is part of the Icybee 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\Modules\Forms;
13 
14 use ICanBoogie\Errors;
15 use ICanBoogie\Operation;
16 
17 /**
18  * Returns model specific default values for the form.
19  */
20 class DefaultsOperation extends Operation
21 {
22     /**
23      * Controls for the operation: authentication, permission(create)
24      */
25     protected function get_controls()
26     {
27         return array
28         (
29             self::CONTROL_AUTHENTICATION => true,
30             self::CONTROL_PERMISSION => Module::PERMISSION_CREATE
31         )
32 
33         + parent::get_controls();
34     }
35 
36     /**
37      * Validates the operation unles the operation key is not defined.
38      */
39     protected function validate(Errors $errors)
40     {
41         if (!$this->key)
42         {
43             $errors['key'] = 'Missing modelid';
44 
45             return false;
46         }
47 
48         return true;
49     }
50 
51     /**
52      * The "defaults" operation can be used to retrieve the default values for the form, usualy
53      * the values for the notify feature.
54      */
55     protected function process()
56     {
57         global $core;
58 
59         $modelid = $this->key;
60         $models = $core->configs->synthesize('formmodels', 'merge');
61 
62         if (empty($models[$modelid]))
63         {
64             \ICanBoogie\log_error("Unknown model.");
65 
66             return;
67         }
68 
69         $model = $models[$modelid];
70         $model_class = $model['class'];
71 
72         if (!method_exists($model_class, 'get_defaults'))
73         {
74             \ICanBoogie\log_success("The model doesn't have defaults.");
75 
76             return false;
77         }
78 
79         return call_user_func(array($model_class, 'get_defaults'));
80     }
81 }
Autodoc API documentation generated by ApiGen 2.8.0