Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $message->setSender(Config::get('mailer.global.address', 'mailer@' . SITE_NAME . '.com'), Config::get('mailer.global.sender', SITE_NAME));
     $headers = $message->getHeaders();
     $headers->addTextHeader('X-Mailer', Config::get('mailer.app.version', SITE_NAME . ' Mailer v1.2'));
     $headers->addTextHeader('X-MC-Track', Config::get('mailer.global.track', 'clicks_textonly'));
     $message = (string) $message;
     $message = str_replace('swift', SITE_NAME, $message);
     // $res = $client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', [
     // 	'body' 				=> [
     // 		'key' 			=> $this->key,
     // 		'raw_message' 	=> (string) $message,
     // 		'async'			=> true,
     // 	],
     // ]);
     $arguments = ['body' => ['key' => $this->key, 'raw_message' => (string) $message, 'async' => true]];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json');
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('key' => $this->key, 'raw_message' => (string) $message, 'async' => true)));
     $response = curl_exec($ch);
     // catch errors
     if (curl_errno($ch)) {
         #$errors = curl_error($ch);
         curl_close($ch);
         // return false
         return false;
     } else {
         curl_close($ch);
         // return array
         return json_decode($response, true);
     }
 }
Esempio n. 2
0
 public function run()
 {
     if (fnmatch('*cli*', php_sapi_name())) {
         $dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules');
         if (is_dir($dir)) {
             Timer::start();
             Cli::show("Start of execution", 'COMMENT');
             $files = glob($dir . DS . '*.php');
             foreach ($files as $file) {
                 require_once $file;
                 $object = str_replace('.php', '', Arrays::last(explode(DS, $file)));
                 $class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule'));
                 $instance = lib('app')->make($class);
                 $methods = get_class_methods($instance);
                 Cli::show("Start schedule '{$object}'", 'COMMENT');
                 foreach ($methods as $method) {
                     $when = $this->getWhen($instance, $method);
                     $isDue = $this->isDue($object, $method, $when);
                     if (true === $isDue) {
                         Cli::show("Execution of {$object}->{$method}", 'INFO');
                         $instance->{$method}();
                     } else {
                         Cli::show("No need to execute {$object}->{$method}", 'QUESTION');
                     }
                 }
             }
             Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS');
             Cli::show("end of execution", 'COMMENT');
         }
     }
 }
