コード例 #1
0
ファイル: edit.html.php プロジェクト: kenjs/Goteo
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Goteo is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with Goteo.  If not, see <http://www.gnu.org/licenses/agpl.txt>.
 *
 */
use Goteo\Library\Text, Goteo\Library\i18n\Lang;
$project = $this['project'];
$langs = Lang::getAll();
$filters = $this['filters'];
?>
<script type="text/javascript">
function assign() {
    if (document.getElementById('assign-user').value != '') {
        document.getElementById('form-assign').submit();
        return true;
    } else {
        alert('No has seleccionado ningun traductor');
        return false;
    }
}
</script>
<div class="widget">
<?php 
コード例 #2
0
ファイル: users.php プロジェクト: anvnguyen/Goteo
 public static function process($action = 'list', $id = null, $filters = array(), $subaction = '')
 {
     // @NODESYS
     $nodes = array();
     // @NODESYS
     $node = \GOTEO_NODE;
     $errors = array();
     switch ($action) {
         case 'add':
             // si llega post: creamos
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 // para crear se usa el mismo método save del modelo, hay que montar el objeto
                 $user = new Model\User();
                 $user->userid = $_POST['userid'];
                 $user->name = $_POST['name'];
                 $user->email = $_POST['email'];
                 $user->password = $_POST['password'];
                 $user->node = !empty($_POST['node']) ? $_POST['node'] : \GOTEO_NODE;
                 if (isset($_SESSION['admin_node']) && $user->node != $_SESSION['admin_node']) {
                     $user->node = $_SESSION['admin_node'];
                 }
                 $user->save($errors);
                 if (empty($errors)) {
                     // mensaje de ok y volvemos a la lista de usuarios
                     Message::Info(Text::get('user-register-success'));
                     throw new Redirection('/admin/users/manage/' . $user->id);
                 } else {
                     // si hay algun error volvemos a poner los datos en el formulario
                     $data = $_POST;
                     Message::Error(implode('<br />', $errors));
                 }
             }
             // vista de crear usuario
             return new View('view/admin/index.html.php', array('folder' => 'users', 'file' => 'add', 'data' => $data, 'nodes' => $nodes));
             break;
         case 'edit':
             $user = Model\User::get($id);
             // si llega post: actualizamos
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $tocado = array();
                 // para crear se usa el mismo método save del modelo, hay que montar el objeto
                 if (!empty($_POST['email'])) {
                     $user->email = $_POST['email'];
                     $tocado[] = Text::_('el email');
                 }
                 if (!empty($_POST['password'])) {
                     $user->password = $_POST['password'];
                     $tocado[] = Text::_('la contraseña');
                 }
                 if (!empty($tocado) && $user->update($errors)) {
                     // Evento Feed
                     $log = new Feed();
                     $log->setTarget($user->id, 'user');
                     $log->populate(Text::_('Operación sobre usuario'), '/admin/users', \vsprintf('El admin %s ha %s del usuario %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Tocado ' . implode(' y ', $tocado)), Feed::item('user', $user->name, $user->id))));
                     $log->doAdmin('user');
                     unset($log);
                     // mensaje de ok y volvemos a la lista de usuarios
                     Message::Info(Text::_('Datos actualizados'));
                     throw new Redirection('/admin/users');
                 } else {
                     // si hay algun error volvemos a poner los datos en el formulario
                     $data = $_POST;
                     Message::Error(Text::_('No se ha guardado correctamente. ') . implode('<br />', $errors));
                 }
             }
             // vista de editar usuario
             return new View('view/admin/index.html.php', array('folder' => 'users', 'file' => 'edit', 'user' => $user, 'data' => $data, 'nodes' => $nodes));
             break;
         case 'manage':
             // si llega post: ejecutamos + mensaje + seguimos editando
             // operación y acción para el feed
             $mngSa = static::_manageSubAct();
             $sql = $mngSa[$subaction]['sql'];
             $log_action = $mngSa[$subaction]['log'];
             if (!empty($sql)) {
                 $user = Model\User::getMini($id);
                 if (Model\User::query($sql, array(':user' => $id))) {
                     // mensaje de ok y volvemos a la gestion del usuario
                     //                            Message::Info('Ha <strong>' . $log_action . '</strong> al usuario <strong>'.$user->name.'</strong> CORRECTAMENTE');
                     $log_text = 'El admin %s ha %s al usuario %s';
                     // procesos adicionales
                     switch ($subaction) {
                         case 'admin':
                         case 'noadmin':
                             // @NODESYS : this admin/noadmin subactions are here for NODESYS module extra
                             break;
                         case 'translator':
                             // le ponemos todos los idiomas (excepto el español)
                             $sql = "INSERT INTO user_translang (user, lang) SELECT '{$id}' as user, id as lang FROM `lang` WHERE id != 'es'";
                             Model\User::query($sql);
                             break;
                         case 'notranslator':
                             // quitamos los idiomas
                             $sql = "DELETE FROM user_translang WHERE user = :user";
                             Model\User::query($sql, array(':user' => $id));
                             break;
                     }
                 } else {
                     // mensaje de error y volvemos a la gestion del usuario
                     Message::Error('Ha FALLADO cuando ha <strong>' . $log_action . '</strong> al usuario <strong>' . $id . '</strong>');
                     $log_text = 'Al admin %s le ha <strong>FALLADO</strong> cuando ha %s al usuario %s';
                 }
                 // Evento Feed
                 $log = new Feed();
                 $log->setTarget($user->id, 'user');
                 $log->populate(Text::_('Operación sobre usuario'), '/admin/users', \vsprintf($log_text, array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', $log_action), Feed::item('user', $user->name, $user->id))));
                 $log->doAdmin('user');
                 unset($log);
                 throw new Redirection('/admin/users/manage/' . $id);
             }
             $user = Model\User::get($id);
             $viewData = array('folder' => 'users', 'file' => 'manage', 'user' => $user, 'nodes' => $nodes);
             $viewData['roles'] = Model\User::getRolesList();
             $viewData['langs'] = Lang::getAll();
             // quitamos el español
             unset($viewData['langs']['es']);
             // vista de gestión de usuario
             return new View('view/admin/index.html.php', $viewData);
             break;
             // aplicar idiomas
         // aplicar idiomas
         case 'translang':
             if (!isset($_POST['user'])) {
                 Message::Error(Text::_('Hemos perdido de vista al usuario'));
                 throw new Redirection('/admin/users');
             } else {
                 $user = $_POST['user'];
             }
             $sql = "DELETE FROM user_translang WHERE user = :user";
             Model\User::query($sql, array(':user' => $user));
             $anylang = false;
             foreach ($_POST as $key => $value) {
                 if (\substr($key, 0, \strlen('lang_')) == 'lang_') {
                     $sql = "INSERT INTO user_translang (user, lang) VALUES (:user, :lang)";
                     if (Model\User::query($sql, array(':user' => $user, ':lang' => $value))) {
                         $anylang = true;
                     }
                 }
             }
             if (!$anylang) {
                 Message::Error(Text::_('No se ha seleccionado ningún idioma, este usuario tendrá problemas en su panel de traducción!'));
             } else {
                 Message::Info(Text::_('Se han aplicado al traductor los idiomas seleccionados'));
             }
             throw new Redirection('/admin/users/manage/' . $user);
             break;
         case 'impersonate':
             $user = Model\User::get($id);
             // vista de acceso a suplantación de usuario
             return new View('view/admin/index.html.php', array('folder' => 'users', 'file' => 'impersonate', 'user' => $user, 'nodes' => $nodes));
             break;
         case 'move':
             $user = Model\User::get($id);
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $values = array(':id' => $id, ':node' => $_POST['node']);
                 try {
                     $sql = "UPDATE user SET node = :node WHERE id = :id";
                     if (Model\User::query($sql, $values)) {
                         $log_text = 'El admin %s ha <span class="red">movido</span> el usuario %s al nodo %s';
                     } else {
                         $log_text = 'Al admin %s le ha <span class="red">fallado al mover</span> el usuario %s al nodo %s';
                     }
                     // Evento Feed
                     $log = new Feed();
                     $log->setTarget($user->id, 'user');
                     $log->populate('User cambiado de nodo (admin)', '/admin/users', \vsprintf($log_text, array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('user', $user->name, $user->id), Feed::item('user', $nodes[$_POST['node']]))));
                     Message::Error($log->html);
                     $log->doAdmin('user');
                     unset($log);
                     throw new Redirection('/admin/users');
                 } catch (\PDOException $e) {
                     Message::Error("Ha fallado! " . $e->getMessage());
                 }
             }
             // vista de acceso a suplantación de usuario
             return new View('view/admin/index.html.php', array('folder' => 'users', 'file' => 'move', 'user' => $user, 'nodes' => $nodes));
             break;
         case 'list':
         default:
             if (!empty($filters['filtered'])) {
                 $users = Model\User::getAll($filters, $node);
             } else {
                 $users = array();
             }
             $status = array('active' => Text::_('Activo'), 'inactive' => Text::_('Inactivo'));
             $interests = Model\User\Interest::getAll();
             $roles = Model\User::getRolesList();
             $roles['user'] = Text::_('Solo usuario');
             $types = array('creators' => Text::_('Impulsores'), 'investors' => Text::_('Cofinanciadores'), 'supporters' => Text::_('Colaboradores'));
             $orders = array('created' => Text::_('Fecha de alta'), 'name' => Text::_('Alias'), 'id' => Text::_('User'), 'amount' => Text::_('Cantidad'), 'projects' => Text::_('Proyectos'));
             // proyectos con aportes válidos
             $projects = Model\Invest::projects(true, $node);
             return new View('view/admin/index.html.php', array('folder' => 'users', 'file' => 'list', 'users' => $users, 'filters' => $filters, 'status' => $status, 'interests' => $interests, 'roles' => $roles, 'types' => $types, 'nodes' => $nodes, 'projects' => $projects, 'orders' => $orders));
             break;
     }
 }
