eurotext_translationMANAGER - Version 1.1.2.2

Version Notes

Version 1.1.2.2
====================================================================================
- Eigene Kategorieattribute übersetzen: Exportieren Sie Ihre benutzerdefinierten Attribute (siehe Dokumentation)

Version 1.1.2.1
====================================================================================
- Duplicate URL-Key Fehler behoben

Version 1.1.2.0
====================================================================================
- Überarbeiteter DEBUG Modus. Kann nun im Backend (System -> Configuration -> Developer -> Log) aktiviert werden
- Log-Datei wird in /var/log/eurotext.log erstellt, schwere Fehler werden auch
bei ausgeschaltetem DEBUG Modus in eurotext_fatal.log gespeichert
- Basisverzeichnis jetzt in /var/eurotext und nicht mehr /eurotext
- FTP-Prüfung jetzt mit DEBUG Ausgabe
- Diverse Verbesserungen in der Verwendung von Magento-Verzeichnissen

Version 1.1.1.0
====================================================================================
- Es werden nur noch die ausgewählten Sprachdateien exportiert
- Fehlerbehebungen

Version 1.1.0.0
====================================================================================
- Eigene Artikelattribute übersetzen: Exportieren Sie Ihre benutzerdefinierten Attribute (siehe Dokumentation)
- Absicherung: Bei Übertragungsfehlern zum Eurotext Server wird das Paket nach /var/export gesichert.
- Fehlerkorrekturen und Sicherheitsupdates
- Verbesserte und stabilere Programmbasis

Version 1.0.0.9
====================================================================================
- Der Lagerstatus wird bei der Produktauswahl nun auch für 'virtuelle' Artikel/Hauptartikel wie im Backend eingestellt angezeigt

Version 1.0.0.8
====================================================================================
- Bei der Produktauswahl kann nun auch nach Artikeltyp gefiltert werden

Version 1.0.0.7
====================================================================================
- Javascript-Fehler beseitigt
- Update-Skript arbeitet nun toleranter

Version 1.0.0.6
====================================================================================
- Bei der Auswahl der Produkte sind nun zwei zusätzliche Filter (nach Status und nach Lagerbestand) verfügbar
- Es können nun auch statische Blöcke exportiert und wieder importiert werden. Die statischen Blöcke werden mit bei der Auswahl der CMS-Seiten angezeigt

Version 1.0.0.5
====================================================================================
- Es werden im Kommentar-Feld der control.xml mehr Projektinformationen angegeben
- Ein Projekt kann nun jeweils um einen Schritt zurückgesetzt werden
- Es wird nun die korrekte Modulversion in der control.xml angegeben

Version 1.0.0.4
====================================================================================
- Das Modul exportiert Attribute nun auch, wenn für das Quell-Storeview keine Bezeichnung
vorhanden ist. Es wird dann der Admin-Standardtext exportiert.

Version 1.0.0.3
====================================================================================
- URL-Key wird im Ziel-Storeview nun nur noch (anhand der Produkt-/Kategorie-Bezeichnung)
gesetzt, wenn zuvor noch kein Wert gesetzt war (also "Use default values" /
"Standardwerte übernehmen" aktiv war)
Zuvor wurde der URL-Key gesetzt, wenn der Wert leer bzw. gleich dem Standardwert gesetzt war
- Einstellung "Use default values" / "Standardwerte übernehmen" sollte bei Feldern, die in den
Übersetzungsdateien nicht vorhanden sind, nun nicht mehr verloren gehen.

Version 1.0.0.2
====================================================================================
- Wurden zwischen Export und Import Produktbilder im Magento-Backend gelöscht für die Übersetzungen erzeugt wurden, konnte der Import fehlschlagen.
Beim Import fehlende Produktbilder werden nun übersprungen.

Version 1.0.0.1
====================================================================================
- Erweiterung der Produktauswahl um die Möglichkeit auch nach Kategorien zu filtern
und so ggf. schnell ganze Kategorien übersetzen zu können
- Wurden URL-Felder nicht mit exportiert, wurden diese beim Import auf die Standardwerte gesetzt statt diese anhand der (übersetzten) Bezeichnung zu generieren

Download this release

Release Info

Developer Eurotext AG
Extension eurotext_translationMANAGER
Version 1.1.2.2
Comparing to
See all releases


Version 1.1.2.2

Files changed (63) hide show
  1. app/code/community/Eurotext/TranslationManager/.DS_Store +0 -0
  2. app/code/community/Eurotext/TranslationManager/Block/Help.php +6 -0
  3. app/code/community/Eurotext/TranslationManager/Block/Projects.php +158 -0
  4. app/code/community/Eurotext/TranslationManager/Block/Register.php +39 -0
  5. app/code/community/Eurotext/TranslationManager/Block/Response/Ajax.php +9 -0
  6. app/code/community/Eurotext/TranslationManager/Block/Selectcategories.php +139 -0
  7. app/code/community/Eurotext/TranslationManager/Block/Selectcmspages.php +116 -0
  8. app/code/community/Eurotext/TranslationManager/Block/Selectemails.php +81 -0
  9. app/code/community/Eurotext/TranslationManager/Block/Selectlangfiles.php +65 -0
  10. app/code/community/Eurotext/TranslationManager/Block/Selectproducts.php +329 -0
  11. app/code/community/Eurotext/TranslationManager/Block/Settings.php +34 -0
  12. app/code/community/Eurotext/TranslationManager/Helper/Data.php +566 -0
  13. app/code/community/Eurotext/TranslationManager/Helper/Eurotext.php +247 -0
  14. app/code/community/Eurotext/TranslationManager/Model/.DS_Store +0 -0
  15. app/code/community/Eurotext/TranslationManager/Model/Resource/Setup.php +6 -0
  16. app/code/community/Eurotext/TranslationManager/controllers/.DS_Store +0 -0
  17. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/.DS_Store +0 -0
  18. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/.DS_Store +0 -0
  19. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/HelpController.php +17 -0
  20. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/ProjectsController.php +3240 -0
  21. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/RegisterController.php +230 -0
  22. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/SelectcategoriesController.php +134 -0
  23. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/SelectcmspagesController.php +123 -0
  24. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/SelectemailsController.php +88 -0
  25. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/SelectlangfilesController.php +89 -0
  26. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/SelectproductsController.php +224 -0
  27. app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/SettingsController.php +72 -0
  28. app/code/community/Eurotext/TranslationManager/etc/adminhtml.xml +60 -0
  29. app/code/community/Eurotext/TranslationManager/etc/config.xml +79 -0
  30. app/code/community/Eurotext/TranslationManager/etc/jstranslator.xml +36 -0
  31. app/code/community/Eurotext/TranslationManager/etc/system.xml +32 -0
  32. app/code/community/Eurotext/TranslationManager/sql/eurotext_translationmanager_setup/mysql4-install-1.0.0.0.php +246 -0
  33. app/code/community/Eurotext/TranslationManager/sql/eurotext_translationmanager_setup/mysql4-upgrade-1.0.0.5-1.0.0.6.php +32 -0
  34. app/code/community/Eurotext/TranslationManager/sql/eurotext_translationmanager_setup/mysql4-upgrade-1.0.0.7-1.0.0.8.php +14 -0
  35. app/design/adminhtml/base/default/layout/eurotext/translationmanager.xml +128 -0
  36. app/design/adminhtml/base/default/template/eurotext/translationmanager/help.phtml +88 -0
  37. app/design/adminhtml/base/default/template/eurotext/translationmanager/projects.phtml +392 -0
  38. app/design/adminhtml/base/default/template/eurotext/translationmanager/register.phtml +344 -0
  39. app/design/adminhtml/base/default/template/eurotext/translationmanager/selectcategories.phtml +130 -0
  40. app/design/adminhtml/base/default/template/eurotext/translationmanager/selectcmspages.phtml +169 -0
  41. app/design/adminhtml/base/default/template/eurotext/translationmanager/selectemails.phtml +113 -0
  42. app/design/adminhtml/base/default/template/eurotext/translationmanager/selectlangfiles.phtml +129 -0
  43. app/design/adminhtml/base/default/template/eurotext/translationmanager/selectproducts.phtml +351 -0
  44. app/design/adminhtml/base/default/template/eurotext/translationmanager/settings.phtml +202 -0
  45. app/etc/modules/Eurotext_TranslationManager.xml +11 -0
  46. app/locale/de_DE/Eurotext_TranslationManager.csv +223 -0
  47. app/locale/en_US/Eurotext_TranslationManager.csv +227 -0
  48. package.xml +98 -0
  49. skin/adminhtml/base/default/eurotext/translationmanager/css/styles.css +206 -0
  50. skin/adminhtml/base/default/eurotext/translationmanager/images/btt_suche.png +0 -0
  51. skin/adminhtml/base/default/eurotext/translationmanager/images/cat-minus.png +0 -0
  52. skin/adminhtml/base/default/eurotext/translationmanager/images/cat-none.png +0 -0
  53. skin/adminhtml/base/default/eurotext/translationmanager/images/cat-plus.png +0 -0
  54. skin/adminhtml/base/default/eurotext/translationmanager/images/eurotext_logo.png +0 -0
  55. skin/adminhtml/base/default/eurotext/translationmanager/images/eurotext_table_head.png +0 -0
  56. skin/adminhtml/base/default/eurotext/translationmanager/images/logo_dixeno.png +0 -0
  57. skin/adminhtml/base/default/eurotext/translationmanager/images/logo_eurotext.png +0 -0
  58. skin/adminhtml/base/default/eurotext/translationmanager/images/pager_arrow_left.gif +0 -0
  59. skin/adminhtml/base/default/eurotext/translationmanager/images/pager_arrow_left_off.gif +0 -0
  60. skin/adminhtml/base/default/eurotext/translationmanager/images/pager_arrow_right.gif +0 -0
  61. skin/adminhtml/base/default/eurotext/translationmanager/images/pager_arrow_right_off.gif +0 -0
  62. skin/adminhtml/base/default/eurotext/translationmanager/js/eurotext-jquery-1.9.1.js +9597 -0
  63. skin/adminhtml/base/default/eurotext/translationmanager/js/eurotext.js +898 -0
