Browse Source

- Rename a few method in camelCase

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
d5b0edd621
  1. 2
      app/views/page.tpl
  2. 14
      app/widgets/Avatar/Avatar.php
  3. 2
      app/widgets/Login/Login.php
  4. 2
      mud.php
  5. 5
      system/Conf.php
  6. 14
      system/Event.php
  7. 2
      system/RPC.php
  8. 4
      system/Route.php
  9. 15
      system/User.php
  10. 19
      system/controllers/BaseController.php
  11. 18
      system/controllers/FrontController.php
  12. 22
      system/i18n/i18n.php
  13. 30
      system/template/TplPageBuilder.php
  14. 14
      system/widget/WidgetWrapper.php

2
app/views/page.tpl

@ -5,7 +5,7 @@
<meta charset="utf-8" />
<title><?php $this->title();?></title>
<link rel="shortcut icon" href="<?php $this->link_file('img/favicon.ico');?>" />
<link rel="shortcut icon" href="<?php $this->linkFile('img/favicon.ico');?>" />
<link rel="stylesheet" href="<?php echo BASE_URI; ?>app/assets/js/leaflet.css" />
<script src="<?php echo BASE_URI; ?>app/assets/js/leaflet.js"></script>

14
app/widgets/Avatar/Avatar.php

