FormatHelper.php 38 KB

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