diff --git a/CHANGELOG b/CHANGELOG index 6ff9a87..04655c5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ **Changelog** +1.8 2016? +- Update to movim 0.9 git2016-04-12 + 1.7.1 2016-30-30 - Update to movim 0.9 git2016-03-30 diff --git a/README.md b/README.md index cf182e8..bddedee 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Movim is a decentralized social network, written in PHP and HTML5 and based on t It is recommended to use a "valid" certificate to use Movim, auto-signed is sometimes problematic. You might want to take a look a StartSSL or Let's Encrypt. -Provided Movim version : 0.9 git2016-03-30 +Provided Movim version : 0.9 git2016-04-12 Please read CHANGELOG. diff --git a/sources/app/models/conference/ConferenceDAO.php b/sources/app/models/conference/ConferenceDAO.php index ecb4a1f..22d529b 100644 --- a/sources/app/models/conference/ConferenceDAO.php +++ b/sources/app/models/conference/ConferenceDAO.php @@ -12,10 +12,10 @@ class ConferenceDAO extends SQL { status = :status where jid = :jid and conference= :conference'; - + $this->prepare( - 'Conference', - array( + 'Conference', + array( 'jid' => $c->jid, 'conference' => $c->conference, 'name' => $c->name, @@ -24,17 +24,17 @@ class ConferenceDAO extends SQL { 'status' => $c->status ) ); - + $this->run('Conference'); - + if(!$this->_effective) { $this->_sql = ' insert into conference (jid, conference, name, nick, autojoin, status) values (:jid, :conference, :name, :nick, :autojoin, :status)'; - + $this->prepare( - 'Conference', + 'Conference', array( 'jid' => $c->jid, 'conference' => $c->conference, @@ -44,7 +44,7 @@ class ConferenceDAO extends SQL { 'status' => $c->status ) ); - + $this->run('Conference'); } } @@ -54,110 +54,63 @@ class ConferenceDAO extends SQL { select * from conference where jid = :jid and conference= :conference'; - + $this->prepare( - 'Conference', + 'Conference', array( 'jid' => $this->_user, 'conference' => $conference, ) ); - - return $this->run('Conference', 'item'); + + return $this->run('Conference', 'item'); } - + function getAll() { $this->_sql = ' select * from conference where jid = :jid order by conference'; - + $this->prepare( - 'Conference', + 'Conference', array( 'jid' => $this->_user ) ); - - return $this->run('Conference'); + + return $this->run('Conference'); } - - function getConnected() { - $this->_sql = ' - select * from conference - where jid = :jid - and status= 1'; - - $this->prepare( - 'Conference', - array( - 'jid' => $this->_user - ) - ); - - return $this->run('Conference'); - } - /* - function getSubscribed() { - $this->_sql = ' - select - subscription.jid, - subscription.server, - subscription.node, - subscription, - name - from subscription - left outer join item - on item.server = subscription.server - and item.node = subscription.node - where subscription.jid = :jid - group by - subscription.server, - subscription.node, - subscription.jid, - subscription, item.name - order by - subscription.server'; - - $this->prepare( - 'Subscription', - array( - 'jid' => $this->_user - ) - ); - - return $this->run('Subscription'); - } - */ + function delete() { $this->_sql = ' delete from conference where jid = :jid'; - + $this->prepare( - 'Subscription', + 'Subscription', array( 'jid' => $this->_user ) ); - + return $this->run('conference'); } - + function deleteNode($conference) { $this->_sql = ' delete from conference where jid = :jid and conference= :conference'; - + $this->prepare( - 'Conference', + 'Conference', array( 'jid' => $this->_user, 'conference' => $conference ) ); - + return $this->run('Conference'); } } diff --git a/sources/app/models/postn/Postn.php b/sources/app/models/postn/Postn.php index 11978e6..c2797a2 100644 --- a/sources/app/models/postn/Postn.php +++ b/sources/app/models/postn/Postn.php @@ -20,6 +20,8 @@ class Postn extends Model { public $commentplace; + public $open; + public $published; // public $updated; // public $delay; // @@ -31,11 +33,10 @@ class Postn extends Model { public $links; - public $privacy; - public $hash; private $youtube; + private $openlink; public function __construct() { $this->hash = md5(openssl_random_pseudo_bytes(5)); @@ -65,6 +66,9 @@ class Postn extends Model { "commentplace" : {"type":"string", "size":128 }, + "open" : + {"type":"bool"}, + "published" : {"type":"date" }, "updated" : @@ -256,8 +260,10 @@ class Postn extends Model { return in_array($type, array('picture', 'image/jpeg', 'image/png', 'image/jpg', 'image/gif')); } - private function typeIsLink($type) { - return $type == 'text/html'; + private function typeIsLink($link) { + return (isset($link['type']) + && $link['type'] == 'text/html' + && Validator::url()->validate($link['href'])); } private function setAttachements($links, $extra = false) { @@ -274,6 +280,9 @@ class Postn extends Model { $this->picture = true; } + if($enc['rel'] == 'alternate' + && Validator::url()->validate($enc['href'])) $this->open = true; + if((string)$attachment->attributes()->title == 'comments') { $substr = explode('?',substr((string)$attachment->attributes()->href, 5)); $this->commentplace = reset($substr); @@ -292,27 +301,38 @@ class Postn extends Model { { $attachements = null; $this->picture = null; + $this->openlink = null; if(isset($this->links)) { - $attachements = array('pictures' => array(), 'files' => array(), 'links' => array()); + $attachements = array( + 'pictures' => array(), + 'files' => array(), + 'links' => array() + ); $links = unserialize($this->links); + foreach($links as $l) { if(isset($l['type']) && $this->typeIsPicture($l['type'])) { if($this->picture == null) { $this->picture = $l['href']; } + array_push($attachements['pictures'], $l); - } elseif((isset($l['type']) && $this->typeIsLink($l['type']) - || in_array($l['rel'], array('related', 'alternate'))) - && Validator::url()->validate($l['href'])) { + } elseif($this->typeIsLink($l)) { if($this->youtube == null && preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $l['href'], $match)) { $this->youtube = $match[1]; } - array_push($attachements['links'], array('href' => $l['href'], 'url' => parse_url($l['href']))); - } elseif(isset($l['rel']) && $l['rel'] == 'enclosure') { + if($l['rel'] == 'alternate') { + $this->openlink = $l['href']; + if(!$this->isMicroblog()) { + array_push($attachements['links'], array('href' => $l['href'], 'url' => parse_url($l['href']))); + } + } + } elseif(isset($l['rel']) + && $l['rel'] == 'enclosure') { array_push($attachements['files'], $l); } } @@ -389,11 +409,7 @@ class Postn extends Model { public function getPublicUrl() { - if($this->isMicroblog()) { - return \Route::urlize('blog', array($this->origin, $this->nodeid)); - } else { - return \Route::urlize('node', array($this->origin, $this->node, $this->nodeid)); - } + return $this->openlink; } public function getTags() @@ -414,7 +430,7 @@ class Postn extends Model { } public function isPublic() { - return (isset($this->privacy) && $this->privacy); + return ($this->open); } } diff --git a/sources/app/models/postn/PostnDAO.php b/sources/app/models/postn/PostnDAO.php index 603a14c..ed1b37d 100644 --- a/sources/app/models/postn/PostnDAO.php +++ b/sources/app/models/postn/PostnDAO.php @@ -17,6 +17,8 @@ class PostnDAO extends SQL { commentplace = :commentplace, + open = :open, + published = :published, updated = :updated, delay = :delay, @@ -47,6 +49,8 @@ class PostnDAO extends SQL { 'commentplace' => $post->commentplace, + 'open' => $post->open, + 'published' => $post->published, 'updated' => $post->updated, 'delay' => $post->delay, @@ -86,6 +90,8 @@ class PostnDAO extends SQL { commentplace, + open, + published, updated, delay, @@ -113,6 +119,8 @@ class PostnDAO extends SQL { :commentplace, + :open, + :published, :updated, :delay, @@ -140,6 +148,8 @@ class PostnDAO extends SQL { 'commentplace' => $post->commentplace, + 'open' => $post->open, + 'published' => $post->published, 'updated' => $post->updated, 'delay' => $post->delay, @@ -196,9 +206,8 @@ class PostnDAO extends SQL { function getNode($from, $node, $limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where ((postn.origin, node) in (select server, node from subscription where jid = :aid)) and postn.origin = :origin and postn.node = :node @@ -222,11 +231,10 @@ class PostnDAO extends SQL { function getPublicTag($tag, $limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where nodeid in (select nodeid from tag where tag = :title) - and privacy.value = 1 + and postn.open = true order by postn.published desc'; if($limitr !== false) @@ -244,9 +252,8 @@ class PostnDAO extends SQL { function getNodeUnfiltered($from, $node, $limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where postn.origin = :origin and postn.node = :node order by postn.published desc'; @@ -267,9 +274,8 @@ class PostnDAO extends SQL { function getGallery($from, $limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where postn.aid = :aid and postn.picture = 1 order by postn.published desc'; @@ -310,9 +316,8 @@ class PostnDAO extends SQL { function getItem($id) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where postn.nodeid = :nodeid'; $this->prepare( @@ -327,9 +332,8 @@ class PostnDAO extends SQL { function getAllPosts($jid = false, $limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where ( (postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\') or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\') @@ -358,9 +362,8 @@ class PostnDAO extends SQL { function getFeed($limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where ((postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\') or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\')) and postn.node not like \'urn:xmpp:microblog:0:comments/%\' @@ -383,9 +386,8 @@ class PostnDAO extends SQL { function getNews($limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where ((postn.origin, node) in (select server, node from subscription where jid = :origin)) order by postn.published desc '; @@ -407,9 +409,8 @@ class PostnDAO extends SQL { function getMe($limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where postn.origin = :origin and postn.node = \'urn:xmpp:microblog:0\' order by postn.published desc '; @@ -430,12 +431,11 @@ class PostnDAO extends SQL { function getPublic($origin, $node, $limitf = false, $limitr = false) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where postn.origin = :origin and postn.node = :node - and privacy.value = 1 + and postn.open = true order by postn.published desc'; if($limitr !== false) @@ -454,12 +454,11 @@ class PostnDAO extends SQL { function getPublicItem($origin, $node, $nodeid) { $this->_sql = ' - select *, postn.aid, privacy.value as privacy from postn + select *, postn.aid from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where postn.origin = :origin and postn.node = :node - and privacy.value = 1 + and postn.open = true and postn.nodeid = :nodeid order by postn.published desc'; @@ -606,11 +605,10 @@ class PostnDAO extends SQL { $this->_sql = ' select * from postn left outer join contact on postn.aid = contact.jid - left outer join privacy on postn.nodeid = privacy.pkey where node = \'urn:xmpp:microblog:0\' and postn.origin not in (select jid from rosterlink where session = :origin) - and privacy.value = 1 + and postn.open = true order by published desc '; diff --git a/sources/app/models/sessionx/SessionxDAO.php b/sources/app/models/sessionx/SessionxDAO.php index e6bee5e..e3f5769 100644 --- a/sources/app/models/sessionx/SessionxDAO.php +++ b/sources/app/models/sessionx/SessionxDAO.php @@ -3,11 +3,10 @@ namespace modl; class SessionxDAO extends SQL { - function init(Sessionx $s) { + function init(Sessionx $s) { $this->_sql = ' update sessionx set username = :username, - password = :password, hash = :hash, resource = :resource, rid = :rid, @@ -22,13 +21,12 @@ class SessionxDAO extends SQL { timestamp = :timestamp, mechanism = :mechanism where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $s->session, 'username' => $s->username, - 'password' => $s->password, 'hash' => $s->hash, 'resource' => $s->resource, 'rid' => $s->rid, @@ -44,15 +42,14 @@ class SessionxDAO extends SQL { 'mechanism' => $s->mechanism ) ); - + $this->run('Sessionx'); - + if(!$this->_effective) { $this->_sql = ' insert into sessionx (session, username, - password, hash, resource, rid, @@ -69,7 +66,6 @@ class SessionxDAO extends SQL { values (:session, :username, - :password, :hash, :resource, :rid, @@ -83,13 +79,12 @@ class SessionxDAO extends SQL { :start, :timestamp, :mechanism)'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $s->session, 'username' => $s->username, - 'password' => $s->password, 'hash' => $s->hash, 'resource' => $s->resource, 'rid' => $s->rid, @@ -105,7 +100,7 @@ class SessionxDAO extends SQL { 'mechanism' => $s->mechanism ) ); - + $this->run('Sessionx'); } } @@ -116,11 +111,11 @@ class SessionxDAO extends SQL { set '.$key.' = :'.$key.', timestamp = :timestamp - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session, $key => $value, @@ -134,11 +129,11 @@ class SessionxDAO extends SQL { function get($session) { $this->_sql = ' select * from sessionx - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session ) @@ -150,11 +145,11 @@ class SessionxDAO extends SQL { function getHash($hash) { $this->_sql = ' select * from sessionx - where + where hash = :hash'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'hash' => $hash ) @@ -166,16 +161,16 @@ class SessionxDAO extends SQL { function getId($session) { $this->_sql = ' select id from sessionx - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session ) ); - + $value = $this->run(null, 'array'); $value = $value[0]['id']; @@ -184,11 +179,11 @@ class SessionxDAO extends SQL { set id = :id, timestamp = :timestamp - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session, 'id' => $value+1, @@ -197,23 +192,23 @@ class SessionxDAO extends SQL { ); $this->run(); - + return $value; } function getRid($session) { $this->_sql = ' select rid from sessionx - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session ) ); - + $value = $this->run(null, 'array'); $value = $value[0]['rid']; @@ -222,11 +217,11 @@ class SessionxDAO extends SQL { set rid = :rid, timestamp = :timestamp - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session, 'rid' => $value+1, @@ -235,23 +230,23 @@ class SessionxDAO extends SQL { ); $this->run(); - + return $value; } function delete($session) { $this->_sql = ' delete from sessionx - where + where session = :session'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( 'session' => $session ) ); - + return $this->run('Sessionx'); } @@ -269,26 +264,12 @@ class SessionxDAO extends SQL { return $this->run('Sessionx'); } - /*function clean() { - $this->_sql = ' - delete from sessionx - where timestamp < :timestamp'; - - $this->prepare( - 'Sessionx', - array( - 'timestamp' => date(DATE_ISO8601, time() - 3600) - ) - ); - - $this->run('Sessionx'); - }*/ function clear() { $this->_sql = ' truncate table sessionx'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array( ) ); @@ -299,51 +280,12 @@ class SessionxDAO extends SQL { function getAll() { $this->_sql = ' select * from sessionx'; - + $this->prepare( - 'Sessionx', + 'Sessionx', array() ); - return $this->run('Sessionx'); - } - - function getConnected() { - $this->_sql = ' - select count(*) from sessionx'; - - $this->prepare( - 'Sessionx', - array( - - ) - ); - - $results = $this->run(null, 'array'); - $results = array_values($results[0]); - - return (int)$results[0]; - } - - function checkConnected($username, $host) - { - $this->_sql = ' - select count(*) from sessionx - where - username = :username - and host = :host'; - - $this->prepare( - 'Sessionx', - array( - 'username' => $username, - 'host' => $host - ) - ); - - $results = $this->run(null, 'array'); - $results = array_values($results[0]); - - return (int)$results[0]; + return $this->run('Sessionx'); } } diff --git a/sources/app/views/room.tpl b/sources/app/views/room.tpl index 23151f5..a5c35da 100644 --- a/sources/app/views/room.tpl +++ b/sources/app/views/room.tpl @@ -1,3 +1,4 @@ +widget('Stickers');?> widget('Presence'); ?> widget('LoginAnonymous'); ?>
diff --git a/sources/app/widgets/About/about.tpl b/sources/app/widgets/About/about.tpl index b009161..5d5211c 100644 --- a/sources/app/widgets/About/about.tpl +++ b/sources/app/widgets/About/about.tpl @@ -37,6 +37,7 @@ Moxl - Movim XMPP Library - GitHub Moxl under AGPLv3
Map Library - Leaflet leafletjs.com under BSD
+ Chart.js - Nick Downie chart.js under MIT
Favico.js - Miroslav Magda lab.ejci.net/favico.js under GPL and MIT
Markdown - Michel Fortin michelf.ca ©Michel Fortin
Template Engine - RainTPL - Federico Ulfo www.raintpl.com under MIT
diff --git a/sources/app/widgets/AccountNext/AccountNext.php b/sources/app/widgets/AccountNext/AccountNext.php index 5570b4f..d86c0e2 100644 --- a/sources/app/widgets/AccountNext/AccountNext.php +++ b/sources/app/widgets/AccountNext/AccountNext.php @@ -102,8 +102,9 @@ class AccountNext extends \Movim\Widget\Base { $domain = \Moxl\Utils::getDomain($host); // We create a new session or clear the old one - $s = Sessionx::start(); - $s->init(null, null, $host, $domain); + $s = Session::start(); + $s->set('host', $host); + $s->set('domain', $domain); \Moxl\Stanza\Stream::init($host); } diff --git a/sources/app/widgets/AccountNext/_accountnext_registered.tpl b/sources/app/widgets/AccountNext/_accountnext_registered.tpl index b63ab4a..3c71fd3 100644 --- a/sources/app/widgets/AccountNext/_accountnext_registered.tpl +++ b/sources/app/widgets/AccountNext/_accountnext_registered.tpl @@ -3,7 +3,7 @@

username@server.com

- + {$c->__('page.login')} diff --git a/sources/app/widgets/AdHoc/AdHoc.php b/sources/app/widgets/AdHoc/AdHoc.php index 2b6819f..3db6ccc 100644 --- a/sources/app/widgets/AdHoc/AdHoc.php +++ b/sources/app/widgets/AdHoc/AdHoc.php @@ -60,10 +60,10 @@ class AdHoc extends \Movim\Widget\Base function ajaxGet() { - $session = \Sessionx::start(); + $session = \Session::start(); $g = new Get; - $g->setTo($session->host) + $g->setTo($session->get('host')) ->request(); } @@ -77,10 +77,10 @@ class AdHoc extends \Movim\Widget\Base function ajaxSubmit($data, $node, $sessionid) { - $session = \Sessionx::start(); + $session = \Session::start(); $s = new Submit; - $s->setTo($session->host) + $s->setTo($session->get('host')) ->setNode($node) ->setData($data) ->setSessionid($sessionid) diff --git a/sources/app/widgets/AdminTest/AdminTest.php b/sources/app/widgets/AdminTest/AdminTest.php index 8035528..68be0ac 100644 --- a/sources/app/widgets/AdminTest/AdminTest.php +++ b/sources/app/widgets/AdminTest/AdminTest.php @@ -14,7 +14,7 @@ * * See COPYING for licensing information. */ - + class AdminTest extends \Movim\Widget\Base { function load() { @@ -24,14 +24,14 @@ class AdminTest extends \Movim\Widget\Base public function version() { - return (version_compare(PHP_VERSION, '5.3.0') >= 0); + return (version_compare(PHP_VERSION, '5.4.0') >= 0); } public function testDir($dir) { return (file_exists($dir) && is_dir($dir) && is_writable($dir)); } - + public function testFile($file) { return (file_exists($file) && is_writable($file)); @@ -39,15 +39,10 @@ class AdminTest extends \Movim\Widget\Base function display() { - $md = \modl\Modl::getInstance(); + $md = \Modl\Modl::getInstance(); $supported = $md->getSupportedDatabases(); - $cd = new \Modl\ConfigDAO(); - $config = $cd->get(); - $this->view->assign('dbconnected', $md->_connected); - $this->view->assign('dbtype', $supported[$config->type]); $this->view->assign('dbinfos', sizeof($md->check())); - $this->view->assign('websocketurl', $config->websocketurl); } } diff --git a/sources/app/widgets/Chat/Chat.php b/sources/app/widgets/Chat/Chat.php index 969716b..d8daff5 100644 --- a/sources/app/widgets/Chat/Chat.php +++ b/sources/app/widgets/Chat/Chat.php @@ -224,7 +224,9 @@ class Chat extends \Movim\Widget\Base * @return void */ function ajaxSendMessage($to, $message, $muc = false, $resource = false, $replace = false) { - if($message == '') + $body = trim(rawurldecode($message)); + + if($body == '' || $body == '/me') return; $m = new \Modl\Message(); @@ -243,25 +245,18 @@ class Chat extends \Movim\Widget\Base $m->published = gmdate('Y-m-d H:i:s'); } - $session = \Sessionx::start(); + $session = \Session::start(); $m->type = 'chat'; - $m->resource = $session->resource; + $m->resource = $session->get('resource'); if($muc) { $m->type = 'groupchat'; - - $s = Session::start(); - $m->resource = $s->get('username'); - - if($m->resource == null) { - $m->resource = $session->user; - } - + $m->resource = $session->get('username'); $m->jidfrom = $to; } - $m->body = trim(rawurldecode($message)); + $m->body = $body; //$m->html = prepareString($m->body, false, true); if($resource != false) { @@ -290,7 +285,7 @@ class Chat extends \Movim\Widget\Base /* Is it really clean ? */ if(!$p->getMuc()) { if(!preg_match('#^\?OTR#', $m->body)) { - $md = new \Modl\MessageDAO(); + $md = new \Modl\MessageDAO; $md->set($m); } @@ -368,7 +363,7 @@ class Chat extends \Movim\Widget\Base { if(!$this->validateJid($jid)) return; - $md = new \Modl\MessageDAO(); + $md = new \Modl\MessageDAO; $messages = $md->getHistory(echapJid($jid), date(DATE_ISO8601, strtotime($date)), $this->_pagination); if(count($messages) > 0) { @@ -524,7 +519,7 @@ class Chat extends \Movim\Widget\Base { if(!$this->validateJid($jid)) return; - $md = new \Modl\MessageDAO(); + $md = new \Modl\MessageDAO; $messages = $md->getContact(echapJid($jid), 0, $this->_pagination); if(is_array($messages)) { diff --git a/sources/app/widgets/Chat/chat.js b/sources/app/widgets/Chat/chat.js index d7e4169..25fb4d2 100644 --- a/sources/app/widgets/Chat/chat.js +++ b/sources/app/widgets/Chat/chat.js @@ -131,7 +131,7 @@ var Chat = { bubble.id = message.newid; } - if(message.body.match(/^\/me/)) { + if(message.body.match(/^\/me\s/)) { bubble.querySelector('div.bubble').className = 'bubble quote'; message.body = message.body.substr(4); } @@ -235,12 +235,14 @@ MovimWebsocket.attach(function() { } }); -Upload.attach(function() { - var textarea = document.querySelector('#chat_textarea'); - textarea.value = Upload.get + ' ' + textarea.value; - textarea.focus(); - movim_textarea_autoheight(textarea); -}); +if(typeof Upload != 'undefined') { + Upload.attach(function() { + var textarea = document.querySelector('#chat_textarea'); + textarea.value = Upload.get + ' ' + textarea.value; + textarea.focus(); + movim_textarea_autoheight(textarea); + }); +} document.addEventListener('focus', function() { var textarea = document.querySelector('#chat_textarea'); diff --git a/sources/app/widgets/Group/Group.php b/sources/app/widgets/Group/Group.php index 914c5f1..5f59de4 100644 --- a/sources/app/widgets/Group/Group.php +++ b/sources/app/widgets/Group/Group.php @@ -368,11 +368,6 @@ class Group extends \Movim\Widget\Base RPC::call('movim_fill', 'group_widget', $html); } - function ajaxTogglePrivacy($id) { - $p = new Post; - $p->ajaxTogglePrivacy($id); - } - function prepareEmpty() { $id = new \modl\ItemDAO(); diff --git a/sources/app/widgets/Infos/Infos.php b/sources/app/widgets/Infos/Infos.php index b0038b6..0bb24ea 100644 --- a/sources/app/widgets/Infos/Infos.php +++ b/sources/app/widgets/Infos/Infos.php @@ -14,7 +14,7 @@ * * See COPYING for licensing information. */ - + class Infos extends \Movim\Widget\Base { function load() { @@ -34,7 +34,7 @@ class Infos extends \Movim\Widget\Base $cd = new \Modl\ConfigDAO(); $config = $cd->get(); - $sd = new \Modl\SessionxDAO(); + $connected = (int)requestURL('http://localhost:1560/started/', 2); $infos = array( 'url' => BASE_URI, @@ -46,9 +46,11 @@ class Infos extends \Movim\Widget\Base 'php_version' => phpversion(), 'version' => APP_VERSION, 'population' => $pop, - 'connected' => $sd->getConnected() + 'linked' => (int)requestURL('http://localhost:1560/linked/', 2), + 'started' => $connected, + 'connected' => $connected ); - + $this->view->assign('json', json_encode($infos)); } } diff --git a/sources/app/widgets/Login/Login.php b/sources/app/widgets/Login/Login.php index cbb158d..8cd5b4f 100644 --- a/sources/app/widgets/Login/Login.php +++ b/sources/app/widgets/Login/Login.php @@ -38,10 +38,9 @@ class Login extends \Movim\Widget\Base $pd = new \Modl\PresenceDAO(); $pd->clearPresence(); - $session = \Sessionx::start(); - $session->load(); + $session = \Session::start(); - if($session->mechanism != 'ANONYMOUS') { + if($session->get('mechanism') != 'ANONYMOUS') { // http://xmpp.org/extensions/xep-0280.html \Moxl\Stanza\Carbons::enable(); @@ -84,12 +83,7 @@ class Login extends \Movim\Widget\Base $pop++; $this->view->assign('pop', $pop-2); - - $sd = new \Modl\SessionxDAO(); - $connected = $sd->getConnected(); - - $this->view->assign('connected', $connected); - + $this->view->assign('connected', (int)requestURL('http://localhost:1560/started/', 2)); $this->view->assign('error', $this->prepareError()); if(isset($_SERVER['PHP_AUTH_USER']) @@ -202,12 +196,15 @@ class Login extends \Movim\Widget\Base $here = $sd->getHash(sha1($username.$password.$host)); if($here) { + //if($s->get('hash') == sha1($username.$password.$host)) { RPC::call('Login.setCookie', $here->session); RPC::call('movim_redirect', Route::urlize('main')); $this->showErrorBlock('conflict'); return; } + $s = Session::start(); + // We try to get the domain $domain = \Moxl\Utils::getDomain($host); @@ -215,6 +212,13 @@ class Login extends \Movim\Widget\Base RPC::call('register', $host); // We create a new session or clear the old one + $s->set('password', $password); + $s->set('username', $username); + $s->set('host', $host); + $s->set('domain', $domain); + $s->set('jid', $login); + $s->set('hash', sha1($username.$password.$host)); + $s = Sessionx::start(); $s->init($username, $password, $host, $domain); diff --git a/sources/app/widgets/Login/login.tpl b/sources/app/widgets/Login/login.tpl index e1dbc8f..3b59128 100644 --- a/sources/app/widgets/Login/login.tpl +++ b/sources/app/widgets/Login/login.tpl @@ -21,9 +21,9 @@ data-action="{$submit}" name="login">
+ -
@@ -53,7 +53,8 @@ {if="isset($info) && $info != ''"} {/if} diff --git a/sources/app/widgets/Menu/_menu_list.tpl b/sources/app/widgets/Menu/_menu_list.tpl index f390e0e..fd814ca 100644 --- a/sources/app/widgets/Menu/_menu_list.tpl +++ b/sources/app/widgets/Menu/_menu_list.tpl @@ -61,7 +61,7 @@ {$value->node|firstLetterCapitalize} {/if} - {if="$value->privacy"} + {if="$value->isPublic()"} diff --git a/sources/app/widgets/Post/Post.php b/sources/app/widgets/Post/Post.php index ed0534c..fe5c1b3 100644 --- a/sources/app/widgets/Post/Post.php +++ b/sources/app/widgets/Post/Post.php @@ -214,27 +214,6 @@ class Post extends \Movim\Widget\Base } } - function ajaxTogglePrivacy($id) { - $validate = Validator::stringType()->length(6, 128); - - if(!$validate->validate($id)) - return; - - $pd = new \Modl\PostnDAO; - $po = $pd->getItem($id); - - if($po->isMine()) { - if($po->privacy == 1) { - Notification::append(false, $this->__('post.public_no')); - \Modl\Privacy::set($id, 0); - } - if($po->privacy == 0) { - Notification::append(false, $this->__('post.public_yes')); - \Modl\Privacy::set($id, 1); - } - } - } - function getComments($post) { $pd = new \Modl\PostnDAO(); diff --git a/sources/app/widgets/Post/_post.tpl b/sources/app/widgets/Post/_post.tpl index e52a2bc..3606424 100644 --- a/sources/app/widgets/Post/_post.tpl +++ b/sources/app/widgets/Post/_post.tpl @@ -139,7 +139,8 @@ {/if} {/loop} - {elseif="$post->getYoutube()"} + {/if} + {if="$post->getYoutube()"}
@@ -165,18 +166,16 @@ {/if} - {if="$post->isMine() && !$public"} -
- -
{if="$item != false"} {$tags = $item->getTagsImploded()} @@ -100,4 +89,43 @@ {/if}>
+ + + +
+
    +
  • + + + + +
    +
    + + +
    +
    +
    +

    + {$c->__('post.public')} +

    +
  • +
+
diff --git a/sources/app/widgets/Publish/publish.css b/sources/app/widgets/Publish/publish.css index 5fb365e..1b692f7 100644 --- a/sources/app/widgets/Publish/publish.css +++ b/sources/app/widgets/Publish/publish.css @@ -11,3 +11,7 @@ form[name=post] #enable_content:hover > * { form[name=post] #content_field { display: none; } + +form[name=post] article section { + padding-top: 0; +} diff --git a/sources/app/widgets/Rooms/Rooms.php b/sources/app/widgets/Rooms/Rooms.php index ebf651e..358d94a 100644 --- a/sources/app/widgets/Rooms/Rooms.php +++ b/sources/app/widgets/Rooms/Rooms.php @@ -51,6 +51,14 @@ class Rooms extends \Movim\Widget\Base RPC::call('Rooms.refresh'); } + /** + * @brief Get the Rooms + */ + public function ajaxDisplay() + { + $this->refreshRooms(); + } + /** * @brief Display the add room form */ @@ -99,7 +107,7 @@ class Rooms extends \Movim\Widget\Base { if(!$this->validateRoom($room)) return; - $cd = new \modl\ConferenceDAO(); + $cd = new \Modl\ConferenceDAO; $cd->deleteNode($room); $this->setBookmark(); @@ -120,11 +128,6 @@ class Rooms extends \Movim\Widget\Base $nickname = $s->get('username'); } - if($nickname == false || $nickname == null) { - $session = \Sessionx::start(); - $nickname = $session->username; - } - $p->setNickname($nickname); $p->request(); @@ -142,11 +145,6 @@ class Rooms extends \Movim\Widget\Base $s = Session::start(); $resource = $s->get('username'); - if($resource == null) { - $session = \Sessionx::start(); - $resource = $session->username; - } - $pu = new Unavailable; $pu->setTo($room) ->setResource($resource) @@ -178,14 +176,15 @@ class Rooms extends \Movim\Widget\Base public function setBookmark($item = false) { - $arr = array(); + $arr = []; if($item) { array_push($arr, $item); } - $sd = new \modl\SubscriptionDAO(); - $cd = new \modl\ConferenceDAO(); + $sd = new \Modl\SubscriptionDAO; + $cd = new \Modl\ConferenceDAO; + $session = Session::start(); if($sd->getSubscribed()) { foreach($sd->getSubscribed() as $s) { @@ -213,7 +212,7 @@ class Rooms extends \Movim\Widget\Base $b = new Set; $b->setArr($arr) - ->setTo($this->user->getLogin()) + ->setTo($session->get('jid')) ->request(); } @@ -225,11 +224,11 @@ class Rooms extends \Movim\Widget\Base return; } - $pd = new \modl\PresenceDAO(); + $pd = new \Modl\PresenceDAO; if($resource == false) { - $session = \Sessionx::start(); - $resource = $session->user; + $session = \Session::start(); + $resource = $session->get('username'); } $presence = $pd->getPresence($room, $resource); @@ -248,19 +247,21 @@ class Rooms extends \Movim\Widget\Base $list = $cod->getAll(); - $connected = array(); + $connected = []; - foreach($list as $key => $room) { - if($this->checkConnected($room->conference, $room->nick)) { - $room->connected = true; - array_push($connected, $room); - unset($list[$key]); + if(is_array($list)) { + foreach($list as $key => $room) { + if($this->checkConnected($room->conference, $room->nick)) { + $room->connected = true; + array_push($connected, $room); + unset($list[$key]); + } } + + $connected = array_merge($connected, $list); } - $list = array_merge($connected, $list); - - $view->assign('conferences', $list); + $view->assign('conferences', $connected); $view->assign('room', $this->get('r')); return $view->draw('_rooms', true); @@ -292,6 +293,5 @@ class Rooms extends \Movim\Widget\Base function display() { - $this->view->assign('list', $this->prepareRooms()); } } diff --git a/sources/app/widgets/Rooms/rooms.js b/sources/app/widgets/Rooms/rooms.js index 8c17124..9623bde 100644 --- a/sources/app/widgets/Rooms/rooms.js +++ b/sources/app/widgets/Rooms/rooms.js @@ -18,7 +18,7 @@ var Rooms = { Rooms_ajaxJoin(this.dataset.jid); } } - + Chat_ajaxGetRoom(this.dataset.jid); Chats.reset(items); movim_add_class(this, 'active'); @@ -69,4 +69,5 @@ var Rooms = { MovimWebsocket.attach(function() { Rooms.refresh(); Rooms.anonymousInit(); + Rooms_ajaxDisplay(); }); diff --git a/sources/app/widgets/Rooms/rooms.tpl b/sources/app/widgets/Rooms/rooms.tpl index b486395..60cb8c1 100644 --- a/sources/app/widgets/Rooms/rooms.tpl +++ b/sources/app/widgets/Rooms/rooms.tpl @@ -1 +1 @@ -
{$list}
+
diff --git a/sources/app/widgets/Statistics/Statistics.php b/sources/app/widgets/Statistics/Statistics.php index f66268d..4f5cfb8 100644 --- a/sources/app/widgets/Statistics/Statistics.php +++ b/sources/app/widgets/Statistics/Statistics.php @@ -1,39 +1,18 @@ - * * - * Copyright (C)2014 MOVIM project - * - * See COPYING for licensing information. - */ - use Modl\SessionxDAO; class Statistics extends \Movim\Widget\Base { function load() { + $this->addjs('chart.min.js'); + $this->addjs('statistics.js'); } - function display() + function ajaxDisplay() { - $sd = new SessionxDAO; - $this->view->assign('sessions', $sd->getAll()); - - $cd = new \Modl\ConfigDAO(); - $config = $cd->get(); - - $this->view->assign('hash', $config->password); - - $tmp = array(); + $tmp = []; foreach(scandir(USERS_PATH) as $f) { if(is_dir(USERS_PATH.'/'.$f)) { @@ -45,9 +24,9 @@ class Statistics extends \Movim\Widget\Base } sort($tmp); - $days = array(); + $days = []; - $pattern = "Y-m"; + $pattern = "M Y"; foreach($tmp as $k => $time) { $key = date($pattern, $time); @@ -59,15 +38,34 @@ class Statistics extends \Movim\Widget\Base } } - $this->renderTimeLineChart($days, $this->__('statistics.monthly_sub'), "monthly.png"); + $data = new stdClass; + $data->labels = []; + $data->datasets = []; - $sum = 0; + $first = new StdClass; + $first->label = "Monthly Subscriptions"; + $first->fillColor = "rgba(255,152,0,0.5)"; + $first->strokeColor = "rgba(255,152,0,0.8)"; + $first->highlightFill = "rgba(220,220,220,0.75)"; + $first->highlightStroke = "rgba(220,220,220,1)"; + + $values = []; foreach($days as $key => $value) { - $sum = $sum + $value; - $days[$key] = $sum; + array_push($data->labels, $key); + array_push($values, $value); } - $this->renderTimeLineChart($days, $this->__('statistics.monthly_sub_cum'), "monthly_cumulated.png"); + $first->data = $values; + + array_push($data->datasets, $first); + + RPC::call('Statistics.drawGraphs', $data); + } + + function display() + { + $sd = new SessionxDAO; + $this->view->assign('sessions', $sd->getAll()); } public function getContact($username, $host) @@ -77,24 +75,6 @@ class Statistics extends \Movim\Widget\Base return $cd->get($jid); } - private function renderTimeLineChart($data, $title, $filename) - { - $chart = new Libchart\View\Chart\LineChart(750, 450); - - $dataSet = new Libchart\Model\XYDataSet(); - - foreach($data as $key => $value) { - $dataSet->addPoint(new Libchart\Model\Point($key, $value)); - } - - $chart->setDataSet($dataSet); - - $chart->setTitle($title); - $chart->render(CACHE_PATH.$filename); - - $this->view->assign('cache_path', BASE_URI.'cache/'); - } - function getTime($date) { return prepareDate(strtotime($date)); diff --git a/sources/app/widgets/Statistics/chart.min.js b/sources/app/widgets/Statistics/chart.min.js new file mode 100644 index 0000000..c4c4ef0 --- /dev/null +++ b/sources/app/widgets/Statistics/chart.min.js @@ -0,0 +1,11 @@ +/*! + * Chart.js + * http://chartjs.org/ + * Version: 1.0.1 + * + * Copyright 2015 Nick Downie + * Released under the MIT license + * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md + */ +(function(){"use strict";var t=this,i=t.Chart,e=function(t){this.canvas=t.canvas,this.ctx=t;var i=function(t,i){return t["offset"+i]?t["offset"+i]:document.defaultView.getComputedStyle(t).getPropertyValue(i)},e=this.width=i(t.canvas,"Width"),n=this.height=i(t.canvas,"Height");t.canvas.width=e,t.canvas.height=n;var e=this.width=t.canvas.width,n=this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this};e.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,maintainAspectRatio:!0,showTooltips:!0,customTooltips:!1,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},e.types={};var s=e.helpers={},n=s.each=function(t,i,e){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n=0;s--){var n=t[s];if(i(n))return n}},s.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},s=function(){this.constructor=e};return s.prototype=i.prototype,e.prototype=new s,e.extend=r,t&&a(e.prototype,t),e.__super__=i.prototype,e}),c=s.noop=function(){},u=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof define&&define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,i,e){if(f(i)){if(t>i)return i}else if(f(e)&&e>t)return e;return t},s.getDecimalPlaces=function(t){return t%1!==0&&f(t)?t.toString().split(".")[1].length:0}),S=s.radians=function(t){return t*(Math.PI/180)},x=(s.getAngleFromPoint=function(t,i){var e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s),o=2*Math.PI+Math.atan2(s,e);return 0>e&&0>s&&(o+=2*Math.PI),{angle:o,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),y=(s.splineCurve=function(t,i,e,s){var n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=s*n/(n+o),h=s*o/(n+o);return{inner:{x:i.x-a*(e.x-t.x),y:i.y-a*(e.y-t.y)},outer:{x:i.x+h*(e.x-t.x),y:i.y+h*(e.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),C=(s.calculateScaleRange=function(t,i,e,s,n){var o=2,a=Math.floor(i/(1.5*e)),h=o>=a,l=g(t),r=m(t);l===r&&(l+=.5,r>=.5&&!s?r-=.5:l+=.5);for(var c=Math.abs(l-r),u=y(c),d=Math.ceil(l/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(r/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,v=Math.pow(10,u),S=Math.round(f/v);(S>a||a>2*S)&&!h;)if(S>a)v*=2,S=Math.round(f/v),S%1!==0&&(h=!0);else if(n&&u>=0){if(v/2%1!==0)break;v/=2,S=Math.round(f/v)}else v/=2,S=Math.round(f/v);return h&&(S=o,v=f/S),{steps:S,stepValue:v,min:p,max:p+S*v}},s.template=function(t,i){function e(t,i){var e=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return i?e(i):e}if(t instanceof Function)return t(i);var s={};return e(t,i)}),w=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=C(t,{value:e+s*(n+1)})}),o},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),st?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)*.5+1)},easeInBack:function(t){var i=1.70158;return 1*(t/=1)*t*((i+1)*t-i)},easeOutBack:function(t){var i=1.70158;return 1*((t=t/1-1)*t*((i+1)*t+i)+1)},easeInOutBack:function(t){var i=1.70158;return(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},easeInBounce:function(t){return 1-w.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*w.easeInBounce(2*t):.5*w.easeOutBounce(2*t-1)+.5}}),b=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),P=s.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),L=(s.animationLoop=function(t,i,e,s,n,o){var a=0,h=w[e]||w.linear,l=function(){a++;var e=a/i,r=h(e);t.call(o,r,e,a),s.call(o,r,e),i>a?o.animationFrame=b(l):n.apply(o)};b(l)},s.getRelativePosition=function(t){var i,e,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect();return s.touches?(i=s.touches[0].clientX-o.left,e=s.touches[0].clientY-o.top):(i=s.clientX-o.left,e=s.clientY-o.top),{x:i,y:e}},s.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),k=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},F=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},L(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){k(t.chart.canvas,e,i)})}),R=s.getMaximumWidth=function(t){var i=t.parentNode;return i.clientWidth},T=s.getMaximumHeight=function(t){var i=t.parentNode;return i.clientHeight},A=(s.getMaximumSize=s.getMaximumWidth,s.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=s+"px",i.canvas.height=s*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))}),M=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},W=s.fontString=function(t,i,e){return i+" "+t+"px "+e},z=s.longestText=function(t,i,e){t.font=i;var s=0;return n(e,function(i){var e=t.measureText(i).width;s=e>s?e:s}),s},B=s.drawRoundedRectangle=function(t,i,e,s,n,o){t.beginPath(),t.moveTo(i+o,e),t.lineTo(i+s-o,e),t.quadraticCurveTo(i+s,e,i+s,e+o),t.lineTo(i+s,e+n-o),t.quadraticCurveTo(i+s,e+n,i+s-o,e+n),t.lineTo(i+o,e+n),t.quadraticCurveTo(i,e+n,i,e+n-o),t.lineTo(i,e+o),t.quadraticCurveTo(i,e,i+o,e),t.closePath()};e.instances={},e.Type=function(t,i,s){this.options=i,this.chart=s,this.id=u(),e.instances[this.id]=this,i.responsive&&this.resize(),this.initialize.call(this,t)},a(e.Type.prototype,{initialize:function(){return this},clear:function(){return M(this.chart),this},stop:function(){return P(this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=R(this.chart.canvas),s=this.options.maintainAspectRatio?e/this.chart.aspectRatio:T(this.chart.canvas);return i.width=this.chart.width=e,i.height=this.chart.height=s,A(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return C(this.options.legendTemplate,this)},destroy:function(){this.clear(),F(this,this.events);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,t.style.removeProperty?(t.style.removeProperty("width"),t.style.removeProperty("height")):(t.style.removeAttribute("width"),t.style.removeAttribute("height")),delete e.instances[this.id]},showTooltip:function(t,i){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var o=function(t){var i=!1;return t.length!==this.activeElements.length?i=!0:(n(t,function(t,e){t!==this.activeElements[e]&&(i=!0)},this),i)}.call(this,t);if(o||i){if(this.activeElements=t,this.draw(),this.options.customTooltips&&this.options.customTooltips(!1),t.length>0)if(this.datasets&&this.datasets.length>1){for(var a,h,r=this.datasets.length-1;r>=0&&(a=this.datasets[r].points||this.datasets[r].bars||this.datasets[r].segments,h=l(a,t[0]),-1===h);r--);var c=[],u=[],d=function(){var t,i,e,n,o,a=[],l=[],r=[];return s.each(this.datasets,function(i){t=i.points||i.bars||i.segments,t[h]&&t[h].hasValue()&&a.push(t[h])}),s.each(a,function(t){l.push(t.x),r.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(r),e=g(r),n=m(l),i=g(l),{x:n>this.chart.width/2?n:i,y:(o+e)/2}}.call(this,h);new e.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:u,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx,custom:this.options.customTooltips}).draw()}else n(t,function(t){var i=t.tooltipPosition();new e.Tooltip({x:Math.round(i.x),y:Math.round(i.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:C(this.options.tooltipTemplate,t),chart:this.chart,custom:this.options.customTooltips}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),e.Type.extend=function(t){var i=this,s=function(){return i.apply(this,arguments)};if(s.prototype=o(i.prototype),a(s.prototype,t),s.extend=e.Type.extend,t.name||i.prototype.name){var n=t.name||i.prototype.name,l=e.defaults[i.prototype.name]?o(e.defaults[i.prototype.name]):{};e.defaults[n]=a(l,t.defaults),e.types[n]=s,e.prototype[n]=function(t,i){var o=h(e.defaults.global,e.defaults[n],i||{});return new s(t,o,this)}}else d("Name not provided for this chart, so it hasn't been registered");return i},e.Element=function(t){a(this,t),this.initialize.apply(this,arguments),this.save()},a(e.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):a(this,this._saved),this},save:function(){return this._saved=o(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,i){this._saved[i]=this[i],this[i]=t},this),this},transition:function(t,i){return n(t,function(t,e){this[e]=(t-this._saved[e])*i+this._saved[e]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}},hasValue:function(){return f(this.value)}}),e.Element.extend=r,e.Point=e.Element.extend({display:!0,inRange:function(t,i){var e=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(i-this.y,2)=this.startAngle&&e.angle<=this.endAngle,o=e.distance>=this.innerRadius&&e.distance<=this.outerRadius;return n&&o},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,i=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*i,y:this.y+Math.sin(t)*i}},draw:function(t){var i=this.ctx;i.beginPath(),i.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),i.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),i.closePath(),i.strokeStyle=this.strokeColor,i.lineWidth=this.strokeWidth,i.fillStyle=this.fillColor,i.fill(),i.lineJoin="bevel",this.showStroke&&i.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this.ctx,i=this.width/2,e=this.x-i,s=this.x+i,n=this.base-(this.base-this.y),o=this.strokeWidth/2;this.showStroke&&(e+=o,s-=o,n+=o),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(e,this.base),t.lineTo(e,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,i){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&i>=this.y&&i<=this.base}}),e.Tooltip=e.Element.extend({draw:function(){var t=this.chart.ctx;t.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=this.caretPadding=2,e=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+i;this.x+e/2>this.chart.width?this.xAlign="left":this.x-e/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var o=this.x-e/2,a=this.y-n;if(t.fillStyle=this.fillColor,this.custom)this.custom(this);else{switch(this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-i),t.lineTo(this.x+this.caretHeight,this.y-(i+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(i+this.caretHeight)),t.closePath(),t.fill();break;case"below":a=this.y+i+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+i),t.lineTo(this.x+this.caretHeight,this.y+i+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+i+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":o=this.x-e+(this.cornerRadius+this.caretHeight);break;case"right":o=this.x-(this.cornerRadius+this.caretHeight)}B(t,o,a,e,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,o+e/2,a+s/2)}}}),e.MultiTooltip=e.Element.extend({initialize:function(){this.font=W(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=W(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,i=z(this.ctx,this.font,this.labels)+this.fontSize+3,e=g([i,t]);this.width=e+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var i=this.y-this.height/2+this.yPadding,e=t-1;return 0===t?i+this.titleFontSize/2:i+(1.5*this.fontSize*e+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){if(this.custom)this.custom(this);else{B(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(i,e){t.fillStyle=this.textColor,t.fillText(i,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(e+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[e].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}}),e.Scale=e.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(C(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?z(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,i=this.endPoint-this.startPoint;for(this.calculateYRange(i),this.buildYLabels(),this.calculateXLabelRotation();i>this.endPoint-this.startPoint;)i=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(i),this.buildYLabels(),tthis.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=z(this.ctx,this.font,this.xLabels);this.xLabelWidth=o;for(var a=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>a&&0===this.xLabelRotation||this.xLabelWidth>a&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(S(this.xLabelRotation)),t=n*e,i=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*o;this.xLabelRotation>0&&(this.endPoint-=Math.sin(S(this.xLabelRotation))*o+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var i=this.drawingArea()/(this.min-this.max);return this.endPoint-i*(t-this.min)},calculateX:function(t){var i=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),e=i/Math.max(this.valuesCount-(this.offsetGridLines?0:1),1),s=e*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=e/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,i=(this.endPoint-this.startPoint)/this.steps,e=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,o){var a=this.endPoint-i*o,h=Math.round(a),l=this.showHorizontalLines;t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),0!==o||l||(l=!0),l&&t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),l&&(t.moveTo(e,h),t.lineTo(this.width,h),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(e-5,h),t.lineTo(e,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(i,e){var s=this.calculateX(e)+x(this.lineWidth),n=this.calculateX(e-(this.offsetGridLines?.5:0))+x(this.lineWidth),o=this.xLabelRotation>0,a=this.showVerticalLines;0!==e||a||(a=!0),a&&t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),a&&(t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath()),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(-1*S(this.xLabelRotation)),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(i,0,0),t.restore()},this))}}),e.RadialScale=e.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(C(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,e,s,n,o,a,h,l,r,c,u,d=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;ip&&(p=t.x+s,n=i),t.x-sp&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e0){var s,n=e*(this.drawingArea/this.steps),o=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var a=0;a=0;i--){if(this.angleLineWidth>0){var e=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(e.x,e.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=W(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var o=this.labels.length,a=this.labels.length/2,h=a/2,l=h>i||i>o-h,r=i===h||i===o-h;t.textAlign=0===i?"center":i===a?"center":a>i?"left":"right",t.textBaseline=r?"middle":l?"bottom":"top",t.fillText(this.labels[i],s.x,s.y)}}}}}),s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(e.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return e}):"object"==typeof module&&module.exports&&(module.exports=e),t.Chart=e,e.noConflict=function(){return t.Chart=i,e}}).call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,scaleShowHorizontalLines:!0,scaleShowVerticalLines:!0,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'
    <% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>
'};i.Type.extend({name:"Bar",defaults:s,initialize:function(t){var s=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,i,e){var n=this.calculateBaseWidth(),o=this.calculateX(e)-n/2,a=this.calculateBarWidth(t);return o+a*i+i*s.barDatasetSpacing+a/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return i/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(s),e.each(i.data,function(e,n){s.bars.push(new this.BarClass({value:e,label:t.labels[n],datasetLabel:i.label,strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,i,s){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,s,i),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(i,s){e.each(i.bars,t,this,s)},this)},getBarsAtEvent:function(t){for(var i,s=[],n=e.getRelativePosition(t),o=function(t){s.push(t.bars[i])},a=0;a<% for (var i=0; i
  • <%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>'};i.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.segments=[],this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.calculateTotal(t),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({value:t.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(t.value),label:t.label})),e||(this.reflow(),this.update())},calculateCircumference:function(t){return 2*Math.PI*(Math.abs(t)/this.total)},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=Math.abs(t.value)},this)},update:function(){this.calculateTotal(this.segments),e.each(this.activeElements,function(t){t.restore(["fillColor"])}),e.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,e.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var i=t?t:1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},i),t.endAngle=t.startAngle+t.circumference,t.draw(),0===e&&(t.startAngle=1.5*Math.PI),e<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'};i.Type.extend({name:"Line",defaults:s,initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(t){return Math.pow(t-this.x,2)0&&ithis.scale.endPoint?t.controlPoints.outer.y=this.scale.endPoint:t.controlPoints.outer.ythis.scale.endPoint?t.controlPoints.inner.y=this.scale.endPoint:t.controlPoints.inner.y0&&(s.lineTo(h[h.length-1].x,this.scale.endPoint),s.lineTo(h[0].x,this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),e.each(h,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBeginAtZero:!0,scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,scaleShowLine:!0,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'
      <% for (var i=0; i
    • <%if(segments[i].label){%><%=segments[i].label%><%}%>
    • <%}%>
    '};i.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.segments=[],this.SegmentArc=i.Arc.extend({showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,ctx:this.chart.ctx,innerRadius:0,x:this.chart.width/2,y:this.chart.height/2}),this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,valuesCount:t.length}),this.updateScaleRange(t),this.scale.update(),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value,outerRadius:this.options.animateScale?0:this.scale.calculateCenterOffset(t.value),circumference:this.options.animateRotate?0:this.scale.getCircumference(),startAngle:1.5*Math.PI})),e||(this.reflow(),this.update())},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var i=[];e.each(t,function(t){i.push(t.value)});var s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s,{size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.calculateTotal(this.segments),e.each(this.segments,function(t){t.save()}),this.reflow(),this.render()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),e.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),e.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var i=t||1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},i),t.endAngle=t.startAngle+t.circumference,0===e&&(t.startAngle=1.5*Math.PI),e<% for (var i=0; i
  • <%if(datasets[i].label){%><%=datasets[i].label%><%}%>
  • <%}%>'},initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx}),this.datasets=[],this.buildScale(t),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(e,n){var o;this.scale.animation||(o=this.scale.getPointPosition(n,this.scale.calculateCenterOffset(e))),s.points.push(new this.PointClass({value:e,label:t.labels[n],datasetLabel:i.label,x:this.options.animation?this.scale.xCenter:o.x,y:this.options.animation?this.scale.yCenter:o.y,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))},this)},this),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=e.getRelativePosition(t),s=e.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},i),n=2*Math.PI/this.scale.valuesCount,o=Math.round((s.angle-1.5*Math.PI)/n),a=[];return(o>=this.scale.valuesCount||0>o)&&(o=0),s.distance<=this.scale.drawingArea&&e.each(this.datasets,function(t){a.push(t.points[o])}),a},buildScale:function(t){this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,angleLineColor:this.options.angleLineColor,angleLineWidth:this.options.angleShowLineOut?this.options.angleLineWidth:0,pointLabelFontColor:this.options.pointLabelFontColor,pointLabelFontSize:this.options.pointLabelFontSize,pointLabelFontFamily:this.options.pointLabelFontFamily,pointLabelFontStyle:this.options.pointLabelFontStyle,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,labels:t.labels,valuesCount:t.datasets[0].data.length}),this.scale.setScaleSize(),this.updateScaleRange(t.datasets),this.scale.buildYLabels()},updateScaleRange:function(t){var i=function(){var i=[];return e.each(t,function(t){t.data?i=i.concat(t.data):e.each(t.points,function(t){i.push(t.value)})}),i}(),s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s)},addData:function(t,i){this.scale.valuesCount++,e.each(t,function(t,e){var s=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[e].points.push(new this.PointClass({value:t,label:i,x:s.x,y:s.y,strokeColor:this.datasets[e].pointStrokeColor,fillColor:this.datasets[e].pointColor}))},this),this.scale.labels.push(i),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),e.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){this.eachPoints(function(t){t.save()}),this.reflow(),this.render()},reflow:function(){e.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2}),this.updateScaleRange(this.datasets),this.scale.setScaleSize(),this.scale.buildYLabels()},draw:function(t){var i=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.hasValue()&&t.transition(this.scale.getPointPosition(e,this.scale.calculateCenterOffset(t.value)),i)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(t,i){0===i?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),e.each(t.points,function(t){t.hasValue()&&t.draw()})},this)}})}.call(this); \ No newline at end of file diff --git a/sources/app/widgets/Statistics/statistics.js b/sources/app/widgets/Statistics/statistics.js new file mode 100644 index 0000000..92f9c80 --- /dev/null +++ b/sources/app/widgets/Statistics/statistics.js @@ -0,0 +1,46 @@ +var Statistics = { + drawGraphs: function(data) + { + var options = { + //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value + scaleBeginAtZero : true, + + //Boolean - Whether grid lines are shown across the chart + scaleShowGridLines : true, + + //String - Colour of the grid lines + scaleGridLineColor : "rgba(0,0,0,.05)", + + //Number - Width of the grid lines + scaleGridLineWidth : 1, + + responsive : true, + + //Boolean - Whether to show horizontal lines (except X axis) + scaleShowHorizontalLines: true, + + //Boolean - Whether to show vertical lines (except Y axis) + scaleShowVerticalLines: true, + + //Boolean - If there is a stroke on each bar + barShowStroke : true, + + //Number - Pixel width of the bar stroke + barStrokeWidth : 2, + + //Number - Spacing between each of the X value sets + barValueSpacing : 5, + + //Number - Spacing between data sets within X values + barDatasetSpacing : 1, + + //String - A legend template + legendTemplate : "
      -legend\"><% for (var i=0; i
    • \"><%if(datasets[i].label){%><%=datasets[i].label%><%}%>
    • <%}%>
    " + + }; + + var ctx = document.getElementById("monthly").getContext("2d"); + var chart = new Chart(ctx).Line(data, options); + } +} + diff --git a/sources/app/widgets/Statistics/statistics.tpl b/sources/app/widgets/Statistics/statistics.tpl index b3591d6..8a66391 100644 --- a/sources/app/widgets/Statistics/statistics.tpl +++ b/sources/app/widgets/Statistics/statistics.tpl @@ -27,15 +27,7 @@

    {$c->__('statistics.subscriptions')}

    -
    - -
    -
    - -
    - + +
    + diff --git a/sources/app/widgets/Stickers/Stickers.php b/sources/app/widgets/Stickers/Stickers.php index c644b23..8fd7fef 100644 --- a/sources/app/widgets/Stickers/Stickers.php +++ b/sources/app/widgets/Stickers/Stickers.php @@ -57,7 +57,7 @@ class Stickers extends \Movim\Widget\Base $p->set($key, 'png'); // Creating a message - $m = new \Modl\Message(); + $m = new \Modl\Message; $m->session = $this->user->getLogin(); $m->jidto = echapJid($to); $m->jidfrom = $this->user->getLogin(); @@ -66,11 +66,11 @@ class Stickers extends \Movim\Widget\Base $m->published = gmdate('Y-m-d H:i:s'); - $session = \Sessionx::start(); + $session = \Session::start(); $m->id = Uuid::uuid4(); $m->type = 'chat'; - $m->resource = $session->resource; + $m->resource = $session->get('resource'); // Sending the sticker $html = "

    Sticker

    "; @@ -82,7 +82,7 @@ class Stickers extends \Movim\Widget\Base ->setId($m->id) ->request(); - $md = new \Modl\MessageDAO(); + $md = new \Modl\MessageDAO; $md->set($m); // Sending it to Chat diff --git a/sources/app/widgets/Subscribe/subscribe.tpl b/sources/app/widgets/Subscribe/subscribe.tpl index 489ac50..ea67a5b 100644 --- a/sources/app/widgets/Subscribe/subscribe.tpl +++ b/sources/app/widgets/Subscribe/subscribe.tpl @@ -6,7 +6,7 @@ -