Browse Source

- Add a spoiler system for NSFW contents

- Add a getter for Privacy
- The Bookmarks are more clearly displayed
pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
01a70e67e3
  1. 23
      app/assets/js/movim_utils.js
  2. 5
      app/models/privacy/Privacy.php
  3. 4
      app/models/subscription/SubscriptionDAO.php
  4. 15
      app/widgets/Bookmark/Bookmark.php
  5. 2
      app/widgets/Bookmark/bookmark.tpl
  6. 46
      app/widgets/NodeConfig/NodeConfig.php
  7. 6
      app/widgets/WidgetCommon/WidgetCommon.php
  8. 6
      app/widgets/WidgetCommon/_post.tpl
  9. 25
      themes/movim/css/posts.css

23
app/assets/js/movim_utils.js

@ -3,6 +3,21 @@
*
* This file include some useful functions used quite everywhere in Movim
*/
function movim_check_string(str) {
if (typeof str == 'object') {
return str instanceof String;
} else {
return typeof str == 'string';
}
}
function movim_get_node(str) {
if(movim_check_string(str))
return document.querySelector(str);
else
return str;
}
/**
* @brief Force Movim to go back to the login page
@ -118,7 +133,7 @@ function movim_textarea_autoheight(textbox) {
* @param string the class to check
*/
function movim_has_class(element,classname) {
var element = document.querySelector(element);
var element = movim_get_node(element);
return element.className.match(new RegExp('(\\s|^)'+classname+'(\\s|$)'));
}
@ -129,7 +144,7 @@ function movim_has_class(element,classname) {
*/
function movim_add_class(element,classname) {
if(!movim_has_class(element,classname)) {
var element = document.querySelector(element);
var element = movim_get_node(element);
element.className += " "+classname;
}
}
@ -142,7 +157,7 @@ function movim_add_class(element,classname) {
function movim_remove_class(element,classname) {
if (movim_has_class(element,classname)) {
var reg = new RegExp('(\\s|^)'+classname+'(\\s|$)');
var element = document.querySelector(element);
var element = movim_get_node(element);
element.className=element.className.replace(reg,' ');
}
}
@ -182,7 +197,7 @@ function movim_button_reset(element) {
* @param string the selector of the element
*/
function movim_toggle_display(element) {
var node = document.querySelector(element);
var node = movim_get_node(element);
if(node.style.display == 'block')
node.style.display = 'none';
else

5
app/models/privacy/Privacy.php

@ -30,4 +30,9 @@ class Privacy extends ModlModel {
$pd = new PrivacyDAO();
$pd->set($p);
}
static function get($key) {
$pd = new PrivacyDAO();
return (int)$pd->get($key)->value;
}
}

4
app/models/subscription/SubscriptionDAO.php

@ -88,7 +88,9 @@ class SubscriptionDAO extends ModlSQL {
subscription.server,
subscription.node,
subscription.jid,
subscription, item.name';
subscription, item.name
order by
subscription.server';
$this->prepare(
'Subscription',

15
app/widgets/Bookmark/Bookmark.php

@ -226,12 +226,21 @@ class Bookmark extends WidgetBase
$sd = new \modl\SubscriptionDAO();
if($sd != null && $sd->getSubscribed() != null) {
$server = null;
foreach($sd->getSubscribed() as $s) {
if($s->name != null)
$name = $s->name;
else
$name = $s->node;
if($server != $s->server) {
$subscription .= '
<a href="'.Route::urlize('server', array($s->server)).'"><h3>'.
$s->server.'
</h3></a>';
$server = $s->server;
}
$subscription .= '
<li>
@ -280,7 +289,7 @@ class Bookmark extends WidgetBase
if($conference != '') {
$html .= '
<h3>'.t('Conferences').' - '.$conferencenum.'</h3>
<h2>'.t('Conferences').' - '.$conferencenum.'</h2>
<ul>'.
$conference.'
</ul>';
@ -288,7 +297,7 @@ class Bookmark extends WidgetBase
if($subscription != '') {
$html .= '
<h3>'.t('Groups').' - '.$subscriptionnum.'</h3>
<h2>'.t('Groups').' - '.$subscriptionnum.'</h2>
<ul>'.
$subscription.'
</ul>';
@ -296,7 +305,7 @@ class Bookmark extends WidgetBase
if($url != '') {
$html .= '
<h3>'.t('Links').' - '.$urlnum.'</h3>
<h2>'.t('Links').' - '.$urlnum.'</h2>
<ul>'.
$url.'
</ul>';

2
app/widgets/Bookmark/bookmark.tpl

@ -4,7 +4,7 @@
}
</script>
<h2>{$c->t('Bookmarks')}</h2>
<!--<h2>{$c->t('Bookmarks')}</h2>-->
<div id="bookmarks">
{$preparebookmark}

46
app/widgets/NodeConfig/NodeConfig.php

@ -104,51 +104,19 @@ class NodeConfig extends WidgetBase
}
function ajaxSubmitConfig($data, $server, $node){
if(isset($data['pubsub#access_model'])) {
if($data['pubsub#access_model'] == 'open')
\modl\Privacy::set($server.$node, 1);
else
\modl\Privacy::set($server.$node, 0);
}
$r = new moxl\PubsubSetConfig();
$r->setTo($server)
->setNode($node)
->setData($data)
->request();
}
/*
function build()
{
echo '
<div class="breadcrumb">
<a href="'.Route::urlize('explore').'">
'.t('Explore').'
</a>
<a href="'.Route::urlize('server', $_GET['s']).'">
'.$_GET['s'].'
</a>
<a href="'.Route::urlize('node', array($_GET['s'], $_GET['n'])).'">
'.$_GET['n'].'
</a>
<a>'.t('Configuration').'</a>
</div>';
?>
<div class="tabelem" title="<?php echo t('Configuration'); ?>" id="groupconfig">
<h1><?php echo t('Configuration'); ?></h1>
<div id="groupconfiguration" class="paddedtop">
<div id="handlingmessages"></div>
<a
class="button color green icon write"
onclick="<?php echo $this->genCallAjax('ajaxGroupConfig', "'".$_GET['s']."'", "'".$_GET['n']."'"); ?> this.style.display = 'none'">
<?php echo t("Configure your group");?>
</a>
<a
class="button color red icon no"
onclick="<?php echo $this->genCallAjax('ajaxGroupDelete', "'".$_GET['s']."'", "'".$_GET['n']."'"); ?> this.style.display = 'none'">
<?php echo t("Delete this group");?>
</a>
</div>
</div>
<?php
}
*/
}
?>

6
app/widgets/WidgetCommon/WidgetCommon.php

@ -33,6 +33,11 @@ class WidgetCommon extends WidgetBase {
if($post->title)
$title = $post->title;
$spoiler = false;
if(current(explode('.', $post->jid)) == 'nsfw')
$spoiler = ' movim_toggle_class(this, \'show\')';
if($this->user->getLogin() == $post->aid) {
$class = 'me ';
@ -119,6 +124,7 @@ class WidgetCommon extends WidgetBase {
$view->assign('id', $post->nodeid);
$view->assign('class', $class);
$view->assign('access', $access);
$view->assign('spoiler', $spoiler);
$view->assign('flagtitle', getFlagTitle($flagcolor));
if(filter_var($post->jid, FILTER_VALIDATE_EMAIL))
$view->assign('friend', Route::urlize('friend', $post->jid));

6
app/widgets/WidgetCommon/_post.tpl

@ -14,7 +14,11 @@
</span>
<!--{$author}-->
</div>
<div class="content">
<div class="content
{if="$spoiler != false"}
spoiler
{/if}
" onclick="{$spoiler}">
{$content}
</div>
{$tags}

25
themes/movim/css/posts.css

@ -390,3 +390,28 @@
cursor: pointer;
text-decoration: underline;
}
.post .spoiler > * {
opacity: 0;
}
.post .spoiler.show > * {
opacity: 1;
}
.post .spoiler:before {
content: "Spoiler +";
padding: 0.5em;
margin: 0.5em 0;
color: #777;
border-bottom: 1px solid #BBB;
display: block;
}
.post .spoiler.show:before {
content: "Spoiler -";
}
.post .spoiler:hover {
cursor: pointer;
}
Loading…
Cancel
Save