コード例 #1
0
ファイル: Files.php プロジェクト: hyrmedia/directus
 public function __construct()
 {
     $acl = Bootstrap::get('acl');
     $adapter = Bootstrap::get('ZendDb');
     $this->filesystem = Bootstrap::get('filesystem');
     $config = Bootstrap::get('config');
     $this->config = $config['filesystem'] ?: [];
     // Fetch files settings
     $Settings = new DirectusSettingsTableGateway($acl, $adapter);
     $this->filesSettings = $Settings->fetchCollection('files', array('storage_adapter', 'storage_destination', 'thumbnail_storage_adapter', 'thumbnail_storage_destination', 'thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled'));
 }
コード例 #2
0
ファイル: Storage.php プロジェクト: rudderdon/Directus
 public function __construct()
 {
     $this->acl = Bootstrap::get('acl');
     $this->adapter = Bootstrap::get('ZendDb');
     // Fetch files settings
     $Settings = new DirectusSettingsTableGateway($this->acl, $this->adapter);
     $this->filesSettings = $Settings->fetchCollection('files', array('storage_adapter', 'storage_destination', 'thumbnail_storage_adapter', 'thumbnail_storage_destination', 'thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled'));
     // Initialize Storage Adapters
     $StorageAdapters = new DirectusStorageAdaptersTableGateway($this->acl, $this->adapter);
     $adapterRoles = array('DEFAULT', 'THUMBNAIL', 'TEMP');
     $storage = $StorageAdapters->fetchByUniqueRoles($adapterRoles);
     if (count($storage) !== count($adapterRoles)) {
         throw new \RuntimeException(__CLASS__ . ' expects adapter settings for these default adapter roles: ' . implode(',', $adapterRoles));
     }
     $this->FilesStorage = self::getStorage($storage['DEFAULT']);
     $this->ThumbnailStorage = self::getStorage($storage['THUMBNAIL']);
     $this->storageAdaptersByRole = $storage;
 }
コード例 #3
0
ファイル: api.php プロジェクト: smkkstudios/Directus
})->via('GET', 'POST', 'PUT', 'DELETE');
/**
 * REVISIONS COLLECTION
 */
$app->get("/{$v}/tables/:table/rows/:id/revisions/?", function ($table, $id) use($acl, $ZendDb, $params) {
    $params['table_name'] = $table;
    $params['id'] = $id;
    $Activity = new DirectusActivityTableGateway($acl, $ZendDb);
    $revisions = $Activity->fetchRevisions($id, $table);
    JsonView::render($revisions);
});
/**
 * SETTINGS COLLECTION
 */
