From 564c2942787d86e74ab8d594c837f2af50592249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaussoin=20Timoth=C3=A9e?= Date: Tue, 16 Dec 2014 20:11:34 +0100 Subject: [PATCH] - Continue Material implementation --- app/assets/js/movim_tpl.js | 10 +- app/controllers/ChatController.php | 11 + app/helpers/StringHelper.php | 2 +- app/models/contact/ContactDAO.php | 18 + app/views/chat.tpl | 14 + app/views/conf.tpl | 1 + app/views/contact.tpl | 7 +- app/views/main.tpl | 7 +- app/widgets/ConfigData/ConfigData.php | 4 +- app/widgets/ConfigData/configdata.tpl | 102 +++--- app/widgets/Contact/Contact.php | 48 ++- app/widgets/Contact/_contact.tpl | 47 +-- app/widgets/Contact/_contact_explore.tpl | 23 ++ app/widgets/Contact/_contact_header.tpl | 32 ++ app/widgets/Contact/locales.ini | 3 + app/widgets/Explore/Explore.php | 2 +- app/widgets/Header/Header.php | 31 ++ app/widgets/Header/_header_chat.tpl | 6 + app/widgets/Header/_header_contact.tpl | 12 + app/widgets/Header/_header_main.tpl | 6 + app/widgets/Header/header.tpl | 1 + app/widgets/Menu/Menu.php | 3 +- app/widgets/Menu/_menu_refresh.tpl | 2 +- app/widgets/Navigation/navigation.tpl | 15 +- app/widgets/Roster/Roster.php | 27 ++ app/widgets/Roster/_roster_search.tpl | 30 ++ app/widgets/Roster/_roster_search_results.tpl | 9 + app/widgets/Roster/roster.js | 5 +- app/widgets/Roster/roster.tpl | 11 +- app/widgets/Vcard4/_vcard4_form.tpl | 328 +++++++++--------- locales/locales.ini | 2 + system/Route.php | 1 + system/controllers/BaseController.php | 6 +- system/template/TplPageBuilder.php | 22 +- system/widget/WidgetBase.php | 12 +- system/widget/WidgetWrapper.php | 26 +- themes/material/css/article.css | 24 ++ themes/material/css/form.css | 12 +- themes/material/css/list.css | 2 +- themes/material/css/style.css | 27 +- 40 files changed, 642 insertions(+), 309 deletions(-) create mode 100644 app/controllers/ChatController.php create mode 100644 app/views/chat.tpl create mode 100644 app/widgets/Contact/_contact_explore.tpl create mode 100644 app/widgets/Contact/_contact_header.tpl create mode 100644 app/widgets/Header/Header.php create mode 100644 app/widgets/Header/_header_chat.tpl create mode 100644 app/widgets/Header/_header_contact.tpl create mode 100644 app/widgets/Header/_header_main.tpl create mode 100644 app/widgets/Header/header.tpl create mode 100644 app/widgets/Roster/_roster_search.tpl create mode 100644 app/widgets/Roster/_roster_search_results.tpl diff --git a/app/assets/js/movim_tpl.js b/app/assets/js/movim_tpl.js index 3d949be0d..8804aee83 100755 --- a/app/assets/js/movim_tpl.js +++ b/app/assets/js/movim_tpl.js @@ -49,13 +49,13 @@ var MovimTpl = { }, showPanel : function() { movim_add_class('main section > div:first-child:nth-last-child(2) ~ div', 'enabled'); - document.getElementById('menu').style.display = 'none'; - document.getElementById('back').style.display = ''; }, hidePanel : function() { - movim_remove_class('main section > div:first-child:nth-last-child(2) ~ div', 'enabled'); - document.getElementById('menu').style.display = ''; - document.getElementById('back').style.display = 'none'; + Header_ajaxReset(CURRENT_PAGE); + var selector = 'main section > div:first-child:nth-last-child(2) ~ div'; + document.querySelector(selector + ' div').innerHTML = ''; + + movim_remove_class(selector, 'enabled'); }, showMenu : function() { movim_add_class('body > nav', 'active'); diff --git a/app/controllers/ChatController.php b/app/controllers/ChatController.php new file mode 100644 index 000000000..74854765d --- /dev/null +++ b/app/controllers/ChatController.php @@ -0,0 +1,11 @@ +session_only = true; + } + + function dispatch() { + $this->page->setTitle(__('title.main', APP_TITLE)); + } +} diff --git a/app/helpers/StringHelper.php b/app/helpers/StringHelper.php index 6d1b228c0..add5bc4e9 100755 --- a/app/helpers/StringHelper.php +++ b/app/helpers/StringHelper.php @@ -299,6 +299,6 @@ function stringToColor($string) { * @return string */ function firstLetterCapitalize($string) { - return strtoupper(substr($string, 0, 1)); + return ucfirst(strtolower(substr($string, 0, 2))); } diff --git a/app/models/contact/ContactDAO.php b/app/models/contact/ContactDAO.php index ea782c8db..2eca47fb4 100755 --- a/app/models/contact/ContactDAO.php +++ b/app/models/contact/ContactDAO.php @@ -328,6 +328,24 @@ class ContactDAO extends SQL { return $this->run('Contact'); } + function searchJid($search) { + $this->_sql = + 'select *, privacy.value as privacy from contact + left outer join privacy + on contact.jid = privacy.pkey + where jid like :jid + and privacy.value = 1 + order by jid'; + + $this->prepare( + 'Contact', + array( + 'jid' => '%'.$search.'%' + ) + ); + return $this->run('Contact'); + } + function getAllPublic() { $this->_sql = 'select *, privacy.value as privacy from contact diff --git a/app/views/chat.tpl b/app/views/chat.tpl new file mode 100644 index 000000000..0c4809698 --- /dev/null +++ b/app/views/chat.tpl @@ -0,0 +1,14 @@ + + +
+ widget('Header'); ?> +
+ widget('Roster');?> +
+ widget('Contact');?> +
+
+
diff --git a/app/views/conf.tpl b/app/views/conf.tpl index a4cd211e4..2156a4329 100755 --- a/app/views/conf.tpl +++ b/app/views/conf.tpl @@ -18,6 +18,7 @@
widget('Tabs');?> + widget('Vcard4');?> widget('Config');?> widget('ConfigData');?> widget('PubsubSubscriptionConfig');?> diff --git a/app/views/contact.tpl b/app/views/contact.tpl index 124213286..0c4809698 100644 --- a/app/views/contact.tpl +++ b/app/views/contact.tpl @@ -4,12 +4,7 @@
-
- - - -

Contacts **FIXME**

-
+ widget('Header'); ?>
widget('Roster');?>
diff --git a/app/views/main.tpl b/app/views/main.tpl index b148d602f..ca6c7c98e 100755 --- a/app/views/main.tpl +++ b/app/views/main.tpl @@ -6,12 +6,7 @@
-
- - - -

News **FIXME**

-
+ widget('Header');?>
widget('Menu');?> widget('Post');?> diff --git a/app/widgets/ConfigData/ConfigData.php b/app/widgets/ConfigData/ConfigData.php index d5cc7eb05..e0d8ce99a 100755 --- a/app/widgets/ConfigData/ConfigData.php +++ b/app/widgets/ConfigData/ConfigData.php @@ -64,10 +64,10 @@ class ConfigData extends WidgetBase $stats = $cd->getStatistics(); $pd = new \modl\PostnDAO(); - $pstats = array_slice($pd->getStatistics(), 0, 10); + $pstats = array_slice($pd->getStatistics(), 0, 7); $md = new \modl\MessageDAO(); - $mstats = array_slice($md->getStatistics(), 0, 10); + $mstats = array_slice($md->getStatistics(), 0, 7); $this->view->assign('stats', $stats[0]); $this->view->assign('pstats', $pstats); diff --git a/app/widgets/ConfigData/configdata.tpl b/app/widgets/ConfigData/configdata.tpl index 244d01639..aa8318f16 100755 --- a/app/widgets/ConfigData/configdata.tpl +++ b/app/widgets/ConfigData/configdata.tpl @@ -4,7 +4,7 @@
  • {$c->__('button.clear')} @@ -12,54 +12,62 @@ {$c->__('title.contacts')} - {$stats.rosterlink}
  • - - {$c->__('title.posts')} - {$stats.post} -
    -
      - {loop="$pstats"} -
    • - - {$c->formatDate($value.month, $value.year)} - - - {$value.count} - -
    • - {/loop} -
    - +
  • + + + {$c->__('title.posts')} - {$stats.post} +
  • +
  • +
      + {loop="$pstats"} +
    • + + {$c->formatDate($value.month, $value.year)} + + + {$value.count} + +
    • + {/loop} +
    +
  • +
  • + + + {$c->__('title.messages')} - {$stats.message} +
  • - {$c->__('title.messages')} - {$stats.message} -
    -
      - {loop="$mstats"} -
    • - - {$c->formatDate($value.month, $value.year)} - - - {$value.count} - -
    • - {/loop} +
    • +
        + {loop="$mstats"} +
      • + + {$c->formatDate($value.month, $value.year)} + + + {$value.count} + +
      • + {/loop} +
      +
    -
    diff --git a/app/widgets/Contact/Contact.php b/app/widgets/Contact/Contact.php index 74758ca99..e3716e9e7 100644 --- a/app/widgets/Contact/Contact.php +++ b/app/widgets/Contact/Contact.php @@ -9,30 +9,64 @@ class Contact extends WidgetCommon function ajaxGetContact($jid) { $html = $this->prepareContact($jid); + $header = $this->prepareHeader($jid); + + Header::fill($header); RPC::call('movim_fill', 'contact_widget', $html); + RPC::call('MovimTpl.showPanel'); } - function prepareEmpty($jid) + function prepareHeader($jid) { + $cd = new \Modl\ContactDAO; + $cr = $cd->getRosterItem($jid); + $view = $this->tpl(); + $view->assign('jid', $jid); - return $view->draw('_contact_empty', true); + + if(isset($cr)) { + $view->assign('contactr', $cr); + } else { + $view->assign('contactr', null); + $c = $cd->get($jid); + if(isset($c)) { + $view->assign('contact', $c); + } else { + $view->assign('contact', null); + } + } + + return $view->draw('_contact_header', true); + } + + function prepareEmpty($jid = null) + { + if($jid == null) { + $cd = new \modl\ContactDAO(); + $users = $cd->getAllPublic(); + + $view = $this->tpl(); + $view->assign('users', array_reverse($users)); + return $view->draw('_contact_explore', true); + } else { + $view = $this->tpl(); + $view->assign('jid', $jid); + return $view->draw('_contact_empty', true); + } } function prepareContact($jid) { $cd = new \Modl\ContactDAO; $c = $cd->get($jid); - $cd = new \Modl\ContactDAO; - $cr = $cd->getRosterItem($jid); + $cr = $cd->getRosterItem($jid); $view = $this->tpl(); if(isset($c)) { - $view->assign('gender' , getGender()); - $view->assign('marital', getMarital()); $view->assign('mood', getMood()); - + $view->assign('contact', $c); $view->assign('contactr', $cr); return $view->draw('_contact', true); diff --git a/app/widgets/Contact/_contact.tpl b/app/widgets/Contact/_contact.tpl index 8d34cc35b..06c026a66 100644 --- a/app/widgets/Contact/_contact.tpl +++ b/app/widgets/Contact/_contact.tpl @@ -8,7 +8,7 @@
      {if="$contact->delay != null"}
    • - + {$c->__('last.title')}

      {$contact->delay}

    • @@ -16,7 +16,7 @@ {if="$contact->fn != null"}
    • - {$contact->fn|firstLetterCapitalize} + {$contact->fn|firstLetterCapitalize} {$c->__('general.name')}

      {$contact->fn}

    • @@ -24,7 +24,7 @@ {if="$contact->nickname != null"}
    • - {$contact->nickname|firstLetterCapitalize} + {$contact->nickname|firstLetterCapitalize} {$c->__('general.nickname')}

      {$contact->nickname}

    • @@ -32,7 +32,7 @@ {if="strtotime($contact->date) != 0"}
    • - + {$c->__('general.date_of_birth')}

      {$contact->date|strtotime|prepareDate:false}

    • @@ -40,7 +40,7 @@ {if="$contact->url != null"}
    • - + {$c->__('general.website')}

      {$contact->url}

    • @@ -48,39 +48,39 @@ {if="$contact->email != null"}
    • - + {$c->__('general.email')}

    • {/if} - {if="$contact->marital != null && $contact->marital != 'none'"} + {if="$contact->getMarital() != null"}
    • - + {$c->__('general.marital')} -

      {$marital[$contact->marital]}

      +

      {$contact->getMarital()}

    • {/if} - {if="$contact->gender != null && $contact->gender != 'N'"} + {if="$contact->getGender() != null"}
    • - + {$c->__('general.gender')} -

      {$gender[$contact->gender]}

      +

      {$contact->getGender()}

    • {/if} {if="$contactr->delay != null"}
    • - + {$c->__('last.title')}

      {$contactr->delay|strtotime|prepareDate}

    • {/if} - {if="$contact->description != null"} + {if="$contact->description != null && trim($contact->description) != ''"}
    • - + {$c->__('general.about')}

      {$contact->description}

    • @@ -89,7 +89,7 @@ {if="$contact->mood != null"} {$moods = unserialize($contact->mood)}
    • - + {$c->__('mood.title')}

      {loop="$moods"} {$mood[$value]} @@ -102,11 +102,12 @@

      {if="$contact->adrlocality != null || $contact->adrcountry != null"}
        +
      • {$c->__('position.legend')}
      • {if="$contact->adrlocality != null"}
      • - + {$c->__('position.locality')}

        {$contact->adrlocality} @@ -115,7 +116,7 @@ {/if} {if="$contact->adrcountry != null"}

      • - + {$c->__('position.country')}

        {$contact->adrcountry} @@ -132,7 +133,7 @@ {if="$contact->twitter != null"}

      • - + T Twitter

        - + S Skype

        - + Y Yahoo!

      {/if} + + + + diff --git a/app/widgets/Contact/_contact_explore.tpl b/app/widgets/Contact/_contact_explore.tpl new file mode 100644 index 000000000..728538b35 --- /dev/null +++ b/app/widgets/Contact/_contact_explore.tpl @@ -0,0 +1,23 @@ +

      {$c->__('last_registered')}

      + +
        +{loop="$users"} +
      • + + {$value->getTrueName()} +

        + {if="$value->getAge()"} + {$value->getAge()} + {/if} + {if="$value->getGender()"} + {$value->getGender()} + {/if} + {if="$value->getMarital()"} + {$value->getMarital()} + {/if} +
        + {$value->description|strip_tags} +

        +
      • +{/loop} +
      diff --git a/app/widgets/Contact/_contact_header.tpl b/app/widgets/Contact/_contact_header.tpl new file mode 100644 index 000000000..efb6abdf5 --- /dev/null +++ b/app/widgets/Contact/_contact_header.tpl @@ -0,0 +1,32 @@ + + +{if="$contactr != null"} +
        +
      • + + + +
      • +
      +

      {$contactr->getTrueName()}

      +{else} + {if="$contact != null"} +
        +
      • + + + +
      • +
      +

      {$contact->getTrueName()}

      + {else} +
        +
      • + + + +
      • +
      +

      {$jid}

      + {/if} +{/if} diff --git a/app/widgets/Contact/locales.ini b/app/widgets/Contact/locales.ini index 1b657304c..1db68c449 100644 --- a/app/widgets/Contact/locales.ini +++ b/app/widgets/Contact/locales.ini @@ -28,3 +28,6 @@ last.title = 'Last seen' [client] client.title = 'Client Informations' + +[explore] +last_registered = 'Last registered' diff --git a/app/widgets/Explore/Explore.php b/app/widgets/Explore/Explore.php index 3529f0bb2..c05763924 100755 --- a/app/widgets/Explore/Explore.php +++ b/app/widgets/Explore/Explore.php @@ -1,6 +1,6 @@ prepareHeader($view); + RPC::call('movim_fill', 'header', $html); + } + + function prepareHeader($view = null) + { + if($view == null) $view = $this->_view; + $tpl = $this->tpl(); + return $tpl->draw('_header_'.$view, true); + } + + function display() + { + $this->view->assign('header', $this->prepareHeader()); + } +} diff --git a/app/widgets/Header/_header_chat.tpl b/app/widgets/Header/_header_chat.tpl new file mode 100644 index 000000000..ed8432e89 --- /dev/null +++ b/app/widgets/Header/_header_chat.tpl @@ -0,0 +1,6 @@ +
      + + + +

      {$c->__('page.chats')}

      +
      diff --git a/app/widgets/Header/_header_contact.tpl b/app/widgets/Header/_header_contact.tpl new file mode 100644 index 000000000..943534ccc --- /dev/null +++ b/app/widgets/Header/_header_contact.tpl @@ -0,0 +1,12 @@ + diff --git a/app/widgets/Header/_header_main.tpl b/app/widgets/Header/_header_main.tpl new file mode 100644 index 000000000..feb1a1552 --- /dev/null +++ b/app/widgets/Header/_header_main.tpl @@ -0,0 +1,6 @@ +
      + + + +

      {$c->__('page.news')}

      +
      diff --git a/app/widgets/Header/header.tpl b/app/widgets/Header/header.tpl new file mode 100644 index 000000000..f0b509a8e --- /dev/null +++ b/app/widgets/Header/header.tpl @@ -0,0 +1 @@ +{$header} diff --git a/app/widgets/Menu/Menu.php b/app/widgets/Menu/Menu.php index e5d310509..774d602d0 100644 --- a/app/widgets/Menu/Menu.php +++ b/app/widgets/Menu/Menu.php @@ -8,8 +8,7 @@ class Menu extends WidgetCommon { $this->registerEvent('post', 'onStream'); $this->registerEvent('stream', 'onStream'); - - //$this->addcss('menu.css'); + $this->addjs('menu.js'); } diff --git a/app/widgets/Menu/_menu_refresh.tpl b/app/widgets/Menu/_menu_refresh.tpl index d26129566..3f137eb32 100644 --- a/app/widgets/Menu/_menu_refresh.tpl +++ b/app/widgets/Menu/_menu_refresh.tpl @@ -1,3 +1,3 @@ - + {$c->__('post.new_items', $count)} - {$c->__('button.refresh')} diff --git a/app/widgets/Navigation/navigation.tpl b/app/widgets/Navigation/navigation.tpl index 78281b196..1c740e185 100644 --- a/app/widgets/Navigation/navigation.tpl +++ b/app/widgets/Navigation/navigation.tpl @@ -10,14 +10,21 @@
    • - Contacts + {$c->__('page.contacts')}
    • - +
    • - 5 - Chats + + {$c->__('page.chats')} +
    • +
      + +
    • + + + {$c->__('page.media')}
    diff --git a/app/widgets/Roster/Roster.php b/app/widgets/Roster/Roster.php index cbb909f24..622ec84dd 100644 --- a/app/widgets/Roster/Roster.php +++ b/app/widgets/Roster/Roster.php @@ -91,6 +91,33 @@ class Roster extends WidgetBase $r->request(); } + /** + * @brief Display the search contact form + */ + function ajaxDisplaySearch() + { + $view = $this->tpl(); + $view->assign('search', $this->call('ajaxDisplayFound', 'this.value')); + Dialog::fill($view->draw('_roster_search', true)); + } + + /** + * @brief Return the found jid + */ + function ajaxDisplayFound($jid) + { + if($jid != '') { + $cd = new \Modl\ContactDAO(); + $contacts = $cd->searchJid($jid); + + $view = $this->tpl(); + $view->assign('contacts', $contacts); + $html = $view->draw('_roster_search_results', true); + + RPC::call('movim_fill', 'search_results', $html); + } + } + private function getCaps() { $capsdao = new \Modl\CapsDAO(); $caps = $capsdao->getAll(); diff --git a/app/widgets/Roster/_roster_search.tpl b/app/widgets/Roster/_roster_search.tpl new file mode 100644 index 000000000..ed0c69056 --- /dev/null +++ b/app/widgets/Roster/_roster_search.tpl @@ -0,0 +1,30 @@ +
    +
      +
    • {$c->__('roster.search')}
    • +
    • +
      +
      + + +
      +
      +
    • +
    +
    + +
    +
    + diff --git a/app/widgets/Roster/_roster_search_results.tpl b/app/widgets/Roster/_roster_search_results.tpl new file mode 100644 index 000000000..294161861 --- /dev/null +++ b/app/widgets/Roster/_roster_search_results.tpl @@ -0,0 +1,9 @@ +
      + {loop="$contacts"} +
    • + + {$value->getTrueName()} +

      {$value->jid}

      +
    • + {/loop} +
    diff --git a/app/widgets/Roster/roster.js b/app/widgets/Roster/roster.js index 0648fa838..ac81b499d 100644 --- a/app/widgets/Roster/roster.js +++ b/app/widgets/Roster/roster.js @@ -383,7 +383,6 @@ var Roster = { while(i < items.length -1) { items[i].onclick = function(e) { - MovimTpl.showPanel(); Contact_ajaxGetContact(this.id); Roster.reset(items); movim_add_class(this, 'active'); @@ -396,6 +395,10 @@ var Roster = { for(i = 0; i < list.length; i++) { movim_remove_class(list[i], 'active'); } + }, + + setFound : function(jid) { + document.querySelector('input[name=searchjid]').value = jid; } } diff --git a/app/widgets/Roster/roster.tpl b/app/widgets/Roster/roster.tpl index b82cda330..f90bad059 100644 --- a/app/widgets/Roster/roster.tpl +++ b/app/widgets/Roster/roster.tpl @@ -28,16 +28,19 @@ />
    -
    -
    -
    -
    +
    + + + + +
    + {{contact.rosterview.name}}

    {{contact.status}} - diff --git a/app/widgets/Vcard4/_vcard4_form.tpl b/app/widgets/Vcard4/_vcard4_form.tpl index 5ec2f4b36..6de6a40bf 100755 --- a/app/widgets/Vcard4/_vcard4_form.tpl +++ b/app/widgets/Vcard4/_vcard4_form.tpl @@ -1,188 +1,188 @@ +

      +
    • {$c->__('vcard.privacy_title')}
    • +
    • + + + +
      +
      +
      + + +
      +
      +
      + {$c->__('vcard.privacy_question')} +

      {$c->__('vcard.privacy_info')}

      +
    • +
    +
    -
    - {$c->__('page.profile')} -
    - - -
    -
    - - -
    -
    - - -
    +

    {$c->__('page.profile')}

    +
    + + +
    +
    + + +
    - +
    + + +
    -
    - -
    - -
    - -
    - -
    - -
    - -
    -
    +
    -
    - -
    - + + {loop="$days"} + + >{$value} {/loop} - -
    +
    - -
    - -
    - + + {loop="$months"} + + >{$value} {/loop} - -
    +
    - -
    - - + +
    +
    +
    -
    - - +
    + +
    +
    -
    +
    -
    - {$c->__('vcard.position_title')} - -
    - - -
    - -
    - -
    - -
    +
    + +
    +
    +
    -
    +
    + + +
    -
    - {$c->__('vcard.accounts_title')} - -
    - - -
    - -
    - - -
    +
    + + +
    + + {$c->__('vcard.position_title')} -
    - - +
    + + +
    + +
    + +
    +
    -
    + -
    - - {$c->__('Submit')} - - - {$c->__('Reset')} - -
    -
    - {$c->__('vcard.privacy_title')} -
    - -
    - - -
    -
    -
    -
    - {$c->__('vcard.privacy_info')} -
    -
    -
    + {$c->__('vcard.accounts_title')} + +
    + + +
    + +
    + + +
    + +
    + + +
    + + + {$c->__('Submit')} + + + {$c->__('Reset')} + + + diff --git a/locales/locales.ini b/locales/locales.ini index 5019aab9d..e637e06b7 100755 --- a/locales/locales.ini +++ b/locales/locales.ini @@ -10,6 +10,8 @@ page.explore = 'Explore' page.account_creation = 'Account Creation' page.news = 'News' page.avatar = 'Avatar' +page.contacts = 'Contacts' +page.chats = 'Chats' page.configuration = 'Configuration' page.server = 'Server' page.public_groups = 'Public Groups' diff --git a/system/Route.php b/system/Route.php index 27d0761ff..457865060 100755 --- a/system/Route.php +++ b/system/Route.php @@ -16,6 +16,7 @@ class Route extends \BaseController { 'discover' => false, 'profile' => false, 'contact' => false, + 'chat' => false, 'infos' => false, 'media' => array('f'), 'conf' => false, diff --git a/system/controllers/BaseController.php b/system/controllers/BaseController.php index b798e4eb9..59f99ca6c 100755 --- a/system/controllers/BaseController.php +++ b/system/controllers/BaseController.php @@ -73,12 +73,12 @@ class BaseController { } if($this->raw) { - echo $content->build($this->name.'.tpl'); + echo $content->build($this->name); exit; } else { - $built = $content->build($this->name.'.tpl'); + $built = $content->build($this->name); $this->page->setContent($built); - echo $this->page->build('page.tpl'); + echo $this->page->build('page'); } } } diff --git a/system/template/TplPageBuilder.php b/system/template/TplPageBuilder.php index 373187a92..bc2424e48 100755 --- a/system/template/TplPageBuilder.php +++ b/system/template/TplPageBuilder.php @@ -12,15 +12,14 @@ class TplPageBuilder { - // internal variables private $theme = 'movim'; + private $_view = ''; private $title = ''; private $menu = array(); private $content = ''; private $user; private $css = array(); private $scripts = array(); - private $polling = true; /** * Constructor. Determines whether to show the login page to the user or the @@ -70,8 +69,10 @@ class TplPageBuilder /** * Actually generates the page from templates. */ - function build($template) + function build($view) { + $this->_view = $view; + $template = $this->_view.'.tpl'; //if (ENVIRONMENT === 'production') ob_clean(); ob_start(); @@ -199,15 +200,6 @@ class TplPageBuilder $this->content .= $data; } - function addContent($data, $append = true) - { - if($append) { - $this->content .= $data; - } else { - $this->content = $data . $this->content; - } - } - function content() { echo $this->content; @@ -216,9 +208,11 @@ class TplPageBuilder /** * Loads up a widget and prints it at the current place. */ - function widget($name, $register = true) + function widget($name) { - $widgets = WidgetWrapper::getInstance($register); + $widgets = WidgetWrapper::getInstance(); + $widgets->setView($this->_view); + echo $widgets->runWidget($name, 'build'); } diff --git a/system/widget/WidgetBase.php b/system/widget/WidgetBase.php index 202f2479f..8019c7369 100755 --- a/system/widget/WidgetBase.php +++ b/system/widget/WidgetBase.php @@ -28,15 +28,19 @@ class WidgetBase protected $name; protected $pure; // To render the widget without the container protected $translations = array(); // Set translations in the controller + protected $_view; public $events; /** * Initialises Widget stuff. */ - function __construct($light = false) + function __construct($light = false, $view = null) { + if($view != null) $this->_view = $view; + $this->load(); - + $this->name = get_class($this); + // If light loading enabled, we stop here if($light) return; @@ -78,12 +82,10 @@ class WidgetBase $this->view->objectConfigure($config); $this->view->assign('c', $this); - - $this->name = get_class($this); $this->pure = false; } - + function t() { return call_user_func_array('t',func_get_args()); } diff --git a/system/widget/WidgetWrapper.php b/system/widget/WidgetWrapper.php index 343a8401f..1b6de546f 100644 --- a/system/widget/WidgetWrapper.php +++ b/system/widget/WidgetWrapper.php @@ -27,6 +27,8 @@ class WidgetWrapper private $_widgets = array(); private $_events = array(); + private $_view = ''; // The current page where the widget is displayed + private $css = array(); // All the css loaded by the widgets so far. private $js = array(); // All the js loaded by the widgets so far. @@ -37,8 +39,6 @@ class WidgetWrapper public function registerAll($load = false) { $widgets_dir = scandir(APP_PATH ."widgets/"); - - $old = memory_get_usage(); foreach($widgets_dir as $widget_dir) { if(is_dir(APP_PATH ."widgets/".$widget_dir) && @@ -47,8 +47,6 @@ class WidgetWrapper if($load) $this->loadWidget($widget_dir, true); array_push($this->_widgets, $widget_dir); } - - $old = memory_get_usage(); } } @@ -67,6 +65,15 @@ class WidgetWrapper } } + /** + * @desc Set the view + * @param $page the name of the current view + */ + public function setView($view) + { + $this->_view = $view; + } + /** * @desc Loads a widget and returns it * @param $name the name of the widget @@ -101,11 +108,17 @@ class WidgetWrapper } } } else { - $widget = new $name(); + if($this->_view != '') { + $widget = new $name(false, $this->_view); + } else { + $widget = new $name(); + } // Collecting stuff generated by the widgets. $this->css = array_merge($this->css, $widget->loadcss()); $this->js = array_merge($this->js, $widget->loadjs()); } + + return $widget; } /** @@ -119,8 +132,7 @@ class WidgetWrapper */ function runWidget($widget_name, $method, array $params = null) { - $this->loadWidget($widget_name); - $widget = new $widget_name(); + $widget = $this->loadWidget($widget_name); if(!is_array($params)) $params = array(); diff --git a/themes/material/css/article.css b/themes/material/css/article.css index 2a706e49f..2ead2ac8f 100644 --- a/themes/material/css/article.css +++ b/themes/material/css/article.css @@ -30,3 +30,27 @@ article img { article section p { margin-bottom: 1rem; } + +article section content ul li { + line-height: 3rem; + padding-left: 2rem; + list-style-type: circle; + list-style-position: inside; + min-height: 4rem; +} + +article section content strong, +article section content b { + font-weight: 700; +} + +article section content code, +article section content pre { + font-family: monospace; +} + +article section content cite, +article section content blockquote { + padding-left: 4rem; + font-style: italic; +} diff --git a/themes/material/css/form.css b/themes/material/css/form.css index 5acde2cea..a5faa1d3a 100644 --- a/themes/material/css/form.css +++ b/themes/material/css/form.css @@ -192,5 +192,15 @@ input[type=button].flat:focus { } .button.action { - + position: fixed; + bottom: 2rem; + right: 2rem; + border-radius: 10rem; + width: 3rem; + min-height: 0rem; + line-height: 6rem; + padding: 1rem; + height: 8rem; + z-index: 1; + font-size: 3rem; } diff --git a/themes/material/css/list.css b/themes/material/css/list.css index 4e1298ad7..6e021da6c 100644 --- a/themes/material/css/list.css +++ b/themes/material/css/list.css @@ -89,7 +89,7 @@ ul li span { ul li > div.control { float: right; - text-align: center; + text-align: right; min-width: 5rem; font-size: 2.5rem; opacity: 0.7; diff --git a/themes/material/css/style.css b/themes/material/css/style.css index a573cd346..3cb4e9faa 100644 --- a/themes/material/css/style.css +++ b/themes/material/css/style.css @@ -171,6 +171,8 @@ main > header { color: white; z-index: 2; box-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.5); + white-space: nowrap; + text-overflow: ellipsis; } main > header ul { @@ -180,6 +182,7 @@ main > header ul { main > header ul li { float: left; height: 7rem; + min-width: 0; line-height: 7rem; width: 7rem; padding: 0; @@ -198,6 +201,7 @@ main header + section { main section > div { overflow-y: auto; display: block; + position: relative; float: left; height: 100%; width: 100%; @@ -282,9 +286,9 @@ span.icon.bubble { overflow: hidden; color: white; font-size: 0; + font-size: 2.5rem; } -span.icon.bubble:first-letter, span.icon.bubble i { font-size: 3rem; line-height: 5rem; @@ -311,6 +315,14 @@ span.icon.small.bubble i { vertical-align: text-top; } +main > header ul li span.icon { + left: 1rem; +} + +main ul li .control > i { + margin-left: 0; +} + /* Card */ .card { @@ -337,8 +349,8 @@ header .icon:hover { header.big { background-size: cover, cover; background-position: center center; - height: 20rem; - max-height: 20rem; + height: 25rem; + max-height: 25rem; width: 100%; max-width: 100%; color: white; @@ -389,14 +401,17 @@ header.big p { .dialog > section:hover { } -.dialog > section > ul li { +.dialog > section ul li { + padding-right: 0; padding-left: 7rem; } -.dialog > section > ul li.subheader { + +.dialog > section ul li.subheader, +.dialog > section ul.simple li { padding-left: 0; } -.dialog > section > ul li .icon { +.dialog > section ul li .icon { left: 1rem; }