PHP Classes

D3 System: Framework to edit model data using CRUD interfaces

Recommend this page to a friend!
  Info   View files Documentation   View files View files (49)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 32 This week: 1All time: 10,987 This week: 560Up
Version License PHP version Categories
d3system 1.0Freeware5HTML, PHP 5, Databases, Libraries, De...
Description 

Author

This package provides a framework to edit model data using CRUD interfaces.

It provides a structure of classes to implement model classes that store and retrieve data that will be edited by the users on a Web page.

Applications may configure several aspects like:

- The list of model classes that will be available to edit the record data

- Which model fields can be edited using Web forms

- How the data the user entered in forms will be mapped before storing in the database

- Code that will be used to implement custom processing of user data

Picture of Uldis Nelsons
Name: Uldis Nelsons <contact>
Classes: 18 packages by
Country: Latvia Latvia
Age: 54
All time rank: 19736 in Latvia Latvia
Week rank: 34 Up1 in Latvia Latvia Up
Innovation award
Innovation award
Nominee: 12x

Winner: 2x

Documentation

d3system

Installation

composer require d3yii2/d3system dev-master

Configuration

add translation

$config = [
   'components' => [
        'i18n' => [
            'translations' => [ 
                'd3system*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@d3yii2/d3system/messages',
                    'sourceLanguage' => 'en-US',
                ],
                'crud' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@d3yii2/d3system/messages',
                    'sourceLanguage' => 'en-US',
                ],
            ]
        ]
    ]
];

Components

ModelsList

