/** * Get a configuration value. * * Config Value names should be CamelCase */ public static function get($name, $default = null) { if (array_key_exists($name, self::$cache)) { return self::$cache[$name]; } if (array_key_exists('application.' . $name, self::$cache)) { return self::$cache['application.' . $name]; } if (defined('BACKEND_WITH_DATABASE') && BACKEND_WITH_DATABASE) { $value = Value::get($name, null); //Retrieved from the DB if (!is_null($value)) { self::$cache[$name] = $value; return $value; } } $name = explode('.', $name); if (count($name) == 1) { array_unshift($name, 'application'); } //Check the config file $result = Backend::getConfig($name, $default); self::$cache[implode('.', $name)] = $result; return $result; }
function action_check() { if (!Backend::getConfig('application.file_provider', false)) { return false; } $files = Component::fromFolder(); $count = 0; foreach ($files as $file) { if ($rev_id = bzr_get_file_revision(BACKEND_FOLDER . '/' . $file)) { $name = preg_replace('/\\.obj\\.php$/', '', basename($file)); $be_file = BackendFile::retrieve($file, 'dbobject'); if ($be_file->array) { if ($rev_id != $be_file->array['version']) { if ($be_file->update(array('version' => $rev_id))) { $count++; Backend::addSuccess($name . ' updated to ' . $rev_id); } else { Backend::addError('Could not update version for ' . $name); } } } else { $data = array('name' => $name, 'file' => $file, 'version' => $rev_id, 'active' => 1); if ($be_file->create($data)) { $count++; Backend::addSuccess($name . ' added'); } else { Backend::addError('Could not add info for ' . $name); } } } } return $count; }
protected function registerBackendAuthProvider() { /** * Модель пользователей */ $this->app['backend.auth.provider'] = $this->app->share(function ($app) { return new EloquentUserProvider($app['backend.auth.crypt'], \Backend::getConfig('auth_model')); }); }
public static function getInstance($provider) { if (array_key_exists($provider, self::$instances)) { return self::$instances[$provider]; } $parameters = array('consumer_key' => Backend::getConfig($provider . '.oauth.consumer.key'), 'consumer_secret' => Backend::getConfig($provider . '.oauth.consumer.secret'), 'access_url' => Backend::getConfig($provider . '.oauth.access.url'), 'authorize_url' => Backend::getConfig($provider . '.oauth.authorize.url')); self::$instances[$provider] = new self($parameters); return self::$instances[$provider]; }
public function action_request_auth() { $token = $this->oauth->getAuthToken(); if ($token) { $_SESSION['OAuthAuthToken'] = $token; $url = Backend::getConfig('twitter.oauth.authorize.url'); $url .= '?oauth_token=' . OAuth::encode($token['oauth_token']); Controller::redirect($url); } else { if (array_key_exists('OAuthAuthToken', $_SESSION)) { unset($_SESSION['OAuthAuthToken']); } } return $token; }
/** * Construct a DB Object * * children have the following options: * - conditions = array(ClassName => array(field_in_child => value | field_in_this_model)) * - relation = single | multiple, defaults to single */ function __construct($meta = array(), array $options = array()) { if (!is_array($meta)) { $meta = is_numeric($meta) ? array('id' => $meta) : array(); } $meta['id'] = array_key_exists('id', $meta) ? $meta['id'] : false; $meta['id_field'] = array_key_exists('id_field', $meta) ? $meta['id_field'] : 'id'; $meta['table'] = array_key_exists('table', $meta) ? $meta['table'] : table_name(get_class($this)); $meta['database'] = array_key_exists('database', $meta) ? $meta['database'] : Backend::getConfig('backend.dbs.default.alias', 'default'); $meta['provider'] = array_key_exists('provider', $meta) ? $meta['provider'] : Backend::getConfig('backend.provider', 'MySQL'); $meta['fields'] = array_key_exists('fields', $meta) ? $meta['fields'] : array(); $meta['keys'] = array_key_exists('keys', $meta) ? $meta['keys'] : array(); $meta['name'] = array_key_exists('name', $meta) ? $meta['name'] : class_name(get_class($this)); $meta['objname'] = array_key_exists('objname', $meta) ? $meta['objname'] : get_class($this); $meta['relations'] = array_key_exists('relations', $meta) ? $meta['relations'] : array(); $this->meta = $meta; $load_type = array_key_exists('load_mode', $options) ? $options['load_mode'] : $this->load_mode; if ($this->checkConnection()) { if ($meta['id']) { $this->read(array('mode' => $load_type)); } } }
<?php if (!defined('WURFL_DIR')) { define('WURFL_DIR', Backend::getConfig('application.wurfl.dir')); } if (!defined('RESOURCES_DIR')) { define('RESOURCES_DIR', Backend::getConfig('application.wurfl.resources')); } if (WURFL_DIR) { require_once WURFL_DIR . 'WURFLManagerProvider.php'; } class Wurfl extends AreaCtl { private static $device = null; public function action_test() { $requestingDevice = self::getDevice(); if ($requestingDevice) { $content = '<ul>'; $content .= '<li>ID: ' . $requestingDevice->id . '</li>'; $content .= '<li>Brand Name: ' . $requestingDevice->getCapability("brand_name") . '</li>'; $content .= '<li>Model Name: ' . $requestingDevice->getCapability("model_name") . '</li>'; $content .= '<li>Xhtml Preferred Markup: ' . $requestingDevice->getCapability("preferred_markup") . '</li>'; $content .= '<li>Resolution Width: ' . $requestingDevice->getCapability("resolution_width") . '</li>'; $content .= '<li>Resolution Height: ' . $requestingDevice->getCapability("resolution_height") . '</li>'; $content .= '</ul>'; } else { $content = '<p>Could not get device information</p>'; } Backend::addContent($content); return false;
public static function hook_start() { $user = self::check(); if ($user && in_array('superadmin', $user->roles) && !Backend::getConfig('application.NoSuperWarning')) { Backend::addInfo('You are the super user. Be carefull, careless clicking costs lives...'); } self::$current_user = $user; Backend::add('BackendUser', $user); }
private static function checkUploadFolder($sub_folder = false) { $folder = Backend::getConfig('backend.application.file_store', SITE_FOLDER . '/files/'); if ($sub_folder) { if (substr($folder, -1) != '/') { $folder .= '/'; } $folder .= $sub_folder; } if (substr($folder, -1) != '/') { $folder .= '/'; } if (!file_exists($folder)) { if (!@mkdir($folder, 0775)) { Backend::addError('Cannot create File Store'); $folder = false; } } else { if (!is_writeable($folder)) { $folder = false; } } return $folder; }