CodePinch.php
9 years ago
Helper.php
9 years ago
Localization.php
9 years ago
PostOptionList.php
9 years ago
SecurityOptionList.php
9 years ago
UtilityOptionList.php
9 years ago
Helper.php
65 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 | * Backend view helper |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | */ |
| 16 | class AAM_Backend_View_Helper { |
| 17 | |
| 18 | /** |
| 19 | * Prepare phrase or label |
| 20 | * |
| 21 | * @param string $phrase |
| 22 | * @param mixed $... |
| 23 | * |
| 24 | * @return string |
| 25 | * |
| 26 | * @access protected |
| 27 | */ |
| 28 | public static function preparePhrase($phrase) { |
| 29 | //prepare search patterns |
| 30 | $num = func_num_args(); |
| 31 | $search = array_fill(0, ($num - 1) * 2, null); |
| 32 | array_walk($search, 'AAM_Backend_View_Helper::prepareWalk'); |
| 33 | |
| 34 | $replace = array(); |
| 35 | foreach (array_slice(func_get_args(), 1) as $key) { |
| 36 | array_push($replace, "<{$key}>", "</{$key}>"); |
| 37 | } |
| 38 | |
| 39 | //localize the phase first |
| 40 | return preg_replace($search, $replace, __($phrase, AAM_KEY), 1); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * |
| 45 | * @param string $value |
| 46 | * @param type $index |
| 47 | */ |
| 48 | public static function prepareWalk(&$value, $index) { |
| 49 | $value = '/\\' . ($index % 2 ? ']' : '[') . '/'; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Conver string to readable |
| 54 | * |
| 55 | * @param string $text |
| 56 | * |
| 57 | * @return string |
| 58 | * |
| 59 | * @access public |
| 60 | */ |
| 61 | public static function getHumanText($text) { |
| 62 | return implode(' ', array_map('ucfirst', explode('_', $text))); |
| 63 | } |
| 64 | |
| 65 | } |