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


PHP Application::module方法代码示例

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


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

示例1: saveAction

 /**
  * @Route("/", methods="POST")
  * @Route("/{id}", methods="POST", requirements={"id"="\d+"})
  * @Request({"submission": "array", "id": "int", "g-recaptcha-response": "string"}, csrf=true)
  */
 public function saveAction($data, $id = 0, $gRecaptchaResponse = '')
 {
     if (!($submission = Submission::find($id))) {
         $submission = Submission::create();
         unset($data['id']);
         $submission->form_id = $data['form_id'];
         $submission->created = new \DateTime();
         $submission->ip = App::request()->getClientIp();
     }
     unset($data['created']);
     if (!($form = Form::find($submission->form_id))) {
         App::abort(404, 'Form not found.');
     }
     $submission->form = $form;
     if ($form->get('recaptcha') && $id == 0) {
         $resp = (new ReCaptcha(App::module('formmaker')->config('recaptha_secret_key')))->verify($gRecaptchaResponse, App::request()->server->get('REMOTE_ADDR'));
         if (!$resp->isSuccess()) {
             $errors = $resp->getErrorCodes();
             App::abort(403, $errors[0]);
         }
     }
     $submission->save($data);
     $submission->email = $submission->getUserEmail();
     if ($id == 0 && $submission->email) {
         try {
             (new MailHelper($submission))->sendMail();
             $submission->save();
         } catch (Exception $e) {
             App::abort(400, $e->getMessage());
         }
     }
     return ['message' => 'Submission successfull', 'submission' => $submission];
 }
开发者ID:4nxiety,项目名称:pagekit-formmaker,代码行数:38,代码来源:SubmissionApiController.php

示例2: indexAction

 /**
  * @Route("/", methods="GET")
  * @Request({"filter": "array", "page":"int"})
  */
 public function indexAction($filter = [], $page = 0)
 {
     $query = Post::query();
     $filter = array_merge(array_fill_keys(['status', 'search', 'author', 'order', 'limit'], ''), $filter);
     extract($filter, EXTR_SKIP);
     if (!App::user()->hasAccess('blog: manage all posts')) {
         $author = App::user()->id;
     }
     if (is_numeric($status)) {
         $query->where(['status' => (int) $status]);
     }
     if ($search) {
         $query->where(function ($query) use($search) {
             $query->orWhere(['title LIKE :search', 'slug LIKE :search'], ['search' => "%{$search}%"]);
         });
     }
     if ($author) {
         $query->where(function ($query) use($author) {
             $query->orWhere(['user_id' => (int) $author]);
         });
     }
     if (!preg_match('/^(date|title|comment_count)\\s(asc|desc)$/i', $order, $order)) {
         $order = [1 => 'date', 2 => 'desc'];
     }
     $limit = (int) $limit ?: App::module('blog')->config('posts.posts_per_page');
     $count = $query->count();
     $pages = ceil($count / $limit);
     $page = max(0, min($pages - 1, $page));
     $posts = array_values($query->offset($page * $limit)->related('user', 'comments')->limit($limit)->orderBy($order[1], $order[2])->get());
     return compact('posts', 'pages', 'count');
 }
开发者ID:pagekit,项目名称:extension-blog,代码行数:35,代码来源:PostApiController.php

示例3: indexAction

 /**
  * @Route("/", methods="GET")
  * @Request({"filter": "array", "page":"int"})
  */
 public function indexAction($filter = [], $page = 0)
 {
     $query = File::query()->select('f.*')->from('@download_file f');
     $filter = array_merge(array_fill_keys(['status', 'category_id', 'search', 'order', 'limit'], ''), $filter);
     extract($filter, EXTR_SKIP);
     if ($search) {
         $query->where(function ($query) use($search) {
             $query->orWhere(['title LIKE :search'], ['search' => "%{$search}%"]);
         });
     }
     if (is_numeric($status)) {
         $query->where(['status' => (int) $status]);
     }
     if (is_numeric($category_id)) {
         $query->select('x.catordering')->innerJoin('@download_files_categories x', 'x.file_id = f.id')->where(['x.category_id' => (int) $category_id]);
     }
     if (!preg_match('/^(date|downloads|title)\\s(asc|desc)$/i', $order, $order)) {
         $order = [1 => 'date', 2 => 'desc'];
     }
     $limit = (int) $limit ?: App::module('bixie/download')->config('files_per_page');
     $count = $query->count();
     $pages = ceil($count / $limit);
     $page = max(0, min($pages - 1, $page));
     $files = array_values($query->related('categories')->offset($page * $limit)->limit($limit)->orderBy($order[1], $order[2])->get());
     return compact('files', 'pages', 'count');
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:30,代码来源:FileApiController.php

示例4: getFormat

 protected static function getFormat($format)
 {
     $intl = App::module('system/intl');
     $formats = $intl->getFormats($intl->getLocale());
     $moment_format = isset($formats['DATETIME_FORMATS'][$format]) ? $formats['DATETIME_FORMATS'][$format] : $format;
     return strtr($moment_format, static::$intl2php);
 }
开发者ID:Bixie,项目名称:pagekit-framework,代码行数:7,代码来源:DateHelper.php

示例5: __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

示例6: 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

示例7: __construct

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

示例8: 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

示例9: 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

示例10: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!in_array($this->option('db-driver'), ['mysql', 'sqlite'])) {
         $this->error("Unsupported db driver.");
         exit;
     }
     $this->line("Setting up Pagekit installation...");
     $app = $this->container;
     App::module('session')->config['storage'] = 'array';
     $app->boot();
     $app['module']->load('installer');
     $installer = new Installer($app);
     $dbDriver = $this->option('db-driver');
     $config = ['locale' => $this->option('locale'), 'database' => ['default' => $dbDriver, 'connections' => [$dbDriver => ['dbname' => $this->option('db-name'), 'host' => $this->option('db-host'), 'user' => $this->option('db-user'), 'password' => $this->option('db-pass'), 'prefix' => $this->option('db-prefix')]]]];
     $user = ['username' => $this->option('username'), 'password' => $this->option('password'), 'email' => $this->option('mail')];
     $options = ['system' => ['site' => ['locale' => $this->option('locale')], 'admin' => ['locale' => $this->option('locale')]], 'system/site' => ['title' => $this->option('title')]];
     $result = $installer->install($config, $options, $user);
     $status = $result['status'];
     $message = $result['message'];
     if ($status == 'success') {
         $this->line("Done");
     } else {
         $this->error($message);
     }
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:28,代码来源:SetupCommand.php

