FormatHelper.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <?php
  2. namespace Tools\View\Helper;
  3. use Cake\Core\Configure;
  4. use Cake\Utility\Inflector;
  5. use Cake\View\Helper\TextHelper;
  6. use Cake\View\StringTemplate;
  7. use Cake\View\View;
  8. /**
  9. * Format helper with basic html snippets
  10. *
  11. * TODO: make snippets more "css and background image" (instead of inline img links)
  12. *
  13. * @author Mark Scherer
  14. * @license MIT
  15. */
  16. class FormatHelper extends TextHelper {
  17. /**
  18. * Other helpers used by FormHelper
  19. *
  20. * @var array
  21. */
  22. public $helpers = ['Html', 'Tools.Numeric'];
  23. public $template;
  24. protected $_defaults = [
  25. 'fontIcons' => false, // Defaults to false for BC
  26. 'iconNamespace' => 'fa', // Used to be icon
  27. ];
  28. public function __construct(View $View, array $config = []) {
  29. $config += $this->_defaults;
  30. if ($config['fontIcons'] === true) {
  31. $config['fontIcons'] = (array)Configure::read('Format.fontIcons');
  32. if ($namespace = Configure::read('Format.iconNamespace')) {
  33. $config['iconNamespace'] = $namespace;
  34. }
  35. }
  36. $templates = [
  37. 'icon' => '<i class="{{class}}" title="{{title}}" data-placement="bottom" data-toggle="tooltip"></i>',
  38. ] + (array)Configure::read('Format.templates');
  39. if (!isset($this->template)) {
  40. $this->template = new StringTemplate($templates);
  41. }
  42. parent::__construct($View, $config);
  43. }
  44. /**
  45. * jqueryAccess: {id}Pro, {id}Contra
  46. *
  47. * @return string
  48. */
  49. public function thumbs($id, $inactive = false, $inactiveTitle = null) {
  50. $status = 'Active';
  51. $upTitle = __d('tools', 'consentThis');
  52. $downTitle = __d('tools', 'dissentThis');
  53. if ($inactive === true) {
  54. $status = 'Inactive';
  55. $upTitle = $downTitle = !empty($inactiveTitle) ? $inactiveTitle : __d('tools', 'alreadyVoted');
  56. }
  57. if ($this->_config['fontIcons']) {
  58. // TODO: Return proper font icons
  59. // fa-thumbs-down
  60. // fa-thumbs-up
  61. }
  62. $ret = '<div class="thumbsUpDown">';
  63. $ret .= '<div id="' . $id . 'Pro' . $status . '" rel="' . $id . '" class="thumbUp up' . $status . '" title="' . $upTitle . '"></div>';
  64. $ret .= '<div id="' . $id . 'Contra' . $status . '" rel="' . $id . '" class="thumbDown down' . $status . '" title="' . $downTitle . '"></div>';
  65. $ret .= '<br class="clear"/>';
  66. $ret .= '</div>';
  67. return $ret;
  68. }
  69. /**
  70. * Display neighbor quicklinks
  71. *
  72. * @param array $neighbors (containing prev and next)
  73. * @param string $field: just field or Model.field syntax
  74. * @param array $options:
  75. * - name: title name: next{Record} (if none is provided, "record" is used - not translated!)
  76. * - slug: true/false (defaults to false)
  77. * - titleField: field or Model.field
  78. * @return string
  79. */
  80. public function neighbors($neighbors, $field, $options = []) {
  81. if (mb_strpos($field, '.') !== false) {
  82. $fieldArray = explode('.', $field, 2);
  83. $alias = $fieldArray[0];
  84. $field = $fieldArray[1];
  85. }
  86. if (empty($alias)) {
  87. if (!empty($neighbors['prev'])) {
  88. $modelNames = array_keys($neighbors['prev']);
  89. $alias = $modelNames[0];
  90. } elseif (!empty($neighbors['next'])) {
  91. $modelNames = array_keys($neighbors['next']);
  92. $alias = $modelNames[0];
  93. }
  94. }
  95. if (empty($field)) {
  96. }
  97. $name = 'Record'; // Translation further down!
  98. if (!empty($options['name'])) {
  99. $name = ucfirst($options['name']);
  100. }
  101. $prevSlug = $nextSlug = null;
  102. if (!empty($options['slug'])) {
  103. if (!empty($neighbors['prev'])) {
  104. $prevSlug = Inflector::slug($neighbors['prev'][$alias][$field], '-');
  105. }
  106. if (!empty($neighbors['next'])) {
  107. $nextSlug = Inflector::slug($neighbors['next'][$alias][$field], '-');
  108. }
  109. }
  110. $titleAlias = $alias;
  111. $titleField = $field;
  112. if (!empty($options['titleField'])) {
  113. if (mb_strpos($options['titleField'], '.') !== false) {
  114. $fieldArray = explode('.', $options['titleField'], 2);
  115. $titleAlias = $fieldArray[0];
  116. $titleField = $fieldArray[1];
  117. } else {
  118. $titleField = $options['titleField'];
  119. }
  120. }
  121. if (!isset($options['escape']) || $options['escape'] === false) {
  122. $titleField = h($titleField);
  123. }
  124. $ret = '<div class="next-prev-navi nextPrevNavi">';
  125. if (!empty($neighbors['prev'])) {
  126. $url = [$neighbors['prev'][$alias]['id'], $prevSlug];
  127. if (!empty($options['url'])) {
  128. $url += $options['url'];
  129. }
  130. $ret .= $this->Html->link($this->cIcon(ICON_PREV, false) . '&nbsp;' . __d('tools', 'prev' . $name), $url, ['escape' => false, 'title' => $neighbors['prev'][$titleAlias][$titleField]]);
  131. } else {
  132. $ret .= $this->cIcon(ICON_PREV_DISABLED, __d('tools', 'noPrev' . $name)) . '&nbsp;' . __d('tools', 'prev' . $name);
  133. }
  134. $ret .= '&nbsp;&nbsp;';
  135. if (!empty($neighbors['next'])) {
  136. $url = [$neighbors['next'][$alias]['id'], $prevSlug];
  137. if (!empty($options['url'])) {
  138. $url += $options['url'];
  139. }
  140. $ret .= $this->Html->link($this->cIcon(ICON_NEXT, false) . '&nbsp;' . __d('tools', 'next' . $name), $url, ['escape' => false, 'title' => $neighbors['next'][$titleAlias][$titleField]]);
  141. } else {
  142. $ret .= $this->cIcon(ICON_NEXT_DISABLED, __d('tools', 'noNext' . $name)) . '&nbsp;' . __d('tools', 'next' . $name);
  143. }
  144. $ret .= '</div>';
  145. return $ret;
  146. }
  147. const GENDER_FEMALE = 2;
  148. const GENDER_MALE = 1;
  149. /**
  150. * Displays gender icon
  151. *
  152. * @return string
  153. */
  154. public function genderIcon($value = null) {
  155. $value = (int)$value;
  156. if ($value == static::GENDER_FEMALE) {
  157. $icon = $this->icon('genderFemale', null, null, null, ['class' => 'gender']);
  158. } elseif ($value == static::GENDER_MALE) {
  159. $icon = $this->icon('genderMale', null, null, null, ['class' => 'gender']);
  160. } else {
  161. $icon = $this->icon('genderUnknown', null, null, null, ['class' => 'gender']);
  162. }
  163. return $icon;
  164. }
  165. /**
  166. * Display a font icon (fast and resource-efficient).
  167. * Uses http://fontawesome.io/icons/
  168. *
  169. * Options:
  170. * - size (int|string: 1...5 or large)
  171. * - rotate (integer: 90, 270, ...)
  172. * - spin (booelan: true/false)
  173. * - extra (array: muted, light, dark, border)
  174. * - pull (string: left, right)
  175. *
  176. * @param string|array $icon
  177. * @param array $options
  178. * @return string
  179. */
  180. public function fontIcon($icon, array $options = [], array $attributes = []) {
  181. $defaults = [
  182. 'namespace' => $this->_config['iconNamespace']
  183. ];
  184. $options += $defaults;
  185. $icon = (array)$icon;
  186. $class = [$options['namespace']];
  187. foreach ($icon as $i) {
  188. $class[] = $options['namespace'] . '-' . $i;
  189. }
  190. if (!empty($options['extra'])) {
  191. foreach ($options['extra'] as $i) {
  192. $class[] = $options['namespace'] . '-' . $i;
  193. }
  194. }
  195. if (!empty($options['size'])) {
  196. $class[] = $options['namespace'] . '-' . ($options['size'] === 'large' ? 'large' : $options['size'] . 'x');
  197. }
  198. if (!empty($options['pull'])) {
  199. $class[] = 'pull-' . $options['pull'];
  200. }
  201. if (!empty($options['rotate'])) {
  202. $class[] = $options['namespace'] . '-rotate-' . (int)$options['rotate'];
  203. }
  204. if (!empty($options['spin'])) {
  205. $class[] = $options['namespace'] . '-spin';
  206. }
  207. return '<i class="' . implode(' ', $class) . '"></i>';
  208. }
  209. /**
  210. * Quick way of printing default icons
  211. *
  212. * @todo refactor to $type, $options, $attributes
  213. *
  214. * @param type
  215. * @param title
  216. * @param alt (set to FALSE if no alt is supposed to be shown)
  217. * @param bool automagic i18n translate [default true = __('xyz')]
  218. * @param options array ('class'=>'','width/height'=>'','onclick=>'') etc
  219. * @return string
  220. */
  221. public function icon($type, $t = null, $a = null, $translate = null, $options = []) {
  222. if (isset($t) && $t === false) {
  223. $title = '';
  224. } else {
  225. $title = $t;
  226. }
  227. if (isset($a) && $a === false) {
  228. $alt = '';
  229. } else {
  230. $alt = $a;
  231. }
  232. if (!$this->_config['fontIcons'] || !isset($this->_config['fontIcons'][$type])) {
  233. if (array_key_exists($type, $this->icons)) {
  234. $pic = $this->icons[$type]['pic'];
  235. $title = (isset($title) ? $title : $this->icons[$type]['title']);
  236. $alt = (isset($alt) ? $alt : preg_replace('/[^a-zA-Z0-9]/', '', $this->icons[$type]['title']));
  237. if ($translate !== false) {
  238. $title = __($title);
  239. $alt = __($alt);
  240. }
  241. if ($alt) {
  242. $alt = '[' . $alt . ']';
  243. }
  244. } else {
  245. $pic = 'pixelspace.gif';
  246. }
  247. $defaults = ['title' => $title, 'alt' => $alt, 'class' => 'icon'];
  248. $newOptions = $options + $defaults;
  249. return $this->Html->image('icons/' . $pic, $newOptions);
  250. }
  251. $options['title'] = $title;
  252. $options['translate'] = $translate;
  253. return $this->_fontIcon($type, $options);
  254. }
  255. /**
  256. * Custom Icons
  257. *
  258. * @param string $icon (constant or filename)
  259. * @param array $options:
  260. * - translate, ...
  261. * @param array $attributes:
  262. * - title, alt, ...
  263. * THE REST IS DEPRECATED
  264. * @return string
  265. */
  266. public function cIcon($icon, $t = null, $a = null, $translate = true, $options = []) {
  267. if (is_array($t)) {
  268. $translate = isset($t['translate']) ? $t['translate'] : true;
  269. $options = (array)$a;
  270. $a = isset($t['alt']) ? $t['alt'] : null; // deprecated
  271. $t = isset($t['title']) ? $t['title'] : null; // deprecated
  272. }
  273. $type = pathinfo($icon, PATHINFO_FILENAME);
  274. if (!$this->_config['fontIcons'] || !isset($this->_config['fontIcons'][$type])) {
  275. $title = isset($t) ? $t : ucfirst($type);
  276. $alt = (isset($a) ? $a : Inflector::slug($title));
  277. if ($translate !== false) {
  278. $title = __($title);
  279. $alt = __($alt);
  280. }
  281. if ($alt) {
  282. $alt = '[' . $alt . ']';
  283. }
  284. $defaults = ['title' => $title, 'alt' => $alt, 'class' => 'icon'];
  285. $options += $defaults;
  286. if (substr($icon, 0, 1) !== '/') {
  287. $icon = 'icons/' . $icon;
  288. }
  289. return $this->Html->image($icon, $options);
  290. }
  291. $options['title'] = $t;
  292. $options['translate'] = $translate;
  293. return $this->_fontIcon($type, $options);
  294. }
  295. /**
  296. * FormatHelper::_fontIcon()
  297. *
  298. * @param string $type
  299. * @param array $options
  300. * @return string
  301. */
  302. protected function _fontIcon($type, $options) {
  303. $iconType = $this->_config['fontIcons'][$type];
  304. $defaults = [
  305. 'class' => $iconType . ' ' . $type
  306. ];
  307. $options += $defaults;
  308. if (!isset($options['title'])) {
  309. $options['title'] = ucfirst($type);
  310. if ($options['translate'] !== false) {
  311. $options['title'] = __($options['title']);
  312. }
  313. }
  314. return $this->template->format('icon', $options);
  315. }
  316. /**
  317. * Display yes/no symbol.
  318. *
  319. * @todo $on=1, $text=false, $ontitle=false,... => in array(OPTIONS)
  320. *
  321. * @param text: default FALSE; if TRUE, text instead of the image
  322. * @param ontitle: default FALSE; if it is embadded in a link, set to TRUE
  323. * @return image:Yes/No or text:Yes/No
  324. */
  325. public function yesNo($v, $ontitle = null, $offtitle = null, $on = 1, $text = false, $notitle = false) {
  326. $ontitle = (!empty($ontitle) ? $ontitle : __d('tools', 'Yes'));
  327. $offtitle = (!empty($offtitle) ? $offtitle : __d('tools', 'No'));
  328. $sbez = ['0' => @substr($offtitle, 0, 1), '1' => @substr($ontitle, 0, 1)];
  329. $bez = ['0' => $offtitle, '1' => $ontitle];
  330. if ($v == $on) {
  331. $icon = ICON_YES;
  332. $value = 1;
  333. } else {
  334. $icon = ICON_NO;
  335. $value = 0;
  336. }
  337. if ($text !== false) {
  338. return $bez[$value];
  339. }
  340. $options = ['title' => ($ontitle === false ? '' : $bez[$value]), 'alt' => $sbez[$value], 'class' => 'icon'];
  341. if ($this->_config['fontIcons']) {
  342. return $this->cIcon($icon, $options['title']);
  343. }
  344. return $this->Html->image('icons/' . $icon, $options);
  345. }
  346. /**
  347. * Get URL of a png img of a website (16x16 pixel).
  348. *
  349. * @param string domain
  350. * @return string
  351. */
  352. public function siteIconUrl($domain) {
  353. if (strpos($domain, 'http') === 0) {
  354. // Strip protocol
  355. $pieces = parse_url($domain);
  356. $domain = $pieces['host'];
  357. }
  358. return 'http://www.google.com/s2/favicons?domain=' . $domain;
  359. }
  360. /**
  361. * Display a png img of a website (16x16 pixel)
  362. * if not available, will return a fallback image (a globe)
  363. *
  364. * @param domain (preferably without protocol, e.g. "www.site.com")
  365. * @return string
  366. */
  367. public function siteIcon($domain, $options = []) {
  368. $url = $this->siteIconUrl($domain);
  369. $options['width'] = 16;
  370. $options['height'] = 16;
  371. if (!isset($options['alt'])) {
  372. $options['alt'] = $domain;
  373. }
  374. if (!isset($options['title'])) {
  375. $options['title'] = $domain;
  376. }
  377. return $this->Html->image($url, $options);
  378. }
  379. /**
  380. * Display a disabled link tag
  381. *
  382. * @param string $text
  383. * @param array $options
  384. * @return string
  385. */
  386. public function disabledLink($text, $options = []) {
  387. $defaults = ['class' => 'disabledLink', 'title' => __d('tools', 'notAvailable')];
  388. $options += $defaults;
  389. return $this->Html->tag('span', $text, $options);
  390. }
  391. /**
  392. * Generates a pagination count: #1 etc for each pagination record
  393. * respects order (ASC/DESC)
  394. *
  395. * @param array $paginator
  396. * @param int $count (current post count on this page)
  397. * @param string $dir (ASC/DESC)
  398. * @return int
  399. * @deprecated
  400. */
  401. public function absolutePaginateCount(array $paginator, $count, $dir = null) {
  402. if ($dir === null) {
  403. $dir = 'ASC';
  404. }
  405. $currentPage = $paginator['page'];
  406. $pageCount = $paginator['pageCount'];
  407. $totalCount = $paginator['count'];
  408. $limit = $paginator['limit'];
  409. $step = 1; //$paginator['step'];
  410. //pr($paginator);
  411. if ($dir === 'DESC') {
  412. $currentCount = $count + ($pageCount - $currentPage) * $limit * $step;
  413. if ($currentPage != $pageCount && $pageCount > 1) {
  414. $currentCount -= $pageCount * $limit * $step - $totalCount;
  415. }
  416. } else {
  417. $currentCount = $count + ($currentPage - 1) * $limit * $step;
  418. }
  419. return $currentCount;
  420. }
  421. /**
  422. * Fixes utf8 problems of native php str_pad function
  423. * //TODO: move to textext helper?
  424. *
  425. * @param string $input
  426. * @param int $padLength
  427. * @param string $padString
  428. * @param mixed $padType
  429. * @return string input
  430. */
  431. public function pad($input, $padLength, $padString, $padType = STR_PAD_RIGHT) {
  432. $length = mb_strlen($input);
  433. if ($padLength - $length > 0) {
  434. switch ($padType) {
  435. case STR_PAD_LEFT:
  436. $input = str_repeat($padString, $padLength - $length) . $input;
  437. break;
  438. case STR_PAD_RIGHT:
  439. $input .= str_repeat($padString, $padLength - $length);
  440. break;
  441. }
  442. }
  443. return $input;
  444. }
  445. /**
  446. * Returns red colored if not ok
  447. *
  448. * @param string $value
  449. * @param $okValue
  450. * @return string Value in HTML tags
  451. */
  452. public function warning($value, $ok = false) {
  453. if (!$ok) {
  454. return $this->ok($value, false);
  455. }
  456. return $value;
  457. }
  458. /**
  459. * Returns green on ok, red otherwise
  460. *
  461. * @todo Remove inline css and make classes better: green=>ok red=>not-ok
  462. * Maybe use templating
  463. *
  464. * @param mixed $currentValue
  465. * @param bool $ok: true/false (defaults to false)
  466. * //@param string $comparizonType
  467. * //@param mixed $okValue
  468. * @return string newValue nicely formatted/colored
  469. */
  470. public function ok($value, $ok = false) {
  471. if ($ok) {
  472. $value = '<span class="green" style="color:green">' . $value . '</span>';
  473. } else {
  474. $value = '<span class="red" style="color:red">' . $value . '</span>';
  475. }
  476. return $value;
  477. }
  478. /**
  479. * Useful for displaying tabbed (code) content when the default of 8 spaces
  480. * inside <pre> is too much. This converts it to spaces for better output.
  481. *
  482. * Inspired by the tab2space function found at:
  483. * @see http://aidan.dotgeek.org/lib/?file=function.tab2space.php
  484. * @param string $text
  485. * @param int $spaces
  486. * @return string
  487. */
  488. public function tab2space($text, $spaces = 4) {
  489. $spaces = str_repeat(" ", $spaces);
  490. $text = preg_split("/\r\n|\r|\n/", trim($text));
  491. $wordLengths = [];
  492. $wArray = [];
  493. // Store word lengths
  494. foreach ($text as $line) {
  495. $words = preg_split("/(\t+)/", $line, -1, PREG_SPLIT_DELIM_CAPTURE);
  496. foreach (array_keys($words) as $i) {
  497. $strlen = strlen($words[$i]);
  498. $add = isset($wordLengths[$i]) && ($wordLengths[$i] < $strlen);
  499. if ($add || !isset($wordLengths[$i])) {
  500. $wordLengths[$i] = $strlen;
  501. }
  502. }
  503. $wArray[] = $words;
  504. }
  505. $text = '';
  506. // Apply padding when appropriate and rebuild the string
  507. foreach (array_keys($wArray) as $i) {
  508. foreach (array_keys($wArray[$i]) as $ii) {
  509. if (preg_match("/^\t+$/", $wArray[$i][$ii])) {
  510. $wArray[$i][$ii] = str_pad($wArray[$i][$ii], $wordLengths[$ii], "\t");
  511. } else {
  512. $wArray[$i][$ii] = str_pad($wArray[$i][$ii], $wordLengths[$ii]);
  513. }
  514. }
  515. $text .= str_replace("\t", $spaces, implode("", $wArray[$i])) . "\n";
  516. }
  517. return $text;
  518. }
  519. /**
  520. * Translate a result array into a HTML table
  521. *
  522. * @todo Move to Text Helper etc.
  523. *
  524. * @author Aidan Lister <aidan@php.net>
  525. * @version 1.3.2
  526. * @link http://aidanlister.com/2004/04/converting-arrays-to-human-readable-tables/
  527. * @param array $array The result (numericaly keyed, associative inner) array.
  528. * @param bool $recursive Recursively generate tables for multi-dimensional arrays
  529. * @param string $null String to output for blank cells
  530. */
  531. public function array2table($array, $options = []) {
  532. $defaults = [
  533. 'null' => '&nbsp;',
  534. 'recursive' => false,
  535. 'heading' => true,
  536. 'escape' => true
  537. ];
  538. $options += $defaults;
  539. // Sanity check
  540. if (empty($array) || !is_array($array)) {
  541. return false;
  542. }
  543. if (!isset($array[0]) || !is_array($array[0])) {
  544. $array = [$array];
  545. }
  546. // Start the table
  547. $table = "<table>\n";
  548. if ($options['heading']) {
  549. // The header
  550. $table .= "\t<tr>";
  551. // Take the keys from the first row as the headings
  552. foreach (array_keys($array[0]) as $heading) {
  553. $table .= '<th>' . ($options['escape'] ? h($heading) : $heading) . '</th>';
  554. }
  555. $table .= "</tr>\n";
  556. }
  557. // The body
  558. foreach ($array as $row) {
  559. $table .= "\t<tr>";
  560. foreach ($row as $cell) {
  561. $table .= '<td>';
  562. // Cast objects
  563. if (is_object($cell)) {
  564. $cell = (array)$cell;
  565. }
  566. if ($options['recursive'] && is_array($cell) && !empty($cell)) {
  567. // Recursive mode
  568. $table .= "\n" . static::array2table($cell, $options) . "\n";
  569. } else {
  570. $table .= (!is_array($cell) && strlen($cell) > 0) ? ($options['escape'] ? h($cell) : $cell) : $options['null'];
  571. }
  572. $table .= '</td>';
  573. }
  574. $table .= "</tr>\n";
  575. }
  576. $table .= '</table>';
  577. return $table;
  578. }
  579. public $icons = [
  580. 'up' => [
  581. 'pic' => ICON_UP,
  582. 'title' => 'Up',
  583. ],
  584. 'down' => [
  585. 'pic' => ICON_DOWN,
  586. 'title' => 'Down',
  587. ],
  588. 'edit' => [
  589. 'pic' => ICON_EDIT,
  590. 'title' => 'Edit',
  591. ],
  592. 'view' => [
  593. 'pic' => ICON_VIEW,
  594. 'title' => 'View',
  595. ],
  596. 'delete' => [
  597. 'pic' => ICON_DELETE,
  598. 'title' => 'Delete',
  599. ],
  600. 'reset' => [
  601. 'pic' => ICON_RESET,
  602. 'title' => 'Reset',
  603. ],
  604. 'help' => [
  605. 'pic' => ICON_HELP,
  606. 'title' => 'Help',
  607. ],
  608. 'loader' => [
  609. 'pic' => 'loader.white.gif',
  610. 'title' => 'Loading...',
  611. ],
  612. 'loader-alt' => [
  613. 'pic' => 'loader.black.gif',
  614. 'title' => 'Loading...',
  615. ],
  616. 'details' => [
  617. 'pic' => ICON_DETAILS,
  618. 'title' => 'Details',
  619. ],
  620. 'use' => [
  621. 'pic' => ICON_USE,
  622. 'title' => 'Use',
  623. ],
  624. 'yes' => [
  625. 'pic' => ICON_YES,
  626. 'title' => 'Yes',
  627. ],
  628. 'no' => [
  629. 'pic' => ICON_NO,
  630. 'title' => 'No',
  631. ],
  632. // deprecated from here down
  633. 'close' => [
  634. 'pic' => ICON_CLOCK,
  635. 'title' => 'Close',
  636. ],
  637. 'reply' => [
  638. 'pic' => ICON_REPLY,
  639. 'title' => 'Reply',
  640. ],
  641. 'time' => [
  642. 'pic' => ICON_CLOCK,
  643. 'title' => 'Time',
  644. ],
  645. 'check' => [
  646. 'pic' => ICON_CHECK,
  647. 'title' => 'Check',
  648. ],
  649. 'role' => [
  650. 'pic' => ICON_ROLE,
  651. 'title' => 'Role',
  652. ],
  653. 'add' => [
  654. 'pic' => ICON_ADD,
  655. 'title' => 'Add',
  656. ],
  657. 'remove' => [
  658. 'pic' => ICON_REMOVE,
  659. 'title' => 'Remove',
  660. ],
  661. 'email' => [
  662. 'pic' => ICON_EMAIL,
  663. 'title' => 'Email',
  664. ],
  665. 'options' => [
  666. 'pic' => ICON_SETTINGS,
  667. 'title' => 'Options',
  668. ],
  669. 'lock' => [
  670. 'pic' => ICON_LOCK,
  671. 'title' => 'Locked',
  672. ],
  673. 'warning' => [
  674. 'pic' => ICON_WARNING,
  675. 'title' => 'Warning',
  676. ],
  677. 'genderUnknown' => [
  678. 'pic' => 'gender_icon.gif',
  679. 'title' => 'genderUnknown',
  680. ],
  681. 'genderMale' => [
  682. 'pic' => 'gender_icon_m.gif',
  683. 'title' => 'genderMale',
  684. ],
  685. 'genderFemale' => [
  686. 'pic' => 'gender_icon_f.gif',
  687. 'title' => 'genderFemale',
  688. ],
  689. ];
  690. }
  691. // Default icons
  692. if (!defined('ICON_UP')) {
  693. define('ICON_UP', 'up.gif');
  694. }
  695. if (!defined('ICON_DOWN')) {
  696. define('ICON_DOWN', 'down.gif');
  697. }
  698. if (!defined('ICON_EDIT')) {
  699. define('ICON_EDIT', 'edit.gif');
  700. }
  701. if (!defined('ICON_VIEW')) {
  702. define('ICON_VIEW', 'see.gif');
  703. }
  704. if (!defined('ICON_DELETE')) {
  705. define('ICON_DELETE', 'delete.gif');
  706. }
  707. if (!defined('ICON_DETAILS')) {
  708. define('ICON_DETAILS', 'loupe.gif');
  709. }
  710. if (!defined('ICON_OPTIONS')) {
  711. define('ICON_OPTIONS', 'options.gif');
  712. }
  713. if (!defined('ICON_SETTINGS')) {
  714. define('ICON_SETTINGS', 'options.gif');
  715. }
  716. if (!defined('ICON_USE')) {
  717. define('ICON_USE', 'use.gif');
  718. }
  719. if (!defined('ICON_CLOSE')) {
  720. define('ICON_CLOSE', 'close.gif');
  721. }
  722. if (!defined('ICON_REPLY')) {
  723. define('ICON_REPLY', 'reply.gif');
  724. }
  725. if (!defined('ICON_RESET')) {
  726. define('ICON_RESET', 'reset.gif');
  727. }
  728. if (!defined('ICON_HELP')) {
  729. define('ICON_HELP', 'help.gif');
  730. }
  731. if (!defined('ICON_YES')) {
  732. define('ICON_YES', 'yes.gif');
  733. }
  734. if (!defined('ICON_NO')) {
  735. define('ICON_NO', 'no.gif');
  736. }
  737. if (!defined('ICON_CLOCK')) {
  738. define('ICON_CLOCK', 'clock.gif');
  739. }
  740. if (!defined('ICON_CHECK')) {
  741. define('ICON_CHECK', 'check.gif');
  742. }
  743. if (!defined('ICON_ROLE')) {
  744. define('ICON_ROLE', 'role.gif');
  745. }
  746. if (!defined('ICON_ADD')) {
  747. define('ICON_ADD', 'add.gif');
  748. }
  749. if (!defined('ICON_REMOVE')) {
  750. define('ICON_REMOVE', 'remove.gif');
  751. }
  752. if (!defined('ICON_EMAIL')) {
  753. define('ICON_EMAIL', 'email.gif');
  754. }
  755. if (!defined('ICON_LOCK')) {
  756. define('ICON_LOCK', 'lock.gif');
  757. }
  758. if (!defined('ICON_WARNING')) {
  759. define('ICON_WARNING', 'warning.png');
  760. }
  761. if (!defined('ICON_MAP')) {
  762. define('ICON_MAP', 'map.gif');
  763. }