FormatHelper.php 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. <?php
  2. App::uses('TextHelper', 'View/Helper');
  3. App::uses('StringTemplate', 'Tools.View');
  4. /**
  5. * Format helper with basic html snippets
  6. *
  7. * TODO: make snippets more "css and background image" (instead of inline img links)
  8. *
  9. * @author Mark Scherer
  10. * @license MIT
  11. */
  12. class FormatHelper extends TextHelper {
  13. /**
  14. * Other helpers used by FormHelper
  15. *
  16. * @var array
  17. */
  18. public $helpers = array('Html', 'Tools.Numeric');
  19. protected $_defaultConfig = array(
  20. 'fontIcons' => false
  21. );
  22. public function __construct(View $View, $config = array()) {
  23. $config += $this->_defaultConfig;
  24. if ($config['fontIcons'] === true) {
  25. $config['fontIcons'] = (array)Configure::read('Format.fontIcons');
  26. }
  27. parent::__construct($View, $config);
  28. }
  29. /**
  30. * jqueryAccess: {id}Pro, {id}Contra
  31. *
  32. * @return string
  33. */
  34. public function thumbs($id, $inactive = false, $inactiveTitle = null) {
  35. $class = 'Active';
  36. $upTitle = __('Zustimmen');
  37. $downTitle = __('Dagegen');
  38. if ($inactive === true) {
  39. $class = 'Inactive';
  40. $upTitle = $downTitle = !empty($inactiveTitle) ? $inactiveTitle : __('alreadyVoted');
  41. }
  42. $ret = '<div class="thumbsUpDown">';
  43. $ret .= '<div id="' . $id . 'Pro' . $class . '" rel="' . $id . '" class="thumbUp up' . $class . '" title="' . $upTitle . '"></div>';
  44. $ret .= '<div id="' . $id . 'Contra' . $class . '" rel="' . $id . '" class="thumbDown down' . $class . '" title="' . $downTitle . '"></div>';
  45. $ret .= '<br class="clear"/>';
  46. $ret .= '</div>';
  47. return $ret;
  48. }
  49. /**
  50. * Display neighbor quicklinks
  51. *
  52. * @param array $neighbors (containing prev and next)
  53. * @param string $field: just field or Model.field syntax
  54. * @param array $options:
  55. * - name: title name: next{Record} (if none is provided, "record" is used - not translated!)
  56. * - slug: true/false (defaults to false)
  57. * - titleField: field or Model.field
  58. * @return string
  59. */
  60. public function neighbors($neighbors, $field, $options = array()) {
  61. if (mb_strpos($field, '.') !== false) {
  62. $fieldArray = explode('.', $field, 2);
  63. $alias = $fieldArray[0];
  64. $field = $fieldArray[1];
  65. }
  66. if (empty($alias)) {
  67. if (!empty($neighbors['prev'])) {
  68. $modelNames = array_keys($neighbors['prev']);
  69. $alias = $modelNames[0];
  70. } elseif (!empty($neighbors['next'])) {
  71. $modelNames = array_keys($neighbors['next']);
  72. $alias = $modelNames[0];
  73. }
  74. }
  75. if (empty($field)) {
  76. }
  77. $name = 'Record'; // Translation further down!
  78. if (!empty($options['name'])) {
  79. $name = ucfirst($options['name']);
  80. }
  81. $prevSlug = $nextSlug = null;
  82. if (!empty($options['slug'])) {
  83. if (!empty($neighbors['prev'])) {
  84. $prevSlug = slug($neighbors['prev'][$alias][$field]);
  85. }
  86. if (!empty($neighbors['next'])) {
  87. $nextSlug = slug($neighbors['next'][$alias][$field]);
  88. }
  89. }
  90. $titleAlias = $alias;
  91. $titleField = $field;
  92. if (!empty($options['titleField'])) {
  93. if (mb_strpos($options['titleField'], '.') !== false) {
  94. $fieldArray = explode('.', $options['titleField'], 2);
  95. $titleAlias = $fieldArray[0];
  96. $titleField = $fieldArray[1];
  97. } else {
  98. $titleField = $options['titleField'];
  99. }
  100. }
  101. if (!isset($options['escape']) || $options['escape'] === false) {
  102. $titleField = h($titleField);
  103. }
  104. $ret = '<div class="nextPrevNavi">';
  105. if (!empty($neighbors['prev'])) {
  106. $url = array($neighbors['prev'][$alias]['id'], $prevSlug);
  107. if (!empty($options['url'])) {
  108. $url += $options['url'];
  109. }
  110. $ret .= $this->Html->link($this->cIcon(ICON_PREV, false) . '&nbsp;' . __('prev' . $name), $url, array('escape' => false, 'title' => $neighbors['prev'][$titleAlias][$titleField]));
  111. } else {
  112. $ret .= $this->cIcon(ICON_PREV_DISABLED, __('noPrev' . $name)) . '&nbsp;' . __('prev' . $name);
  113. }
  114. $ret .= '&nbsp;&nbsp;';
  115. if (!empty($neighbors['next'])) {
  116. $url = array($neighbors['next'][$alias]['id'], $prevSlug);
  117. if (!empty($options['url'])) {
  118. $url += $options['url'];
  119. }
  120. $ret .= $this->Html->link($this->cIcon(ICON_NEXT, false) . '&nbsp;' . __('next' . $name), $url, array('escape' => false, 'title' => $neighbors['next'][$titleAlias][$titleField]));
  121. } else {
  122. $ret .= $this->cIcon(ICON_NEXT_DISABLED, __('noNext' . $name)) . '&nbsp;' . __('next' . $name);
  123. }
  124. $ret .= '</div>';
  125. return $ret;
  126. }
  127. /**
  128. * Allows icons to be added on the fly
  129. * NOTE: overriding not allowed by default
  130. *
  131. * @return void
  132. */
  133. public function addIcon($name = null, $pic = null, $title = null, $allowOverride = false) {
  134. if ($allowOverride === true || ($allowOverride !== true && !array_key_exists($name, $this->icons))) {
  135. if (!empty($name) && !empty($pic)) {
  136. $this->icons[$name] = array('pic' => strtolower($pic), 'title' => (!empty($title) ? $title : ''));
  137. }
  138. }
  139. }
  140. const GENDER_FEMALE = 2;
  141. const GENDER_MALE = 1;
  142. /**
  143. * Displays gender icon
  144. *
  145. * @return string
  146. */
  147. public function genderIcon($value = null, $type = null) {
  148. $value = (int)$value;
  149. if ($value == self::GENDER_FEMALE) {
  150. $icon = $this->icon('genderFemale', null, null, null, array('class' => 'gender'));
  151. } elseif ($value == self::GENDER_MALE) {
  152. $icon = $this->icon('genderMale', null, null, null, array('class' => 'gender'));
  153. } else {
  154. $icon = $this->icon('genderUnknown', null, null, null, array('class' => 'gender'));
  155. }
  156. return $icon;
  157. }
  158. /**
  159. * Returns img from customImgFolder
  160. *
  161. * @param string $folder
  162. * @param string $icon
  163. * @param bool $checkExists
  164. * @param array $options (ending [default: gif])
  165. * @return string
  166. */
  167. public function customIcon($folder, $icon = null, $checkExist = false, $options = array(), $attr = array()) {
  168. $attachment = 'default';
  169. $ending = 'gif';
  170. $image = null;
  171. if (!empty($options)) {
  172. if (!empty($options['ending'])) {
  173. $ending = $options['ending'];
  174. }
  175. if (!empty($options['backend'])) {
  176. $attachment = 'backend';
  177. }
  178. }
  179. if (empty($icon)) {
  180. } elseif ($checkExist === true && !file_exists(PATH_CONTENT . $folder . DS . $icon . '.' . $ending)) {
  181. } else {
  182. $image = $icon;
  183. }
  184. if ($image === null) {
  185. return $this->Html->image(IMG_ICONS . 'custom' . '/' . $folder . '_' . $attachment . '.' . $ending, $attr);
  186. }
  187. return $this->Html->image(IMG_CONTENT . $folder . '/' . $image . '.' . $ending, $attr);
  188. }
  189. /**
  190. * @return string
  191. */
  192. public function importantIcon($icon, $value) {
  193. $ending = 'gif';
  194. $image = 'default';
  195. if (!empty($value)) {
  196. $image = 'important';
  197. }
  198. return $this->Html->image(IMG_ICONS . $icon . '_' . $image . '.' . $ending);
  199. }
  200. /**
  201. * @param value
  202. * @param array $options
  203. * - max (3/5, defaults to 5)
  204. * - normal: display an icon for normal as well (defaults to false)
  205. * - map: array (manually map values, if you use 1 based values no need for that)
  206. * - title, alt, ...
  207. * @return string html
  208. */
  209. public function priorityIcon($value, $options = array()) {
  210. $defaults = array(
  211. 'max' => 5,
  212. 'normal' => false,
  213. 'map' => array(),
  214. 'css' => true,
  215. );
  216. $options = array_merge($defaults, $options);
  217. extract($options);
  218. $matching = array(
  219. 1 => 'low',
  220. 2 => 'lower',
  221. 3 => 'normal',
  222. 4 => 'higher',
  223. 5 => 'high'
  224. );
  225. if (!empty($map)) {
  226. $value = $map[$value];
  227. }
  228. if (!$normal && $value == ($max + 1) / 2) {
  229. return '';
  230. }
  231. if ($max != 5) {
  232. if ($value == 2) {
  233. $value = 3;
  234. } elseif ($value == 3) {
  235. $value = 5;
  236. }
  237. }
  238. $attr = array(
  239. 'class' => 'prio-' . $matching[$value],
  240. 'title' => __('prio' . ucfirst($matching[$value])),
  241. );
  242. if (!$css) {
  243. $attr['alt'] = $matching[$value];
  244. }
  245. $attr = array_merge($attr, array_diff_key($options, $defaults));
  246. if ($css) {
  247. $html = $this->Html->tag('div', '&nbsp;', $attr);
  248. } else {
  249. $icon = 'priority_' . $matching[$value] . '.gif';
  250. $html = $this->Html->image('icons/' . $icon, $attr);
  251. }
  252. return $html;
  253. }
  254. /**
  255. * Display a font icon (fast and resource-efficient).
  256. * Uses http://fontawesome.io/icons/
  257. *
  258. * Options:
  259. * - size (int|string: 1...5 or large)
  260. * - rotate (integer: 90, 270, ...)
  261. * - spin (booelan: true/false)
  262. * - extra (array: muted, light, dark, border)
  263. * - pull (string: left, right)
  264. *
  265. * @param string|array $icon
  266. * @param array $options
  267. * @return string
  268. */
  269. public function fontIcon($icon, array $options = array(), array $attributes = array()) {
  270. $icon = (array)$icon;
  271. $class = array();
  272. foreach ($icon as $i) {
  273. $class[] = 'icon-' . $i;
  274. }
  275. if (!empty($options['extra'])) {
  276. foreach ($options['extra'] as $i) {
  277. $class[] = 'icon-' . $i;
  278. }
  279. }
  280. if (!empty($options['size'])) {
  281. $class[] = 'icon-' . ($options['size'] === 'large' ? 'large' : $options['size'] . 'x');
  282. }
  283. if (!empty($options['pull'])) {
  284. $class[] = 'pull-' . $options['pull'];
  285. }
  286. if (!empty($options['rotate'])) {
  287. $class[] = 'icon-rotate-' . (int)$options['rotate'];
  288. }
  289. if (!empty($options['spin'])) {
  290. $class[] = 'icon-spin';
  291. }
  292. return '<i class="' . implode(' ', $class) . '"></i>';
  293. }
  294. /**
  295. * Quick way of printing default icons
  296. *
  297. * @param type
  298. * @param title
  299. * @param alt (set to FALSE if no alt is supposed to be shown)
  300. * @param bool automagic i18n translate [default true = __('xyz')]
  301. * @param options array ('class'=>'','width/height'=>'','onclick=>'') etc
  302. * @return string
  303. */
  304. public function icon($type, $t = null, $a = null, $translate = null, $options = array()) {
  305. if (isset($t) && $t === false) {
  306. $title = '';
  307. } elseif (empty($t)) {
  308. } else {
  309. $title = $t;
  310. }
  311. if (isset($a) && $a === false) {
  312. $alt = '';
  313. } elseif (empty($a)) {
  314. } else {
  315. $alt = $a;
  316. }
  317. if (array_key_exists($type, $this->icons)) {
  318. $pic = $this->icons[$type]['pic'];
  319. $title = (isset($title) ? $title : $this->icons[$type]['title']);
  320. $alt = (isset($alt) ? $alt : preg_replace('/[^a-zA-Z0-9]/', '', $this->icons[$type]['title']));
  321. if ($translate !== false) {
  322. $title = __($title);
  323. $alt = __($alt);
  324. }
  325. $alt = '[' . $alt . ']';
  326. } else {
  327. $pic = 'pixelspace.gif';
  328. $title = '';
  329. $alt = '';
  330. }
  331. if (!$this->settings['fontIcons'] || !isset($this->settings['fontIcons'][$type])) {
  332. $defaults = array('title' => $title, 'alt' => $alt, 'class' => 'icon');
  333. $newOptions = $options + $defaults;
  334. return $this->Html->image('icons/' . $pic, $newOptions);
  335. }
  336. $iconType = $this->settings['fontIcons'][$type];
  337. $templates = array(
  338. 'icon' => '<i class="{{class}}" title="{{title}}" data-placement="bottom" data-toggle="tooltip"></i>',
  339. );
  340. if (!isset($this->template)) {
  341. $this->template = new StringTemplate($templates);
  342. }
  343. if (!$title) {
  344. $title = ucfirst($type);
  345. if ($translate !== false) {
  346. $title = __($title);
  347. }
  348. }
  349. $defaults = array(
  350. 'title' => $title,
  351. 'class' => $iconType . ' ' . $type
  352. );
  353. $options += $defaults;
  354. return $this->template->format('icon', $options);
  355. }
  356. /**
  357. * Custom Icons
  358. *
  359. * @param string $icon (constant or filename)
  360. * @param array $options:
  361. * - translate, ...
  362. * @param array $attributes:
  363. * - title, alt, ...
  364. * THE REST IS DEPRECATED
  365. * @return string
  366. */
  367. public function cIcon($icon, $t = null, $a = null, $translate = true, $options = array()) {
  368. if (is_array($t)) {
  369. $translate = isset($t['translate']) ? $t['translate'] : true;
  370. $options = (array)$a;
  371. $a = isset($t['alt']) ? $t['alt'] : null; // deprecated
  372. $t = isset($t['title']) ? $t['title'] : null; // deprecated
  373. }
  374. $title = (isset($t) ? $t : ucfirst(extractPathInfo('filename', $icon)));
  375. //$alt = (isset($a)?$a:preg_replace('/[^a-zA-Z0-9]/', '', $title));
  376. $alt = (isset($a) ? $a : Inflector::slug($title, '-'));
  377. if ($translate !== false) {
  378. $title = __($title);
  379. $alt = __($alt);
  380. }
  381. $alt = '[' . $alt . ']';
  382. $defaultOptions = array('title' => $title, 'alt' => $alt, 'class' => 'icon');
  383. $options = array_merge($defaultOptions, $options);
  384. if (substr($icon, 0, 1) !== '/') {
  385. $icon = 'icons/' . $icon;
  386. }
  387. return $this->Html->image($icon, $options);
  388. }
  389. /**
  390. * Print Star Bar
  391. * //TODO: 0.5 steps!
  392. *
  393. * array $options: steps=1/0.5 [default:1]), show_zero=true/false [default:false], title=false/true [default:false]
  394. * array $attr: string 'title' (both single and span title empty => 'x of x' for span)
  395. * @return string
  396. * @deprecated use RatingHelper::stars() instead
  397. */
  398. public function showStars($current = null, $max = null, $options = array(), $attr = array()) {
  399. $res = '---';
  400. if (!empty($options['steps']) && $options['steps'] == 0.5) {
  401. $steps = 0.5;
  402. $current = ((int)(2 * $current) / 2);
  403. } else {
  404. $steps = 1;
  405. $current = (int)$current;
  406. }
  407. $min = (int)$current;
  408. $max = (int)$max;
  409. if ((!empty($current) || (!empty($options['show_zero']) && $current == 0)) && (!empty($max)) && $current <= $max) {
  410. if (!empty($options) && is_array($options)) {
  411. }
  412. $text = '';
  413. for ($i = 0;$i < $min;$i++) {
  414. $attributes = array('alt' => '#', 'class' => 'full');
  415. if (!empty($options['title'])) { $attributes['title'] = ($i + 1) . '/' . $max; } // ?
  416. $text .= $this->Html->image('icons/star_icon2.gif', $attributes);
  417. }
  418. for ($i = $min;$i < $max;$i++) {
  419. $attributes = array('alt' => '-', 'class' => 'empty');
  420. if (!empty($options['title'])) { $attributes['title'] = ($i + 1) . '/' . $max; } // ?
  421. if ($steps == 0.5 && $current == $i + 0.5) {
  422. $text .= $this->Html->image('icons/star_icon2_half.gif', $attributes);
  423. } else {
  424. $text .= $this->Html->image('icons/star_icon2_empty.gif', $attributes);
  425. }
  426. }
  427. $attributes = array('class' => 'starBar');
  428. $attributes = array_merge($attributes, $attr);
  429. if (empty($attributes['title']) && empty($options['title'])) {
  430. $attributes['title'] = ($current) . ' ' . __('of') . ' ' . $max;
  431. }
  432. $res = $this->Html->tag('span', $text, $attributes);
  433. //$res='<span title="ss" class="starBar">'.$text.'</span>';
  434. } else {
  435. if ($max > 3) {
  436. for ($i = 0; $i < $max - 3; $i++) {
  437. $res .= '-';
  438. }
  439. }
  440. }
  441. return $res;
  442. }
  443. /**
  444. * Display language flags
  445. *
  446. * @return string HTML
  447. */
  448. public function languageFlags() {
  449. $langs = Configure::read('LanguagesAvailable');
  450. $supportedLangs = array(
  451. 'de' => array('title' => 'Deutsch'),
  452. 'en' => array('title' => 'English'),
  453. 'it' => array('title' => 'Italiano'),
  454. );
  455. $languageChange = __('Language') . ': ';
  456. $languages = array();
  457. foreach ($langs as $lang) {
  458. $languages[$lang] = $supportedLangs[$lang];
  459. }
  460. if ($sLang = (string)CakeSession::read('Config.language')) {
  461. $lang = $sLang;
  462. } else {
  463. $lang = '';
  464. }
  465. echo '<span class="country">';
  466. foreach ($languages as $code => $la) {
  467. if ($lang == $code) {
  468. $languageChange .= $this->Html->image('language_flags/' . $code . '.gif', array('alt' => $code, 'title' => $la['title'] . ' (' . __('active') . ')', 'class' => 'country_flag active')) . '';
  469. } else {
  470. $languageChange .= $this->Html->link($this->Html->image('language_flags/' . $code . '.gif', array('alt' => $code, 'title' => $la['title'], 'class' => 'country_flag')), '/lang/' . $code, array('escape' => false)) . '';
  471. }
  472. }
  473. $languageChange .= '</span>'; //.__('(Translation not complete yet)');
  474. return $languageChange;
  475. }
  476. /**
  477. * It is still believed that encoding will stop spam-bots being able to find your email address.
  478. * Nevertheless, encoded email address harvester are on the way (http://www.dreamweaverfever.com/experiments/spam/).
  479. *
  480. * //TODO: move to TextExt?
  481. * Helper Function to Obfuscate Email by inserting a span tag (not more! not very secure on its own...)
  482. * each part of this mail now does not make sense anymore on its own
  483. * (striptags will not work either)
  484. *
  485. * @param string email: necessary (and valid - containing one @)
  486. * @return string
  487. */
  488. public function encodeEmail($mail) {
  489. list($mail1, $mail2) = explode('@', $mail);
  490. $encMail = $this->encodeText($mail1) . '<span>@</span>' . $this->encodeText($mail2);
  491. return $encMail;
  492. }
  493. /**
  494. * //TODO: move to TextExt?
  495. * Obfuscates Email (works without JS!) to avoid spam bots to get it
  496. *
  497. * @param string mail: email to encode
  498. * @param string text: optional (if none is given, email will be text as well)
  499. * @param array attributes: html tag attributes
  500. * @param array params: ?subject=y&body=y to be attached to "mailto:xyz"
  501. * @return string Save string with JS generated link around email (and non JS fallback)
  502. */
  503. public function encodeEmailUrl($mail, $text = null, $params = array(), $attr = array()) {
  504. if (empty($class)) { $class = 'email';}
  505. $defaults = array(
  506. 'title' => __('for use in an external mail client'),
  507. 'class' => 'email',
  508. 'escape' => false
  509. );
  510. if (empty($text)) {
  511. $text = $this->encodeEmail($mail);
  512. }
  513. $encMail = 'mailto:' . $mail;
  514. // additionally there could be a span tag in between: email<span syle="display:none"></span>@web.de
  515. $querystring = '';
  516. foreach ($params as $key => $val) {
  517. if ($querystring) {
  518. $querystring .= "&$key=" . rawurlencode($val);
  519. } else {
  520. $querystring = "?$key=" . rawurlencode($val);
  521. }
  522. }
  523. $attr = array_merge($defaults, $attr);
  524. $xmail = $this->Html->link('', $encMail . $querystring, $attr);
  525. $xmail1 = mb_substr($xmail, 0, count($xmail) - 5);
  526. $xmail2 = mb_substr($xmail, -4, 4);
  527. $len = mb_strlen($xmail1);
  528. $i = 0;
  529. while ($i < $len) {
  530. $c = mt_rand(2, 6);
  531. $par[] = (mb_substr($xmail1, $i, $c));
  532. $i += $c;
  533. }
  534. $join = implode('\'+ \'', $par);
  535. return '<script language=javascript><!--
  536. document.write(\'' . $join . '\');
  537. //--></script>
  538. ' . $text . '
  539. <script language=javascript><!--
  540. document.write(\'' . $xmail2 . '\');
  541. //--></script>';
  542. }
  543. /**
  544. * //TODO: move to TextExt?
  545. * Encodes Piece of Text (without usage of JS!) to avoid spam bots to get it
  546. *
  547. * @param STRING text to encode
  548. * @return string (randomly encoded)
  549. */
  550. public function encodeText($text) {
  551. $encmail = '';
  552. for ($i = 0; $i < mb_strlen($text); $i++) {
  553. $encMod = mt_rand(0, 2);
  554. switch ($encMod) {
  555. case 0: // None
  556. $encmail .= mb_substr($text, $i, 1);
  557. break;
  558. case 1: // Decimal
  559. $encmail .= "&#" . ord(mb_substr($text, $i, 1)) . ';';
  560. break;
  561. case 2: // Hexadecimal
  562. $encmail .= "&#x" . dechex(ord(mb_substr($text, $i, 1))) . ';';
  563. break;
  564. }
  565. }
  566. return $encmail;
  567. }
  568. /**
  569. * Display yes/no symbol.
  570. *
  571. * @todo $on=1, $text=false, $ontitle=false,... => in array(OPTIONS) packen
  572. *
  573. * @param text: default FALSE; if TRUE, text instead of the image
  574. * @param ontitle: default FALSE; if it is embadded in a link, set to TRUE
  575. * @return image:Yes/No or text:Yes/No
  576. */
  577. public function yesNo($v, $ontitle = null, $offtitle = null, $on = 1, $text = false, $notitle = false) {
  578. $ontitle = (!empty($ontitle) ? $ontitle : __('Ja'));
  579. $offtitle = (!empty($offtitle) ? $offtitle : __('Nein'));
  580. $sbez = array('0' => @substr($offtitle, 0, 1), '1' => @substr($ontitle, 0, 1));
  581. $bez = array('0' => $offtitle, '1' => $ontitle);
  582. if ($v == $on) {
  583. $icon = ICON_YES;
  584. $value = 1;
  585. } else {
  586. $icon = ICON_NO;
  587. $value = 0;
  588. }
  589. if ($text !== false) {
  590. $light = $bez[$value];
  591. } else {
  592. //$light='<img src="images/icons/'.$icon.'" alt="'.$sbez[$value].'" '.($notitle!==false?'title="'.$bez[$value].'"':'').'/>';
  593. //$light=$this->Html->image('',)<img src="images/icons/'.$icon.'" alt="'.$sbez[$value].'" '.($notitle!==false?'title="'.$bez[$value].'"':'').'/>';
  594. $options = array('title' => ($ontitle === false ? '' : $bez[$value]), 'alt' => $sbez[$value], 'class' => 'icon');
  595. $light = $this->Html->image('icons/' . $icon, $options);
  596. }
  597. return $light;
  598. }
  599. /**
  600. * Get URL of a png img of a website (16x16 pixel).
  601. *
  602. * @param string domain
  603. * @return string
  604. */
  605. public function siteIconUrl($domain) {
  606. if (strpos($domain, 'http') === 0) {
  607. // Strip protocol
  608. $pieces = parse_url($domain);
  609. $domain = $pieces['host'];
  610. }
  611. return 'http://www.google.com/s2/favicons?domain=' . $domain;
  612. }
  613. /**
  614. * Display a png img of a website (16x16 pixel)
  615. * if not available, will return a fallback image (a globe)
  616. *
  617. * @param domain (preferably without protocol, e.g. "www.site.com")
  618. * @return string
  619. */
  620. public function siteIcon($domain, $options = array()) {
  621. $url = $this->siteIconUrl($domain);
  622. $options['width'] = 16;
  623. $options['height'] = 16;
  624. if (!isset($options['alt'])) {
  625. $options['alt'] = $domain;
  626. }
  627. if (!isset($options['title'])) {
  628. $options['title'] = $domain;
  629. }
  630. return $this->Html->image($url, $options);
  631. }
  632. /**
  633. * Display text as image
  634. * //TODO: move to own helper
  635. *
  636. * @param string $text
  637. * @param array $options (for generation):
  638. * - inline, font, size, background (optional)
  639. * @param array $tagAttributes (for image)
  640. * @return string result - as image
  641. */
  642. public function textAsImage($text, $options = array(), $attr = array()) {
  643. /*
  644. $image = new Imagick();
  645. //$image->newImage(218, 46, new ImagickPixel('white'));
  646. $image->setImageCompression(10); // Keine Auswirkung auf Dicke
  647. $draw = new ImagickDraw();
  648. $draw->setFont($font);
  649. $draw->setFontSize(22.0); // Keine Auswirkung auf Dicke
  650. $draw->setFontWeight(100); // 0-999 Keine Auswirkung auf Dicke
  651. $draw->annotation(5, 20, $text);
  652. $image->drawImage($draw);
  653. $image->setImageResolution(1200, 1200); // Keine Auswirkung auf Dicke
  654. $image->setImageFormat('gif');
  655. $image->writeImage(TMP.'x.gif');
  656. $image->trim($mw,0);
  657. */
  658. $defaults = array('alt' => $text);
  659. $attr = array_merge($defaults, $attr);
  660. return $this->_textAsImage($text, $options, $attr);
  661. }
  662. /**
  663. * @return string htmlImage tag (or empty string on failure)
  664. */
  665. public function _textAsImage($text, $options = array(), $attr = array()) {
  666. $defaults = array('inline' => true, 'font' => FILES . 'linotype.ttf', 'size' => 18, 'color' => '#7A7166');
  667. $options = array_merge($defaults, $options);
  668. if ($options['inline']) { // Inline base 64 encoded
  669. $folder = CACHE . 'imagick';
  670. } else {
  671. $folder = WWW_ROOT . 'img' . DS . 'content' . DS . 'imagick';
  672. }
  673. $file = sha1($text . serialize($options)) . '.' . ($options['inline'] || !empty($options['background']) ? 'png' : 'gif');
  674. if (!file_exists($folder)) {
  675. mkdir($folder, 0755);
  676. }
  677. if (!file_exists($folder . DS . $file)) {
  678. $command = 'convert -background ' . (!empty($options['background']) ? '"' . $options['background'] . '"' : 'transparent') . ' -font ' . $options['font'] . ' -fill ' . (!empty($options['color']) ? '"' . $options['color'] . '"' : 'transparent') . ' -pointsize ' . $options['size'] . ' label:"' . $text . '" ' . $folder . DS . $file;
  679. exec($command, $a, $r);
  680. if ($r !== 0) {
  681. return '';
  682. }
  683. }
  684. if ($options['inline']) {
  685. $res = file_get_contents($folder . DS . $file);
  686. $out = $this->Html->imageFromBlob($res, $attr);
  687. } else {
  688. $out = $this->Html->image($this->Html->url('/img/content/imagick/', true) . $file, $attr);
  689. }
  690. return $out;
  691. }
  692. /**
  693. * Display a disabled link tag
  694. *
  695. * @param string $text
  696. * @param array $options
  697. * @return string
  698. */
  699. public function disabledLink($text, $options = array()) {
  700. $defaults = array('class' => 'disabledLink', 'title' => __('notAvailable'));
  701. $options = array_merge($defaults, $options);
  702. return $this->Html->tag('span', $text, $options);
  703. }
  704. /**
  705. * Generates a pagination count: #1 etc for each pagination record
  706. * respects order (ASC/DESC)
  707. *
  708. * @param array $paginator
  709. * @param int $count (current post count on this page)
  710. * @param string $dir (ASC/DESC)
  711. * @return int
  712. */
  713. public function absolutePaginateCount($paginator, $count, $dir = null) {
  714. if ($dir === null) {
  715. $dir = 'ASC';
  716. }
  717. $currentPage = $paginator['page'];
  718. $pageCount = $paginator['pageCount'];
  719. $totalCount = $paginator['count'];
  720. $limit = $paginator['limit'];
  721. $step = 1; //$paginator['step'];
  722. //pr($paginator);
  723. if ($dir === 'DESC') {
  724. $currentCount = $count + ($pageCount - $currentPage) * $limit * $step;
  725. if ($currentPage != $pageCount && $pageCount > 1) {
  726. $currentCount -= $pageCount * $limit * $step - $totalCount;
  727. }
  728. } else {
  729. $currentCount = $count + ($currentPage - 1) * $limit * $step;
  730. }
  731. return $currentCount;
  732. }
  733. /**
  734. * @param float progress
  735. * @param array options:
  736. * - min, max
  737. * - steps
  738. * - decimals (how precise should the result be displayed)
  739. * @return string HTML
  740. */
  741. public function progressBar($progress, $options = array(), $htmlOptions = array()) {
  742. $defaults = array(
  743. 'min' => 0,
  744. 'max' => 100,
  745. 'steps' => 15,
  746. 'decimals' => 1 // TODO: rename to places!!!
  747. );
  748. $options = array_merge($defaults, $options);
  749. $current = (((float)$progress / $options['max']) - $options['min']);
  750. $percent = $current * 100;
  751. $current *= $options['steps'];
  752. $options['progress'] = number_format($current, $options['decimals'], null, '');
  753. $params = Router::queryString($options, array(), true);
  754. $htmlDefaults = array('title' => $this->Numeric->format($percent, $options['decimals']) . ' ' . __('Percent'), 'class' => 'help');
  755. $htmlDefaults['alt'] = $htmlDefaults['title'];
  756. $htmlOptions = array_merge($htmlDefaults, $htmlOptions);
  757. //return $this->Html->image('/files/progress_bar/index.php'.$params, $htmlOptions);
  758. // bug in Html::webroot() ??? ommits ?...
  759. return '<img src="' . $this->Html->url('/files') . '/progress_bar/index.php' . $params . '" title="' . $htmlOptions['title'] . '" class="' .
  760. $htmlOptions['class'] . '" alt="' . $htmlOptions['title'] . '" />';
  761. }
  762. public function tip($type, $file, $title, $icon) {
  763. return $this->cIcon($icon, $title, null, null, array('class' => 'tip' . ucfirst($type) . ' hand', 'rel' => $file));
  764. }
  765. public function tipHelp($file) {
  766. return $this->tip('help', $file, 'Hilfe', ICON_HELP);
  767. }
  768. /**
  769. * Fixes utf8 problems of native php str_pad function
  770. * //TODO: move to textext helper?
  771. *
  772. * @param string $input
  773. * @param int $padLength
  774. * @param string $padString
  775. * @param mixed $padType
  776. * @return string input
  777. */
  778. public function pad($input, $padLength, $padString, $padType = STR_PAD_RIGHT) {
  779. $length = mb_strlen($input);
  780. if ($padLength - $length > 0) {
  781. switch ($padType) {
  782. case STR_PAD_LEFT:
  783. $input = str_repeat($padString, $padLength - $length) . $input;
  784. break;
  785. case STR_PAD_RIGHT:
  786. $input .= str_repeat($padString, $padLength - $length);
  787. break;
  788. }
  789. }
  790. return $input;
  791. }
  792. /**
  793. * Display traffic light for status etc
  794. */
  795. public function statusLight($color = null, $title = null, $alt = null, $options = array()) {
  796. $icons = array(
  797. 'green', 'yellow', 'red', 'blue'
  798. /*
  799. 'red' => array(
  800. 'title'=>'',
  801. 'alt'=>''
  802. ),
  803. */
  804. );
  805. $icon = (in_array($color, $icons) ? $color : 'blank');
  806. $defaultOptions = array('title' => (!empty($title) ? $title : ucfirst(__('color' . ucfirst($color)))), 'alt' => (!empty($alt) ? $alt :
  807. __('color' . ucfirst($color))), 'class' => 'icon help');
  808. $options = array_merge($defaultOptions, $options);
  809. return $this->Html->image('icons/status_light_' . $icon . '.gif', $options);
  810. }
  811. /**
  812. * FormatHelper::onlineIcon()
  813. *
  814. * @param mixed $modified
  815. * @param mixed $options
  816. * @return string
  817. */
  818. public function onlineIcon($modified = null, $options = array()) {
  819. // from low (off) to high (on)
  820. $icons = array('healthbar0.gif', 'healthbar1.gif', 'healthbar1b.gif', 'healthbar2.gif', 'healthbar3.gif', 'healthbar4.gif', 'healthbar5.gif');
  821. // default = offline
  822. $res = $icons[0]; // inactive
  823. $time = strtotime($modified);
  824. $timeAgo = time() - $time; // in seconds
  825. if ($timeAgo < 180) { // 3min // active
  826. $res = $icons[6];
  827. } elseif ($timeAgo < 360) { // 6min
  828. $res = $icons[5];
  829. } elseif ($timeAgo < 540) { // 9min
  830. $res = $icons[4];
  831. } elseif ($timeAgo < 720) { // 12min
  832. $res = $icons[3];
  833. } elseif ($timeAgo < 900) { // 15min
  834. $res = $icons[2];
  835. } elseif ($timeAgo < 1080) { // 18min
  836. $res = $icons[1];
  837. }
  838. return $this->Html->image('misc/' . $res, array('style' => 'width: 60px; height: 16px'));
  839. }
  840. /**
  841. * Returns red colored if not ok
  842. *
  843. * @param string $value
  844. * @param $okValue
  845. * @return string Value in HTML tags
  846. */
  847. public function warning($value, $ok = false) {
  848. if ($ok !== true) {
  849. return $this->ok($value, false);
  850. }
  851. return $value;
  852. }
  853. /**
  854. * Returns green on ok, red otherwise
  855. *
  856. * @param mixed $currentValue
  857. * @param bool $ok: true/false (defaults to false)
  858. * //@param string $comparizonType
  859. * //@param mixed $okValue
  860. * @return string newValue nicely formatted/colored
  861. */
  862. public function ok($value, $ok = false) {
  863. if ($ok === true) {
  864. $value = '<span class="green" style="color:green">' . $value . '</span>';
  865. } else {
  866. $value = '<span class="red" style="color:red">' . $value . '</span>';
  867. }
  868. return $value;
  869. }
  870. /**
  871. * test@test.de becomes t..t@t..t.de
  872. *
  873. * @param string $email: valid(!) email address
  874. * @return string
  875. */
  876. public static function hideEmail($mail) {
  877. $mailParts = explode('@', $mail, 2);
  878. $domainParts = explode('.', $mailParts[1], 2);
  879. $email = mb_substr($mailParts[0], 0, 1) . '..' . mb_substr($mailParts[0], -1, 1) . '@' . mb_substr($domainParts[0], 0, 1) . '..' . mb_substr($domainParts[0],
  880. -1, 1) . '.' . $domainParts[1];
  881. return $email;
  882. }
  883. /**
  884. * (Intelligent) Shortening of a text string
  885. *
  886. * @param STRING textstring
  887. * @param int chars = max-length
  888. * For options array:
  889. * @param bool strict (default: FALSE = intelligent shortening, cutting only between whole words)
  890. * @param STRING ending (default: '...' no leading whitespace)
  891. * @param bool remain_lf (default: false = \n to ' ')
  892. * Note: ONLY If intelligent:
  893. * - the word supposed to be cut is removed completely (instead of remaining as last one)
  894. * - Looses line breaks (for textarea content to work with this)!
  895. * @deprecated use truncate instead
  896. */
  897. public function shortenText($textstring, $chars, $options = array()) {
  898. $chars++; // add +1 for correct cut
  899. $needsEnding = false;
  900. #Options
  901. $strict = false;
  902. $ending = CHAR_HELLIP; //'...';
  903. $remainLf = false; // not implemented: choose if LF transformed to ' '
  904. $class = 'help';
  905. $escape = true;
  906. $title = '';
  907. if (!empty($options) && is_array($options)) {
  908. if (!empty($options['strict']) && ($options['strict'] === true || $options['strict'] === false)) {
  909. $strict = $options['strict'];
  910. }
  911. if (!empty($options['remain_lf']) && ($options['remain_lf'] === true || $options['remain_lf'] === false)) {
  912. $remainLf = $options['remain_lf'];
  913. }
  914. if (isset($options['title'])) {
  915. $title = $options['title'];
  916. if ($options['title'] === true) {
  917. $title = $textstring;
  918. }
  919. }
  920. if (isset($options['class']) && $options['class'] === false) {
  921. $class = '';
  922. }
  923. if (isset($options['ending'])) {
  924. $ending = (string)$options['ending'];
  925. }
  926. if (isset($options['escape'])) {
  927. $escape = (bool)$options['escape'];
  928. }
  929. }
  930. $textstring = trim($textstring);
  931. // cut only between whole words
  932. if ($strict !== true) {
  933. $completeWordText = $textstring . ' ';
  934. // transform line breaks to whitespaces (for textarea content etc.)
  935. $completeWordTextLf = str_replace(LF, ' ', $completeWordText);
  936. $completeWordText = $completeWordTextLf;
  937. $completeWordText = substr($completeWordTextLf, 0, $chars);
  938. // round the text to the previous entire word instead of cutting off part way through a word
  939. $completeWordText = substr($completeWordText, 0, strrpos($completeWordText, ' '));
  940. }
  941. $textEnding = '';
  942. if ($strict !== true && strlen($completeWordText) > 1) {
  943. $text = trim($completeWordText);
  944. // add ending only if result is shorter then original
  945. if (strlen($text) < strlen(trim($completeWordTextLf))) {
  946. $textEnding = ' ' . $ending; // additional whitespace as there is a new word added
  947. }
  948. } else {
  949. $text = trim(substr($textstring, 0, $chars));
  950. // add ending only if result is shorter then original
  951. if (strlen($text) < strlen($textstring)) {
  952. $textEnding = $ending;
  953. }
  954. }
  955. if ($escape) {
  956. $text = h($text);
  957. $title = h($title);
  958. }
  959. $text .= $textEnding;
  960. #TitleIfTooLong
  961. if (!empty($title)) {
  962. $text = '<span ' . (!empty($class) ? 'class="' . $class . '" ' : '') . 'title="' . $title . '">' . $text . '</span>';
  963. }
  964. return $text;
  965. }
  966. /**
  967. * Useful for displaying tabbed (code) content when the default of 8 spaces
  968. * inside <pre> is too much. This converts it to spaces for better output.
  969. *
  970. * Inspired by the tab2space function found at:
  971. * @see http://aidan.dotgeek.org/lib/?file=function.tab2space.php
  972. * @param string $text
  973. * @param int $spaces
  974. * @return string
  975. */
  976. public function tab2space($text, $spaces = 4) {
  977. $spaces = str_repeat(" ", $spaces);
  978. $text = preg_split("/\r\n|\r|\n/", trim($text));
  979. $wordLengths = array();
  980. $wArray = array();
  981. // Store word lengths
  982. foreach ($text as $line) {
  983. $words = preg_split("/(\t+)/", $line, -1, PREG_SPLIT_DELIM_CAPTURE);
  984. foreach (array_keys($words) as $i) {
  985. $strlen = strlen($words[$i]);
  986. $add = isset($wordLengths[$i]) && ($wordLengths[$i] < $strlen);
  987. if ($add || !isset($wordLengths[$i])) {
  988. $wordLengths[$i] = $strlen;
  989. }
  990. }
  991. $wArray[] = $words;
  992. }
  993. // Clear $text
  994. $text = '';
  995. // Apply padding when appropriate and rebuild the string
  996. foreach (array_keys($wArray) as $i) {
  997. foreach (array_keys($wArray[$i]) as $ii) {
  998. if (preg_match("/^\t+$/", $wArray[$i][$ii])) {
  999. $wArray[$i][$ii] = str_pad($wArray[$i][$ii], $wordLengths[$ii], "\t");
  1000. } else {
  1001. $wArray[$i][$ii] = str_pad($wArray[$i][$ii], $wordLengths[$ii]);
  1002. }
  1003. }
  1004. $text .= str_replace("\t", $spaces, implode("", $wArray[$i])) . "\n";
  1005. }
  1006. // Finished
  1007. return $text;
  1008. }
  1009. /**
  1010. * Word Censoring Function
  1011. *
  1012. * Supply a string and an array of disallowed words and any
  1013. * matched words will be converted to #### or to the replacement
  1014. * word you've submitted.
  1015. *
  1016. * @param string the text string
  1017. * @param string the array of censoered words
  1018. * @param string the optional replacement value
  1019. * @return string
  1020. */
  1021. public function wordCensor($str, $censored, $replacement = null) {
  1022. if (empty($censored)) {
  1023. return $str;
  1024. }
  1025. $str = ' ' . $str . ' ';
  1026. // \w, \b and a few others do not match on a unicode character
  1027. // set for performance reasons. As a result words like ..ber
  1028. // will not match on a word boundary. Instead, we'll assume that
  1029. // a bad word will be bookended by any of these characters.
  1030. $delim = '[-_\'\"`() {}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]';
  1031. foreach ($censored as $badword) {
  1032. if ($replacement !== null) {
  1033. $str = preg_replace("/({$delim})(" . str_replace('\*', '\w*?', preg_quote($badword, '/')) . ")({$delim})/i", "\\1{$replacement}\\3", $str);
  1034. } else {
  1035. $str = preg_replace("/({$delim})(" . str_replace('\*', '\w*?', preg_quote($badword, '/')) . ")({$delim})/ie", "'\\1'.str_repeat('#', strlen('\\2')).'\\3'",
  1036. $str);
  1037. }
  1038. }
  1039. return trim($str);
  1040. }
  1041. /**
  1042. * Translate a result array into a HTML table
  1043. *
  1044. * @author Aidan Lister <aidan@php.net>
  1045. * @version 1.3.2
  1046. * @link http://aidanlister.com/2004/04/converting-arrays-to-human-readable-tables/
  1047. * @param array $array The result (numericaly keyed, associative inner) array.
  1048. * @param bool $recursive Recursively generate tables for multi-dimensional arrays
  1049. * @param string $null String to output for blank cells
  1050. */
  1051. public function array2table($array, $options = array()) {
  1052. $defaults = array(
  1053. 'null' => '&nbsp;',
  1054. 'recursive' => false,
  1055. 'heading' => true,
  1056. 'escape' => true
  1057. );
  1058. $options = array_merge($defaults, $options);
  1059. // Sanity check
  1060. if (empty($array) || !is_array($array)) {
  1061. return false;
  1062. }
  1063. if (!isset($array[0]) || !is_array($array[0])) {
  1064. $array = array($array);
  1065. }
  1066. // Start the table
  1067. $table = "<table>\n";
  1068. if ($options['heading']) {
  1069. // The header
  1070. $table .= "\t<tr>";
  1071. // Take the keys from the first row as the headings
  1072. foreach (array_keys($array[0]) as $heading) {
  1073. $table .= '<th>' . ($options['escape'] ? h($heading) : $heading) . '</th>';
  1074. }
  1075. $table .= "</tr>\n";
  1076. }
  1077. // The body
  1078. foreach ($array as $row) {
  1079. $table .= "\t<tr>";
  1080. foreach ($row as $cell) {
  1081. $table .= '<td>';
  1082. // Cast objects
  1083. if (is_object($cell)) {
  1084. $cell = (array)$cell;
  1085. }
  1086. if ($options['recursive'] && is_array($cell) && !empty($cell)) {
  1087. // Recursive mode
  1088. $table .= "\n" . self::array2table($cell, $options) . "\n";
  1089. } else {
  1090. $table .= (!is_array($cell) && strlen($cell) > 0) ? ($options['escape'] ? h($cell) : $cell) : $options['null'];
  1091. }
  1092. $table .= '</td>';
  1093. }
  1094. $table .= "</tr>\n";
  1095. }
  1096. $table .= '</table>';
  1097. return $table;
  1098. }
  1099. public $icons = array(
  1100. 'up' => array(
  1101. 'pic' => ICON_UP,
  1102. 'title' => 'Up',
  1103. ),
  1104. 'down' => array(
  1105. 'pic' => ICON_DOWN,
  1106. 'title' => 'Down',
  1107. ),
  1108. 'edit' => array(
  1109. 'pic' => ICON_EDIT,
  1110. 'title' => 'Edit',
  1111. ),
  1112. 'view' => array(
  1113. 'pic' => ICON_VIEW,
  1114. 'title' => 'View',
  1115. ),
  1116. 'delete' => array(
  1117. 'pic' => ICON_DELETE,
  1118. 'title' => 'Delete',
  1119. ),
  1120. 'reset' => array(
  1121. 'pic' => ICON_RESET,
  1122. 'title' => 'Reset',
  1123. ),
  1124. 'help' => array(
  1125. 'pic' => ICON_HELP,
  1126. 'title' => 'Help',
  1127. ),
  1128. 'loader' => array(
  1129. 'pic' => 'loader.white.gif',
  1130. 'title' => 'Loading...',
  1131. ),
  1132. 'loader-alt' => array(
  1133. 'pic' => 'loader.black.gif',
  1134. 'title' => 'Loading...',
  1135. ),
  1136. 'details' => array(
  1137. 'pic' => ICON_DETAILS,
  1138. 'title' => 'Details',
  1139. ),
  1140. 'use' => array(
  1141. 'pic' => ICON_USE,
  1142. 'title' => 'Use',
  1143. ),
  1144. 'yes' => array(
  1145. 'pic' => ICON_YES,
  1146. 'title' => 'Yes',
  1147. ),
  1148. 'no' => array(
  1149. 'pic' => ICON_NO,
  1150. 'title' => 'No',
  1151. ),
  1152. // deprecated from here down
  1153. 'close' => array(
  1154. 'pic' => ICON_CLOCK,
  1155. 'title' => 'Close',
  1156. ),
  1157. 'reply' => array(
  1158. 'pic' => ICON_REPLY,
  1159. 'title' => 'Reply',
  1160. ),
  1161. 'time' => array(
  1162. 'pic' => ICON_CLOCK,
  1163. 'title' => 'Time',
  1164. ),
  1165. 'check' => array(
  1166. 'pic' => ICON_CHECK,
  1167. 'title' => 'Check',
  1168. ),
  1169. 'role' => array(
  1170. 'pic' => ICON_ROLE,
  1171. 'title' => 'Role',
  1172. ),
  1173. 'add' => array(
  1174. 'pic' => ICON_ADD,
  1175. 'title' => 'Add',
  1176. ),
  1177. 'remove' => array(
  1178. 'pic' => ICON_REMOVE,
  1179. 'title' => 'Remove',
  1180. ),
  1181. 'email' => array(
  1182. 'pic' => ICON_EMAIL,
  1183. 'title' => 'Email',
  1184. ),
  1185. 'options' => array(
  1186. 'pic' => ICON_SETTINGS,
  1187. 'title' => 'Options',
  1188. ),
  1189. 'lock' => array(
  1190. 'pic' => ICON_LOCK,
  1191. 'title' => 'Locked',
  1192. ),
  1193. 'warning' => array(
  1194. 'pic' => ICON_WARNING,
  1195. 'title' => 'Warning',
  1196. ),
  1197. 'genderUnknown' => array(
  1198. 'pic' => 'gender_icon.gif',
  1199. 'title' => 'genderUnknown',
  1200. ),
  1201. 'genderMale' => array(
  1202. 'pic' => 'gender_icon_m.gif',
  1203. 'title' => 'genderMale',
  1204. ),
  1205. 'genderFemale' => array(
  1206. 'pic' => 'gender_icon_f.gif',
  1207. 'title' => 'genderFemale',
  1208. ),
  1209. );
  1210. }
  1211. // Default icons
  1212. if (!defined('ICON_UP')) {
  1213. define('ICON_UP', 'up.gif');
  1214. }
  1215. if (!defined('ICON_DOWN')) {
  1216. define('ICON_DOWN', 'down.gif');
  1217. }
  1218. if (!defined('ICON_EDIT')) {
  1219. define('ICON_EDIT', 'edit.gif');
  1220. }
  1221. if (!defined('ICON_VIEW')) {
  1222. define('ICON_VIEW', 'see.gif');
  1223. }
  1224. if (!defined('ICON_DELETE')) {
  1225. define('ICON_DELETE', 'delete.gif');
  1226. }
  1227. if (!defined('ICON_DETAILS')) {
  1228. define('ICON_DETAILS', 'loupe.gif');
  1229. }
  1230. if (!defined('ICON_OPTIONS')) {
  1231. define('ICON_OPTIONS', 'options.gif');
  1232. }
  1233. if (!defined('ICON_SETTINGS')) {
  1234. define('ICON_SETTINGS', 'options.gif');
  1235. }
  1236. if (!defined('ICON_USE')) {
  1237. define('ICON_USE', 'use.gif');
  1238. }
  1239. if (!defined('ICON_CLOSE')) {
  1240. define('ICON_CLOSE', 'close.gif');
  1241. }
  1242. if (!defined('ICON_REPLY')) {
  1243. define('ICON_REPLY', 'reply.gif');
  1244. }
  1245. if (!defined('ICON_RESET')) {
  1246. define('ICON_RESET', 'reset.gif');
  1247. }
  1248. if (!defined('ICON_HELP')) {
  1249. define('ICON_HELP', 'help.gif');
  1250. }
  1251. if (!defined('ICON_YES')) {
  1252. define('ICON_YES', 'yes.gif');
  1253. }
  1254. if (!defined('ICON_NO')) {
  1255. define('ICON_NO', 'no.gif');
  1256. }
  1257. if (!defined('ICON_CLOCK')) {
  1258. define('ICON_CLOCK', 'clock.gif');
  1259. }
  1260. if (!defined('ICON_CHECK')) {
  1261. define('ICON_CHECK', 'check.gif');
  1262. }
  1263. if (!defined('ICON_ROLE')) {
  1264. define('ICON_ROLE', 'role.gif');
  1265. }
  1266. if (!defined('ICON_ADD')) {
  1267. define('ICON_ADD', 'add.gif');
  1268. }
  1269. if (!defined('ICON_REMOVE')) {
  1270. define('ICON_REMOVE', 'remove.gif');
  1271. }
  1272. if (!defined('ICON_EMAIL')) {
  1273. define('ICON_EMAIL', 'email.gif');
  1274. }
  1275. if (!defined('ICON_LOCK')) {
  1276. define('ICON_LOCK', 'lock.gif');
  1277. }
  1278. if (!defined('ICON_WARNING')) {
  1279. define('ICON_WARNING', 'warning.png');
  1280. }
  1281. if (!defined('ICON_MAP')) {
  1282. define('ICON_MAP', 'map.gif');
  1283. }