Content.php
7 years ago
Interface.php
7 years ago
Login.php
7 years ago
LoginRedirect.php
7 years ago
Login.php
92 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * ====================================================================== |
| 5 | * LICENSE: This file is subject to the terms and conditions defined in * |
| 6 | * file 'license.txt', which is part of this source code package. * |
| 7 | * ====================================================================== |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * AAM shortcode strategy for login form |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | */ |
| 16 | class AAM_Shortcode_Strategy_Login implements AAM_Shortcode_Strategy_Interface { |
| 17 | |
| 18 | /** |
| 19 | * |
| 20 | * @var type |
| 21 | */ |
| 22 | protected $args; |
| 23 | |
| 24 | /** |
| 25 | * |
| 26 | * @var type |
| 27 | */ |
| 28 | protected $content; |
| 29 | |
| 30 | /** |
| 31 | * Initialize shortcode decorator |
| 32 | * |
| 33 | * Expecting attributes in $args are: |
| 34 | * "id" => unique form Id |
| 35 | * "user-title" => Logged in user title |
| 36 | * "redirect" => Redirect to URL |
| 37 | * "callback" => callback function that returns the login button |
| 38 | * |
| 39 | * @param type $args |
| 40 | * @param type $content |
| 41 | */ |
| 42 | public function __construct($args, $content) { |
| 43 | $this->args = $args; |
| 44 | $this->content = $content; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Process shortcode |
| 49 | */ |
| 50 | public function run() { |
| 51 | $this->args['id'] = isset($this->args['id']) ? $this->args['id'] : uniqid(); |
| 52 | |
| 53 | if (empty($this->args['user-title'])) { |
| 54 | $this->args['user-title'] = __('Howdy, %username%', AAM_KEY); |
| 55 | } |
| 56 | |
| 57 | if (empty($this->args['redirect'])) { |
| 58 | $this->args['redirect'] = AAM_Core_Request::get('redirect_to'); |
| 59 | } |
| 60 | |
| 61 | if (isset($this->args['callback'])) { |
| 62 | $content = call_user_func($this->args['callback'], $this); |
| 63 | } else { |
| 64 | ob_start(); |
| 65 | require AAM::api()->getConfig( |
| 66 | 'feature.secureLogin.shortcode.template', |
| 67 | realpath(AAM_BASEDIR . '/Application/Frontend/phtml/login.phtml') |
| 68 | ); |
| 69 | $content = ob_get_contents(); |
| 70 | ob_end_clean(); |
| 71 | } |
| 72 | |
| 73 | return $content; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * |
| 78 | * @return type |
| 79 | */ |
| 80 | public function getArgs() { |
| 81 | return $this->args; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * |
| 86 | * @return type |
| 87 | */ |
| 88 | public function getContent() { |
| 89 | return $this->content; |
| 90 | } |
| 91 | |
| 92 | } |