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


PHP Pagekit\Application类代码示例

本文整理汇总了PHP中Pagekit\Application的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $this->breadcrumbs = new BreadcrumbsManager($app);
     $app->extend('view', function ($view) {
         return $view->addGlobal('breadcrumbs', $this);
     });
 }
开发者ID:Bixie,项目名称:pagekit-breadcrumbs,代码行数:10,代码来源:BreadcrumbsModule.php

示例2: load

 /**
  * {@inheritdoc}
  */
 public function load($module)
 {
     $class = $module[is_string($module['main']) ? 'main' : 'class'];
     $module = new $class($module);
     $module->main($this->app);
     if (is_a($module, 'Pagekit\\Event\\EventSubscriberInterface')) {
         $this->app->subscribe($module);
     }
     return $module;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:13,代码来源:ModuleLoader.php

示例3: getStyles

 /**
  * @return array
  */
 public function getStyles()
 {
     if (!static::$styles) {
         $paths = glob($this->app->locator()->get('theme:styles') . '/*/style.less', GLOB_NOSORT) ?: [];
         static::$styles = ['default'];
         foreach ($paths as $p) {
             static::$styles[] = basename(dirname($p));
         }
     }
     return static::$styles;
 }
开发者ID:Bixie,项目名称:pagekit-bixbase,代码行数:14,代码来源:StyleManager.php

示例4: getNext

 /**
  * @param File $file
  * @return mixed
  */
 public static function getNext($file)
 {
     $module = App::module('bixie/download');
     return self::where(['title < ?', 'status = ?'], [$file->title, '1'])->where(function ($query) {
         return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
     })->orderBy($module->config('ordering'), $module->config('ordering_dir'))->first();
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:11,代码来源:FileModelTrait.php

示例5: bulkSaveAction

 /**
  * @Route("/bulk", methods="POST")
  * @Request({"widgets": "array"}, csrf=true)
  */
 public function bulkSaveAction($widgets = [])
 {
     foreach ($widgets as $data) {
         $this->saveAction($data, isset($data['id']) ? $data['id'] : 0);
     }
     return ['message' => 'success', 'positions' => array_values(App::position()->all())];
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:11,代码来源:WidgetApiController.php

示例6: configAction

 /**
  *  Returns several config settings needed for the settings view.
  */
 public function configAction()
 {
     $styles = array_map(function ($fn) {
         return basename($fn, '.css');
     }, glob(App::locator()->get('highlight:assets/styles') . '/*.css'));
     return compact('styles');
 }
开发者ID:pagekit,项目名称:extension-highlight,代码行数:10,代码来源:HighlightController.php

示例7: editAction

 /**
  * @Route("/edit")
  * @Request({"id"})
  */
 public function editAction($id = '')
 {
     /** @var \Bixie\Formmaker\FormmakerModule $formmaker */
     $formmaker = App::module('bixie/formmaker');
     if (is_numeric($id)) {
         $field = Field::find($id);
     } else {
         $field = Field::create();
         $field->setFieldType($id);
     }
     if (!$field) {
         App::abort(404, __('Field not found.'));
     }
     if (!($type = $formmaker->getFieldType($field->type))) {
         App::abort(404, __('Type not found.'));
     }
     //default values
     $fixedFields = ['multiple', 'required'];
     if (!$field->id) {
         foreach ($type->getConfig() as $key => $value) {
             if (!in_array($key, $fixedFields)) {
                 $field->set($key, $value);
             }
         }
     }
     //check fixed value
     foreach ($fixedFields as $key) {
         if ($type[$key] != -1) {
             $field->set($key, $type[$key]);
         }
     }
     return ['field' => $field, 'type' => $type, 'roles' => array_values(Role::findAll())];
 }
开发者ID:Eichi,项目名称:pagekit-formmaker,代码行数:37,代码来源:FieldApiController.php

示例8: __construct

 public function __construct()
 {
     $config = App::module('shoutzor')->config();
     $this->enabled = $config['acoustid']['enabled'] == 1;
     $this->appKey = $config['acoustid']['appKey'];
     $this->requirementDir = realpath($config['root_path'] . '/../shoutzor-requirements/acoustid');
 }
开发者ID:xorinzor,项目名称:Shoutzor,代码行数:7,代码来源:AcoustID.php

示例9: saveAction

 /**
  * @Request({"user": "array"}, csrf=true)
  */
 public function saveAction($data)
 {
     $user = App::user();
     if (!$user->isAuthenticated()) {
         App::abort(404);
     }
     try {
         $user = User::find($user->id);
         if ($password = @$data['password_new']) {
             if (!App::auth()->getUserProvider()->validateCredentials($user, ['password' => @$data['password_old']])) {
                 throw new Exception(__('Invalid Password.'));
             }
             if (trim($password) != $password || strlen($password) < 3) {
                 throw new Exception(__('Invalid Password.'));
             }
             $user->password = App::get('auth.password')->hash($password);
         }
         if (@$data['email'] != $user->email) {
             $user->set('verified', false);
         }
         $user->name = @$data['name'];
         $user->email = @$data['email'];
         $user->validate();
         $user->save();
         return ['message' => 'success'];
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:32,代码来源:ProfileController.php

示例10: getRandomTrack

 public function getRandomTrack($autoForce = true, $forced = false)
 {
     if ($forced === true) {
         return Media::query()->orderBy('rand()')->first();
     } else {
         $list = array();
     }
     $config = App::module('shoutzor')->config('shoutzor');
     $requestHistoryTime = (new DateTime())->sub(new DateInterval('PT' . $config['mediaRequestDelay'] . 'M'))->format('Y-m-d H:i:s');
     $artistHistoryTime = (new DateTime())->sub(new DateInterval('PT' . $config['artistRequestDelay'] . 'M'))->format('Y-m-d H:i:s');
     //Build a list of media id's that are available to play, next, randomly pick one
     $q = Media::query()->select('DISTINCT m.*')->from('@shoutzor_media m')->leftJoin('@shoutzor_requestlist q', 'q.media_id = m.id')->where('q.media_id IS NULL')->where('m.id NOT IN (
                   SELECT h.media_id
                   FROM @shoutzor_history h
                   LEFT JOIN @shoutzor_requestlist tq ON tq.media_id = h.media_id
                   WHERE h.played_at > :maxTime
               )', ['maxTime' => $requestHistoryTime])->where('m.id NOT IN (
               SELECT tma.media_id
               FROM @shoutzor_media_artist tma
               WHERE tma.artist_id IN (
                   SELECT ma.artist_id
                   FROM @shoutzor_media_artist ma
                   WHERE ma.media_id IN (
                       SELECT th.media_id
                       FROM @shoutzor_history th
                       LEFT JOIN @shoutzor_requestlist tq ON tq.media_id = th.media_id
                       WHERE th.played_at > :maxTime
                     )
                   )
               )', ['maxTime' => $artistHistoryTime])->groupBy('m.id')->orderBy('rand(' . microtime(true) . ')');
     if ($q->count() === 0) {
         return $autoForce === true ? $this->getRandomTrack(true, true) : false;
     }
     return $q->first();
 }
开发者ID:xorinzor,项目名称:Shoutzor,代码行数:35,代码来源:AutoDJ.php

示例11: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "_remember_me": "boolean"})
  */
 public function authenticateAction($credentials, $remember = false)
 {
     $isXml = App::request()->isXmlHttpRequest();
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (!$isXml) {
             return App::auth()->login($user, $remember);
         } else {
             App::auth()->setUser($user, $remember);
             return ['success' => true];
         }
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (!$isXml) {
         App::message()->error($error);
         return App::redirect(App::url()->previous());
     } else {
         App::abort(400, $error);
     }
 }
开发者ID:aqnouch,项目名称:rimbo,代码行数:30,代码来源:AuthController.php

示例12: saving

 /**
  * @Saving
  */
 public static function saving($event, Field $field)
 {
     $userprofile = App::module('bixie/userprofile');
     if (!($type = $userprofile->getFieldType($field->type))) {
         throw new Exception(__('Field type not found.'));
     }
     foreach (['multiple', 'required'] as $key) {
         if ($type[$key] != -1) {
             //check fixed value
             if ($type[$key] != $field->get($key)) {
                 throw new Exception(__('Invalid value for ' . $key . ' option.'));
             }
         }
     }
     //slug
     $i = 2;
     $id = $field->id;
     if (!$field->slug) {
         $field->slug = $field->label;
     }
     while (self::where(['slug = ?'], [$field->slug])->where(function ($query) use($id) {
         if ($id) {
             $query->where('id <> ?', [$id]);
         }
     })->first()) {
         $field->slug = preg_replace('/-\\d+$/', '', $field->slug) . '-' . $i++;
     }
     if (!$field->id) {
         $next = self::getConnection()->fetchColumn('SELECT MAX(priority) + 1 FROM @userprofile_field');
         $field->priority = $next ?: 0;
     }
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:35,代码来源:FieldModelTrait.php

示例13: confirmAction

 /**
  * @Request({"user", "key"})
  */
 public function confirmAction($username = "", $activation = "")
 {
     if (empty($username) || empty($activation) || !($user = User::where(compact('username', 'activation'))->first())) {
         return $this->messageView(__('Invalid key.'), $success = false);
     }
     if ($user->isBlocked()) {
         return $this->messageView(__('Your account has not been activated or is blocked.'), $success = false);
     }
     $error = '';
     if ('POST' === App::request()->getMethod()) {
         try {
             if (!App::csrf()->validate()) {
                 throw new Exception(__('Invalid token. Please try again.'));
             }
             $password = App::request()->request->get('password');
             if (empty($password)) {
                 throw new Exception(__('Enter password.'));
             }
             if ($password != trim($password)) {
                 throw new Exception(__('Invalid password.'));
             }
             $user->password = App::get('auth.password')->hash($password);
             $user->activation = null;
             $user->save();
             App::message()->success(__('Your password has been reset.'));
             return App::redirect('@user/login');
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     return ['$view' => ['title' => __('Reset Confirm'), 'name' => 'system/user/reset-confirm.php'], 'username' => $username, 'activation' => $activation, 'error' => $error];
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:35,代码来源:ResetPasswordController.php

示例14: getRelativePath

 /**
  * Returns the path relative to the root.
  *
  * @param  string $path
  * @return string
  */
 protected function getRelativePath($path)
 {
     if (0 === strpos($path, App::path())) {
         $path = ltrim(str_replace('\\', '/', substr($path, strlen(App::path()))), '/');
     }
     return $path;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:13,代码来源:InfoHelper.php

示例15: indexAction

 /**
  * @Route("/", name="index")
  */
 public function indexAction()
 {
     $config = App::module('shoutzor')->config('liquidsoap');
     $liquidsoapManager = new LiquidsoapManager();
     $wrapperActive = $liquidsoapManager->isUp('wrapper');
     $shoutzorActive = $liquidsoapManager->isUp('shoutzor');
     $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal');
     $form->addField(new DivField("Permission Check", $config['logDirectoryPath'] . (is_writable($config['logDirectoryPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['logDirectoryPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger"));
     //Usually the log directory and the socket directory will be the same
     //Thus, showing twice that the same directory is (not) writable has no use
     if ($config['logDirectoryPath'] != $config['socketPath']) {
         $form->addField(new DivField("Permission Check", $config['socketPath'] . (is_writable($config['socketPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['socketPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger"));
     }
     $form->addField(new DivField("Permission Check", $liquidsoapManager->getPidFileDirectory() . (is_writable($liquidsoapManager->getPidFileDirectory()) ? " is writable" : " is not writable! chown manually to liquidsoap:www-data"), "", is_writable($liquidsoapManager->getPidFileDirectory()) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger"));
     $form->addField(new DividerField());
     $form->addField(new InputField("wrapperToggle", "wrapperToggle", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "button", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "(De)activates the wrapper liquidsoap script", $wrapperActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY));
     if ($wrapperActive === false) {
         $form->setError("The wrapper script is not activated!");
     } else {
         $form->setSuccess("The wrapper script is up and running!");
     }
     $form->addField(new InputField("shoutzorToggle", "shoutzorToggle", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "button", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "(De)activates the shoutzor liquidsoap script", $shoutzorActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY));
     if ($shoutzorActive === false) {
         if ($wrapperActive === false) {
             $form->setError("The wrapper script needs to be activated first!");
         } else {
             $form->setError("The shoutzor script is not activated!");
         }
     } else {
         $form->setSuccess("The shoutzor script is up and running!");
     }
     $content = $form->render();
     return ['$view' => ['title' => __('Shoutzor System'), 'name' => 'shoutzor:views/admin/system.php'], 'form' => $content];
 }
开发者ID:xorinzor,项目名称:Shoutzor,代码行数:37,代码来源:SystemController.php


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