Example #1
0
 /**
  * Set default panel
  *
  * @param string $title
  * @return \FrenchFrogs\Core\Panel
  */
 public function useDefaultPanel($title = '')
 {
     /** @var $panel \FrenchFrogs\Polliwog\Panel\Panel\Panel */
     $panel = configurator()->get('panel.class');
     $panel = new $panel();
     $panel->setTitle(strval($title));
     return $this->setPanel($panel);
 }
Example #2
0
 /**
  * Constructror
  *
  * @param $name
  * @param string $label
  * @param array $attr
  */
 public function __construct($name, $label = '', $format = null, $attr = [])
 {
     parent::__construct($name, $label, $attr);
     $this->center();
     if (is_null($format)) {
         $format = configurator()->get('table.column.date.format');
     }
     $this->addFilter('dateFormat', 'dateFormat', $format);
 }
Example #3
0
 /**
  * Constructror
  *
  * @param $name
  * @param string $label
  * @param array $attr
  */
 public function __construct($name, $label = '', $attr = [])
 {
     $this->setRemoteId(configurator()->get('modal.remote.id', $this->remoteId));
     $this->setAttributes($attr);
     $this->setName($name);
     $this->setLabel($label);
     $this->setOptionAsDefault();
     $this->disableIconOnly();
 }
Example #4
0
 /**
  * Constructor
  *
  * @param $name
  * @param string $label
  * @param array $attr
  */
 public function __construct($name, $label = '', $formatDisplay = null, $formatStore = null, $attr = [])
 {
     $this->setAttributes($attr);
     $this->setName($name);
     $this->setLabel($label);
     $this->addAttribute('data-date-format', configurator()->get('form.element.date.formatjs'));
     $this->setFormatDisplay(is_null($formatDisplay) ? configurator()->get('form.element.date.formatDisplay') : $formatDisplay);
     $this->setFormatStore(is_null($formatStore) ? configurator()->get('form.element.date.formatStore') : $formatStore);
     $this->addFilter('dateFormat', 'dateFormat', $this->getFormatDisplay());
 }
Example #5
0
/**
 * Return auth user information
 *
 * @return mixed
 */
function user($info = null)
{
    // if $info is not null we send the wanted info
    if (!is_null($info)) {
        $user = \auth()->user()->{$info};
    } else {
        $user = \configurator()->build('user.business.class', \FrenchFrogs\Models\Business\User::class, [\auth()->user()->user_id]);
    }
    return $user;
}
Example #6
0
 public function renderNavigation()
 {
     if (!$this->hasRenderer()) {
         $renderer = configurator()->build('ruler.renderer.class');
         $this->setRenderer($renderer);
     }
     $render = '';
     try {
         $render = $this->getRenderer()->render('navigation', $this);
     } catch (\Exception $e) {
         dd($e->getMessage());
         //@todo find a good way to warn the developper
     }
     return $render;
 }
Example #7
0
 public function __construct()
 {
     $renderer = configurator()->get('panel.renderer.class');
     $this->setRenderer(new $renderer());
     $this->setContextAsDefault();
 }
Example #8
0
 /**
  * Add toastr success message
  *
  * @param $body
  * @param string $title
  * @return $this
  */
 public function error($body = '', $title = '')
 {
     $body = empty($body) ? configurator()->get('toastr.error.default') : $body;
     $this->append([static::TYPE_INLINE, sprintf('toastr.error("%s", "%s");', $body, $title)]);
     return $this;
 }
Example #9
0
 /**
  * Add default delete button
  *
  * @param string $link
  * @param array $binds
  * @param array $attr
  * @return \FrenchFrogs\Table\Column\Button
  */
 public function addButtonDelete($link = '#', $binds = [], $is_remote = true, $method = 'delete')
 {
     $c = new Column\Button(configurator()->get('button.delete.name'), configurator()->get('button.delete.label'), $link, $binds);
     $c->setOptionAsDanger();
     $c->icon(configurator()->get('button.delete.icon'));
     if ($is_remote) {
         $c->enableRemote($method);
     }
     $this->addColumn($c);
     return $c;
 }
