class ViewsAdminController extends BaseAdminController

The ViewsAdminController class is the controller that handles all actions of the views management interface.

These actions are:

  • Creation of a view
  • Adding a node (file or folder) in the view tree
  • Editing text file content
  • Renaming a node
  • Deleting a node
  • Export of a view
  • Deletion of a view

Properties

ControllersHelper $helper from BaseAdminController
string $databasesDir from BaseAdminController
string $simulatorsDir from BaseAdminController
string $publicDir from BaseAdminController
string $viewsDir from BaseAdminController
private string $root
private int $nodeNum
private array|null $nodeFile
private int $node
private int $script

Methods

Response
errorResponse(array $form, string $error)

Returns a JSON response formed with the data of a form and an error message.

zip(array $contents)

Zip file creation function.

int
unix2DosTime(int $unixtime)

Converts unix time to MS DOS time

Response|RedirectResponse
indexAction(Request $request, string|null $view = null, int $node, string|null $crud = null)

Entry point for the route paths begining by /admin/views

Response|RedirectResponse
runIndex(Request $request, string|null $view, string|null $crud)

Dispatches the index action to the appropriate processing based on the value of the crud parameter.

Response
showViews(Request $request, string|null $view, string|null $crud)

Shows the views management interface.

RedirectResponse
doCreateView(array $form, array $files)

Creates a views and installs its templates and assets

RedirectResponse
dropView(string $view)

Drops a view and all its files

RedirectResponse
doEditNode(array $form, string $view)

Edits a text file content

RedirectResponse
renameNode(array $form, string $view)

Renames a node

RedirectResponse
removeViewNode(string $view)

Deletes a node from the view tree

RedirectResponse
addViewNode(array $form, array $files, string $view)

Adds a node into the view tree

Response
exportViewNode(string $view)

Exports a view node

string
searchNodePath(string $view)

Search the directory path of the current node of the view

string
findNodePath(string $dir)

Recursively traverses a directory to find the directory path of the current node

array
makeTree(string $dir, string $type, int $parent)

Recursively constructs a tree into an array from the directories of the view tree.

string
getMode(string $file)

Returns the language mode of a file for the javascript component CodeMirror.

Details

in BaseAdminController at line 93
protected Response errorResponse(array $form, string $error)

Returns a JSON response formed with the data of a form and an error message.

Parameters

array $form The form fields
string $error The error message

Return Value

Response

in BaseAdminController at line 113
protected zip(array $contents)

Zip file creation function.

Makes zip files. Derivated from PhpMyAdmin package The $contents parameter is an array of associative array where keys are : - name: name of the zip - modtime: modification time - data: data to compress

Parameters

array $contents The array of contents to be compressed

See also

Official ZIP file format: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

in BaseAdminController at line 188
protected int unix2DosTime(int $unixtime)

Converts unix time to MS DOS time

Parameters

int $unixtime (default: 0) The unix time

Return Value

int The MS DOS time

at line 120
Response|RedirectResponse indexAction(Request $request, string|null $view = null, int $node, string|null $crud = null)

Entry point for the route paths begining by /admin/views

These route paths are :

  • /admin/views
  • /admin/views/{view}
  • /admin/views/{view}/{node}
  • /admin/views/{view}/{node}/{crud}

Parameters

Request $request The request
string|null $view (default: null) The view name
int $node (default: 0) The node number
string|null $crud (default: null) operation to execute on the view (docreate-view, drop-view, edit-node, doedit-node, rename-node, add-node, remove-node, export)

Return Value

Response|RedirectResponse The response object

at line 141
protected Response|RedirectResponse runIndex(Request $request, string|null $view, string|null $crud)

Dispatches the index action to the appropriate processing based on the value of the crud parameter.

If the crud parameter contains no value, shows the views management interface.

Parameters

Request $request The request
string|null $view The view name
string|null $crud operation to execute on the view (docreate-view, drop-view, edit-node, doedit-node, rename-node, add-node, remove-node, export)

Return Value

Response|RedirectResponse The response object

at line 172
protected Response showViews(Request $request, string|null $view, string|null $crud)

Shows the views management interface.

Parameters

Request $request The request
string|null $view The view name
string|null $crud Contains 'edit-node' or null

Return Value

Response The response object

at line 254
protected RedirectResponse doCreateView(array $form, array $files)

Creates a views and installs its templates and assets

Route path : /admin/views/new/0/docreate-view

The templates are copied into the views directory and the assets into the public directory

Parameters

array $form The form fields
array $files Compressed files of assets and templates

Return Value

RedirectResponse The response object

at line 319
protected RedirectResponse dropView(string $view)

Drops a view and all its files

Route path : /admin/views/{view}/0/drop-view

Parameters

string $view The view name

Return Value

RedirectResponse The response object

at line 340
protected RedirectResponse doEditNode(array $form, string $view)

Edits a text file content

Route path : /admin/views/{view}/{node}/doedit-node

Parameters

array $form The form fields
string $view The view name

Return Value

RedirectResponse The response object

at line 360
protected RedirectResponse renameNode(array $form, string $view)

Renames a node

Route path : /admin/views/{view}/{node}/rename-node

Parameters

array $form The form fields
string $view The view name

Return Value

RedirectResponse The response object

at line 389
protected RedirectResponse removeViewNode(string $view)

Deletes a node from the view tree

Route path : /admin/views/{view}/{node}/remove-node

Parameters

string $view The view name

Return Value

RedirectResponse The response object

at line 416
protected RedirectResponse addViewNode(array $form, array $files, string $view)

Adds a node into the view tree

Route path : /admin/views/{view}/{node}/add-node

If the node is a folder, a directory is created. If the node is a file, the uploaded file is copied into the view tree.

Parameters

array $form The form fields
array $files The uploaded file of the node
string $view The view name

Return Value

RedirectResponse The response object

at line 462
protected Response exportViewNode(string $view)

Exports a view node

Route path : /admin/views/{view}/{node}/export

Creates a compressed file containing all the files of the node for downloading by the user.

Parameters

string $view The view name

Return Value

Response The response object

at line 496
private string searchNodePath(string $view)

Search the directory path of the current node of the view

Parameters

string $view The view name

Return Value

string the directory path of the current node

at line 522
private string findNodePath(string $dir)

Recursively traverses a directory to find the directory path of the current node

Parameters

string $dir The directory

Return Value

string the directory path of the current node

at line 553
private array makeTree(string $dir, string $type, int $parent)

Recursively constructs a tree into an array from the directories of the view tree.

Parameters

string $dir Current directory
string $type 'template' or 'asset'
int $parent (default: 0) Parent node

Return Value

array The node tree

at line 602
private string getMode(string $file)

Returns the language mode of a file for the javascript component CodeMirror.

Parameters

string $file The file name

Return Value

string The language mode