本文整理汇总了PHP中C::g方法的典型用法代码示例。如果您正苦于以下问题:PHP C::g方法的具体用法?PHP C::g怎么用?PHP C::g使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C
的用法示例。
在下文中一共展示了C::g方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public static function update($data)
{
//CHECK
$checks = array('defaultLanguage' => 'is_string-!is_empty', 'availableLanguages' => 'is_array-!is_empty', 'defaultBaseUrl' => 'is_string-!is_empty', 'availableBaseUrl' => 'is_array-!is_empty');
if (!KLib\Validator::arrayCheck($data, $checks)) {
throw new Exception('INVALID CONFIG DATA', 500);
}
if (!array_key_exists($data['defaultLanguage'], C::g('LIST_LANGUAGE'))) {
throw new Exception('INVALID CONFIG DATA', 500);
}
foreach ($data['availableLanguages'] as $id) {
if (!array_key_exists(strtoupper($id), C::g('LIST_LANGUAGE'))) {
throw new Exception('INVALID CONFIG DATA', 500);
}
$availableLanguages[] = "'" . strtoupper($id) . "'";
}
if (!filter_var('http://' . $data['defaultBaseUrl'], FILTER_VALIDATE_URL)) {
throw new Exception('INVALID CONFIG DATA', 500);
}
foreach ($data['availableBaseUrl'] as $id) {
if (!filter_var('http://' . $id, FILTER_VALIDATE_URL)) {
throw new Exception('INVALID CONFIG DATA', 500);
}
$availableBaseUrls[] = "'" . $id . "'";
}
$raw = "<?php\n### Default language\n### Index of LIST_LANGUAGE\nC::s('DEFAULT_LANG', '" . $data['defaultLanguage'] . "');\n### Language available\n### List of index of LIST_LANGUAGE\nC::s('DEFAULT_AVAILABLE_LANG', array(" . implode(', ', $availableLanguages) . "));\n### Default baseUrl\n### eg. 'www.korona.io'\nC::s('DEFAULT_BASEURL', '" . $data['defaultBaseUrl'] . "');\n### List of available baseUrl\n### eg. 'www.korona.io'\nC::s('DEFAULT_AVAILABLE_BASEURL', array(" . implode(', ', $availableBaseUrls) . "));";
return file_put_contents(self::$configPath, $raw);
}
示例2: setType
public function setType($data)
{
if (!is_string($data) || !array_key_exists($data, C::g('MENUITEM_TYPE'))) {
throw new Exception('INVALID MENUITEM TYPE PARAMETER', 500);
}
$this->type = $data;
}
示例3: updatePo
public function updatePo()
{
if (KLib\File::fileNameExtension($_FILES['file']['name']) != 'po') {
throw new Exception('FORBIDDEN ACCESS', 403);
}
if (move_uploaded_file($_FILES['file']['tmp_name'], $this->path . C::g('LANG_DOMAIN_CURRENT') . '.po')) {
return array('error' => 'OK');
}
return array('error' => 'FAIL');
}
示例4: go
/**
* Init a routing algo
* @param string $from URL source if not provide, Route::go will determine the good route from $_SERVER parameter
* @return mixed[]
*/
public static function go($published = true, $lang = 'FR', $host = null)
{
$host = !is_string($host) ? $_SERVER['HTTP_HOST'] : $host;
C::s('FULLURL', 'http://' . $host);
if (array_key_exists('HTTPS', $_SERVER)) {
C::s('FULLURL', 'https://' . $host);
}
$uri = parse_url($_SERVER['REQUEST_URI']);
if (substr($uri['path'], -1) == '/') {
$uri['path'] = substr($uri['path'], 0, -1);
}
$route = self::getRoute($host, $uri['path'], $_SERVER['REQUEST_METHOD']);
if (!is_a($route, 'KLib\\Router')) {
//PAGE
$data = \Page::getByUrl($host, $uri['path'], $lang, $published);
if (!is_a($data, 'Page') && $lang != C::g('DEFAULT_LANG')) {
$data = \Page::getByUrl($host, $uri['path'], C::g('DEFAULT_LANG'), $published);
}
if (!is_a($data, 'Page')) {
throw new \Exception('PAGE NOT FOUND', 404);
}
$route = new Self($data->getBaseUrl(), $uri['path'], $data->getAction(), $data->getMethod(), array_merge($_GET, array('page' => $data)));
}
if (!is_a($route, 'KLib\\Router')) {
throw new \Exception('PAGE NOT FOUND', 404);
}
return BaseController::run($route->getController(), $route->getAction(), $route->getArgs());
}
示例5: f
<?php
error_reporting(E_ALL | E_STRICT);
trait T
{
protected function f()
{
return 1;
}
private function p()
{
return 2;
}
function g()
{
return $this->f();
}
function h()
{
return $this->p();
}
}
class C
{
use T;
}
$c = new C();
echo $c->g();
echo $c->h();
示例6: urls
public function urls()
{
return array('static' => C::g('STATICURL'));
}
示例7: remove
/**
* Remove the page
*
* @param string $collection Collection to store
* @return null
*/
public function remove()
{
//LOAD
$datas = json_decode(file_get_contents(C::g('AUTH_FILE')), true);
//REMOVE
foreach ($datas as $k => $d) {
if ($d['id'] == $this->id) {
unset($datas[$k]);
}
}
file_put_contents(C::g('AUTH_FILE'), json_encode(array_values($datas), JSON_PRETTY_PRINT));
return true;
}
示例8: f1
<?php
class B
{
public function f1()
{
var_dump(get_called_class());
if ($this !== null) {
var_dump(get_class($this));
} else {
var_dump(null);
}
echo "\n";
}
}
class C extends B
{
public function g()
{
$obj = new B();
forward_static_call(array('B', 'f1'));
call_user_func(array('B', 'f1'));
}
}
$obj = new C();
$obj->g();
示例9: setLanguage
public function setLanguage($data)
{
if (!is_string($data) || empty($data) || !array_key_exists(strtoupper($data), C::g('LIST_LANGUAGE'))) {
$data = C::g('DEFAULT_LANG');
}
$this->language = strtoupper($data);
}
示例10: view
public function view()
{
$ret = array('defaultLanguage' => C::g('DEFAULT_LANG'), 'availableLanguages' => C::g('DEFAULT_AVAILABLE_LANG'), 'defaultBaseUrl' => C::g('DEFAULT_BASEURL'), 'availableBaseUrl' => C::g('DEFAULT_AVAILABLE_BASEURL'));
return $ret;
}
示例11: f
class C
{
/**
* @return self
*/
function f()
{
return $this;
}
/**
* @return static
*/
function g()
{
return $this;
}
/**
* @return $this
*/
function h()
{
return $this;
}
function test(C $c)
{
}
}
$c = new C();
$f = $c->test($c->f());
$g = $c->test($c->g());
$h = $c->test($c->h());
示例12: setLanguage
public function setLanguage($data)
{
if (!is_string($data) || empty($data) || !in_array(strtoupper($data), C::g('DEFAULT_AVAILABLE_LANG'))) {
$data = C::g('DEFAULT_LANG');
}
$this->language = strtoupper($data);
}
示例13:
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/page/{is_mongoid}', 'Page::delete', 'DELETE');
//KADMIN
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/user', 'Kadmin::all', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/user', 'Kadmin::add', 'POST');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/user/already', 'Kadmin::already', 'POST');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/user/{is_string}', 'Kadmin::view', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/user/{is_string}', 'Kadmin::update', 'PUT');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/user/{is_string}', 'Kadmin::delete', 'DELETE');
//MENU
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/menu', 'Menu::all', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/menu', 'Menu::add', 'POST');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/menu/{is_mongoid}', 'Menu::view', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/menu/{is_mongoid}', 'Menu::update', 'PUT');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/menu/{is_mongoid}', 'Menu::delete', 'DELETE');
//CONFIG
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/config', 'Config::view', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/config', 'Config::update', 'PUT');
//SEO
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/robot', 'Seo::robotView', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/robot', 'Seo::robotUpdate', 'PUT');
//BLOCK
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/block', 'Block::list', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/block/clone/{is_mongoid}', 'Block::clone', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/block/{is_mongoid}', 'Block::view', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/block/{is_mongoid}', 'Block::update', 'PUT');
//TRANSLATE
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/translate/po', 'Translate::po', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/translate/pot', 'Translate::pot', 'GET');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/translate/po', 'Translate::updatePo', 'POST');
RK::a(C::g('DEFAULT_BASEURL'), '/kadmin/translate/mo', 'Translate::updateMo', 'POST');
示例14: session_name
session_name('KNSESSID');
session_start();
require_once __DIR__ . '/global.inc.php';
try {
Router::loadPost();
Router::loadGet();
$published = true;
if (isset($_GET['force']) && $_GET['force'] == '1') {
$published = null;
}
KLib\RouterKorona::go($published);
} catch (Exception $e) {
//LOG EXCEPTION
if (!in_array($e->getCode(), array(200, 204, 542))) {
KLib\Log::info($e->getCode() . ' ' . $e->getMessage());
if (C::g('DEV')) {
KLib\Log::warning("\n" . $e->getTraceAsString());
}
header('Content-Type: text/html');
}
//FORMAT EXCEPTION
switch ($e->getCode()) {
case 204:
header('HTTP/1.1 204 OK');
break;
case 401:
KLib\BaseController::run('error', 'authenticate', array('exception' => $e));
break;
case 403:
KLib\BaseController::run('error', 'forbidden', array('exception' => $e));
break;
示例15: setLanguage
public function setLanguage($data)
{
if (!is_string($data) || empty($data)) {
throw new Exception('INVALID LANGUAGE BLOCK PARAMETER', 500);
}
if (in_array(strtoupper($data), C::g('DEFAULT_AVAILABLE_LANG'))) {
$this->language = strtoupper($data);
} else {
$this->language = C::g('DEFAULT_LANG');
}
}