/**
     * Carousel helper => generate a carousel helpers
     *
     * @param       $data
     * @param array $params
     * @param null  $formatContent
     *
     * @return string
     */
    public static function carousel($data, $params = array(), $formatContent = null)
    {
        $defaults = array('parent@' => array('id' => 'carousel', 'class' => 'carousel slide', 'data-interval' => 'false', 'data-wrap' => 'true'), 'child@' => array('class' => 'item'), 'item_per_slide' => 1, 'icon_prev' => 'icon-prev', 'icon_next' => 'icon-next');
        $params = Arr::merge($defaults, $params);
        $pagination = '<li data-target="#' . $params['parent@']['id'] . '" data-slide-to="0" class="active"></li>';
        $slides = '<div class="' . $params['child@']['class'] . ' active">';
        $hideNav = $params['item_per_slide'] >= count($data) ? true : false;
        if (!is_array($data)) {
            return null;
        }
        $i = 0;
        foreach ($data as $key => $post) {
            if ($i > 0 && $i % $params['item_per_slide'] == 0) {
                $pagination .= '<li data-target="#' . $params['parent@']['id'] . '" data-slide-to="' . $i / intval($params['item_per_slide']) . '"></li>';
                $slides .= '</div><div' . Html::attributes($params['child@']) . '>';
            }
            if (is_null($formatContent)) {
                $slides .= '<div' . Html::attributes($params['child@']) . '>' . $post . '</div>';
            } elseif (is_callable($formatContent)) {
                $slides .= $formatContent($post, $params, $i);
            }
            $i++;
        }
        $slides .= '</div>';
        if ($hideNav) {
            $output = '<div ' . Html::attributes($params['parent@']) . '><div class="carousel-inner">' . $slides . '</div></div><!--/ #' . $params['parent@']['id'] . ' -->';
        } else {
            $output = '<div ' . Html::attributes($params['parent@']) . '>
                <ol class="carousel-indicators">' . $pagination . '</ol>

                <div class="carousel-inner">' . $slides . '</div>

                <a class="left carousel-control" href="#' . $params['parent@']['id'] . '" data-slide="prev"><span class="' . $params['icon_prev'] . '"></span></a>
                <a class="right carousel-control" href="#' . $params['parent@']['id'] . '" data-slide="next"><span class="' . $params['icon_next'] . '"></span></a>
            </div><!--/ #' . $params['parent@']['id'] . ' -->';
        }
        return $output;
    }
Exemple #2
0
 public static function config($param = array())
 {
     $default = array('driver' => 'smtp', 'host' => getenv('SERVER_NAME'), 'port' => 25, 'from' => array('address' => 'no-reply@' . getenv('SERVER_NAME'), 'name' => 'No Reply'), 'encryption' => 'tls', 'username' => '', 'password' => '', 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => false);
     $config = Arr::merge($default, $param);
     $t = self::getInstance();
     switch ($config['driver']) {
         case 'smtp':
             extract($config);
             // The Swift SMTP transport instance will allow us to use any SMTP backend
             // for delivering mail such as Sendgrid, Amazon SMS, or a custom server
             // a developer has available. We will just pass this configured host.
             $transport = SmtpTransport::newInstance($config['host'], $config['port']);
             if (isset($config['encryption'])) {
                 $transport->setEncryption($config['encryption']);
             }
             // Once we have the transport we will check for the presence of a username
             // and password. If we have it we will set the credentials on the Swift
             // transporter instance so that we'll properly authenticate delivery.
             if (isset($username)) {
                 $transport->setUsername($config['username']);
                 $transport->setPassword($config['password']);
             }
             $t->_transport = $transport;
             break;
         case 'sendmail':
             $t->_transport = SendmailTransport::newInstance($config['sendmail']);
             break;
         case 'mail':
             $t->_transport = MailTransport::newInstance();
             break;
         default:
             throw new \InvalidArgumentException('Invalid mail driver.');
     }
     $t->_mailer = Swift_Mailer::newInstance($t->_transport);
     return $t;
 }
