Core - PSF1/pharinix GitHub Wiki

Pharinix execute index.php on each user call, see .htaccess.

It don't consider HTML how the default output format, although if don't have other it output HTML, param interface=1. Commands must output her results as array and if it's necessary translate to JSON, XML, HTML, or other, with help of commands like echoJson, param interface=echoJson.

A jQuery call to load a json result should be:

$.ajax({

    type: "POST",

    url:  "<?php echo CMS_DEFAULT_URL_BASE; ?>",

    data: {

        command: "templateEditorList",

        interface: echoJson, // Interface = echoJson to see result how json encoded string.

        }

}).done(function ( data ) {

    // Do something...

});

This call can get something like:

{
"0":"etc\/templates\/pages\/default.xml",
"1":"etc\/templates\/pages\/two_column.xml",
"2":"etc\/templates\/pages\/two_column_right.xml"
}

And this is the implementation of the command templateEditorList:

if (!class_exists("commandTemplateEditorList")) {

    class commandTemplateEditorList extends driverCommand {

        public static function runMe(&$params, $debug = true) {

            // Get the list of templates

            $data = driverTools::lsDir("etc/templates/pages/", "*.xml");

            // output, to the client, how json
            
            //TODO: Update command and example in documentation.

            driverCommand::run("echoJson", $data["files"]);

        }

        public static function getHelp() {

            return array(

                "description" => "Echo a json list of templates. ['default', ...]}", 

                "parameters" => array(), 

                "response" => array()

            );

        }

    }

}

return new commandTemplateEditorList();

So easy, no? :D

The related call only need execute index.php, a few of structural loads, and the command itself.

Hooks

All commands have two hooks, before and after the execution. For example, to nothing command we have beforenothingHook and afternothingHook.

Hooks list:

You can get a complete list of hooks in your system with the command getCommandHelp.

"2": {
                        "name": "pageToHtmlTypeHook",
                        "description": "Allow change the document type.",
                        "parameters": {
                            "element": "Document type tag, default is '<!DOCTYPE html>'."
                        }
                    },
                    "3": {
                        "name": "pageToHtmlRootHook",
                        "description": "Allow change default HTML root tag.",
                        "parameters": {
                            "element": "The actual tag.",
                            "lang": "Raw language code needed."
                        }
                    },
                    "4": {
                        "name": "pageToHtmlHeadHook",
                        "description": "Allow change default head tag.",
                        "parameters": {
                            "charset": "Needed charset",
                            "pagetitle": "Main page title.",
                            "generalTitle": "General page title.",
                            "metas": "Array of tags required by the XML template.",
                            "element": "Prebuild head tag."
                        }
                    },
                    "5": {
                        "name": "pageToHtmlOpenBodyHook",
                        "description": "Allow change default open body tag.",
                        "parameters": {
                            "element": "Prebuild open body tag."
                        }
                    },
                    "6": {
                        "name": "pageToHtmlCloseBodyHook",
                        "description": "Allow change default close body tag.",
                        "parameters": {
                            "element": "Prebuild close body tag."
                        }
                    },
                    "7": {
                        "name": "pageToHtmlOpenMainContentHook",
                        "description": "Allow change default container block.",
                        "parameters": {
                            "element": "Prebuild open tag.",
                            "class": "Class attribute to set to the block.",
                            "tag": "Tag type to close the block, default is 'div'."
                        }
                    },
                    "8": {
                        "name": "pageToHtmlCloseMainContentHook",
                        "description": "Allow change default container block.",
                        "parameters": {
                            "element": "Prebuild open tag.",
                            "tag": "Tag type to close the block, default is 'div'."
                        }
                    },
                    "9": {
                        "name": "pageToHtmlCustomJavascriptHook",
                        "description": "Allow change custom Javascript in page foot.",
                        "parameters": {
                            "element": "Prebuild <script> block.",
                            "raw": "Required Javascript code."
                        }
                    },
                    "10": {
                        "name": "pageToHtmlCustomStylesHook",
                        "description": "Allow change custom CSS styles in page foot.",
                        "parameters": {
                            "element": "Prebuild <style> block.",
                            "raw": "Required CSS."
                        }
                    },
                    "11": {
                        "name": "pageToHtmlOpenRowHook",
                        "description": "Allow change the open row tag.",
                        "parameters": {
                            "element": "Prebuild open tag.",
                            "attributes": "Array of attributes to apply.",
                            "tag": "Tag type to close the block, default is 'div'. If is empty, '', pageToHTML don't add the close tag."
                        }
                    },
                    "12": {
                        "name": "pageToHtmlOpenColHook",
                        "description": "Allow change the open column tag.",
                        "parameters": {
                            "element": "Prebuild open tag.",
                            "attributes": "Array of attributes to apply.",
                            "tag": "Tag type to close the block, default is 'div'. If is empty, '', pageToHTML don't add the close tag."
                        }
                    }
"2": {
                        "name": "smartyRenderBeforeDisplay",
                        "description": "Allow change configuration of the Smarty instance before render the template.",
                        "parameters": {
                            "page": "Readonly, rendered page ID.",
                            "smarty": "Configured Smarty instance before display the template.",
                            "tpl": "Template file to render."
                        }
                    }
⚠️ **GitHub.com Fallback** ⚠️