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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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.0false|null|stringHTMLclass.1false|null|stringHTMLclass. If this value is a string, then the entire layout of the panel will be replaced with this value.2array|nullHTMLclass.alertarrayarearrayarecontext.asarrayascontext.assetarrayskipproperty with atruevalue.authorstringbasestringcanarraycancontext.chunkint|null20. Developers need to declare the default value manually when they find anullvalue in this property.contentnull|stringlotproperty will be ignored, and the entire contents of the panel will be replaced with this value.countint0. Developers need to declare the value manually if they want to tell other extensions that this value can be trusted to use.deepint|true$deepparameter in thegfunction.descriptionarray|null|stringfilenull|string$_['path']value is a valid file location relative to the.\lotfolder, this property will return that file path, otherwise, this property will returnnull.foldernull|string$_['path']value is a valid folder location relative to the.\lotfolder, this property will return that folder path, otherwise, this property will returnnull.hasarrayhascontext.hashnull|string$_COOKIE['hash'], usually set by JavaScript, because it is not possible to capture URL hash using PHP.iconarray<svg>tag to be loaded just after the opening<body>tag, for inline SVG optimization.isarrayiscontext.kickarray|null|stringx\panel\to\linkfunction automatically.lotarraytype. Values in this property will be ignored ifcontentproperty exists with a string value, even if it is just an empty string. Each item should have astackproperty to set the order of each item consistently. If this property does not exist, it will be assigned a value of10by default. Item with a falsy value or with an array value containing askipproperty with a truthy value will be ignored.notarraynotcontext.ofarrayofcontext.partint|nullhttp://127.0.0.1/panel/get/asset/documents/1indicates that the user is currently viewing a list of files and folders in the.\lot\asset\documentsfolder, while locationhttp://127.0.0.1/panel/get/asset/documentsindicates that user is currently viewing a folder editor to edit the.\lot\asset\documentsfolder.pathnull|string$_['task']and before$_['part'].queryarray|nullsortarray|null1or+1for ascending and-1for descending), the second item determines the sorting key.statusint200,401,403,404or405.taskstringget,let,set, orfire/*where*is the custom task name.titlenull|stringtokenstringtypenull|stringtypeparameter in the panel URL.witharraywithcontext.xint|null|string0for folder and1for file) or file extensions to be passed to the$xparameter in thegfunction.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 theerrortype, it is very commonly used to prevent the next operation from being performed if there is anerroralert data available when the request is made:Asset
Insert assets files this way:
The
stackproperty specifies the loading order of the asset files in the HTML output. You can also use thelinkorurlproperty instead ofpathto 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
idattribute in the HTML output. You can also set a customidvalue different from the asset reference by adding anidproperty. If you set the value tofalseon this property, then theidattribute will be completely removed:You can hide (unload) certain asset files from the HTML output without removing the asset data by adding the
skipproperty with atruevalue (this property has the value set tofalseby default).Other HTML attributes can be set via the
2property: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/panelorhttp://127.0.0.1/panel/*where*is any number greater than0does not implement this rule and will be used to display a generic page rendered from a file stored as.\lot\page\panel.archiveor.\lot\page\panel.pageor pages that come from files stored in.\lot\page\panelfolder.Please note that the
/panelroute is not static, and can be changed to a different route by setting it via therouteproperty in the.\lot\x\panel\state.phpfile.Panel URL is divided into several parts as follows:
basehttp://127.0.0.1/panel. Value cannot benull.taskbase. Value functions as an order to execute tasks. Value can beget,let,set, orfirewith a user-defined command name following after.pathtask. Should point to a file or folder inside the.\lotfolder.partpath. Value can be any number greater than0ornull. 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$deepparameter in thegfunction. Specifying a value in this query will also change the current value of the$_['deep']variable.kickx\panel\to\linkfunction automatically. Specifying a value in this query will also change the current value of the$_['kick']variable.query$_GETvariable. If that’s the case, you will need to modify the values on both variables.sort1or+1for ascending and-1for descending), the second item determines the sorting key. Specifying a value in this query will also change the current value of the$_['sort']variable.stackhttp://127.0.0.1/panel/get/page/lorem-ipsum.page?stack[the-stack-name]=the-stack-valuedirectly will activate the stack with valuethe-stack-valuein groupthe-stack-name.tabhttp://127.0.0.1/panel/get/page/lorem-ipsum.page?tab[the-tab-name]=the-tab-valuedirectly will activate the tab with valuethe-tab-valuein groupthe-tab-name.tokenGETmethod. Specifying a value in this query will also change the current value of the$_['token']variable.type$_['type']variable.x0for folder and1for file) or file extensions to be passed to the$xparameter in thegfunction. 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
blankblobblob/xbloblayout optimized to upload extensions.blob/ybloblayout optimized to upload layouts.data.data.filefilesfiles/cachefileslayout with limited features, optimized to manage cache files (mostly only to delete the cache files).files/trashfileslayout with limited features, optimized to manage trash files (mostly to recover deleted files or to permanently delete the trash files).files/xfileslayout optimized to manage extension files.files/yfileslayout optimized to manage layout files.folderfoldersfiles.page.archive,.draft, or.page).page/pagepagelayout optimized to create/delete/update page files stored in the.\lot\pagefolder.page/userpagelayout optimized to create/delete/update user files stored in the.\lot\userfolder.pages.archive,.draft, or.page) in a folder.pages/pagepageslayout optimized to list page files stored in the.\lot\pagefolder.pages/userpageslayout optimized to list user files stored in the.\lot\userfolder.pages/xpageslayout optimized to list page files stored in the.\lot\x\*folder.pages/ypageslayout optimized to list page files stored in the.\lot\y\*folder.statestate.phpfile. Not quite functional except for internal use.Some optional extensions also have implemented their layout types that inherit the layouts above:
page/commentpagelayout optimized to create/delete/update comment files stored in the.\lot\commentfolder.pages/commentpageslayout optimized to list comment files stored in the.\lot\commentfolder.page/tagpagelayout optimized to create/delete/update tag files stored in the.\lot\tagfolder.pages/tagpageslayout optimized to list tag files stored in the.\lot\tagfolder.You can view the desired panel layout by appending a
typequery 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
typequery 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=filelayout 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.pagestored in.\lot\pagefolder, it will implicitly set the panel layout topage/page..archive,.draft, or.pagestored in.\lot\userfolder, 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\pagefolder 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\userfolder, 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.0false|null|stringHTMLclass.1false|null|stringHTMLclass.2array|nullHTMLclass.activebooltrue. Means that if this property does not exist, then it will have an implicitactiveproperty with valuetrue. You have to set this property with valuefalseto disable a field or a link.arearrayare:. These data will then be combined with the data in thetagsproperty. Some data likeactiveandcurrentmight also set this property values automatically. For example, if there is anactiveproperty with valuetrue, it will add an itemactivein theareproperty with valuetrueautomatically. So it will prepare the component to add classis:activein the HTML output.asarrayas:. These data will then be combined with the data in thetagsproperty.canarraycan:. These data will then be combined with the data in thetagsproperty.countintcurrentbooldecorsarraystyleattribute in the HTML output. This is probably not standard as I am currently struggle with the naming convention to make sure it matched with thetagskey functionality.descriptionnull|stringhasarrayhas:. These data will then be combined with the data in thetagsproperty.hintarray|stringiconarray|false|stringidscalarimagefalse|stringisarrayis:. These data will then be combined with the data in thetagsproperty.keyscalar$keyvariable.keysarraylinkarray|false|stringnamenull|stringnameattribute.notarraynot:. These data will then be combined with the data in thetagsproperty.ofarrayof:. These data will then be combined with the data in thetagsproperty.sizeintskipbooltruethen the component will not be rendered in the output.stackfloat|intlotproperty.tagsarraytextnull|stringcontent,description, ortitleproperties. If you want to preserve the HTML elements but wants them to be escaped in the output, then consider using thevalueproperty. 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.titlearray|stringtypestringunitarray|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.urlarray|false|stringvaluemixedvalueattribute.valuesarrayvalueattribute. Some field types such asfield/colorsandfield/itemsneed to hold multiple values at once. Thisvaluesproperty will be more dominant to use compared to thevalueproperty. The value can be a sequence array or an associative array, depending on the needs and specifications of the field.witharraywith:. These data will then be combined with the data in thetagsproperty.Formal syntax:
Example usage:
The example below calls the
sectiontype directly so you don’t have to specify thetypeproperty.bardescriptionarray|null|stringlotarraytitlearray|stringbuttonactiveboolfalse, it disables the button.descriptionarray|null|stringiconarray|null|stringstatusarray|stringtitlearray|stringPart 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/buttonbutton/linklinkarray|stringtargetproperty is not set, when you click on it.targetnull|stringurlarray|stringtargetproperty is not set, when you click on it.button/resetbutton/submitcolumncontentnull|stringlotarraysizefloat|int|stringcolumnscontentnull|stringlotarraycolumn/*components.contentcontentnull|stringdescriptionarray|null|stringtitlearray|null|stringdescriptioncontentnull|stringdeskcontentnull|stringlotarraywidthbool|int|stringfieldactiveboolcontentnull|stringdescriptionarray|null|stringfieldarray|null|stringfixboolhintarray|null|stringlotarraytitlearray|null|stringvaluemixedvaluesmixedvitalboolwidthbool|int|stringfield/blobdescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringfield/blobsdescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringfield/buttondescriptionarray|null|stringnamenull|stringtitlearray|null|stringvaluemixedfield/buttonsdescriptionarray|null|stringlotarraytitlearray|null|stringfield/colordescriptionarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/colorsdescriptionarray|null|stringnamenull|stringtitlearray|null|stringvaluesarrayfield/contentdescriptionarray|null|stringheightnull|int|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/datedescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/date-timedescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/descriptiondescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/emaildescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/flexdescriptionarray|null|stringhintarray|null|stringlotarraytitlearray|null|stringfield/hiddennamenull|stringvaluenull|stringfield/itemdescriptionarray|null|stringlotarraynamenull|stringtitlearray|null|stringvaluenull|stringfield/itemsdescriptionarray|null|stringflatboollotarraynamenull|stringtitlearray|null|stringvaluenull|stringvaluesarrayfield/linkdescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/namedescriptionarray|null|stringhintarray|null|stringmaxnull|intminnull|intnamenull|stringpatternnull|stringtitlearray|null|stringvaluenull|stringxarray|null|stringfield/numberdescriptionarray|null|stringhintarray|null|stringmaxnull|intminnull|intnamenull|stringstepfloat|null|inttitlearray|null|stringvaluenull|stringfield/optiondescriptionarray|null|stringlotarraynamenull|stringtitlearray|null|stringvaluenull|stringfield/options*descriptionarray|null|stringlotarraynamenull|stringtitlearray|null|stringvaluenull|stringvaluesnull|stringfield/passdescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringfield/pathdescriptionarray|null|stringhintarray|null|stringmaxnull|intminnull|intnamenull|stringtitlearray|null|stringvaluenull|stringfield/querydescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/rangedescriptionarray|null|stringhintarray|null|stringmaxnull|intminnull|intnamenull|stringrangearraytitlearray|null|stringvaluenull|stringfield/routedescriptionarray|null|stringhintarray|null|stringmaxnull|intminnull|intnamenull|stringtitlearray|null|stringvaluenull|stringfield/setcontentarray|null|stringdescriptionarray|null|stringlotarraytitlearray|null|stringfield/sourcedescriptionarray|null|stringheightnull|int|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/textdescriptionarray|null|stringhintarray|null|stringnamenull|stringpatternnull|stringtitlearray|null|stringvaluenull|stringfield/timedescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/titledescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/toggledescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/u-r-ldescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfield/urlThis is an alias for
field/u-r-l.field/versiondescriptionarray|null|stringhintarray|null|stringnamenull|stringtitlearray|null|stringvaluenull|stringfieldsfilefilesflexfolderfoldersformPart that comes after
form/is the formmethodas described in the HTML5 specification for<form>element.form/dialogform/getform/posticoninputPart 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,readonlyandrequiredfollows the standard property naming of panel. For example, to adddisabledattribute, you don’t usedisabledproperty directly. Instead, useactiveproperty with the value offalse.input/buttoninput/checkboxinput/colorinput/dateinput/datetime-localinput/emailinput/fileinput/hiddeninput/imageinput/monthinput/numberinput/passwordinput/radioinput/rangeinput/resetinput/searchinput/submitinput/telinput/textinput/timeinput/urlinput/weeklinklinkslotmenupagepagerpagesrowrowssectionselectselect/multiple*separatorstackstackstabtabstaskstasks/buttontasks/linktextareatitleunitTo be continued.
Icon
The global
$_['icon']property exists to store icons data. These data will mostly auto-fill when a component that hasiconfeature 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/blobcomponent, used to upload a file.blobs[]<input multiple type="file">orfield/blobscomponent, used to upload multiple files at once.datafilecontent,name, andseal.foldername.hashkickoptionspagefile[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.querykickproperty is not set.stackstatetabtokentypeTasks
Defined under namespace
x\panel\task\{get,let,set}.blobdatafilefolderpagestateCustom Tasks
Defined under namespace
x\panel\task\fire.fusezipTODO
Hook
_do.blob.setdo.data.getdo.data.letdo.data.setdo.file.getdo.file.letdo.file.setdo.folder.getdo.folder.letdo.folder.setdo.page.getdo.page/page.getdo.page/user.getdo.page.letdo.page/page.letdo.page/user.letdo.page.setdo.page/page.setdo.page/user.setdo.state.getTo be continued.
Beta Was this translation helpful? Give feedback.
All reactions