本文整理汇总了PHP中site函数的典型用法代码示例。如果您正苦于以下问题:PHP site函数的具体用法?PHP site怎么用?PHP site使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了site函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->isSecure() && noah_installed() && site('forceSsl') == '1') {
return redirect($request->path(), 302, [], true);
}
return $next($request);
}
示例2: rules
public function rules()
{
$site_id = site()->id;
$publicable = true;
request()->merge(compact('site_id', 'publicable'));
return ['key' => 'required|unique:' . $this->getTable() . ',key,' . (string) $this->id . ',id,site_id,' . $site_id, 'value' => 'required'];
}
示例3: socialLogin
/**
* Redirect user to the related service auth.
*
* @param $service
* @return \Illuminate\Http\Response
*
* @author Cali
*/
public function socialLogin($service)
{
if (site($service . 'On') != '1') {
return redirect('/');
}
return Socialite::with($service)->redirect();
}
示例4: posterImage
/**
* Get the item's poster image object or a default image
*
* @return string
*/
public function posterImage()
{
if ($this->poster()->isNotEmpty()) {
return $this->image($this->poster());
}
return site()->image(site()->defaultPlaceImage());
}
示例5: categoryImage
/**
* Get the category image for calendar use
*
* @return File
*/
public function categoryImage()
{
if ($this->hasCalendarImage()) {
return $this->image($this->calendarImage());
}
return site()->image(site()->eventDefaultImage());
}
示例6: index
public function index()
{
if (site()->users()->count() > 0) {
go(panel()->urls()->login());
}
if ($problems = installation::check()) {
$content = view('installation/check', array('problems' => $problems));
} else {
$form = panel()->form('installation', array('language' => kirby()->option('panel.language', 'en')));
$form->cancel = false;
$form->save = l('installation.signup.button');
$form->centered = true;
foreach (panel()->languages() as $lang) {
$form->fields()->get('language')->options[$lang->code()] = $lang->title();
}
$form->on('submit', function ($form) {
try {
// fetch all the form data
$data = $form->serialize();
// make sure that the first user is an admin
$data['role'] = 'admin';
// try to create the new user
$user = panel()->site()->users()->create($data);
// store the new username for the login screen
s::set('username', $user->username());
// redirect to the login
go(panel()->urls()->login() . '/welcome');
} catch (Exception $e) {
$form->alert($e->getMessage());
}
});
$content = view('installation/signup', array('form' => $form));
}
return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content));
}
示例7: validateToken
/**
* Gatekeeper function that validates input forms and prevents csrf attacks.
* Call this from your form action code.
*
* @param string $targetURL The URL of the form action that brought us here.
* @param boolean $haltExecutionOnBadRequest If set to true, the function halts all execution if the form doesn't validate. (True by default.)
* @return true|false
*/
public static function validateToken($action = '', $haltExecutionOnBadRequest = true)
{
if (site()->session()->isAPIRequest()) {
return true;
}
return parent::validateToken($action, $haltExecutionOnBadRequest);
}
示例8: css
/**
* DISPLAY
*/
public function css()
{
if ($language = site()->language() and $language->direction() === 'rtl') {
$this->assets->setHook('css', tools::load('css', 'components/rtl'));
}
return '<style>' . $this->fontPaths($this->getHooks('css')) . '</style>';
}
示例9: registerPages
function registerPages()
{
site()->addPageHandler('/admin/?', '\\Idno\\Pages\\Admin\\Home');
site()->addPageHandler('/admin/plugins/?', '\\Idno\\Pages\\Admin\\Plugins');
site()->addPageHandler('/admin/dependencies/?', '\\Idno\\Pages\\Admin\\Dependencies');
site()->addPageHandler('/admin/about/?', '\\Idno\\Pages\\Admin\\About');
}
示例10: registerEvents
function registerEvents()
{
\Idno\Core\site()->addEventHook('saved', function (\Idno\Core\Event $event) {
$eventdata = $event->data();
if ($object = $eventdata['object']) {
if (site()->session()->isLoggedOn()) {
if (!empty(site()->session()->currentUser()->robot_state)) {
$user = site()->session()->currentUser();
switch ($user->robot_state) {
case '1':
if (class_exists('IdnoPlugins\\Status') && $object instanceof \IdnoPlugins\Status) {
$user->robot_state = '2a';
} else {
$user->robot_state = '2b';
}
self::$changed_state = 1;
break;
case '2a':
if (class_exists('IdnoPlugins\\Photo') && $object instanceof \IdnoPlugins\Photo) {
$user->robot_state = '3a';
}
self::$changed_state = 1;
break;
case '2b':
$user->robot_state = '3b';
self::$changed_state = 1;
break;
}
$user->save();
site()->session()->refreshSessionUser($user);
}
}
}
});
}
示例11: login
public function login($welcome = null)
{
if ($user = panel()->site()->user()) {
go(panel()->urls()->index());
}
$message = l('login.error');
$error = false;
$form = panel()->form('login');
$form->cancel = false;
$form->save = l('login.button');
$form->centered = true;
if (r::is('post') and get('_csfr') and csfr(get('_csfr'))) {
$data = $form->serialize();
$user = site()->user(str::lower($data['username']));
if (!$user) {
$error = true;
} else {
if (!$user->hasPanelAccess()) {
$error = true;
} else {
if (!$user->login(get('password'))) {
$error = true;
} else {
go(panel()->urls()->index());
}
}
}
}
if ($username = s::get('username')) {
$form->fields->username->value = html($username, false);
}
return layout('login', array('meta' => new Snippet('meta'), 'welcome' => $welcome ? l('login.welcome') : '', 'form' => $form, 'error' => $error ? $message : false));
}
示例12: structure
public function structure($id, $fieldName, $context)
{
$page = empty($id) ? site() : page($id);
if (!$page) {
throw new Exception('The page could not be found');
}
$blueprint = blueprint::find($page);
$field = null;
$fields = $context == 'file' ? $blueprint->files()->fields() : $blueprint->fields();
// make sure to get fields by case insensitive field names
foreach ($fields as $f) {
if (strtolower($f->name) == strtolower($fieldName)) {
$field = $f;
}
}
if (!$field) {
throw new Exception('The field could not be found');
}
$fields = new Blueprint\Fields($field->fields(), $page);
$fields = $fields->toArray();
foreach ($fields as $key => $field) {
if ($field['type'] == 'textarea') {
$fields[$key]['buttons'] = false;
}
}
$form = new Form($fields, null, $fieldName);
$form->save = get('_id') ? l('fields.structure.save') : l('fields.structure.add');
return view('editor/structure', array('page' => $page, 'form' => $form));
}
示例13: show
/**
* DISPLAY
*/
public static function show($args = array())
{
if ($user = site()->user() and $user->hasPanelAccess()) {
$self = new self($args);
return $self->_output();
}
}
示例14: items
protected function items($page, $method)
{
switch ($method) {
case 'visibleChildren':
$items = $page->children()->visible();
break;
case 'invisibleChildren':
$items = $page->children()->invisible();
break;
case 'siblings':
$items = $page->siblings()->not($page);
break;
case 'pages':
$items = site()->index();
$items = $items->sortBy('title', 'asc');
break;
case 'index':
$items = $page->index();
$items = $items->sortBy('title', 'asc');
break;
case 'children':
case 'files':
case 'images':
case 'documents':
case 'videos':
case 'audio':
case 'code':
case 'archives':
$items = $page->{$method}();
break;
}
return $items;
}
示例15: signup
protected function signup()
{
$self = $this;
$form = $this->form('installation/signup', array(), function ($form) use($self) {
$form->validate();
if (!$form->isValid()) {
return false;
}
try {
// fetch all the form data
$data = $form->serialize();
// make sure that the first user is an admin
$data['role'] = 'admin';
// try to create the new user
$user = site()->users()->create($data);
// store the new username for the login screen
s::set('username', $user->username());
// try to login the user automatically
if ($user->hasPanelAccess()) {
$user->login($data['password']);
}
// redirect to the login
$self->redirect('login');
} catch (Exception $e) {
$form->alert($e->getMessage());
}
});
return $this->modal('index', compact('form'));
}