$app->map("/{$v}/settings(/:id)/?", function ($id = null) use($acl, $ZendDb, $params, $requestPayload, $app) {
    $Settings = new DirectusSettingsTableGateway($acl, $ZendDb);
    switch ($app->request()->getMethod()) {
        case "POST":
        case "PUT":
            $data = $requestPayload;
            unset($data['id']);
            $Settings->setValues($id, $data);
            break;
    }
    $settings_new = $Settings->fetchAll();
    $get_new = is_null($id) ? $settings_new : $settings_new[$id];
    JsonView::render($get_new);
})->via('GET', 'POST', 'PUT');
// GET and PUT table details
$app->map("/{$v}/tables/:table/?", function ($table) use($ZendDb, $acl, $params, $requestPayload, $app) {
    $TableGateway = new TableGateway($acl, 'directus_tables', $ZendDb, null, null, null, 'table_name');
コード例 #4
0
ファイル: Bootstrap.php プロジェクト: YounessTayer/directus
 /**
  * @return \Directus\Embed\EmbedManager
  */
 private static function embedManager()
 {
     $embedManager = new EmbedManager();
     $acl = static::get('acl');
     $adapter = static::get('ZendDb');
     // Fetch files settings
     $SettingsTable = new DirectusSettingsTableGateway($acl, $adapter);
     try {
         $settings = $SettingsTable->fetchCollection('files', ['thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled']);
     } catch (\Exception $e) {
         $settings = [];
         $log = static::get('log');
         $log->warn($e);
     }
     $providers = ['\\Directus\\Embed\\Provider\\VimeoProvider', '\\Directus\\Embed\\Provider\\YoutubeProvider'];
     $path = implode(DIRECTORY_SEPARATOR, [BASE_PATH, 'customs', 'embeds', '*.php']);
     foreach (glob($path) as $filename) {
         $providers[] = '\\Directus\\Embed\\Provider\\' . basename($filename, '.php');
     }
     foreach ($providers as $providerClass) {
         $provider = new $providerClass($settings);
         $embedManager->register($provider);
     }
     return $embedManager;
 }
コード例 #5
0
ファイル: index.php プロジェクト: hyrmedia/directus
function getSettings()
{
    global $ZendDb, $acl;
    $settings = new DirectusSettingsTableGateway($acl, $ZendDb);
    $items = array();
    foreach ($settings->fetchAll() as $key => $value) {
        $value['id'] = $key;
        $items[] = $value;
    }
    return $items;
}
コード例 #6
0
ファイル: index.php プロジェクト: jel-massih/directus
function getSettings()
{
    global $ZendDb, $acl;
    $settings = new DirectusSettingsTableGateway($acl, $ZendDb);
    $items = [];
    foreach ($settings->fetchAll() as $key => $value) {
        if ($key == 'global') {
            $value['max_file_size'] = get_max_upload_size();
        }
        $value['id'] = $key;
        $items[] = $value;
    }
    return $items;
}
コード例 #7
0
ファイル: api.php プロジェクト: YounessTayer/directus
                }
                array_push($column_settings, $col);
            }
            $TableGateway->updateCollection($column_settings);
    }
    $UiOptions = new DirectusUiTableGateway($acl, $ZendDb);
    $response = $UiOptions->fetchOptions($table, $column, $ui);
    if (!$response) {
        $app->response()->setStatus(404);
        $response = ['message' => __t('unable_to_find_column_x_options_for_x', ['column' => $column, 'ui' => $ui]), 'success' => false];
    }
    JsonView::render($response);
})->via('GET', 'POST', 'PUT');
$app->notFound(function () use($app, $acl, $ZendDb) {
    $app->response()->header('Content-Type', 'text/html; charset=utf-8');
    $settingsTable = new DirectusSettingsTableGateway($acl, $ZendDb);
    $settings = $settingsTable->fetchCollection('global');
    $projectName = isset($settings['project_name']) ? $settings['project_name'] : 'Directus';
    $projectLogoURL = '/assets/img/directus-logo-flat.svg';
    if (isset($settings['cms_thumbnail_url']) && $settings['cms_thumbnail_url']) {
        $projectLogoURL = $settings['cms_thumbnail_url'];
    }
    $data = ['project_name' => $projectName, 'project_logo' => $projectLogoURL];
    $app->render('errors/404.twig.html', $data);
});
/**
 * Run the Router
 */
