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
$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
global $css;\r
global $js;\r
global $standard;\r
+ global $meta;\r
\r
$args = cubePage::getArgs($args);\r
\r
$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
$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
$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
\r
public function __set($varname, $value)\r
{\r
+ if(empty($varname)){\r
+ return;\r
+ }\r
$this->set($varname, $value);\r
}\r
\r
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
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