File: src/start.php

Recommend this page to a friend!
  Classes of Thierry Feuzeu  >  Jaxon  >  src/start.php  >  Download  
File: src/start.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Jaxon
Call PHP classes from JavaScript using AJAX
Author: By
Last change: Fixed issues in classes documentation.
Moved the library initialisation code to the Jaxon constructor.
Separated the parameter factory from the request factory.
Fix.
Removed the Jaxon\Features\App trait.
Changed how the Jaxon and Container classes are instanciated.
Added the view manager.
Added a jaxon_di() which returns the DI container.
Rewrote the request factory.
Added a parameter factory.
Enhanced request and paginator factories.
Enhanced request factory.
Moved the JQuery plugin to the Response\Plugin subdir.
Replaced array() with [].
Date: 9 months ago
Size: 3,059 bytes
 

Contents

Class file image Download
<?php

use Jaxon\Jaxon;
use
Jaxon\Plugin\Plugin;

/**
 * start.php -
 *
 * This file is automatically loaded by the Composer autoloader
 *
 * The Jaxon global functions are defined here, and the library is initialised.
 *
 * @package jaxon-core
 * @author Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @copyright 2016 Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-core
 */

/**
 * Return the singleton instance of the Jaxon/Jaxon class
 *
 * @return Jaxon
 */
function jaxon()
{
    return
Jaxon::getInstance();
}

/**
 * Translate a text to the selected language
 *
 * @param string $sText The text to translate
 * @param array $aPlaceHolders The placeholders in the text
 * @param string|null $sLanguage The language to translate to
 *
 * @return string
 */
function jaxon_trans($sText, array $aPlaceHolders = [], $sLanguage = null)
{
    return
Jaxon::getInstance()->di()->getTranslator()->trans($sText, $aPlaceHolders, $sLanguage);
}

/**
 * Register a plugin
 *
 * @param Plugin $xPlugin An instance of a plugin
 * @param integer $nPriority The plugin priority, used to order the plugins
 *
 * @return void
 */
function jaxon_register_plugin(Plugin $xPlugin, $nPriority = 1000)
{
   
Jaxon::getInstance()->registerPlugin($xPlugin, $nPriority);
}

/**
 * Get the single instance of the request factory, and set the class to call.
 *
 * @return \Jaxon\Request\Factory\RequestFactory
 */
function rq($sClassName = null)
{
    return
Jaxon::getInstance()->di()->getRequestFactory()->setClassName($sClassName);
}

/**
 * Get the single instance of the parameter factory
 *
 * @return \Jaxon\Request\Factory\ParameterFactory
 */
function pr()
{
    return
Jaxon::getInstance()->di()->getParameterFactory();
}

/**
 * Create a JQuery Element with a given selector
 *
 * The returned element is not linked to any Jaxon response, so this function shall be used
 * to insert jQuery code into a javascript function, or as a parameter of a Jaxon function call.
 *
 * @param string $sSelector The jQuery selector
 * @param string $sContext A context associated to the selector
 *
 * @return \Jaxon\Response\Plugin\JQuery\Dom\Element
 */
function jq($sSelector = '', $sContext = '')
{
    return new \
Jaxon\Response\Plugin\JQuery\Dom\Element($sSelector, $sContext);
}

/**
 * Create a JQuery Element with a given selector
 *
 * The returned element is not linked to any Jaxon response, so this function shall be used
 * to insert jQuery code into a javascript function, or as a parameter of a Jaxon function call.
 *
 * @param string $sSelector The jQuery selector
 * @param string $sContext A context associated to the selector
 *
 * @return \Jaxon\Response\Plugin\JQuery\Dom\Element
 */
function jQuery($sSelector = '', $sContext = '')
{
    return
jq($sSelector, $sContext);
}


For more information send a message to info at phpclasses dot org.