@ -88,20 +88,6 @@ class Avatar extends WidgetBase
function ajaxAvatarSubmit($avatar)
{
/*
$cd = new \modl\ContactDAO();
$c = $cd->get($this->user->getLogin());
if($c == null)
$c = new modl\Contact();
//$c->phototype = $avatar->phototype->value;
$c->photobin = $avatar->photobin->value;
$c->createThumbnails();
$cd->set($c);*/
$p = new \Picture;
$p->fromBase((string)$avatar->photobin->value);
$p->set($this->user->getLogin());

2
app/widgets/Login/Login.php

@ -263,7 +263,7 @@ class Login extends WidgetBase {
$wrapper = WidgetWrapper::getInstance(false);
$sess = Session::start(APP_NAME);
$sess->set('registered_events', $wrapper->register_events());
$sess->set('registered_events', $wrapper->registerEvents());
// BOSH + XMPP connexion test
$warning = moxl\login();

2
mud.php

@ -46,7 +46,7 @@ function comploc() {
$langs = load_lang_array();
foreach($langs as $key => $value) {
$langarr = parse_lang_file(DOCUMENT_ROOT . '/locales/' . $key . '.po');
$langarr = parseLangFile(DOCUMENT_ROOT . '/locales/' . $key . '.po');
$out = '<?php global $translations;
$translations = array(';

5
system/Conf.php

@ -8,7 +8,6 @@ class Conf
public static $conf_files = array();
/* Return the general configuration */
static function getServerConf() {
$conf_file = DOCUMENT_ROOT . self::$conf_path . "/conf.php";
return self::getConf('server', $conf_file);
@ -51,7 +50,6 @@ class Conf
}
/* Return the element of the general configuration */
static function getServerConfElement($element) {
$conf = self::getServerConf();
if(!isset($conf[$element])) {
@ -63,8 +61,7 @@ class Conf
}
}
/* Actually reads the XML file if it exists */
/* Actually reads the PHP file if it exists */
static function readConfFile($file_path) {
if(!file_exists($file_path)) {
throw new MovimException(t("Cannot load file '%s'", $file_path));

14
system/Event.php

@ -18,24 +18,12 @@ class Event
$widgets = WidgetWrapper::getInstance(false);
/*
* $widgets->iterate('runEvents', array(
array(
'type' => 'allEvents',
'data' => $event,
)));*/
$widgets->iterate('runEvents', array(
array(
'type' => $type,
'data' => $event,
)));
/*$widgets->iterateAll('isEvents', array(
array(
'type' => $type,
'data' => $event,
)));*/
// Outputting any RPC calls.
RPC::commit();
}

2
system/RPC.php

@ -116,7 +116,7 @@ class RPC
}
$widgets = WidgetWrapper::getInstance(false);
$widgets->run_widget($widget_name, (string)$request->func, $result);
$widgets->runWidget($widget_name, (string)$request->func, $result);
}
}
}

4
system/Route.php

@ -29,14 +29,14 @@ class Route extends \BaseController {
);
if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) {
$q = $this->fetch_get('query');
$q = $this->fetchGet('query');
//load data in $_GET variable
if (!$this->find($q)) {
$this->error404();
exit;
}
} else {
$q = $this->fetch_get('q');
$q = $this->fetchGet('q');
if(empty($q))
$_GET['q'] = 'main';
}

15
system/User.php

@ -1,9 +1,18 @@
<?Php
<?php
/**
* \class User
* \brief Handles the user's login and user.
* @file User.php
* This file is part of Movim.
*
* @brief Handles the user's login and user.
*
* @author Jaussoin Timothée
*
* @date 2014
*
* Copyright (C)2014 Movim
*
* See COPYING for licensing information.
*/
class User {
private $xmppSession;

19
system/controllers/BaseController.php

@ -7,13 +7,12 @@ class BaseController {
protected $page;
function __construct() {
$this->load_language();
$this->loadLanguage();
$this->page = new TplPageBuilder();
$this->page->addScript('movim_hash.js');
$this->page->addScript('movim_utils.js');
$this->page->addScript('movim_base.js');
$this->page->addScript('movim_tpl.js');
//$this->page->addScript('movim_session.js');
$this->page->addScript('movim_rpc.js');
}
@ -21,23 +20,23 @@ class BaseController {
/**
* Loads up the language, either from the User or default.
*/
function load_language() {
function loadLanguage() {
$user = new User();
if($user->isLogged()) {
try{
$lang = $user->getConfig('language');
load_language($lang);
loadLanguage($lang);
}
catch(MovimException $e) {
// Load default language.
load_language(\system\Conf::getServerConfElement('defLang'));
loadLanguage(\system\Conf::getServerConfElement('defLang'));
}
}
else if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
load_language_auto();
loadLanguageAuto();
}
else {
load_language(\system\Conf::getServerConfElement('defLang'));
loadLanguage(\system\Conf::getServerConfElement('defLang'));
}
}
@ -47,7 +46,7 @@ class BaseController {
* @param name is the desired variable's name.
* @return the value of the requested variable, or FALSE.
*/
protected function fetch_get($name)
protected function fetchGet($name)
{
if(isset($_GET[$name])) {
return htmlentities($_GET[$name]);
@ -62,7 +61,7 @@ class BaseController {
* @param name is the desired variable's name.
* @return the value of the requested variable, or FALSE.
*/
protected function fetch_post($name)
protected function fetchPost($name)
{
if(isset($_POST[$name])) {
return htmlentities($_POST[$name]);
@ -71,7 +70,7 @@ class BaseController {
}
}
function check_session() {
function checkSession() {
if($this->session_only) {
$user = new User();

18
system/controllers/FrontController.php

@ -18,15 +18,15 @@ class FrontController extends BaseController
$r = new Route();
// Note that the request is always specified by 'q'.
if($r->find($this->fetch_get('q'))) {
$request = $this->fetch_get('q');
$this->run_req($request);
if($r->find($this->fetchGet('q'))) {
$request = $this->fetchGet('q');
$this->runRequest($request);
} else {
$this->run_req('notfound');
$this->runRequest('notfound');
}
}
private function load_controller($request) {
private function loadController($request) {
$class_name = ucfirst($request).'Controller';
if(file_exists(APP_PATH . 'controllers/'.$class_name.'.php')) {
$controller_path = APP_PATH . 'controllers/'.$class_name.'.php';
@ -43,19 +43,19 @@ class FrontController extends BaseController
/*
* Here we load, instanciate and execute the correct controller
*/
public function run_req($request) {
$c = $this->load_controller($request);
public function runRequest($request) {
$c = $this->loadController($request);
if(is_callable(array($c, 'load'))) {
$c->name = $request;
$c->load();
$c->check_session();
$c->checkSession();
$c->dispatch();
// If the controller ask to display a different page
if($request != $c->name) {
$new_name = $c->name;
$c = $this->load_controller($new_name);
$c = $this->loadController($new_name);
$c->name = $new_name;
$c->load();
$c->dispatch();

22
system/i18n/i18n.php

@ -65,7 +65,7 @@ function t($string)
return $lstring;
}
function get_quoted_string($string)
function getQuotedString($string)
{
$matches = array();
preg_match('#"(.+)"#', $string, $matches);
@ -77,7 +77,7 @@ function get_quoted_string($string)
/**
* Parses a .po file.
*/
function parse_lang_file($pofile)
function parseLangFile($pofile)
{
if(!file_exists($pofile)) {
return false;
@ -103,14 +103,14 @@ function parse_lang_file($pofile)
$trans_string[$msgid] = $msgstr;
}
$last_token = "msgid";
$msgid = get_quoted_string($line);
$msgid = getQuotedString($line);
}
else if(preg_match('#^msgstr#', $line)) {
$last_token = "msgstr";
$msgstr = get_quoted_string($line);
$msgstr = getQuotedString($line);
}
else {
$last_token .= get_quoted_string($line);
$last_token .= getQuotedString($line);
}
}
if($last_token == "msgstr") {
@ -125,7 +125,7 @@ function parse_lang_file($pofile)
/**
* Auto-detects and loads the language.
*/
function load_language_auto()
function loadLanguageAuto()
{
$langs = array();
$langNotFound = true;
@ -146,10 +146,10 @@ function load_language_auto()
$exploded = explode('-', $key);
$key = reset($exploded);
if($key == 'en') {
load_language(\system\Conf::getServerConfElement('defLang'));
loadLanguage(\system\Conf::getServerConfElement('defLang'));
$langNotFound = false;
} elseif(file_exists(DOCUMENT_ROOT . '/locales/' . $key . '.po')) {
load_language($key);
loadLanguage($key);
$langNotFound = false;
}
}
@ -158,7 +158,7 @@ function load_language_auto()
/**
* Loads the given language.
*/
function load_language($lang)
function loadLanguage($lang)
{
global $translations;
global $language;
@ -172,7 +172,7 @@ function load_language($lang)
// And we set our gloabl $translations
require_once(DOCUMENT_ROOT . '/cache/locales/' . $lang . '.php');
} else
$translations = parse_lang_file(DOCUMENT_ROOT . '/locales/' . $lang . '.po');
$translations = parseLangFile(DOCUMENT_ROOT . '/locales/' . $lang . '.po');
$language = $lang;
@ -195,7 +195,7 @@ function load_extra_lang($directory)
$directory .= '/';
}
$trans = parse_lang_file($directory . $language . '.po');
$trans = parseLangFile($directory . $language . '.po');
if(!$trans) {
return false;

30
system/template/TplPageBuilder.php

@ -49,7 +49,7 @@ class TplPageBuilder
* @param file is the path to the file relative to the theme's root
* @param return optionally returns the link instead of printing it if set to true
*/
function link_file($file, $return = false)
function linkFile($file, $return = false)
{
$path = BASE_URI . 'themes/' . $this->theme . '/' . $file;
@ -63,31 +63,13 @@ class TplPageBuilder
/**
* Inserts the link tag for a css file.
*/
function theme_css($file)
function themeCss($file)
{
echo '<link rel="stylesheet" href="'
. $this->link_file($file, true) .
. $this->linkFile($file, true) .
"\" type=\"text/css\" />\n";
}
/**
* Inserts the link tag for a theme picture
*/
function theme_img($src, $alt)
{
$size = getimagesize($this->link_file($src, true));
$outp = '<img src="'
. $this->link_file($src, true) . '" '
. $size["3"];
if(!empty($alt)) {
$outp .=' alt="'.$alt.'"';
}
$outp .='>';
return $outp;
}
/**
* Actually generates the page from templates.
*/
@ -178,7 +160,7 @@ class TplPageBuilder
*/
function addCss($file)
{
$this->css[] = $this->link_file($file, true);
$this->css[] = $this->linkFile($file, true);
}
function scripts()
@ -239,7 +221,7 @@ class TplPageBuilder
function widget($name, $register = true)
{
$widgets = WidgetWrapper::getInstance($register);
$widgets->run_widget($name, 'build');
$widgets->runWidget($name, 'build');
}
function displayFooterDebug()

14
system/widget/WidgetWrapper.php

@ -118,7 +118,7 @@ class WidgetWrapper
/**
* Loads a widget and returns it.
*/
public function load_widget($widget_name)
public function loadWidget($widget_name)
{
// Attempting to load the user's widgets in priority
$widget_path = "";
@ -145,13 +145,13 @@ class WidgetWrapper
* be passed along to the method.
* @return what the widget's method returns.
*/
function run_widget($widget_name, $method, array $params = NULL)
function runWidget($widget_name, $method, array $params = NULL)
{
if($this->register_widgets &&
!in_array($widget_name, $this->loaded_widgets))
$this->loaded_widgets[] = $widget_name;
$widget = $this->load_widget($widget_name);
$widget = $this->loadWidget($widget_name);
if(!is_array($params))
$params = array();
@ -169,10 +169,10 @@ class WidgetWrapper
*
* @return the registered events
*/
function register_events() {
function registerEvents() {
$widgets = $this->get_all_widgets();
foreach($widgets as $widget_name) {
$widget = $this->load_widget($widget_name);
$widget = $this->loadWidget($widget_name);
// We save the registered events of the widget for the filter
if(isset($widget->events)) {
foreach($widget->events as $key => $value) {
@ -211,14 +211,14 @@ class WidgetWrapper
if(isset($widgets) && is_array($widgets))
foreach($widgets as $widget)
$this->run_widget($widget, $method, $params);
$this->runWidget($widget, $method, $params);
}
/*
function iterateAll($method, array $params = NULL) {
$widgets = $this->get_all_widgets();
$isevent = array();
foreach($widgets as $widget) {
if($this->run_widget($widget, $method, $params))
if($this->runWidget($widget, $method, $params))
$isevent[$widget] = true;
}

Loading…
Cancel
Save