[270489] Need a simple MOTD functionality
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 0000000..f0aa4f0
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1 @@
+base.conf
diff --git a/addons/.cvsignore b/addons/.cvsignore
new file mode 100644
index 0000000..5b6b749
--- /dev/null
+++ b/addons/.cvsignore
@@ -0,0 +1 @@
+addons.conf
diff --git a/babel-setup.sql b/babel-setup.sql
index 47b912f..08fdf35 100644
--- a/babel-setup.sql
+++ b/babel-setup.sql
@@ -49,6 +49,32 @@
KEY `project_id` (`project_id`),
CONSTRAINT `files_ibfk_1` FOREIGN KEY (`project_id`,`version`) REFERENCES `project_versions` (`project_id`,`version`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+SET @OLD_SQL_MODE=@@SQL_MODE;
+DELIMITER ;;
+/*!50003 SET SESSION SQL_MODE="" */;;
+DROP TRIGGER IF EXISTS `upd_is_active`;;
+
+/* This trigger will recursively update the is_active status of the strings of a file */
+CREATE TRIGGER `upd_is_active` AFTER UPDATE ON `files` FOR EACH ROW BEGIN
+ UPDATE strings set is_active = NEW.is_active WHERE strings.file_id = NEW.file_id;
+
+ /* update project_progress table to indicate this proj/lang/vers stats are stale */
+ /* don't know if record is there or not, so do both an insert and an update */
+ /* This portion of the trigger is similar to what is in the translations table */
+ UPDATE IGNORE project_progress SET is_stale = 1 where project_id = @PROJECT
+ AND version = @VERSION;
+
+ INSERT IGNORE INTO project_progress SET is_stale = 1, project_id = @PROJECT,
+ version = @VERSION;
+
+END;
+;;
+DELIMITER ;
+/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;
+
+
--
-- Table structure for table `languages`
--
@@ -213,7 +239,15 @@
;;
DELIMITER ;
-
+--
+-- Table structure for table `sys_values`
+--
+DROP TABLE IF EXISTS `sys_values`;
+CREATE TABLE `sys_values` (
+ `itemid` char(6) NOT NULL,
+ `value` text,
+ PRIMARY KEY (`itemid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `translation_archives`
@@ -304,6 +338,7 @@
/* update project_progress table to indicate this proj/lang/vers stats are stale */
/* don't know if record is there or not, so do both an insert and an update */
+ /* This portion of the trigger is similar to what is in the files table */
UPDATE IGNORE project_progress SET is_stale = 1 where project_id = @PROJECT
AND version = @VERSION
AND language_id = NEW.language_id;
@@ -522,4 +557,7 @@
truncate table scoreboard;
INSERT INTO scoreboard SELECT NULL, "LANGPR", CONCAT(b.name,IF(ISNULL(b.locale),"",CONCAT(" ", b.locale))), count(*) as StringCount from translations as a inner join languages as b on b.language_id = a.language_id where a.value <> '' and a.is_active = 1 group by a.language_id order by StringCount desc;
INSERT INTO scoreboard SELECT NULL, "TOPTR", CONCAT(first_name, IF(ISNULL(last_name),"",CONCAT(" ", last_name))), count(translations.string_id) as cnt from translations inner join users on users.userid = translations.userid where is_active=1 group by first_name, last_name order by cnt desc limit 20;
-INSERT INTO scoreboard SELECT NULL, "LASGEN", "Scoreboard Last Generated", MAX(translation_id) FROM translations;
\ No newline at end of file
+INSERT INTO scoreboard SELECT NULL, "LASGEN", "Scoreboard Last Generated", MAX(translation_id) FROM translations;
+
+/* create a holding record for the MOTD */
+INSERT INTO sys_values VALUES ("MOTD", NULL);
\ No newline at end of file
diff --git a/classes/export/syncup.php b/classes/export/syncup.php
index 1fcb99a..da8839d 100644
--- a/classes/export/syncup.php
+++ b/classes/export/syncup.php
@@ -42,7 +42,14 @@
$language_id = $lang_row['language_id'];
echo "Investigating language " . $language_id . "\n\n";
$untranslated_strings = mysql_query( "SELECT * from strings where is_active and value <> '' and string_id not in(select string_id from translations where language_id=". $language_id .")" );
+ $count = 0;
while ( ($string_row = mysql_fetch_assoc($untranslated_strings)) != null) {
+ $count++;
+
+ if($count % 100 == 0) {
+ echo "Processed " . $count . " strings...\n";
+ }
+
$untranslated_value = $string_row['value'];
$untranslated_id = $string_row['string_id'];
$possible_translations = mysql_query( "SELECT t.value from strings As s inner join translations AS t on s.string_id = t.string_id where s.string_id != '" . $untranslated_id . "' and BINARY s.value = '" .$untranslated_value . "' and t.language_id = '" . $language_id . "' ");
diff --git a/html/babel.css b/html/babel.css
index 50c90b3..9bf03c4 100644
--- a/html/babel.css
+++ b/html/babel.css
@@ -1092,6 +1092,16 @@
text-decoration: underline;
}
+#motd {
+ position: relative;
+ width: 700px;
+ margin: 10px auto 10px auto;
+ border: 1px solid darkred;
+ background-color: LightGoldenRodYellow;
+ padding: 3px;
+ }
+
+
#trans-progress-area{
position: absolute;
left: auto;
diff --git a/html/fragments/motd.php b/html/fragments/motd.php
new file mode 100644
index 0000000..e2db98c
--- /dev/null
+++ b/html/fragments/motd.php
@@ -0,0 +1,24 @@
+<?php
+/*******************************************************************************
+ * Copyright (c) 2009 Eclipse Foundation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eclipse Foundation - initial API and implementation
+*******************************************************************************/
+
+require_once("frag_global.php");
+
+$query = "SELECT value FROM sys_values WHERE itemid = 'MOTD' AND value IS NOT NULL AND value <> '' LIMIT 1";
+
+if ($res = mysql_query($query)) {
+ if ($row = mysql_fetch_assoc($res)) {
+ echo "<div id='motd'>";
+ echo $row['value'];
+ echo "</div>";
+ }
+}
+?>
\ No newline at end of file
diff --git a/html/index.php b/html/index.php
index 3ac3c8b..ee57c88 100644
--- a/html/index.php
+++ b/html/index.php
@@ -18,13 +18,13 @@
global $addon;
$addon->callHook("head");
-
?>
<h1 id="page-message">Welcome to the Babel Project</h1>
+<? include("fragments/motd.php");?>
<div id="index-page" style='width: 510px; padding-right: 190px;'>
<div style='float: right;height: 290px; border: 0px solid red;'>
<? include("fragments/language_progress.php");?>
- <? include("fragments/top_translators.php");?>
+ <? include("fragments/top_translators.php");?>
</div>
<div style='float: left;border: 0px solid red;'>
diff --git a/html/translate.php b/html/translate.php
index b6f07f1..f9c7081 100644
--- a/html/translate.php
+++ b/html/translate.php
@@ -51,6 +51,7 @@
?>
<h1 id="page-message">Welcome to the Babel Project</h1>
+<? include("fragments/motd.php");?>
<div id="contentArea">
<h2>Languages / Projects / Versions / Files</h2>