app/code/community/Eurotext/TranslationManager/.DS_Store ADDED
Binary file
app/code/community/Eurotext/TranslationManager/Block/Help.php ADDED
@@ -0,0 +1,6 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Help extends Mage_Adminhtml_Block_Template
4
+ {
5
+
6
+ }
app/code/community/Eurotext/TranslationManager/Block/Projects.php ADDED
@@ -0,0 +1,158 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Projects extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function getSelectUrl($selectType, $project_id)
6
+ {
7
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_'.$selectType.'/index/',array('id' => $project_id));
8
+ }
9
+
10
+ public function getNewProjectUrl()
11
+ {
12
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/addproject');
13
+ }
14
+
15
+ public function getSaveProjectUrl()
16
+ {
17
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/saveproject');
18
+ }
19
+
20
+ public function getProjectUrl($project_id)
21
+ {
22
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/index/id/'.intval($project_id));
23
+ }
24
+
25
+ public function getProjectDeleteUrl($project_id)
26
+ {
27
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/delete/id/'.$project_id);
28
+ }
29
+
30
+ public function getProjectResetUrl($project_id)
31
+ {
32
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/reset/id/'.$project_id);
33
+ }
34
+
35
+ public function getAjaxImportStepUrl()
36
+ {
37
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/importstep');
38
+ }
39
+
40
+ public function getUploadUrl()
41
+ {
42
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/upload');
43
+ }
44
+
45
+ public function getPostBackUrl2()
46
+ {
47
+ // Postback-URL für Projekt-Einstellungen
48
+ return ""; //return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_export/save');
49
+ }
50
+
51
+ public function getAjaxExportUrl()
52
+ {
53
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_projects/ajaxexport');
54
+ }
55
+
56
+ public function getProjects()
57
+ {
58
+ $tableName = Mage::getSingleton('core/resource')->getTableName('eurotext_translationmanager/project');
59
+
60
+ $dbres = Mage::getSingleton('core/resource');
61
+ $dbr=$dbres->getConnection('core_read');
62
+
63
+ $projects=$dbr->fetchAll("SELECT * FROM `".$tableName."` WHERE deleted=false ORDER BY id ASC");
64
+
65
+ return $projects;
66
+ }
67
+
68
+ public function getSelectedProjectId()
69
+ {
70
+ return intval(Mage::app()->getRequest()->getParam('id',-1));
71
+ }
72
+
73
+ public function getSelectedProject()
74
+ {
75
+ $id=$this->getSelectedProjectId();
76
+
77
+ $tableName = Mage::getSingleton('core/resource')->getTableName('eurotext_translationmanager/project');
78
+
79
+ $dbres = Mage::getSingleton('core/resource');
80
+ $dbr=$dbres->getConnection('core_read');
81
+
82
+ $projects=$dbr->fetchAll("SELECT * FROM `".$tableName."` WHERE id=".$id);
83
+
84
+ return $projects[0];
85
+ }
86
+
87
+ public function GetCheckedStr($val)
88
+ {
89
+ if (($val=="1") || ($val==true))
90
+ {
91
+ return "checked='checked'";
92
+ }
93
+
94
+ return "";
95
+ }
96
+
97
+ public function getStatusText($status_id)
98
+ {
99
+ if ($status_id==0)
100
+ {
101
+ return $this->__("New");
102
+ }
103
+ else if ($status_id==1)
104
+ {
105
+ return $this->__("In progress");
106
+ }
107
+ else if ($status_id==2)
108
+ {
109
+ return $this->__("In progress");
110
+ }
111
+ else if ($status_id==3)
112
+ {
113
+ return $this->__("Loaded");
114
+ }
115
+ }
116
+
117
+ public function getStoreviewTitle($store_id)
118
+ {
119
+ if ($store_id<0)
120
+ {
121
+ return $this->__("Not yet selected");
122
+ }
123
+
124
+ try
125
+ {
126
+ $store=Mage::app()->getStore($store_id);
127
+ $locale_code=Mage::getStoreConfig('general/locale/code', $store->getId());
128
+ return $store->getName()." (".$locale_code.")";
129
+ }
130
+ catch(Exception $e)
131
+ {
132
+ return $this->__("A storeview does not exist (anymore)")." (ID: '".$store_id."')";
133
+ }
134
+ }
135
+
136
+ public function getSpracheSelect($selectName, $selectedId,$disabledStr)
137
+ {
138
+ $html="<select ".$disabledStr." id='".$selectName."' autocomplete='off'>";
139
+ $html.="<option value='-1'>".$this->__("-- Select storeview --")."</option>";
140
+
141
+ $stores=Mage::app()->getStores();
142
+ foreach($stores as $store)
143
+ {
144
+ $locale_code=Mage::getStoreConfig('general/locale/code', $store->getId());
145
+
146
+ $selAttr="";
147
+ if ($store->getId()==$selectedId)
148
+ {
149
+ $selAttr="selected='selected'";
150
+ }
151
+
152
+ $html.="<option value='".$store->getId()."' ".$selAttr.">".$store->getName()." (".$locale_code.")</option>";
153
+ }
154
+ $html.="</select>";
155
+
156
+ return $html;
157
+ }
158
+ }
app/code/community/Eurotext/TranslationManager/Block/Register.php ADDED
@@ -0,0 +1,39 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Register extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function getModuleVersion()
6
+ {
7
+ return (string) Mage::getConfig()->getNode()->modules->Eurotext_TranslationManager->version;
8
+ }
9
+
10
+ public function getPostBackUrl()
11
+ {
12
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_register/save');
13
+ }
14
+
15
+ // returns "saved", if the email was sent
16
+ public function getMessage()
17
+ {
18
+ if ($this->isSaved())
19
+ {
20
+ return $this->__("Last save").": ".$this->getSetting("register_mailsent_date","?");
21
+ }
22
+ else
23
+ {
24
+ return $this->__("Not yet saved");
25
+ }
26
+ }
27
+
28
+ // returns true, if the registration data was sent previously
29
+ public function isSaved()
30
+ {
31
+ return ($this->getSetting("register_mailsent","0")=="1");
32
+ }
33
+
34
+ public function getSetting($key)
35
+ {
36
+ $helper=Mage::helper('eurotext_translationmanager');
37
+ return $helper->getSetting($key,"");
38
+ }
39
+ }
app/code/community/Eurotext/TranslationManager/Block/Response/Ajax.php ADDED
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Response_Ajax extends Mage_Adminhtml_Block_Abstract {
4
+
5
+ public function returnJson(){
6
+ return $this->toJson($this->getResponseArray());
7
+ }
8
+
9
+ }
app/code/community/Eurotext/TranslationManager/Block/Selectcategories.php ADDED
@@ -0,0 +1,139 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Selectcategories extends Mage_Adminhtml_Block_Template
4
+ {
5
+ private function getTableName($tblName)
6
+ {
7
+ return Mage::getSingleton('core/resource')->getTableName($tblName);
8
+ }
9
+
10
+ private function getProjectId()
11
+ {
12
+ return intval($this->getRequest()->getParam("id"));
13
+ }
14
+
15
+ public function getSelectCategoriesUrl()
16
+ {
17
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectcategories/index',array('id' => $this->getProjectId()));
18
+ }
19
+
20
+ public function getSelectCategoriesSaveUrl()
21
+ {
22
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectcategories/save',array('id' => $this->getProjectId()));
23
+ }
24
+
25
+ public function getProject()
26
+ {
27
+ $id=$this->getProjectId();
28
+
29
+ $tableName = Mage::getSingleton('core/resource')->getTableName('eurotext_translationmanager/project');
30
+
31
+ $dbres = Mage::getSingleton('core/resource');
32
+ $dbr=$dbres->getConnection('core_read');
33
+
34
+ $projects=$dbr->fetchAll("SELECT * FROM `".$tableName."` WHERE id=".$id);
35
+
36
+ return $projects[0];
37
+ }
38
+
39
+ public function getRootCategory()
40
+ {
41
+ $project=$this->getProject();
42
+ $store=Mage::app()->getStore($project['storeview_src']);
43
+ $rootCategoryId=$store->getRootCategoryId();
44
+
45
+ $rootCategory=Mage::getModel("catalog/category")->load($rootCategoryId);
46
+ return $rootCategory;
47
+ }
48
+
49
+ public function getOpenedPathIds()
50
+ {
51
+ return array();
52
+ }
53
+
54
+ public function getSelectedCategoryIds()
55
+ {
56
+ $dbres = Mage::getSingleton('core/resource');
57
+ $dbr=$dbres->getConnection('core_read');
58
+
59
+ $rv=array();
60
+
61
+ $selectedCategories=$dbr->fetchAll("SELECT category_id FROM `".$this->getTableName('eurotext_project_categories')."` WHERE project_id=?",array($this->getProjectId()));
62
+ foreach($selectedCategories as $selectedCategory)
63
+ {
64
+ array_push($rv,$selectedCategory['category_id']);
65
+ }
66
+
67
+ return $rv;
68
+ }
69
+
70
+ public function getSearchResult()
71
+ {
72
+ $pagesize=20;
73
+
74
+ $rv=array();
75
+ $rv['find']=trim($this->getRequest()->getParam("find"));
76
+ $page_current=intval($this->getRequest()->getParam("page"));
77
+
78
+ $dbres = Mage::getSingleton('core/resource');
79
+ $dbr=$dbres->getConnection('core_read');
80
+
81
+ $eavAttribute = Mage::getModel('eav/entity_attribute');
82
+ $name_id = $eavAttribute->getIdByCode('catalog_category', 'name');
83
+
84
+ $findme="%".$rv['find']."%";
85
+
86
+ $sql="SELECT a.store_id, a.value as article_name, e.sku, e.entity_id FROM `".$this->getTableName('catalog_product_entity_varchar')."` a, `".$this->getTableName('catalog_product_entity')."` e WHERE (a.entity_id=e.entity_id) AND a.store_id=0 AND (a.attribute_id=?) AND ((UPPER(e.sku) LIKE ?) OR (UPPER(a.value) LIKE ?)) ORDER BY article_name ASC, e.entity_id ASC";
87
+ $allProducts=$dbr->fetchAll($sql,array($name_id,$findme,$findme));
88
+
89
+ $pageCount=intval(count($allProducts)/$pagesize);
90
+ if (($pageCount*$pagesize)<count($allProducts))
91
+ {
92
+ $pageCount++;
93
+ }
94
+ $rv['page_last']=$pageCount;
95
+
96
+ if ($page_current>$pageCount)
97
+ {
98
+ $page_current=$pageCount;
99
+ }
100
+ if ($page_current<1)
101
+ {
102
+ $page_current=1;
103
+ }
104
+
105
+ if ($pageCount<1)
106
+ {
107
+ $pageCount=1;
108
+ }
109
+
110
+ // Result-Array:
111
+ $resultProducts=array();
112
+ $ofs_start=($page_current-1)*$pageCount;
113
+ $ofs_end=$ofs_start+$pagesize;
114
+ if ($ofs_end>=count($allProducts))
115
+ {
116
+ $ofs_end=count($allProducts)-1;
117
+ }
118
+
119
+ for ($i=$ofs_start; $i<=$ofs_end; $i++)
120
+ {
121
+ $prod=$allProducts[$i];
122
+ $prod['checked']=false;
123
+
124
+ // Already selected?
125
+ $sql="SELECT product_id FROM `".$this->getTableName('eurotext_project_products')."` p WHERE (p.project_id=?) AND (p.product_id=?)";
126
+ $selProducts=$dbr->fetchAll($sql,array($this->getProjectId(),$prod['entity_id']));
127
+ $prod['checked']=(count($selProducts)>0);
128
+
129
+ array_push($resultProducts,$prod);
130
+ }
131
+
132
+ $rv['page_current']=$page_current;
133
+ $rv['page_last']=$pageCount;
134
+ $rv['result_count']=count($allProducts);
135
+ $rv['products']=$resultProducts;
136
+
137
+ return $rv;
138
+ }
139
+ }
app/code/community/Eurotext/TranslationManager/Block/Selectcmspages.php ADDED
@@ -0,0 +1,116 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Selectcmspages extends Mage_Adminhtml_Block_Template
4
+ {
5
+ private function getTableName($tblName)
6
+ {
7
+ return Mage::getSingleton('core/resource')->getTableName($tblName);
8
+ }
9
+
10
+ private function getProjectId()
11
+ {
12
+ return intval($this->getRequest()->getParam("id"));
13
+ }
14
+
15
+ public function getSelectCmsPagesUrl()
16
+ {
17
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectcmspages/index',array('id' => $this->getProjectId()));
18
+ }
19
+
20
+ public function getSelectCmsPagesSaveUrl()
21
+ {
22
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectcmspages/save',array('id' => $this->getProjectId()));
23
+ }
24
+
25
+ public function getProject()
26
+ {
27
+ $id=$this->getProjectId();
28
+
29
+ $tableName = Mage::getSingleton('core/resource')->getTableName('eurotext_translationmanager/project');
30
+
31
+ $dbres = Mage::getSingleton('core/resource');
32
+ $dbr=$dbres->getConnection('core_read');
33
+
34
+ $projects=$dbr->fetchAll("SELECT * FROM `".$tableName."` WHERE id=".$id);
35
+
36
+ return $projects[0];
37
+ }
38
+
39
+ public function getCMSPages()
40
+ {
41
+ $dbres = Mage::getSingleton('core/resource');
42
+ $dbr=$dbres->getConnection('core_read');
43
+
44
+ $project=$this->getProject();
45
+ $storeview_src=$project['storeview_src'];
46
+
47
+ $rv=array();
48
+ $selectedCMSPages=array();
49
+
50
+ $selectedPageIds=$dbr->fetchAll("SELECT page_id FROM `".$this->getTableName('eurotext_project_cmspages')."` WHERE project_id=?",array($this->getProjectId()));
51
+ foreach($selectedPageIds as $selectedPageId)
52
+ {
53
+ array_push($selectedCMSPages,$selectedPageId['page_id']);
54
+ }
55
+
56
+ // cms-pages:
57
+ $mPages=$dbr->fetchAll("SELECT * FROM `".$this->getTableName('cms_page')."` ORDER BY title ASC");
58
+ foreach($mPages as $mPage)
59
+ {
60
+ // Is this CMS-Page activated for the source storeview?
61
+ $storeCount=intval($dbr->fetchOne("SELECT COUNT(*) FROM `".$this->getTableName('cms_page_store')."` WHERE page_id=".$mPage['page_id']." AND (store_id=0 OR store_id=?)",array($storeview_src)));
62
+ if ($storeCount>0) // Has activated store
63
+ {
64
+ $page=array();
65
+ $page['page_id']=$mPage['page_id'];
66
+ $page['title']=$mPage['title'];
67
+ $page['checked']=in_array($mPage['page_id'],$selectedCMSPages);
68
+ $page['identifier']=$mPage['identifier'];
69
+ $page['type']=$this->__("CMS-Page");
70
+
71
+ array_push($rv,$page);
72
+ }
73
+ }
74
+
75
+ return $rv;
76
+ }
77
+
78
+ public function getCMSBlocks()
79
+ {
80
+ $dbres = Mage::getSingleton('core/resource');
81
+ $dbr=$dbres->getConnection('core_read');
82
+
83
+ $project=$this->getProject();
84
+ $storeview_src=$project['storeview_src'];
85
+
86
+ $rv=array();
87
+ $selectedCMSBlocks=array();
88
+
89
+ $selectedBlockIds=$dbr->fetchAll("SELECT block_id FROM `".$this->getTableName('eurotext_project_cmsblocks')."` WHERE project_id=?",array($this->getProjectId()));
90
+ foreach($selectedBlockIds as $selectedBlockId)
91
+ {
92
+ array_push($selectedCMSBlocks,$selectedBlockId['block_id']);
93
+ }
94
+
95
+ // static blocks:
96
+ $mPages=$dbr->fetchAll("SELECT * FROM `".$this->getTableName('cms_block')."` ORDER BY title ASC");
97
+ foreach($mPages as $mPage)
98
+ {
99
+ // Is this CMS-Block activated for the source storeview?
100
+ $storeCount=intval($dbr->fetchOne("SELECT COUNT(*) FROM `".$this->getTableName('cms_block_store')."` WHERE block_id=".$mPage['block_id']." AND (store_id=0 OR store_id=?)",array($storeview_src)));
101
+ if ($storeCount>0) // Has activated store
102
+ {
103
+ $page=array();
104
+ $page['block_id']=$mPage['block_id'];
105
+ $page['title']=$mPage['title'];
106
+ $page['checked']=in_array($mPage['block_id'],$selectedCMSBlocks);
107
+ $page['identifier']=$mPage['identifier'];
108
+ $page['type']=$this->__("CMS-Block");
109
+
110
+ array_push($rv,$page);
111
+ }
112
+ }
113
+
114
+ return $rv;
115
+ }
116
+ }
app/code/community/Eurotext/TranslationManager/Block/Selectemails.php ADDED
@@ -0,0 +1,81 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Selectemails extends Mage_Adminhtml_Block_Template
4
+ {
5
+ private function getTableName($tblName)
6
+ {
7
+ return Mage::getSingleton('core/resource')->getTableName($tblName);
8
+ }
9
+
10
+ private function getProjectId()
11
+ {
12
+ return intval($this->getRequest()->getParam("id"));
13
+ }
14
+
15
+ public function getSelectEmailsUrl()
16
+ {
17
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectemails/index',array('id' => $this->getProjectId()));
18
+ }
19
+
20
+ public function getSelectEmailsSaveUrl()
21
+ {
22
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectemails/save',array('id' => $this->getProjectId()));
23
+ }
24
+
25
+ public function getProject()
26
+ {
27
+ $id=$this->getProjectId();
28
+
29
+ $tableName = Mage::getSingleton('core/resource')->getTableName('eurotext_translationmanager/project');
30
+
31
+ $dbres = Mage::getSingleton('core/resource');
32
+ $dbr=$dbres->getConnection('core_read');
33
+
34
+ $projects=$dbr->fetchAll("SELECT * FROM `".$tableName."` WHERE id=".$id);
35
+
36
+ $project=$projects[0];
37
+
38
+ // storeview_src_locale:
39
+ $project['storeview_src_locale']="en_US";
40
+ if ($project['storeview_src']>=0)
41
+ {
42
+ $project['storeview_src_locale']=Mage::getStoreConfig('general/locale/code', $project['storeview_src']);
43
+ }
44
+
45
+ // storeview_dst_locale:
46
+ $project['storeview_dst_locale']="en_US";
47
+ if ($project['storeview_dst']>=0)
48
+ {
49
+ $project['storeview_dst_locale']=Mage::getStoreConfig('general/locale/code', $project['storeview_dst']);
50
+ }
51
+
52
+ return $project;
53
+ }
54
+
55
+ public function getEMailTemplates()
56
+ {
57
+ $dbres = Mage::getSingleton('core/resource');
58
+ $dbr=$dbres->getConnection('core_read');
59
+
60
+ $project=$this->getProject();
61
+ $storeview_src=$project['storeview_src'];
62
+
63
+ $rv=array();
64
+
65
+ $helper=Mage::helper('eurotext_translationmanager');
66
+ $helper->ajaxexportAction_CollectEMailTemplates($project);
67
+
68
+ $langfiles=$dbr->fetchAll("SELECT file_hash, filename, translate_flag FROM `".$this->getTableName('eurotext_emailtemplates')."` WHERE project_id=".$project['id']." AND locale_dst='".$project['storeview_src_locale']."' ORDER BY filename ASC");
69
+ foreach($langfiles as $langfile)
70
+ {
71
+ $rvItem=array();
72
+ $rvItem['file_hash']=$langfile['file_hash'];
73
+ $rvItem['filename']=$langfile['filename'];
74
+ $rvItem['checked']=((intval($langfile['translate_flag']))>0);
75
+
76
+ array_push($rv,$rvItem);
77
+ }
78
+
79
+ return $rv;
80
+ }
81
+ }
app/code/community/Eurotext/TranslationManager/Block/Selectlangfiles.php ADDED
@@ -0,0 +1,65 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Selectlangfiles extends Mage_Adminhtml_Block_Template
4
+ {
5
+ private function getTableName($tblName)
6
+ {
7
+ return Mage::getSingleton('core/resource')->getTableName($tblName);
8
+ }
9
+
10
+ private function getProjectId()
11
+ {
12
+ return intval($this->getRequest()->getParam("id"));
13
+ }
14
+
15
+ public function getSelectLangfilesUrl()
16
+ {
17
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectlangfiles/index',array('id' => $this->getProjectId()));
18
+ }
19
+
20
+ public function getSelectLangfilesSaveUrl()
21
+ {
22
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectlangfiles/save',array('id' => $this->getProjectId()));
23
+ }
24
+
25
+ public function getProject()
26
+ {
27
+ $id=$this->getProjectId();
28
+
29
+ $tableName = Mage::getSingleton('core/resource')->getTableName('eurotext_translationmanager/project');
30
+
31
+ $dbres = Mage::getSingleton('core/resource');
32
+ $dbr=$dbres->getConnection('core_read');
33
+
34
+ $projects=$dbr->fetchAll("SELECT * FROM `".$tableName."` WHERE id=".$id);
35
+
36
+ return $projects[0];
37
+ }
38
+
39
+ public function getLangfiles()
40
+ {
41
+ $dbres = Mage::getSingleton('core/resource');
42
+ $dbr=$dbres->getConnection('core_read');
43
+
44
+ $project=$this->getProject();
45
+ $storeview_src=$project['storeview_src'];
46
+
47
+ $rv=array();
48
+
49
+ $projectsController=Mage::helper('eurotext_translationmanager');
50
+ $projectsController->ajaxexportAction_CollectLangfiles($project);
51
+
52
+ $langfiles=$dbr->fetchAll("SELECT line_hash, filename, translate_flag FROM `".$this->getTableName('eurotext_csv')."` WHERE locale_dst='en_US' AND project_id=".$project['id']." ORDER BY filename ASC");
53
+ foreach($langfiles as $langfile)
54
+ {
55
+ $rvItem=array();
56
+ $rvItem['line_hash']=$langfile['line_hash'];
57
+ $rvItem['filename']=$langfile['filename'];
58
+ $rvItem['checked']=((intval($langfile['translate_flag']))>0);
59
+
60
+ array_push($rv,$rvItem);
61
+ }
62
+
63
+ return $rv;
64
+ }
65
+ }
app/code/community/Eurotext/TranslationManager/Block/Selectproducts.php ADDED
@@ -0,0 +1,329 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Selectproducts extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function updateFilterData()
6
+ {
7
+ if ($this->getRequest()->getParam("status")!="")
8
+ {
9
+ $filter_status=intval($this->getRequest()->getParam("status"));
10
+ $filter_stock=intval($this->getRequest()->getParam("stock"));
11
+ $filter_product_type=$this->getRequest()->getParam("producttype");
12
+ $project_id=$this->getProjectId();
13
+
14
+ $dbres = Mage::getSingleton('core/resource');
15
+ $dbw=$dbres->getConnection('core_write');
16
+ $dbw->query("UPDATE `".$this->getTableName('eurotext_project')."` SET filter_status=?, filter_stock=?, filter_product_type=? WHERE id=?;",array($filter_status,$filter_stock,$filter_product_type,$project_id));
17
+ }
18
+ }
19
+
20
+ private function getProjectId()
21
+ {
22
+ return intval($this->getRequest()->getParam("id"));
23
+ }
24
+
25
+ public function getSelectProductsUrl()
26
+ {
27
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectproducts/index',array('id' => $this->getProjectId()));
28
+ }
29
+
30
+ public function getSelectProductsSaveUrl()
31
+ {
32
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_selectproducts/save'); //,array('id' => $this->getProjectId()));
33
+ }
34
+
35
+ private function getTableName($tblName)
36
+ {
37
+ return Mage::getSingleton('core/resource')->getTableName($tblName);
38
+ }
39
+
40
+ public function getOpenCatIds()
41
+ {
42
+ // Parse catids (list of open categories)
43
+ $open_catids_str=$this->getRequest()->getParam("catids");
44
+
45
+ $open_catids_list=explode(",",$open_catids_str);
46
+ $open_catids=array();
47
+ foreach($open_catids_list as $opencatid)
48
+ {
49
+ $cat_id=intval($opencatid); // prevent non-numeric ids
50
+ array_push($open_catids,$cat_id);
51
+ }
52
+ array_push($open_catids,1); // root-category is always open
53
+ $open_catids=array_unique($open_catids);
54
+
55
+ return $open_catids;
56
+ }
57
+
58
+ public function getCategoryTreeHTML()
59
+ {
60
+ $pagesize=20;
61
+
62
+ $dbres = Mage::getSingleton('core/resource');
63
+ $dbr=$dbres->getConnection('core_read');
64
+
65
+ $rv=array();
66
+ $rv['find']=trim($this->getRequest()->getParam("find"));
67
+ $page_current=intval($this->getRequest()->getParam("page"));
68
+
69
+ $pagesize=intval($this->getRequest()->getParam("pagesize"));
70
+ if ($pagesize<20)
71
+ {
72
+ $pagesize=20;
73
+ }
74
+
75
+ $helper=Mage::helper('eurotext_translationmanager');
76
+
77
+ $open_catids=$this->getOpenCatIds();
78
+ $root=$helper->getCategoryTree(1,$open_catids);
79
+ $baselink=$this->getSelectProductsUrl()."find/".urlencode($rv['find'])."/pagesize/".$pagesize;
80
+
81
+ $current_path=array();
82
+ $project_id=$this->getProjectId();
83
+
84
+ return $this->getCategoryTreeHTMLInternal($dbr,$project_id,$root,-1,$open_catids,$current_path,$baselink);
85
+ }
86
+
87
+ private function getCategoryTreeHTMLInternal($dbr, $project_id, $treeNode, $lvl, $open_catids, $current_path, $baselink)
88
+ {
89
+
90
+ $rv = '';
91
+ $_lvl=max(0,$lvl);
92
+ $marginLeft=($_lvl)*22;
93
+
94
+ $current_path_new=array_merge(array(),$current_path);
95
+ array_push($current_path_new,$treeNode['id']);
96
+ $current_path_new=array_unique($current_path_new);
97
+
98
+ $showChildren=false;
99
+ $isSelected=in_array($treeNode['id'],$open_catids);
100
+
101
+ $cssClass="eurotext_category_none";
102
+ if ($treeNode['hasChildren'])
103
+ {
104
+ if ($isSelected)
105
+ {
106
+ $showChildren=true;
107
+ $cssClass="eurotext_category_minus";
108
+ }
109
+ else
110
+ {
111
+ $cssClass="eurotext_category_plus id_".$treeNode['id']." path_".implode("_",$open_catids);
112
+ }
113
+ }
114
+ if ($treeNode['id']==1)
115
+ {
116
+ $cssClass="eurotext_category_none"; // no 'open'-icon on root-category
117
+ }
118
+
119
+ $linkStyle="color:black;text-decoration:none;padding:2px;";
120
+ if ($isSelected)
121
+ {
122
+ if ( ($treeNode['id']==1) && (count($open_catids)>1))
123
+ {
124
+ // Ignore selection on root category
125
+ }
126
+ else
127
+ {
128
+ $linkStyle="color:black;text-decoration:none;background-color: rgb(245, 214, 199);padding:2px;";
129
+ }
130
+ }
131
+
132
+ // Determine category state:
133
+ $categoryState=Mage::helper('eurotext_translationmanager')->getTreeNodeTranslationState($dbr,$treeNode['id'],$project_id);
134
+
135
+ $checkedStr="";
136
+ if ($categoryState=="checked")
137
+ {
138
+ $checkedStr="checked='checked'";
139
+ }
140
+
141
+
142
+ $rv .= "<table style='margin-left:".$marginLeft."px;'> \r\n";
143
+ $rv .= " <tr> \r\n";
144
+ $rv .= " <td><div class='".$cssClass."'></div></td> \r\n"; // Icon
145
+ $rv .= " <td><input type='checkbox' autocomplete='off' x-state='".$categoryState."' x-catid='".$treeNode['id']."' class='eurotext_catsel' id='eurotext_catsel_".$treeNode['id']."' ".$checkedStr." /> </td> \r\n";
146
+ $rv .= " <td><a style='".$linkStyle."' href='".$baselink."/catids/".implode(",",$current_path_new)."'>".htmlentities($treeNode['name'])."</a></td> \r\n";
147
+ $rv .= " </tr> \r\n";
148
+ $rv .= "</table> \r\n";
149
+
150
+ if ($categoryState=="indeterminate")
151
+ {
152
+ $rv .= "<script>document.getElementById('eurotext_catsel_".$treeNode['id']."').indeterminate = true;</script> \r\n";
153
+ }
154
+
155
+ if ($showChildren)
156
+ {
157
+ foreach($treeNode['childs'] as $child)
158
+ {
159
+ $rv .= $this->getCategoryTreeHTMLInternal($dbr,$project_id,$child,($lvl+1),$open_catids,$current_path_new,$baselink);
160
+ }
161
+ }
162
+
163
+ return $rv;
164
+
165
+ }
166
+
167
+ private $filterDataRead=false;
168
+ private $filter_status=1;
169
+ private $filter_stock=1;
170
+ private $filter_product_type="";
171
+
172
+ private function readFilterData()
173
+ {
174
+ if ($this->filterDataRead)
175
+ {
176
+ return;
177
+ }
178
+
179
+ $dbres = Mage::getSingleton('core/resource');
180
+ $dbr=$dbres->getConnection('core_read');
181
+
182
+ $project_id=$this->getProjectId();
183
+
184
+ $allProducts=$dbr->fetchAll("SELECT filter_status, filter_stock, filter_product_type FROM `".$this->getTableName('eurotext_project')."` WHERE id=?",array($project_id));
185
+ foreach($allProducts as $row)
186
+ {
187
+ $this->filter_status=$row['filter_status'];
188
+ $this->filter_stock=$row['filter_stock'];
189
+ $this->filter_product_type=$row['filter_product_type'];
190
+ }
191
+
192
+ $this->filterDataRead=true;
193
+ }
194
+
195
+ public function getFilterStatus()
196
+ {
197
+ $this->readFilterData();
198
+
199
+ return $this->filter_status;
200
+ }
201
+
202
+ public function getFilterStock()
203
+ {
204
+ $this->readFilterData();
205
+
206
+ return $this->filter_stock;
207
+ }
208
+
209
+ public function getFilterProductType()
210
+ {
211
+ $this->readFilterData();
212
+
213
+ $tmp=$this->filter_product_type;
214
+
215
+ $validProductTypes=array("simple","grouped","configurable","virtual","bundle","downloadable");
216
+ if (in_array($tmp,$validProductTypes))
217
+ {
218
+ return $tmp;
219
+ }
220
+ else
221
+ {
222
+ return "";
223
+ }
224
+ }
225
+
226
+ public function getSearchResult()
227
+ {
228
+ $pagesize=20;
229
+
230
+ $rv=array();
231
+ $rv['find']=trim($this->getRequest()->getParam("find"));
232
+ $page_current=intval($this->getRequest()->getParam("page"));
233
+
234
+ $pagesize=intval($this->getRequest()->getParam("pagesize"));
235
+ if ($pagesize<20)
236
+ {
237
+ $pagesize=20;
238
+ }
239
+
240
+ $dbres = Mage::getSingleton('core/resource');
241
+ $dbr=$dbres->getConnection('core_read');
242
+
243
+ $eavAttribute = Mage::getModel('eav/entity_attribute');
244
+ $name_id = $eavAttribute->getIdByCode('catalog_product', 'name');
245
+
246
+ $attr_status_id=$eavAttribute->getIdByCode('catalog_product', 'status');
247
+
248
+ $findme="%".$rv['find']."%";
249
+
250
+ $sql_categoryfilter="";
251
+ $open_catids=$this->getOpenCatIds();
252
+ if (count($open_catids)>0)
253
+ {
254
+ $selected_catid=$open_catids[count($open_catids)-1]; // Last ID is the selected category
255
+ if ($selected_catid>1) // root-category has id 1
256
+ {
257
+ $search_catids=Mage::helper('eurotext_translationmanager')->getAllSubCategories($selected_catid); // Get the IDs of all children (direct+indirect)
258
+ array_push($search_catids,$selected_catid); // add selected category to list
259
+
260
+ // Filter to products which are assigned to any category in $search_catids:
261
+ $sql_categoryfilter=" AND e.entity_id IN (SELECT cat.product_id FROM catalog_category_product cat WHERE cat.category_id IN (".implode(",",$search_catids)."))";
262
+ }
263
+ }
264
+
265
+ $sql_stockfilter=" AND e.entity_id IN (SELECT stock.product_id FROM cataloginventory_stock_item stock WHERE stock.is_in_stock=".$this->getFilterStock().")";
266
+ $sql_statusfilter=" AND e.entity_id IN (SELECT pstatus.entity_id FROM catalog_product_entity_int pstatus WHERE pstatus.attribute_id=".$attr_status_id." AND pstatus.value=".$this->getFilterStatus().")";
267
+
268
+ if ($this->getFilterProductType()!=="")
269
+ {
270
+ $sql_statusfilter.=" AND e.type_id='".$this->getFilterProductType()."'";
271
+ }
272
+
273
+ $sql="SELECT a.store_id, a.value as article_name, e.sku, e.entity_id FROM `".$this->getTableName('catalog_product_entity_varchar')."` a, `".$this->getTableName('catalog_product_entity')."` e WHERE (a.entity_id=e.entity_id) AND a.store_id=0 AND (a.attribute_id=?) AND ((UPPER(e.sku) LIKE ?) OR (UPPER(a.value) LIKE ?)) $sql_categoryfilter $sql_stockfilter $sql_statusfilter ORDER BY article_name ASC, e.entity_id ASC";
274
+
275
+ //echo $sql;
276
+ $allProducts=$dbr->fetchAll($sql,array($name_id,$findme,$findme));
277
+
278
+ $pageCount=intval(count($allProducts)/$pagesize);
279
+ if (($pageCount*$pagesize)<count($allProducts))
280
+ {
281
+ $pageCount++;
282
+ }
283
+ $rv['page_last']=$pageCount;
284
+
285
+ if ($page_current>$pageCount)
286
+ {
287
+ $page_current=$pageCount;
288
+ }
289
+ if ($page_current<1)
290
+ {
291
+ $page_current=1;
292
+ }
293
+
294
+ if ($pageCount<1)
295
+ {
296
+ $pageCount=1;
297
+ }
298
+
299
+ // Result-Array:
300
+ $resultProducts=array();
301
+ $ofs_start=($page_current-1)*$pageCount;
302
+ $ofs_end=$ofs_start+$pagesize;
303
+ if ($ofs_end>=count($allProducts))
304
+ {
305
+ $ofs_end=count($allProducts)-1;
306
+ }
307
+
308
+ for ($i=$ofs_start; $i<=$ofs_end; $i++)
309
+ {
310
+ $prod=$allProducts[$i];
311
+ $prod['checked']=false;
312
+
313
+ // Already selected?
314
+ $sql="SELECT product_id FROM `".$this->getTableName('eurotext_project_products')."` p WHERE (p.project_id=?) AND (p.product_id=?)";
315
+ $selProducts=$dbr->fetchAll($sql,array($this->getProjectId(),$prod['entity_id']));
316
+ $prod['checked']=(count($selProducts)>0);
317
+
318
+ array_push($resultProducts,$prod);
319
+ }
320
+
321
+ $rv['page_current']=$page_current;
322
+ $rv['page_last']=$pageCount;
323
+ $rv['page_size']=$pagesize;
324
+ $rv['result_count']=count($allProducts);
325
+ $rv['products']=$resultProducts;
326
+
327
+ return $rv;
328
+ }
329
+ }
app/code/community/Eurotext/TranslationManager/Block/Settings.php ADDED
@@ -0,0 +1,34 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Block_Settings extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function getSaveUrl()
6
+ {
7
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_settings/save');
8
+ }
9
+
10
+ public function getUpgradeScopeUrl()
11
+ {
12
+ return Mage::helper('adminhtml')->getUrl('*/eurotext_translationmanager_settings/upgradescope');
13
+ }
14
+
15
+ public function getStoreviews()
16
+ {
17
+ $array_stores=array();
18
+
19
+ $stores=Mage::app()->getStores();
20
+ foreach($stores as $store)
21
+ {
22
+ $array_store=array();
23
+ $array_store['store_id']=$store->getId();
24
+ $array_store['name']=$store->getName();
25
+ $array_store['code']=$store->getCode();
26
+ $array_store['locale']=Mage::getStoreConfig('general/locale/code', $store->getId());
27
+
28
+ array_push($array_stores,$array_store);
29
+ }
30
+
31
+ return $array_stores;
32
+ }
33
+
34
+ }
app/code/community/Eurotext/TranslationManager/Helper/Data.php ADDED
@@ -0,0 +1,566 @@
1
+ <?php
2
+ /**
3
+ */
4
+ class Eurotext_TranslationManager_Helper_Data extends Mage_Core_Helper_Abstract
5
+ {
6
+ const XML_PATH_EUROTEXT_DEBUGMODE = 'dev/log/ettm_debug';
7
+ private $help_url="http://www.eurotext.de";
8
+
9
+ private $live_ftp_host="eurotext-services.de";
10
+ private $live_ftp_port=21;
11
+ private $live_registration_email="magento@eurotext.de";
12
+ private $live_registration_email_name="Eurotext Magento (Live)";
13
+
14
+ private $exportProducts_minPerFile=6;
15
+ private $exportCategories_minPerFile=6;
16
+
17
+ private $debug_registration_email="debug@eurotext.de";
18
+ private $debug_registration_email_name="Eurotext Magento (Debug)";
19
+
20
+ public function getExportProductsMinPerFile()
21
+ {
22
+ return $this->exportProducts_minPerFile;
23
+ }
24
+
25
+ public function getExportCategoriesMinPerFile()
26
+ {
27
+ return $this->exportCategories_minPerFile;
28
+ }
29
+
30
+ public function getDebugMode()
31
+ {
32
+ return Mage::getStoreConfigFlag(self::XML_PATH_EUROTEXT_DEBUGMODE);
33
+ }
34
+
35
+ public function getCustomProductAttributesForExport(){
36
+ // @TODO Modul ist noch nicht Scope-Fähig, wir lassen das erstmal so und stellen das später auf Mage::getStoreConfig um.
37
+ $custom_attributes = Mage::getConfig()->getNode('default/eurotext/translation_manager/custom_product_attributes');
38
+ return $custom_attributes ? $custom_attributes->asArray() : false;
39
+ }
40
+
41
+ public function getCustomCategoryAttributesForExport(){
42
+ // @TODO Modul ist noch nicht Scope-Fähig, wir lassen das erstmal so und stellen das später auf Mage::getStoreConfig um.
43
+ $custom_attributes = Mage::getConfig()->getNode('default/eurotext/translation_manager/custom_category_attributes');
44
+ return $custom_attributes ? $custom_attributes->asArray() : false;
45
+ }
46
+
47
+ // Prüft, ob der URL-Key von Produkt/Kategorie auf "global" statt "storeview" steht
48
+ // Liefert true, zurück wenn mindestens ein Scope NICHT(!) auf "storeview" steht
49
+ public function urlKeyScopeIsGlobal()
50
+ {
51
+ $tbl_eav_attribute = Mage::getSingleton('core/resource')->getTableName('eav_attribute');
52
+ $tbl_catalog_eav_attribute = Mage::getSingleton('core/resource')->getTableName('catalog_eav_attribute');
53
+
54
+ $dbres = Mage::getSingleton('core/resource');
55
+ $dbr=$dbres->getConnection('core_read');
56
+
57
+ $result=$dbr->fetchAll("SELECT v.is_global, a.attribute_id, a.attribute_code FROM `".$tbl_eav_attribute."` a, `".$tbl_catalog_eav_attribute."` v WHERE (a.attribute_id=v.attribute_id) AND ((a.attribute_code='url_key') OR (a.attribute_code='url_path'))");
58
+ foreach($result as $row)
59
+ {
60
+ if ($row['is_global']>0)
61
+ {
62
+ return true;
63
+ }
64
+ }
65
+
66
+ return false;
67
+ }
68
+
69
+ /**
70
+ * Checks for a incremental url
71
+ * if increment value is detected it'll +1 the value
72
+ * else will create an increment
73
+ *
74
+ * @param string $url
75
+ */
76
+ public function getUniqueUrl($url)
77
+ {
78
+ if (preg_match('/^(.*\-)(\d+)#x2F;i', $url, $matches) == 1) {
79
+ return $matches[1] . ++$matches[2];
80
+ } else {
81
+ return $url . '-1';
82
+ }
83
+ }
84
+
85
+ public function getLocaleInfoByMagentoLocale($locale)
86
+ {
87
+ $backendLocale = Mage::app()->getLocale()->getLocaleCode();
88
+
89
+ $rv=array();
90
+ $rv['locale']=$locale;
91
+ $rv['locale_eurotext']="-";
92
+ $rv['lang_name']=$this->__("Unsupported language");
93
+ $rv['supported']=false;
94
+
95
+ $dbres = Mage::getSingleton('core/resource');
96
+ $dbr= $dbres->getConnection('core_read');
97
+
98
+ $tbl_eurotext_languages = Mage::getSingleton('core/resource')->getTableName('eurotext_languages');
99
+
100
+ // Try current backend language first:
101
+ $localeInfos=$dbr->fetchAll("SELECT * FROM `".$tbl_eurotext_languages."` WHERE UPPER(locale_magento)=?",array(strtoupper($locale)));
102
+ if (count($localeInfos)>0)
103
+ {
104
+ $localeInfo=$localeInfos[0];
105
+ $rv['lang_name']=$localeInfo['lang_name'];
106
+ $rv['locale_eurotext']=$localeInfo['locale_eurotext'];
107
+ $rv['supported']=true;
108
+
109
+ return $rv;
110
+ }
111
+
112
+ return $rv;
113
+ }
114
+
115
+ public function getLocaleInfoByEurotextLocale($locale)
116
+ {
117
+ $backendLocale = Mage::app()->getLocale()->getLocaleCode();
118
+
119
+ $rv=array();
120
+ $rv['locale']=$locale;
121
+ $rv['locale_eurotext']=$locale;
122
+ $rv['lang_name']=$this->__("Unsupported language");
123
+ $rv['supported']=false;
124
+
125
+ $dbres = Mage::getSingleton('core/resource');
126
+ $dbr= $dbres->getConnection('core_read');
127
+
128
+ $tbl_eurotext_languages = Mage::getSingleton('core/resource')->getTableName('eurotext_languages');
129
+
130
+ // Try current backend language first:
131
+ $localeInfos=$dbr->fetchAll("SELECT * FROM `".$tbl_eurotext_languages."` WHERE UPPER(locale_eurotext)=?",array(strtoupper($locale)));
132
+ if (count($localeInfos)>0)
133
+ {
134
+ $localeInfo=$localeInfos[0];
135
+ $rv['locale']=$localeInfo['locale_magento'];
136
+ $rv['lang_name']=$localeInfo['lang_name'];
137
+ $rv['locale_eurotext']=$localeInfo['locale_eurotext'];
138
+ $rv['supported']=true;
139
+
140
+ return $rv;
141
+ }
142
+
143
+ return $rv;
144
+ }
145
+
146
+
147
+ public function getRegistrationRecipient()
148
+ {
149
+ $rv=array();
150
+
151
+ if ($this->getDebugMode())
152
+ {
153
+ $rv["email"]=$this->debug_registration_email;
154
+ $rv["name"]=$this->debug_registration_email_name;
155
+ }
156
+ else
157
+ {
158
+ $rv["email"]=$this->live_registration_email;
159
+ $rv["name"]=$this->live_registration_email_name;
160
+ }
161
+
162
+ return $rv;
163
+ }
164
+
165
+ public function getHelpUrl()
166
+ {
167
+ return $this->help_url;
168
+ }
169
+
170
+ public function saveSetting($key, $val)
171
+ {
172
+ $dbres = Mage::getSingleton('core/resource');
173
+ $dbw= $dbres->getConnection('core_write');
174
+
175
+ $tbl_eurotext_config = Mage::getSingleton('core/resource')->getTableName('eurotext_config');
176
+
177
+ $val = $this->sanitize($val);
178
+
179
+ $dbw->query("INSERT IGNORE INTO `".$tbl_eurotext_config."` (config_key, config_value) VALUES (?,?);",array($key,$val));
180
+ $dbw->query("UPDATE `".$tbl_eurotext_config."` SET config_value=? WHERE config_key=?;",array($val,$key));
181
+ }
182
+
183
+ public function log($message, $level = Zend_Log::DEBUG){
184
+ if($this->getDebugMode()) {
185
+ Mage::log($message, $level, 'eurotext.log', true);
186
+ } elseif ($level < Zend_Log::ERR) {
187
+ Mage::log($message, $level, 'eurotext_fatal.log', true);
188
+ }
189
+ }
190
+
191
+ public function openFtpConnection()
192
+ {
193
+ if (!function_exists("ftp_connect")) {
194
+ $this->log('There is no FTP Client available: ftp_connect does not exist.', Zend_Log::CRIT);
195
+
196
+ return false;
197
+ }
198
+
199
+
200
+ $ftp_host=$this->live_ftp_host;
201
+ $ftp_port=$this->live_ftp_port;
202
+
203
+
204
+ return ftp_connect($ftp_host,$ftp_port,30);
205
+
206
+ }
207
+
208
+ public function testFtpConnection()
209
+ {
210
+ $helper=Mage::helper('eurotext_translationmanager');
211
+ $et_username=$helper->getSetting("eurotext_username","");
212
+ $et_password=Mage::helper('core')->decrypt($helper->getSetting("eurotext_password",""));
213
+
214
+ $ftp_username=$et_username;
215
+ $ftp_password=$et_password;
216
+
217
+
218
+ $rv=array();
219
+ $rv['ok']=false;
220
+ $rv['statusmessage']="Unknown error";
221
+
222
+ if (trim($ftp_username)=="")
223
+ {
224
+ $this->log('Login data is not set.', Zend_Log::ERR);
225
+ $rv['statusmessage']="<span class='et_error'>".$this->__("There seems to be a problem with your login data. Please check username and password!")."</span>";
226
+ }
227
+ else
228
+ {
229
+ $ftpConn=$this->openFtpConnection();
230
+ if ($ftpConn===false)
231
+ {
232
+ // Could not connect to host
233
+ $this->log('Could not connect to Translation Portal Server.', Zend_Log::ERR);
234
+ $rv['statusmessage']="<span class='et_error'>".$this->__("Could not connect to server. Could be a temporary error or firewall problem. You could also check for a new module version.")."</span>";
235
+ }
236
+ else
237
+ {
238
+ // Login:
239
+ if (@ftp_login($ftpConn,$ftp_username,$ftp_password))
240
+ {
241
+ $this->log('Translation Portal Server successfully connected.', Zend_Log::INFO);
242
+ $rv['statusmessage']="<span class='et_ok'>".$this->__("Translation portal successfully connected!")."</span>";
243
+ $rv['ok']=true;
244
+ }
245
+ else
246
+ {
247
+ $this->log('Could not login to Translation Portal Server.', Zend_Log::ERR);
248
+ $rv['statusmessage']="<span class='et_error'>".$this->__("There seems to be a problem with your login data. Please check username and password!")."</span>";
249
+ }
250
+
251
+ ftp_close($ftpConn);
252
+ }
253
+ }
254
+
255
+ return $rv;
256
+ }
257
+
258
+ public function getSetting($key, $defaultValue="")
259
+ {
260
+ $dbres = Mage::getSingleton('core/resource');
261
+ $dbr= $dbres->getConnection('core_read');
262
+
263
+ $tbl_eurotext_config = Mage::getSingleton('core/resource')->getTableName('eurotext_config');
264
+
265
+ $result=$dbr->fetchOne("SELECT config_value FROM `".$tbl_eurotext_config."` WHERE config_key=?;",array($key));
266
+ if ($result!==false)
267
+ {
268
+ return $result;
269
+ }
270
+ else
271
+ {
272
+ return $defaultValue;
273
+ }
274
+ }
275
+
276
+ public function ajaxexportAction_CollectLangfiles($project)
277
+ {
278
+ $dbres = Mage::getSingleton('core/resource');
279
+ $dbw=$dbres->getConnection('core_write');
280
+
281
+ $project_id = $this->sanitize($project['id']);
282
+
283
+ $dbw->query("UPDATE `".$this->getTableName("eurotext_csv")."` SET deleteflag=1 WHERE project_id=".$project_id);
284
+
285
+ $base_dir=Mage::getBaseDir('app');
286
+ $this->ajaxexportAction_CollectLangfiles2($dbw,$project,$base_dir);
287
+
288
+ $dbw->query("DELETE FROM `".$this->getTableName("eurotext_csv")."` WHERE deleteflag=1 AND project_id=".$project_id);
289
+ }
290
+
291
+ public function ajaxexportAction_CollectLangfilesLocaleCSV($dbw,$project,$locale,$localeFolder)
292
+ {
293
+
294
+ $project_id = intval($this->sanitize($project['id']));
295
+
296
+ $pathNames=scandir($localeFolder);
297
+ foreach($pathNames as $path)
298
+ {
299
+ $full_path=$localeFolder.DS.$path;
300
+ if ((is_file($full_path)) && (stripos($path,".csv")!==false))
301
+ {
302
+ $base_dir=Mage::getBaseDir('app');
303
+ $filename=substr($full_path,strlen($base_dir));
304
+
305
+ $line_hash=sha1($project_id."_".$filename);
306
+ $dbw->query("INSERT IGNORE INTO `".$this->getTableName('eurotext_csv')."` (line_hash,project_id,filename,locale_dst) VALUES (?,?,?,?);",array($line_hash,$project_id,$filename,$locale));
307
+ $dbw->query("UPDATE `".$this->getTableName('eurotext_csv')."` SET deleteflag=0 WHERE line_hash=?;",array($line_hash));
308
+ }
309
+ }
310
+ }
311
+
312
+ public function ajaxexportAction_CollectLangfilesLocale($dbw,$project,$localeFolder)
313
+ {
314
+ $pathNames=scandir($localeFolder);
315
+ foreach($pathNames as $path)
316
+ {
317
+ $full_path=$localeFolder.DS.$path;
318
+ if (($path==".") || ($path==".."))
319
+ {
320
+ // Ignore
321
+ }
322
+ elseif (is_dir($full_path))
323
+ {
324
+ $this->ajaxexportAction_CollectLangfilesLocaleCSV($dbw,$project,$path,$full_path);
325
+ }
326
+ }
327
+ }
328
+
329
+ public function ajaxexportAction_CollectLangfiles2($dbw,$project,$curdir)
330
+ {
331
+ $pathNames=scandir($curdir);
332
+ foreach($pathNames as $path)
333
+ {
334
+ $full_path=$curdir.DS.$path;
335
+ if (($path==".") || ($path==".."))
336
+ {
337
+ // Ignore
338
+ }
339
+ elseif (is_dir($full_path))
340
+ {
341
+ if ($path=="locale")
342
+ {
343
+ $this->ajaxexportAction_CollectLangfilesLocale($dbw,$project,$full_path);
344
+ }
345
+ else
346
+ {
347
+ $this->ajaxexportAction_CollectLangfiles2($dbw,$project,$full_path);
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ public function ajaxexportAction_CollectEMailTemplates2($helper, $dbw, $project, $locale, $localeFolder)
354
+ {
355
+ $project_id = intval($this->sanitize($project['id']));
356
+
357
+ $templates=$helper->getDirectoryContent($localeFolder,true,true,false);
358
+ foreach($templates as $template)
359
+ {
360
+ $filename=$template['full_path'];
361
+ if ($helper->endsWith(strtolower($filename),".html"))
362
+ {
363
+ $short_filename=substr($filename,strlen($localeFolder));
364
+ $short_filename=substr($filename,strlen($localeFolder));
365
+
366
+ $file_hash=sha1($project_id."_".$locale."_".$short_filename);
367
+
368
+ $dbw->query("INSERT IGNORE INTO `".$this->getTableName('eurotext_emailtemplates')."` (file_hash,project_id,filename,locale_dst) VALUES (?,?,?,?);",array($file_hash,$project_id,$short_filename,$locale));
369
+ $dbw->query("UPDATE `".$this->getTableName('eurotext_emailtemplates')."` SET deleteflag=0 WHERE file_hash=?;",array($file_hash));
370
+ }
371
+ }
372
+ }
373
+
374
+ public function ajaxexportAction_CollectEMailTemplates($project)
375
+ {
376
+ $dbres = Mage::getSingleton('core/resource');
377
+ $dbw=$dbres->getConnection('core_write');
378
+
379
+ $project_id = intval($this->sanitize($project['id']));
380
+
381
+ $dbw->query("UPDATE `".$this->getTableName("eurotext_emailtemplates")."` SET deleteflag=1 WHERE project_id=".$project_id);
382
+
383
+ $baseLocaleFolder=Mage::getBaseDir('locale');
384
+
385
+ $helper_et=Mage::helper('eurotext_translationmanager/eurotext');
386
+ $localeFolders=$helper_et->getDirectoryContent($baseLocaleFolder,false,false,true);
387
+ foreach($localeFolders as $localeFolder)
388
+ {
389
+ $templateFolder=$localeFolder['full_path'].DS."template";
390
+ if (is_dir($templateFolder))
391
+ {
392
+ $this->ajaxexportAction_CollectEMailTemplates2($helper_et, $dbw,$project, $localeFolder['name'], $templateFolder);
393
+ }
394
+ }
395
+
396
+ $dbw->query("DELETE FROM `".$this->getTableName("eurotext_emailtemplates")."` WHERE deleteflag=1 AND project_id=".$project_id);
397
+ }
398
+
399
+ private function getTableName($tblName)
400
+ {
401
+ return Mage::getSingleton('core/resource')->getTableName($tblName);
402
+ }
403
+
404
+ // Gets an array with the ids of all children of $cat_id
405
+ public function getAllSubCategories($cat_id, $recurse=true)
406
+ {
407
+ $rv=array();
408
+
409
+ $_cat=Mage::getModel("catalog/category")->load($cat_id);
410
+
411
+ $subcat_ids_str=$_cat->getChildren();
412
+
413
+ // Free memory:
414
+ unset($_cat);
415
+ $_cat=null;
416
+
417
+ $subcat_ids=array();
418
+ if (strlen($subcat_ids_str)>0)
419
+ {
420
+ $subcat_ids=explode(",",$subcat_ids_str);
421
+
422
+ $rv=array_merge($rv,$subcat_ids);
423
+
424
+ if ($recurse)
425
+ {
426
+ foreach($subcat_ids as $subcat_id)
427
+ {
428
+ $rv=array_merge($rv,Mage::helper('eurotext_translationmanager')->getAllSubCategories($subcat_id,true));
429
+ }
430
+ }
431
+ }
432
+
433
+ return $rv;
434
+ }
435
+
436
+ // Generates a tree (recurses to all cats which ids are in open_catids
437
+ public function getCategoryTree($cat_id, $open_catids)
438
+ {
439
+ $node=array();
440
+
441
+ $_cat=Mage::getModel("catalog/category")->load($cat_id);
442
+
443
+ $node['childs']=array();
444
+ $node['hasChildren']=false;
445
+
446
+ if ($cat_id==1) // Pseudo-Category
447
+ {
448
+ $node['id']=1;
449
+ $node['name']=$this->__("(All products)"); // ." (".$cat_id.")";
450
+ }
451
+ else
452
+ {
453
+ $node['id']=$cat_id;
454
+ $node['name']=$_cat->getName(); // ." (".$cat_id.")";
455
+ }
456
+
457
+ // get children ids (comma-seperated list as string)
458
+ $subcat_ids_str=$_cat->getChildren();
459
+
460
+ // Free memory:
461
+ unset($_cat);
462
+ $_cat=null;
463
+
464
+ $subcat_ids=array();
465
+ if (strlen($subcat_ids_str)>0)
466
+ {
467
+ $subcat_ids=explode(",",$subcat_ids_str);
468
+ }
469
+
470
+ if (count($subcat_ids)>0)
471
+ {
472
+ $node['hasChildren']=true;
473
+
474
+ if (in_array($cat_id, $open_catids))
475
+ {
476
+ // Load sub categories:
477
+ foreach($subcat_ids as $subcat_id)
478
+ {
479
+ $childItem=$this->getCategoryTree($subcat_id,$open_catids);
480
+ array_push($node['childs'],$childItem);
481
+ }
482
+ }
483
+ }
484
+
485
+ return $node;
486
+ }
487
+
488
+ public static function getCategoryProducts($dbr,$cat_id)
489
+ {
490
+ $sql_categoryfilter="";
491
+
492
+ $search_catids=Mage::helper('eurotext_translationmanager')->getAllSubCategories($cat_id); // Get the IDs of all children (direct+indirect)
493
+ array_push($search_catids,$cat_id); // add selected category to list
494
+
495
+ // Filter to products which are assigned to any category in $search_catids:
496
+ $sql_categoryfilter=" AND e.entity_id IN (SELECT cat.product_id FROM catalog_category_product cat WHERE cat.category_id IN (".implode(",",$search_catids)."))";
497
+
498
+ $sql1="SELECT e.entity_id FROM `".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')."` e WHERE (1=1)".$sql_categoryfilter;
499
+ $res1=$dbr->fetchAll($sql1);
500
+
501
+ $rv=array();
502
+ for($i=0; $i<count($res1); $i++)
503
+ {
504
+ array_push($rv,$res1[$i]['entity_id']);
505
+ }
506
+
507
+ return $rv;
508
+ }
509
+
510
+ // Returns 'checked', 'indeterminate' or 'unchecked' for a given category id
511
+ // checked: all products of the category are selected for translation
512
+ // indeterminate: some products of the category are selected for translation
513
+ // unchecked: no products are selected for translation
514
+ public function getTreeNodeTranslationState($dbr,$cat_id, $project_id)
515
+ {
516
+ $sql_categoryfilter="";
517
+
518
+ $search_catids=Mage::helper('eurotext_translationmanager')->getAllSubCategories($cat_id); // Get the IDs of all children (direct+indirect)
519
+ array_push($search_catids,$cat_id); // add selected category to list
520
+
521
+ // Filter to products which are assigned to any category in $search_catids:
522
+ if ($cat_id>1)
523
+ {
524
+ $sql_categoryfilter=" AND e.entity_id IN (SELECT cat.product_id FROM catalog_category_product cat WHERE cat.category_id IN (".implode(",",$search_catids)."))";
525
+ }
526
+
527
+ $sql1="SELECT COUNT(e.product_id) cnt FROM eurotext_project_products e WHERE e.project_id=".intval($project_id)." AND e.product_id IN (SELECT e.entity_id FROM `".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')."` e WHERE (1=1)".$sql_categoryfilter.")";
528
+ //echo $sql1;
529
+ //die($sql1);
530
+ $res1=$dbr->fetchAll($sql1);
531
+ $translatedProducts=$res1[0]['cnt'];
532
+
533
+ $sql2="SELECT COUNT(e.entity_id) cnt FROM `".Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')."` e WHERE (1=1)".$sql_categoryfilter;
534
+ //echo $sql2;
535
+ $res2=$dbr->fetchAll($sql2);
536
+ $allProducts=$res2[0]['cnt'];
537
+
538
+ if ($allProducts==0) // empty category
539
+ {
540
+ return "unchecked";
541
+ }
542
+ else if ($translatedProducts==$allProducts)
543
+ {
544
+ return "checked";
545
+ }
546
+ else if ($translatedProducts==0)
547
+ {
548
+ return "unchecked";
549
+ }
550
+ else if ($translatedProducts<$allProducts)
551
+ {
552
+ return "indeterminate";
553
+ }
554
+ else
555
+ {
556
+ return "unchecked";
557
+ }
558
+ }
559
+
560
+ public function sanitize($value){
561
+ $value = strip_tags($value);
562
+ $value = trim($value);
563
+ $value = htmlspecialchars($value);
564
+ return $value;
565
+ }
566
+ }
app/code/community/Eurotext/TranslationManager/Helper/Eurotext.php ADDED
@@ -0,0 +1,247 @@
1
+ <?php
2
+
3
+ // allow utf8-detection: öäü€
4
+
5
+ // Helper Functions
6
+ class Eurotext_TranslationManager_Helper_Eurotext extends Mage_Core_Helper_Abstract
7
+ {
8
+ // Like realpath, but also works on non-existing paths
9
+ // Source: http://de2.php.net/manual/de/function.realpath.php#84012
10
+ public function getAbsolutePath($path)
11
+ {
12
+ $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
13
+ $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
14
+ $absolutes = array();
15
+ foreach ($parts as $part) {
16
+ if ('.' == $part) continue;
17
+ if ('..' == $part) {
18
+ array_pop($absolutes);
19
+ } else {
20
+ $absolutes[] = $part;
21
+ }
22
+ }
23
+ return DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $absolutes);
24
+ }
25
+
26
+ // Extract directory-part of path
27
+ // "/foo/bar/filename.dat" => "/foo/bar"
28
+ // "/foo/bar/" => "/foo/bar"
29
+ // "/foo/bar" => "/foo"
30
+ public function GetDirectoryFromPath($path)
31
+ {
32
+ $rpath=$this->getAbsolutePath($path);
33
+ $lastSep=strrpos($rpath,DIRECTORY_SEPARATOR);
34
+ if ($lastSep>=0)
35
+ {
36
+ return substr($rpath,0,$lastSep);
37
+ }
38
+ else
39
+ {
40
+ return $path;
41
+ }
42
+ }
43
+
44
+ public function GetFilenameFromPath($path)
45
+ {
46
+ $tmpPath=str_replace("\\","/",$path);
47
+ $lastPos=strrpos($tmpPath,"/");
48
+ if ($lastPos===false)
49
+ {
50
+ return $path;
51
+ }
52
+
53
+ $rv=substr($tmpPath,$lastPos+1);
54
+
55
+ return trim($rv);
56
+ }
57
+
58
+ // Converts $str to a string that is safe to use in filenames
59
+ // (Replaces unsafe characters to '-')
60
+ public function GetFilenameSafeString($str)
61
+ {
62
+ $strTmp=trim(strtolower($str));
63
+ $allowedChars=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','-','_','.','0','1','2','3','4','5','6','7','8','9');
64
+ $str2="";
65
+ for($i=0; $i<strlen($strTmp); $i++)
66
+ {
67
+ if (in_array($strTmp[$i],$allowedChars))
68
+ {
69
+ $str2.=$strTmp[$i];
70
+ }
71
+ else
72
+ {
73
+ $str2.="-";
74
+ }
75
+ }
76
+
77
+ while(stripos($str2,"--")!==false)
78
+ {
79
+ $str2=str_replace("--","-",$str2);
80
+ }
81
+
82
+ while(stripos($str2,"..")!==false)
83
+ {
84
+ $str2=str_replace("..",".",$str2);
85
+ }
86
+
87
+ return $str2;
88
+ }
89
+
90
+ // Tests if $haystack ends with $needle
91
+ public function endsWith($haystack, $needle)
92
+ {
93
+ if (strlen($haystack)>=strlen($needle))
94
+ {
95
+ $lastOfHaystack=substr($haystack,-strlen($needle));
96
+ return ($lastOfHaystack==$needle);
97
+ }
98
+
99
+ return false;
100
+ }
101
+
102
+ public function removeTrailingDirectorySeparator($path)
103
+ {
104
+ if ($this->endsWith($path,DIRECTORY_SEPARATOR))
105
+ {
106
+ return substr($path,0,strlen($path)-1);
107
+ }
108
+
109
+ return $path;
110
+ }
111
+
112
+ public function compareFileItems($a, $b)
113
+ {
114
+ return strcmp($a['full_path'],$b['full_path']);
115
+ }
116
+
117
+ public function getDirectoryContent($directory, $recurse=false, $enumerateFiles=true, $enumerateDirs=true, $sortResult=true)
118
+ {
119
+ $result=array();
120
+
121
+ $dirpath=$this->removeTrailingDirectorySeparator($directory);
122
+
123
+ $dir=opendir($dirpath);
124
+ if ($dir)
125
+ {
126
+ while (false !== ($item = readdir($dir)))
127
+ {
128
+ $full_path=$dirpath.DIRECTORY_SEPARATOR.$item;
129
+ if ( ($item==".") || ($item=="..") )
130
+ {
131
+ // Skip
132
+ }
133
+ elseif ( (is_file($full_path)) && ($enumerateFiles) )
134
+ {
135
+ $rvItem=array();
136
+ $rvItem['full_path']=$full_path;
137
+ $rvItem['name']=$item;
138
+ $rvItem['type']="file";
139
+ array_push($result,$rvItem);
140
+ }
141
+ elseif (is_dir($full_path))
142
+ {
143
+ if ($enumerateDirs)
144
+ {
145
+ $rvItem=array();
146
+ $rvItem['full_path']=$full_path;
147
+ $rvItem['name']=$item;
148
+ $rvItem['type']="dir";
149
+ array_push($result,$rvItem);
150
+ }
151
+
152
+ if ($recurse)
153
+ {
154
+ $subresult=$this->getDirectoryContent($full_path,$recurse,$enumerateFiles, $enumerateDirs, false);
155
+ $result=array_merge($result,$subresult);
156
+ }
157
+ }
158
+ }
159
+
160
+ closedir($dir);
161
+ }
162
+
163
+ if ($sortResult)
164
+ {
165
+ usort($result, array($this, "compareFileItems"));
166
+ }
167
+
168
+ return $result;
169
+ }
170
+
171
+ public function extractZip($zipFile, $dstDirectory)
172
+ {
173
+ $dirpath=$this->removeTrailingDirectorySeparator($dstDirectory);
174
+
175
+ $zip = new ZipArchive;
176
+ if ($zip->open($zipFile)!==true)
177
+ {
178
+ return false;
179
+ }
180
+
181
+ $rv=true;
182
+
183
+ if (!$zip->extractTo($dirpath))
184
+ {
185
+ $rv=false;
186
+ }
187
+
188
+ $zip->close();
189
+
190
+ return $rv;
191
+ }
192
+
193
+ public function zipFolder($directory, $zipFile, $comment="")
194
+ {
195
+
196
+ $helper = Mage::helper('eurotext_translationmanager');
197
+ if (!class_exists("ZipArchive"))
198
+ {
199
+ $helper->log('ZipArchive Class does not exist!', Zend_Log::CRIT);
200
+ return false;
201
+ }
202
+
203
+ $dirpath=$this->removeTrailingDirectorySeparator($directory);
204
+ $items=$this->getDirectoryContent($dirpath, true);
205
+
206
+ $mode = file_exists($zipFile) ? ZipArchive::OVERWRITE : ZipArchive::CREATE;
207
+
208
+ $zip = new ZipArchive;
209
+ $zipOpeningResult = $zip->open($zipFile,$mode);
210
+
211
+ if ($zipOpeningResult !== true)
212
+ {
213
+ $helper->log('Could not open ZIP Archive at '.$zipFile.'!', Zend_Log::CRIT);
214
+ $helper->log('Reason: '.print_r($zipOpeningResult, 1), Zend_log::CRIT);
215
+ return false;
216
+ }
217
+
218
+ if ($comment!="")
219
+ {
220
+ $zip->setArchiveComment($comment);
221
+ }
222
+
223
+ foreach($items as $item)
224
+ {
225
+ if ($item['full_path']==$zipFile)
226
+ {
227
+ // Skip
228
+ }
229
+ else
230
+ {
231
+ $inZipPath=substr($item['full_path'],strlen($dirpath)+1);
232
+
233
+ if ($item['type']=="dir")
234
+ {
235
+ $zip->addEmptyDir($inZipPath);
236
+ }
237
+ else
238
+ {
239
+ $zip->addFile($item['full_path'],$inZipPath);
240
+ }
241
+ }
242
+ }
243
+
244
+ $zip->close();
245
+ return true;
246
+ }
247
+ }
app/code/community/Eurotext/TranslationManager/Model/.DS_Store ADDED
Binary file
app/code/community/Eurotext/TranslationManager/Model/Resource/Setup.php ADDED
@@ -0,0 +1,6 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
4
+ {
5
+
6
+ }
app/code/community/Eurotext/TranslationManager/controllers/.DS_Store ADDED
Binary file
app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/.DS_Store ADDED
Binary file
app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/.DS_Store ADDED
Binary file
app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/HelpController.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+
3
+ class Eurotext_TranslationManager_Adminhtml_Eurotext_Translationmanager_HelpController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _isAllowed()
6
+ {
7
+ return Mage::getSingleton('admin/session')
8
+ ->isAllowed('eurotext_translationmanager/help');
9
+ }
10
+
11
+
12
+ public function indexAction()
13
+ {
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+ }
app/code/community/Eurotext/TranslationManager/controllers/Adminhtml/Eurotext/Translationmanager/ProjectsController.php ADDED
@@ -0,0 +1,3240 @@