Example #10
0
 /**
  * Constructeur
  *
  * @param null $title
  * @param null $body
  * @param null $actions
  */
 public function __construct($title = null, $body = null, $actions = null)
 {
     $this->setBackdrop(configurator()->get('modal.backdrop'));
     $this->setEscToClose(configurator()->get('modal.backdrop'));
     $this->setCloseButtonLabel(configurator()->get('modal.closeButtonLabel', $this->closeButtonLabel));
     if (!is_null($title)) {
         $this->setTitle($title);
     }
     if (!is_null($body)) {
         $this->setBody($body);
     }
     if (!is_null($actions)) {
         $actions = (array) $actions;
         $this->setActions($actions);
     }
     // Renderer
     $renderer = configurator()->get('modal.renderer.class');
     $this->setRenderer(new $renderer());
 }
Example #11
0
/**
 * Return new modal polliwog
 *
 * @param ...$args
 * @return Polliwog\modal\Modal\Bootstrap
 */
function modal(...$args)
{
    // retrieve the good class
    $class = configurator()->get('modal.class', Polliwog\Modal\Modal\Bootstrap::class);
    // build the instance
    $reflection = new ReflectionClass($class);
    return $reflection->newInstanceArgs($args);
}
Example #12
0
 /**
  * Shortcut pour l'ajout de filtre
  *
  * @param $filters
  * @return $this
  */
 public function setFilters($filters)
 {
     if (!$this->hasFilterer()) {
         $this->setFilterer(configurator()->build('form.filterer.class'));
     }
     $this->getFilterer()->setFilters($filters);
     return $this;
 }
Example #13
0
 /**
  * Constructor
  *
  * @param string $url
  * @param string $method
  */
 public function __construct()
 {
     /*
      * Default configuration
      */
     if (!$this->hasRenderer()) {
         $class = configurator()->get('table.renderer.class');
         $this->setRenderer(new $class());
     }
     if (!$this->hasFilterer()) {
         $class = configurator()->get('table.filterer.class');
         $this->setFilterer(new $class());
     }
     if (!$this->hasUrl()) {
         $this->setUrl(request()->url());
     }
     $this->enableBordered();
     // if method "init" exist, we call it.
     if (method_exists($this, 'init')) {
         call_user_func_array([$this, 'init'], func_get_args());
     } elseif (func_num_args() == 1) {
         $this->setSource(func_get_arg(0));
     }
     // Force id html attribute
     if (!$this->hasAttribute('id')) {
         $this->addAttribute('id', 'table-' . rand());
     }
 }
Example #14
0
 /**
  * Constructor
  *
  * @param string $url
  * @param string $method
  */
 public function __construct()
 {
     // if method "init" exist, we call it.
     if (method_exists($this, 'init')) {
         call_user_func_array([$this, 'init'], func_get_args());
     } elseif (func_num_args() == 1) {
         $this->setSource(func_get_arg(0));
     }
     if (!$this->hasRenderer()) {
         $class = configurator()->get('table.renderer.class');
         $this->setRenderer(new $class());
     }
 }
Example #15
0
 /**
  * Render a date range element
  *
  * @param Form\Element\DateRange $element
  */
 public function date_range(Form\Element\DateRange $element)
 {
     // CLASS
     $class = Style::FORM_GROUP_CLASS;
     // ERROR
     if ($hasError = !$element->getValidator()->isValid()) {
         if (empty($element->getAttribute('data-placement'))) {
             $element->addAttribute('data-placement', 'bottom');
         }
         $message = '';
         foreach ($element->getValidator()->getErrors() as $error) {
             $message .= $error . ' ';
         }
         $element->addAttribute('data-original-title', $message);
         $element->addAttribute('data-toggle', 'tooltip');
         $class .= ' ' . Style::FORM_GROUP_ERROR;
     }
     // LABEL
     $label = '';
     if ($element->getForm()->hasLabel()) {
         $label = '<label for="' . $element->getName() . '" class="col-md-3 control-label">' . $element->getLabel() . ($element->hasRule('required') ? ' *' : '') . '</label>';
     }
     $html = html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getFrom()]);
     $html .= '<span class="input-group-addon"> => </span>';
     $html .= html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getTo()]);
     $html = html('div', ['class' => 'input-group input-large date-picker daterange input-daterange', 'data-date-format' => configurator()->get('form.element.date.formatjs')], $html);
     // DESCRIPTION
     if ($element->hasDescription()) {
         $html .= html('span', ['class' => 'help-block'], $element->getDescription());
     }
     // FINAL CONTAINER
     $html = html('div', ['class' => 'col-md-9'], $html);
     return html('div', compact('class'), $label . $html);
 }
