本文整理汇总了PHP中object::config方法的典型用法代码示例。如果您正苦于以下问题:PHP object::config方法的具体用法?PHP object::config怎么用?PHP object::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Check if the user can access to the given URL.
*
* @param array $params The params to check.
*
* @return bool
*/
public function check(array $params = [])
{
if (!$this->request->session()->read('Auth.User')) {
return false;
}
$params += ['_base' => false];
$url = Router::url($params);
$params = Router::parse($url);
$user = [$this->Authorize->config('userModel') => $this->request->session()->read('Auth.User')];
$request = new Request();
$request->addParams($params);
$action = $this->Authorize->action($request);
return $this->Acl->check($user, $action);
}
示例2: testFieldTemplateOverride
/**
* Tests that the string template form `Form::field()` can be overridden.
*/
public function testFieldTemplateOverride()
{
$result = $this->form->field('name', array('type' => 'text'));
$this->form->config(array('templates' => array('field' => '{:label}{:input}{:error}')));
$result = $this->form->field('name', array('type' => 'text'));
$this->assertTags($result, array('label' => array('for' => 'Name'), 'Name', '/label', 'input' => array('type' => 'text', 'name' => 'name', 'id' => 'Name')));
}
示例3: verifySecureCookie
/**
* Verifies the expiry and MAC for the cookie
*
* @param string $cookie String from the client
* @return bool
*/
public function verifySecureCookie($key)
{
$cookieFile = glob($this->_app->config('cookies.savepath') . 'cookies.*');
if (is_array($cookieFile)) {
foreach ($cookieFile as $file) {
if (file_exists($file)) {
$exp = $this->_app->hook->maybe_unserialize(file_get_contents($file));
}
}
}
/**
* If the cookie exists and it is expired, delete it
* from the server side.
*/
if (file_exists($file) && $exp['exp'] < time()) {
unlink($file);
}
if ($this->getCookieVars($key, 'exp') === null || $this->getCookieVars($key, 'exp') < time()) {
// The cookie has expired
return false;
}
$mac = sprintf("exp=%s&data=%s", urlencode($this->getCookieVars($key, 'exp')), urlencode($this->getCookieVars($key, 'data')));
$hash = hash_hmac($this->_app->config('cookies.crypt'), $mac, $this->_app->config('cookies.secret.key'));
if (!hash_equals($this->getCookieVars($key, 'digest'), $hash)) {
// The cookie has been compromised
return false;
}
return true;
}
示例4: testTemplateRemapping
public function testTemplateRemapping()
{
$result = $this->form->password('passwd');
$this->assertTags($result, array('input' => array('type' => 'password', 'name' => 'passwd')));
$this->form->config(array('templates' => array('password' => 'text')));
$result = $this->form->password('passwd');
$this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'passwd')));
}
示例5: parseAttr
/**
* 分析标签属性 正则方式
* @access public
* @param string $str 标签属性字符串
* @param string $name 标签名
* @param string $alias 别名
* @return array
*/
public function parseAttr($str, $name, $alias = '')
{
$regex = '/\\s+(?>(?<name>[\\w-]+)\\s*)=(?>\\s*)([\\"\'])(?<value>(?:(?!\\2).)*)\\2/is';
$result = [];
if (preg_match_all($regex, $str, $matches)) {
foreach ($matches['name'] as $key => $val) {
$result[$val] = $matches['value'][$key];
}
if (!isset($this->tags[$name])) {
// 检测是否存在别名定义
foreach ($this->tags as $key => $val) {
if (isset($val['alias'])) {
$array = (array) $val['alias'];
if (in_array($name, explode(',', $array[0]))) {
$tag = $val;
$type = !empty($array[1]) ? $array[1] : 'type';
$result[$type] = $name;
break;
}
}
}
} else {
$tag = $this->tags[$name];
// 设置了标签别名
if (!empty($alias) && isset($tag['alias'])) {
$type = !empty($tag['alias'][1]) ? $tag['alias'][1] : 'type';
$result[$type] = $alias;
}
}
if (!empty($tag['must'])) {
$must = explode(',', $tag['must']);
foreach ($must as $name) {
if (!isset($result[$name])) {
throw new Exception('_PARAM_ERROR_:' . $name);
}
}
}
} else {
// 允许直接使用表达式的标签
if (!empty($this->tags[$name]['expression'])) {
static $_taglibs;
if (!isset($_taglibs[$name])) {
$_taglibs[$name][0] = strlen(ltrim($this->tpl->config('taglib_begin'), '\\') . $name);
$_taglibs[$name][1] = strlen(ltrim($this->tpl->config('taglib_end'), '\\'));
}
$result['expression'] = substr($str, $_taglibs[$name][0], -$_taglibs[$name][1]);
// 清除自闭合标签尾部/
$result['expression'] = rtrim($result['expression'], '/');
$result['expression'] = trim($result['expression']);
} elseif (empty($this->tags[$name]) || !empty($this->tags[$name]['attr'])) {
throw new Exception('_XML_TAG_ERROR_:' . $name);
}
}
return $result;
}
示例6: hasPermission
/**
* Checks if the given user has permission to perform an action.
*
* @param array $params The params to check.
*
* @return string
*/
public function hasPermission(array $params = [])
{
$params += ['controller' => 'Permissions', '_base' => false, 'prefix' => 'chat'];
$url = Router::url($params);
$params = Router::parse($url);
$request = new Request();
$request->addParams($params);
$action = $this->Authorize->action($request);
$user = [$this->Authorize->config('userModel') => $this->_session->read('Auth.User')];
return $this->Acl->check($user, $action);
}
示例7: parseAttr
/**
* 分析标签属性 正则方式
* @access public
* @param string $str 标签属性字符串
* @param string $tag 标签名
* @return array
*/
public function parseAttr($str, $tag)
{
if (ini_get('magic_quotes_sybase')) {
$str = str_replace('\\"', '\'', $str);
}
$regex = '/\\s+(?>(?<name>\\w+)\\s*)=(?>\\s*)([\\"\'])(?<value>(?:(?!\\2).)*)\\2/is';
$result = [];
if (preg_match_all($regex, $str, $matches)) {
foreach ($matches['name'] as $key => $val) {
$result[$val] = $matches['value'][$key];
}
$tag = strtolower($tag);
if (!isset($this->tags[$tag])) {
// 检测是否存在别名定义
foreach ($this->tags as $key => $val) {
if (isset($val['alias']) && in_array($tag, explode(',', $val['alias']))) {
$item = $val;
break;
}
}
} else {
$item = $this->tags[$tag];
}
if (!empty($item['must'])) {
$must = explode(',', $item['must']);
foreach ($must as $name) {
if (!isset($result[$name])) {
throw new Exception('_PARAM_ERROR_:' . $name);
}
}
}
} else {
// 允许直接使用表达式的标签
if (!empty($this->tags[$tag]['expression'])) {
static $_taglibs;
if (!isset($_taglibs[$tag])) {
$_taglibs[$tag][0] = strlen(ltrim($this->tpl->config('taglib_begin'), '\\') . $tag);
$_taglibs[$tag][1] = strlen(ltrim($this->tpl->config('taglib_end'), '\\'));
}
$result['expression'] = substr($str, $_taglibs[$tag][0], -$_taglibs[$tag][1]);
// 清除自闭合标签尾部/
$result['expression'] = rtrim($result['expression'], '/');
$result['expression'] = trim($result['expression']);
} elseif (empty($this->tags[$tag]) || !empty($this->tags[$tag]['attr'])) {
throw new Exception('_XML_TAG_ERROR_:' . $tag);
}
}
return $result;
}
示例8: __construct
/**
* Constructor is private so that another instance isn't created.
*
* @since 6.2.0
*/
private function __construct(\Liten\Liten $liten = null)
{
// Make sure the script can handle large folders/files for zip and API calls.
ini_set('max_execution_time', 600);
ini_set('memory_limit', '1024M');
if (function_exists('enable_url_ssl')) {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$this->url = $protocol . $this->_baseURL . '/';
$this->patch_url = $this->getReleaseJsonUrl();
$this->local_base_dir = BASE_PATH;
$this->local_backup_dir = '/tmp/';
$this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
$this->update = new \VisualAppeal\AutoUpdate(rtrim($this->app->config('file.savepath'), '/'), rtrim(BASE_PATH, '/'), 1800);
$this->current_release = $this->getCurrentRelease();
$this->current_release_value = $this->current_release['current_release']['current_release_value'];
}
示例9: onCourse
/**
* Return data on a course view (this will be some form of HTML)
*
* @param object $course Current course
* @param object $offering Name of the component
* @param boolean $describe Return plugin description only?
* @return object
*/
public function onCourse($course, $offering, $describe = false)
{
$response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', JText::_('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f0ae');
if ($describe) {
return $response;
}
if (!($active = Request::getVar('active'))) {
Request::setVar('active', $active = $this->_name);
}
// Check to see if user is member and plugin access requires members
$sparams = new \Hubzero\Config\Registry($course->offering()->section()->get('params'));
if (!$course->offering()->section()->access('view') && !$sparams->get('preview', 0)) {
$response->set('html', '<p class="info">' . Lang::txt('COURSES_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>');
return $response;
}
// Determine if we need to return any HTML (meaning this is the active plugin)
if ($response->get('name') == $active) {
$this->css();
// Course and action
$this->course = $course;
$action = strtolower(Request::getWord('action', ''));
$this->view = $this->view('default', 'outline');
$this->view->option = Request::getCmd('option', 'com_courses');
$this->view->controller = Request::getWord('controller', 'course');
$this->view->course = $course;
$this->view->offering = $offering;
$this->view->config = $course->config();
switch ($action) {
case 'build':
$this->_build();
break;
default:
$this->js();
$this->_display();
break;
}
$response->set('html', $this->view->loadTemplate());
}
// Return the output
return $response;
}
示例10: trim
/**
* Decide on which Webception configuration file to load
* based on the 'test' query string parameter.
*
* If the test config is not found, it falls back to the default file.
*
* @param object $app Slim's App object.
* @return array Array of the application config.
*/
function get_webception_config($app)
{
$config = FALSE;
$test_type = $app->request()->params('test');
$webception_config = $app->config('webception');
// If the test query string parameter is set,
// a test config will be loaded.
if ($test_type !== NULL) {
// Sanitize the test type.
$test_type = trim(strtolower(remove_file_extension($test_type)));
// Filter the test type into the test string.
$test_config = sprintf($webception_config['test'], $test_type);
// Load the config if it can be found
if (file_exists($test_config)) {
$config = (require_once $test_config);
}
}
if ($config == FALSE) {
$config = (require_once $webception_config['config']);
}
return $config;
}
示例11: onProject
/**
* Event call to return data for a specific project
*
* @param object $model Project model
* @param string $action Plugin task
* @param string $areas Plugins to return data
* @return array Return array of html
*/
public function onProject($model, $action = 'view', $areas = null)
{
$arr = array('html' => '', 'metadata' => '', 'message' => '', 'error' => '');
// Get this area details
$this->_area = $this->onProjectAreas();
// Check if our area is in the array of areas we want to return results for
if (is_array($areas)) {
if (empty($this->_area) || !in_array($this->_area['name'], $areas)) {
return;
}
}
// Check authorization
if ($model->exists() && !$model->access('member')) {
return $arr;
}
// Model
$this->model = $model;
// Load component configs
$this->_config = $model->config();
$this->gitpath = $this->_config->get('gitpath', '/opt/local/bin/git');
// Incoming
$raw_op = Request::getInt('raw_op', 0);
$action = $action ? $action : Request::getVar('action', 'list');
// Get this area details
$this->_area = $this->onProjectAreas();
// Check if our area is in the array of areas we want to return results for
if (is_array($areas)) {
if (empty($this->_area) || !in_array($this->_area['name'], $areas)) {
return $arr;
}
}
$this->_database = App::get('db');
$this->_uid = User::get('id');
// Publishing?
if ($action == 'browser') {
return $this->browser();
}
if ($action == 'select') {
return $this->select();
}
$act_func = 'act_' . $action;
if (!method_exists($this, $act_func)) {
if ($raw_op) {
print json_encode(array('status' => 'success', 'data' => $table));
exit;
} else {
$act_func = 'act_list';
}
}
// detect CR as new line
ini_set('auto_detect_line_endings', true);
if ($raw_op) {
$this->{$act_func}();
exit;
} else {
Document::addScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
Document::addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js');
Document::addStyleSheet('//ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/smoothness/jquery-ui.css');
Document::addScript('/core/plugins/projects/databases/res/main.js');
Document::addStyleSheet('/core/plugins/projects/databases/res/main.css');
if (file_exists(__DIR__ . '/res/ds.' . $action . '.js')) {
Document::addScript('/core/plugins/projects/databases/res/ds.' . $action . '.js');
}
if (file_exists(__DIR__ . '/res/ds.' . $action . '.css')) {
Document::addStyleSheet('/core/plugins/projects/databases/res/ds.' . $action . '.css');
}
return $this->{$act_func}();
}
}
示例12: sendHUBMessage
/**
* Send hub message
*
* @param string $option
* @param object $project Models\Project
* @param array $addressees
* @param string $subject
* @param string $component
* @param string $layout
* @param string $message
* @param string $reviewer
* @return void
*/
public static function sendHUBMessage($option, $project, $addressees = array(), $subject = '', $component = '', $layout = 'admin', $message = '', $reviewer = '')
{
if (!$layout || !$subject || !$component || empty($addressees)) {
return false;
}
// Is messaging turned on?
if ($project->config()->get('messaging') != 1) {
return false;
}
// Set up email config
$from = array();
$from['name'] = Config::get('sitename') . ' ' . Lang::txt('COM_PROJECTS');
$from['email'] = Config::get('mailfrom');
// Html email
$from['multipart'] = md5(date('U'));
// Message body
$eview = new \Hubzero\Mail\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'site', 'name' => 'emails', 'layout' => $layout . '_plain'));
$eview->option = $option;
$eview->project = $project;
$eview->message = $message;
$eview->reviewer = $reviewer;
$body = array();
$body['plaintext'] = $eview->loadTemplate(false);
$body['plaintext'] = str_replace("\n", "\r\n", $body['plaintext']);
// HTML email
$eview->setLayout($layout . '_html');
$body['multipart'] = $eview->loadTemplate();
$body['multipart'] = str_replace("\n", "\r\n", $body['multipart']);
// Send HUB message
Event::trigger('xmessage.onSendMessage', array($component, $subject, $body, $from, $addressees, $option));
}
示例13: __construct
public function __construct(\Liten\Liten $liten = null)
{
$this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
if (ETSIS_FILE_CACHE_LOW_RAM && function_exists('memory_get_usage')) {
$limit = _trim(ini_get('memory_limit'));
$mod = strtolower($limit[strlen($limit) - 1]);
switch ($mod) {
case 'g':
$limit *= 1073741824;
break;
case 'm':
$limit *= 1048576;
break;
case 'k':
$limit *= 1024;
break;
}
if ($limit <= 0) {
$limit = 0;
}
$this->_memory_limit = $limit;
$limit = _trim(ETSIS_FILE_CACHE_LOW_RAM);
$mod = strtolower($limit[strlen($limit) - 1]);
switch ($mod) {
case 'g':
$limit *= 1073741824;
break;
case 'm':
$limit *= 1048576;
break;
case 'k':
$limit *= 1024;
break;
}
$this->_memory_low = $limit;
} else {
$this->_memory_limit = 0;
$this->_memory_low = 0;
}
/**
* Filter sets whether caching is enabled or not.
*
* @since 6.2.0
* @var bool
*/
$this->enable = $this->app->hook->apply_filter('enable_caching', true);
$this->persist = $this->enable && true;
/**
* File system cache directory.
*/
$dir = $this->app->config('file.savepath') . 'cache';
/**
* Fiter the file cache directory in order to override it
* in case some systems are having issues.
*
* @since 6.2.0
* @param string $dir
* The directory where file system cache files are saved.
*/
$cacheDir = $this->app->hook->apply_filter('filesystem_cache_dir', $dir);
/**
* If the cache directory does not exist, the create it first
* before trying to call it for use.
*/
if (!is_dir($cacheDir) || !file_exists($cacheDir)) {
_mkdir($cacheDir);
}
/**
* If the directory isn't writable, throw an exception.
*/
if (!etsis_is_writable($cacheDir)) {
return new \app\src\Core\Exception\Exception(_t('Could not create the file cache directory.'), 'cookie_cache');
}
/**
* Cache directory is set.
*/
$this->_dir = $cacheDir . DS;
}
示例14: notify
/**
* Send email
*
* @param object $publication Models\Publication
* @param array $addressees
* @param string $subject
* @param string $message
* @return void
*/
public static function notify($publication, $addressees = array(), $subject = NULL, $message = NULL, $hubMessage = false)
{
if (!$subject || !$message || empty($addressees)) {
return false;
}
// Is messaging turned on?
if ($publication->config('email') != 1) {
return false;
}
// Component params
$params = Component::params('com_publications');
$address = $params->get('curatorreplyto');
// Set up email config
$from = array();
$from['name'] = Config::get('sitename') . ' ' . Lang::txt('COM_PUBLICATIONS');
if (!isset($address) || $address == '') {
$from['email'] = Config::get('mailfrom');
} else {
$from['email'] = $address;
}
// Html email
$from['multipart'] = md5(date('U'));
// Get message body
$eview = new \Hubzero\Mail\View(array('base_path' => PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'site', 'name' => 'emails', 'layout' => '_plain'));
$eview->publication = $publication;
$eview->message = $message;
$eview->subject = $subject;
$body = array();
$body['plaintext'] = $eview->loadTemplate(false);
$body['plaintext'] = str_replace("\n", "\r\n", $body['plaintext']);
// HTML email
$eview->setLayout('_html');
$body['multipart'] = $eview->loadTemplate();
$body['multipart'] = str_replace("\n", "\r\n", $body['multipart']);
$body_plain = is_array($body) && isset($body['plaintext']) ? $body['plaintext'] : $body;
$body_html = is_array($body) && isset($body['multipart']) ? $body['multipart'] : NULL;
// Send HUB message
if ($hubMessage) {
Event::trigger('xmessage.onSendMessage', array('publication_status_changed', $subject, $body, $from, $addressees, 'com_publications'));
} else {
// Send email
foreach ($addressees as $userid) {
$user = User::getInstance(trim($userid));
if (!$user->get('id')) {
continue;
}
$mail = new \Hubzero\Mail\Message();
$mail->setSubject($subject)->addTo($user->get('email'), $user->get('name'))->addFrom($from['email'], $from['name'])->setPriority('normal');
$mail->addPart($body_plain, 'text/plain');
if ($body_html) {
$mail->addPart($body_html, 'text/html');
}
$mail->send();
}
}
}
示例15: onCourse
/**
* Return data on a course view (this will be some form of HTML)
*
* @param object $course Current course
* @param object $offering Name of the component
* @param boolean $describe Return plugin description only?
* @return object
*/
public function onCourse($course, $offering, $describe = false)
{
$response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', JText::_('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f086');
if ($describe) {
return $response;
}
if (!($active = Request::getVar('active'))) {
Request::setVar('active', $active = $this->_name);
}
$this->config = $course->config();
$this->course = $course;
$this->offering = $offering;
$this->database = App::get('db');
$this->params->merge(new \Hubzero\Config\Registry($offering->section()->get('params')));
// Determine if we need to return any HTML (meaning this is the active plugin)
if ($response->get('name') == $active) {
$this->_active = $this->_name;
$this->section = new \Components\Forum\Tables\Section($this->database);
$this->sections = $this->section->getRecords(array('state' => 1, 'scope' => 'course', 'scope_id' => $this->offering->get('id'), 'sort_Dir' => 'DESC', 'sort' => 'ordering ASC, created ASC, title'));
//option and paging vars
$this->option = 'com_courses';
$this->name = 'courses';
$this->limitstart = Request::getInt('limitstart', 0);
$this->limit = Request::getInt('limit', 500);
$action = '';
$u = strtolower(Request::getWord('unit', ''));
if ($u == 'manage') {
$action = 'sections';
$b = Request::getVar('group', '');
if ($b) {
Request::setVar('section', $b);
}
$c = Request::getVar('asset', '');
switch ($c) {
case 'orderdown':
$action = 'orderdown';
break;
case 'orderup':
$action = 'orderup';
break;
case 'edit':
$action = 'editsection';
break;
case 'delete':
$action = 'deletesection';
break;
case 'new':
$action = 'editcategory';
break;
default:
if ($c) {
Request::setVar('category', $c);
$action = 'editcategory';
}
$d = Request::getVar('d', '');
switch ($d) {
case 'edit':
$action = 'editcategory';
break;
case 'delete':
$action = 'deletecategory';
break;
default:
//$d = Request::setVar('thread', $c);
//$action = 'threads';
break;
}
break;
}
}
if (Request::getVar('file', '')) {
$action = 'download';
}
$action = Request::getVar('action', $action, 'post');
if (!$action) {
$action = Request::getVar('action', $action, 'get');
}
if ($action == 'edit' && Request::getInt('post', 0)) {
$action = 'editthread';
}
//push the stylesheet to the view
$this->css();
$this->base = $this->offering->link() . '&active=' . $this->_name;
Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $this->base);
switch ($action) {
case 'sections':
$response->set('html', $this->sections());
break;
case 'newsection':
$response->set('html', $this->sections());
break;
case 'editsection':
//.........这里部分代码省略.........