initial
This commit is contained in:
36
includes/class-apigoat_doc-activator.php
Normal file
36
includes/class-apigoat_doc-activator.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin activation
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired during plugin activation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
* @author Your Name <email@example.com>
|
||||
*/
|
||||
class apigoat_doc_Activator
|
||||
{
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function activate()
|
||||
{
|
||||
}
|
||||
}
|
||||
36
includes/class-apigoat_doc-deactivator.php
Normal file
36
includes/class-apigoat_doc-deactivator.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin deactivation
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired during plugin deactivation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's deactivation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
* @author Your Name <email@example.com>
|
||||
*/
|
||||
class apigoat_doc_Deactivator
|
||||
{
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function deactivate()
|
||||
{
|
||||
}
|
||||
}
|
||||
45
includes/class-apigoat_doc-i18n.php
Normal file
45
includes/class-apigoat_doc-i18n.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality.
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
* @author Your Name <email@example.com>
|
||||
*/
|
||||
class apigoat_doc_i18n
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Load the plugin text domain for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function load_plugin_textdomain()
|
||||
{
|
||||
|
||||
load_plugin_textdomain(
|
||||
'apigoat_doc',
|
||||
false,
|
||||
dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
|
||||
);
|
||||
}
|
||||
}
|
||||
141
includes/class-apigoat_doc-loader.php
Normal file
141
includes/class-apigoat_doc-loader.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin.
|
||||
*
|
||||
* Maintain a list of all hooks that are registered throughout
|
||||
* the plugin, and register them with the WordPress API. Call the
|
||||
* run function to execute the list of actions and filters.
|
||||
*
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
* @author Your Name <email@example.com>
|
||||
*/
|
||||
class apigoat_doc_Loader
|
||||
{
|
||||
|
||||
/**
|
||||
* The array of actions registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $actions;
|
||||
|
||||
/**
|
||||
* The array of filters registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $filters;
|
||||
|
||||
/**
|
||||
* Initialize the collections used to maintain the actions and filters.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->actions = array();
|
||||
$this->filters = array();
|
||||
$this->shortcodes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new action to the collection to be registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $hook The name of the WordPress action that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the action is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
||||
*/
|
||||
public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
|
||||
{
|
||||
$this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new filter to the collection to be registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
|
||||
*/
|
||||
public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
|
||||
{
|
||||
$this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
|
||||
}
|
||||
|
||||
public function add_shortcode($hook, $component, $callback, $priority = 10, $accepted_args = 1)
|
||||
{
|
||||
$this->shortcodes = $this->add($this->shortcodes, $hook, $component, $callback, $priority, $accepted_args);
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility function that is used to register the actions and hooks into a single
|
||||
* collection.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority The priority at which the function should be fired.
|
||||
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
||||
* @return array The collection of actions and filters registered with WordPress.
|
||||
*/
|
||||
private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
|
||||
{
|
||||
|
||||
$hooks[] = array(
|
||||
'hook' => $hook,
|
||||
'component' => $component,
|
||||
'callback' => $callback,
|
||||
'priority' => $priority,
|
||||
'accepted_args' => $accepted_args
|
||||
);
|
||||
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the filters and actions with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
foreach ($this->filters as $hook) {
|
||||
add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
|
||||
}
|
||||
|
||||
foreach ($this->actions as $hook) {
|
||||
add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
|
||||
}
|
||||
|
||||
foreach ($this->shortcodes as $hook) {
|
||||
add_shortcode($hook['hook'], $hook['callback']);
|
||||
}
|
||||
}
|
||||
}
|
||||
223
includes/class-apigoat_doc.php
Normal file
223
includes/class-apigoat_doc.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The file that defines the core plugin class
|
||||
*
|
||||
* A class definition that includes attributes and functions used across both the
|
||||
* public-facing side of the site and the admin area.
|
||||
*
|
||||
* @link http://example.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* The core plugin class.
|
||||
*
|
||||
* This is used to define internationalization, admin-specific hooks, and
|
||||
* public-facing site hooks.
|
||||
*
|
||||
* Also maintains the unique identifier of this plugin as well as the current
|
||||
* version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package apigoat_doc
|
||||
* @subpackage apigoat_doc/includes
|
||||
* @author Your Name <email@example.com>
|
||||
*/
|
||||
class apigoat_doc
|
||||
{
|
||||
|
||||
/**
|
||||
* The loader that's responsible for maintaining and registering all hooks that power
|
||||
* the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var apigoat_doc_Loader $loader Maintains and registers all hooks for the plugin.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* The unique identifier of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $apigoat_doc The string used to uniquely identify this plugin.
|
||||
*/
|
||||
protected $apigoat_doc;
|
||||
|
||||
/**
|
||||
* The current version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $version The current version of the plugin.
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Define the core functionality of the plugin.
|
||||
*
|
||||
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
||||
* Load the dependencies, define the locale, and set the hooks for the admin area and
|
||||
* the public-facing side of the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('apigoat_doc_VERSION')) {
|
||||
$this->version = apigoat_doc_VERSION;
|
||||
} else {
|
||||
$this->version = '1.0.0';
|
||||
}
|
||||
$this->apigoat_doc = 'apigoat_doc';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
$this->define_public_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the required dependencies for this plugin.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - apigoat_doc_Loader. Orchestrates the hooks of the plugin.
|
||||
* - apigoat_doc_i18n. Defines internationalization functionality.
|
||||
* - apigoat_doc_Admin. Defines all hooks for the admin area.
|
||||
* - apigoat_doc_Public. Defines all hooks for the public side of the site.
|
||||
*
|
||||
* Create an instance of the loader which will be used to register the hooks
|
||||
* with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies()
|
||||
{
|
||||
|
||||
/**
|
||||
* The class responsible for orchestrating the actions and filters of the
|
||||
* core plugin.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-apigoat_doc-loader.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining internationalization functionality
|
||||
* of the plugin.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-apigoat_doc-i18n.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all actions that occur in the admin area.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-apigoat_doc-admin.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all actions that occur in the public-facing
|
||||
* side of the site.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-apigoat_doc-public.php';
|
||||
|
||||
require plugin_dir_path(dirname(__FILE__)) . 'classes/APIgoatList.php';
|
||||
|
||||
$this->loader = new apigoat_doc_Loader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the locale for this plugin for internationalization.
|
||||
*
|
||||
* Uses the apigoat_doc_i18n class in order to set the domain and to register the hook
|
||||
* with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale()
|
||||
{
|
||||
|
||||
$plugin_i18n = new apigoat_doc_i18n();
|
||||
|
||||
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the admin area functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks()
|
||||
{
|
||||
$plugin_admin = new apigoat_doc_Admin($this->get_apigoat_doc(), $this->get_version());
|
||||
$this->loader->add_action('init', $plugin_admin, 'register_session', 1);
|
||||
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
|
||||
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the public-facing functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_public_hooks()
|
||||
{
|
||||
$plugin_public = new apigoat_doc_Public($this->get_apigoat_doc(), $this->get_version());
|
||||
$this->loader->add_action('init', $plugin_public, 'register_session', 1);
|
||||
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
|
||||
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
||||
$this->loader->add_shortcode('APIgoat_list', $plugin_public, array('APIgoatList', 'init'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the loader to execute all of the hooks with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->loader->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the plugin used to uniquely identify it within the context of
|
||||
* WordPress and to define internationalization functionality.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return string The name of the plugin.
|
||||
*/
|
||||
public function get_apigoat_doc()
|
||||
{
|
||||
return $this->apigoat_doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference to the class that orchestrates the hooks with the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return apigoat_doc_Loader Orchestrates the hooks of the plugin.
|
||||
*/
|
||||
public function get_loader()
|
||||
{
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the version number of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @return string The version number of the plugin.
|
||||
*/
|
||||
public function get_version()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
991
includes/html_helper.php
Normal file
991
includes/html_helper.php
Normal file
@@ -0,0 +1,991 @@
|
||||
<?php
|
||||
|
||||
|
||||
function clean($string, $more = false)
|
||||
{
|
||||
$string = str_replace("\'", "'", $string);
|
||||
$string = str_replace("'", "''", $string);
|
||||
if ($more)
|
||||
$string = str_replace("\"", "”", $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
function htmlLink($name, $link, $options = "", $title = "")
|
||||
{
|
||||
if (!empty($title)) {
|
||||
if ($title === true) {
|
||||
$title = ' title="' . strip_tags($name) . '" ';
|
||||
} else {
|
||||
$title = ' title="' . $title . '" ';
|
||||
}
|
||||
}
|
||||
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<a href=\"$link\" $optionsContent $title>$name</a>";
|
||||
}
|
||||
|
||||
function href($name, $link, $options = "", $title = "")
|
||||
{
|
||||
return htmlLink($name, $link, $options, $title);
|
||||
}
|
||||
|
||||
function anchor($id)
|
||||
{
|
||||
return "<a id=\"$id\"></a>";
|
||||
}
|
||||
|
||||
function div($content, $id = "", $options = "")
|
||||
{
|
||||
if ($id) $id = "id=\"$id\"";
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<div $id $optionsContent>$content</div>";
|
||||
}
|
||||
|
||||
function pre($content, $options = "")
|
||||
{
|
||||
return "<pre $options>$content</pre>";
|
||||
}
|
||||
|
||||
function input($type, $name, $value = "", $options = "", $id = "")
|
||||
{
|
||||
if ($id == "") {
|
||||
$id = $name;
|
||||
}
|
||||
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<input type=\"$type\" name=\"$name\" id=\"$id\" value=\"" . $value . "\" $optionsContent/>";
|
||||
}
|
||||
|
||||
function img($path, $height = "", $width = "", $options = "", $alt = "", $title = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
if (!empty($other))
|
||||
$other = ' ' . $other;
|
||||
/* bug au niveau explorer il voyais pas les photo maintenant corrigé avec cette patch */
|
||||
if (!empty($height)) {
|
||||
if ($height === true) {
|
||||
$path = _SITE_URL . 'css/img/' . $path;
|
||||
} else {
|
||||
$height = ' height="' . $height . '" ';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($width))
|
||||
$width = ' width="' . $width . '" ';
|
||||
|
||||
if (!empty($alt)) {
|
||||
if ($title == '') {
|
||||
$title = ' title="' . $alt . '" ';
|
||||
} else {
|
||||
$title = ' title="' . $title . '" ';
|
||||
}
|
||||
|
||||
$alt = ' alt="' . $alt . '" ';
|
||||
}
|
||||
|
||||
return "<img src=\"" . $path . "\" $width $height $optionsContent $alt $title />";
|
||||
}
|
||||
|
||||
function p($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<p $optionsContent>$content</p>";
|
||||
}
|
||||
|
||||
function b($content, $options = "")
|
||||
{
|
||||
return "<b $options>$content</b>";
|
||||
}
|
||||
function strong($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<strong $optionsContent>$content</strong>";
|
||||
}
|
||||
function i($content, $options = "")
|
||||
{
|
||||
return "<i $options>$content</i>";
|
||||
}
|
||||
|
||||
function h1($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<h1 $optionsContent>$content</h1>";
|
||||
}
|
||||
|
||||
function h2($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<h2 $optionsContent>$content</h2>";
|
||||
}
|
||||
|
||||
function h3($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<h3 $optionsContent>$content</h3>";
|
||||
}
|
||||
|
||||
function h4($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<h4 $optionsContent>$content</h4>";
|
||||
}
|
||||
|
||||
function ul($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<ul $optionsContent>$content</ul>";
|
||||
}
|
||||
|
||||
function li($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<li $optionsContent>$content</li>";
|
||||
}
|
||||
|
||||
function span($content = "", $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<span $optionsContent>$content</span>";
|
||||
}
|
||||
|
||||
function tr($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<tr $optionsContent>$content</tr>\n";
|
||||
}
|
||||
|
||||
function td($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<td $optionsContent>$content</td>";
|
||||
}
|
||||
|
||||
function th($content, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<th $optionsContent>$content</th>";
|
||||
}
|
||||
|
||||
function thead($content, $option = "")
|
||||
{
|
||||
return "<thead $option>$content</thead>";
|
||||
}
|
||||
|
||||
function body($content, $option = "")
|
||||
{
|
||||
return "<body $option>
|
||||
$content</body>";
|
||||
}
|
||||
|
||||
function tbody($content, $option = "")
|
||||
{
|
||||
return "<tbody $option>$content</tbody>";
|
||||
}
|
||||
|
||||
function tfoot($content, $option = "")
|
||||
{
|
||||
return "<tfoot $option>$content</tfoot>";
|
||||
}
|
||||
|
||||
function table($content, $option = "")
|
||||
{
|
||||
return "<table $option>$content</table>";
|
||||
}
|
||||
|
||||
function form($content, $option = "")
|
||||
{
|
||||
return "<form $option>$content</form>";
|
||||
}
|
||||
|
||||
function select($name, $options, $selOption = "", $idSelected = "", $id = "", $opt_re = false, $null_in_sel = false)
|
||||
{
|
||||
if (empty($id))
|
||||
$id = $name;
|
||||
if ($null_in_sel) {
|
||||
$null_in_sel_tab = array('0' => _MESS_SELECTION, '1' => '');
|
||||
if ($options) {
|
||||
array_unshift($options, $null_in_sel_tab);
|
||||
} else {
|
||||
$options = array($null_in_sel_tab);
|
||||
}
|
||||
}
|
||||
if (is_array($options)) {
|
||||
for ($i = 0, $c = count($options); $i < $c; $i++) {
|
||||
if (!empty($options[$i][0])) {
|
||||
// handle multiple selected id
|
||||
if (is_array($idSelected)) {
|
||||
if (array_search($options[$i][1], $idSelected) !== false) {
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "' selected=\"yes\"");
|
||||
} else
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "'");
|
||||
} else {
|
||||
// handle standard selected id
|
||||
if ($idSelected == $options[$i][1]) {
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "' selected=\"yes\"");
|
||||
} else
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
$options = $option;
|
||||
}
|
||||
if (!$opt_re)
|
||||
return "<select name=\"$name\" id=\"$id\" $selOption>$options</select>";
|
||||
else
|
||||
return $options;
|
||||
}
|
||||
|
||||
function selectbox($name, $select, $valeur = '', $class = '')
|
||||
{
|
||||
$placeholder = $name;
|
||||
if ($valeur) {
|
||||
$name = $valeur;
|
||||
}
|
||||
return label(span($name, ' placeholder="' . $placeholder . '" class="select-label-span"') . $select, ' class="select-label js-select-label ' . $class . '"');
|
||||
}
|
||||
|
||||
function optionListeSelect($options, $selectedValue, $defaultLabel = true)
|
||||
{
|
||||
if ($options) {
|
||||
$selectedLabel = "";
|
||||
foreach ($options as $option) {
|
||||
$class = "";
|
||||
if (is_array($selectedValue)) {
|
||||
if (array_search($option[1], $selectedValue) !== false) {
|
||||
$class = ' class="selected"';
|
||||
$selectedLabel .= $option[0] . ',';
|
||||
}
|
||||
} else {
|
||||
if ($selectedValue == $option[1]) {
|
||||
$class = ' class="selected"';
|
||||
$selectedLabel .= $option[0] . ',';
|
||||
}
|
||||
}
|
||||
$optionsList .=
|
||||
li(
|
||||
strong(ucfirst($option[0]), 'unselectable="on" title="' . ucfirst($option[0]) . '"'),
|
||||
'v=\'' . $option[2] . '\' unselectable="on" data-label="' . $option[0] . '" data-value="' . $option[1] . '"' . $class
|
||||
);
|
||||
}
|
||||
}
|
||||
if (empty($selectedLabel)) {
|
||||
if (!empty($defaultLabel)) {
|
||||
$selectedLabel = $defaultLabel;
|
||||
} else {
|
||||
/* mets rien esti */
|
||||
/* $selectedLabel = $options[0][0];
|
||||
$inputValue = $options[0][1];*/
|
||||
}
|
||||
} else {
|
||||
$selectedLabel = substr($selectedLabel, 0, -1);
|
||||
}
|
||||
$return['optionsList'] = $optionsList;
|
||||
$return['selectedLabel'] = $selectedLabel;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function selectboxCustomArray($name, $options, $defaultLabel = '', $attr = '', $selectedValue = 'default', $classParam = '', $null_in_sel = false)
|
||||
{
|
||||
$placeholder = $name;
|
||||
$tabindex = "";
|
||||
$multiple = false;
|
||||
if (is_array($selectedValue)) {
|
||||
$selectedValue = implode(',', $selectedValue);
|
||||
}
|
||||
$inputValue = $selectedValue;
|
||||
if (!is_array($selectedValue)) {
|
||||
$selectedValue = explode(',', $selectedValue);
|
||||
}
|
||||
if ($selectedValue) {
|
||||
foreach ($selectedValue as $value) {
|
||||
$valuesList[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$attr = str_replace('otherTabs=1', '', $attr);
|
||||
if (!preg_match('/disabled/', $attr))
|
||||
$tabindex = ' tabindex="0" othertabs="1"';
|
||||
if (preg_match('/multiple/', $attr))
|
||||
$multiple = true;
|
||||
|
||||
$rOption = optionListeSelect($options, $selectedValue, $defaultLabel);
|
||||
$optionsList = $rOption['optionsList'];
|
||||
$selectedLabel = $rOption['selectedLabel'];
|
||||
|
||||
if (!empty($defaultLabel)) {
|
||||
$defaultLabel = li(span(_('Clear'), 'unselectable="on" title="' . ucfirst($defaultLabel) . '"'), 'class="default" unselectable="on" data-label="' . $defaultLabel . '" data-value="default"');
|
||||
}
|
||||
if ($null_in_sel) {
|
||||
$emptyLabel = li(span(_('Empty value'), 'unselectable="off" title="' . ucfirst(_('Empty value')) . '"'), 'class="null" unselectable="off" data-label="' . _('Empty value') . '" data-value="_null"');
|
||||
$classParam .= " hasNull";
|
||||
}
|
||||
$grayClass = " gray ";
|
||||
if ($inputValue) {
|
||||
$grayClass = "";
|
||||
}
|
||||
$mobileHeader = "";
|
||||
if ($multiple) {
|
||||
$mobileHeader = div(span('x', 'class="select-close-button js-select-close-button"'), '', 'class="mobile-header"');
|
||||
}
|
||||
$findme = 'SearchTabs';
|
||||
$SearchTabs = " SearchTabs='1' ";
|
||||
if (strpos($attr, $findme) === false) {
|
||||
$SearchTabs = '';
|
||||
}
|
||||
$list = ul(
|
||||
$defaultLabel
|
||||
. $emptyLabel
|
||||
. $optionsList,
|
||||
'class="scrollable select-element ' . $name . '" data-default-selected=\'' . json_encode($valuesList) . '\''
|
||||
)
|
||||
. input('hidden', $name, $inputValue, 'class="selextbox-input NC' . str_replace('[]', '', $name) . '" ' . $SearchTabs . ' s="d"');
|
||||
|
||||
return label(
|
||||
span($selectedLabel, ' placeholder="' . $placeholder . '" class="select-label-span' . $grayClass . '"' . $tabindex) . $mobileHeader . $list,
|
||||
str_replace('SearchTabs=\'1\'', '', str_replace('s=\'d\'', '', $attr . ' data-child-select="' . str_replace('[]', '', $name) . '" data-name="' . $name . '" class="select-label js-select-label ' . $classParam . '"'))
|
||||
);
|
||||
}
|
||||
|
||||
function arrayToOptions($options, $idSelected = '')
|
||||
{
|
||||
if (is_array($options)) {
|
||||
for ($i = 0, $c = count($options); $i < $c; $i++) {
|
||||
if (!empty($options[$i][0])) {
|
||||
// handle multiple selected id
|
||||
if (is_array($idSelected)) {
|
||||
if (array_search($options[$i][1], $idSelected)) {
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "' selected=\"yes\"");
|
||||
} else
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "'");
|
||||
} else {
|
||||
// handle standard selected id
|
||||
if ($idSelected == $options[$i][1]) {
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "' selected=\"yes\"");
|
||||
} else
|
||||
$option .= option($options[$i][0], $options[$i][1], "v='" . $options[$i][2] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
$options = $option;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
function arrayToJson($options, $idSelected = '')
|
||||
{
|
||||
if (is_array($options)) {
|
||||
for ($i = 0, $c = count($options); $i < $c; $i++) {
|
||||
if (!empty($options[$i][0])) {
|
||||
// handle multiple selected id
|
||||
if (is_array($idSelected)) {
|
||||
if (array_search($options[$i][1], $idSelected)) {
|
||||
$option[$options[$i][1]] = li($options[$i][0], "data-label='" . $options[$i][0] . "' data-value='" . $options[$i][1] . "' v='" . $options[$i][2] . "' class='selected'");
|
||||
} else
|
||||
$option[$options[$i][1]] = li($options[$i][0], "data-label='" . $options[$i][0] . "' data-value='" . $options[$i][1] . "' v='" . $options[$i][2] . "'");
|
||||
} else {
|
||||
// handle standard selected id
|
||||
if ($idSelected == $options[$i][1]) {
|
||||
$option[$options[$i][1]] = li($options[$i][0], "data-label='" . $options[$i][0] . "' data-value='" . $options[$i][1] . "' v='" . $options[$i][2] . "' class='selected'");
|
||||
} else
|
||||
$option[$options[$i][1]] = li($options[$i][0], "data-label='" . $options[$i][0] . "' data-value='" . $options[$i][1] . "' v='" . $options[$i][2] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return json_encode($option);
|
||||
}
|
||||
|
||||
function option($caption, $value, $options = "")
|
||||
{
|
||||
return "<option value=\"$value\" $options>$caption</option>";
|
||||
}
|
||||
|
||||
function iframe($src, $options = "")
|
||||
{
|
||||
return "<iframe src=\"$src\" $options></iframe>
|
||||
";
|
||||
}
|
||||
|
||||
function textarea($id, $value = "", $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<textarea id=\"$id\" name=\"$id\" $optionsContent >$value</textarea>";
|
||||
}
|
||||
|
||||
function customCheckInput($input, $label)
|
||||
{
|
||||
return span(
|
||||
$input
|
||||
. span('', 'class="placeholder-input"')
|
||||
. span(
|
||||
$label,
|
||||
'class="checkbox-label"'
|
||||
),
|
||||
'class="custom-input"'
|
||||
);
|
||||
}
|
||||
function checkbox($id, $value, $options = "")
|
||||
{
|
||||
return "<input type=\"checkbox\" id=\"$id\" name=\"$id\" value=\"$value\" $options>";
|
||||
}
|
||||
function radio($id, $value, $options = "")
|
||||
{
|
||||
return "<input type=\"radio\" id=\"$id\" name=\"$id\" value=\"$value\" $options>";
|
||||
}
|
||||
|
||||
function loadCss($style, $options = "")
|
||||
{
|
||||
if ($style) {
|
||||
return "<link href=\"$style\" rel=\"stylesheet\" type=\"text/css\" $options />";
|
||||
}
|
||||
}
|
||||
|
||||
function loadjs($js)
|
||||
{
|
||||
if ($js) {
|
||||
return "<script src=\"$js\" type=\"text/javascript\"></script>";
|
||||
}
|
||||
}
|
||||
|
||||
function htmlHeader($title = "", $style = "", $desciption = "", $keywords = "", $others = "", $favicon = "favicon.ico", $author = '')
|
||||
{
|
||||
$Html_head = "<head>";
|
||||
//$Html_head .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />";
|
||||
$Html_head .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
|
||||
if (!empty($desciption))
|
||||
$Html_head .= "<meta name=\"description\" content=\"$desciption\" />";
|
||||
if (!empty($keywords))
|
||||
$Html_head .= "<meta name=\"keywords\" content=\"$keywords\" />";
|
||||
if (!empty($title))
|
||||
$Html_head .= "<title>$title</title>";
|
||||
//if(!empty($favicon))
|
||||
$Html_head .= "<link rel=\"icon\" type=\"image/png\" href=\"" . _SITE_URL . $favicon . "\" />";
|
||||
if (!empty($style))
|
||||
$Html_head .= $style;
|
||||
$Html_head .= $others;
|
||||
$Html_head .= "<meta name='Author' content='" . $author . "' />";
|
||||
$Html_head .= "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>";
|
||||
|
||||
$Html_head .= "</head>";
|
||||
return $Html_head;
|
||||
}
|
||||
|
||||
function docType()
|
||||
{
|
||||
//return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
|
||||
//return "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
|
||||
return "<!DOCTYPE HTML>";
|
||||
}
|
||||
|
||||
function htmlTag($content, $option = "")
|
||||
{
|
||||
$Html = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\" lang=\"fr\" dir=\"ltr\" " . $option . ">";
|
||||
$Html .= $content;
|
||||
$Html .= "</html>";
|
||||
return $Html;
|
||||
}
|
||||
|
||||
function startHtml()
|
||||
{
|
||||
$Html = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\" lang=\"fr\" dir=\"ltr\">";
|
||||
return $Html;
|
||||
}
|
||||
|
||||
function closeHtml()
|
||||
{
|
||||
$Html_foot .= "</html>";
|
||||
return $Html_foot;
|
||||
}
|
||||
|
||||
function htmlSpace($nbr)
|
||||
{
|
||||
for ($i = 0; $i < $nbr; $i++)
|
||||
$space .= " ";
|
||||
return $space;
|
||||
}
|
||||
|
||||
function req($val)
|
||||
{
|
||||
return str_replace('\\', '\\\\', strip_tags(trim(htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($_REQUEST[$val]) : $_REQUEST[$val]), ENT_QUOTES))));
|
||||
}
|
||||
|
||||
function cleanString($str)
|
||||
{
|
||||
$str = str_replace("script", "", $str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
function getUrlParamsJSON($arrayParams = "", $asUrl = false)
|
||||
{
|
||||
$keys = array_keys($_REQUEST);
|
||||
|
||||
if ($asUrl) {
|
||||
foreach ($keys as $key) {
|
||||
if (in_array($key, $arrayParams)) {
|
||||
$urlParams .= "&" . $key . "=" . urlencode($_REQUEST[$key]);
|
||||
}
|
||||
}
|
||||
return $urlParams;
|
||||
}
|
||||
|
||||
$urlParams .= "'dum':'z'";
|
||||
if ($arrayParams[0] != "") {
|
||||
foreach ($keys as $key) {
|
||||
if (in_array($key, $arrayParams)) {
|
||||
$urlParams .= ",\"" . $key . "\":\"" . urlencode($_REQUEST[$key]) . "\"";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($keys as $key) {
|
||||
if ($key != "__utma" && $key != "__utmz" && $key != "PHPSESSID" && !strstr($key, "SESS") && $key != "dum") {
|
||||
$urlParams .= ",'" . $key . "':'" . urlencode($_REQUEST[$key]) . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $urlParams;
|
||||
}
|
||||
|
||||
function message($message)
|
||||
{
|
||||
return "<script>$(document).ready(function() {message('" . $message . "');});</script>";
|
||||
}
|
||||
|
||||
function script($data, $option = "")
|
||||
{
|
||||
return "<script type='text/javascript' " . $option . ">" . $data . "</script>";
|
||||
}
|
||||
|
||||
function scriptReady($data, $option = "")
|
||||
{
|
||||
return "<script type='text/javascript' " . $option . ">
|
||||
$(document).ready(function(){
|
||||
" . $data . "
|
||||
});</script>";
|
||||
}
|
||||
|
||||
function style($data, $option = "")
|
||||
{
|
||||
return "<style type='text/css' $option>" . trim(preg_replace("/\s+/", " ", $data)) . "</style>";
|
||||
}
|
||||
|
||||
|
||||
function createRandomKey($amount)
|
||||
{
|
||||
$keyset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
$randkey = "";
|
||||
for ($i = 0; $i < $amount; $i++)
|
||||
$randkey .= substr($keyset, rand(0, strlen($keyset) - 1), 1);
|
||||
return $randkey;
|
||||
}
|
||||
|
||||
function ynToStr($yn, $lang = 'fr')
|
||||
{
|
||||
if ($lang == 'fr') {
|
||||
return ($yn == 'y') ? "Oui" : "Non";
|
||||
}
|
||||
if ($lang == 'en') {
|
||||
return ($yn == 'y') ? "Yes" : "No";
|
||||
}
|
||||
}
|
||||
|
||||
function selectYN($name, $selected = '', $options = '')
|
||||
{
|
||||
return select($name, array(0 => array('Yes', 'y'), 1 => array('No', 'n')), $options, $selected);
|
||||
}
|
||||
|
||||
function selectYesNo($name, $selected = '', $options = '')
|
||||
{
|
||||
return select($name, array(0 => array('Yes', 'yes'), 1 => array('No', 'no')), $options, $selected);
|
||||
}
|
||||
|
||||
function selectIntYN($name, $selected = '', $options = '', $null = false)
|
||||
{
|
||||
if ($null)
|
||||
$choices = array(0 => array('Choose', '0'), 1 => array('Yes', '1'), 2 => array('No', '2'));
|
||||
else
|
||||
$choices = array(0 => array('Yes', '1'), 1 => array('No', '0'));
|
||||
return select($name, $choices, $options . " s='" . $selected . "'", $selected);
|
||||
}
|
||||
|
||||
function selectLang($name, $selected = '', $options = '')
|
||||
{
|
||||
return select($name, array(0 => array('Francais', 'FR'), 1 => array('English', 'EN')), $options, $selected);
|
||||
}
|
||||
function assocToNumDef($array, $addDefault = false, $valeur = _MESS_SELECTION)
|
||||
{
|
||||
$arrValues = array_values($array);
|
||||
$len = count($arrValues);
|
||||
/*if($addDefault){
|
||||
$num[] = array(1=> NULL, 0=> $valeur);
|
||||
}*/
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$val = array_values($arrValues[$i]);
|
||||
$num[] = $val;
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
|
||||
function assocToNumWidthNull($array, $addDefault = false)
|
||||
{
|
||||
return assocToNumDef($array, $addDefault = false);
|
||||
}
|
||||
|
||||
function assocToNum($array, $addDefault = false)
|
||||
{
|
||||
$arrValues = array_values($array);
|
||||
$len = count($arrValues);
|
||||
/* if($addDefault){
|
||||
$num[] = array(1=> NULL, 0=> _MESS_SELECTION, 2=>'_MESS_SELECTION');
|
||||
}*/
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$val = array_values($arrValues[$i]);
|
||||
$num[] = $val;
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
function assocToNumV($array, $addDefault = false)
|
||||
{
|
||||
$arrValues = array_values($array);
|
||||
$len = count($arrValues);
|
||||
/*if($addDefault){
|
||||
$num[] = array(1=> NULL, 0=> _MESS_SELECTION, 2=>'_MESS_SELECTION');
|
||||
}*/
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$val = array_values($arrValues[$i]);
|
||||
$num[] = $val;
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
$array_search;
|
||||
function message_label($label, $local = NULL)
|
||||
{
|
||||
|
||||
if ($label) {
|
||||
global $messagesCache;
|
||||
if (!$local)
|
||||
$local = $_SESSION[_AUTH_VAR]->config['locale']['locale'];
|
||||
|
||||
if (!isset($messagesCache[$label][$local])) {
|
||||
$data = \App\MessageQuery::create()
|
||||
->filterByLabel($label)
|
||||
->findOne();
|
||||
|
||||
if ($data) {
|
||||
$messagesCache[$label][$local] = $data->getTranslation($local)->getText();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
$e = new App\Message();
|
||||
$e->setLabel($label);
|
||||
$e->save();
|
||||
|
||||
if (count($_SESSION[_AUTH_VAR]->config['locale']['supported_locale']) > 1) {
|
||||
foreach ($_SESSION[_AUTH_VAR]->config['locale']['supported_locale'] as $locale) {
|
||||
$mt = new App\MessageI18n();
|
||||
$mt->setLocale($locale);
|
||||
$mt->setText($label == '' ? null : $label);
|
||||
$e->addMessageI18n($mt);
|
||||
$e->save();
|
||||
}
|
||||
} else {
|
||||
$mt = new App\MessageI18n();
|
||||
$mt->setLocale($local);
|
||||
$mt->setText($label == '' ? null : $label);
|
||||
$e->addMessageI18n($mt);
|
||||
$e->save();
|
||||
}
|
||||
|
||||
$messagesCache[$label][$local] = $label;
|
||||
}
|
||||
|
||||
return $messagesCache[$label][$local];
|
||||
}
|
||||
}
|
||||
|
||||
function handleNotOkResponse($msg, $ui = '', $print = false, $text_title = 'Message')
|
||||
{
|
||||
$ui = (!empty($ui)) ? '#' . $ui : '';
|
||||
$msg = message_label($msg);
|
||||
$error['txt'] .= $msg;
|
||||
|
||||
if ($_SESSION[_AUTH_VAR]->SessVar['content-type'] == 'JSON') {
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-type: application/json');
|
||||
$ret['status'] = 'error-notok';
|
||||
$ret['data']['title'] = $text_title;
|
||||
$ret['data']['msg'] = $msg;
|
||||
die(json_encode($ret));
|
||||
} else {
|
||||
if ($print) {
|
||||
$error['onReadyJs'] = "
|
||||
<script>$('#ui-dialog-title-alertDialog').html('" . str_replace("'", " ", $text_title) . "');
|
||||
$('#alert_text').show().html('" . str_replace("'", " ", $msg) . "');
|
||||
$('#alertDialog').dialog('open');</script>
|
||||
|
||||
";
|
||||
} else {
|
||||
$error['onReadyJs'] = "
|
||||
$('#ui-dialog-title-alertDialog').html('" . str_replace("'", " ", $text_title) . "');
|
||||
$('#alert_text').show().html('" . str_replace("'", " ", $msg) . "');
|
||||
$('#alertDialog').dialog('open');";
|
||||
$error['error'] = 'yes';
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
function handleValidationError($objValidationFails, $ui = '', $text_title = 'Message', $extValidationErr = '')
|
||||
{
|
||||
$error['error'] = 'yes';
|
||||
$red_flag = "";
|
||||
$fields = array();
|
||||
if (is_array($extValidationErr)) {
|
||||
foreach ($extValidationErr as $failure => $field) {
|
||||
$msg = message_label($failure);
|
||||
$error['txt'] .= $msg . "<br>";
|
||||
$fields = array_merge($fields, $field['fields']);
|
||||
}
|
||||
}
|
||||
foreach ($objValidationFails->getValidationFailures() as $failure) {
|
||||
$msg = message_label($failure->getMessage());
|
||||
$error['txt'] .= $msg . "<br>";
|
||||
$fields[] = $failure->getColumn();
|
||||
}
|
||||
$ui = (!empty($ui)) ? "#" . $ui : "";
|
||||
$error['onReadyJs'] .= "
|
||||
$('" . $ui . " .error_field').removeClass('error_field');";
|
||||
foreach ($fields as $field) {
|
||||
if (!empty($field)) {
|
||||
if (strstr($field, '.')) {
|
||||
$input = explode('.', $field);
|
||||
$fieldName = $input[1];
|
||||
} else
|
||||
$fieldName = $field;
|
||||
$error['onReadyJs'] .= "
|
||||
if($('" . $ui . " [v=" . addslashes(strtoupper($fieldName)) . "] .select-label-span').length > 0){
|
||||
$('" . $ui . " [v=" . addslashes(strtoupper($fieldName)) . "] .select-label-span').addClass('error_field');
|
||||
}else{
|
||||
$('" . $ui . " [v=" . addslashes(strtoupper($fieldName)) . "]').addClass('error_field');
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
$error['onReadyJs'] .= "
|
||||
|
||||
$('#ui-dialog-title-alertDialog').html('" . addslashes($text_title) . "');
|
||||
$('#alert_text').show().html('" . addslashes($error['txt']) . "');
|
||||
$('#alertDialog').dialog('open');
|
||||
alert_close = '$(\'" . $ui . " .error_field\').first().focus();';
|
||||
";
|
||||
|
||||
if ($_SESSION[_AUTH_VAR]->SessVar['content-type'] == 'JSON') {
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-type: application/json');
|
||||
$ret['status'] = 'error-validation';
|
||||
$ret['data'] = $fields;
|
||||
die(json_encode($ret));
|
||||
} else {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
function camelize($string, $pascalCase = false)
|
||||
{
|
||||
if (strpos($string, '_') !== false) {
|
||||
$string = strtolower($string);
|
||||
}
|
||||
$string = str_replace(array('-', '_'), ' ', $string);
|
||||
$string = ucwords($string);
|
||||
$string = str_replace(' ', '', $string);
|
||||
|
||||
if (!$pascalCase) {
|
||||
return lcfirst($string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
function unCamelize($input)
|
||||
{
|
||||
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||
$ret = $matches[0];
|
||||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
return implode('_', $ret);
|
||||
}
|
||||
function format_phone($phone)
|
||||
{
|
||||
return format_phone_v2($phone);
|
||||
}
|
||||
function format_phone_v2($phone)
|
||||
{
|
||||
$phoneNumber = preg_replace('/[^0-9]/', '', $phoneNumber);
|
||||
|
||||
if (strlen($phoneNumber) > 10) {
|
||||
$countryCode = substr($phoneNumber, 0, strlen($phoneNumber) - 10);
|
||||
$areaCode = substr($phoneNumber, -10, 3);
|
||||
$nextThree = substr($phoneNumber, -7, 3);
|
||||
$lastFour = substr($phoneNumber, -4, 4);
|
||||
|
||||
$phoneNumber = '+' . $countryCode . ' (' . $areaCode . ') ' . $nextThree . '-' . $lastFour;
|
||||
} else if (strlen($phoneNumber) == 10) {
|
||||
$areaCode = substr($phoneNumber, 0, 3);
|
||||
$nextThree = substr($phoneNumber, 3, 3);
|
||||
$lastFour = substr($phoneNumber, 6, 4);
|
||||
|
||||
$phoneNumber = '(' . $areaCode . ') ' . $nextThree . '-' . $lastFour;
|
||||
} else if (strlen($phoneNumber) == 7) {
|
||||
$nextThree = substr($phoneNumber, 0, 3);
|
||||
$lastFour = substr($phoneNumber, 3, 4);
|
||||
|
||||
$phoneNumber = $nextThree . '-' . $lastFour;
|
||||
}
|
||||
|
||||
return ltrim($phoneNumber, '0');
|
||||
}
|
||||
|
||||
function return_jour($id)
|
||||
{
|
||||
$tab_jour[0] = "Samedi";
|
||||
$tab_jour[1] = "Dimanche";
|
||||
$tab_jour[2] = "Lundi";
|
||||
$tab_jour[3] = "Mardi";
|
||||
$tab_jour[4] = "Mercredi";
|
||||
$tab_jour[5] = "Jeudi";
|
||||
$tab_jour[6] = "Vendredi";
|
||||
|
||||
return substr($tab_jour[$id], 0, 3);
|
||||
}
|
||||
|
||||
function label($text, $options = "")
|
||||
{
|
||||
return "<label $options>$text</label>";
|
||||
}
|
||||
|
||||
function article($text, $options = "")
|
||||
{
|
||||
return "<article $options>$text</article>";
|
||||
}
|
||||
function button($text, $options = "")
|
||||
{
|
||||
return "<button $options>$text</button>";
|
||||
}
|
||||
|
||||
function section($text, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<section $optionsContent>$text</section>";
|
||||
}
|
||||
function canvas($text, $options = "")
|
||||
{
|
||||
return "<canvas $options>$text</canvas>";
|
||||
}
|
||||
|
||||
function headerTag($text, $options = "")
|
||||
{
|
||||
return "<header $options>$text</header>";
|
||||
}
|
||||
|
||||
function nav($text, $options = "")
|
||||
{
|
||||
$optionsContent = generateData($options);
|
||||
|
||||
return "<nav $optionsContent>$text</nav>";
|
||||
}
|
||||
|
||||
function footer($text, $options = "")
|
||||
{
|
||||
return "<footer $options>$text</footer>";
|
||||
}
|
||||
|
||||
function encrypt_decrypt($action, $string)
|
||||
{
|
||||
$output = false;
|
||||
|
||||
$encrypt_method = "AES-256-CBC";
|
||||
$secret_key = _CRYPT_KEY;
|
||||
$secret_iv = _CRYPT_IV;
|
||||
|
||||
$key = hash('sha256', $secret_key);
|
||||
$iv = substr(hash('sha256', $secret_iv), 0, 16);
|
||||
|
||||
if ($action == 'encrypt') {
|
||||
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
|
||||
$output = base64_encode($output);
|
||||
} else if ($action == 'decrypt') {
|
||||
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function generateData($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
if ($options[0] === null) {
|
||||
$dataArray = $options;
|
||||
} else {
|
||||
$dataArray = $options[1];
|
||||
$optionsContent .= $options[0];
|
||||
}
|
||||
|
||||
if (count($dataArray) > 0) {
|
||||
foreach ($dataArray as $key => $data) {
|
||||
$optionsContent .= 'data-' . $key . '="' . $data . '" ';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$optionsContent = $options;
|
||||
}
|
||||
|
||||
return $optionsContent;
|
||||
}
|
||||
|
||||
function send404()
|
||||
{
|
||||
if ($_SESSION[_AUTH_VAR]->SessVar['content-type'] == 'JSON') {
|
||||
http_response_code(404);
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Content-type: application/json');
|
||||
$ret['status'] = 'error-notfound';
|
||||
die(json_encode($ret));
|
||||
} else {
|
||||
http_response_code(404);
|
||||
}
|
||||
}
|
||||
|
||||
function swheader($name = '', $hasControls = '')
|
||||
{
|
||||
return div(
|
||||
htmlLink(span(_('Open/close menu')), 'javascript:', 'class="toggle-menu button-link-blue trigger-menu"')
|
||||
. div($controlsContent, $name . 'ControlsList', "class='custom-controls " . $hasControls . "'")
|
||||
. $_SESSION['ccSwCustom'],
|
||||
'',
|
||||
'class="sw-header"'
|
||||
);
|
||||
}
|
||||
|
||||
function preprint(array $array)
|
||||
{
|
||||
echo pre(print_r($array, true));
|
||||
}
|
||||
1
includes/index.php
Normal file
1
includes/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
||||
Reference in New Issue
Block a user