Skip to content

Commit

Permalink
Merge pull request #64 from jaxon-php/develop
Browse files Browse the repository at this point in the history
Merge develop branch into master.
  • Loading branch information
feuzeu committed Jan 13, 2020
2 parents 8535165 + 2281b9b commit f09da5b
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 109 deletions.
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -18,7 +18,8 @@
},
"require": {
"php": ">=5.6.0",
"psr/log": "*",
"psr/log": ">=1.0.0",
"psr/container": ">=1.0.0",
"pimple/pimple": "^3.0",
"lemonphp/event": "^1.0",
"matthiasmullie/minify": "^1.3"
Expand All @@ -38,5 +39,5 @@
"psr-4": {
"Jaxon\\Tests\\": "tests/"
}
}
}
}
34 changes: 0 additions & 34 deletions src/Contracts/Container.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Jaxon.php
Expand Up @@ -46,7 +46,7 @@ class Jaxon implements LoggerAwareInterface
*
* @var string
*/
private $sVersion = 'Jaxon 3.1.3';
private $sVersion = 'Jaxon 3.2.0';

/*
* Plugin types
Expand Down
12 changes: 2 additions & 10 deletions src/Plugin/Code/Generator.php
Expand Up @@ -28,7 +28,7 @@ class Generator
*
* @var string
*/
const JS_LIB_URL = 'https://cdn.jsdelivr.net/gh/jaxon-php/jaxon-js@3.0/dist';
const JS_LIB_URL = 'https://cdn.jsdelivr.net/gh/jaxon-php/jaxon-js@3.2/dist';

/**
* The objects that generate code
Expand Down Expand Up @@ -183,15 +183,6 @@ public function getJs()
*/
private function _getScript()
{
$aConfigVars = $this->getOptionVars();
$sYesScript = 'jaxon.ajax.response.process(command.response)';
$sNoScript = 'jaxon.confirm.skip(command);jaxon.ajax.response.process(command.response)';
$sQuestionScript = jaxon()->dialog()->confirm('msg', $sYesScript, $sNoScript);

$aConfigVars['sQuestionScript'] = $this->_render('confirm.js', [
'sQuestionScript' => $sQuestionScript,
]);

$sScript = '';
$sReadyScript = '';
foreach($this->aGenerators as $xGenerator)
Expand All @@ -205,6 +196,7 @@ private function _getScript()
}

// These three parts are always rendered together
$aConfigVars = $this->getOptionVars();
return $this->_render('config.js', $aConfigVars) . "\n" . $sScript . "\n" .
$this->_render('ready.js', ['sScript' => $sReadyScript]);
}
Expand Down
45 changes: 41 additions & 4 deletions src/Response/Features/JsCommands.php
Expand Up @@ -10,6 +10,8 @@

namespace Jaxon\Response\Features;

use Jaxon\Response\Response;