Esempio n. 3
0
 public function __construct($db)
 {
     $this->orm = $db;
     $this->db = $db->db();
     $this->table = $db->table();
     $dir = Config::get('dir.blizz.store', session_save_path());
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     $file = $this->dir . DS . 'data.db';
     $new = false;
     if (!is_file($file)) {
         File::create($file);
         $new = true;
         File::put($this->dir . DS . 'age.blizz', '');
     }
     $link = new SQLite3($file);
     Now::set("blizz.link.{$this->db}.{$this->table}", $link);
     if ($new) {
         $this->init();
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     $this->locale = session('web')->getLanguage();
     $this->db = rdb('lang', 'dictionary');
     $defaultLng = Config::get('application.language', DEFAULT_LANGUAGE);
     $this->mustTranslate = $defaultLng != $this->locale;
 }
Esempio n. 5
0
 public function __construct($ns = 'core.cache')
 {
     $this->lite = new mysqli(Config::get('database.host', '127.0.0.1'), Config::get('database.username', 'root'), Config::get('database.password', 'root'), Config::get('database.database', SITE_NAME));
     $this->table = $table = str_replace('.', '_', $ns) . '_my';
     $q = "CREATE TABLE IF NOT EXISTS {$table} (k VARCHAR (255) PRIMARY KEY, v LONGTEXT, ts INT (20) UNSIGNED);";
     $res = $this->raw($q);
 }
Esempio n. 6
0
 private function client()
 {
     defined("APPLICATION_ENV") || define('APPLICATION_ENV', 'production');
     if (is_null($this->client)) {
         $this->client = new pc(['host' => Config::get('redys.host', '127.0.0.1'), 'port' => Config::get('redys.port', 6379), 'database' => Config::get('redys.database', 4)]);
     }
     return $this->client;
 }
Esempio n. 7
0
 public function getContent()
 {
     $session = session('social_twitter');
     $token = $session->getToken();
     $secret = $session->getSecret();
     $connection = new TwitterOAuth(Config::get('twitter.key'), Config::get('twitter.secret'), $token, $secret);
     $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
     $session->setAccess($access_token);
     return $connection->get('account/verify_credentials');
 }
Esempio n. 8
0
 public function __construct($collection, $dbCluster = 'default')
 {
     $this->db = new OrientDB('localhost', Config::get('orientdb.port', 2424));
     $this->cnx = $this->db->connect(Config::get('orientdb.user', 'root'), Config::get('orientdb.password', 'root'));
     $clusters = $this->db->DBOpen($collection, 'admin', Config::get('orientdb.password', 'root'));
     foreach ($clusters['clusters'] as $cluster) {
         if ($cluster->name === $dbCluster) {
             $this->cluster = $cluster;
         }
     }
 }
Esempio n. 9
0
 public function __construct($ns = 'core.cache')
 {
     $dir = Conf::get('dir.nosql.store', STORAGE_PATH . DS . 'nosql');
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $this->dir = $dir . DS . $ns;
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
 }
Esempio n. 10
0
 public function getContent()
 {
     $serviceFactory = new ServiceFactory();
     $storage = new OauThSession();
     $credentials = new Credentials(Config::get('google.key'), Config::get('google.secret'), URLSITE . 'google/auth');
     $googleService = $serviceFactory->createService('google', $credentials, $storage, array('userinfo_email', 'userinfo_profile'));
     $state = isset($_GET['state']) ? $_GET['state'] : null;
     // This was a callback request from google, get the token
     $googleService->requestAccessToken($_GET['code'], $state);
     // Send a request with it
     return json_decode($googleService->request('userinfo'), true);
 }
Esempio n. 11
0
 public function __construct($db, $table)
 {
     $config = Config::get('mdo.config.' . $db, []);
     if (empty($config)) {
         $config = ['driver' => Config::get('database.adapter', 'mysql'), 'host' => Config::get('database.host', '127.0.0.1'), 'database' => Config::get('database.dbname', SITE_NAME), 'username' => Config::get('database.username', 'root'), 'password' => Config::get('database.password', 'root'), 'charset' => Config::get('database.charset', 'utf8'), 'collation' => Config::get('database.collation', 'utf8_unicode_ci'), 'prefix' => Config::get('database.prefix', '')];
     }
     if (empty($config)) {
         throw new Exception('No config provided to launch motor.');
     }
     $this->db = mysqli_connect($config['host'], $config['username'], $config['password'], $config['database']);
     $this->table = $table;
     $this->database = $db;
 }
Esempio n. 12
0
 /**
  * Instantiates the Resizer and receives the path to an image we're working with.
  * @param mixed $file The file array provided by a path to a file
  */
 function __construct($file)
 {
     // Load the config from the main application first, if it's not available
     Config::load('sizer');
     $this->config = Config::get('sizer');
     // Open up the file.
     $this->image = $this->openImage($file);
     if (!$this->image) {
         throw new Exception('File not recognised. Possibly because the path is wrong. Keep in mind, paths are relative to the main index.php file.');
     }
     // Get width and height of our image.
     $this->width = imagesx($this->image);
     $this->height = imagesy($this->image);
 }
Esempio n. 13
0
 public function __construct($db, $table)
 {
     $dir = Config::get('mlite.dir.' . $db, STORAGE_PATH . DS . $db . '.db');
     $new = !is_file($dir);
     if (!is_file($dir)) {
         File::create($dir);
     }
     $this->db = new SQLite3($dir);
     if ($new) {
         $q = "CREATE TABLE infosdb (data_key VARCHAR PRIMARY KEY, data_value);";
         $this->db->exec($q);
     }
     $this->table = $table;
     $this->database = $db;
 }
Esempio n. 14
0
 public function __construct($db, $table)
 {
     $file = Config::get('mlite.dir.' . $db, STORAGE_PATH . DS . $db . '.db');
     $new = !is_file($file);
     if (!is_file($file)) {
         File::create($file);
     }
     $link = new SQLite3($file);
     Now::set("lite.link.{$db}.{$table}", $link);
     if ($new) {
         $q = "CREATE TABLE IF NOT EXISTS infosdb (data_key VARCHAR PRIMARY KEY, data_value);";
         $res = $link->exec($q);
     }
     $this->table = $table;
     $this->database = $db;
 }
Esempio n. 15
0
 public function __construct($ns = null)
 {
     $ns = is_null($ns) ? forever() : $ns;
     $this->ns = $ns;
     $host = Config::get('mongo.host', '127.0.0.1');
     $port = Config::get('mongo.port', 27017);
     $protocol = Config::get('mongo.protocol', 'mongodb');
     $auth = Config::get('mongo.auth', true);
     $user = Config::get('mongo.username', SITE_NAME . '_master');
     $password = Config::get('mongo.password');
     $this->connect($protocol, $user, $password, $host, $port);
     if (!isset(self::$instances[$ns])) {
         self::$instances[$ns] = $this;
     }
     $odm = $this->cnx->selectDB('keep');
     $this->db = $odm->selectCollection($ns);
 }
Esempio n. 16
0
 public function __construct($db, $table, $config = [])
 {
     $db = strtolower($db);
     $table = strtolower($table);
     $this->db = $db;
     $this->table = $table;
     $this->collection = "{$db}.{$table}";
     $host = Config::get('database.host', isAke($config, 'host', '127.0.0.1'));
     $port = Config::get('database.port', isAke($config, 'port', 3306));
     $adapter = Config::get('database.adapter', isAke($config, 'adapter', 'mysql'));
     $driver = Config::get('database.driver', isAke($config, 'driver', 'pdo_mysql'));
     $username = Config::get('database.username', isAke($config, 'username', 'root'));
     $password = Config::get('database.password', isAke($config, 'password', 'root'));
     $dsn = $adapter . ":dbname=" . $db . ";host=" . $host;
     $this->engine = new PDO($dsn, $username, $password);
     $this->map();
 }
Esempio n. 17
0
 public static function connect()
 {
     $dsn = 'mysql:dbname=' . Config::get('mysql.dbname', ConfigApp::get('database.dbname', SITE_NAME)) . ';host=' . Config::get('mysql.host', ConfigApp::get('database.host', 'localhost'));
     $user = Config::get('mysql.username', ConfigApp::get('database.username', 'root'));
     $password = Config::get('mysql.password', ConfigApp::get('database.password', ''));
     $key = sha1('KVSMYSQL');
     $has = Instance::has('KvsMysql', $key);
     if (true === $has) {
         $instance = Instance::get('KvsMysql', $key);
         self::init($instance);
         return $instance;
     } else {
         $instance = Instance::make('KvsMysql', $key, new PDO($dsn, $user, $password));
         self::init($instance);
         return $instance;
     }
 }
Esempio n. 18
0
 public function __construct($ns)
 {
     $this->ns = $ns;
     $this->collection = "core.cache";
     $host = Conf::get('mongo.host', '127.0.0.1');
     $port = Conf::get('mongo.port', 27017);
     $protocol = Conf::get('mongo.protocol', 'mongodb');
     $auth = Conf::get('mongo.auth', true);
     if (true === $auth) {
         $user = Conf::get('mongo.username', SITE_NAME . '_master');
         $password = Conf::get('mongo.password');
         $this->connect($protocol, $user, $password, $host, $port);
     } else {
         $this->cnx = new MGC($protocol . '://' . $host . ':' . $port, ['connect' => true]);
     }
     $this->clean();
 }
Esempio n. 19
0
 /**
  *
  * @method __construct
  *
  * @param  string
  * @param  array
  */
 public function __construct(array $data = [])
 {
     $ns = $this->ns = $this->forever();
     $file = Config::get('cachemelite.dir.' . $ns, STORAGE_PATH . DS . $ns . '_cache.db');
     $new = !is_file($file);
     if (!is_file($file)) {
         File::create($file);
     }
     $db = new SQLite3($file);
     Now::set("cachemelite.link.{$ns}", $db);
     $q = "CREATE TABLE IF NOT EXISTS cachedb (data_key VARCHAR PRIMARY KEY, data_value);";
     $res = $this->db->exec($q);
     if (!empty($data)) {
         foreach ($data as $k => $v) {
             $this->set($k, $v);
         }
     }
 }
Esempio n. 20
0
 /**
  * Automatically verify Paypal IPN communications.
  *
  * @return  boolean
  */
 public static function ipn()
 {
     // only accept post data
     if (!count($_POST)) {
         return false;
     }
     // if production mode...
     if (Config::get('paypal.production_mode')) {
         // use production endpoint
         $endpoint = 'https://www.paypal.com/cgi-bin/webscr';
     } else {
         // use sandbox endpoint
         $endpoint = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     }
     // build response
     $fields = http_build_query(array('cmd' => '_notify-validate') + Input::all());
     // curl request
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $endpoint);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
     $response = curl_exec($ch);
     $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     // if errors...
     if (curl_errno($ch)) {
         #$errors = curl_error($ch);
         curl_close($ch);
         // return false
         return false;
     } else {
         // close connection
         curl_close($ch);
         // if success...
         if ($code === 200 and $response === 'VERIFIED') {
             return true;
         } else {
             return false;
         }
     }
 }
