]> _ Git - cubeextranet.git/commitdiff
#1505
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 27 Jun 2017 15:17:42 +0000 (15:17 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 27 Jun 2017 15:17:42 +0000 (15:17 +0000)
inc/commons/class.common.tools.php
inc/ws/Metier/class.ws.book.parametres.php

index 00133fb7e550bf1e597fbfeebf6f808018fa7879..635b14cb078de65980768c0161d45a4e36d5384e 100644 (file)
@@ -998,6 +998,89 @@ class commonTools {
                }
        }
 
+       public static function SNCFCodes() {
+               //commonDroits::min(1);
+               global $core;
+               $res = commonPage::barre();
+               $res .= commonPage::tMain();
+               $res .= commonPage::bh();
+               $res .= '<form action="' . SITE_PATH . 'tools/makeSNCFCodes" method="post" class="notajax" enctype="multipart/form-data">';
+               $res .= '<table class="liste">';
+               $res .= '<tr><th colspan="2"><strong>' . __('Générer dictionnaires de liens pour fluidbook SNCF') . '</strong></th></tr>';
+               $res .= '<tr><td>' . __("Email") . '</td><td><input type="file" name="file" /></td></tr>';
+               $res .= '<tr><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Générer les dictionnaires')) . '</a></td></td>';
+               $res .= '</table>';
+               $res .= '</form>';
+               $res .= commonPage::bf();
+
+               $res .= commonPage::bMain();
+               return $res;
+               $res .= commonPage::bMain();
+               return $res;
+       }
+
+       public static function makeSNCFCodes() {
+               $list = explode("\n", file_get_contents($_FILES['file']['tmp_name']));
+               $labels = [];
+               $links = [];
+
+               foreach ($list as $item) {
+                       $item = trim($item);
+                       if ($item == '') {
+                               continue;
+                       }
+                       $labels[] = ['word' => $item, 'action' => ['type' => 'definelabel', 'action' => $item]];
+                       $links[] = ['word' => $item, 'action' => ['type' => 'gotolabel', 'action' => $item]];
+               }
+
+               ob_end_clean();
+
+               header('Content-type: application/zip');
+               header('Content-Disposition: attachment; filename="sncf.zip"');
+
+               $zip = new ZipArchive();
+               $zip->open('/tmp/sncf', ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
+               $zip->addFromString('labels.ald', self::_listToALD($labels));
+               $zip->addFromString('links.ald', self::_listToALD($links));
+               $zip->close();
+
+               echo file_get_contents('/tmp/sncf');
+
+               exit;
+       }
+
+       public static function _listToALD($list) {
+               $res = '<</Link [/c <<  /Desc [/t (AutoBookmark Link Dictionary File)]
+       /Entries [/c <<         ';
+               foreach ($list as $k => $item) {
+                       $res .= '/' . $k . ' [/c <<                     /code [/t (' . self::_actionToALDCode($item['action']) . ')]
+                       /word [/t (' . addcslashes($item['word'], "\\") . ')]
+>>]
+               ';
+               }
+
+
+               $res .= '
+>>]
+       /Name [/t (Dictionary)]
+>>]
+>>';
+
+               return $res;
+       }
+
+       public static function _actionToALDCode($action) {
+               if ($action['type'] == 'gotolabel') {
+                       return '@' . $action['action'];
+               } elseif ($action['type'] == 'uri') {
+                       return 'uri:' . $action['action'];
+               } else if ($action['type'] == 'definelabel') {
+                       return 'uri:pagelabel:' . $action['action'];
+               } else if ($action['type'] == 'page') {
+                       return $action['action'] . ',InheritZoom';
+               }
+       }
+
        public static function proxy() {
                ob_end_clean();
                echo file_get_contents($_GET['url']);
index 2c29c8c127f5c55124392ad856d5beb1be76930e..b56819848aa34594de73228668e4ef232806803f 100644 (file)
@@ -123,7 +123,7 @@ class wsBookParametres extends wsParametres {
                $this->fields['tooltipTimer'] = array('type' => 'float', 'default' => 3, "editable" => true, 'label' => __("Temps maximum d'apparition des infos-bulles (en secondes)"));
 
                $this->forms['general'] = array('label' => __('Fonctionnalités générales'),
-                                               'fieldsnames' => array('navOrder', 'tooltipTimer','preload', 'pages', 'width', 'height'));
+                                               'fieldsnames' => array('navOrder', 'tooltipTimer', 'preload', 'pages', 'width', 'height'));
                //.
                //
 
@@ -380,8 +380,9 @@ class wsBookParametres extends wsParametres {
 
                $this->fields['secureURL'] = array('type' => 'text', 'default' => 'http://', 'editable' => true, 'label' => __('URL de sécurisation'), 'grade' => 5, 'hint' => __('URL intérrogé pour vérifier si le visiteur à les droits pour consulter la publication'));
                $this->fields['secureURLRedirect'] = array('type' => 'text', 'default' => 'http://', 'editable' => true, 'label' => __('Redirection'), 'grade' => 5, 'hint' => __("Si l'authentification échoue, redirection vers cette adresse"));
+               $this->fields['preventRightClick'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Essayer d'empêcher le clic droit"), 'grade' => 1);
                $this->forms['secure'] = array('label' => __('Sécurisation'),
-                                              'fieldsnames' => array('secureURL', 'secureURLRedirect'));
+                                              'fieldsnames' => array('secureURL', 'secureURLRedirect', '|', 'preventRightClick'));
 
                $this->fields['seoVersion'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Générer une version pour les moteurs de recherche'));
                $this->fields['seoRobots'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Autoriser le parcours par les moteurs de recherche'));