本文整理汇总了PHP中Str::camilize方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::camilize方法的具体用法?PHP Str::camilize怎么用?PHP Str::camilize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::camilize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public static function load($path = '')
{
if (!empty($path) and !in_array($path, self::$loaded)) {
$path = !empty($path) ? '\\' . trim($path, '\\') : '';
$lang_class = '\\GCore' . $path . '\\Locales\\EnGb\\Lang';
$cutsom_lang = '\\GCore' . $path . '\\Locales\\' . Str::camilize(str_replace('-', '_', strtolower(Base::getConfig('site_language', 'en-gb')))) . '\\Lang';
if (class_exists($cutsom_lang)) {
if (class_exists($lang_class)) {
//load default language as well
$lang_class_loaded = new \ReflectionClass($lang_class);
self::$translations = array_merge((array) self::$translations, $lang_class_loaded->getConstants(), $lang_class_loaded->getStaticProperties());
self::$loaded[] = $path;
}
$lang_class = $cutsom_lang;
}
if (!class_exists($lang_class)) {
return false;
}
$lang_class_loaded = new \ReflectionClass($lang_class);
self::$translations = array_merge((array) self::$translations, $lang_class_loaded->getConstants(), $lang_class_loaded->getStaticProperties());
self::$loaded[] = $path;
return true;
}
return false;
}
示例2: getInstance
public static function getInstance($handler = 'php', $params = array())
{
if ($handler != 'php') {
if (empty(self::$instances[$handler])) {
$class = '\\GCore\\Libs\\SessionHandlers\\' . Str::camilize($handler);
self::$instances[$handler] = new $class($params);
}
return self::$instances[$handler];
}
}
示例3: getInstance
public static function getInstance($domain = 'gcore', $params = array(), $engine = 'file')
{
$domain = !empty($domain) ? $domain : 'gcore';
$engine = func_num_args() > 2 ? $engine : Base::getConfig('cache_engine');
if (empty(self::$instances[$engine][$domain])) {
$class = '\\GCore\\Libs\\CacheEngines\\' . Str::camilize($engine);
self::$instances[$engine][$domain] = new $class($domain, $params);
}
return self::$instances[$engine][$domain];
}
示例4: getInstance
public static function getInstance($options = array())
{
if (!empty($options)) {
$db_adapter_class = '\\GCore\\Libs\\DatabaseAdapters\\' . Str::camilize(Base::getConfig('db_adapter', 'pdo'));
$new_object = new $db_adapter_class($options);
return $new_object;
} else {
return false;
}
}
示例5: getInstance
public static function getInstance($options = array())
{
if (!empty($options)) {
$db_adapter_class = '\\GCore\\Libs\\DatabaseAdapters\\' . Str::camilize(Base::getConfig('db_adapter', 'pdo'));
$new_object = new $db_adapter_class($options);
$new_object->_initialize($options);
//$db_processor_class = '\GCore\Libs\DatabaseProcessors\\'.Str::camilize($new_object->db_type);
//$new_object->processor = new $db_processor_class();
return $new_object;
} else {
return false;
}
}
示例6: _save_settings
function _save_settings($ext)
{
$settings_model = new \GCore\Admin\Models\Extension();
$extenion_name = Str::camilize($ext);
//check data exist
$settings = $settings_model->find('first', array('conditions' => array('name' => $ext)));
if (!empty($this->data[$extenion_name])) {
if (!empty($settings['Extension']['settings'])) {
$this->data[$extenion_name] = array_merge($settings['Extension']['settings'], $this->data[$extenion_name]);
return $settings_model->save(array('settings' => $this->data[$extenion_name]), array('conditions' => array('name' => $ext)));
} else {
return $settings_model->save(array('name' => $ext, 'enabled' => 1, 'settings' => $this->data[$extenion_name]));
}
}
return false;
}
示例7: trigger
public static function trigger()
{
$args = func_get_args();
if (!empty($args)) {
$event = array_shift($args);
$extensions = self::get_extensions();
$prefix = '\\GCore';
$site = '';
if (GCORE_SITE == 'admin') {
$site = '\\Admin';
$prefix = '\\GCore\\Admin';
}
$return = array();
foreach ($extensions as $extension) {
if (is_callable(array($prefix . '\\Extensions\\' . Str::camilize($extension) . '\\' . Str::camilize($extension) . 'Events', $event))) {
Lang::load($site . '\\Extensions\\' . Str::camilize($extension));
$return[] = call_user_func_array(array($prefix . '\\Extensions\\' . Str::camilize($extension) . '\\' . Str::camilize($extension) . 'Events', $event), self::get_references($args));
}
}
return $return;
}
return null;
}
示例8: set_params
public static function set_params($extension, $path_chunks = array(), $type = 'extension')
{
$route_vars = array();
if ($type == 'extension') {
$ext_router = '\\GCore\\Extensions\\' . Str::camilize($extension) . '\\' . Str::camilize($extension) . 'Router';
} else {
$ext_router = '\\GCore\\Controllers\\' . Str::camilize($extension) . 'Router';
}
if (class_exists($ext_router)) {
//some url params should be processed
if (method_exists($ext_router, 'translate')) {
$route_vars = (array) $ext_router::translate($path_chunks);
} else {
if (!empty($ext_router::$params) and !empty($path_chunks)) {
foreach ($ext_router::$params as $k => $param) {
//check if param index exists in the current path
if (array_key_exists($k, $path_chunks)) {
if (strlen(Request::data($param)) != 0) {
//param has been already set through a page param for example
continue;
}
//Request::set($param, $path_chunks[$k]);
if ($param == 'cont') {
$route_vars['controller'] = $path_chunks[$k];
continue;
}
if ($param == 'act') {
$route_vars['action'] = $path_chunks[$k];
continue;
}
$route_vars[$param] = $path_chunks[$k];
//Request::set('_Route.'.$param, $path_chunks[$k]);
} else {
//break on the first non existent param
break;
}
}
}
}
}
return $route_vars;
}
示例9: dispatch
function dispatch($content_only = false)
{
Event::trigger('on_before_dispatch', $this);
$session = Base::getSession();
reset:
//if no action set, set it to index
if (strlen(trim($this->action)) == 0) {
$this->action = 'index';
}
//set admin path
$site = '';
if ($this->site == 'admin') {
$site = '\\Admin';
}
//load the extension class
$controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
$extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
$classname = '\\GCore' . $site . $extension . $controller;
$this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
//set referer
if (!$content_only) {
if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
//$session->set('_referer', Url::current());
} else {
//$session->set('_referer', 'index.php');
}
}
$G_User = $session->get('user', array());
//check permissions
$J_User = \JFactory::getUser();
if (empty($J_User->groups) or empty($G_User['groups']) or array_values($J_User->groups) !== $G_User['groups'] or empty($G_User['inheritance'])) {
$user_session = array();
$user_session['id'] = $J_User->id;
$user_session['name'] = $J_User->name;
$user_session['username'] = $J_User->username;
$user_session['email'] = $J_User->email;
$user_session['last_login'] = $J_User->lastvisitDate;
$user_session['logged_in'] = !$J_User->guest;
$user_session['guest'] = $J_User->guest;
$user_session['groups'] = empty($J_User->groups) ? array(1) : array_values($J_User->groups);
$user_session['inheritance'] = array();
if (!empty($J_User->groups)) {
//sort groups
$groups = \GCore\Admin\Models\Group::getInstance()->find('all', array('order' => 'Group.parent_id ASC'));
$valid_groups = array_intersect($user_session['groups'], \GCore\Libs\Arr::getVal($groups, array('[n]', 'Group', 'id')));
if (!empty($groups) and $valid_groups) {
reloop:
foreach ($groups as $group) {
//if this group exists in the user's groups or its inheitance then add its parent_id
if (in_array($group['Group']['id'], $user_session['groups']) or in_array($group['Group']['id'], $user_session['inheritance'])) {
$user_session['inheritance'][] = $group['Group']['parent_id'];
}
}
//find the number of occurances of each group in the inheritane
$groups_counted = array_count_values($user_session['inheritance']);
//if the count of root parent (0 parent_id) is less than the count of user's groups then not all pathes have been found, reloop
if (count($user_session['groups']) and !isset($groups_counted[0]) or $groups_counted[0] < count($user_session['groups'])) {
goto reloop;
} else {
$user_session['inheritance'] = array_unique($user_session['inheritance']);
}
}
}
if ($session->get('user', array()) !== $user_session) {
$session->clear('acos_permissions');
}
$session->set('user', array_merge($session->get('user', array()), $user_session));
}
//copy some config
$mainframe = \JFactory::getApplication();
//set timezone
date_default_timezone_set($mainframe->getCfg('offset'));
//site title
\GCore\Libs\Base::setConfig('site_title', $mainframe->getCfg('sitename'));
//$lang = \JFactory::getLanguage();
//\GCore\Libs\Base::setConfig('site_language', $lang->getTag());
/*if(!Authorize::authorized($classname, $this->action)){
if($content_only){
return;
}
$this->redirect(r_('index.php?cont=users&act=login'));
}*/
//if the extension class not found or the action function not found then load an error
if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
$this->controller = 'errors';
$this->action = 'e404';
//reset the controller
//$classname = '\GCore\Controllers\Errors';
$this->buffer = 'Page not found';
\GCore\Libs\Env::e404();
\JError::raiseError(404, $this->buffer);
//we need the rendered content only
if ($content_only) {
return;
}
}
//load language file
if (!empty($extension)) {
Lang::load($site . $extension);
}
//.........这里部分代码省略.........
示例10: dispatch
function dispatch($content_only = false)
{
Event::trigger('on_before_dispatch', $this);
$session = Base::getSession();
reset:
//if no action set, set it to index
if (strlen(trim($this->action)) == 0) {
$this->action = 'index';
}
//set admin path
$site = '';
if ($this->site == 'admin') {
$site = '\\Admin';
}
//load the extension class
$controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
$extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
$classname = '\\GCore' . $site . $extension . $controller;
$this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
//set referer
if (!$content_only) {
if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
//$session->set('_referer', Url::current());
} else {
//$session->set('_referer', 'index.php');
}
}
$G_User = $session->get('user', array());
//check permissions
/*
$J_User = \JFactory::getUser();
if(empty($J_User->groups) OR empty($G_User['groups']) OR (array_values($J_User->groups) !== $G_User['groups']) OR empty($G_User['inheritance'])){
$user_session = array();
$user_session['id'] = $J_User->id;
$user_session['name'] = $J_User->name;
$user_session['username'] = $J_User->username;
$user_session['email'] = $J_User->email;
$user_session['last_login'] = $J_User->lastvisitDate;
$user_session['logged_in'] = !$J_User->guest;
$user_session['guest'] = $J_User->guest;
$user_session['groups'] = empty($J_User->groups) ? array(1) : array_values($J_User->groups);
$user_session['inheritance'] = array();
if(!empty($J_User->groups)){
//sort groups
$groups = \GCore\Admin\Models\Group::getInstance()->find('all', array('order' => 'Group.parent_id ASC'));
if(!empty($groups)){
reloop:
foreach($groups as $group){
//if this group exists in the user's groups or its inheitance then add its parent_id
if(in_array($group['Group']['id'], $user_session['groups']) OR in_array($group['Group']['id'], $user_session['inheritance'])){
$user_session['inheritance'][] = $group['Group']['parent_id'];
}
}
//find the number of occurances of each group in the inheritane
$groups_counted = array_count_values($user_session['inheritance']);
//if the count of root parent (0 parent_id) is less than the count of user's groups then not all pathes have been found, reloop
if((count($user_session['groups']) AND !isset($groups_counted[0])) OR $groups_counted[0] < count($user_session['groups'])){
goto reloop;
}else{
$user_session['inheritance'] = array_unique($user_session['inheritance']);
}
}
}
if($session->get('user', array()) !== $user_session){
$session->clear('acos_permissions');
}
$session->set('user', array_merge($session->get('user', array()), $user_session));
}
*/
//set timezone
date_default_timezone_set(get_option('timezone_string'));
//site title
\GCore\Libs\Base::setConfig('site_title', get_bloginfo('name'));
/*if(!Authorize::authorized($classname, $this->action)){
if($content_only){
return;
}
$this->redirect(r_('index.php?cont=users&act=login'));
}*/
//if the extension class not found or the action function not found then load an error
if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
$this->controller = 'errors';
$this->action = 'e404';
//reset the controller
//$classname = '\GCore\Controllers\Errors';
$this->buffer = 'Page not found';
\GCore\Libs\Env::e404();
//we need the rendered content only
if ($content_only) {
return;
}
}
//load language file
if (!empty($extension)) {
Lang::load($site . $extension);
}
//set theme
$doc = Document::getInstance($this->site, $this->thread);
$doc->theme = 'bootstrap3';
//$theme = \GCore\Helpers\Theme::getInstance();
//.........这里部分代码省略.........
示例11: dispatch
function dispatch($content_only = false, $check_perm = true)
{
Event::trigger('on_before_dispatch', $this);
$session = Base::getSession();
reset:
//if no action set, set it to index
if (strlen(trim($this->action)) == 0) {
$this->action = 'index';
}
//set admin path
$site = '';
if ($this->site == 'admin') {
$site = '\\Admin';
}
//load the extension class
$controller = !empty($this->controller) ? '\\Controllers\\' . Str::camilize($this->controller) : '\\' . Str::camilize($this->extension);
$extension = !empty($this->extension) ? '\\Extensions\\' . Str::camilize($this->extension) : '';
$classname = '\\GCore' . $site . $extension . $controller;
$this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout;
//set referer
if (!$content_only) {
if (!($this->controller == 'users' and ($this->action == 'login' or $this->action == 'logout' or $this->action == 'register')) and (!empty($this->extension) or !empty($this->controller)) and $this->tvout == 'index') {
$session->set('_referer', Url::current());
} else {
//$session->set('_referer', 'index.php');
}
}
//check permissions
if ($check_perm and !Authorize::authorized($classname, $this->action)) {
if ($content_only) {
return;
}
$this->redirect(r_('index.php?cont=users&act=login'));
}
//if the extension class not found or the action function not found then load an error
if (!class_exists($classname) or !in_array($this->action, get_class_methods($classname)) and !in_array('__call', get_class_methods($classname)) or substr($this->action, 0, 1) == '_') {
$this->controller = 'errors';
$this->action = 'e404';
//reset the controller
$classname = '\\GCore\\Controllers\\Errors';
\GCore\Libs\Env::e404();
//we need the rendered content only
if ($content_only) {
return;
}
}
//load language file
if (!empty($extension)) {
Lang::load($site . $extension);
}
//set theme
$doc = Document::getInstance($this->site, $this->thread);
$doc->theme = 'bootstrap3';
//'gcoreui';//'semantic1';
$theme = \GCore\Helpers\Theme::getInstance();
// in gcore app, bootstrap should be always loaded first with jquery
//load class and run the action
${$classname} = new $classname($this->site, $this->thread);
ob_start();
$continue = ${$classname}->_initialize();
//check and read cache
if (!empty(${$classname}->cache)) {
if (!is_array(${$classname}->cache)) {
${$classname}->cache = array();
}
if (empty(${$classname}->cache['time'])) {
${$classname}->cache['time'] = Base::getConfig('app_cache_expiry', 900);
}
if (empty(${$classname}->cache['title'])) {
${$classname}->cache['title'] = File::makeSafe($classname . '_' . $this->action);
} else {
${$classname}->cache['title'] = File::makeSafe(${$classname}->cache['title']);
}
if (empty(${$classname}->cache['key'])) {
${$classname}->cache['key'] = 'cached_view';
} else {
${$classname}->cache['key'] = 'cached_view_' . ${$classname}->cache['key'];
}
$cache = Cache::getInstance(${$classname}->cache['title'], array('expiration' => ${$classname}->cache['time']));
$cached_view = $cache->get(${$classname}->cache['key']);
$cached = false;
if (!empty($cached_view)) {
$cached = true;
$continue = false;
echo $cached_view;
}
}
if ($continue !== false) {
${$classname}->{$this->action}();
if ($this->reset === true) {
$this->reset = false;
goto reset;
}
//initialize and render view
$view = new View();
$view->initialize(${$classname});
$view->renderView($this->action);
}
//get the action output buffer
$this->buffer = ob_get_clean();
//.........这里部分代码省略.........