Esempio n. 21
0
 public function __construct($db = null, $table = null)
 {
     $this->db = is_null($db) ? SITE_NAME : $db;
     $this->table = is_null($table) ? 'core' : $table;
     $this->store = Config::get('dir.flight.store');
     $this->db = Inflector::urlize($this->db, '');
     $this->table = Inflector::urlize($this->table, '');
     if (!$this->store) {
         throw new Exception("You must defined in config a dir store for JDB.");
     }
     if (!is_dir($this->store)) {
         File::mkdir($this->store);
     }
     $this->dir = $this->store . DS . $this->db;
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     $this->ids = $this->dir . DS . 'ids.' . $this->table;
     if (!file_exists($this->ids)) {
         File::put($this->ids, 1);
     }
     $this->dir .= DS . $this->table;
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     $this->age = filemtime($this->dir);
     $this->tuplesDir = $this->dir . DS . 'tuples';
     if (!is_dir($this->tuplesDir)) {
         File::mkdir($this->tuplesDir);
     }
     $this->cacheDir = $this->dir . DS . 'cache';
     if (!is_dir($this->cacheDir)) {
         File::mkdir($this->cacheDir);
     }
     $this->indicesDir = $this->dir . DS . 'indices';
     if (!is_dir($this->indicesDir)) {
         File::mkdir($this->indicesDir);
     }
     $this->relationsDir = $this->dir . DS . 'relations';
     if (!is_dir($this->relationsDir)) {
         File::mkdir($this->relationsDir);
     }
 }
