本文整理汇总了PHP中Adianti\Core\AdiantiCoreTranslator::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP AdiantiCoreTranslator::translate方法的具体用法?PHP AdiantiCoreTranslator::translate怎么用?PHP AdiantiCoreTranslator::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adianti\Core\AdiantiCoreTranslator
的用法示例。
在下文中一共展示了AdiantiCoreTranslator::translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate a given value
* @param $label Identifies the value to be validated in case of exception
* @param $value Value to be validated
* @param $parameters aditional parameters for validation (min value)
*/
public function validate($label, $value, $parameters = NULL)
{
$minvalue = $parameters[0];
if ($value < $minvalue) {
throw new Exception(AdiantiCoreTranslator::translate('The field ^1 can not be less than ^2', $label, $minvalue));
}
}
示例2: __construct
/**
* Class Constructor
* @param $type Type of the message (info, error)
* @param $message Message to be shown
* @param $action Action to be processed when closing the dialog
* @param $title_msg Dialog Title
*/
public function __construct($type, $message, TAction $action = NULL, $title_msg = '')
{
$this->id = 'tmessage_' . mt_rand(1000000000, 1999999999);
$modal_wrapper = new TElement('div');
$modal_wrapper->{'class'} = 'modal';
$modal_wrapper->{'id'} = $this->id;
$modal_wrapper->{'style'} = 'padding-top: 10%; z-index:4000';
$modal_wrapper->{'tabindex'} = '-1';
$modal_dialog = new TElement('div');
$modal_dialog->{'class'} = 'modal-dialog';
$modal_content = new TElement('div');
$modal_content->{'class'} = 'modal-content';
$modal_header = new TElement('div');
$modal_header->{'class'} = 'modal-header';
if ($type == 'info') {
$image = new TImage("fa:fa fa-info-circle fa-5x blue");
} else {
$image = new TImage("fa:fa fa-exclamation-circle fa-5x red");
}
$image->{'style'} = 'float:left; margin-right: 10px;';
$close = new TElement('button');
$close->{'type'} = 'button';
$close->{'class'} = 'close';
$close->{'data-dismiss'} = 'modal';
$close->{'aria-hidden'} = 'true';
$close->add('×');
$title = new TElement('h4');
$title->{'class'} = 'modal-title';
$title->{'style'} = 'display:inline';
$title->add($title_msg ? $title_msg : ($type == 'info' ? AdiantiCoreTranslator::translate('Information') : AdiantiCoreTranslator::translate('Error')));
$body = new TElement('div');
$body->{'style'} = 'text-align:left';
$body->{'class'} = 'modal-body';
$body->add($image);
$span = new TElement('span');
$span->add($message);
$body->add($span);
$button = new TElement('button');
$button->{'class'} = 'btn btn-default';
$button->{'data-dismiss'} = 'modal';
$button->{'onclick'} = "\$( '.modal-backdrop' ).last().remove(); \$('#{$this->id}').modal('hide'); \$('body').removeClass('modal-open');";
$button->add('OK');
if ($action) {
$button->{'onclick'} .= "__adianti_load_page('{$action->serialize()}');";
$button->{'data-toggle'} = "modal";
}
$footer = new TElement('div');
$footer->{'class'} = 'modal-footer';
$modal_wrapper->add($modal_dialog);
$modal_dialog->add($modal_content);
$modal_content->add($modal_header);
$modal_header->add($close);
$modal_header->add($title);
$modal_content->add($body);
$modal_content->add($footer);
$footer->add($button);
$modal_wrapper->show();
$callback = 'function () {' . $button->{'onclick'} . '}';
TScript::create("tdialog_start( '#{$this->id}', {$callback} );");
}
示例3: __construct
/**
* Class Constructor
* @param $name name of the form field
* @param $database name of the database connection
* @param $form name of the parent form
* @param $model name of the Active Record to be searched
* @param $display_field name of the field to be searched and shown
* @param $receive_key name of the form field to receive the primary key
* @param $receive_display_field name of the form field to receive the "display field"
* @param $display_field2 name of the #2 field to be searched and shown
*/
public function __construct($name, $database, $form, $model, $display_field, $receive_key, $receive_display_field, TCriteria $criteria = NULL, $display_field2 = NULL)
{
parent::__construct($name);
if (empty($database)) {
throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'database', __CLASS__));
}
if (empty($model)) {
throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'model', __CLASS__));
}
if (empty($display_field)) {
throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'display_field', __CLASS__));
}
$obj = new TStandardSeek2();
// define the action parameters
$action = new TAction(array($obj, 'onSetup'));
$action->setParameter('database', $database);
$action->setParameter('parent', $form);
$action->setParameter('model', $model);
$action->setParameter('display_field', $display_field);
$action->setParameter('receive_key', $receive_key);
$action->setParameter('receive_field', $receive_display_field);
$action->setParameter('criteria', base64_encode(serialize($criteria)));
$action->setParameter('display_field2', $display_field2);
parent::setAction($action);
}
示例4: show
/**
* Show the widget at the screen
*/
public function show()
{
// define the tag properties
$this->tag->name = $this->name;
// tag name
$this->tag->value = $this->value;
// tag value
$this->tag->type = 'password';
// input type
if (strstr($this->size, '%') !== FALSE) {
$this->setProperty('style', "width:{$this->size};", FALSE);
//aggregate style info
} else {
$this->setProperty('style', "width:{$this->size}px;", FALSE);
//aggregate style info
}
// verify if the field is not editable
if (parent::getEditable()) {
if (isset($this->exitAction)) {
if (!TForm::getFormByName($this->formName) instanceof TForm) {
throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
}
$string_action = $this->exitAction->serialize(FALSE);
$this->setProperty('onBlur', "__adianti_post_lookup('{$this->formName}', '{$string_action}', this)");
}
} else {
// make the field read-only
$this->tag->readonly = "1";
$this->tag->{'class'} = 'tfield_disabled';
// CSS
}
// show the tag
$this->tag->show();
}
示例5: onSave
public function onSave()
{
try {
// open a transaction with database
TTransaction::open($this->database);
// get the form data
$object = $this->form->getData($this->activeRecord);
// validate data
$this->form->validate();
// stores the object
$object->store();
// fill the form with the active record data
$this->form->setData($object);
// close the transaction
TTransaction::close();
// shows the success message
//new TMessage('info', AdiantiCoreTranslator::translate('Record saved'));
parent::add(new TAlert('info', AdiantiCoreTranslator::translate('Record saved')));
$this->form->clear();
return $object;
} catch (Exception $e) {
// get the form data
$object = $this->form->getData($this->activeRecord);
// fill the form with the active record data
$this->form->setData($object);
// shows the exception error message
new TMessage('error', $e->getMessage());
// undo all pending operations
TTransaction::rollback();
}
}
示例6: validate
/**
* Validate a given value
* @param $label Identifies the value to be validated in case of exception
* @param $value Value to be validated
* @param $parameters aditional parameters for validation (length)
*/
public function validate($label, $value, $parameters = NULL)
{
$length = $parameters[0];
if (strlen($value) > $length) {
throw new Exception(AdiantiCoreTranslator::translate('The field ^1 can not be greater than ^2 characters', $label, $length));
}
}
示例7: __construct
/**
* Handle paths from a XML file
* @param $xml_file path for the file
*/
public function __construct($xml_file, $controller)
{
parent::__construct();
$path = array();
if (file_exists($xml_file)) {
$menu_string = file_get_contents($xml_file);
if (utf8_encode(utf8_decode($menu_string)) == $menu_string) {
$xml = new SimpleXMLElement($menu_string);
} else {
$xml = new SimpleXMLElement(utf8_encode($menu_string));
}
foreach ($xml as $xmlElement) {
$atts = $xmlElement->attributes();
$label = (string) $atts['label'];
$action = (string) $xmlElement->action;
$icon = (string) $xmlElement->icon;
$this->parse($xmlElement->menu->menuitem, array($label));
}
if (isset($this->paths[$controller]) and $this->paths[$controller]) {
$total = count($this->paths[$controller]);
parent::addHome($path);
$count = 1;
foreach ($this->paths[$controller] as $path) {
parent::addItem($path, $count == $total);
$count++;
}
} else {
throw new Exception(AdiantiCoreTranslator::translate('Class ^1 not found in ^2', $controller, $xml_file));
}
} else {
throw new Exception(AdiantiCoreTranslator::translate('File not found') . ': ' . $xml_file);
}
}
示例8: validate
/**
* Validate a given value
* @param $label Identifies the value to be validated in case of exception
* @param $value Value to be validated
* @param $parameters aditional parameters for validation
*/
public function validate($label, $value, $parameters = NULL)
{
$cnpj = preg_replace("@[./-]@", "", $value);
if (strlen($cnpj) != 14 or !is_numeric($cnpj)) {
throw new Exception(AdiantiCoreTranslator::translate('The field ^1 has not a valid CNPJ', $label));
}
$k = 6;
$soma1 = "";
$soma2 = "";
for ($i = 0; $i < 13; $i++) {
$k = $k == 1 ? 9 : $k;
$soma2 += $cnpj[$i] * $k;
$k--;
if ($i < 12) {
if ($k == 1) {
$k = 9;
$soma1 += $cnpj[$i] * $k;
$k = 1;
} else {
$soma1 += $cnpj[$i] * $k;
}
}
}
$digito1 = $soma1 % 11 < 2 ? 0 : 11 - $soma1 % 11;
$digito2 = $soma2 % 11 < 2 ? 0 : 11 - $soma2 % 11;
$valid = ($cnpj[12] == $digito1 and $cnpj[13] == $digito2);
if (!$valid) {
throw new Exception(AdiantiCoreTranslator::translate('The field ^1 has not a valid CNPJ', $label));
}
}
示例9: __construct
/**
* Class Constructor
* @param $action Callback to be executed
*/
public function __construct($action)
{
$this->action = $action;
if (!is_callable($this->action)) {
$action_string = $this->toString();
throw new Exception(AdiantiCoreTranslator::translate('Method ^1 must receive a paremeter of type ^2', __METHOD__, 'Callback') . ' <br> ' . AdiantiCoreTranslator::translate('Check if the action (^1) exists', $action_string));
}
}
示例10: setActiveRecord
/**
* method setActiveRecord()
* Define wich Active Record class will be used
*/
public function setActiveRecord($activeRecord)
{
if (is_subclass_of($activeRecord, 'TRecord')) {
$this->activeRecord = $activeRecord;
} else {
throw new Exception(AdiantiCoreTranslator::translate('The class ^1 must be subclass of ^2', $activeRecord, 'TRecord'));
}
}
示例11: __construct
/**
* Constructor Method
* Creates the page, the search form and the listing
*/
public function __construct()
{
parent::__construct();
parent::setTitle(AdiantiCoreTranslator::translate('Search record'));
parent::setSize(800, 500);
// creates a new form
$this->form = new TForm('form_standard_seek');
// creates a new table
$table = new TTable();
// adds the table into the form
$this->form->add($table);
// create the form fields
$display_field = new TEntry('display_field');
$display_field->setSize(370);
// keeps the field's value
$display_field->setValue(TSession::getValue('tstandardseek_display_value'));
// create the action button
$find_button = new TButton('busca');
// define the button action
$find_button->setAction(new TAction(array($this, 'onSearch')), AdiantiCoreTranslator::translate('Search'));
$find_button->setImage('ico_find.png');
// add a row for the filter field
$table->addRowSet(new TLabel(_t('Search') . ': '), $display_field, $find_button);
// define wich are the form fields
$this->form->setFields(array($display_field, $find_button));
// creates a new datagrid
$this->datagrid = new TDataGrid();
// create two datagrid columns
$id = new TDataGridColumn('id', 'ID', 'right', 70);
$display = new TDataGridColumn('display_field', AdiantiCoreTranslator::translate('Field'), 'left', 570);
// add the columns to the datagrid
$this->datagrid->addColumn($id);
$this->datagrid->addColumn($display);
// create a datagrid action
$action1 = new TDataGridAction(array($this, 'onSelect'));
$action1->setLabel('Selecionar');
$action1->setImage('ico_apply.png');
$action1->setField('id');
// add the actions to the datagrid
$this->datagrid->addAction($action1);
// create the datagrid model
$this->datagrid->createModel();
// creates the paginator
$this->pageNavigation = new TPageNavigation();
$this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
$this->pageNavigation->setWidth($this->datagrid->getWidth());
// creates the container
$vbox = new TVBox();
$vbox->add($this->form);
$vbox->add($this->datagrid);
$vbox->add($this->pageNavigation);
// add the container to the page
parent::add($vbox);
}
示例12: addCell
/**
* Add a new cell (TTableCell) to the Table Row
* @param $value Cell Content
* @return TTableCell
*/
public function addCell($value)
{
if (is_null($value)) {
throw new Exception(AdiantiCoreTranslator::translate('Method ^1 does not accept null values', __METHOD__));
} else {
// creates a new Table Cell
$cell = new TTableCell($value);
parent::add($cell);
// returns the cell object
return $cell;
}
}
示例13: TTable
/**
* Constructor method
*/
function __construct(Exception $e)
{
$error_array = $e->getTrace();
$table = new TTable();
$row = $table->addRow();
$row->addCell('<b>' . $e->getMessage() . '</b><br>');
$row = $table->addRow();
$row->addCell(' ');
foreach ($error_array as $error) {
$file = isset($error['file']) ? $error['file'] : '';
$line = isset($error['line']) ? $error['line'] : '';
$file = str_replace(PATH, '', $file);
$row = $table->addRow();
$row->addCell('File: ' . $file . ' : ' . $line);
$row = $table->addRow();
$args = array();
if ($error['args']) {
foreach ($error['args'] as $arg) {
if (is_object($arg)) {
$args[] = get_class($arg) . ' object';
} else {
if (is_array($arg)) {
$array_param = array();
foreach ($arg as $value) {
if (is_object($value)) {
$array_param[] = get_class($value);
} else {
if (is_array($value)) {
$array_param[] = 'array';
} else {
$array_param[] = $value;
}
}
}
$args[] = implode(',', $array_param);
} else {
$args[] = (string) $arg;
}
}
}
}
$class = isset($error['class']) ? $error['class'] : '';
$type = isset($error['type']) ? $error['type'] : '';
$row->addCell(' <i>' . '<font color=green>' . $class . '</font>' . '<font color=olive>' . $type . '</font>' . '<font color=darkblue>' . $error['function'] . '</font>' . '(' . '<font color=maroon>' . implode(',', $args) . '</font>' . ')</i>');
}
$scroll = new TScroll();
$scroll->setSize(690, 390);
$scroll->add($table);
ob_start();
$table->show();
$content = ob_get_clean();
new TMessage('error', $content, NULL, AdiantiCoreTranslator::translate('Exception'));
}
示例14: addCell
/**
* Add a new cell (TTableCell) to the Table Row
* @param $value Cell Content
* @return TTableCell
*/
public function addCell($content)
{
if (is_null($content)) {
throw new Exception(AdiantiCoreTranslator::translate('Method ^1 does not accept null values', __METHOD__));
} else {
if (is_string($content)) {
$content = new GtkLabel($content);
}
$cell = new TTableCell($content);
$this->cells[] = $cell;
return $cell;
}
}
示例15: setFieldsByRow
/**
* Define the field quantity per row
* @param $count Field count
*/
public function setFieldsByRow($count)
{
if (is_int($count) and $count >= 1 and $count <= 3) {
$this->fieldsByRow = $count;
if (!empty($this->titleCell)) {
$this->titleCell->{'colspan'} = 2 * $this->fieldsByRow;
}
if (!empty($this->actionCell)) {
$this->actionCell->{'colspan'} = 2 * $this->fieldsByRow;
}
} else {
throw new Exception(AdiantiCoreTranslator::translate('The method (^1) just accept values of type ^2 between ^3 and ^4', __METHOD__, 'integer', 1, 3));
}
}