]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 15 Dec 2010 14:55:43 +0000 (14:55 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 15 Dec 2010 14:55:43 +0000 (14:55 +0000)
inc/config.inc.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Metier/class.ws.parametres.php
index.php

index 5fb2d44417f3dfd7eb46d3357fc135ae0965e464..b338c41c58f5d14de4c7e6318fd186f5f6fc9146 100644 (file)
@@ -65,6 +65,7 @@ define('WS_BOOKS', WS_FILES . '/books');
 define('WS_DOCS', WS_FILES . '/docs');\r
 define('WS_ICONS', WS_FILES . '/icones');\r
 define('WS_THEMES', WS_FILES . '/themes');\r
+define('WS_CACHE', WS_FILES . '/cache');\r
 define('WS_COMPILE_ASSETS', WS_FILES . '/compile');\r
 // define('MINIMIZE_JS', false);\r
 define('WORKER_PREFIX', 'worker.');\r
index 58a93f73efb4ffc24e91f42efd5cc67fc65d364b..e55e10c0aa31c4991d52760865907648d669cd0f 100644 (file)
@@ -33,30 +33,71 @@ class wsServices extends cubeFlashGateway {
                $this->xml->addChild('ok', $mail->send()?'1':'0');\r
        }\r
 \r
-       public function shortenURL()\r
+       protected function shortenURL($url, $id)\r
        {\r
                $bitLyUser = 'fluidbook';\r
                $bitLyKey = 'R_3858dd1c9884d5c6a5fe386d7e95cf1d';\r
                // Recherche dans le cache\r
-               $r = $this->con->select('SELECT * FROM book_short_url WHERE long_url=\'' . $this->con->escape($this->args['url']) . '\' LIMIT 1');\r
+               $r = $this->con->select('SELECT * FROM book_short_url WHERE long_url=\'' . $this->con->escape($url) . '\' LIMIT 1');\r
                if ($r->count() > 0) {\r
                        $this->xml->addChild('shortURL', $r->short_url);\r
                        return;\r
                }\r
                // Si pas dans le cache, on le recherche\r
-               $short_url = cubeURLShortener::bitLy($this->args['url'], $bitLyUser, $bitLyKey);\r
+               $short_url = cubeURLShortener::bitLy($url, $bitLyUser, $bitLyKey);\r
                if (is_null($short_url) || empty($short_url) || !$short_url) {\r
-                       $short_url = cubeURLShortener::tinyURL($this->args['url']);\r
+                       $short_url = cubeURLShortener::tinyURL($url);\r
                }\r
                $short_url = trim($short_url);\r
 \r
                $c = $this->con->openCursor('book_short_url');\r
-               $c->long_url = $this->args['url'];\r
-               $c->book_id = $this->args['id'];\r
+               $c->long_url = $url;\r
+               $c->book_id = $id;\r
                $c->short_url = $short_url;\r
                $c->insert();\r
 \r
-               $this->xml->addChild('shortURL', $short_url);\r
+               return $short_url;\r
+       }\r
+\r
+       /**\r
+        * wsServices::facebook_thumbnail()\r
+        *\r
+        * @return\r
+        */\r
+       public function facebook_thumbnail()\r
+       {\r
+               $this->outputXML = false;\r
+               $dao = new wsDAOBook($this->con);\r
+               $pages = $dao->getPagesOfBook($this->args['id']);\r
+\r
+               $dest = WS_CACHE . '/thumbnails/' . $this->args['id'] . '_' . $pages[1]['document_id'] . '_' . $pages[1]['document_page'] . '.jpg';\r
+               $cover = WS_DOCS . '/' . $pages[1]['document_id'] . '/p' . $pages[1]['document_page'] . '.jpg';\r
+\r
+               if (!file_exists($dest) || filemtime($dest) < filemtime($cover)) {\r
+                       $it = new imageTools();\r
+                       $it->loadImage($cover);\r
+                       $it->resize(130, 110, 'crop', true);\r
+                       $it->output('jpeg', $dest, 90);\r
+               }\r
+\r
+               cubeHTTP::relayFile($dest);\r
+               exit;\r
+       }\r
+\r
+       public function facebookShare()\r
+       {\r
+               http::redirect('http://www.facebook.com/sharer.php?u=' . $this->args['url']);\r
+               exit;\r
+       }\r
+\r
+       public function twitterShare()\r
+       {\r
+               $url = $this->shortenURL($this->args['url'], $this->args['id']);\r
+               $post = str_replace('%short%', $url, $this->args['post']);\r
+               $post = rawurlencode($post);\r
+\r
+               http::redirect('http://twitter.com/?status=' . $post);\r
+               exit;\r
        }\r
 \r
        public function getPDF()\r
index b14d0c7d71f2faf7e21344fc1e78a409efc4276e..943e09eda5134fe78e1f710a49c93e849bd2d624 100644 (file)
@@ -125,6 +125,7 @@ html{height:100%}' . "\n";
                global $css;\r
                global $js;\r
                global $standard;\r
+               global $meta;\r
 \r
                $args = cubePage::getArgs($args);\r
 \r
@@ -152,16 +153,24 @@ html{height:100%}' . "\n";
                $standard = 'XHTML 1.0 Transitional';\r
                $css[] = $webcompile . '/style.css';\r
                cubePage::swfaddress();\r
-\r
-               //$fv = array('base' => WEBROOT . '/fluidbook/books/final/' . $e[0]);\r
+               // $fv = array('base' => WEBROOT . '/fluidbook/books/final/' . $e[0]);\r
                $fv = array();\r
 \r
                $res = '<html>';\r
                $res .= '<head>';\r
-               $res .= '<title>' . $book->nom . '</title>';\r
+               $res .= '<title>' . $book->parametres->title . '</title>';\r
+               if ($book->parametres->facebook) {\r
+                       $meta['og:title'] = ($book->parametres->facebook_title == '')?$book->parametres->title:$book->parametres->facebook_title;\r
+\r
+                       if ($book->parametres->facebook_description != '') {\r
+                               $meta['og:description'] = $book->parametres->facebook_description;\r
+                       }\r
+                       $meta['og:image'] = 'http://dev.ws.fluidbook.com/services/facebook_thumbnail?id=' . $book->book_id;\r
+               }\r
+\r
                $res .= '</head>';\r
                $res .= '<body>';\r
-               $res .= cubeMedia::flash2($webcompile.'index.swf?junk='.TIME, '100%', '100%', $fv, 'fluidbook', '', 10, '#ffffff', '', true);\r
+               $res .= cubeMedia::flash2($webcompile . 'index.swf?junk=' . TIME, '100%', '100%', $fv, 'fluidbook', '', 10, '#ffffff', '', true);\r
                $res .= '</body>';\r
                $res .= '</html>';\r
 \r
index 64a2096f10c04b8ac76b288e867e7e37d7dd50b5..7747f63e80c00daf4c99e9825e49c80c9b1dd19a 100644 (file)
@@ -327,6 +327,9 @@ class wsDAOBook extends extranetDAO {
                $parametres = $book->parametres;\r
                $new = json_decode($settings, false);\r
                foreach($new as $k => $v) {\r
+                       if($k=='_empty_'){\r
+                               continue;\r
+                       }\r
                        $parametres->$k = $v;\r
                }\r
                $c = $this->con->openCursor('books');\r
index bb9aa793701761253f2f7b1846275c8fd2a81d9f..49550537f917236c9e7276e1baf9fa970066af16 100644 (file)
@@ -28,10 +28,17 @@ class wsBookParametres extends wsParametres {
                $this->fields['askAcknowledge'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Demander au destinataire un accusé de réception"), 'extra' => true, 'grade' => 4);\r
                $this->fields['attachPDFInEmail'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Joindre le fichier PDF de la page en cours à l'email"), 'extra' => true, 'grade' => 4);\r
                $this->fields['attachmentName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Nom de la pièce jointe'), 'extra' => true, 'grade' => 4);\r
-               $this->fields['addThis'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Identifiant addThis"), 'extra' => false, 'grade' => 4);\r
-               $this->fields['addThisOptions'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Paramètres addThis"), 'extra' => false, 'grade' => 4);\r
+               // $this->fields['addThis'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Identifiant addThis"), 'extra' => false, 'grade' => 4);\r
+               // $this->fields['addThisOptions'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Paramètres addThis"), 'extra' => false, 'grade' => 4);\r
+               $this->fields['facebook'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Facebook'), 'extra' => false, 'grade' => 1);\r
+               $this->fields['facebook_title'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Titre facebook"), 'extra' => false, 'grade' => 1, 'hint' => __('Titre proposé sur la fonction de partage facebook (par défaut, titre de la publication)'));\r
+               $this->fields['facebook_description'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Description facebook"), 'extra' => false, 'grade' => 1, 'hint' => __('Description proposée sur la fonction de partage facebook (par défaut, vide)'));\r
+               $this->fields['twitter'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Twitter'), 'extra' => false, 'grade' => 1);\r
+               $this->fields['twitter_description'] = array('type' => 'textarea', 'default' => '%title% : %short%', 'editable' => true, 'label' => __("Contenu Twitter"), 'extra' => false, 'grade' => 1, 'hint' => __('Contenu du Twit'));\r
                $this->forms['share'] = array('label' => __('Fonctions de partage'),\r
-                       'fieldsnames' => array('friend', 'email_title', 'email_body', 'email_editable', 'askAcknowledge', 'attachPDFInEmail', 'attachmentName', 'addThis', 'addThisOptions'));\r
+                       'fieldsnames' => array('friend', 'email_title', 'email_body', 'email_editable', 'askAcknowledge', '|',\r
+                               'facebook', 'facebook_title', 'facebook_description', '|',\r
+                               'twitter', 'twitter_description'));\r
                // .\r
                $this->fields['pages'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Nombre de pages'), 'extra' => false, 'grade' => 0);\r
                $this->fields['width'] = array('type' => 'float', 'default' => '', 'editable' => false, 'label' => __('Largeur'), 'extra' => false, 'grade' => 0);\r
index 319df1647b053be6d41d92cd0a6d6a511b82229a..1267868daf2cd849e96f3c5b998c0a249cb379e8 100644 (file)
@@ -25,6 +25,9 @@ class wsParametres extends cubeMetier implements Iterator {
 \r
        public function __set($varname, $value)\r
        {\r
+               if(empty($varname)){\r
+                       return;\r
+               }\r
                $this->set($varname, $value);\r
        }\r
 \r
index cb262771265b537ad2c42b7091960526643cb6b7..0f9b8546fc462ee5787c35fa907ab892f7acd56e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2,6 +2,7 @@
 require_once(dirname(__FILE__) . '/inc/prepend.php');\r
 ob_start();\r
 \r
+$meta=array();\r
 $js[] = JS_PATH . '/common.js';\r
 $js[] = JS_PATH . '/' . MODE . '.js';\r
 $jsvar['IMG'] = IMG;\r
@@ -15,7 +16,7 @@ $buffer = ob_get_contents();
 ob_clean();\r
 \r
 // $css['IE'] = CSS_PATH . '/ie.css';\r
-echo cubePage::page($buffer, $js, $jsvar, $css, array(), 6,false,array(),array(),$standard);\r
+echo cubePage::page($buffer, $js, $jsvar, $css, array(), 6,false,$meta,array(),$standard);\r
 fb($core->debug());\r
 \r
 ?>
\ No newline at end of file