Configuration:

 'components' => [
        'ModelsList' => [
            'class' => 'd3system\compnents\ModelsList',
            'cacheKey' => 'd3system\modeList',
            'cacheDuration' => 3600
        ]    
        

Usage:

  $modelId = \Yii::$app->ModelsList->getId($model);

Date & Time conversions

Dependency https://github.com/d3yii2/yii2-datetime

Conversion works only for the model attributes suffixed vith "_local" A example, instead

$model->YOUR_ATTRIBUTE

use

$model->YOUR_ATTRIBUTE_local

Add behavior config in model

Add the behavior to your model and list the attributes need to be converted Important: do NOT add the "_local" suffix here!

public function behaviors(): array
{
    return D3DateTimeBehavior::getConfig(['YOUR_ATTRIBUTE']);
}

Or if You need custom options (see the https://github.com/d3yii2/yii2-datetime)

public function behaviors()
{
    return [
        'datetime' => [
            'class' => D3DateTimeBehavior::className(), // Our behavior
            'attributes' => [
                'YOUR_ATTRIBUTE', // List all editable date/time attributes
            ],
            // Date formats or other options
           'originalFormat' => ['datetime', 'yyyy-MM-dd HH:mm:ss'],
           'targetFormat' => 'date',
        ]
    ];
}

Display value in view

<?= $model->YOUR_ATTRIBUTE_local ?>

Assign the value before save

$model->load(Yii::$app->request->post());

or

 $model->YOUR_ATTRIBUTE_local = $value;

or

 $model->setAttribute('YOUR_ATTRIBUTE_local', $value);

By multiple assignment via load() ensure the local attributes have 'safe' rules:

// Virtual params for DateTimeBehavior
public function rules(): array
{   
    return [
        [...],
        [['YOUR_ATTRIBUTE_local'], 'safe'],
    ];
}

D3EditableAction Initial Setup in Controller

editAbleFields: must match real attributes
editAbleFieldsForbbiden: must match real attributes
modelName: pass current controller model Name with full Namespace
/
 * @var array
 */
public $editAbleFields = ['hasEditable', 'status'];

/
 * @var array
 */
public $editAbleFieldsForbbiden = [];

Actions

public function actions()
{
    return [
        'editable'      => [
            'class'                   => D3EditableAction::class,
             'modelName'               => AudAuditor::class,
             'editAbleFields'          => ['status','notes'],
             'editAbleFieldsForbbiden' => $this->editAbleFieldsForbbiden,
             'preProcess' => static function (Inout $model) {
                  if ($model->isAttributeChanged('driver')) {
                     $model->driver = iconv('UTF-8', 'ASCII//TRANSLIT',$model->driver);
                  }   
             },
             'outPreProcess' => static function (ContInout $model, array $output) {
                 if (isset($output['ediBookingId'])) {
                     $output['ediBookingId'] = DepoEdiBookingDictionary::getIdLabel($output['ediBookingId']);
                 }
                 return $output;
             }             
        ],
    ];
}


  Files folder image Files  
File Role Description
Files folder imageactions (4 files)
Files folder imagebehaviors (1 file)
Files folder imagecommands (1 file)
Files folder imagecompnents (4 files, 1 directory)
Files folder imagedictionaries (1 file)
Files folder imageexceptions (3 files)
Files folder imagegii (1 file)
Files folder imagehelpers (1 file)
Files folder imagemessages (2 directories)
Files folder imagemigrations (4 files)
Files folder imagemodels (5 files, 1 directory)
Files folder imageviews (1 directory)
Files folder imagewidgets (3 files)
Files folder imageyii2 (5 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file Module.php Class Class source
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  actions  
File Role Description
  Plain text file D3EditableAction.php Class Class source
  Plain text file D3EditableColumnAction.php Class Class source
  Plain text file D3SettingAction.php Class Class source
  Plain text file Yii2ModEditableAction.php Class Class source

  Files folder image Files  /  behaviors  
File Role Description
  Plain text file D3DateTimeBehavior.php Class Class source

  Files folder image Files  /  commands  
File Role Description
  Plain text file D3CommandController.php Class Class source

  Files folder image Files  /  compnents  
File Role Description
Files folder imageoptional (2 files)
  Plain text file D3Ref.php Class Class source
  Plain text file Expression.php Class Class source
  Plain text file ModelsList.php Class Class source
  Plain text file TryCatch.php Class Class source

  Files folder image Files  /  compnents  /  optional  
File Role Description
  Plain text file Optional.php Class Class source
  Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  dictionaries  
File Role Description
  Plain text file SysModelsDictionary.php Class Class source

  Files folder image Files  /  exceptions  
File Role Description
  Plain text file D3ActiveRecordException.php Class Class source
  Plain text file D3Exception.php Class Class source
  Plain text file D3UserAlertException.php Class Class source

  Files folder image Files  /  gii  
File Role Description
  Accessible without login Plain text file sys_cron_final_pointGiiantModel.json Data Auxiliary data

  Files folder image Files  /  helpers  
File Role Description
  Plain text file D3FileHelper.php Class Class source

  Files folder image Files  /  messages  
File Role Description
Files folder imagelv-LV (2 files)
Files folder imageru (2 files)

  Files folder image Files  /  messages  /  lv-LV  
File Role Description
  Accessible without login Plain text file crud.php Aux. Auxiliary script
  Accessible without login Plain text file d3system.php Aux. Auxiliary script

  Files folder image Files  /  messages  /  ru  
File Role Description
  Accessible without login Plain text file crud.php Aux. Auxiliary script
  Accessible without login Plain text file d3system.php Aux. Auxiliary script

  Files folder image Files  /  migrations  
File Role Description
  Plain text file m180821_114733_init.php Class Class source
  Plain text file m190225_144643_alt..._add_unique_key.php Class Class source
  Plain text file m190516_092701_cre...ron_final_point.php Class Class source
  Plain text file m200513_160317_alt...final_point_key.php Class Class source

  Files folder image Files  /  models  
File Role Description
Files folder imagebase (1 file)
  Plain text file D3ActiveRecord.php Class Class source
  Plain text file D3Attribute.php Class Class source
  Plain text file ModelObjectAdditionalAttributes.php Class Class source
  Plain text file SysCronFinalPoint.php Class Class source
  Plain text file SysModels.php Class Class source

  Files folder image Files  /  models  /  base  
File Role Description
  Plain text file SysCronFinalPoint.php Class Class source

  Files folder image Files  /  views  
File Role Description
Files folder imagemigration (1 file)

  Files folder image Files  /  views  /  migration  
File Role Description
  Accessible without login Plain text file migration.php Aux. Auxiliary script

  Files folder image Files  /  widgets  
File Role Description
  Plain text file D3Widget.php Class Class source
  Plain text file ThBadge.php Class Class source
  Plain text file ThBadgeList.php Class Class source

  Files folder image Files  /  yii2  
File Role Description
Files folder imagebase (1 file)
Files folder imagedata (3 files)
Files folder imagedb (3 files)
Files folder imagelog (1 file)
Files folder imageweb (2 files)

  Files folder image Files  /  yii2  /  base  
File Role Description
  Plain text file D3Module.php Class Class source

  Files folder image Files  /  yii2  /  data  
File Role Description
  Plain text file D3ActiveDataProvider.php Class Class source
  Plain text file D3Pagination.php Class Class source
  Plain text file D3Sort.php Class Class source

  Files folder image Files  /  yii2  /  db  
File Role Description
  Plain text file D3ActiveQuery.php Class Class source
  Plain text file D3Command.php Class Class source
  Plain text file D3Db.php Class Class source

  Files folder image Files  /  yii2  /  log  
File Role Description
  Plain text file D3FileTarget.php Class Class source

  Files folder image Files  /  yii2  /  web  
File Role Description
  Plain text file D3SystemMobView.php Class Class source
  Plain text file D3SystemView.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:32
This week:1
All time:10,987
This week:560Up