当前位置: 首页>>代码示例>>PHP>>正文


PHP Site::config方法代码示例

本文整理汇总了PHP中Site::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::config方法的具体用法?PHP Site::config怎么用?PHP Site::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Site的用法示例。


在下文中一共展示了Site::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionContent

 protected function actionContent($params)
 {
     if (!isset($params['slug'])) {
         $params['slug'] = '';
     }
     $content = \GO\Site\Model\Content::model()->findBySlug($params['slug']);
     if (!$content) {
         header("HTTP/1.0 404 Not Found");
         header("Status: 404 Not Found");
         echo $this->render('/site/404');
     } else {
         $this->setPageTitle($content->metaTitle);
         if (!empty($content->meta_description)) {
             \Site::scripts()->registerMetaTag($content->meta_description, 'description');
         }
         if (!empty($content->meta_keywords)) {
             \Site::scripts()->registerMetaTag($content->meta_keywords, 'keywords');
         }
         // Check if the template is not empty
         if (empty($content->template)) {
             $defaultTemplate = \Site::config()->getDefaultTemplate();
             if (!empty($defaultTemplate)) {
                 $content->template = $defaultTemplate;
             }
         }
         echo $this->render($content->template, array('content' => $content));
     }
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:28,代码来源:FrontController.php

示例2: testPostCreatePrivateSite

 /**
  * Verifies 'enforce private' setting when creating pastes
  */
 public function testPostCreatePrivateSite()
 {
     $this->initTestStep();
     Site::config('general', array('paste_visibility' => 'private'));
     $key = 'UnitTest::Protected' . str_random(64);
     $response = $this->call('POST', 'create', array('title' => 'UnitTest::Title', 'data' => $key, 'language' => 'text'));
     Site::config('general', array('paste_visibility' => 'default'));
     $this->assertRedirectedTo($response->getTargetUrl());
     $this->assertEquals(Paste::where('data', $key)->first()->private, 1);
 }
开发者ID:moises-silva,项目名称:sticky-notes,代码行数:13,代码来源:CreateTest.php

示例3: testPostRegister

 /**
  * Tests the postRegister method of the controller
  */
 public function testPostRegister()
 {
     $this->initTestStep();
     // Disable the captcha
     Site::config('auth', array('db_show_captcha' => 0, 'db_allow_reg' => 1));
     // Generate a random user key
     $key = 'unittest' . time();
     $this->call('POST', 'user/register', array('username' => $key, 'password' => $key, 'email' => "{$key}@test.com"));
     $this->assertRedirectedTo('user/login');
     $this->assertEquals(User::where('username', $key)->count(), 1);
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:14,代码来源:UserTest.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Get the config group, key and value
     $group = $this->option('group');
     $key = $this->option('key');
     $value = $this->option('value');
     // Group, key and value are mandatory options
     if (!empty($group) and !empty($key) and !empty($value)) {
         Site::config($group, array($key => $value));
         $this->info('Configuration data saved successfully. Please delete the contents of `app/storage/cache` folder for your changes to take effect.');
     } else {
         $this->error('Insufficient arguments specified.');
         $this->error('Usage: snconfig:get --group="..." --key="..." --value="..."');
     }
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:20,代码来源:ConfigWriter.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Get the config group and key
     $group = $this->option('group');
     $key = $this->option('key');
     // Both group and key are mandatory options
     if (!empty($group) and !empty($key)) {
         $values = Site::config($group);
         if (isset($values->{$key})) {
             $this->info($values->{$key});
         } else {
             $this->error('No config data exists for given key.');
         }
     } else {
         $this->error('Insufficient arguments specified.');
         $this->error('Usage: snconfig:get --group="..." --key="..."');
     }
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:23,代码来源:ConfigReader.php

示例6: postCreate

 /**
  * Creates a new paste item
  *
  * @return \Illuminate\Support\Facades\Redirect
  */
 public function postCreate()
 {
     // Get the site configuration
     $site = Site::config('general');
     // Define validation rules
     $validator = Validator::make(Input::all(), array('title' => 'max:30', 'data' => 'required|auth|mbmax:' . $site->maxPasteSize, 'language' => 'required|in:' . Highlighter::make()->languages(TRUE), 'expire' => 'in:' . Paste::getExpiration('create', TRUE)));
     // Generate anti-spam modules
     $antispam = Antispam::make('paste', 'data');
     // Run validations
     $resultValidation = $validator->passes();
     // Execute antispam services
     $resultAntispam = $antispam->passes();
     // Get the paste language. We use it to store a language history
     $language = Input::get('language');
     $historyLangs = Cookie::get('languages');
     // History languages must always be an array
     $historyLangs = is_array($historyLangs) ? $historyLangs : array();
     // No dulicates allowed in the history
     if (in_array($language, $historyLangs)) {
         $key = array_search($language, $historyLangs);
         unset($historyLangs[$key]);
     } else {
         if (count($historyLangs) >= 10) {
             $historyLangs = array_slice($historyLangs, 1, count($historyLangs));
         }
     }
     // Add current language to the history
     array_push($historyLangs, $language);
     $cookie = Cookie::forever('languages', $historyLangs);
     // Evaluate validation results
     if ($resultValidation and $resultAntispam) {
         // We inject the project into the input so that
         // it is also inserted into the DB accordingly
         Input::merge(array('project' => $this->project));
         // All OK! Create the paste already!!
         $paste = Paste::createNew('web', Input::all());
         // Now, save the attachment, if any (and if enabled)
         if ($site->allowAttachment and Input::hasFile('attachment')) {
             $file = Input::file('attachment');
             if ($file->isValid()) {
                 $file->move(storage_path() . '/uploads', $paste->urlkey);
             }
         }
         // Redirect to paste if there's no password
         // Otherwise, just show a link
         if ($paste->password) {
             $url = link_to("{$paste->urlkey}/{$paste->hash}");
             $message = sprintf(Lang::get('create.click_for_paste'), $url);
             Session::flash('messages.success', $message);
         } else {
             return Redirect::to(Paste::getUrl($paste))->withCookie($cookie);
         }
     } else {
         // Set the error message as flashdata
         if (!$resultValidation) {
             Session::flash('messages.error', $validator->messages()->all('<p>:message</p>'));
         } else {
             if (!$resultAntispam) {
                 Session::flash('messages.error', $antispam->message());
             }
         }
     }
     return Redirect::to(URL::previous())->withInput()->withCookie($cookie);
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:69,代码来源:CreateController.php

示例7: function

    return TRUE;
});
Validator::replacer('mbmax', function ($message, $attribute, $rule, $parameters) {
    return str_replace(':max', $parameters[0], $message);
});
/*
|--------------------------------------------------------------------------
| Trust proxy headers
|--------------------------------------------------------------------------
|
| Checks if the site is behind a proxy server (or a load balancer) and
| set whether to trust the client IP sent in the request that comes via
| the proxy intermediary.
|
*/
if (Site::config('general')->proxy) {
    // Trust the client proxy address
    Request::setTrustedProxies(array(Request::getClientIp()));
    // Trust the client IP header
    Request::setTrustedHeaderName(\Symfony\Component\HttpFoundation\Request::HEADER_CLIENT_IP, 'X-Forwarded-For');
    // Trust the client protocol header
    Request::setTrustedHeaderName(\Symfony\Component\HttpFoundation\Request::HEADER_CLIENT_PROTO, 'X-Forwarded-Proto');
}
/*
|--------------------------------------------------------------------------
| Handle application errors
|--------------------------------------------------------------------------
|
| Shows custom screens for app errors. This is mainly done to show a
| friendly error message and to throw errors with ease from the view.
|
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:31,代码来源:global.php

示例8: postCreate

 /**
  * Creates a new paste via the API
  *
  * @param  string  $mode
  * @return \Illuminate\Support\Facades\View
  */
 public function postCreate($mode)
 {
     $api = API::make($mode);
     // Set custom messages for validation module
     $custom = array('title.max' => 'title_max_30', 'data.required' => 'data_required', 'data.auth' => 'cannot_post', 'data.mbmax' => 'data_too_big', 'language.required' => 'lang_required', 'language.in' => 'lang_invalid', 'expire.integer' => 'expire_integer', 'expire.in' => 'expire_invalid');
     // Define validation rules
     $validator = Validator::make(Input::all(), array('title' => 'max:30', 'data' => 'required|auth|mbmax:' . Site::config('general')->maxPasteSize, 'language' => 'required|in:' . Highlighter::make()->languages(TRUE), 'expire' => 'integer|in:' . Paste::getExpiration('create', TRUE)), $custom);
     // Run validations
     if ($validator->fails()) {
         return $api->error($validator->messages()->first());
     }
     // Set custom messages for the antispam module
     $custom = array('ipban' => 'antispam_ipban', 'stealth' => 'antispam_stealth', 'censor' => 'antispam_censor', 'noflood' => 'antispam_noflood', 'php' => 'antispam_php');
     // Instantiate the antispam module
     $antispam = Antispam::make('api_call', 'data', $custom);
     // Run the anti-spam modules
     if ($antispam->fails()) {
         return $api->error($antispam->message());
     }
     // Create the paste like a boss!
     $paste = Paste::createNew('api', Input::all());
     // All done! Now we need to output the urlkey and hash
     $data = array('urlkey' => $paste->urlkey, 'hash' => $paste->hash);
     // Return the output
     return $api->out('create', $data);
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:32,代码来源:ApiController.php

示例9: postComment

 /**
  * Handles the paste password submission
  *
  * @param  string  $urlkey
  * @param  string  $hash
  * @return \Illuminate\Support\Facades\Redirect|null
  */
 public function postComment()
 {
     if (Site::config('general')->comments) {
         // Define validation rules
         $validator = Validator::make(Input::all(), array('comment' => 'required|auth|min:5|max:1024'));
         // Generate anti-spam modules
         $antispam = Antispam::make('comment', 'comment');
         // Run validations
         $resultValidation = $validator->passes();
         // Execute antispam services
         $resultAntispam = $antispam->passes();
         if ($resultValidation and $resultAntispam) {
             // Get the associated paste
             $paste = Paste::findOrFail(Input::get('id'));
             // Insert the new comment
             if (!is_null($paste)) {
                 $comment = new Comment();
                 $comment->paste_id = $paste->id;
                 $comment->data = nl2br(strip_tags(Input::get('comment')));
                 $comment->author = Auth::check() ? Auth::user()->username : Lang::get('global.anonymous');
                 $comment->timestamp = time();
                 $comment->save();
             }
             return Redirect::to(URL::previous());
         } else {
             // Set the error message as flashdata
             if (!$resultValidation) {
                 Session::flash('messages.error', $validator->messages()->all('<p>:message</p>'));
             } else {
                 if (!$resultAntispam) {
                     Session::flash('messages.error', $antispam->message());
                 }
             }
             return Redirect::to(URL::previous())->withInput();
         }
     } else {
         App::abort(401);
         // Unauthorized
     }
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:47,代码来源:ShowController.php

示例10: function

    });
});
// API routes
Route::get('api/{mode}/parameter/{param}', 'ApiController@getParameter');
Route::get('api/{mode}/show/{urlkey}/{hash?}/{password?}', 'ApiController@getShow');
Route::get('api/{mode}/list/{page?}', 'ApiController@getList');
Route::post('api/{mode}/create', 'ApiController@postCreate');
// Feed routes
Route::get('feed/{type?}', 'FeedController@getFeed')->where('type', 'rss');
// AJAX routes
Route::controller('ajax', 'AjaxController');
// Application setup routes
Route::controller('setup', 'SetupController');
// Documentation routes
Route::get('docs', function () {
    return Redirect::to(Site::config('services')->docsUrl);
});
// User operation routes
Route::get('user/login', 'UserController@getLogin');
Route::post('user/login', 'UserController@postLogin');
Route::get('user/logout', 'UserController@getLogout');
Route::get('user/register', 'UserController@getRegister');
Route::get('user/forgot', 'UserController@getForgot');
// DB-only user operations
Route::group(array('before' => 'auth.config'), function () {
    // Submit user registration
    Route::post('user/register', 'UserController@postRegister');
    // Submit forgot password
    Route::post('user/forgot', 'UserController@postForgot');
    // Submit user profile
    Route::group(array('before' => 'auth'), function () {
开发者ID:moises-silva,项目名称:sticky-notes,代码行数:31,代码来源:routes.php

示例11: postRegister

 /**
  * Handles POST requests on the registration screen
  *
  * @access public
  * @return \Illuminate\Support\Facades\Redirect
  */
 public function postRegister()
 {
     // Define validation rules
     $rules = array('username' => 'required|max:50|alpha_dash|unique:users,username,-1,id,type,db', 'email' => 'required|max:100|email|unique:users,email,-1,id,type,db', 'dispname' => 'max:100', 'password' => 'required|min:5');
     // Check if captcha is enabled, and if it is, validate it
     if (Site::config('auth')->dbShowCaptcha) {
         $rules['captcha'] = 'required|captcha';
     }
     $validator = Validator::make(Input::all(), $rules);
     // Run the validator
     if ($validator->passes()) {
         $user = new User();
         $user->username = Input::get('username');
         $user->email = Input::get('email');
         $user->dispname = Input::get('dispname');
         $user->salt = str_random(5);
         $user->password = PHPass::make()->create(Input::get('password'), $user->salt);
         $user->admin = 0;
         $user->save();
         Session::flash('messages.success', Lang::get('user.register_done'));
         return Redirect::to('user/login');
     } else {
         Session::flash('messages.error', $validator->messages()->all('<p>:message</p>'));
         return Redirect::to('user/register')->withInput();
     }
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:32,代码来源:UserController.php

示例12: preparePageConfiguration

 function preparePageConfiguration()
 {
     self::$config = Map::getPageConfiguration(array_values(self::$request_uri_array));
 }
开发者ID:rasstroen,项目名称:baby-album,代码行数:4,代码来源:Site.php

示例13: array

<?php

return array('driver' => 'stickynotes' . Site::config('auth')->method, 'model' => 'User', 'table' => 'users', 'reminder' => array('email' => 'emails.auth.reminder', 'table' => 'password_reminders', 'expire' => 60));
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:3,代码来源:auth.php

示例14: noExpire

 /**
  * Check if the paste cannot expire
  *
  * @static
  * @return bool
  */
 public static function noExpire()
 {
     $noExpire = FALSE;
     // Admins can always create permanent pastes
     if (Auth::roles()->admin) {
         $noExpire = TRUE;
     }
     // Check if only registered users can create permanent pastes
     if (Site::config('general')->noExpire == 'user' and Auth::roles()->user) {
         $noExpire = TRUE;
     }
     // Check if everyone can create permanent pastes
     if (Site::config('general')->noExpire == 'all') {
         $noExpire = TRUE;
     }
     return $noExpire;
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:23,代码来源:Paste.php

示例15: array_map

    if (File::exists($configFile)) {
        include $configFile;
        // Import site settings
        Site::config('general', array_map('html_entity_decode', array('title' => $site_name, 'copyright' => $site_copyright, 'googleApi' => $google_api_key)));
        // Import antispam settings
        Site::config('antispam', array_map('html_entity_decode', array('services' => $sg_services, 'phpKey' => $sg_php_key, 'phpDays' => $sg_php_days, 'phpScore' => $sg_php_score, 'phpType' => $sg_php_type, 'censor' => $sg_censor)));
        // Import authentication settings
        Site::config('auth', array_map('html_entity_decode', array('method' => $auth_method, 'ldapServer' => $ldap_server, 'ldapPort' => $ldap_port, 'ldapBaseDn' => $ldap_base_dn, 'ldapUid' => $ldap_uid, 'ldapFilter' => $ldap_filter, 'ldapUserDn' => $ldap_user_dn, 'ldapPassword' => $ldap_password)));
        // Import SMTP settings
        Site::config('mail', array_map('html_entity_decode', array('host' => $smtp_host, 'port' => $smtp_port, 'encryption' => $smtp_crypt, 'username' => $smtp_username, 'password' => $smtp_password, 'address' => $smtp_from)));
        // If auth method is LDAP, notify the user to set
        // an admin filter.
        if ($auth_method == 'ldap') {
            Setup::messages('0.4', Lang::get('setup.ldap_update_warn'));
        }
        // Remove the old config file
        File::delete($configFile);
    }
}), '1.0' => array(), '1.1' => array('closure' => function () {
    $config = Site::config('general');
    // Modify config values
    if (isset($config->googleApi)) {
        Site::config('services', array('googleApiKey' => $config->googleApi));
    }
}), '1.2' => array('newTables' => array('comments' => array((object) array('name' => 'id', 'type' => 'increments'), (object) array('name' => 'paste_id', 'type' => 'integer'), (object) array('name' => 'data', 'type' => 'text'), (object) array('name' => 'author', 'type' => 'string', 'length' => 50, 'nullable' => TRUE, 'default' => NULL), (object) array('name' => 'timestamp', 'type' => 'integer')))), '1.3' => array('newTables' => array('statistics' => array((object) array('name' => 'id', 'type' => 'increments'), (object) array('name' => 'date', 'type' => 'date'), (object) array('name' => 'web', 'type' => 'integer', 'default' => 0), (object) array('name' => 'api', 'type' => 'integer', 'default' => 0)))), '1.4' => array(), '1.5' => array(), '1.6' => array('modifyTables' => array('main' => array((object) array('name' => 'flagged', 'type' => 'boolean', 'default' => 0), (object) array('name' => 'attachment', 'type' => 'boolean', 'default' => 0)), 'users' => array((object) array('name' => 'remember_token', 'type' => 'string', 'length' => 60, 'default' => '')))), '1.7' => array('closure' => function () {
    $config = Site::config('general');
    // Modify config values
    if (isset($config->privateSite) and $config->privateSite) {
        Site::config('general', array('pasteVisibility' => 'private'));
    }
})));
开发者ID:moises-silva,项目名称:sticky-notes,代码行数:31,代码来源:schema.php


注:本文中的Site::config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。