Download the PHP package apharmony/jsharmony-cms-sdk-php without Composer
On this page you can find all versions of the php package apharmony/jsharmony-cms-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jsharmony-cms-sdk-php
jsharmony-cms-sdk-php
jsHarmony CMS SDK for PHP
Installation
Installation and integration instructions are available at jsHarmonyCMS.com
API Documentation
apHarmony\jsHarmonyCms\CmsRouter Class
- Constructor
- Public Properties
- config
- Public Methods
- serve
- getStandalone
- getPlaceholder
- isInEditor
- resolve
- route
- matchRedirect
- getRedirectData
- getEditorScript
- serveFile
- redirect301
- redirect302
- passthru
- generate404
- generateError
- getPage
- getPageFromFile
- getPageFileName
- getFile
- getJsonFile
apHarmony\jsHarmonyCms\CmsPage Class
- Public Properties
- seo
- title
- keywords
- metadesc
- canonical_url
- css
- js
- header
- footer
- title
- page_template_id
- content
- properties
- isInEditor
- editorScript
- notFound
- seo
- Public Methods
- fromArray
apHarmony\jsHarmonyCms\CmsResponse Class
- Constructor
- Public Properties
- type
- filename
- redirect
apHarmony\jsHarmonyCms\CmsPassthruResponse Class
- Public Properties
- http_code
- content_type
- content
- Public Methods
- serve
apHarmony\jsHarmonyCms\CmsRedirect Class
- Constructor
- Public Properties
- http_code
- url
jsHarmonyCmsEditor Class (Client JS)
- Constructor
apHarmony\jsHarmonyCms\CmsRouter Class
CmsRouter Constructor
Arguments
$config
(array) :: Associative array with one or more of the configuration keys below:
Example
Public Properties
CmsRouter->config
(array)
An associative array with the CmsRouter's config. Config parameters are defined in the Constructor above.
Public Methods
CmsRouter->serve
CmsRouter->serve(?string $url = null, array $options = [])
Main Entry Point - Serve CMS Content
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
$options: (array)
(Optional) An associative array that may have any of the following keys:
Returns
(mixed)
Result of the onPage, on301, on302, onPassthru, on404, or onError handler, or TRUE if the return value is null or not defined.
Example
CmsRouter->getStandalone
CmsRouter->getStandalone(?string $url = null)
Main Entry Point - Get CMS Page Data for Standalone Integration
Parameters:
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
Returns
(CmsPage)
Page Content
If page is opened from CMS Editor or Not Found, an empty CmsPage Object will be returned
Example
CmsRouter->getPlaceholder
CmsRouter->getPlaceholder()
Get Placeholder Page for Editor template rendering
Parameters:
N/A
Returns
(CmsPage)
Placeholder Page
Example
CmsRouter->isInEditor
CmsRouter->isInEditor(?string $url = null)
Checks whether the page is in CMS Edit mode
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
Returns
(bool)
True if this page was opened from the CMS Editor
Example
CmsRouter->resolve
CmsRouter->resolve(?string $url = null, array $options = [])
Converts URL to CMS Content Path
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
$options: (array)
(Optional) An associative array that may have any of the following keys:
Returns
(string)
CMS Content Path
Example
CmsRouter->route
CmsRouter->route(?string $url = null)
Run CMS router on the target URL
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
Returns
(CmsResponse|null)
Response with Page Filename, Redirect, or null if not foundExample
CmsRouter->matchRedirect
CmsRouter->matchRedirect(?array $redirects, ?string $url)
Check if URL matches redirects and return first match
Parameters
redirects: (array|null)
Array of CMS Redirects (from getRedirectData function)-
url: (string|null)
Target URL to match against the CMS RedirectsUse Full URL, Root-relative URL, or leave blank to use current URL
Returns
(CmsRedirect|null)
RedirectExample
CmsRouter->getRedirectData
CmsRouter->getRedirectData()
Get CMS Redirect Data
Requires config['redirect_listing_path']
to be defined
Returns
array|null
JSON array of CMS redirects
Example
CmsRouter->getEditorScript
CmsRouter->getEditorScript(?string $url = null)
Generate script for CMS Editor
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
Returns
(string)
HTML Code to launch the CMS Editor
If the page was not launched from the CMS Editor, an empty string will be returned
Security
The querystring jshcms_url parameter is validated against config['cms_server_urls']
If the CMS Server is not found in config['cms_server_urls']
, an empty string will be returned
Example
CmsRouter->serveFile
CmsRouter->serveFile($filePath)
Serves a file to the user
Parameters
$filePath (string)
Path to target file
Example
CmsRouter->redirect301
CmsRouter->redirect301(string $url)
Perform 301 Redirect
Parameters
$url (string)
Target URL for Redirect
Example
CmsRouter->redirect302
CmsRouter->redirect302(string $url)
Perform 302 Redirect
Parameters
$url (string)
Target URL for Redirect
Example
CmsRouter->passthru
CmsRouter->passthru(string $url)
Perform Passthru Request
Parameters
$url (string)
Target URL for Passthru Redirect
Returns
(CmsPassthruResponse)
Response
Call the CmsPassthruResponse->serve() method to serve the page
Example
CmsRouter->generate404
CmsRouter->generate404()
Generate a 404 Not Found Page
Parameters
N/A
Example
CmsRouter->generateError
CmsRouter->generateError($err)
Generate a 500 Error Page
Parameters
$err (Exception|string)
Error message
Example
CmsRouter->getPage
CmsRouter->getPage(?string $url = null, array $options = [])
Get CMS Page from URL
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
$options: (array)
(Optional) An associative array that may have any of the following keys:
Returns
(CmsPage|null)
Page data, or null if page was not found
Example
CmsRouter->getPageFromFile
CmsRouter->getPageFromFile(string $filePath)
Get CMS Page from file path
Parameters
$filePath (string)
Path to target fileReturns
(CmsPage|null)
Page data, or null if page was not found or an error occurredExample
CmsRouter->getPageFileName
CmsRouter->getPageFileName(?string $url = null, array $options = [])
Get CMS Page File
Parameters
-
$url (string|null)
(Optional) CMS Page URLUse Full URL, Root-relative URL, or leave blank to use current URL
$options: (array)
(Optional) An associative array that may have any of the following keys:
Returns
(string)
Full path to CMS content file
CmsPageNotFoundException
exception is thrown if page is not found
Example
CmsRouter->getFile
CmsRouter->getFile($filePath)
Reads a file from the file system
Parameters
$filePath (string)
Path to target file
Returns
(string)
File content
Example
CmsRouter->getJsonFile
CmsRouter->getJsonFile($filePath)
Reads and parses a JSON file
Parameters
$filePath (string)
Path to target file
Returns
(array|null)
JSON content, or null if file was not found or an error occurred
Example
apHarmony\jsHarmonyCms\CmsPage Class
Public Properties
CmsPage->seo
(CmsPageSeo)
A class instance with the SEO-related properties for a page
CmsPage->seo->title
(string)
Page content for the header <title>
tag
CmsPage->seo->keywords
(string)
Page content for the header <meta name="keywords" content="..." />
tag
CmsPage->seo->metadesc
(string)
Page content for the header <meta name="description" content="..." />
tag
CmsPage->seo->canonical_url
(string)
Page content for the header <link rel="canonical" href="..." />
tag
CmsPage->css
(string)
Page content for a header <style type="text/css">
tag
CmsPage->js
(string)
Page content for a header <script type="javascript">
tag
CmsPage->header
(string)
HTML content to be appended to the <head>
tag
CmsPage->footer
(string)
HTML content to be appended to the end of the <body>
tag
CmsPage->title
(string)
HTML content to be added to an <h1>
tag in the body
CmsPage->page_template_id
(string)
Name of the CMS page template used by this page
CmsPage->content
(CmsPageDictionary)
Array of content for this page, indexed by Content Element ID.
Example
If a content area is not defined, its value will be an empty string.
CmsPage->properties
(CmsPageDictionary)
Array of property values for this page, indexed by property name.
Example
If a property is not defined, its value will be an empty string.
CmsPage->isInEditor
(bool)
True if the page was detected to have been opened by the CMS.
CmsPage->editorScript
(string)
If the page was opened by the CMS, the script tag used to launch the CMS Editor. Otherwise, an empty string.
CmsPage->notFound
(bool)
Set to true by CmsRouter->getStandalone if no matching content was found when the page content was supposed to be rendered (when not in CMS Editor mode).
Public Methods
CmsPage::fromArray
CmsPage::fromArray($data)
Generate a CmsPage object from JSON data
Parameters
$data (array)
CMS JSON Page ContentReturns
(CmsPage)
PageExample
apHarmony\jsHarmonyCms\CmsResponse Class
CmsResponse Constructor
Arguments
$type (string)
Type of the response - 'page' or 'redirect'
Example
Public Properties
CmsResponse->type
(string|null)
Type of the response - 'page' or 'redirect'
CmsResponse->filename
(string|null)
Page filename, if response type is "page"
CmsResponse->redirect
(CmsRedirect|null)
Redirect, if response type is "redirect"
apHarmony\jsHarmonyCms\CmsPassthruResponse Class
Public Properties
CmsPassthruResponse->http_code
(int|null)
The HTTP response code from the target passthru page
CmsPassthruResponse->content_type
(string|null)
The HTTP content type from the target passthru page
CmsPassthruResponse->content
(string|null)
The HTML content from the target passthru page
Public Methods
CmsPassthruResponse->serve
CmsPassthruResponse->serve()
Serve the passthru content to the user
Parameters
N/A
Example
apHarmony\jsHarmonyCms\CmsRedirect Class
CmsRedirect Constructor
Arguments
-
$http_code (string)
HTTP Code ('301', '302' or 'PASSTHRU') $url (string)
Destination URL
Example
Public Properties
CmsRedirect->http_code
(string|null)
HTTP Code ('301', '302' or 'PASSTHRU')
CmsRedirect->url
(string|null)
Destination URL
jsHarmonyCmsEditor Class (Client JS)
jsHarmonyCmsEditor Constructor
Arguments
config
(Object) :: Object with one or more of the configuration keys below: