本文整理汇总了PHP中Goteo\Library\Text::_方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::_方法的具体用法?PHP Text::_怎么用?PHP Text::_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goteo\Library\Text
的用法示例。
在下文中一共展示了Text::_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(&$errors = array())
{
if (!$this->validate($errors)) {
return false;
}
$fields = array('id', 'section', 'title', 'description', 'order');
$set = '';
$values = array();
foreach ($fields as $field) {
if ($set != '') {
$set .= ", ";
}
$set .= "`{$field}` = :{$field} ";
$values[":{$field}"] = $this->{$field};
}
try {
$sql = "REPLACE INTO criteria SET " . $set;
self::query($sql, $values);
if (empty($this->id)) {
$this->id = self::insertId();
}
$extra = array('section' => $this->section);
Check::reorder($this->id, $this->move, 'criteria', 'id', 'order', $extra);
return true;
} catch (\PDOException $e) {
$errors[] = Text::_("No se ha guardado correctamente. ") . $e->getMessage();
return false;
}
}
示例2: 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}"));
}
示例3: 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}"));
}
示例4: 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;
}
}
示例5: save
public function save(&$errors = array())
{
if (!$this->validate($errors)) {
return false;
}
try {
$sql = "REPLACE INTO project_account (project, bank, bank_owner, paypal, paypal_owner, allowpp) VALUES(:project, :bank, :bank_owner, :paypal, :paypal_owner, :allowpp)";
$values = array(':project' => $this->project, ':bank' => $this->bank, ':bank_owner' => $this->bank_owner, ':paypal' => $this->paypal, ':paypal_owner' => $this->paypal_owner, ':allowpp' => $this->allowpp);
self::query($sql, $values);
return true;
} catch (\PDOException $e) {
$errors[] = Text::_("Las cuentas no se han asignado correctamente. Por favor, revise los datos.") . $e->getMessage();
return false;
}
}
示例6: process
public static function process($action = 'list', $id = null)
{
$model = 'Goteo\\Model\\Skill';
$url = '/admin/skills';
$errors = array();
switch ($action) {
case 'add':
if (isset($_GET['word'])) {
$item = (object) array('name' => $_GET['word']);
} else {
$item = (object) array();
}
$parent_skill = $model::getAllParent();
return new View('view/admin/index.html.php', array('folder' => 'skills', 'file' => 'edit', 'data' => $item, 'parent_skill' => $parent_skill, '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::_('Skill'), 'name' => 'name', 'type' => 'text'), 'description' => array('label' => Text::_('Descripción'), 'name' => 'description', 'type' => 'textarea', 'properties' => 'cols="100" rows="2"')))));
break;
case 'edit':
// gestionar post
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) {
// instancia
$item = new $model(array('id' => $_POST['id'], 'name' => $_POST['name'], 'description' => $_POST['description'], 'parent_skill_id' => $_POST['parent_skill_id']));
if ($item->save($errors)) {
throw new Redirection($url);
} else {
Message::Error(implode('<br />', $errors));
}
} else {
$item = $model::get($id);
}
$parent_skill = $model::getAllParent();
return new View('view/admin/index.html.php', array('folder' => 'skills', 'file' => 'edit', 'data' => $item, 'parent_skill' => $parent_skill, 'form' => array('action' => "{$url}/edit/{$id}", 'submit' => array('name' => 'update', 'label' => 'Guardar'), 'fields' => array('id' => array('label' => '', 'name' => 'id', 'type' => 'hidden'), 'name' => array('label' => 'Skill', 'name' => 'name', 'type' => 'text'), 'description' => array('label' => 'Descripción', 'name' => 'description', 'type' => 'textarea', 'properties' => 'cols="100" rows="2"')))));
break;
case 'up':
$model::up($id);
break;
case 'down':
$model::down($id);
break;
case 'remove':
if ($model::delete($id)) {
throw new Redirection($url);
}
break;
case 'keywords':
return new View('view/admin/index.html.php', array('folder' => 'keywords', 'file' => 'list', 'skills' => $model::getList(), 'words' => $model::getKeyWords()));
break;
}
return new View('view/admin/index.html.php', array('folder' => 'skills', 'file' => 'list', 'model' => 'skill', 'addbutton' => Text::_('New skill'), 'otherbutton' => '<a href="/admin/skills/keywords" class="button">' . Text::get('admin-skill_keyword') . '</a>', 'data' => $model::getAll(), 'columns' => array('edit' => '', 'name' => 'Skill', 'numProj' => 'Proyectos', 'numUser' => 'Usuarios', 'order' => 'Prioridad', 'translate' => '', 'up' => '', 'down' => '', 'translate' => '', 'remove' => ''), 'url' => "{$url}"));
}
示例7: 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");
}
}
示例8: foreach
echo $filter;
?>
" />
<input type="hidden" name="order" value="<?php
echo $order;
?>
" />
<p>
<input type="checkbox" id="msg_all" name="msg_all" value="1" onclick="alert('全ての支援者に送信します');" />
<label for="msg_all">全ての支援者に送信</label>
</p>
<p>
<?php
echo Text::_('Send it to reward seekers');
_;
?>
: <br />
<?php
foreach ($rewards as $rewardId => $rewardData) {
?>
<input type="checkbox" id="msg_reward-<?php
echo $rewardId;
?>
" name="msg_reward-<?php
echo $rewardId;
?>
" value="1" />
<label for="msg_reward-<?php
echo $rewardId;
示例9:
<input type="hidden" name="group" value="<?php
echo $this['template']->group;
?>
" />
<p>
<label for="tpltitle"><?php
echo Text::_('Título');
?>
:</label><br />
<input id="tpltitle" type="text" name="title" size="120" value="<?php
echo $this['template']->title;
?>
" />
</p>
<p>
<label for="tpltext"><?php
echo Text::_('Contenido');
?>
:</label><br />
<textarea id="tpltext" name="text" cols="100" rows="20"><?php
echo $this['template']->text;
?>
</textarea>
</p>
<input type="submit" name="save" value="<?php
echo Text::_('Guardar');
?>
" />
</form>
</div>
示例10: save
public static function save($data, &$errors = array())
{
if (empty($data)) {
$errors[] = Text::_("Sin datos");
return false;
}
if (empty($data['name']) || empty($data['amount']) || empty($data['id'])) {
$errors[] = Text::_("No se guardar sin nombre y cantidad");
return false;
}
try {
$values = array(':id' => $data['id'], ':name' => $data['name'], ':amount' => $data['amount']);
$sql = "REPLACE INTO worthcracy SET `id` = :id, `name` = :name, `amount` = :amount ";
if (Model::query($sql, $values)) {
return true;
} else {
$errors[] = Text::_("Ha fallado ") . $sql . Text::_('con') . " <pre>" . print_r($values, 1) . "</pre>";
return false;
}
} catch (\PDOException $e) {
$errors[] = Text::_('Error sql al grabar el nivel de meritocracia. ') . $e->getMessage();
return false;
}
}
示例11:
<?php
foreach ($this['projects'] as $projectId => $projectName) {
?>
<option value="<?php
echo $projectId;
?>
"><?php
echo $projectName;
?>
</option>
<?php
}
?>
</select>
</p>
<p>
<label for="invest-anonymous"><?php
echo Text::_("Aporte anónimo:");
?>
</label><br />
<input id="invest-anonymous" type="checkbox" name="anonymous" value="1">
</p>
<input type="submit" name="add" value="<?php
echo Text::_("Generar aporte");
?>
" />
</form>
</div>
示例12: foreach
</div>
<div class="widget board">
<?php
if (!empty($this['faqs'])) {
?>
<table>
<thead>
<tr>
<td><!-- Edit --></td>
<th><?php
echo Text::_("Título");
?>
</th> <!-- title -->
<th><?php
echo Text::_("Posición");
?>
</th> <!-- order -->
<td><!-- Move up --></td>
<td><!-- Move down --></td>
<td><!-- Traducir--></td>
<td><!-- Remove --></td>
</tr>
</thead>
<tbody>
<?php
foreach ($this['faqs'] as $faq) {
?>
<tr>
<td><a href="/admin/faq/edit/<?php
示例13: remove
/**
* Quitar un retorno de un proyecto
*
* @param varchar(50) $project id de un proyecto
* @param INT(12) $id identificador de la tabla reward
* @param array $errors
* @return boolean
*/
public function remove(&$errors = array())
{
$values = array(':project' => $this->project, ':id' => $this->id);
try {
self::query("DELETE FROM reward WHERE id = :id AND project = :project", $values);
return true;
} catch (\PDOException $e) {
$errors[] = Text::_('No se ha podido quitar el retorno ') . $this->id . '. ' . $e->getMessage();
//Text::get('remove-reward-fail');
return false;
}
}
示例14: save
public static function save($data, &$errors = array())
{
$fields = static::_fields();
if (empty($data)) {
$errors[] = Text::_("Sin datos");
return false;
}
if (empty($data['lang']) || $data['lang'] == 'original') {
$errors[] = Text::_("No se peude traducir el contenido original, seleccionar un idioma para traducir");
return false;
}
try {
// tenemos el id en $this->id (el campo id siempre se llama id)
// tenemos el lang en $this->lang
// tenemos el nombre de la tabla en $this->table
// tenemos los campos en $fields[$table] y el contenido de cada uno en $this->$field
$set = '`id` = :id, `lang` = :lang ';
$values = array(':id' => $data['id'], ':lang' => $data['lang']);
foreach ($fields[$data['table']] as $field => $fieldDesc) {
if ($set != '') {
$set .= ", ";
}
$set .= "`{$field}` = :{$field} ";
$values[":{$field}"] = $data[$field];
}
$sql = "REPLACE INTO {$data['table']}_lang SET {$set}";
if (Model::query($sql, $values)) {
return true;
} else {
$errors[] = Text::_("Ha fallado ") . $sql . Text::_('con') . " <pre>" . print_r($values, 1) . "</pre>";
return false;
}
} catch (\PDOException $e) {
$errors[] = Text::_('Error sql al grabar el contenido multiidioma. ') . $e->getMessage();
return false;
}
}
示例15: round
<td width="<?php
echo round($per) - 5;
?>
%"><?php
echo is_object($item) ? $item->{$key} : $item[$key];
?>
</td>
<?php
}
?>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} else {
?>
<p><?php
echo Text::_("No se han encontrado registros");
?>
</p>
<?php
}
?>
</div>