Esempio n. 22
0
 public function __construct($db = null, $table = null)
 {
     $this->db = is_null($db) ? SITE_NAME : $db;
     $this->table = is_null($table) ? 'core' : $table;
     $dir = Config::get('dir.blizz.store', session_save_path());
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     $store = lib('blizzstore', [$this]);
     Now::set("blizz.store.{$this->db}.{$this->table}", $store);
     $this->cursor = lib('blizzcursor', [$this]);
 }
Esempio n. 23
0
 public function __construct($db = null, $table = null)
 {
     $this->db = is_null($db) ? SITE_NAME : $db;
     $this->table = is_null($table) ? 'core' : $table;
     $dir = Config::get('dir.flat.store', session_save_path());
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
     if (!is_dir($dir)) {
         File::mkdir($dir);
     }
     $this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
     if (!is_dir($this->dir)) {
         File::mkdir($this->dir);
     }
     if (!is_file($this->dir . DS . 'age.blazz')) {
         File::put($this->dir . DS . 'age.blazz', '');
     }
     $this->cursor = core('cursor', [$this]);
 }
Esempio n. 24
0
 /**
  * @return Twig_Loader_Filesystem
  */
 private function getTwigFilesystemLoader()
 {
     $paths = [];
     if ($this->config->isEmpty('theme')) {
         $paths[] = $this->config->get('layouts.path');
     } elseif ($this->config->get('theme') == 'default') {
         $paths[] = $this->config->get('layouts.path') . '/default';
     } else {
         $paths[] = $this->config->get('layouts.path') . '/' . $this->config->get('theme');
         $paths[] = $this->config->get('layouts.path') . '/default';
     }
     $paths[] = __DIR__ . '/layouts';
     // Fallback
     $loader = new Twig_Loader_Filesystem($paths);
     // namespaces
     $namespaces = ['plugin' => $this->config->get('plugins.path'), 'page' => $this->config->get('pages.path'), 'post' => $this->config->get('posts.path'), 'site' => $this->config->get('site.path'), 'widget' => __DIR__ . '/Twig/widgets'];
     foreach ($namespaces as $namespace => $path) {
         if (is_readable($path)) {
             $loader->addPath($path, $namespace);
         }
     }
     return $loader;
 }
