Panel API: PHP #217
taufik-nurrohman
started this conversation in
General
Replies: 2 comments 7 replies
-
di mecha 3.0.0 panel custom nya gimana kang, tetap seperti biasakah kang? file panel.php perlu dibuat tersendiri? |
Beta Was this translation helpful? Give feedback.
4 replies
-
// `<script async src="https://code.jquery.com/jquery-3.6.1.min.js" type="text/javascript"></script>`
$_['asset'][] = [
'2' => [
'async' => true,
'type' => 'text/javascript'
],
'link' => 'https://code.jquery.com/jquery-3.6.1.min.js'
]; untuk mecha v3 ya kang? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This article is a draft and will be moved to the official web site when the API is matured.
State
Global states are stored as array and can be accessed through
$_
variable or through$GLOBALS['_']
variable if you are in a closure. All states must be primitive and must be able to be encoded and decoded from/to JSON without changing their initial value.0
false|null|string
HTML
class.1
false|null|string
HTML
class. If this value is a string, then the entire layout of the panel will be replaced with this value.2
array|null
HTML
class.alert
array
are
array
are
context.as
array
as
context.asset
array
skip
property with atrue
value.author
string
base
string
can
array
can
context.chunk
int|null
20
. Developers need to declare the default value manually when they find anull
value in this property.content
null|string
lot
property will be ignored, and the entire contents of the panel will be replaced with this value.count
int
0
. Developers need to declare the value manually if they want to tell other extensions that this value can be trusted to use.deep
int|true
$deep
parameter in theg
function.description
array|null|string
file
null|string
$_['path']
value is a valid file location relative to the.\lot
folder, this property will return that file path, otherwise, this property will returnnull
.folder
null|string
$_['path']
value is a valid folder location relative to the.\lot
folder, this property will return that folder path, otherwise, this property will returnnull
.has
array
has
context.hash
null|string
$_COOKIE['hash']
, usually set by JavaScript, because it is not possible to capture URL hash using PHP.icon
array
<svg>
tag to be loaded just after the opening<body>
tag, for inline SVG optimization.is
array
is
context.kick
array|null|string
x\panel\to\link
function automatically.lot
array
type
. Values in this property will be ignored ifcontent
property exists with a string value, even if it is just an empty string. Each item should have astack
property to set the order of each item consistently. If this property does not exist, it will be assigned a value of10
by default. Item with a falsy value or with an array value containing askip
property with a truthy value will be ignored.not
array
not
context.of
array
of
context.part
int|null
http://127.0.0.1/panel/get/asset/documents/1
indicates that the user is currently viewing a list of files and folders in the.\lot\asset\documents
folder, while locationhttp://127.0.0.1/panel/get/asset/documents
indicates that user is currently viewing a folder editor to edit the.\lot\asset\documents
folder.path
null|string
$_['task']
and before$_['part']
.query
array|null
sort
array|null
1
or+1
for ascending and-1
for descending), the second item determines the sorting key.status
int
200
,401
,403
,404
or405
.task
string
get
,let
,set
, orfire/*
where*
is the custom task name.title
null|string
token
string
type
null|string
type
parameter in the panel URL.with
array
with
context.x
int|null|string
0
for folder and1
for file) or file extensions to be passed to the$x
parameter in theg
function.Alert
To declare an alert is quite simple:
Values in the first-level array are alert types. It has no special rules. You can add any type of alert you want, but in general, it can be expressed as
error
,info
, andsuccess
. Especially for theerror
type, it is very commonly used to prevent the next operation from being performed if there is anerror
alert data available when the request is made:Asset
Insert assets files this way:
The
stack
property specifies the loading order of the asset files in the HTML output. You can also use thelink
orurl
property instead ofpath
to load external asset files.Asset output will follow the file path extension. If the path ends with
.css
, then the data will be converted into a<link rel="stylesheet">
element. If the path ends with.js
, then the data will be converted into a<script>
element.Static reference written as a set of non-numeric characters will be converted into an
id
attribute in the HTML output. You can also set a customid
value different from the asset reference by adding anid
property. If you set the value tofalse
on this property, then theid
attribute will be completely removed:You can hide (unload) certain asset files from the HTML output without removing the asset data by adding the
skip
property with atrue
value (this property has the value set tofalse
by default).Other HTML attributes can be set via the
2
property:URL
Panel URL consists of several parts. You are considered in the panel when you are logged-in and are in the scope of
http://127.0.0.1/panel/fire/*
http://127.0.0.1/panel/get/*
,http://127.0.0.1/panel/let/*
, orhttp://127.0.0.1/panel/set/*
where*
cannot be numbers. An exact URL points tohttp://127.0.0.1/panel
orhttp://127.0.0.1/panel/*
where*
is any number greater than0
does not implement this rule and will be used to display a generic page rendered from a file stored as.\lot\page\panel.archive
or.\lot\page\panel.page
or pages that come from files stored in.\lot\page\panel
folder.Please note that the
/panel
route is not static, and can be changed to a different route by setting it via theroute
property in the.\lot\x\panel\state.php
file.Panel URL is divided into several parts as follows:
base
http://127.0.0.1/panel
. Value cannot benull
.task
base
. Value functions as an order to execute tasks. Value can beget
,let
,set
, orfire
with a user-defined command name following after.path
task
. Should point to a file or folder inside the.\lot
folder.part
path
. Value can be any number greater than0
ornull
. The value specifies the pagination offset.query
[]
(empty array) ornull
, then the URL is considered to have no query.hash
""
(empty string) ornull
, then the URL is considered to have no hash. In an application that works on the server side, this data is useless, unless you want to create a panel URL from data to be used as a redirection target.Internal function is available to form a panel URL from the array:
Not all parts of the URL have to be declared. Some undeclared values will be available automatically based on the current URL data stored in
$_
.There are some reserved panel URL queries:
chunk
$_['chunk']
variable.deep
$deep
parameter in theg
function. Specifying a value in this query will also change the current value of the$_['deep']
variable.kick
x\panel\to\link
function automatically. Specifying a value in this query will also change the current value of the$_['kick']
variable.query
$_GET
variable. If that’s the case, you will need to modify the values on both variables.sort
1
or+1
for ascending and-1
for descending), the second item determines the sorting key. Specifying a value in this query will also change the current value of the$_['sort']
variable.stack
http://127.0.0.1/panel/get/page/lorem-ipsum.page?stack[the-stack-name]=the-stack-value
directly will activate the stack with valuethe-stack-value
in groupthe-stack-name
.tab
http://127.0.0.1/panel/get/page/lorem-ipsum.page?tab[the-tab-name]=the-tab-value
directly will activate the tab with valuethe-tab-value
in groupthe-tab-name
.token
GET
method. Specifying a value in this query will also change the current value of the$_['token']
variable.type
$_['type']
variable.x
0
for folder and1
for file) or file extensions to be passed to the$x
parameter in theg
function. Specifying a value in this query will also change the current value of the$_['x']
variable.All of the above queries, if present in the panel URL, including any other queries which are not reserved, will affect the current value of the
$_['query']
variable.Type
blank
blob
blob/x
blob
layout optimized to upload extensions.blob/y
blob
layout optimized to upload layouts.data
.data
.file
files
files/cache
files
layout with limited features, optimized to manage cache files (mostly only to delete the cache files).files/trash
files
layout with limited features, optimized to manage trash files (mostly to recover deleted files or to permanently delete the trash files).files/x
files
layout optimized to manage extension files.files/y
files
layout optimized to manage layout files.folder
folders
files
.page
.archive
,.draft
, or.page
).page/page
page
layout optimized to create/delete/update page files stored in the.\lot\page
folder.page/user
page
layout optimized to create/delete/update user files stored in the.\lot\user
folder.pages
.archive
,.draft
, or.page
) in a folder.pages/page
pages
layout optimized to list page files stored in the.\lot\page
folder.pages/user
pages
layout optimized to list user files stored in the.\lot\user
folder.pages/x
pages
layout optimized to list page files stored in the.\lot\x\*
folder.pages/y
pages
layout optimized to list page files stored in the.\lot\y\*
folder.state
state.php
file. Not quite functional except for internal use.Some optional extensions also have implemented their layout types that inherit the layouts above:
page/comment
page
layout optimized to create/delete/update comment files stored in the.\lot\comment
folder.pages/comment
pages
layout optimized to list comment files stored in the.\lot\comment
folder.page/tag
page
layout optimized to create/delete/update tag files stored in the.\lot\tag
folder.pages/tag
pages
layout optimized to list tag files stored in the.\lot\tag
folder.You can view the desired panel layout by appending a
type
query in the URL with the panel layout type:Depending on the situation, the panel layout can automatically be set or even ignored without the need to append a
type
query in the URL, or, it can also redirect you to the correct URL when a dangerous action may occur. For example, when you try to create a file in a folder by manually opening a blank?type=file
layout in the address bar, but it turns out that the panel path actually point to a file without an extension, then you will be automatically redirected to the form to edit that extension-less file.file
..data
, it will implicitly set the panel layout todata
..archive
,.draft
, or.page
, it will implicitly set the panel layout topage
..archive
,.draft
, or.page
stored in.\lot\page
folder, it will implicitly set the panel layout topage/page
..archive
,.draft
, or.page
stored in.\lot\user
folder, it will implicitly set the panel layout topage/user
.folder
. If it contains a page offset, it will implicitly set the panel layout tofiles
..\lot\page
folder or any folders in it, and it contains a page offset, it will implicitly set the panel layout topages/page
. Else, it will implicitly set the panel layout tofolder
..\lot\user
folder, and it contains a page offset, it will implicitly set the panel layout topages/user
. Else, it will implicitly set the panel layout tofolder
.Component
Defined under namespace
x\panel\type
. The following are some common property names. Not all of these properties will be applied to the component, and even if they do exist as component data, they do not always have a role. They may come from the parent data. However, these properties will always have the same functionality across all components.0
false|null|string
HTML
class.1
false|null|string
HTML
class.2
array|null
HTML
class.active
bool
true
. Means that if this property does not exist, then it will have an implicitactive
property with valuetrue
. You have to set this property with valuefalse
to disable a field or a link.are
array
are:
. These data will then be combined with the data in thetags
property. Some data likeactive
andcurrent
might also set this property values automatically. For example, if there is anactive
property with valuetrue
, it will add an itemactive
in theare
property with valuetrue
automatically. So it will prepare the component to add classis:active
in the HTML output.as
array
as:
. These data will then be combined with the data in thetags
property.can
array
can:
. These data will then be combined with the data in thetags
property.count
int
current
bool
decors
array
style
attribute in the HTML output. This is probably not standard as I am currently struggle with the naming convention to make sure it matched with thetags
key functionality.description
null|string
has
array
has:
. These data will then be combined with the data in thetags
property.hint
array|string
icon
array|false|string
id
scalar
image
false|string
is
array
is:
. These data will then be combined with the data in thetags
property.key
scalar
$key
variable.keys
array
link
array|false|string
name
null|string
name
attribute.not
array
not:
. These data will then be combined with the data in thetags
property.of
array
of:
. These data will then be combined with the data in thetags
property.size
int
skip
bool
true
then the component will not be rendered in the output.stack
float|int
lot
property.tags
array
text
null|string
content
,description
, ortitle
properties. If you want to preserve the HTML elements but wants them to be escaped in the output, then consider using thevalue
property. HTML entities like×
are HTML elements, however multi-byte strings written as-is such as×
need to be treated as plain text which doesn’t need to be removed.title
array|string
type
string
unit
array|string
'px'
value set on this property, this property will add a suffix contains text'px'
to the number input to tell the user that the number he/she put on the input is to be used as a pixel value.url
array|false|string
value
mixed
value
attribute.values
array
value
attribute. Some field types such asfield/colors
andfield/items
need to hold multiple values at once. Thisvalues
property will be more dominant to use compared to thevalue
property. The value can be a sequence array or an associative array, depending on the needs and specifications of the field.with
array
with:
. These data will then be combined with the data in thetags
property.Formal syntax:
Example usage:
The example below calls the
section
type directly so you don’t have to specify thetype
property.bar
description
array|null|string
lot
array
title
array|string
button
active
bool
false
, it disables the button.description
array|null|string
icon
array|null|string
status
array|string
title
array|string
Part that comes after
button/
is the button type as described in the HTML5 specification for<button>
element. These components are generally not used directly and function as auxiliary components on the internal side.button/button
button/link
link
array|string
target
property is not set, when you click on it.target
null|string
url
array|string
target
property is not set, when you click on it.button/reset
button/submit
column
content
null|string
lot
array
size
float|int|string
columns
content
null|string
lot
array
column/*
components.content
content
null|string
description
array|null|string
title
array|null|string
description
content
null|string
desk
content
null|string
lot
array
width
bool|int|string
field
active
bool
content
null|string
description
array|null|string
field
array|null|string
fix
bool
hint
array|null|string
lot
array
title
array|null|string
value
mixed
values
mixed
vital
bool
width
bool|int|string
field/blob
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
field/blobs
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
field/button
description
array|null|string
name
null|string
title
array|null|string
value
mixed
field/buttons
description
array|null|string
lot
array
title
array|null|string
field/color
description
array|null|string
name
null|string
title
array|null|string
value
null|string
field/colors
description
array|null|string
name
null|string
title
array|null|string
values
array
field/content
description
array|null|string
height
null|int|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/date
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/date-time
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/description
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/email
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/flex
description
array|null|string
hint
array|null|string
lot
array
title
array|null|string
field/hidden
name
null|string
value
null|string
field/item
description
array|null|string
lot
array
name
null|string
title
array|null|string
value
null|string
field/items
description
array|null|string
flat
bool
lot
array
name
null|string
title
array|null|string
value
null|string
values
array
field/link
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/name
description
array|null|string
hint
array|null|string
max
null|int
min
null|int
name
null|string
pattern
null|string
title
array|null|string
value
null|string
x
array|null|string
field/number
description
array|null|string
hint
array|null|string
max
null|int
min
null|int
name
null|string
step
float|null|int
title
array|null|string
value
null|string
field/option
description
array|null|string
lot
array
name
null|string
title
array|null|string
value
null|string
field/options*
description
array|null|string
lot
array
name
null|string
title
array|null|string
value
null|string
values
null|string
field/pass
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
field/path
description
array|null|string
hint
array|null|string
max
null|int
min
null|int
name
null|string
title
array|null|string
value
null|string
field/query
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/range
description
array|null|string
hint
array|null|string
max
null|int
min
null|int
name
null|string
range
array
title
array|null|string
value
null|string
field/route
description
array|null|string
hint
array|null|string
max
null|int
min
null|int
name
null|string
title
array|null|string
value
null|string
field/set
content
array|null|string
description
array|null|string
lot
array
title
array|null|string
field/source
description
array|null|string
height
null|int|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/text
description
array|null|string
hint
array|null|string
name
null|string
pattern
null|string
title
array|null|string
value
null|string
field/time
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/title
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/toggle
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/u-r-l
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
field/url
This is an alias for
field/u-r-l
.field/version
description
array|null|string
hint
array|null|string
name
null|string
title
array|null|string
value
null|string
fields
file
files
flex
folder
folders
form
Part that comes after
form/
is the formmethod
as described in the HTML5 specification for<form>
element.form/dialog
form/get
form/post
icon
input
Part that comes after
input/
is the input type as described in the HTML5 specification for<input>
element. These components are generally not used directly and function as auxiliary components on the internal side. To add HTML attributes such asdisabled
,readonly
andrequired
follows the standard property naming of panel. For example, to adddisabled
attribute, you don’t usedisabled
property directly. Instead, useactive
property with the value offalse
.input/button
input/checkbox
input/color
input/date
input/datetime-local
input/email
input/file
input/hidden
input/image
input/month
input/number
input/password
input/radio
input/range
input/reset
input/search
input/submit
input/tel
input/text
input/time
input/url
input/week
link
links
lot
menu
page
pager
pages
row
rows
section
select
select/multiple*
separator
stack
stacks
tab
tabs
tasks
tasks/button
tasks/link
textarea
title
unit
To be continued.
Icon
The global
$_['icon']
property exists to store icons data. These data will mostly auto-fill when a component that hasicon
feature appear on the page.Get your desired icon path via Google’s Material design icons browser or use the community version of Material design icons browser which is easier to use and provides more icon alternatives created by contributors.
Be sure to follow the original Material icon system guidelines when you want to use third party icon path data to represent your own brand.
Form
Reserved form names:
blob
<input type="file">
orfield/blob
component, used to upload a file.blobs[]
<input multiple type="file">
orfield/blobs
component, used to upload multiple files at once.data
file
content
,name
, andseal
.folder
name
.hash
kick
options
page
file[content]
value, to be processed as a regular file.path
$_['path']
value will not be used in the form action, but execution will still be carried out on the current URL. This data is usually used only to direct the submission data to another path without having to change the current location of the form. Useful for cases like uploading files by forcing a certain folder structure, for example if files need to be stored in folders named with the current year and month, for organizing files.query
kick
property is not set.stack
state
tab
token
type
Tasks
Defined under namespace
x\panel\task\{get,let,set}
.blob
data
file
folder
page
state
Custom Tasks
Defined under namespace
x\panel\task\fire
.fuse
zip
TODO
Hook
_
do.blob.set
do.data.get
do.data.let
do.data.set
do.file.get
do.file.let
do.file.set
do.folder.get
do.folder.let
do.folder.set
do.page.get
do.page/page.get
do.page/user.get
do.page.let
do.page/page.let
do.page/user.let
do.page.set
do.page/page.set
do.page/user.set
do.state.get
To be continued.
Beta Was this translation helpful? Give feedback.
All reactions