Exemple #3
0
 /**
  * Set the flash element
  *
  * @param $options
  * @param $settings
  * @return $this
  */
 public function set($options = ['icon' => null, 'title' => null, 'message' => '', 'url' => null, 'target' => null], $settings = [])
 {
     $settings = Arr::merge($this->settings, $settings);
     $this->session->flash('notify.options', $options);
     $this->session->flash('notify.settings', $settings);
     $this->hook->put('__app.notify.options', $options);
     $this->hook->put('__app.notify.settings', $settings);
     return $this;
 }
 /**
  * Set body attributes
  */
 public function setBodyAttributes($layout, $data = array())
 {
     $data = Arr::merge($data, array('body' => array('attributes' => array('class' => static::$tplPrefixClass . str_replace(array('::', '.'), '-', $layout)))));
     $data = $this->getCommonVars($data);
     view()->share('body', $data['body']);
     return $data;
 }
Exemple #5
0
 /**
  * Load single or multiple file configuration.
  *
  * @param string $mPath      Array of path or string
  * @param string $sNamespace String used as reference (ex. Config::get('namespace.paths.classes'))
  *
  * @return object
  *
  * @example
  * Config::instance()->load('paths.adapters', 'defaults'); // dot-notated query url in configuration paths
  * Config::instance()->load('some/path/to/your/configuration/file.php');
  * Config::instance()->load('some/path/to/your/configuration/folder/');
  */
 public static function load($mPath, $sNamespace = null)
 {
     # Check if $mPath is an array of path
     if (is_array($mPath) && !empty($mPath)) {
         $aFiles = $mPath;
     } elseif (strpos($mPath, '.') > 0 && !is_null(Arr::get(static::$aSettings, $mPath))) {
         $tmp = Arr::get(static::$aSettings, $mPath);
         $aFiles = glob(substr($tmp, -1) === '/' ? $tmp . '*.php' : $tmp);
     } else {
         $aFiles = glob(substr($mPath, -1) === '/' ? $mPath . '*.php' : $mPath);
     }
     foreach ($aFiles as $sFilePath) {
         $pathinfo = pathinfo($sFilePath);
         $key = !is_null($sNamespace) ? $sNamespace . '.' . $pathinfo['filename'] : $pathinfo['filename'];
         if (!is_int(array_search($sFilePath, $aFiles))) {
             $key = array_search($sFilePath, $aFiles);
         }
         if (!is_null(Arr::get(static::$aSettings, $key))) {
             static::set($key, Arr::merge(static::get($key), include $sFilePath));
         } elseif (is_file($sFilePath)) {
             static::set($key, include $sFilePath);
         }
     }
     return static::getInstance();
 }
Exemple #6
0
 /**
  * Random an array
  *
  * @param array $array
  * @param array $param
  * @return string
  */
 public static function randArray(array $array, $param = array())
 {
     if (!is_array($param)) {
         $param = json_decode($param, true);
     }
     $defParam = array();
     $param = Arr::merge($defParam, $param);
     # Define the number of element to take
     if (!empty($param['take'])) {
         $response = array();
         for ($i = 1; $i <= $param['take']; $i++) {
             $response[] = $array[array_rand($array, 1)];
         }
         return $response;
     } else {
         # Return randomly only 1 element value of the array
         return $array[array_rand($array, 1)];
     }
 }
Exemple #7
0
 /**
  * Create a text input field.
  *
  * @param string $name
  * @param string $value
  * @param array $options
  * @return string
  * @static
  */
 public static function text($name, $value = null, $options = array())
 {
     $defOptions = array('class' => 'form-control');
     $options = Arr::merge($defOptions, $options);
     return self::resolve($name, $value, $options);
 }
 /**
  * Same than View make but injects common vars
  *
  * @param $layout
  * @param array $data
  * @return \Illuminate\View\View
  */
 public function viewMake($layout, $data = array())
 {
     $data = Arr::merge($data, array('body' => array('attributes' => array('class' => static::$tplPrefixClass . str_replace(array('::', '.'), '-', $layout)))));
     $data = $this->getCommonVars($data);
     return View::make($layout, $data);
 }
Exemple #9
0
 public static function configMysql($param = array())
 {
     $default = array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '');
     return Arr::merge($default, $param);
 }