Example #16
0
 /**
  *
  *
  * @param $index
  * @param null $method
  * @param ...$params
  */
 public function addFilter($index, $method = null, ...$params)
 {
     if (!$this->hasFilterer()) {
         $this->setFilterer(configurator()->build('table.filterer.class'));
     }
     array_unshift($params, $index, $method);
     call_user_func_array([$this->getFilterer(), 'addFilter'], $params);
     return $this;
 }
Example #17
0
 /**
  * Magic method for exceptional use
  *
  * @param $name
  * @param $arguments
  */
 function __call($name, $arguments)
 {
     if (preg_match('#add(?<type>\\w+)#', $name, $match)) {
         // cas des action
         if (substr($match['type'], 0, 6) == 'Action') {
             $type = substr($match['type'], 6);
             $class = new \ReflectionClass(__NAMESPACE__ . '\\Element\\' . $type);
             $e = $class->newInstanceArgs($arguments);
             $this->addAction($e);
             // cas des element
         } else {
             $namespace = __NAMESPACE__;
             if (!empty(configurator()->get('form.namespace'))) {
                 $namespace = configurator()->get('form.namespace');
             }
             $class = new \ReflectionClass($namespace . '\\Element\\' . $match['type']);
             $e = $class->newInstanceArgs($arguments);
             $this->addElement($e);
         }
     }
 }
Example #18
0
/**
 * Return ruler polliwog
 *
 * @return \FrenchFrogs\Ruler\Ruler\Ruler
 */
function ruler()
{
    // retrieve the good class
    $class = configurator()->get('ruler.class', FrenchFrogs\Ruler\Ruler\Ruler::class);
    return $class::getInstance();
}
Example #19
0
 /**
  * Maker constructor.
  */
 public function __construct()
 {
     // CONFIGURATION
     if (!$this->hasRenderer()) {
         $class = configurator()->get('maker.renderer.class');
         $this->setRenderer(new $class());
     }
 }
Example #20
0
 /**
  * Constructor
  *
  * @param $name
  * @param string $label
  * @param string $link
  * @param array $binds
  * @param array $attr
  */
 public function __construct($name, $label = '%s', $link = '#', $binds = [], $attr = [])
 {
     $this->setRemoteId(configurator()->get('modal.remote.id', $this->remoteId));
     $this->setAttributes($attr);
     $this->setName($name);
     $this->setLabel($label);
     $this->setLink($link);
     $this->setBinds((array) $binds);
 }
 /**
  * Modal Manager
  *
  * Gestion des reponse ajax qui s'affiche dans une modal
  *
  */
 public function bootModal()
 {
     Response::macro('modal', function ($title, $body = '', $actions = []) {
         if ($title instanceof FrenchFrogs\Modal\Modal\Modal) {
             $modal = $title->enableRemote();
         } elseif ($title instanceof FrenchFrogs\Form\Form\Form) {
             $renderer = configurator()->get('form.renderer.modal.class');
             $modal = $title->setRenderer(new $renderer());
         } else {
             $modal = modal($title, $body, $actions)->enableRemote();
         }
         $modal .= '<script>jQuery(function() {' . js('onload') . '});</script>';
         return $modal;
     });
 }
