本文整理汇总了PHP中Goteo\Library\Message::Info方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::Info方法的具体用法?PHP Message::Info怎么用?PHP Message::Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goteo\Library\Message
的用法示例。
在下文中一共展示了Message::Info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public static function process($action = 'list', $id = null, $filters = array())
{
$groups = Model\Icon::groups();
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$icon = new Model\Icon(array('id' => $_POST['id'], 'name' => $_POST['name'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'group' => empty($_POST['group']) ? null : $_POST['group']));
if ($icon->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info('Nuevo tipo añadido correctamente');
break;
case 'edit':
Message::Info('Tipo editado correctamente');
// Evento Feed
$log = new Feed();
$log->populate('modificacion de tipo de retorno/recompensa (admin)', '/admin/icons', \vsprintf("El admin %s ha %s el tipo de retorno/recompensa %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('project', $icon->name))));
$log->doAdmin('admin');
unset($log);
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'icons', 'file' => 'edit', 'action' => $_POST['action'], 'icon' => $icon, 'groups' => $groups));
}
}
switch ($action) {
case 'edit':
$icon = Model\Icon::get($id);
return new View('view/admin/index.html.php', array('folder' => 'icons', 'file' => 'edit', 'action' => 'edit', 'icon' => $icon, 'groups' => $groups));
break;
}
$icons = Model\Icon::getAll($filters['group']);
return new View('view/admin/index.html.php', array('folder' => 'icons', 'file' => 'list', 'icons' => $icons, 'groups' => $groups, 'filters' => $filters));
}
示例2: process
public static function process($action = 'list', $id = null, $filters = array())
{
$errors = array();
// valores de filtro
$groups = Template::groups();
switch ($action) {
case 'edit':
// si estamos editando una plantilla
$template = Template::get($id);
// si llega post, vamos a guardar los cambios
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$template->title = $_POST['title'];
$template->text = $_POST['text'];
if ($template->save($errors)) {
Message::Info(Text::_('La plantilla se ha actualizado correctamente'));
throw new Redirection("/admin/templates");
} else {
Message::Error(Text::_('No se ha grabado correctamente. ') . implode('<br />', $errors));
}
}
// sino, mostramos para editar
return new View('view/admin/index.html.php', array('folder' => 'templates', 'file' => 'edit', 'template' => $template));
break;
case 'list':
// si estamos en la lista de páginas
$templates = Template::getAll($filters);
return new View('view/admin/index.html.php', array('folder' => 'templates', 'file' => 'list', 'templates' => $templates, 'groups' => $groups, 'filters' => $filters));
break;
}
}
示例3: process
public static function process($action = 'list', $id = null)
{
$model = 'Goteo\\Model\\Blog\\Post\\Tag';
$url = '/admin/tags';
$errors = array();
switch ($action) {
case 'add':
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => (object) array(), 'form' => array('action' => "{$url}/edit/", 'submit' => array('name' => 'update', 'label' => Text::_('Añadir')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'name' => array('label' => Text::_('Tag'), 'name' => 'name', 'type' => 'text')))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) {
$errors = array();
// instancia
$item = new $model(array('id' => $_POST['id'], 'name' => $_POST['name']));
if ($item->save($errors)) {
Message::Info(Text::get('admin-tags-info-udate'));
throw new Redirection($url);
} else {
Message::Error(Text::get('admin-tags-error-save-fail') . implode('<br />', $errors));
}
} else {
$item = $model::get($id);
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => $item, 'form' => array('action' => "{$url}/edit/{$id}", 'submit' => array('name' => 'update', 'label' => Text::get('regular-save')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'name' => array('label' => Text::_('Tag'), 'name' => 'name', 'type' => 'text')))));
break;
case 'remove':
if ($model::delete($id)) {
throw new Redirection($url);
}
break;
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'list', 'model' => 'tag', 'addbutton' => Text::_('Nuevo tag'), 'data' => $model::getList(1), 'columns' => array('edit' => '', 'name' => Text::_('Tag'), 'used' => Text::_('Entradas'), 'translate' => '', 'remove' => ''), 'url' => "{$url}"));
}
示例4: process
public static function process($action = 'list', $id = null)
{
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $action == 'edit') {
// instancia
$data = array('id' => $_POST['id'], 'name' => $_POST['name'], 'amount' => $_POST['amount']);
if (WorthLib::save($data, $errors)) {
$action = 'list';
Message::Info(Text::_('Nivel de meritocracia modificado'));
// Evento Feed
$log = new Feed();
$log->populate(Text::_('Nivel de meritocracia modificado'), '/admin/worth', \vsprintf("El admin %s ha %s el nivel de meritocrácia %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('project', $icon->name))));
$log->doAdmin('admin');
unset($log);
} else {
Message::Error(Text::_('No se ha guardado correctamente. ') . implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'edit', 'action' => 'edit', 'worth' => (object) $data));
}
}
switch ($action) {
case 'edit':
$worth = WorthLib::getAdmin($id);
return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'edit', 'action' => 'edit', 'worth' => $worth));
break;
}
$worthcracy = WorthLib::getAll();
return new View('view/admin/index.html.php', array('folder' => 'worth', 'file' => 'list', 'worthcracy' => $worthcracy));
}
示例5: process
public static function process($action = 'list', $id = null, $filters = array(), $type = 'main')
{
//@NODESYS
$node = \GOTEO_NODE;
$type = 'main';
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$item = new Model\Home(array('item' => $_POST['item'], 'type' => $_POST['type'], 'node' => $node, 'order' => $_POST['order'], 'move' => 'down'));
if ($item->save($errors)) {
} else {
Message::Error(implode('<br />', $errors));
}
}
switch ($action) {
case 'remove':
Model\Home::delete($id, $node, $type);
throw new Redirection('/admin/home');
break;
case 'up':
Model\Home::up($id, $node, $type);
throw new Redirection('/admin/home');
break;
case 'down':
Model\Home::down($id, $node, $type);
throw new Redirection('/admin/home');
break;
case 'add':
$next = Model\Home::next($node, 'main');
$availables = Model\Home::available($node);
if (empty($availables)) {
Message::Info(Text::_('Todos los elementos disponibles ya estan en portada'));
throw new Redirection('/admin/home');
break;
}
return new View('view/admin/index.html.php', array('folder' => 'home', 'file' => 'add', 'action' => 'add', 'home' => (object) array('node' => $node, 'order' => $next, 'type' => 'main'), 'availables' => $availables));
break;
case 'addside':
$next = Model\Home::next($node, 'side');
$availables = Model\Home::availableSide($node);
if (empty($availables)) {
Message::Info(Text::_('Todos los elementos laterales disponibles ya estan en portada'));
throw new Redirection('/admin/home');
break;
}
return new View('view/admin/index.html.php', array('folder' => 'home', 'file' => 'add', 'action' => 'add', 'home' => (object) array('node' => $node, 'order' => $next, 'type' => 'side'), 'availables' => $availables));
break;
}
$viewData = array('folder' => 'home', 'file' => 'list');
$viewData['items'] = Model\Home::getAll($node);
/* Para añadir nuevos desde la lista */
$viewData['availables'] = Model\Home::available($node);
$viewData['new'] = (object) array('node' => $node, 'order' => Model\Home::next($node, 'main'), 'type' => 'main');
// laterales
$viewData['side_items'] = Model\Home::getAllSide($node);
$viewData['side_availables'] = Model\Home::availableSide($node);
$viewData['side_new'] = (object) array('node' => $node, 'order' => Model\Home::next($node, 'side'), 'type' => 'side');
return new View('view/admin/index.html.php', $viewData);
}
示例6: process
public static function process($action = 'list', $id = null)
{
$node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
$model = 'Goteo\\Model\\Sponsor';
$url = '/admin/sponsors';
$errors = array();
switch ($action) {
case 'add':
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => (object) array('order' => $model::next($node), 'node' => $node), 'form' => array('action' => "{$url}/edit/", 'submit' => array('name' => 'update', 'label' => Text::_('Añadir')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'node' => array('label' => '', 'name' => 'node', 'type' => 'hidden'), 'name' => array('label' => Text::_('Patrocinador'), 'name' => 'name', 'type' => 'text'), 'url' => array('label' => Text::_('Enlace'), 'name' => 'url', 'type' => 'text', 'properties' => 'size=100'), 'image' => array('label' => Text::_('Logo'), 'name' => 'image', 'type' => 'image'), 'order' => array('label' => Text::_('Posición'), 'name' => 'order', 'type' => 'text')))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$item = new $model(array('id' => $_POST['id'], 'name' => $_POST['name'], 'node' => $_POST['node'], 'image' => $_POST['image'], 'url' => $_POST['url'], 'order' => $_POST['order']));
// tratar si quitan la imagen
$current = $_POST['image'];
// la actual
if (isset($_POST['image-' . $current . '-remove'])) {
$image = Model\Image::get($current);
$image->remove('sponsor');
$item->image = '';
$removed = true;
}
// tratar la imagen y ponerla en la propiedad image
if (!empty($_FILES['image']['name'])) {
$item->image = $_FILES['image'];
}
if ($item->save($errors)) {
Message::Info(Text::_('Datos grabados correctamente'));
throw new Redirection($url);
} else {
Message::Error(Text::_('No se ha grabado correctamente. ') . implode(', ', $errors));
}
} else {
$item = $model::get($id);
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'edit', 'data' => $item, 'form' => array('action' => "{$url}/edit/{$id}", 'submit' => array('name' => 'update', 'label' => Text::get('regular-save')), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'node' => array('label' => '', 'name' => 'node', 'type' => 'hidden'), 'name' => array('label' => Text::_('Patrocinador'), 'name' => 'name', 'type' => 'text'), 'url' => array('label' => Text::_('Enlace'), 'name' => 'url', 'type' => 'text', 'properties' => 'size=100'), 'image' => array('label' => Text::_('Logo'), 'name' => 'image', 'type' => 'image'), 'order' => array('label' => Text::_('Posición'), 'name' => 'order', 'type' => 'text')))));
break;
case 'up':
$model::up($id, $node);
throw new Redirection($url);
break;
case 'down':
$model::down($id, $node);
throw new Redirection($url);
break;
case 'remove':
if ($model::delete($id)) {
Message::Info(Text::_('Se ha eliminado el registro'));
throw new Redirection($url);
} else {
Message::Info(Text::_('No se ha podido eliminar el registro'));
}
break;
}
return new View('view/admin/index.html.php', array('folder' => 'base', 'file' => 'list', 'addbutton' => Text::_('Nuevo patrocinador'), 'data' => $model::getAll($node), 'columns' => array('edit' => '', 'name' => Text::_('Patrocinador'), 'url' => Text::_('Enlace'), 'image' => Text::_('Imagen'), 'order' => Text::_('Posición'), 'up' => '', 'down' => '', 'remove' => ''), 'url' => "{$url}"));
}
示例7: process
public static function process($action = 'list', $id = null)
{
$node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE;
$errors = array();
switch ($action) {
case 'add':
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$page = new Page();
$page->id = $_POST['id'];
$page->name = $_POST['name'];
if ($page->add($errors)) {
Message::Info('La página <strong>' . $page->name . '</strong> se ha creado correctamente, se puede editar ahora.');
throw new Redirection("/admin/pages/edit/{$page->id}");
} else {
Message::Error('No se ha creado bien ' . implode('<br />', $errors));
throw new Redirection("/admin/pages/add");
}
}
return new View('view/admin/index.html.php', array('folder' => 'pages', 'file' => 'add'));
break;
case 'edit':
if ($node != \GOTEO_NODE && !in_array($id, static::_node_pages())) {
Message::Info('No puedes gestionar la página <strong>' . $id . '</strong>');
throw new Redirection("/admin/pages");
}
// si estamos editando una página
$page = Page::get($id, $node, \GOTEO_DEFAULT_LANG);
// si llega post, vamos a guardar los cambios
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$page->name = $_POST['name'];
$page->description = $_POST['description'];
$page->content = $_POST['content'];
if ($page->save($errors)) {
// Evento Feed
$log = new Feed();
if ($node != \GOTEO_NODE && in_array($id, static::_node_pages())) {
$log->setTarget($node, 'node');
}
$log->populate(Text::_('modificacion de página institucional (admin)'), '/admin/pages', \vsprintf("El admin %s ha %s la página institucional %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('relevant', $page->name, $page->url))));
$log->doAdmin('admin');
unset($log);
Message::Info('La página ' . $page->name . ' se ha actualizado correctamente');
throw new Redirection("/admin/pages");
} else {
Message::Error(implode('<br />', $errors));
}
}
// sino, mostramos para editar
return new View('view/admin/index.html.php', array('folder' => 'pages', 'file' => 'edit', 'page' => $page));
break;
case 'list':
// si estamos en la lista de páginas
$pages = Page::getList($node);
return new View('view/admin/index.html.php', array('folder' => 'pages', 'file' => 'list', 'pages' => $pages, 'node' => $node));
break;
}
}
示例8: process
public static function process($action = 'list', $id = null, $filters = array())
{
// agrupaciones de mas a menos abertas
$groups = Model\License::groups();
// tipos de retorno para asociar
$icons = Model\Icon::getAll('social');
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// objeto
$license = new Model\License(array('id' => $_POST['id'], 'name' => $_POST['name'], 'description' => $_POST['description'], 'url' => $_POST['url'], 'group' => $_POST['group'], 'order' => $_POST['order'], 'icons' => $_POST['icons']));
if ($license->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info(Text::get('admin-licenses-info-add'));
break;
case 'edit':
Message::Info(Text::get('admin-licenses-info-edit'));
// Evento Feed
$log = new Feed();
$log->populate('modificacion de licencia (admin)', '/admin/licenses', \vsprintf("El admin %s ha %s la licencia %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Modificado'), Feed::item('project', $license->name))));
$log->doAdmin('admin');
unset($log);
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'edit', 'action' => $_POST['action'], 'license' => $license, 'icons' => $icons, 'groups' => $groups));
}
}
switch ($action) {
case 'up':
Model\License::up($id);
break;
case 'down':
Model\License::down($id);
break;
case 'add':
$next = Model\License::next();
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'edit', 'action' => 'add', 'license' => (object) array('order' => $next, 'icons' => array()), 'icons' => $icons, 'groups' => $groups));
break;
case 'edit':
$license = Model\License::get($id);
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'edit', 'action' => 'edit', 'license' => $license, 'icons' => $icons, 'groups' => $groups));
break;
case 'remove':
// Model\License::delete($id);
break;
}
$licenses = Model\License::getAll($filters['icon'], $filters['group']);
return new View('view/admin/index.html.php', array('folder' => 'licenses', 'file' => 'list', 'licenses' => $licenses, 'filters' => $filters, 'groups' => $groups, 'icons' => $icons));
}
示例9: process
public static function process($action = 'list', $id = null, $filters = array())
{
$sections = Model\Faq::sections();
if (!isset($sections[$filters['section']])) {
unset($filters['section']);
}
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$faq = new Model\Faq(array('id' => $_POST['id'], 'node' => \GOTEO_NODE, 'section' => $_POST['section'], 'title' => $_POST['title'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'move' => $_POST['move']));
if ($faq->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info('Pregunta añadida correctamente');
break;
case 'edit':
Message::Info('Pregunta editado correctamente');
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'edit', 'action' => $_POST['action'], 'faq' => $faq, 'filter' => $filter, 'sections' => $sections));
}
}
switch ($action) {
case 'up':
Model\Faq::up($id);
throw new Redirection('/admin/faq');
break;
case 'down':
Model\Faq::down($id);
throw new Redirection('/admin/faq');
break;
case 'add':
$next = Model\Faq::next($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'edit', 'action' => 'add', 'faq' => (object) array('section' => $filters['section'], 'order' => $next, 'cuantos' => $next), 'sections' => $sections));
break;
case 'edit':
$faq = Model\Faq::get($id);
$cuantos = Model\Faq::next($faq->section);
$faq->cuantos = $cuantos - 1;
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'edit', 'action' => 'edit', 'faq' => $faq, 'sections' => $sections));
break;
case 'remove':
Model\Faq::delete($id);
break;
}
$faqs = Model\Faq::getAll($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'faq', 'file' => 'list', 'faqs' => $faqs, 'sections' => $sections, 'filters' => $filters));
}
示例10: done
public function done($id)
{
$errors = array();
if (!empty($id) && isset($_SESSION['user']->id)) {
$task = Model\Task::get($id);
if ($task->setDone($errors)) {
Message::Info(Text::get('admin-info-done-completion'));
} else {
Message::Error(implode('<br />', $errors));
}
} else {
Message::Error(Text::get('admin-info-done-missing_data'));
}
throw new Redirection('/admin');
}
示例11: done
public function done($id)
{
$errors = array();
if (!empty($id) && isset($_SESSION['user']->id)) {
$task = Model\Task::get($id);
if ($task->setDone($errors)) {
Message::Info('La tarea se ha marcado como realizada');
} else {
Message::Error(implode('<br />', $errors));
}
} else {
Message::Error('Faltan datos');
}
throw new Redirection('/admin');
}
示例12: process
public static function process($action = 'list', $id = null, $filters = array())
{
$sections = Model\Criteria::sections();
if (!isset($sections[$filters['section']])) {
unset($filters['section']);
}
$errors = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// instancia
$criteria = new Model\Criteria(array('id' => $_POST['id'], 'section' => $_POST['section'], 'title' => $_POST['title'], 'description' => $_POST['description'], 'order' => $_POST['order'], 'move' => $_POST['move']));
if ($criteria->save($errors)) {
switch ($_POST['action']) {
case 'add':
Message::Info(Text::get('criteria-info-add-correctly'));
break;
case 'edit':
Message::Info(Text::get('criteria-info-edit-correctly'));
break;
}
} else {
Message::Error(implode('<br />', $errors));
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => $_POST['action'], 'criteria' => $criteria, 'sections' => $sections));
}
}
switch ($action) {
case 'up':
Model\Criteria::up($id);
break;
case 'down':
Model\Criteria::down($id);
break;
case 'add':
$next = Model\Criteria::next($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => 'add', 'criteria' => (object) array('section' => $filters['section'], 'order' => $next, 'cuantos' => $next), 'sections' => $sections));
break;
case 'edit':
$criteria = Model\Criteria::get($id);
$cuantos = Model\Criteria::next($criteria->section);
$criteria->cuantos = $cuantos - 1;
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'edit', 'action' => 'edit', 'criteria' => $criteria, 'sections' => $sections));
break;
case 'remove':
Model\Criteria::delete($id);
break;
}
$criterias = Model\Criteria::getAll($filters['section']);
return new View('view/admin/index.html.php', array('folder' => 'criteria', 'file' => 'list', 'criterias' => $criterias, 'sections' => $sections, 'filters' => $filters));
}
示例13: process
public static function process($action = 'list', $id = null, $filters = array())
{
// valores de filtro
$groups = Text::groups();
// metemos el todos
\array_unshift($groups, Text::_('Todas las agrupaciones'));
//@fixme temporal hasta pasar las agrupaciones a tabal o arreglar en el list.html.php
// I dont know if this must serve in default lang or in current navigation lang
$data = Text::getAll($filters, 'original');
foreach ($data as $key => $item) {
$data[$key]->group = $groups[$item->group];
}
switch ($action) {
case 'list':
return new View('view/admin/index.html.php', array('folder' => 'texts', 'file' => 'list', 'data' => $data, 'columns' => array('edit' => '', 'text' => Text::_('Texto'), 'group' => Text::_('Agrupación')), 'url' => '/admin/texts', 'filters' => array('filtered' => $filters['filtered'], 'group' => array('label' => Text::_('Filtrar por agrupación:'), 'type' => 'select', 'options' => $groups, 'value' => $filters['group']), 'text' => array('label' => Text::_('Buscar texto:'), 'type' => 'input', 'options' => null, 'value' => $filters['text']))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) {
$errors = array();
$id = $_POST['id'];
$text = $_POST['text'];
$data = array('id' => $id, 'text' => $_POST['text']);
if (Text::update($data, $errors)) {
Message::Info(Text::_('El texto ha sido actualizado'));
throw new Redirection("/admin/texts");
} else {
Message::Error(implode('<br />', $errors));
}
} else {
//@TODO: this must get the text in the GOTEO_DEFAULT_LANG or it will be overwrited
$text = Text::getPurpose($id);
// Julian Canaves 23 nov 2013
// right now getPurpose gets the spanish text.
// In future this spanish text will be moved to the `Text` table
// and the `Purpose` table will distribute to database text or to gettext
// and there will be no hardcoded strings
// and will be all happy, fun and joy
}
return new View('view/admin/index.html.php', array('folder' => 'texts', 'file' => 'edit', 'data' => (object) array('id' => $id, 'text' => $text), 'form' => array('action' => '/admin/texts/edit/' . $id, 'submit' => array('name' => 'update', 'label' => Text::_('Aplicar')), 'fields' => array('idtext' => array('label' => '', 'name' => 'id', 'type' => 'hidden', 'properties' => ''), 'newtext' => array('label' => Text::_('Texto'), 'name' => 'text', 'type' => 'textarea', 'properties' => 'cols="100" rows="6"')))));
break;
default:
throw new Redirection("/admin");
}
}
示例14: index
public function index($post = null)
{
if (!empty($post)) {
$show = 'post';
// -- Mensaje azul molesto para usuarios no registrados
if (empty($_SESSION['user'])) {
$_SESSION['jumpto'] = '/blog/' . $post;
Message::Info(Text::html('user-login-required'));
}
} else {
$show = 'list';
}
// sacamos su blog
$blog = Model\Blog::get(\GOTEO_NODE, 'node');
$filters = array();
if (isset($_GET['tag'])) {
$tag = Model\Blog\Post\Tag::get($_GET['tag']);
if (!empty($tag->id)) {
$filters['tag'] = $tag->id;
}
} else {
$tag = null;
}
if (isset($_GET['author'])) {
$author = Model\User::getMini($_GET['author']);
if (!empty($author->id)) {
$filters['author'] = $author->id;
}
} else {
$author = null;
}
if (!empty($filters)) {
$blog->posts = Model\Blog\Post::getList($filters);
}
if (isset($post) && !isset($blog->posts[$post]) && $_GET['preview'] != $_SESSION['user']->id) {
throw new \Goteo\Core\Redirection('/blog');
}
// segun eso montamos la vista
return new View('view/blog/index.html.php', array('blog' => $blog, 'show' => $show, 'filters' => $filters, 'post' => $post, 'owner' => \GOTEO_NODE));
}
示例15: process
public static function process($action = 'list', $id = null, $filters = array())
{
switch ($action) {
case 'init':
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// plantilla
$template = $_POST['template'];
// destinatarios
if ($_POST['test']) {
$users = Boletin::getTesters();
} elseif ($template == 33) {
// los destinatarios de newsletter
$users = Boletin::getReceivers();
} elseif ($template == 35) {
// los destinatarios para testear a subscriptores
$users = Boletin::getReceivers();
}
// sin idiomas
$nolang = $_POST['nolang'];
if ($nolang) {
$receivers[LANG] = $users;
} else {
// separamos destinatarios en idiomas
$receivers = array();
foreach ($users as $usr) {
if (empty($usr->lang) || $usr->lang == LANG) {
$receivers[LANG][] = $usr;
} else {
$receivers[$usr->lang][] = $usr;
}
}
}
// idiomas que vamos a enviar
$langs = array_keys($receivers);
// para cada idioma
foreach ($langs as $lang) {
// destinatarios
$recipients = $receivers[$lang];
// datos de la plantilla
$tpl = Template::get($template, $lang);
// contenido de newsletter
$content = $template == 33 ? Boletin::getContent($tpl->text, $lang) : ($content = $tpl->text);
// asunto
$subject = $tpl->title;
// creamos instancia
$sql = "INSERT INTO mail (id, email, html, template) VALUES ('', :email, :html, :template)";
$values = array(':email' => 'any', ':html' => $content, ':template' => $template);
$query = \Goteo\Core\Model::query($sql, $values);
$mailId = \Goteo\Core\Model::insertId();
// inicializamos el envío
if (Sender::initiateSending($mailId, $subject, $recipients, true)) {
// ok...
} else {
Message::Error('No se ha podido iniciar el mailing con asunto "' . $subject . '"');
}
}
}
throw new Redirection('/admin/newsletter');
break;
case 'activate':
if (Sender::activateSending($id)) {
Message::Info('Se ha activado un nuevo envío automático');
} else {
Message::Error('No se pudo activar el envío. Iniciar de nuevo');
}
throw new Redirection('/admin/newsletter');
break;
case 'detail':
$mailing = Sender::getSending($id);
$list = Sender::getDetail($id, $filters['show']);
return new View('view/admin/index.html.php', array('folder' => 'newsletter', 'file' => 'detail', 'detail' => $filters['show'], 'mailing' => $mailing, 'list' => $list));
break;
default:
$list = Sender::getMailings();
return new View('view/admin/index.html.php', array('folder' => 'newsletter', 'file' => 'list', 'list' => $list));
}
}