Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
6ea98bf3
Commit
6ea98bf3
authored
Jan 17, 2014
by
Digimon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format fixed, substr changed to mb_substr, database-related settings added
parent
48eb4c26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
MessageController.php
framework/console/controllers/MessageController.php
+8
-8
No files found.
framework/console/controllers/MessageController.php
View file @
6ea98bf3
...
@@ -92,15 +92,15 @@ class MessageController extends Controller
...
@@ -92,15 +92,15 @@ class MessageController extends Controller
throw
new
Exception
(
"The source path
{
$config
[
'sourcePath'
]
}
is not a valid directory."
);
throw
new
Exception
(
"The source path
{
$config
[
'sourcePath'
]
}
is not a valid directory."
);
}
}
if
(
in_array
(
$config
[
'format'
],
[
'php'
,
'po'
]))
{
if
(
in_array
(
$config
[
'format'
],
[
'php'
,
'po'
]))
{
if
(
!
is_dir
(
$config
[
'messagePath'
]))
{
if
(
!
is_dir
(
$config
[
'messagePath'
]))
{
throw
new
Exception
(
"The message path
{
$config
[
'messagePath'
]
}
is not a valid directory."
);
throw
new
Exception
(
"The message path
{
$config
[
'messagePath'
]
}
is not a valid directory."
);
}
}
}
}
if
(
empty
(
$config
[
'languages'
]))
{
if
(
empty
(
$config
[
'languages'
]))
{
throw
new
Exception
(
"Languages cannot be empty."
);
throw
new
Exception
(
"Languages cannot be empty."
);
}
}
if
(
empty
(
$config
[
'format'
])
||
!
in_array
(
$config
[
'format'
],
[
'php'
,
'po'
,
'db'
]))
{
if
(
empty
(
$config
[
'format'
])
||
!
in_array
(
$config
[
'format'
],
[
'php'
,
'po'
,
'db'
]))
{
throw
new
Exception
(
'Format should be either "php", "po" or "db".'
);
throw
new
Exception
(
'Format should be either "php", "po" or "db".'
);
}
}
$files
=
FileHelper
::
findFiles
(
realpath
(
$config
[
'sourcePath'
]),
$config
);
$files
=
FileHelper
::
findFiles
(
realpath
(
$config
[
'sourcePath'
]),
$config
);
...
@@ -135,7 +135,7 @@ class MessageController extends Controller
...
@@ -135,7 +135,7 @@ class MessageController extends Controller
$res
=
[];
$res
=
[];
foreach
(
$config
[
'languages'
]
as
$language
)
{
foreach
(
$config
[
'languages'
]
as
$language
)
{
foreach
(
$messages
as
$category
=>
$msgs
)
{
foreach
(
$messages
as
$category
=>
$msgs
)
{
$res
[
$category
]
=
$msgs
;
$res
[
$category
]
=
$msgs
;
}
}
}
}
$this
->
saveMessagesToDb
(
$this
->
saveMessagesToDb
(
...
@@ -153,8 +153,8 @@ class MessageController extends Controller
...
@@ -153,8 +153,8 @@ class MessageController extends Controller
* @param $sourceMessageTable
* @param $sourceMessageTable
* @param $removeUnused
* @param $removeUnused
*/
*/
protected
function
saveMessagesToDb
(
$messages
,
$dbConnection
,
$sourceMessageTable
,
$removeUnused
)
protected
function
saveMessagesToDb
(
$messages
,
$dbConnection
,
$sourceMessageTable
,
$removeUnused
)
{
{
$q
=
new
\yii\db\Query
;
$q
=
new
\yii\db\Query
;
$current
=
[];
$current
=
[];
...
@@ -182,7 +182,7 @@ class MessageController extends Controller
...
@@ -182,7 +182,7 @@ class MessageController extends Controller
if
(
!
$removeUnused
)
{
if
(
!
$removeUnused
)
{
foreach
(
$obsoleted
as
$pk
=>
$m
)
{
foreach
(
$obsoleted
as
$pk
=>
$m
)
{
if
(
substr
(
$m
,
0
,
2
)
===
'@@'
&&
substr
(
$m
,
-
2
)
===
'@@'
)
{
if
(
mb_substr
(
$m
,
0
,
2
)
===
'@@'
&&
mb_
substr
(
$m
,
-
2
)
===
'@@'
)
{
unset
(
$obsoleted
[
$pk
]);
unset
(
$obsoleted
[
$pk
]);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment