]> _ Git - cubeextranet.git/commitdiff
#fluidbook-workshop : add support of phone link on html5 Fluidbook
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 26 Jan 2016 13:28:22 +0000 (13:28 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 26 Jan 2016 13:28:22 +0000 (13:28 +0000)
inc/config.inc.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Util/html5/class.ws.html5.links.php

index 6da0ea772b68e6c59ffe165e5dc63cbd2b026c11..1da341abefa600d8db6b9fc705651c9a06181ef0 100644 (file)
@@ -5,7 +5,7 @@ define('DB_ENGINE', 'MyISAM');
 
 $scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http';
 
-define('ROOT', dirname(__FILE__) . '/..');
+define('ROOT', realpath(dirname(__FILE__) . '/..'));
 
 define('WEBROOT', '');
 define('SITE_PATH', WEBROOT . '/');
index 884fa78c2d645faed199fe69b0b35948010e1f55..015a33fd0ab33669551c3a3e73e9afbdd5a9d45f 100644 (file)
@@ -107,7 +107,7 @@ class wsMaintenance {
                                try {
                                        $c->insert();
                                } catch (Exception $e) {
-// fb($e);
+                                       // fb($e);
                                }
                        }
                }
@@ -115,11 +115,11 @@ class wsMaintenance {
 
        public static function importFromOldWS($args) {
                global $core;
-// Import des fluidbooks
-// Donc le dernier importé est le max dont le numéro est inférieur Ã  10000
+               // Import des fluidbooks
+               // Donc le dernier importé est le max dont le numéro est inférieur Ã  10000
                $r = $core->con->select('SELECT MAX(book_id) AS book_id FROM books WHERE book_id<10000');
                $lastImported = $r->book_id;
-// On recherche maintenant les fluidbook dans la vieille base
+               // On recherche maintenant les fluidbook dans la vieille base
                $r = $core->con->select('SELECT bid FROM ws.book WHERE bid>' . $lastImported);
                $oldBooks = array();
                while ($r->fetch()) {
@@ -137,7 +137,7 @@ class wsMaintenance {
 
        public static function importLangs($oldBooks) {
                global $core, $allTrads, $trads;
-// On regarde d'abord les langues que nous avons déjà
+               // On regarde d'abord les langues que nous avons déjà
                $r = $core->con->select('SELECT lang_id FROM langues');
                $already = array();
                while ($r->fetch()) {
@@ -199,7 +199,7 @@ class wsMaintenance {
 
                $r = $core->con->select('SELECT MAX(theme_id) AS theme_id FROM themes WHERE theme_id<1000');
                $lastImported = $r->theme_id;
-// Import des thèmes
+               // Import des thèmes
                $r = $core->con->select('SELECT * FROM ws.theme WHERE tid IN (SELECT tid FROM ws.book WHERE bid ' . self::_sqlIn($oldBooks) . ') AND tid>' . $lastImported);
                $theme = new wsTheme();
                while ($r->fetch()) {
@@ -228,7 +228,7 @@ class wsMaintenance {
 
        public static function importDocs($oldBooks) {
                global $core;
-// On cherche maintenant Ã  savoir si l'on doit importer de nouveaux documents associés
+               // On cherche maintenant Ã  savoir si l'on doit importer de nouveaux documents associés
                $oldDocuments = array();
                $r = $core->con->select('SELECT DISTINCT did FROM ws.book_pages WHERE bid ' . self::_sqlIn($oldBooks) . '');
                while ($r->fetch()) {
@@ -282,12 +282,12 @@ class wsMaintenance {
 
        public static function importBooks($oldBooks) {
                global $core, $allTrads, $signatures;
-// Importe les fluidbooks
+               // Importe les fluidbooks
                $r = $core->con->select('SELECT * FROM ws.book WHERE bid ' . self::_sqlIn($oldBooks) . ' ORDER BY bid');
                if (!$r->count()) {
                        return;
                }
-// .
+               // .
                while ($r->fetch()) {
                        $c = $core->con->openCursor('books');
                        $c->book_id = $r->bid;
@@ -318,12 +318,12 @@ class wsMaintenance {
                        }
 
                        $n = array();
-// Pages sans numéro
+                       // Pages sans numéro
                        $offset = $r->first_page_nr - 1;
                        for ($i = 0; $i < $offset; $i++) {
                                $n[] = '';
                        }
-// Pages avec numero
+                       // Pages avec numero
                        for ($j = 1; $j + $offset <= $r->pages; $j++) {
                                $n[] = $j;
                        }
@@ -336,7 +336,7 @@ class wsMaintenance {
                        $c->version = 1;
                        $c->insert();
                }
-// Import des pages
+               // Import des pages
                $core->con->execute('INSERT INTO book_pages (book_id,book_page,document_id,document_page) SELECT bid,bpid,did,dpid FROM ws.book_pages WHERE bid ' . self::_sqlIn($oldBooks));
 
                $dao = new wsDAOBook($core->con);
@@ -389,7 +389,7 @@ class wsMaintenance {
        protected static function _getAllUsers() {
                global $core, $entreprises, $entreprise_id, $utilisateurs_entreprises, $utilisateur_id, $ws2ext, $grades, $utilisateurs;
                $grades = array(0 => 1, 0.4 => 1, '0.4' => 1, 0.5 => 1, '0.5' => 1, 1 => 1, 2 => 2, 3 => 3, 4 => 5);
-// Contrôle des entreprises déjà dans la base extranet
+               // Contrôle des entreprises déjà dans la base extranet
                $entreprises = array();
                $entreprise_id = 0;
                $r = $core->con->select('SELECT entreprise_id,nom FROM entreprises');
@@ -407,7 +407,7 @@ class wsMaintenance {
                }
 
                $entreprise_id++;
-// Obtient les emails des utilisateurs
+               // Obtient les emails des utilisateurs
                $utilisateur_id = 0;
                $utilisateurs = array();
                $r = $core->con->select('SELECT utilisateur_id,email FROM utilisateurs');
@@ -426,13 +426,13 @@ class wsMaintenance {
 
        protected static function _importOldUser($oldid) {
                global $core, $entreprises, $entreprise_id, $utilisateurs_entreprises, $utilisateur_id, $ws2ext, $grades, $utilisateurs;
-// Get user from old
+               // Get user from old
                $r = $core->con->select('SELECT * FROM ws.user WHERE uid=\'' . $core->con->escape($oldid) . '\'');
                if ($r->extranet != 0) {
                        $ws2ext[$r->uid] = $r->extranet;
                        return;
                }
-// On s'occupe de l'entreprise
+               // On s'occupe de l'entreprise
                $email = trim(mb_strtolower($r->email));
 
                $rs = trim($r->rs);
@@ -473,7 +473,7 @@ class wsMaintenance {
                        $c->ws_admin = self::_getWsUser($r->admin);
                        $c->update('WHERE entreprise_id=\'' . $e . '\'');
                }
-// Puis de l'utilisateur
+               // Puis de l'utilisateur
                if (isset($utilisateurs[$email])) {
                        $c = $core->con->openCursor('utilisateurs');
                        $c->ws_password = $r->password;
@@ -524,12 +524,12 @@ class wsMaintenance {
 
        public static function cleanPackages() {
                $limit = TIME - (4 * 3600); // 4 heures avant maintenant*
-//
+               //
                $dirs = array(ROOT . '/cache/download',
-                       WS_FILES . '/packager/download/',
-                       WS_FILES . '/packager/',
-                       '/home/ws/www/download');
-// Clean downloads
+                             WS_FILES . '/packager/download/',
+                             WS_FILES . '/packager/',
+                             '/home/ws/www/download');
+               // Clean downloads
 
                foreach ($dirs as $dir) {
                        if (!file_exists($dir)) {
@@ -588,6 +588,41 @@ class wsMaintenance {
                                echo $rm->commande . "<br />";
                        }
                }
+
+               $docs = array();
+               $dr = opendir(WS_DOCS);
+               while ($d = readdir($dr)) {
+                       if ($d == '.' || $d == '..') {
+                               continue;
+                       }
+                       $d = intval($d);
+                       if (!$d) {
+                               continue;
+                       }
+                       $docs[] = intval($d);
+               }
+
+               sort($docs);
+               $docs = array_splice($docs, 0, count($docs) - 1000);
+               if (count($docs)) {
+                       $toMove = array_slice($docs, 0, 250);
+
+                       foreach ($toMove as $d) {
+                               if (trim($d) == '') {
+                                       continue;
+                               }
+                               $source = WS_DOCS . '/' . $d . '/';
+                               $dest = '/mnt/sshfs/batman' . WS_DOCS . '/' . $d . '/';
+                               if (!file_exists($dest)) {
+                                       mkdir($dest, 0777, true);
+                               }
+                               $rsync = "rsync -av $source $dest";
+                               $rm = "rm -rf $source";
+                               `$rsync;$rm`;
+                               echo $rsync . "\n";
+                               echo $rm . "\n";
+                       }
+               }
        }
 
        public static function moveFluidbookDatas() {
@@ -816,7 +851,7 @@ class wsMaintenance {
                        }
                }
                $res = 'test';
-               $res.='</pre>';
+               $res .= '</pre>';
 
                ldap_close($ds);
                return $res;
@@ -887,10 +922,10 @@ class wsMaintenance {
 
                $newlinks = array();
                foreach ($links as $link) {
-                       $link['left']-=1;
-                       $link['top']+=1;
-                       $link['width']+=5;
-                       $link['height']+=3;
+                       $link['left'] -= 1;
+                       $link['top'] += 1;
+                       $link['width'] += 5;
+                       $link['height'] += 3;
                        $newlinks[] = $link;
                }
 
@@ -922,7 +957,7 @@ class wsMaintenance {
                }
                $newlinks = array();
                foreach ($links as $link) {
-                       $link[$k]+=$value;
+                       $link[$k] += $value;
                        $newlinks[] = $link;
                }
 
@@ -961,7 +996,7 @@ class wsMaintenance {
 
                $dir = WS_BOOKS . '/index/' . $book->book_id;
                if ($book->parametres->ignoreSearchSeparators != '') {
-                       $dir.='/' . sha1($book->parametres->ignoreSearchSeparators);
+                       $dir .= '/' . sha1($book->parametres->ignoreSearchSeparators);
                }
 
                $prefixes = array('', 'p');
index 0f7e4ac94faf7999b52ad5e0b669cb6aa6522aed..a0a4fe05ff15660fc5bf50b628397f811511902e 100644 (file)
@@ -110,6 +110,9 @@ class wsHTML5Link {
                        case 23:
                                return new statsTagLink($id, $init, $compiler);
                                break;
+                       case
+                               24:
+                               return new phoneLink($id, $init, $compiler);
                        default:
                                return null;
                }
@@ -425,6 +428,22 @@ class mailLink extends normalLink {
 
 }
 
+class phoneLink extends mailLink {
+
+       public function getURL() {
+               return 'tel:' . $this->to;
+       }
+
+       public function getTarget() {
+               return '_blank';
+       }
+
+       public function getDefaultTooltip() {
+               return 'click to call this number';
+       }
+
+}
+
 class internalLink extends normalLink {
 
        public function getURL() {