/
txt.php
101 lines (94 loc) · 2.86 KB
/
txt.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
<?php
/**
* @version: $Id: txt.php 4387 2015-02-19 12:24:35Z Radek Suski $
* @package: SobiPro Library
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: http://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2015 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
* @license GNU/LGPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/lgpl.html and http://sobipro.sigsiu.net/licenses.
* This program 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.
* $Date: 2015-02-19 13:24:35 +0100 (Thu, 19 Feb 2015) $
* $Revision: 4387 $
* $Author: Radek Suski $
* $HeadURL: file:///opt/svn/SobiPro/Component/branches/SobiPro-1.1/Site/lib/ctrl/txt.php $
*/
defined( 'SOBIPRO' ) || exit( 'Restricted access' );
SPLoader::loadController( 'controller' );
/**
* @author Radek Suski
* @version 1.0
* @created 15-Jul-2010 18:17:28
*/
class SPJsTxt extends SPController
{
/**
* @var string
*/
protected $_defTask = 'js';
public function __construct()
{
}
/**
*/
public function execute()
{
$this->_task = strlen( $this->_task ) ? $this->_task : $this->_defTask;
switch ( $this->_task ) {
case 'js':
$this->js();
break;
case 'messages':
$this->messages();
break;
case 'translate':
$this->translate();
break;
}
}
protected function translate()
{
$term = Sobi::Txt( SPRequest::cmd( 'term' ) );
Sobi::Trigger( 'Translate', 'Text', array( &$term ) );
SPFactory::mainframe()
->cleanBuffer()
->customHeader();
echo json_encode( array( 'translation' => $term ) );
exit;
}
protected function messages()
{
$messages = SPFactory::message()->getReports( SPRequest::cmd( 'spsid' ) );
$response = array();
if ( count( $messages ) ) {
foreach ( $messages as $type => $content ) {
if ( count( $content ) ) {
foreach ( $content as $message ) {
$response[ ] = array( 'type' => $type, 'text' => $message );
}
}
}
}
$this->response( null, null, false, SPC::INFO_MSG, array( 'messages' => $response ) );
}
protected function js()
{
$lang = SPLang::jsLang();
if ( count( $lang ) ) {
foreach ( $lang as $term => $text ) {
unset( $lang[ $term ] );
$term = str_replace( 'SP.JS_', null, $term );
$lang[ $term ] = $text;
}
}
if ( !( SPRequest::int( 'deb' ) ) ) {
SPFactory::mainframe()->cleanBuffer();
header( 'Content-type: text/javascript' );
}
echo 'SobiPro.setLang( ' . json_encode( $lang ) . ' );';
exit;
}
}