本文整理汇总了PHP中Goteo\Library\Text::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::update方法的具体用法?PHP Text::update怎么用?PHP Text::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goteo\Library\Text
的用法示例。
在下文中一共展示了Text::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
}
}