Esempio n. 25
0
 public static function dispatch($module = null)
 {
     $module = is_null($module) ? 'front' : $module;
     $ever = context()->get('MVC404');
     if (true !== $ever) {
         $file = APPLICATION_PATH . DS . 'config' . DS . SITE_NAME . '_routes.php';
         if (File::exists($file)) {
             $routes = (include $file);
             static::$routes = isAke($routes, $module, []);
         }
         if (count(static::$routes)) {
             $baseUri = Config::get('application.base_uri', '');
             if (strlen($baseUri)) {
                 $uri = strReplaceFirst($baseUri, '', $_SERVER['REQUEST_URI']);
             } else {
                 $uri = $_SERVER['REQUEST_URI'];
             }
             static::$uri = $uri;
             static::$method = Request::method();
             return static::find();
         }
     }
     return false;
 }
Esempio n. 26
0
 public function cache($bool = true)
 {
     /* Polymorphism */
     if (is_int($bool)) {
         if ($bool == 0) {
             $bool = false;
         } elseif ($bool == 1) {
             $bool = true;
         } elseif (60 <= $bool) {
             Config::set('database.cache.ttl', $bool);
         } else {
             $bool = true;
         }
     }
     $this->cache = $bool;
     return $this;
 }
Esempio n. 27
0
 public function listing()
 {
     $fields = $this->fields();
     $fieldInfos = isAke($this->config, 'fields');
     $defaultOrder = isAke($this->config, 'default_order', $this->model->pk());
     $defaultDir = isAke($this->config, 'default_order_direction', 'ASC');
     $limit = isAke($this->config, 'items_by_page', Config::get('crud.items.number', 25));
     $many = isAke($this->config, 'many');
     $where = isAke($_REQUEST, 'crud_where', null);
     $page = isAke($_REQUEST, 'crud_page', 1);
     $order = isAke($_REQUEST, 'crud_order', $defaultOrder);
     $orderDirection = isAke($_REQUEST, 'crud_order_direction', $defaultDir);
     $export = isAke($_REQUEST, 'crud_type_export', false);
     $export = !strlen($export) ? false : $export;
     $offset = $page * $limit - $limit;
     $whereData = '';
     if (!empty($where)) {
         $whereData = $this->parseQuery($where);
     }
     $db = call_user_func_array(array('\\Thin\\Database', 'instance'), $this->model->args);
     if (strstr($whereData, ' && ')) {
         $wheres = explode(' && ', $whereData);
         foreach ($wheres as $tmpWhere) {
             $db = $this->model->where($tmpWhere);
         }
     } else {
         if (strlen($whereData)) {
             $db = $this->model->where($whereData);
         } else {
             $db = $this->model->rows();
         }
     }
     $results = $db->order($order, $orderDirection)->exec();
     if (count($results) < 1) {
         if (strlen($where)) {
             return '<div class="alert alert-danger col-md-4 col-md-pull-4 col-md-push-4">La requête ne remonte aucun résultat.</div>';
         } else {
             return '<div class="alert alert-info col-md-4 col-md-pull-4 col-md-push-4">Aucune donnée à afficher..</div>';
         }
     }
     if (false !== $export) {
         return $this->export($export, $results);
     }
     $total = count($results);
     $last = ceil($total / $limit);
     $paginator = new Paginator($results, $page, $total, $limit, $last);
     $data = $paginator->getItemsByPage();
     $pagination = $paginator->links();
     $pagination = '<div class="row">
         <div class="col-md-12">
         ' . $pagination . '
         </div>
         </div>';
     $html = $pagination . '<div class="row"><div class="col-md-12"><form action="/crud/static/list/table/' . $this->model->table . '" id="listForm" method="post">
         <input type="hidden" name="crud_page" id="crud_page" value="' . $page . '" /><input type="hidden" name="crud_order" id="crud_order" value="' . $order . '" /><input type="hidden" name="crud_order_direction" id="crud_order_direction"  value="' . $orderDirection . '" /><input type="hidden" id="crud_where" name="crud_where" value="' . \Thin\Crud::checkEmpty('crud_where') . '" /><input type="hidden" id="crud_type_export" name="crud_type_export" value="" />
         <table style="clear: both;" class="table table-striped tablesorter table-bordered table-condensed table-hover">
                     <thead>
                     <tr>';
     foreach ($fields as $field) {
         $fieldSettings = isAke($fieldInfos, $field);
         $label = isAke($fieldSettings, 'label', ucfirst($field));
         $listable = isAke($fieldSettings, 'is_listable', true);
         $sortable = isAke($fieldSettings, 'is_sortable', true);
         if (!$listable || $field == $this->model->pk()) {
             continue;
         }
         if (!$sortable) {
             $html .= '<th>' . \Thin\Html\Helper::display($label) . '</th>';
         } else {
             if ($field == $order) {
                 $directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC';
                 $js = 'orderGoPage(\'' . $field . '\', \'' . $directionJs . '\');';
                 $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting ' . Inflector::lower($orderDirection) . '" rel="' . $field . '">' . \Thin\Html\Helper::display($label) . '</div></th>';
             } else {
                 $js = 'orderGoPage(\'' . $field . '\', \'ASC\');';
                 $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting" rel="' . $field . '">' . \Thin\Html\Helper::display($label) . '</div></th>';
             }
         }
     }
     if (count($many)) {
         $html .= '<th>Rel.</th>';
     }
     $html .= '<th style="text-align: center;">Action</th>
                     </tr>
                     </thead>
                     <tbody>';
     foreach ($data as $item) {
         $id = isAke($item, $this->model->pk(), null);
         $html .= '<tr ondblclick="document.location.href = \'/crud/static/update/table/' . $this->model->table . '/id/' . $id . '\';">';
         foreach ($fields as $field) {
             $fieldSettings = isAke($fieldInfos, $field);
             $listable = isAke($fieldSettings, 'is_listable', true);
             if (!$listable || $field == $this->model->pk()) {
                 continue;
             }
             $value = isAke($item, $field, null);
             $closure = isAke($fieldSettings, 'content_view', false);
             if (false === $closure || !is_callable($closure)) {
                 $continue = true;
                 if (ake('form_type', $fieldSettings)) {
                     if ($fieldSettings['form_type'] == 'image' && strlen($value)) {
                         $html .= '<td><img src="' . $value . '" style="max-width: 200px;" /></td>';
                         $continue = false;
                     }
                     if ($fieldSettings['form_type'] == 'email' && strlen($value)) {
                         $html .= '<td><a href="mailto:' . $value . '">' . \Thin\Html\Helper::display($this->truncate($value)) . '</a></td>';
                         $continue = false;
                     }
                     if ($fieldSettings['form_type'] == 'file' && strlen($value)) {
                         $html .= '<td><a class="btn btn-small btn-success" href="' . $value . '"><i class="fa fa-download"></i></td>';
                         $continue = false;
                     }
                 }
                 if (true === $continue) {
                     if ('email' == $field) {
                         $html .= '<td><a href="mailto:' . $value . '">' . \Thin\Html\Helper::display($this->truncate($value)) . '</a></td>';
                     } else {
                         $html .= '<td>' . \Thin\Html\Helper::display($this->truncate($value)) . '</td>';
                     }
                 }
             } else {
                 $value = call_user_func_array($closure, array($item));
                 $html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>';
             }
         }
         if (count($many)) {
             $html .= '<td><ul class="list-inline">';
             foreach ($many as $rel) {
                 $foreignCrud = new self(model($rel));
                 $nameRel = isAke($foreignCrud->config(), 'plural', $rel . 's');
                 $html .= '<li><a class="btn btn-primary" target="_blank" href="/crud/static/many/table/' . $rel . '/foreign/' . $this->model->table . '_id/id/' . $id . '"><i class="fa fa-chain"></i> ' . $nameRel . '</a></li>';
             }
             $html .= '</ul></td>';
         }
         $html .= $this->options($id);
         $html .= '</tr>';
     }
     $html .= '</tbody>
                 </table></form>' . $pagination . '</div></div>';
     return $html;
 }
Esempio n. 28
0
 public function logout()
 {
     $session = session(Config::get('bundle.auth.session', 'auth'));
     $user = $session->getUser();
     if (!is_null($user) && isset($this->user)) {
         unset($this->user);
         $session->erase('user');
     }
     return $this;
 }
Esempio n. 29
0
 public function __construct()
 {
     $this->bucket = Config::get('s3.bucket', SITE_NAME);
     $this->client = S3Client::factory(['credentials' => ['key' => Config::get('aws.access_key'), 'secret' => Config::get('aws.secret_key')], 'region' => Config::get('s3.region', 'eu-west-1'), 'version' => 'latest']);
 }
Esempio n. 30
0
 function forget($key)
 {
     return Config::forget('helper.' . $key);
 }