/** * Set a bunch of placeholders to be used within Smarty templates * * @return void */ public function setPlaceholders() { $username = ''; if ($this->modx->getOption('manager_use_fullname') == true) { $userProfile = $this->modx->user->getOne('Profile'); $username = $userProfile->get('fullname'); } if (empty($username)) { $username = $this->modx->getLoginUserName(); } $placeholders = array('username' => $username, 'userImage' => $this->getUserImage()); $this->controller->setPlaceholders($placeholders); }
/** * Retrieve/compute the user picture profile * * @return string The HTML output */ public function getUserImage() { /** @var modUserProfile $userProfile */ $userProfile = $this->modx->user->getOne('Profile'); // Default to FontAwesome $userImage = '<i class="icon icon-user icon-large"></i> '; if ($userProfile->photo) { // First, handle user defined image $src = $this->modx->getOption('connectors_url', MODX_CONNECTORS_URL) . 'system/phpthumb.php?zc=1&h=128&w=128&src=' . $userProfile->photo; $userImage = '<img src="' . $src . '" />'; } elseif ($this->modx->getOption('enable_gravatar')) { // Gravatar $gravemail = md5(strtolower(trim($userProfile->email))); $gravsrc = $this->modx->getOption('url_scheme', null, 'http://') . 'www.gravatar.com/avatar/' . $gravemail . '?s=128&d=mm'; $userImage = '<img src="' . $gravsrc . '" alt="' . $this->modx->getLoginUserName() . '" />'; } return $userImage; }
/** * Set a bunch of placeholders to be used within Smarty templates * * @return void */ public function setPlaceholders() { $placeholders = array('username' => $this->modx->getLoginUserName(), 'userImage' => $this->getUserImage()); $this->controller->setPlaceholders($placeholders); }