-
Notifications
You must be signed in to change notification settings - Fork 54
/
flexicontent_items.php
793 lines (692 loc) · 24.7 KB
/
flexicontent_items.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<?php
/**
* @version 1.5 stable $Id: flexicontent_items.php 1832 2014-01-17 00:17:27Z ggppdk $
* @package Joomla
* @subpackage FLEXIcontent
* @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
* @license GNU/GPL v2
*
* FLEXIcontent is a derivative work of the excellent QuickFAQ component
* @copyright (C) 2008 Christoph Lukes
* see www.schlu.net for more information
*
* FLEXIcontent is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.access.rules');
use Joomla\String\StringHelper;
class _flexicontent_items_common extends JTable
{
protected function __getAssetParentId(JTable $table = null, $id = null)
{
// Initialise variables.
$assetId = null;
$db = $this->getDbo();
// This is a article under a category.
if ($this->catid) {
// Build the query to get the asset id for the parent category.
$query = $db->getQuery(true);
$query->select('asset_id');
$query->from('#__categories');
$query->where('id = '.(int) $this->catid);
// Get the asset id from the database.
$this->_db->setQuery($query);
if ($result = $this->_db->loadResult()) {
$assetId = (int) $result;
}
}
// Return the asset id.
if ($assetId) {
return $assetId;
} else {
return parent::_getAssetParentId($table, $id);
}
}
}
/* This is no longer needed but it is a good example of
* how to fix STRICT warnings when a newer Joomla version adds TYPE to the parameter of a method
* thus makes possible for same code to run on both old and new Joomla version without warnings
*/
if (FLEXI_J30GE) {
class _flexicontent_items extends _flexicontent_items_common {
protected function _getAssetParentId(JTable $table = null, $id = null) {
return parent::__getAssetParentId($table, $id);
}
}
}
else {
class _flexicontent_items extends _flexicontent_items_common {
protected function _getAssetParentId($table = null, $id = null) {
return parent::__getAssetParentId($table, $id);
}
}
}
/**
* FLEXIcontent table class
*
* @package Joomla
* @subpackage FLEXIcontent
* @since 1.0
*/
class flexicontent_items extends _flexicontent_items {
/** @var int Primary key */
var $id = null;
/** @var string */
var $title = null;
/** @var string */
var $alias = null;
/** @var string */
var $title_alias = null; // deprecated do not use
/** @var string */
var $introtext = null;
/** @var string */
var $fulltext = null;
/** @var int */
var $state = null;
/** @var int The id of the category section*/
var $sectionid = null;
/** @var int DEPRECATED */
var $mask = null; // deprecated do not use
/** @var int */
var $catid = null;
/** @var datetime */
var $created = null;
/** @var int User id*/
var $created_by = null;
/** @var string An alias for the author*/
var $created_by_alias = null;
/** @var datetime */
var $modified = null;
/** @var int User id*/
var $modified_by = null;
/** @var boolean */
var $checked_out = 0;
/** @var time */
var $checked_out_time = 0;
/** @var datetime */
var $frontpage_up = null;
/** @var datetime */
var $frontpage_down = null;
/** @var datetime */
var $publish_up = null;
/** @var datetime */
var $publish_down = null;
/** @var string */
var $images = null;
/** @var string */
var $urls = null;
/** @var string */
var $attribs = null;
/** @var int */
var $version = null;
/** @var int */
var $parentid = null; // deprecated do not use
/** @var int */
var $ordering = null;
/** @var string */
var $metakey = null;
/** @var string */
var $metadesc = null;
/** @var string */
var $metadata = null;
/** @var int */
var $access = null;
/** @var int */
var $hits = null;
/** @var boolean */
var $featured = 0;
/** @var int Primary Foreign key */
var $item_id = null;
/** @var int */
var $type_id = null;
/** @var string */
var $language = null;
/** @var int */
var $lang_parent_id = null;
/** @var string */
/** @TODO : implement */
var $sub_items = null;
/** @var int */
/** @TODO : implement */
var $sub_categories = null;
/** @var string */
/** @TODO : implement */
var $related_items = null;
/** @var string */
var $search_index = null;
/**
* Name of the the items ext table
*
* @var string
* @access protected
*/
var $_tbl_join_ext = '#__flexicontent_items_ext';
/**
* Name of the foreign key in the link table
* $_tbl_key property maps to this property
*
* @var string
* @access protected
*/
var $_frn_key_ext = 'item_id';
/**
* Array of all properties from the join table added to this object
*
* @var array
* @access protected
*/
var $_join_prop_ext = array(
'item_id',
'type_id',
'language',
'lang_parent_id',
'sub_items',
'sub_categories',
'related_items',
'search_index'
);
/**
* Name of the the items ext table
*
* @var string
* @access protected
*/
var $_tbl_join_tmp = '#__flexicontent_items_tmp';
/**
* Name of the foreign key in the link table
* $_tbl_key property maps to this property
*
* @var string
* @access protected
*/
var $_frn_key_tmp = 'id';
/**
* Array of all properties from the join table added to this object
*
* @var array
* @access protected
*/
var $_join_prop_tmp = array();
/**
* @param database A database connector object
*/
function __construct(&$db) {
static $tbl_fields = null;
if (!isset($tbl_fields))
{
$tbls = array($this->_tbl_join_tmp);
foreach ($tbls as $tbl) $tbl_fields[$tbl] = $db->getTableColumns($tbl);
}
$this->_join_prop_tmp = array_keys($tbl_fields[$this->_tbl_join_tmp]);
parent::__construct('#__content', 'id', $db);
}
/**
* Method to compute the default name of the asset.
* The default name is in the form `table_name.id`
* where id is the value of the primary key of the table.
*
* @return string
* @since 1.6
*/
protected function _getAssetName() {
$k = $this->_tbl_key;
return 'com_content.article.'.(int) $this->$k;
}
/**
* Method to return the title to use for the asset table.
*
* @return string
*
* @since 11.1
*/
protected function _getAssetTitle()
{
return $this->title;
}
/**
* Method to get the parent asset id for the record
*
* @param JTable $table A JTable object for the asset parent
* @param integer $id
*
* @return integer
*
* @since 11.1
*/
// see (above) parent class method: _getAssetParentId($table = null, $id = null)
/**
* Overloaded load function
*
* @access public
* @return boolean
* @since 1.5
*/
function load( $oid=null, $reset = true )
{
$k = $this->_tbl_key;
if ($oid !== null) {
$this->$k = $oid;
}
$oid = $this->$k;
if ($oid === null) {
return false;
}
$this->reset();
$db = $this->getDBO();
$query = 'SELECT *'
. ' FROM '.$this->_tbl
. ' LEFT JOIN '.$this->_tbl_join_ext
. ' ON '.$this->_tbl_key.' = '.$this->_frn_key_ext
//. ' LEFT JOIN '.$this->_tbl_join_tmp // same name and same data columns
//. ' ON '.$this->_tbl_key.' = '.$this->_frn_key_tmp // ... so do not join
. ' WHERE '.$this->_tbl_key.' = '.$db->Quote($oid);
$db->setQuery( $query );
if ($result = $db->loadAssoc( )) {
//dump($result,'bind');
return $this->bind($result);
}
else
{
$this->setError( $db->getErrorMsg() );
return false;
}
}
/**
* Overloaded bind function
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error string
*
* @see JTable:bind
* @since 11.1
*/
public function bind($array, $ignore = '')
{
if (isset($array['images']) && is_array($array['images'])) {
$registry = new JRegistry;
$registry->loadArray($array['images']);
$array['images'] = (string)$registry;
}
if (isset($array['urls']) && is_array($array['urls'])) {
$registry = new JRegistry;
$registry->loadArray($array['urls']);
$array['urls'] = (string)$registry;
}
if (isset($array['attribs']) && is_array($array['attribs'])) {
$registry = new JRegistry;
$registry->loadArray($array['attribs']);
$array['attribs'] = (string)$registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry;
$registry->loadArray($array['metadata']);
$array['metadata'] = (string)$registry;
}
// Bind the rules.
if (isset($array['rules']) && is_array($array['rules'])) {
$rules = new JAccessRules($array['rules']);
$this->setRules($rules);
}
return parent::bind($array, $ignore);
}
/**
* Overloaded store function
*
* @access public
* @return boolean
* @since 1.5
*/
function store( $updateNulls=false )
{
$k = $this->_tbl_key;
$frn_key_ext = $this->_frn_key_ext;
$frn_key_tmp = $this->_frn_key_tmp;
// Split the object for the two tables #__content and #__flexicontent_items_ext
//$type = new stdClass();
$type = JTable::getInstance('content');
$type->_tbl = $this->_tbl;
$type->_tbl_key = $this->_tbl_key;
//$type_ext = new stdClass();
$type_ext = JTable::getInstance('flexicontent_items_ext', '');
$type_ext->_tbl = $this->_tbl_join_ext;
$type_ext->_tbl_key = $this->_frn_key_ext;
//$type_tmp = new stdClass();
$type_tmp = JTable::getInstance('flexicontent_items_tmp', '');
$type_tmp->_tbl = $this->_tbl_join_tmp;
$type_tmp->_tbl_key = $this->_frn_key_tmp;
foreach ($this->getProperties() as $p => $v) {
// If the property is in the join properties array we add it to the items_tmp object (coming either from tbl or tbl_ext or from other joined table)
if (in_array($p, $this->_join_prop_tmp)) {
$type_tmp->$p = $v;
}
// If the property is in the join properties array we add it to the items_ext object
if (in_array($p, $this->_join_prop_ext)) {
$type_ext->$p = $v;
// Catch case of new J1.6+ article language column
if (FLEXI_J16GE && $p == "language") {
//$jAp= JFactory::getApplication();
//$jAp->enqueueMessage('setting content language to' . $v,'message');
$type->$p = $v;
}
// Catch case of master item for (translation groups) not being set
if ($p == "lang_parent_id" /*&& $v==0*/) {
//$jAp= JFactory::getApplication();
//$jAp->enqueueMessage('Setting default lang_parent_id to '. $type->id,'message');
$type_ext->$p = 0;//$type->id;
$type_tmp->$p = 0;//$type->id;
}
}
// Else we add it to the core item properties
else {
$type->$p = $v;
}
}
if( $this->$k )
{
$ret = $this->_db->updateObject( $this->_tbl, $type, $this->_tbl_key, $updateNulls );
$type_ext->$frn_key_ext = $this->$k;
$type_tmp->$frn_key_tmp = $this->$k;
}
else
{
$ret = $this->_db->insertObject( $this->_tbl, $type, $this->_tbl_key );
// set the type_id
$this->id = $type->id;
$this->id = $this->id ? $this->id : $this->_db->insertid();
}
if( !$ret )
{
$this->setError(get_class( $this ).'::store failed - '.$this->_db->getErrorMsg());
return false;
}
else
{
// check for foreign key
if (isset($type_ext->$frn_key_ext) && !empty($type_ext->$frn_key_ext)) {
// update #__flexicontent_items_ext table
$ret = $this->_db->updateObject( $this->_tbl_join_ext, $type_ext, $this->_frn_key_ext, $updateNulls );
// update #__flexicontent_items_tmp table
$ret = $this->_db->updateObject( $this->_tbl_join_tmp, $type_tmp, $this->_frn_key_tmp, $updateNulls );
}
else {
/*if ($type_ext->lang_parent_id == 0) {
// case of new item we need to set lang_parent_id after initial content creation
$type_ext->lang_parent_id = $this->id;
}*/
$type_tmp->lang_parent_id = $type_ext->lang_parent_id;
// insert into #__flexicontent_items_ext table
$type_ext->$frn_key_ext = $this->id;
$ret = $this->_db->insertObject( $this->_tbl_join_ext, $type_ext, $this->_frn_key_ext );
// insert into #__flexicontent_items_ext table
$type_tmp->$frn_key_tmp = $this->id;
$ret = $this->_db->insertObject( $this->_tbl_join_tmp, $type_tmp, $this->_frn_key_tmp );
}
// Check for unique Alias
$sub_q = 'SELECT catid FROM #__flexicontent_cats_item_relations WHERE itemid='.(int)$this->id;
$query = 'SELECT COUNT(*) FROM #__content AS i '
.' JOIN #__flexicontent_items_ext AS e ON i.id = e.item_id '
.' LEFT JOIN #__flexicontent_cats_item_relations AS rel ON i.id = rel.itemid '
.' WHERE i.alias='.$this->_db->Quote($this->alias)
.' AND (i.catid='.(int)$this->id.' OR rel.catid IN ('.$sub_q.') )'
.' AND e.language = '.$this->_db->Quote($type_ext->language)
.' AND i.id <> '.(int)$this->id
//.' AND e.lang_parent_id <> '.(int)$type_ext->lang_parent_id
;
$this->_db->setQuery($query);
$duplicate_aliases = (boolean) $this->_db->loadResult();
if ($duplicate_aliases) {
$query = 'UPDATE #__content SET alias='.$this->_db->Quote($this->alias.'_'.$this->id).' WHERE id='.(int)$this->id;
$this->_db->setQuery($query);
$this->_db->execute();
}
}
// If the table is not set to track assets return true.
if (!$this->_trackAssets) {
return true;
}
if ($this->_locked) {
$this->_unlock();
}
//
// Asset Tracking
//
$parentId = $this->_getAssetParentId();
$name = $this->_getAssetName();
$title = $this->_getAssetTitle();
$asset = JTable::getInstance('Asset');
$asset->loadByName($name);
// Check for an error.
if ($error = $asset->getError()) {
$this->setError($error);
return false;
}
// Specify how a new or moved node asset is inserted into the tree.
if (empty($this->asset_id) || $asset->parent_id != $parentId) {
$asset->setLocation($parentId, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parentId;
$asset->name = $name;
$asset->title = $title;
//print_r ($this->_rules); exit();
if ($this->_rules instanceof JAccessRules) {
$asset->rules = (string) $this->_rules;
}
if (!$asset->check() || !$asset->store($updateNulls)) {
$this->setError($asset->getError());
return false;
}
if (empty($this->asset_id)) {
// Update the asset_id field in this table.
$this->asset_id = (int) $asset->id;
$query = $this->_db->getQuery(true);
$query->update( $this->_db->quoteName( $this->_tbl ) );
$query->set('asset_id = '.(int) $this->asset_id);
$query->where( $this->_db->quoteName( $k ) .' = '.(int) $this->$k);
$this->_db->setQuery($query);
if (!$this->_db->execute()) {
$e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED_UPDATE_ASSET_ID', $this->_db->getErrorMsg()));
$this->setError($e);
return false;
}
}
return true;
}
/**
* Overloaded check function
*
* @access public
* @return boolean
* @since 1.5
*/
function check()
{
/*
TODO: This filter is too rigorous,need to implement more configurable solution
// specific filters
$filter = JFilterInput::getInstance( null, null, 1, 1 );
$this->introtext = trim( $filter->clean( $this->introtext ) );
$this->fulltext = trim( $filter->clean( $this->fulltext ) );
*/
if(!strlen($this->title)) {
$this->setError(JText::_( 'FLEXI_ARTICLES_MUST_HAVE_A_TITLE' ));
return false;
}
if(empty($this->alias)) {
$this->alias = $this->title;
}
if ( !JFactory::getConfig()->get('unicodeslugs') )
{
$this->alias = $this->transliterate($this->alias);
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
if (trim( str_replace( ' ', '', $this->fulltext ) ) == '') {
$this->fulltext = '';
}
// clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if(!empty($this->metakey)) { // only process if not empty
$bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove
$after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters
$keys = explode(',', $after_clean); // create array using commas as delimiter
$clean_keys = array();
foreach($keys as $key) {
if(trim($key)) { // ignore blank keywords
$clean_keys[] = trim($key);
}
}
$this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", "
}
// clean up description -- eliminate quotes and <> brackets
if(!empty($this->metadesc)) { // only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc);
}
return true;
}
/**
* Converts record to XML
* @param boolean Map foreign keys to text values
function toXML( $mapKeysToText=false )
{
$db = JFactory::getDBO();
if ($mapKeysToText) {
$query = 'SELECT name'
. ' FROM #__sections'
. ' WHERE id = '. (int) $this->sectionid
;
$db->setQuery( $query );
$this->sectionid = $db->loadResult();
$query = 'SELECT name'
. ' FROM #__categories c'
. ' WHERE c.extension="'.FLEXI_CAT_EXTENSION.'" AND id = '. (int) $this->catid
;
$db->setQuery( $query );
$this->catid = $db->loadResult();
$query = 'SELECT name'
. ' FROM #__users'
. ' WHERE id = ' . (int) $this->created_by
;
$db->setQuery( $query );
$this->created_by = $db->loadResult();
}
return parent::toXML( $mapKeysToText );
}
*/
/**
* Original code form: Phoca International Alias Plugin for Joomla 1.5
*
* This method processes a string and replaces all accented UTF-8 characters by unaccented
* ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased.
*/
function transliterate($string)
{
$langFrom = array();
$langTo = array();
// BULGARIAN
if ($this->language == 'bg-BG') {
$bgLangFrom = array('А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Е', 'е', 'Ж', 'ж', 'З', 'з', 'И', 'и', 'Й', 'й', 'К', 'к', 'Л', 'л', 'М', 'м', 'Н', 'н', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т', 'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Ц', 'ц', 'Ч', 'ч', 'Ш', 'ш', 'Щ', 'щ', 'Ъ', 'ъ', 'Ьо', 'ьо', 'Ю', 'ю', 'Я', 'я');
$bgLangTo = array('A', 'a', 'B', 'b', 'V', 'v', 'G', 'g', 'D', 'd', 'E', 'e', 'Zh', 'zh', 'Z', 'z', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'F', 'f', 'H', 'h', 'C', 'c', 'Ch', 'ch', 'Sh', 'sh', 'Sht', 'sht', 'Y', 'y', 'Io', 'io', 'Ju', 'ju', 'Ja', 'ja');
$langFrom = array_merge ($langFrom, $bgLangFrom);
$langTo = array_merge ($langTo, $bgLangTo);
}
// CZECH
if ($this->language == 'cz-CZ') {
$czLangFrom = array('á','č','ď','é','ě','í','ň','ó','ř','š','ť','ú','ů','ý','ž','Á','Č','Ď','É','Ě','Í','Ň','Ó','Ř','Š','Ť','Ú','Ů','Ý','Ž');
$czLangTo = array('a','c','d','e','e','i','n','o','r','s','t','u','u','y','z','a','c','d','e','e','i','ň','o','r','s','t','u','u','y','z');
$langFrom = array_merge ($langFrom, $czLangFrom);
$langTo = array_merge ($langTo, $czLangTo);
}
// CROATIAN
if ($this->language == 'hr-HR' || $this->language == 'hr-BA') {
$hrLangFrom = array('č','ć','đ','š','ž','Č','Ć','Đ','Š','Ž');
$hrLangTo = array('c','c','d','s','z','c','c','d','s','z');
$langFrom = array_merge ($langFrom, $hrLangFrom);
$langTo = array_merge ($langTo, $hrLangTo);
}
// GREEK
if ($this->language == 'el-GR') {
$grLangFrom = array('α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'η', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω', 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', 'Ά', 'Έ', 'Ή', 'Ί', 'Ύ', 'Ό', 'Ώ', 'ά', 'έ', 'ή', 'ί', 'ύ', 'ό', 'ώ', 'ΰ', 'ΐ', 'ϋ', 'ϊ', 'ς', '«', '»' );
$grLangTo = array('a', 'b', 'g', 'd', 'e', 'z', 'h', 'th', 'i', 'i', 'k', 'l', 'm', 'n', 'ks', 'o', 'p', 'r', 's', 't', 'u', 'f', 'x', 'ps', 'o', 'A', 'B', 'G', 'D', 'E', 'Z', 'I', 'Th', 'I', 'K', 'L', 'M', 'N', 'Ks', 'O', 'P', 'R', 'S', 'T', 'Y', 'F', 'X', 'Ps', 'O', 'A', 'E', 'I', 'I', 'U', 'O', 'O', 'a', 'e', 'i', 'i', 'u', 'o', 'o', 'u', 'i', 'u', 'i', 's', '_', '_' );
$langFrom = array_merge ($langFrom, $grLangFrom);
$langTo = array_merge ($langTo, $grLangTo);
}
// HUNGARIAN
if ($this->language == 'hu-HU') {
$huLangFrom = array('á','é','ë','í','ó','ö','ő','ú','ü','ű','Á','É','Ë','Í','Ó','Ö','Ő','Ú','Ü','Ű');
$huLangTo = array('a','e','e','i','o','o','o','u','u','u','a','e','e','i','o','o','o','u','u','u');
$langFrom = array_merge ($langFrom, $huLangFrom);
$langTo = array_merge ($langTo, $huLangTo);
}
// POLISH
if ($this->language == 'pl-PL') {
$plLangFrom = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż');
$plLangTo = array('a','c','e','l','n','o','s','z','z','a','c','e','l','n','o','s','z','z');
$langFrom = array_merge ($langFrom, $plLangFrom);
$langTo = array_merge ($langTo, $plLangTo);
}
// RUSSIAN
if ($this->language == 'ru-RU') {
$ruLangFrom = array('А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г', 'Д', 'д', 'Е', 'е', 'Ё', 'ё', 'Ж', 'ж', 'З', 'з', 'И', 'и', 'Й', 'й', 'К', 'к', 'Л', 'л', 'М', 'м', 'Н', 'н', 'О', 'о', 'П', 'п', 'Р', 'р', 'С', 'с', 'Т', 'т', 'У', 'у', 'Ф', 'ф', 'Х', 'х', 'Ц', 'ц', 'Ч', 'ч', 'Ш', 'ш', 'Щ', 'щ', 'Ъ', 'ъ', 'Ы', 'ы', 'Ь', 'ь', 'Э', 'э', 'Ю', 'ю', 'Я', 'я');
$ruLangTo = array('A', 'a', 'B', 'b', 'V', 'v', 'G', 'g', 'D', 'd', 'E', 'e', 'Jo', 'jo', 'Zh', 'zh', 'Z', 'z', 'I', 'i', 'J', 'j', 'K', 'k', 'L', 'l', 'M', 'm', 'N', 'n', 'O', 'o', 'P', 'p', 'R', 'r', 'S', 's', 'T', 't', 'U', 'u', 'F', 'f', 'H', 'h', 'C', 'c', 'Ch', 'ch', 'Sh', 'sh', 'Shh', 'shh', '', '', 'Y', 'y', '', '', 'Je', 'je', 'Ju', 'ju', 'Ja', 'ja');
$langFrom = array_merge ($langFrom, $ruLangFrom);
$langTo = array_merge ($langTo, $ruLangTo);
}
// SLOVAK
if ($this->language == 'sk-SK') {
$skLangFrom = array('á','ä','č','ď','é','í','ľ','ĺ','ň','ó','ô','ŕ','š','ť','ú','ý','ž','Á','Ä','Č','Ď','É','Í','Ľ','Ĺ','Ň','Ó','Ô','Ŕ','Š','Ť','Ú','Ý','Ž');
$skLangTo = array('a','a','c','d','e','i','l','l','n','o','o','r','s','t','u','y','z','a','a','c','d','e','i','l','l','n','o','o','r','s','t','u','y','z');
$langFrom = array_merge ($langFrom, $skLangFrom);
$langTo = array_merge ($langTo, $skLangTo);
}
// SLOVENIAN
if ($this->language == 'sl-SI') {
$slLangFrom = array('č','š','ž','Č','Š','Ž');
$slLangTo = array('c','s','z','c','s','z');
$langFrom = array_merge ($langFrom, $slLangFrom);
$langTo = array_merge ($langTo, $slLangTo);
}
// LITHUANIAN
if ($this->language == 'lt-LT') {
$ltLangFrom = array('ą','č','ę','ė','į','š','ų','ū','ž','Ą','Č','Ę','Ė','Į','Š','Ų','Ū','Ž');
$ltLangTo = array('a','c','e','e','i','s','u','u','z','A','C','E','E','I','S','U','U','Z');
$langFrom = array_merge ($langFrom, $ltLangFrom);
$langTo = array_merge ($langTo, $ltLangTo);
}
// ICELANDIC
if ($this->language == 'is-IS') {
$isLangFrom = array('þ', 'æ', 'ð', 'ö', 'í', 'ó', 'é', 'á', 'ý', 'ú', 'Þ', 'Æ', 'Ð', 'Ö', 'Í', 'Ó', 'É', 'Á', 'Ý', 'Ú');
$isLangTo = array('th','ae','d', 'o', 'i', 'o', 'e', 'a', 'y', 'u', 'Th','Ae','D', 'O', 'I', 'O', 'E', 'A', 'Y', 'U');
$langFrom = array_merge ($langFrom, $isLangFrom);
$langTo = array_merge ($langTo, $isLangTo);
}
// TURKISH
if ($this->language == 'tr-TR') {
$tuLangFrom = array('ş','ı','ö','ü','ğ','ç','Ş','İ','Ö','Ü','Ğ','Ç');
$tuLangTo = array('s','i','o','u','g','c','S','I','O','U','G','C');
$langFrom = array_merge ($langFrom, $tuLangFrom);
$langTo = array_merge ($langTo, $tuLangTo);
}
// GERMAN - because of german names used in Czech, Hungarian, Polish or Slovak (because of possible
// match - e.g. German a => ae, but Slovak a => a ... we can use only one, so we use:
// a not ae, u not ue, o not oe, ? will be ss
$deLangFrom = array('ä','ö','ü','ß','Ä','Ö','Ü');
$deLangTo = array('a','o','u','ss','a','o','u');
//$deLangTo = array('ae','oe','ue','ss','ae','oe','ue');
$langFrom = array_merge ($langFrom, $deLangFrom);
$langTo = array_merge ($langTo, $deLangTo);
$string = StringHelper::str_ireplace($langFrom, $langTo, $string);
$string = StringHelper::strtolower($string);
return $string;
}
}