本文整理汇总了PHP中Backend::getDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Backend::getDB方法的具体用法?PHP Backend::getDB怎么用?PHP Backend::getDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend
的用法示例。
在下文中一共展示了Backend::getDB方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkConnection
private function checkConnection()
{
if (!$this->connection instanceof PDO) {
$this->connection = Backend::getDB();
}
return $this->connection instanceof PDO;
}
示例2: adminLinks
public static function adminLinks()
{
if (!Backend::getDB('default')) {
return false;
}
return array(array('href' => '?q=value/admin', 'text' => 'Values'));
}
示例3: install
public static function install(array $options = array())
{
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Permission::add('anonymous', 'index', 'home') && $result;
$result = Permission::add('anonymous', 'error', 'home') && $result;
//TODO Keep this here until we have role hierarchies
$result = Permission::add('authenticated', 'index', 'home') && $result;
$result = Permission::add('authenticated', 'error', 'home') && $result;
return $result;
}
示例4: add
/**
* Perhaps subject can be omitted, and defaults to a value that will allow the an action
* for all subjects? Eg, display.
*/
public static function add($role, $action, $subject, $subject_id = 0, array $options = array())
{
if (!Backend::getDB('default')) {
return false;
}
//Loop through arrays
if (is_array($role)) {
$result = 0;
foreach ($role as $one_role) {
if (self::add($one_role, $action, $subject, $subject_id, $options)) {
$result++;
}
}
return $result;
}
if (is_array($action)) {
$result = 0;
foreach ($action as $one_action) {
if (self::add($role, $one_action, $subject, $subject_id, $options)) {
$result++;
}
}
return $result;
}
if (is_array($subject)) {
$result = 0;
foreach ($subject as $one_subject) {
if (self::add($role, $role, $one_subject, $subject_id, $options)) {
$result++;
}
}
return $result;
}
if (is_array($subject_id)) {
$options = $subject_id;
$subject_id = 0;
}
$control = array_key_exists('control', $options) ? $options['control'] : '100';
$system = array_key_exists('system', $options) ? $options['system'] : 0;
$data = array('role' => $role, 'action' => $action, 'subject' => class_for_url($subject), 'subject_id' => $subject_id, 'control' => $control, 'system' => $system, 'active' => 1);
$permission = new PermissionObj();
if ($permission->replace($data) !== false) {
Backend::addSuccess('Added permission to ' . $action . ' for ' . $role);
$result = true;
} else {
Backend::addError('Could not add permission to ' . $action . ' for ' . $role);
$result = false;
}
return $result;
}
示例5: checkConnection
private function checkConnection()
{
$this->error_msg = false;
if (!$this->db instanceof PDO) {
try {
$this->db = Backend::getDB($this->meta['database']);
} catch (Exception $e) {
Backend::addError($e->getMessage());
}
if (!$this->db instanceof PDO) {
$this->error_msg = 'No Database setup';
if (class_exists('BackendError', false)) {
BackendError::add(get_class($this) . ': No Database setup', 'checkConnection');
}
return false;
}
}
return $this->db instanceof PDO;
}
示例6: install
public static function install(array $options = array())
{
if (!Backend::getDB('default')) {
return true;
}
$install_model = array_key_exists('install_model', $options) ? $options['install_model'] : true;
$toret = parent::install($options);
$class = get_called_class();
if ($class && class_exists($class, true)) {
if ($install_model) {
$toret = call_user_func(array(get_called_class(), 'installModel'), $class . 'Obj', $options);
}
}
return $toret;
}
示例7: install
public static function install(array $options = array())
{
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Hook::add('init', 'pre', get_called_class(), array('global' => true)) && $result;
$result = Hook::add('table_display', 'pre', get_called_class()) && $result;
$result = Permission::add('anonymous', TableCtl::$P_READONLY, get_called_class()) && $result;
$result = Permission::add('authenticated', TableCtl::$P_READONLY, get_called_class()) && $result;
return $result;
}
示例8: install
public static function install(array $options = array())
{
$options['install_model'] = array_key_exists('install_model', $options) ? $options['install_model'] : true;
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Hook::add('init', 'post', get_called_class(), array('global' => true, 'sequence' => 0)) && $result;
$result = Hook::add('start', 'pre', get_called_class(), array('global' => true)) && $result;
$result = Hook::add('finish', 'post', get_called_class(), array('global' => true)) && $result;
$result = Permission::add('anonymous', 'super_signup', get_called_class()) && $result;
$result = Permission::add('anonymous', 'signup', get_called_class()) && $result;
$result = Permission::add('anonymous', 'confirm', get_called_class()) && $result;
$result = Permission::add('anonymous', 'login', get_called_class()) && $result;
$result = Permission::add('authenticated', 'login', get_called_class()) && $result;
$result = Permission::add('authenticated', 'logout', get_called_class()) && $result;
$result = Permission::add('authenticated', 'display', get_called_class()) && $result;
$result = Permission::add('authenticated', 'update', get_called_class()) && $result;
$result = Permission::add('authenticated', 'change_password', get_called_class()) && $result;
return $result;
}
示例9: install
public static function install(array $options = array())
{
$result = parent::install($options);
if (!Backend::getDB('default')) {
return $result;
}
$result = Hook::add('display', 'post', __CLASS__, array('global' => true, 'mode' => 'html')) && $result;
$result = Permission::add('anonymous', 'continual', 'admin') && $result;
$result = Permission::add('anonymous', 'daily', 'admin') && $result;
$result = Permission::add('anonymous', 'weekly', 'admin') && $result;
$result = Permission::add('authenticated', 'continual', 'admin') && $result;
$result = Permission::add('authenticated', 'daily', 'admin') && $result;
$result = Permission::add('authenticated', 'weekly', 'admin') && $result;
return $result;
}
示例10: install
public static function install(array $options = array())
{
if (!Backend::getDB('default')) {
return true;
}
$class = get_called_class();
if (!$class || !class_exists($class, true)) {
return false;
}
//Purge permissions first
$query = new DeleteQuery('Permission');
$query->filter('`subject` = :subject')->filter('`system` = 0');
$query->execute(array(':subject' => class_for_url($class)));
$methods = get_class_methods($class);
$methods = array_filter($methods, create_function('$var', '$temp = explode(\'_\', $var, 2); return count($temp) == 2 && in_array(strtolower($temp[0]), array(\'action\', \'get\', \'post\', \'put\', \'delete\'));'));
$methods = array_map(create_function('$var', 'return preg_replace(\'/^(action|get|post|put|delete)_/\', \'\', $var);'), $methods);
$result = true;
foreach ($methods as $action) {
$result = Permission::add('nobody', $action, class_for_url($class)) && $result;
}
return $result;
}
示例11: pre_install
/**
* Make sure the hooks table exists so that other components can add hooks with installation
*/
public static function pre_install()
{
if (!Backend::getDB('default')) {
return true;
}
$result = self::installModel(__CLASS__ . 'Obj');
return $result;
}
示例12: adminLinks
public static function adminLinks()
{
if (!Backend::getDB('default')) {
return false;
}
return array(array('text' => 'Manage Components', 'href' => '?q=component/manage'), array('text' => 'Check Components', 'href' => '?q=component/check'));
}
示例13: install
public static function install()
{
if (!Backend::getDB('default')) {
return true;
}
$result = true;
return $result;
}
示例14: action
public static function action()
{
if (self::$whoopsed) {
return array(null, null);
}
$control_name = class_name(self::$area);
if (Controller::$debug) {
Backend::addNotice('Trying Controller ' . $control_name);
}
$controller = class_exists($control_name, true) ? new $control_name() : false;
if (!($controller instanceof AreaCtl && Component::isActive($control_name))) {
if (Backend::getDB('default')) {
//We have a DB
Controller::whoops('Component ' . $control_name . ' is Inactive or Invalid', array('message' => 'The requested component doesn\'t exist or is inactive.', 'code_hint' => 404));
self::$area = ConfigValue::get('DefaultErrorController', 'home');
self::$action = ConfigValue::get('DefaultErrorAction', 'error');
$control_name = class_name(self::$area);
} else {
//No DB, allow Content to check if the template exists
self::$parameters[0] = self::$area . '/' . self::$action;
if (count(self::$parameters[0]) > 1) {
self::$parameters = array(self::$parameters[0]);
}
self::$area = ConfigValue::get('DefaultErrorController', 'content');
self::$action = ConfigValue::get('DefaultErrorAction', 'display');
$control_name = class_name(self::$area);
}
}
$controller = class_exists($control_name, true) ? new $control_name() : false;
if (!($controller instanceof AreaCtl && Component::isActive($control_name))) {
Controller::whoops('Invalid Error Area Controller', 'The DefaultErrorController is invalid or inactive.');
return null;
}
Backend::add('Area', self::$area);
Backend::add('Action', self::$action);
if (Controller::$debug) {
Backend::addNotice('Code for this page is in the ' . get_class($controller) . ' Controller');
}
$result = null;
$run_action = Hook::run('action', 'pre', array(), array('toret' => true));
if ($run_action) {
$result = $controller->action();
}
Hook::run('action', 'post');
return array($controller, $result);
}