\r
define('JS_PATH', WEBROOT . '/js');\r
define('JS', JS_PATH);\r
+define('MINIMIZE_JS',false);\r
\r
define('JOURNEE', 8);\r
define('TAUX_JOURNALIER', 500);\r
public static function saveCollection($args, &$x) {\r
global $core;\r
$dao = new wsDAOCollection($core->con);\r
- $dao->sauve($_POST);\r
+ $dao->sauve($_POST, $core->user->utilisateur_id);\r
\r
$x->addClosePopup();\r
$x->addContent('listeCollections', wsUrl::listeCollections());\r
}\r
\r
+ public static function saveCollectionComposition($args, &$x) {\r
+ global $core;\r
+ $dao = new wsDAOCollection($core->con);\r
+\r
+ $save = array('nom' => $_POST['nom'],\r
+ 'collection_id' => $_POST['collection_id']);\r
+\r
+ $datas = array();\r
+ foreach ($_POST['group'] as $gid => $group) {\r
+ if ($gid && $gid == '_new') {\r
+ continue;\r
+ }\r
+\r
+ if (isset($group['publications'])) {\r
+ $publications = array();\r
+ foreach ($group['publications'] as $pid => $publication) {\r
+ $publication = array('id' => $publication['id'], 'label' => $publication['label'], 'online' => isset($publication['online']));\r
+ $publications[] = $publication;\r
+ }\r
+ $group['publications'] = $publications;\r
+ } else {\r
+ $group['publications'] = array($dao->_emptyPublication);\r
+ }\r
+\r
+ $datas[] = $group;\r
+ }\r
+ if (count($datas) == 0) {\r
+ $datas = $dao->_emptyCollection();\r
+ }\r
+ \r
+ fb($datas);\r
+ \r
+ $save['datas'] = $datas;\r
+ $dao->sauve($save);\r
+\r
+ //$x->addReload();\r
+ }\r
+\r
public static function changeBookProprietaire($args, &$x) {\r
return self::_changeProprietaire('book', $args[1], $_POST['proprietaire'], $x);\r
}\r
global $core;\r
commonDroits::min(1);\r
cubePage::ui('Sortable');\r
+ cubePage::autocomplete();\r
//cubePage::checkbox();\r
\r
$dao = new wsDAOCollection($core->con);\r
public static function collectionEdit($collection) {\r
global $core;\r
\r
- $res = '<ul>';\r
- $res.='<h1>Gestion de la collection « ' . $collection->nom . ' » <em># ' . $collection->collection_id . '</em></h1>';\r
+ $res = '<h1>Gestion de la collection « ' . $collection->nom . ' » <em># ' . $collection->collection_id . '</em></h1>';\r
+ $res.='<form method="post" action="saveCollectionComposition">';\r
+ $res.='<table class="max">';\r
+ $res.='<tr><td class="min nowrap">#</td><td>' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '</td></tr>';\r
+ $res.='<tr><td class="min nowrap">' . __('Nom de la collection') . '</td><td>' . form::field('nom', 20, 64, $collection->nom) . '</td></tr>';\r
+\r
+ $res.='</table>';\r
+ $res.='<h3>Composition</h3>';\r
+ $res .= '<ul>';\r
+\r
\r
$dao = new wsDAOCollection($core->con);\r
$books = $dao->getPublications($collection->collection_id);\r
\r
foreach ($datas as $gid => $group) {\r
$class = 'group';\r
- if ($gid == 'new_') {\r
+ if ($gid && $gid == 'new_') {\r
$class.=' empty';\r
}\r
- $res.='<li class="group">';\r
+ $res.='<li class="' . $class . '">';\r
$res.='<div class="g">';\r
$res.='<a href="#" class="move"></a>';\r
$g = 'group[' . $gid . ']';\r
$res.=__('Nom du groupe') . ' ' . form::field(array($g . '[label]'), 20, 64, $group['label']);\r
+ $res.='<a href="#" class="delete"></a>';\r
$res.='</div>';\r
$res.='<ul>';\r
+ $res.='<li style="height:2px;"></li>';\r
foreach ($group['publications'] as $pid => $publication) {\r
$p = $g . '[publication][' . $pid . ']';\r
$res.='<li class="publication"><div>';\r
}\r
$res.='<a href="#" class="move"></a>';\r
$res.=mb_strtoupper($book->lang);\r
- $res.='<span class="id"># ' . form::field($p . '[id]', 20, 64, $publication['id']) . '</span>';\r
- $res.='<span class="label">' . __('Label') . ' ' . form::field($p . '[label]', 20, 64, $publication['label']) . '</span>';\r
+ $res.='<span class="id"># ' . form::field(array($p . '[s]'), 64, 256, trim($publication['id'] . ' - ' . $book->nom, ' -'), 'publication_id') . form::hidden(array($p . '[id]'), $publication['id']) . '</span>';\r
+ $res.='<span class="label">' . __('Label') . ' ' . form::field(array($p . '[label]'), 20, 64, $publication['label']) . '</span>';\r
$res.='<a href="#" class="delete"></a>';\r
$res.='<a href="#" class="add"></a>';\r
- $res.='<span class="online">' . form::checkbox($p . '[online]', '1', $publication['online']) . '</span>';\r
+ $res.='<span class="online">' . form::checkbox(array($p . '[online]'), '1', $publication['online']) . '</span>';\r
$res.='</div></li>';\r
}\r
$res.='</ul>';\r
$res.='</li>';\r
}\r
$res.='</ul>';\r
+ $res.='<a href="#" class="submit right">' . $core->typo->Ajouter(__('Enregistrer')) . '</a>';\r
+ $res.='</form>';\r
+ $res.='<p class="clear"></p>';\r
return $res;\r
}\r
\r
global $core;\r
\r
cubePage::truePopup();\r
- cubePage::autocomplete();\r
+ \r
$droits = wsDroits::getDroits();\r
\r
commonDroits::min(3);\r
}\r
$parametres->$k = $v;\r
}\r
+\r
+ $ip = array();\r
+ if (isset($parametres->stats_exclude_ip) && trim($parametres->stats_exclude_ip) != '') {\r
+ $list = $parametres->stats_exclude_ip;\r
+ $list = str_replace("\r", "\n", $list);\r
+ $e = explode("\n", $list);\r
+ foreach ($e as $i) {\r
+ $i = trim($i);\r
+ if ($i == '') {\r
+ continue;\r
+ }\r
+ $long = ip2long($i);\r
+ if ($long !== false) {\r
+ $ip[] = $long;\r
+ }\r
+ }\r
+ }\r
+\r
+ $file = '/home/stats/www/exclude/' . $book_id;\r
+ \r
+ if (count($ip)) {\r
+ file_put_contents($file, implode(',', $ip));\r
+ chmod($file, 0777);\r
+ chown($file, 'stats');\r
+ } else if (file_exists($file)) {\r
+ unlink($file);\r
+ }\r
+\r
$c = $this->con->openCursor('books');\r
$c->nom = $parametres->title;\r
$c->parametres = serialize($parametres);\r
return $collection;
}
- protected function _emptyCollection() {
+ public function _emptyCollection() {
return array($this->_emptyGroup());
}
return array('label' => '', 'publications' => array($this->_emptyPublication()));
}
- protected function _emptyPublication() {
+ public function _emptyPublication() {
return array('id' => '', 'label' => '', 'online' => false);
}
\r
public function setLinksAndRulers($book_id, $links, $rulers, $comments = '', $user = 0) {\r
$daoBook = new wsDAOBook($this->con);\r
- $pages = $daoBook->getPagesOfBook($book_id,false);\r
- \r
+ $pages = $daoBook->getPagesOfBook($book_id, false);\r
+\r
if (is_array($links)) {\r
$links = json_encode($links);\r
}\r
$links = array();\r
$rulers = array();\r
\r
+ foreach ($pages as $p) {\r
+ if (!isset($links[$p['document_id']])) {\r
+ $links[$p['document_id']] = array();\r
+ $rulers[$p['document_id']] = array();\r
+ }\r
+ \r
+ if (!isset($links[$p['document_id']][$p['document_page']])) {\r
+ $links[$p['document_id']][$p['document_page']] = array();\r
+ $rulers[$p['document_id']][$p['document_page']] = array();\r
+ }\r
+ }\r
+\r
foreach ($t as $page => $tt) {\r
if (!is_int($page)) {\r
continue;\r
}\r
}\r
\r
+ fb($links);\r
+\r
foreach ($links as $document_id => $dummy) {\r
wsLinks::setDocumentLinks($document_id, json_encode($links[$document_id]), json_encode($rulers[$document_id]), $user, $comments, TIME);\r
}\r
$this->fields['friendWidth'] = array('type' => 'integer', 'default' => 319, 'editable' => true, 'label' => __('Largeur du menu'), 'grade' => 5);\r
$this->fields['friendHeight'] = array('type' => 'integer', 'default' => 500, 'editable' => true, 'label' => __('Largeur du menu'), 'grade' => 5);\r
$this->forms['share'] = array('label' => __('Fonctions de partage'),\r
- 'fieldsnames' => array('share','|','email_title', 'email_body', 'email_editable', 'askAcknowledge', '|',\r
+ 'fieldsnames' => array('share', '|', 'email_title', 'email_body', 'email_editable', 'askAcknowledge', '|',\r
'facebook_title', 'facebook_description', 'facebook_image', 'twitter_description', '|',\r
'friend', 'facebook', 'twitter', 'googleplus', 'linkedin', 'viadeo', '|', 'customSharer', '|', 'friendWidth', 'friendHeight'));\r
// .\r
// .\r
$this->fields['stats'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les statistiques Fluidbook'), 'grade' => 3);\r
$this->fields['stats_score'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher les scores dans les rapports'), 'grade' => 5);\r
+ $this->fields['stats_exclude_ip'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Exclure les IP suivantes des statistiques'), 'grade' => 3, 'hint' => sprintf(__('Indiquer une adresse ip de la forme %s par ligne'), 'www.xxx.yyy.zzz'));\r
$this->fields['googleAnalytics'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Code Google Analytics'), 'size' => 10);\r
$this->fields['googleAnalyticsCustom'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Code Google Analytics personnalisé'));\r
$this->forms['stats'] = array('label' => __('Statistiques'),\r
- 'fieldsnames' => array('stats', 'stats_score', '|', 'googleAnalytics', 'googleAnalyticsCustom'));\r
+ 'fieldsnames' => array('stats', 'stats_score', 'stats_exclude_ip', '|', 'googleAnalytics', 'googleAnalyticsCustom'));\r
\r
$this->fields['displayChaptersIcon'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Affiche l'icône du sommaire"), 'grade' => 1);\r
$this->fields['displayChaptersLine'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Affiche une ligne entre le label et le numéro de page"), 'grade' => 5);\r
function load_extranet() {\r
\r
if ($("#devisAdresse #client_nom").length > 0) {\r
- $("#devisAdresse #client_nom").autocomplete(SITE_PATH + 'autocomplete/client', {\r
+ $("#devisAdresse #client_nom").autocompletej(SITE_PATH + 'autocomplete/client', {\r
cacheLength: 0,\r
maxItemsToShow: 15,\r
onFindValue: findClient,\r
\r
\r
if ($("#factureAdresse #projet_nom").length > 0) {\r
- $("#factureAdresse #projet_nom").autocomplete(SITE_PATH + 'autocomplete/projet', {\r
+ $("#factureAdresse #projet_nom").autocompletej(SITE_PATH + 'autocomplete/projet', {\r
cacheLength: 0,\r
maxItemsToShow: 15,\r
onFindValue: findProjet,\r
});\r
\r
if ($("#collection").length > 0) {\r
- $("#collection>ul").sortable({\r
- cancel: 'h3,input',\r
+ $("#collection>form>ul").sortable({\r
+ cancel: 'h1',\r
axis: 'y',\r
handle: '.move'\r
});\r
\r
- $("#collection>ul ul").sortable({\r
- cancel: 'h3,input',\r
- axis: 'y',\r
- handle: '.move',\r
- connectWith: '#collection>ul ul'\r
+\r
+ $("#collection>form>ul a.delete").click(function() {\r
+ $(this).parents('li:first').remove();\r
+ });\r
+\r
+ $("#collection>form>ul>li").each(function() {\r
+ initGroup($(this));\r
+ });\r
+\r
+\r
+ var newCounter = 1;\r
+\r
+ $("#newGroup").click(function() {\r
+ var g = $(".group.empty").clone();\r
+ var html = g.get(0).outerHTML;\r
+ html = html.replace(/new_/gi, "new_" + newCounter);\r
+ g = $(html);\r
+ $(g).removeClass('empty');\r
+ $("#collection>form>ul").append(g);\r
+\r
+ initGroup(g);\r
+\r
+ newCounter++;\r
+ return false;\r
+ });\r
+ }\r
+}\r
+\r
+function initGroup(group) {\r
+ $(group).find("ul").sortable({\r
+ cancel: 'h1',\r
+ axis: 'y',\r
+ handle: '.move',\r
+ connectWith: '#collection>form>ul ul'\r
+ });\r
+\r
+ try {\r
+ $('.publication_id').autocompletej(SITE_PATH + 'autocomplete/book', {\r
+ cacheLength: 0,\r
+ maxItemsToShow: 15,\r
+ onFindValue: findBook,\r
+ onItemSelect: findBook\r
});\r
+ } catch (err) {\r
+ fb(err);\r
}\r
+\r
}\r
\r
function load_ws() {\r
if ($("#book_nom").length) {\r
- $("#book_nom").autocomplete(SITE_PATH + 'autocomplete/book', {\r
+ $("#book_nom").autocompletej(SITE_PATH + 'autocomplete/book', {\r
cacheLength: 0,\r
maxItemsToShow: 15,\r
onFindValue: findBook,\r
}\r
\r
if ($("#book_proprietaire").length) {\r
- $("#book_proprietaire").autocomplete(SITE_PATH + 'autocomplete/wsuser', {\r
+ $("#book_proprietaire").autocompletej(SITE_PATH + 'autocomplete/wsuser', {\r
cacheLength: 0,\r
maxItemsToShow: 15,\r
onFindValue: findProprietaire,\r
\r
\r
if ($("#ws_admin_nom").length > 0) {\r
- $("#ws_admin_nom").autocomplete(SITE_PATH + 'autocomplete/wsadmin', {\r
+ $("#ws_admin_nom").autocompletej(SITE_PATH + 'autocomplete/wsadmin', {\r
cacheLength: 0,\r
maxItemsToShow: 15,\r
onFindValue: findWSAdmin,\r
}\r
\r
function findBook(li) {\r
+\r
var book = li.selectValue.split(' - ');\r
if (book.length <= 1) {\r
return;\r
}\r
var book_id = parseInt(book[0]);\r
- $("#book").val(book_id);\r
+ $(this.input).next('input[type="hidden"]:first').val(book_id);\r
}
\ No newline at end of file
padding:5px;\r
}\r
\r
+#collection .min.nowrap{\r
+ padding:0 15px 0 0;\r
+}\r
+\r
#collection h1{\r
margin:5px 0 10px;\r
padding:0;\r
}\r
\r
+#collection .group.empty{\r
+ display:none;\r
+}\r
+\r
+#collection .g{\r
+ padding:2px 6px;\r
+}\r
+\r
#collection h3{margin:10px 0 10px 0 !important;}\r
#collection .group,\r
#collection .publication{\r
#collection input,\r
#collection select{\r
width:auto;\r
+}\r
+\r
+#collection .submit{\r
+ float:right;\r
}
\ No newline at end of file