Content.php
8 years ago
Interface.php
8 years ago
Login.php
8 years ago
LoginRedirect.php
8 years ago
Login.php
93 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 | */ |
| 51 | public function run() { |
| 52 | $this->args['id'] = isset($this->args['id']) ? $this->args['id'] : uniqid(); |
| 53 | |
| 54 | if (empty($this->args['user-title'])) { |
| 55 | $this->args['user-title'] = __('Howdy, %username%', AAM_KEY); |
| 56 | } |
| 57 | |
| 58 | if (empty($this->args['redirect'])) { |
| 59 | $this->args['redirect'] = AAM_Core_Request::get('redirect_to'); |
| 60 | } |
| 61 | |
| 62 | if (isset($this->args['callback'])) { |
| 63 | $content = call_user_func($this->args['callback'], $this); |
| 64 | } else { |
| 65 | ob_start(); |
| 66 | require AAM_Core_Config::get( |
| 67 | 'login.shortcode.template', |
| 68 | dirname(__FILE__) . '/../../Frontend/phtml/login.phtml' |
| 69 | ); |
| 70 | $content = ob_get_contents(); |
| 71 | ob_end_clean(); |
| 72 | } |
| 73 | |
| 74 | return $content; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * |
| 79 | * @return type |
| 80 | */ |
| 81 | public function getArgs() { |
| 82 | return $this->args; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * |
| 87 | * @return type |
| 88 | */ |
| 89 | public function getContent() { |
| 90 | return $this->content; |
| 91 | } |
| 92 | |
| 93 | } |