コード例 #3
0
ファイル: lang.html.php プロジェクト: isbkch/Goteo
 *  Goteo is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Goteo is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with Goteo.  If not, see <http://www.gnu.org/licenses/agpl.txt>.
 *
 */
use Goteo\Library\i18n\Lang;
$langs = Lang::getAll(true);
?>

    <ul class="lang">
        <?php 
foreach ($langs as $lang) {
    ?>
            <?php 
    if ($lang->id == LANG) {
        continue;
    }
    ?>
            <li >
            <a href="?lang=<?php 
    echo $lang->id;
    ?>
コード例 #4
0
ファイル: translate.php プロジェクト: kenjs/Goteo
 public function index($table = '', $action = 'list', $id = null, $auxAction = 'list', $contentId = null)
 {
     $_SESSION['user']->translangs = Model\User\Translate::getLangs($_SESSION['user']->id);
     if (empty($_SESSION['user']->translangs)) {
         Message::Error(Text::_('No tienes ningún idioma, contacta con el administrador'));
         throw new Redirection('/dashboard');
     }
     if (empty($_SESSION['translate_lang']) || !isset($_SESSION['user']->translangs[$_SESSION['translate_lang']])) {
         if (count($_SESSION['user']->translangs) > 1 && isset($_SESSION['user']->translangs['en'])) {
             $_SESSION['translate_lang'] = 'en';
         } else {
             $_SESSION['translate_lang'] = current(array_keys($_SESSION['user']->translangs));
         }
     }
     if ($table == '') {
         return new View('view/translate/index.html.php', array('menu' => self::menu()));
     }
     // para el breadcrumbs segun el contenido
     $section = $table == 'news' || $table == 'promote' ? 'home' : 'contents';
     // muy especial para traducción de nodo
     if ($table == 'node') {
         $BC = self::menu(array('section' => 'node', 'node' => $action, 'option' => $id, 'action' => $auxAction, 'id' => $contentId));
     } else {
         $BC = self::menu(array('section' => $section, 'option' => $table, 'action' => $action, 'id' => $id));
     }
     define('ADMIN_BCPATH', $BC);
     $errors = array();
     // la operación según acción
     switch ($table) {
         case 'texts':
             // comprobamos los filtros
             $filters = array();
             $fields = array('group', 'text', 'pending');
             if (!isset($_GET['pending'])) {
                 $_GET['pending'] = 0;
             }
             foreach ($fields as $field) {
                 if (isset($_GET[$field])) {
                     $filters[$field] = $_GET[$field];
                     $_SESSION['translate_filters']['texts'][$field] = (string) $_GET[$field];
                 } elseif (!empty($_SESSION['translate_filters']['texts'][$field])) {
                     // si no lo tenemos en el get, cogemos de la sesion pero no lo pisamos
                     $filters[$field] = $_SESSION['translate_filters']['texts'][$field];
                 }
             }
             $filter = "?group={$filters['group']}&text={$filters['text']}&pending={$filters['pending']}";
             // si llega post, vamos a guardar los cambios
             if ($action == 'edit' && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
                 if (Text::save(array('id' => $id, 'text' => $_POST['text'], 'lang' => $_POST['lang']), $errors)) {
                     // Evento Feed
                     /*
                     $log = new Feed();
                     $log->populate('texto traducido (traductor)', '/translate/texts',
                         \vsprintf('El traductor %s ha %s el texto %s al %s', array(
                             Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id),
                             Feed::item('relevant', 'Traducido'),
                             Feed::item('blog', $id),
                             Feed::item('relevant', Lang::get($_POST['lang'])->name)
                     )));
                     $log->doAdmin('admin');
                     unset($log);
                     */
                     Message::Info('Texto <strong>' . $id . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                     throw new Redirection("/translate/texts/{$filter}&page=" . $_GET['page']);
                 } else {
                     // Evento Feed
                     $log = new Feed();
                     $log->setTarget($_SESSION['user']->id, 'user');
                     $log->populate('texto traducido (traductor)', '/translate/texts', \vsprintf('Al traductor %s  le ha %s el texto %s al %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Fallado al traducir'), Feed::item('blog', $id), Feed::item('relevant', Lang::get($_POST['lang'])->name))));
                     $log->doAdmin('admin');
                     unset($log);
                     Message::Error('Ha habido algun ERROR al traducir el Texto <strong>' . $id . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                 }
             }
             // sino, mostramos la lista
             return new View('view/translate/index.html.php', array('section' => 'texts', 'action' => $action, 'id' => $id, 'filter' => $filter, 'filters' => $filters, 'errors' => $errors));
             break;
         case 'node':
             // parametros especiales
             $node = $action;
             $action = $auxAction;
             $contentTable = $id;
             // si llega post, vamos a guardar los cambios
             if ($action == 'edit' && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
                 switch ($contentTable) {
                     case 'banner':
                         if (Content::save(array('id' => $contentId, 'table' => $contentTable, 'title' => $_POST['title'], 'description' => $_POST['description'], 'lang' => $_POST['lang']), $errors)) {
                             Message::Info('El Banner <strong>' . $contentId . '</strong> del nodo <strong>' . $node . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                             throw new Redirection("/translate/node/{$node}/{$contentTable}/list");
                         } else {
                             Message::Error('Ha habido algun ERROR al traducir el Banner <strong>' . $contentId . '</strong> del nodo <strong>' . $node . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                         }
                         break;
                     case 'page':
                         $page = Page::get($contentId, $node);
                         if ($page->update($contentId, $_POST['lang'], $node, $_POST['name'], $_POST['description'], $_POST['content'], $errors)) {
                             Message::Info('La página <strong>' . $contentId . '</strong> del nodo <strong>' . $node . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                             throw new Redirection("/translate/node/{$node}/{$contentTable}/list");
                         } else {
                             Message::Error('Ha habido algun ERROR al traducir la página <strong>' . $contentId . '</strong> del nodo <strong>' . $node . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                         }
                         break;
                     case 'post':
                         if (Content::save(array('id' => $contentId, 'table' => $contentTable, 'title' => $_POST['title'], 'text' => $_POST['text'], 'legend' => $_POST['legend'], 'lang' => $_POST['lang']), $errors)) {
                             Message::Info('La entrada <strong>' . $contentId . '</strong> del nodo <strong>' . $node . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                             throw new Redirection("/translate/node/{$node}/{$contentTable}/list");
                         } else {
                             Message::Error('Ha habido algun ERROR al traducir la Entrada <strong>' . $contentId . '</strong> del nodo <strong>' . $node . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                         }
                         break;
                     default:
                         $node = Model\Node::get($node);
                         $node->lang_lang = $_SESSION['translate_lang'];
                         $node->subtitle_lang = $_POST['subtitle'];
                         $node->description_lang = $_POST['description'];
                         if ($node->updateLang($errors)) {
                             Message::Info('La Descripción del nodo <strong>' . $node->id . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                             throw new Redirection("/translate/node/{$node->id}");
                         } else {
                             Message::Error('Ha habido algun ERROR al traducir la Descripción del nodo <strong>' . $node->id . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                         }
                 }
                 return new View('view/translate/index.html.php', array('section' => 'node', 'action' => 'edit_' . $contentTable, 'option' => $contentTable, 'id' => $contentId, 'node' => $node));
             } elseif ($action == 'edit') {
                 return new View('view/translate/index.html.php', array('section' => 'node', 'action' => 'edit_' . $contentTable, 'option' => $contentTable, 'id' => $contentId, 'node' => $node));
             } elseif ($contentTable == 'data') {
                 return new View('view/translate/index.html.php', array('section' => 'node', 'action' => 'edit_' . $contentTable, 'option' => $contentTable, 'id' => $node, 'node' => $node));
             } else {
                 // sino, mostramos la lista
                 return new View('view/translate/index.html.php', array('section' => 'node', 'action' => 'list_' . $contentTable, 'option' => $contentTable, 'node' => $node));
             }
             break;
         case 'pages':
             // si llega post, vamos a guardar los cambios
             if ($action == 'edit' && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
                 if (Page::update($id, $_POST['lang'], $_POST['node'], $_POST['name'], $_POST['description'], $_POST['content'], $errors)) {
                     Message::Info('Contenido de la Pagina <strong>' . $id . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                     throw new Redirection("/translate/pages");
                 } else {
                     // Evento Feed
                     $log = new Feed();
                     $log->setTarget($_SESSION['user']->id, 'user');
                     $log->populate('pagina traducida (traductor)', '/translate/pages', \vsprintf('Al traductor %s le ha %s la página %s del nodo %s al %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Fallado al traducir'), Feed::item('blog', $id), Feed::item('blog', $_POST['node']), Feed::item('relevant', Lang::get($_POST['lang'])->name))));
                     $log->doAdmin('admin');
                     unset($log);
                     Message::Error('Ha habido algun ERROR al traducir el contenido de la pagina <strong>' . $id . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                 }
             }
             // sino, mostramos la lista
             return new View('view/translate/index.html.php', array('section' => 'pages', 'action' => $action, 'id' => $id, 'errors' => $errors));
             break;
         default:
             // comprobamos los filtros
             $filters = array();
             $fields = array('type', 'text', 'pending');
             if (!isset($_GET['pending'])) {
                 $_GET['pending'] = 0;
             }
             foreach ($fields as $field) {
                 if (isset($_GET[$field])) {
                     $filters[$field] = $_GET[$field];
                     $_SESSION['translate_filters']['contents'][$field] = (string) $_GET[$field];
                 } elseif (!empty($_SESSION['translate_filters']['contents'][$field])) {
                     // si no lo tenemos en el get, cogemos de la sesion pero no lo pisamos
                     $filters[$field] = $_SESSION['translate_filters']['contents'][$field];
                 }
             }
             $filter = "?type={$filters['type']}&text={$filters['text']}&pending={$filters['pending']}";
             // si llega post, vamos a guardar los cambios
             if ($action == 'edit' && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
                 if (!in_array($table, \array_keys(Content::_tables()))) {
                     $errors[] = Text::_("Tabla ") . $table . Text::_(" desconocida");
                     break;
                 }
                 if (Content::save($_POST, $errors)) {
                     // Evento Feed
                     /*
                     $log = new Feed();
                     $log->populate('contenido traducido (traductor)', '/translate/'.$table,
                         \vsprintf('El traductor %s ha %s el contenido del registro %s de la tabla %s al %s', array(
                         Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id),
                         Feed::item('relevant', 'Traducido'),
                         Feed::item('blog', $id),
                         Feed::item('blog', $table),
                         Feed::item('relevant', Lang::get($_SESSION['translate_lang'])->name)
                     )));
                     $log->doAdmin('admin');
                     unset($log);
                     */
                     Message::Info('Contenido del registro <strong>' . $id . '</strong> de la tabla <strong>' . $table . '</strong> traducido correctamente al <strong>' . Lang::get($_POST['lang'])->name . '</strong>');
                     if (isset($_SESSION['translate_node'])) {
                         throw new Redirection('/dashboard/translates/' . $table . 's');
                     }
                     throw new Redirection("/translate/{$table}/{$filter}&page=" . $_GET['page']);
                 } else {
                     // Evento Feed
                     $log = new Feed();
                     $log->setTarget($_SESSION['user']->id, 'user');
                     $log->populate('contenido traducido (traductor)', '/translate/' . $table, \vsprintf('El traductor %s le ha %s el contenido del registro %s de la tabla %s al %s', array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Fallado al traducir'), Feed::item('blog', $id), Feed::item('blog', $table), Feed::item('relevant', Lang::get($_SESSION['translate_lang'])->name))));
                     $log->doAdmin('admin');
                     unset($log);
                     Message::Error('Ha habido algun ERROR al traducir el contenido del registro <strong>' . $id . '</strong> de la tabla <strong>' . $table . '</strong> al <strong>' . Lang::get($_POST['lang'])->name . '</strong><br />' . implode('<br />', $errors));
                 }
             }
             // sino, mostramos la lista
             return new View('view/translate/index.html.php', array('section' => 'contents', 'action' => $action, 'table' => $table, 'id' => $id, 'filter' => $filter, 'filters' => $filters, 'errors' => $errors));
     }
     // si no pasa nada de esto, a la portada
     return new View('view/translate/index.html.php', array('menu' => self::menu()));
 }
コード例 #5
0
ファイル: selector.html.php プロジェクト: kenjs/Goteo
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with Goteo.  If not, see <http://www.gnu.org/licenses/agpl.txt>.
 *
 */

use Goteo\Library\i18n\Lang,
    Goteo\Library\Text;

$langs = Lang::getAll();
unset($langs['es']); // no se puede traducir a español

$actual = Lang::get($_SESSION['translate_lang']);

$section = isset($this['table']) ? $this['table'] : $this['section'];

?>
<div id="lang-selector">
    <form id="selector-form" name="selector_form" action="<?php echo '/translate/select/'.$section.'/'.$this['action'].'/'.$this['id'].'/'.$this['filter'].'&page='.$_GET['page']; ?>" method="post">
    <?php if (!empty($actual->id)) : ?>
        <?php echo Text::get('dashboard-translate_lang'); ?><strong><?php echo $actual->name ?></strong> <label for="selector"><?php echo Text::get('dashboard-translate_lang_change'); ?></label>
    <?php else : ?>
        <?php echo Text::get('dashboard-translate_no_select_lang'); ?><label for="selector">Traducir a:</label>
    <?php endif; ?>
    <select id="selector" name="lang" onchange="document.getElementById('selector-form').submit();">
<!--        <option value="">Seleccionar idioma de traducci&oacute;n</option> -->
    <?php foreach ($langs as $lang) : ?>
        <option value="<?php echo $lang->id; ?>"<?php if ($lang->id == $actual->id) echo ' selected="selected"'; ?>><?php echo $lang->name; ?></option>
コード例 #6
0
ファイル: dashboard.php プロジェクト: nguyendev/LoveSharing
 public function translates($option = 'overview', $action = 'list', $id = null)
 {
     $user = $_SESSION['user'];
     $errors = array();
     $langs = \Goteo\Library\i18n\Lang::getAll();
     if ($action == 'lang' && !empty($_POST['lang'])) {
         $_SESSION['translate_lang'] = $_POST['lang'];
     } elseif (empty($_SESSION['translate_lang'])) {
         $_SESSION['translate_lang'] = 'en';
     }
     $projects = Model\User\Translate::getMyProjects($user->id);
     // al seleccionar controlamos: translate_type
     if ($action == 'select' && !empty($_POST['type'])) {
         unset($_SESSION['translate_project']);
         // quitamos el proyecto de traducción
         $type = $_POST['type'];
         if (!empty($_POST[$type])) {
             $_SESSION['translate_type'] = $type;
             $_SESSION['translate_' . $type] = $_POST[$type];
         } else {
             $_SESSION['translate_type'] = 'profile';
         }
     }
     // view data basico para esta seccion
     $viewData = array('menu' => self::menu(), 'section' => __FUNCTION__, 'option' => $option, 'action' => $action, 'langs' => $langs, 'projects' => $projects, 'errors' => $errors, 'success' => $success);
     // aqui, segun lo que este traduciendo, necesito tener un proyecto de trabajo, una convocatoria o mi perfil personal
     switch ($_SESSION['translate_type']) {
         case 'project':
             try {
                 // si lo que tenemos en sesion no es una instancia de proyecto (es una id de proyecto)
                 if ($_SESSION['translate_project'] instanceof Model\Project) {
                     $project = Model\Project::get($_SESSION['translate_project']->id, $_SESSION['translate_lang']);
                 } else {
                     $project = Model\Project::get($_SESSION['translate_project'], $_SESSION['translate_lang']);
                 }
             } catch (\Goteo\Core\Error $e) {
                 $project = null;
             }
             if (!$project instanceof Model\Project) {
                 Message::Error('Ha fallado al cargar los datos del proyecto');
                 $_SESSION['translate_type'] = 'profile';
                 throw new Redirection('/dashboard/translates');
             }
             $_SESSION['translate_project'] = $project;
             $project->lang_name = $langs[$project->lang]->name;
             unset($viewData['langs'][$project->lang]);
             // quitamos el idioma original
             //// Control de traduccion de proyecto
             if ($option == 'updates') {
                 // sus novedades
                 $blog = Model\Blog::get($project->id);
                 if ($action != 'edit') {
                     $action = 'list';
                 }
             }
             // tratar lo que llega por post para guardar los datos
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 switch ($option) {
                     case 'profile':
                         if ($action == 'save') {
                             $user = Model\User::get($_POST['id'], $_SESSION['translate_lang']);
                             $user->about_lang = $_POST['about'];
                             $user->keywords_lang = $_POST['keywords'];
                             $user->contribution_lang = $_POST['contribution'];
                             $user->lang = $_SESSION['translate_lang'];
                             $user->saveLang($errors);
                         }
                         break;
                     case 'overview':
                         if ($action == 'save') {
                             $project->description_lang = $_POST['description'];
                             $project->motivation_lang = $_POST['motivation'];
                             $project->video_lang = $_POST['video'];
                             $project->about_lang = $_POST['about'];
                             $project->goal_lang = $_POST['goal'];
                             $project->related_lang = $_POST['related'];
                             $project->reward_lang = $_POST['reward'];
                             $project->keywords_lang = $_POST['keywords'];
                             $project->media_lang = $_POST['media'];
                             $project->subtitle_lang = $_POST['subtitle'];
                             $project->lang_lang = $_SESSION['translate_lang'];
                             $project->saveLang($errors);
                         }
                         break;
                     case 'costs':
                         if ($action == 'save') {
                             foreach ($project->costs as $key => $cost) {
                                 if (isset($_POST['cost-' . $cost->id . '-cost'])) {
                                     $cost->cost_lang = $_POST['cost-' . $cost->id . '-cost'];
                                     $cost->description_lang = $_POST['cost-' . $cost->id . '-description'];
                                     $cost->lang = $_SESSION['translate_lang'];
                                     $cost->saveLang($errors);
                                 }
                             }
                         }
                         break;
                     case 'rewards':
                         if ($action == 'save') {
                             foreach ($project->social_rewards as $k => $reward) {
                                 if (isset($_POST['social_reward-' . $reward->id . '-reward'])) {
                                     $reward->reward_lang = $_POST['social_reward-' . $reward->id . '-reward'];
                                     $reward->description_lang = $_POST['social_reward-' . $reward->id . '-description'];
                                     $reward->other_lang = $_POST['social_reward-' . $reward->id . '-other'];
                                     $reward->lang = $_SESSION['translate_lang'];
                                     $reward->saveLang($errors);
                                 }
                             }
                             foreach ($project->individual_rewards as $k => $reward) {
                                 if (isset($_POST['individual_reward-' . $reward->id . '-reward'])) {
                                     $reward->reward_lang = $_POST['individual_reward-' . $reward->id . '-reward'];
                                     $reward->description_lang = $_POST['individual_reward-' . $reward->id . '-description'];
                                     $reward->other_lang = $_POST['individual_reward-' . $reward->id . '-other'];
                                     $reward->lang = $_SESSION['translate_lang'];
                                     $reward->saveLang($errors);
                                 }
                             }
                         }
                         break;
                     case 'supports':
                         if ($action == 'save') {
                             // tratar colaboraciones existentes
                             foreach ($project->supports as $key => $support) {
                                 if (isset($_POST['support-' . $support->id . '-support'])) {
                                     // guardamos los datos traducidos
                                     $support->support_lang = $_POST['support-' . $support->id . '-support'];
                                     $support->description_lang = $_POST['support-' . $support->id . '-description'];
                                     $support->lang = $_SESSION['translate_lang'];
                                     $support->saveLang($errors);
                                     // actualizar el Mensaje correspondiente, solamente actualizar
                                     $msg = Model\Message::get($support->thread);
                                     $msg->message_lang = "{$support->support_lang}: {$support->description_lang}";
                                     $msg->lang = $_SESSION['translate_lang'];
                                     $msg->saveLang($errors);
                                 }
                             }
                         }
                         break;
                     case 'updates':
                         if (empty($_POST['blog']) || empty($_POST['id'])) {
                             break;
                         }
                         $post = Model\Blog\Post::get($_POST['id']);
                         $post->title_lang = $_POST['title'];
                         $post->text_lang = $_POST['text'];
                         $post->media_lang = $_POST['media'];
                         $post->legend_lang = $_POST['legend'];
                         $post->lang = $_SESSION['translate_lang'];
                         $post->saveLang($errors);
                         $action = 'edit';
                         break;
                 }
             }
             switch ($option) {
                 case 'profile':
                     $viewData['user'] = Model\User::get($project->owner, $_SESSION['translate_lang']);
                     break;
                 case 'overview':
                     break;
                 case 'costs':
                     if ($_POST) {
                         foreach ($_POST as $k => $v) {
                             if (!empty($v) && preg_match('/cost-(\\d+)-edit/', $k, $r)) {
                                 $viewData[$k] = true;
                             }
                         }
                     }
                     break;
                 case 'rewards':
                     if ($_POST) {
                         foreach ($_POST as $k => $v) {
                             if (!empty($v) && preg_match('/((social)|(individual))_reward-(\\d+)-edit/', $k)) {
                                 $viewData[$k] = true;
                                 break;
                             }
                         }
                     }
                     break;
                 case 'supports':
                     if ($_POST) {
                         foreach ($_POST as $k => $v) {
                             if (!empty($v) && preg_match('/support-(\\d+)-edit/', $k, $r)) {
                                 $viewData[$k] = true;
                                 break;
                             }
                         }
                     }
                     break;
                     // publicar actualizaciones
                 // publicar actualizaciones
                 case 'updates':
                     $viewData['blog'] = $blog;
                     if ($action == 'edit') {
                         $post = Model\Blog\Post::get($id, $_SESSION['translate_lang']);
                         $viewData['post'] = $post;
                     } else {
                         $posts = array();
                         foreach ($blog->posts as $post) {
                             $posts[] = Model\Blog\Post::get($post->id, $_SESSION['translate_lang']);
                         }
                         $viewData['posts'] = $posts;
                     }
                     break;
             }
             $viewData['project'] = $project;
             //// FIN Control de traduccion de proyecto
             break;
         default:
             // profile
             $viewData['option'] = 'profile';
             unset($langs['es']);
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 if ($action == 'save') {
                     $user = Model\User::get($_POST['id'], $_SESSION['translate_lang']);
                     $user->about_lang = $_POST['about'];
                     $user->keywords_lang = $_POST['keywords'];
                     $user->contribution_lang = $_POST['contribution'];
                     $user->lang = $_SESSION['translate_lang'];
                     $user->saveLang($errors);
                 }
             }
             $viewData['user'] = Model\User::get($user->id, $_SESSION['translate_lang']);
     }
     if (!empty($errors)) {
         Message::Error('HA HABIDO ERRORES: <br />' . implode('<br />', $errors));
     }
     return new View('view/dashboard/index.html.php', $viewData);
 }
コード例 #7
0
ファイル: index.php プロジェクト: isbkch/Goteo
set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
    // @todo Insert error into buffer
    //        echo "Error:  {$errno}, {$errstr}, {$errfile}, {$errline}, {$errcontext}<br />";
    //throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
//@NODESYS
define('NODE_ID', GOTEO_NODE);
/**
 * Sesión.
 */
session_name('goteo');
session_start();
// set Lang
Lang::set();
// change current locale
$locale_name = Lang::locale();
$locale = new Locale($config['locale']);
// avoid Fatal Error if $local_name is empty.
if ($locale_name) {
    $locale->set($locale_name);
} else {
    $locale->set('en_GB');
}
Registry::set('locale', $locale);
// Get URI without query string
$uri = strtok($_SERVER['REQUEST_URI'], '?');
// Get requested segments
$segments = preg_split('!\\s*/+\\s*!', $uri, -1, \PREG_SPLIT_NO_EMPTY);
// Normalize URI
$uri = '/' . implode('/', $segments);
try {
コード例 #8
0
ファイル: header.html.php プロジェクト: anvnguyen/Goteo
           <div id="about">
                <ul>
                    <li><a href="/about"><?php 
echo Text::get('regular-header-about');
?>
</a></li>
                    <li><a href="/blog"><?php 
echo Text::get('regular-header-blog');
?>
</a></li>
                    <li><a href="/faq"><?php 
echo Text::get('regular-header-faq');
?>
</a></li>  
                    <li id="lang"><a href="#" ><?php 
echo Lang::get(LANG)->short;
?>
</a></li>
                    <script type="text/javascript">
                    jQuery(document).ready(function ($) {
						 $("#lang").hover(function(){
						   //desplegar idiomas
						   try{clearTimeout(TID_LANG)}catch(e){};
						   var pos = $(this).offset().left;
						   $('ul.lang').css({left:pos+'px'});
						   $("ul.lang").fadeIn();
					       $("#lang").css("background","#808285 url('/view/css/bolita.png') 4px 7px no-repeat");

					   },function() {
						   TID_LANG = setTimeout('$("ul.lang").hide()',100);
						});