Example #22
0
 /**
  * Render a striner for a text element
  *
  * @param Column\Strainer\Text $strainer
  * @return string
  */
 public function strainerDateRange(Column\Strainer\DateRange $strainer)
 {
     $element = $strainer->getElement();
     $html = html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getFrom()]);
     $html .= '<span class="input-group-addon">-</span>';
     $html .= html('input', ['type' => 'text', 'class' => Style::FORM_ELEMENT_CONTROL, 'name' => $element->getTo()]);
     return html('div', ['name' => $element->getName(), 'class' => 'input-group date-picker daterange input-daterange text-center', 'data-date-format' => configurator()->get('form.element.date.formatjs')], $html);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle(Filesystem $filesystem, Composer $composer)
 {
     // validation declaration
     $validator = \Validator::make(['permission' => $permission = $this->argument('permission')], ['permission' => 'required|not_exists:user_permission,user_permission_id']);
     // check if argument are valid
     if ($validator->fails()) {
         $this->error($validator->getMessageBag()->toJson());
         return;
     }
     $this->info('Nous allons créer ensemble une migration');
     $rulerClass = $this->ask('Quelle est la classe de gestion des Acl?', configurator()->get('ruler.class'));
     $ruler = Maker::load($rulerClass);
     // NOM
     $nice_permission = str_replace('.', '_', $permission);
     $constant = $this->ask('Nom de la constante?', 'PERMISSION_' . strtoupper($nice_permission));
     $constant = strtoupper($constant);
     // ANALYSE DES CONSTANTES
     $groups = $interfaces = [];
     $interfaces['INTERFACE_DEFAULT'] = $rulerClass::INTERFACE_DEFAULT;
     foreach ($ruler->getConstants() as $name => $value) {
         if (preg_match('#^PERMISSION_GROUP_.+#', $name)) {
             $groups[$name] = $value;
         } else {
             if (preg_match('#^INTERFACE_.+#', $name) && $name != 'INTERFACE_DEFAULT') {
                 $interfaces[$name] = $value;
             } elseif ($value == $permission) {
                 // si on remarque que la permission existe deja
                 exc('La permission "' . $permission . '" existe déjà avec le nom : ' . $name);
             } elseif ($name == $constant) {
                 // si on remarque que la permission existe deja
                 exc('Le nom "' . $permission . '" existe déjà avec la permission : ' . $value);
             }
         }
     }
     $interface = $this->choice('A quelle interface voulez vous rattacher cette permission?', array_values($interfaces), 0);
     $interface = array_search($interface, $interfaces);
     // GROUP
     $group = $this->choice('A quel groupe voulez vous rattacher cette permission?', array_values($groups));
     $group = array_search($group, $groups);
     // création de la constante
     $ruler->addConstant($constant, $permission);
     $ruler->write();
     $label = strrpos($permission, '.');
     $label = $label ? substr($permission, $label + 1) : $permission;
     $label = $this->ask('Quelle est le libellé de cette Permission?', ucfirst($label));
     // Creation de la migration
     $this->info('Creation de la migration');
     $filename = 'create_permission_' . $nice_permission . '_' . \uuid('hex');
     $filepath = storage_path('tmp/') . $filename;
     $filesystem->delete($filepath);
     // CLASS
     $maker = Maker::init(camel_case($filename), $filepath);
     $maker->addAlias('Acl', $ruler->getClass()->getName());
     $maker->addAlias('Migration', Migration::class);
     $maker->setParent(Migration::class);
     $maker->setSummary('Migration pour l\'ajout de la permission "' . $permission . '" en base de donnée');
     // METHOD
     $method = $maker->addMethod('up');
     $body = sprintf('Acl::createDatabasePermission(Acl::%s, Acl::%s, Acl::%s, \'%s\');', $constant, $group, $interface, $label);
     $method->setBody($body);
     // FICHIER DE MIGRATION
     $path = $this->laravel->databasePath() . '/migrations';
     $fullPath = $this->laravel['migration.creator']->create($filename, $path);
     $filesystem->put($fullPath, '<?php ' . $maker->render());
     $filesystem->delete($filepath);
     $this->info('Migration created successfully!');
     $composer->dumpAutoloads();
     $this->info('Have fun!!');
 }
Example #24
0
 /**
  * Constructeur
  *
  * @param null $title
  * @param null $body
  * @param null $actions
  */
 public function __construct($title = null, $body = null, $actions = null)
 {
     configurator()->get('modal.backdrop') ? $this->enableBackdrop() : $this->disableBackdrop();
     configurator()->get('modal.backdrop') ? $this->enableEscToClose() : $this->disableEscToClose();
     $this->setCloseButtonLabel(configurator()->get('modal.closeButtonLabel', $this->closeButtonLabel));
     configurator()->get('modal.is_remote') ? $this->enableRemote() : $this->disableRemote();
     $this->setRemoteId(configurator()->get('modal.remote.id', $this->remoteId));
     if (!is_null($title)) {
         $this->setTitle($title);
     }
     if (!is_null($body)) {
         $this->setBody($body);
     }
     if (!is_null($actions)) {
         $actions = (array) $actions;
         $this->setActions($actions);
     }
     // Renderer
     $renderer = configurator()->get('modal.renderer.class');
     $this->setRenderer(new $renderer());
 }