trait JsCommands
{
/**
Expand All @@ -34,23 +36,58 @@ abstract public function addCommand(array $aAttributes, $mData);
*/
abstract protected function _addCommand($sName, array $aAttributes, $mData, $bRemoveEmpty = false);

/**
* Merge the response commands from the specified <Response> object with
* the response commands in this <Response> object
*
* @param Response|array $mCommands The <Response> object
* @param boolean $bBefore Add the new commands to the beginning of the list
*
* @return void
*/
abstract public function appendResponse($mCommands, $bBefore = false);

/**
* Response command that prompts user with [ok] [cancel] style message box
*
* If the user clicks cancel, the specified number of response commands
* following this one, will be skipped.
*
* @param integer $iCmdNumber The number of commands to skip upon cancel
* @param string $sMessage The message to display to the user
* @param integer $iCommandCount The number of commands to skip upon cancel
* @param string $sMessage The message to display to the user
*
* @return Response
*/
public function confirmCommands($iCmdNumber, $sMessage)
public function confirmCommands($iCommandCount, $sMessage)
{
$aAttributes = ['id' => $iCmdNumber];
$aAttributes = ['count' => $iCommandCount];
return $this->_addCommand('cc', $aAttributes, $sMessage);
}

/**
* Response command that prompts user with [ok] [cancel] style message box
*
* If the user clicks cancel, the specified number of response commands
* following this one, will be skipped.
*
* @param string $sMessage The message to display to the user
* @param callable $xCallable The function
*
* @return Response
*/
public function confirm($sMessage, $xCallable)
{
$xResponse = jaxon()->newResponse();
\call_user_func($xCallable, $xResponse);
$iCommandCount = $xResponse->getCommandCount();
if($iCommandCount > 0)
{
$this->confirmCommands($iCommandCount, $sMessage);
$this->appendResponse($xResponse);
}
return $this;
}

/**
* Add a command to display an alert message to the user
*
Expand Down
15 changes: 8 additions & 7 deletions src/Utils/DI/Container.php
Expand Up @@ -33,7 +33,6 @@
use Jaxon\Plugin\Manager as PluginManager;
use Jaxon\Plugin\Code\Generator as CodeGenerator;
use Jaxon\Contracts\Session as SessionContract;
use Jaxon\Contracts\Container as ContainerContract;

use Jaxon\App\App;
use Jaxon\App\Bootstrap;
Expand All @@ -53,6 +52,8 @@
use Jaxon\Utils\Session\Manager as SessionManager;
use Jaxon\Utils\Http\URI;

use Pimple\Container as PimpleContainer;
use Psr\Container\ContainerInterface;
use Lemon\Event\EventDispatcher;
use Closure;
use ReflectionClass;
Expand All @@ -62,14 +63,14 @@ class Container
/**
* The Dependency Injection Container
*
* @var \Pimple\Container
* @var PimpleContainer
*/
private $libContainer = null;

/**
* The Dependency Injection Container
*
* @var \Jaxon\Contracts\Container
* @var ContainerInterface
*/
private $appContainer = null;

Expand All @@ -80,7 +81,7 @@ class Container
*/
public function __construct(array $aOptions)
{
$this->libContainer = new \Pimple\Container();
$this->libContainer = new PimpleContainer();
$this->libContainer[Container::class] = $this;

$sTranslationDir = realpath(__DIR__ . '/../../../translations');
Expand All @@ -92,7 +93,7 @@ public function __construct(array $aOptions)
/**
* Get the container provided by the integrated framework
*
* @return ContainerContract
* @return ContainerInterface
*/
public function getAppContainer()
{
Expand All @@ -102,11 +103,11 @@ public function getAppContainer()
/**
* Set the container provided by the integrated framework
*
* @param ContainerContract $container The container implementation
* @param ContainerInterface $container The container implementation
*
* @return void
*/
public function setAppContainer(ContainerContract $container)
public function setAppContainer(ContainerInterface $container)
{
$this->appContainer = $container;
}
Expand Down
30 changes: 24 additions & 6 deletions src/start.php
Expand Up @@ -2,6 +2,9 @@

use Jaxon\Jaxon;
use Jaxon\Plugin\Plugin;
use Jaxon\Request\Factory\RequestFactory;
use Jaxon\Request\Factory\ParameterFactory;
use Jaxon\Response\Plugin\JQuery\Dom\Element as DomElement;

/**
* start.php -
Expand Down Expand Up @@ -57,7 +60,7 @@ function jaxon_register_plugin(Plugin $xPlugin, $nPriority = 1000)
/**
* Get the single instance of the request factory, and set the class to call.
*
* @return \Jaxon\Request\Factory\RequestFactory
* @return RequestFactory
*/
function rq($sClassName = null)
{
Expand All @@ -67,13 +70,28 @@ function rq($sClassName = null)
/**
* Get the single instance of the parameter factory
*
* @return \Jaxon\Request\Factory\ParameterFactory
* @return ParameterFactory
*/
function pr()
function pm()
{
return Jaxon::getInstance()->di()->getParameterFactory();
}

/**
* Get the single instance of the parameter factory
*
* The pr function is already defined in CakePHP, so it was renamed to pm.
* This function is therefore deprecated, and will be removed in a future version.
*
* @return ParameterFactory
*/
if(!function_exists('pr'))
{
function pr()
{
return Jaxon::getInstance()->di()->getParameterFactory();
}
}
/**
* Create a JQuery Element with a given selector
*
Expand All @@ -83,11 +101,11 @@ function pr()
* @param string $sSelector The jQuery selector
* @param string $sContext A context associated to the selector
*
* @return \Jaxon\Response\Plugin\JQuery\Dom\Element
* @return DomElement
*/
function jq($sSelector = '', $sContext = '')
{
return new \Jaxon\Response\Plugin\JQuery\Dom\Element($sSelector, $sContext);
return new DomElement($sSelector, $sContext);
}

/**
Expand All @@ -99,7 +117,7 @@ function jq($sSelector = '', $sContext = '')
* @param string $sSelector The jQuery selector
* @param string $sContext A context associated to the selector
*
* @return \Jaxon\Response\Plugin\JQuery\Dom\Element
* @return DomElement
*/
function jQuery($sSelector = '', $sContext = '')
{
Expand Down
2 changes: 0 additions & 2 deletions templates/plugins/config.js.php
Expand Up @@ -39,5 +39,3 @@
}
}
<?php endif ?>

<?php echo $this->sQuestionScript;
43 changes: 0 additions & 43 deletions templates/plugins/confirm.js.php

This file was deleted.

0 comments on commit f09da5b

Please sign in to comment.