示例11: requestAction

 /**
  * @Request({"email": "string"})
  */
 public function requestAction($email)
 {
     try {
         if (App::user()->isAuthenticated()) {
             return App::redirect();
         }
         if (!App::csrf()->validate()) {
             throw new Exception(__('Invalid token. Please try again.'));
         }
         if (empty($email)) {
             throw new Exception(__('Enter a valid email address.'));
         }
         if (!($user = User::findByEmail($email))) {
             throw new Exception(__('Unknown email address.'));
         }
         if ($user->isBlocked()) {
             throw new Exception(__('Your account has not been activated or is blocked.'));
         }
         $user->activation = App::get('auth.random')->generateString(32);
         $url = App::url('@user/resetpassword/confirm', ['user' => $user->username, 'key' => $user->activation], 0);
         try {
             $mail = App::mailer()->create();
             $mail->setTo($user->email)->setSubject(__('Reset password for %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/reset.php', compact('user', 'url', 'mail')), 'text/html')->send();
         } catch (\Exception $e) {
             throw new Exception(__('Unable to send confirmation link.'));
         }
         $user->save();
         return ['message' => __('Check your email for the confirmation link.')];
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:35,代码来源:ResetPasswordController.php

示例12: onRequest

 /**
  * Registers node routes
  */
 public function onRequest()
 {
     $site = App::module('system/site');
     $frontpage = $site->config('frontpage');
     $nodes = Node::findAll(true);
     uasort($nodes, function ($a, $b) {
         return strcmp(substr_count($a->path, '/'), substr_count($b->path, '/')) * -1;
     });
     foreach ($nodes as $node) {
         if ($node->status !== 1 || !($type = $site->getType($node->type))) {
             continue;
         }
         $type = array_replace(['alias' => '', 'redirect' => '', 'controller' => ''], $type);
         $type['defaults'] = array_merge(isset($type['defaults']) ? $type['defaults'] : [], $node->get('defaults', []), ['_node' => $node->id]);
         $type['path'] = $node->path;
         $route = null;
         if ($node->get('alias')) {
             App::routes()->alias($node->path, $node->link, $type['defaults']);
         } elseif ($node->get('redirect')) {
             App::routes()->redirect($node->path, $node->get('redirect'), $type['defaults']);
         } elseif ($type['controller']) {
             App::routes()->add($type);
         }
         if (!$frontpage && isset($type['frontpage']) && $type['frontpage']) {
             $frontpage = $node->id;
         }
     }
     if ($frontpage && isset($nodes[$frontpage])) {
         App::routes()->alias('/', $nodes[$frontpage]->link);
     } else {
         App::routes()->get('/', function () {
             return __('No Frontpage assigned.');
         });
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:38,代码来源:NodesListener.php

示例13: getFieldType

 /**
  * @return \Bixie\Framework\FieldType\FieldTypeBase
  */
 public function getFieldType()
 {
     if (!isset($this->fieldType)) {
         $this->fieldType = App::module('bixie/framework')->getFieldType($this->field->type);
     }
     return $this->fieldType;
 }
开发者ID:Bixie,项目名称:pagekit-framework,代码行数:10,代码来源:FieldValueBase.php

示例14: 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

示例15: getFieldTypes

 /**
  * @return array
  */
 public function getFieldTypes($extension = null)
 {
     //todo cache this
     if (!$this->fieldTypes) {
         $this->fieldTypes = [];
         /** @noinspection PhpUnusedLocalVariableInspection */
         $app = App::getInstance();
         //available for index.php files
         $paths = [];
         foreach (App::module() as $module) {
             if ($module->get('fieldtypes')) {
                 $paths = array_merge($paths, glob(sprintf('%s/%s/*/index.php', $module->path, $module->get('fieldtypes')), GLOB_NOSORT) ?: []);
             }
         }
         foreach ($paths as $p) {
             $package = array_merge(['id' => '', 'path' => dirname($p), 'main' => '', 'extensions' => $this->fieldExtensions, 'class' => '\\Bixie\\Framework\\FieldType\\FieldType', 'resource' => 'bixie/framework:app/bundle', 'config' => ['hasOptions' => 0, 'readonlyOptions' => 0, 'required' => 0, 'multiple' => 0], 'dependancies' => [], 'styles' => [], 'getOptions' => '', 'prepareValue' => '', 'formatValue' => ''], include $p);
             $this->registerFieldType($package);
         }
     }
     if ($extension) {
         return array_filter($this->fieldTypes, function ($fieldType) use($extension) {
             /** @var FieldTypeBase $fieldType */
             return in_array($extension, $fieldType->getExtensions());
         });
     }
     return $this->fieldTypes;
 }
开发者ID:stroborobo,项目名称:pagekit-framework,代码行数:30,代码来源:FrameworkModule.php


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