protected static function func(&$a) { if (!empty($a['avatar'])) { $a['avatar'] = '{_AVATAR_IMG_SITE_}{_DIR_}/w/img/avatar/sqr/' . $a['avatar']; } elseif (!empty($a['avatar_external'])) { $a['avatar'] = $a['avatar_external']; } elseif (!empty($a['gravatar']) && !empty($a['email'])) { $a['avatar'] = $a['gravatar']['url'] . hash('md5', $a['email']) . '?s=36' . '&d=' . $a['gravatar']['fallback'] . '&r=' . $a['gravatar']['rating']; } else { $a['avatar'] = '{_IMAGE_SITE_}{_DIR_}/images/avatar.png'; } $fn = !empty($a['fn']) ? $a['fn'] : ''; $ln = !empty($a['ln']) ? $a['ln'] : ''; $mn = !empty($a['mn']) ? $a['mn'] : ''; $displayName = $fn . ' ' . $mn . ' ' . $ln; $a['displayName'] = strlen($displayName) > 2 ? $displayName : (array_key_exists('username', $a) ? $a['username'] : ''); $lastActive = !empty($a['i_lm_ts']) ? $a['i_lm_ts'] : $a['i_reg_ts']; $registered = $a['i_reg_ts']; if (!isset($_SESSION['locale']) || 0 === strncmp('en', $_SESSION['locale'], 2)) { $a['since'] = \Lampcms\TimeAgo::format(new \DateTime(date('r', $registered))); $a['last_seen'] = \Lampcms\TimeAgo::format(new \DateTime(date('r', $lastActive))); } else { $a['since'] = \Lampcms\TimeFormatter::formatTime($_SESSION['locale'], $registered); $a['last_seen'] = \Lampcms\TimeFormatter::formatTime($_SESSION['locale'], $lastActive); } if ('deleted' == $a['role']) { $a['deleted'] = 'deleted'; } }
protected static function func(&$a) { if (isset($a['i_ts'])) { $locale = $_SESSION['locale']; if (0 !== strncmp('en', $locale, 2)) { $a['hts'] = \Lampcms\TimeFormatter::formatTime($locale, $a['i_ts']); } else { $a['hts'] = \date('M j, Y h:i A', $a['i_ts']); } } }
protected static function func(&$a) { if (array_key_exists('a_edited', $a)) { /** * A way to pass "translated" * version of "Edited" word * to the tplEditedby template */ $aEdited = end($a['a_edited']); $a['edits'] = \tplEditedby::parse($aEdited); } if (!empty($a['i_sticky'])) { $a['sticky'] = ' sticky'; } $a['hts'] = \Lampcms\TimeFormatter::formatTime($_SESSION['locale'], $a['i_ts']); if (!empty($a['a_comments'])) { /** * Closure function * to pass resource_id * and author id of this * Question to the tplComments * This way we don't have to store * duplicate data in each comment * element and still be able to * have access to these 2 important * fields in the tplComments template * We going to need id or resource owner * in order to add it to the "reply" link * in the form of class uid-$uid * */ $rid = $a['_id']; $uid = $a['i_uid']; $f = function (&$data) use($rid, $uid) { $data['resource_id'] = $rid; $data['owner_id'] = $uid; }; $a['comments_html'] = tplComment::loop($a['a_comments'], true, $f); // } if (!empty($a['pending'])) { $a['moderate'] = '<span class="cb fl pending">@@This question is pending moderator approval@@</span>'; $a['approve'] = '<span class="ico ttt approve ajax" title="@@Approve this question@@"> </span>'; } }