if (isset($_GET['run_api_router']) && $_GET['run_api_router']) {
    // Run Slim
    $app->response()->header('Content-Type', 'application/json; charset=utf-8');
コード例 #8
0
ファイル: Cache.php プロジェクト: YounessTayer/directus
 private function getInstagramSettings()
 {
     $acl = Bootstrap::get('acl');
     $ZendDb = Bootstrap::get('ZendDb');
     $SettingsTableGateway = new DirectusSettingsTableGateway($acl, $ZendDb);
     $requiredKeys = ['instagram_oauth_access_token', 'instagram_client_id'];
     return $SettingsTableGateway->fetchCollection('social', $requiredKeys);
 }
コード例 #9
0
use Directus\Bootstrap;
use Directus\Db\TableGateway\AclAwareTableGateway;
use Directus\Db\TableGateway\DirectusSettingsTableGateway;
use Directus\Db\TableGateway\DirectusStorageAdaptersTableGateway;
use Directus\Files\Thumbnail;
use Zend\Db\TableGateway\TableGateway;
require 'directusLoader.php';
function out($string)
{
    echo "{$string}\n";
}
$supportedExtensions = array('jpg', 'jpeg', 'png', 'gif');
out("Running script with the following supported extensions: " . implode(", ", $supportedExtensions));
$db = \Directus\Bootstrap::get('ZendDb');
$acl = \Directus\Bootstrap::get('acl');
$Settings = new DirectusSettingsTableGateway($acl, $db);
$filesSettings = $Settings->fetchCollection('media', array('storage_adapter', 'storage_destination', 'thumbnail_storage_adapter', 'thumbnail_storage_destination', 'thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled'));
$StorageAdapters = new DirectusStorageAdaptersTableGateway($acl, $db);
$storageAdaptersById = $StorageAdapters->fetchAllWithIdKeys();
foreach ($storageAdaptersById as $id => $storageAdapter) {
    $storageAdaptersById[$id] = \Directus\Files\Storage\Storage::getStorage($storageAdapter);
}
out("\nLoaded " . count($storageAdaptersById) . " storage adapters.");
$DirectusMedia = new TableGateway('directus_files', $db);
$mediaRecords = $DirectusMedia->select();
out("Found " . $mediaRecords->count() . " Directus media records.");
$thumbnailStorageAdapterResultSet = $StorageAdapters->fetchByUniqueRoles(array('THUMBNAIL'));
if (1 != count($thumbnailStorageAdapterResultSet)) {
    throw new \RuntimeException("Fatal: exactly one storage adapter with role THUMBNAIL is required");
}
$thumbnailStorageAdapterSettings = array_pop($thumbnailStorageAdapterResultSet);
コード例 #10
0
ファイル: Bootstrap.php プロジェクト: rudderdon/Directus
 /**
  * Construct CodeBird Twitter API Client
  * @return \Codebird\Codebird
  */
 private static function codebird()
 {
     $acl = self::get('acl');
     $db = self::get('ZendDb');
     // Social settings
     $SettingsTableGateway = new DirectusSettingsTableGateway($acl, $db);
     $requiredKeys = array('twitter_consumer_key', 'twitter_consumer_secret', 'twitter_oauth_token', 'twitter_oauth_token_secret');
     $socialSettings = $SettingsTableGateway->fetchCollection('social', $requiredKeys);
     // Codebird initialization
     \Codebird\Codebird::setConsumerKey($socialSettings['twitter_consumer_key'], $socialSettings['twitter_consumer_secret']);
     $cb = \Codebird\Codebird::getInstance();
     $cb->setToken($socialSettings['twitter_oauth_token'], $socialSettings['twitter_oauth_token_secret']);
     return $cb;
 }
コード例 #11
0
<?php 
//Used to grab thumbs from temp and put to thumbs
use Directus\Db\TableGateway\DirectusSettingsTableGateway;
use Directus\Db\TableGateway\DirectusStorageAdaptersTableGateway;
use Directus\Files\Thumbnail;
use Zend\Db\TableGateway\TableGateway;
require 'directusLoader.php';
function out($string)
{
    echo "{$string}\n";
}
$supportedExtensions = ['jpg', 'jpeg', 'png', 'gif'];
out('Running script with the following supported extensions: ' . implode(', ', $supportedExtensions));
$db = \Directus\Bootstrap::get('ZendDb');
$acl = \Directus\Bootstrap::get('acl');
$Settings = new DirectusSettingsTableGateway($acl, $db);
$filesSettings = $Settings->fetchCollection('media', ['thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled']);
$StorageAdapters = new DirectusStorageAdaptersTableGateway($acl, $db);
$storageAdaptersById = $StorageAdapters->fetchAllWithIdKeys();
foreach ($storageAdaptersById as $id => $storageAdapter) {
    // @TODO: fix this, this class was removed time ago.
    $storageAdaptersById[$id] = \Directus\Files\Storage\Storage::getStorage($storageAdapter);
}
out("\nLoaded " . count($storageAdaptersById) . ' storage adapters.');
$DirectusMedia = new TableGateway('directus_files', $db);
$mediaRecords = $DirectusMedia->select();
out('Found ' . $mediaRecords->count() . ' Directus media records.');
$thumbnailStorageAdapterResultSet = $StorageAdapters->fetchByUniqueRoles(['THUMBNAIL']);
if (1 != count($thumbnailStorageAdapterResultSet)) {
    throw new \RuntimeException('Fatal: exactly one storage adapter with role THUMBNAIL is required');
}