Browse Source

- Refactor some little stuffs

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
0db8aaf5ed
  1. 9
      app/assets/js/movim_lazy.js
  2. 5
      app/widgets/Profile/profile.tpl
  3. 2
      app/widgets/Syndication/Syndication.php
  4. 34
      lib/Lazy.php
  5. 1966
      locales/messages.pot
  6. 16
      system/controllers/BaseController.php
  7. 23
      system/template/TplPageBuilder.php
  8. 15
      system/widget/WidgetBase.php

9
app/assets/js/movim_lazy.js

@ -7,13 +7,12 @@ function MovimLazy()
{
this.init = function()
{
var links = document.querySelectorAll('a:not([href^=http])');
var links = document.querySelectorAll('ul.menu a:not([href^=http])');
for(var i = 0; i < links.length; i++) {
if(links[i].getAttribute('href') != null) {
var next = links[i].getAttribute('href').split('&')[0].substring(3);
var current =
if(links[i].search != null) {
links[i].onclick = function(event) {
event.preventDefault();
var next = this.search.split('&')[0].substring(3);
movim_ajaxSend('lazy', 'get', [CURRENT_PAGE, next]);
};
}
@ -22,4 +21,4 @@ function MovimLazy()
}
var lazy = new MovimLazy();
movim_add_onload(function() { lazy.init() });
//movim_add_onload(function() { lazy.init() });

5
app/widgets/Profile/profile.tpl

@ -1 +1,4 @@
{$c->prepareVcard()}
<div id="profile_widget">
{$c->prepareVcard()}
</div>

2
app/widgets/Syndication/Syndication.php

@ -23,8 +23,6 @@ class Syndication extends WidgetBase
{
ob_clean();
header("Content-Type: application/atom+xml; charset=UTF-8");
$this->pure = true;
$from = $_GET['f'];
$node = $_GET['n'];

34
lib/Lazy.php

@ -12,11 +12,45 @@
class Lazy {
private $_current;
private $_next;
private $_widgets = array();
public function __construct($current, $next) {
$this->_current = $current;
$this->_next = $next;
// We grab the widgets from the current view
$current_path = VIEWS_PATH . '/' . $this->_current . '.tpl';
require_once $current_path;
ob_clean();
$current_widgets = $this->_widgets;
$this->_widgets = array();
// We grab the widgets from the next view
$next_path = VIEWS_PATH . '/' . $this->_next . '.tpl';
require_once $next_path;
ob_clean();
$next_widgets = $this->_widgets;
$this->_widgets = array();
// We compare the two lists
$diff_widgets_current = array_diff($next_widgets, $current_widgets);
$diff_widgets_next = array_diff($current_widgets, $next_widgets);
\movim_log($diff_widgets_current);
\movim_log($diff_widgets_next);
$widgets = WidgetWrapper::getInstance(false);
foreach($diff_widgets as $key => $name) {
RPC::call('movim_fill', strtolower($name) . '_widget', $widgets->runWidget($name, 'build'));
}
RPC::commit();
}
private function widget($name) {
array_push($this->_widgets, $name);
}
}

1966
locales/messages.pot
File diff suppressed because it is too large
View File

16
system/controllers/BaseController.php

@ -1,9 +1,9 @@
<?php
class BaseController {
public $name = 'main'; // The name of the current page
public $name = 'main'; // The name of the current page
protected $session_only = false;// The page is protected by a session ?
protected $raw = false; // Display only the content ?
protected $raw = false; // Display only the content ?
protected $page;
function __construct() {
@ -90,12 +90,12 @@ class BaseController {
}
if($this->raw) {
echo $content->build($this->name.'.tpl');
exit;
echo $content->build($this->name.'.tpl');
exit;
} else {
$built = $content->build($this->name.'.tpl');
$this->page->setContent($built);
echo $this->page->build('page.tpl');
}
$built = $content->build($this->name.'.tpl');
$this->page->setContent($built);
echo $this->page->build('page.tpl');
}
}
}

23
system/template/TplPageBuilder.php

@ -1,20 +1,15 @@
<?php
//doc
// classname: PageBuilder
// scope: PUBLIC
//
///doc
/**
* \class PageBuilder
* \brief Templating engine for Movim
* @file TplPageBuilder.php
* This file is part of Movim.
*
* @brief This class is the templating engine for movim. It also handles themes.
*
* This class is the templating engine for movim. It determines what page to
* load based on the context and fills in placeholder values ('%' delimited).
* @author Timothée jaussoin
*
* It also handles themes.
*/
class TplPageBuilder
{
// internal variables
@ -39,7 +34,7 @@ class TplPageBuilder
}
function views_path($file)
function viewsPath($file)
{
return VIEWS_PATH . '/' . $file;
}
@ -78,7 +73,7 @@ class TplPageBuilder
if (ENVIRONMENT === 'production') ob_clean();
ob_start();
require($this->views_path($template));
require($this->viewsPath($template));
$outp = ob_get_clean();
$outp = str_replace('<%scripts%>',
$this->printCss() . $this->printScripts(),
@ -222,7 +217,7 @@ class TplPageBuilder
function widget($name, $register = true)
{
$widgets = WidgetWrapper::getInstance($register);
$widgets->runWidget($name, 'build');
echo $widgets->runWidget($name, 'build');
}
function displayFooterDebug()

15
system/widget/WidgetBase.php

@ -27,6 +27,7 @@ class WidgetBase
protected $user;
protected $name;
protected $pure; // To render the widget without the container
protected $translations = array(); // Set translations in the controller
public $events;
/**
@ -79,6 +80,12 @@ class WidgetBase
return call_user_func_array('t',func_get_args());
}
function __($key) {
if(array_key_exists($key, $this->translations)) {
return $this->t($this->translations[$key]);
}
}
function route() {
return call_user_func_array('Route::urlize',func_get_args());
}
@ -90,13 +97,7 @@ class WidgetBase
*/
function build()
{
if($this->pure)
echo $this->draw();
else
echo '
<div id="'.strtolower($this->name).'_widget">'.
$this->draw().'
</div>';
return $this->draw();
}
/*

Loading…
Cancel
Save