当前位置: 首页>>代码示例>>PHP>>正文


PHP App::txt方法代码示例

本文整理汇总了PHP中MapasCulturais\App::txt方法的典型用法代码示例。如果您正苦于以下问题:PHP App::txt方法的具体用法?PHP App::txt怎么用?PHP App::txt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapasCulturais\App的用法示例。


在下文中一共展示了App::txt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setParent

 function setParent($parent)
 {
     //Added this case to remove parent from the entity
     if ($parent === null) {
         $this->parent = null;
         return;
     } elseif (!is_object($parent)) {
         return;
     }
     $parent->checkPermission('createChild');
     $error1 = App::txt('O pai não pode ser o filho.');
     $error2 = App::txt('O pai deve ser do mesmo tipo que o filho.');
     if (!key_exists('parent', $this->_validationErrors)) {
         $this->_validationErrors['parent'] = array();
     }
     if ($parent && $parent->id === $this->id) {
         $this->_validationErrors['parent'][] = $error1;
     } elseif (key_exists('parent', $this->_validationErrors) && in_array($error1, $this->_validationErrors['parent'])) {
         $key = array_search($error, $this->_validationErrors['parent']);
         unset($this->_validationErrors['parent'][$key]);
     }
     if ($parent && $parent->className !== $this->className) {
         $this->_validationErrors['parent'][] = $error2;
     } elseif (key_exists('parent', $this->_validationErrors) && in_array($error2, $this->_validationErrors['parent'])) {
         $key = array_search($error, $this->_validationErrors['parent']);
         unset($this->_validationErrors['parent'][$key]);
     }
     if (!$this->_validationErrors['parent']) {
         unset($this->_validationErrors['parent']);
     }
     $this->parent = $parent;
 }
开发者ID:baldasso,项目名称:mapasculturais,代码行数:32,代码来源:EntityNested.php

示例2: setLocation

 /**
  * Sets the value of the location property.
  *
  * You can set the value of this property using a GeoPoint object or using an array,
  *
  * <code>
  * // example with GeoPoint
  * $entity->location = new GeoPoint(-45.123, -23.345);
  *
  * // example with arrays
  * $entity->location = [-45.123, -23.345];
  * $entity->location = ['x' => -45.123, 'y' => -23.345];
  * $entity->location = ['longitude' => -45.123, 'latitude' => -23.345];
  *
  * </code>
  *
  * This method sets the value of the property _geoLocation with a PostGIS ST_Geography type.
  *
  * @param \MapasCulturais\Types\GeoPoint|array $location
  */
 function setLocation($location)
 {
     $x = $y = null;
     if (!$location instanceof GeoPoint) {
         if (is_array($location) && key_exists('x', $location) && key_exists('y', $location)) {
             $x = $location['x'];
             $y = $location['y'];
         } elseif (is_array($location) && key_exists('longitude', $location) && key_exists('latitude', $location)) {
             $x = $location['longitude'];
             $y = $location['latitude'];
         } elseif (is_array($location) && count($location) === 2 && is_numeric($location[0]) && is_numeric($location[1])) {
             $x = $location[0];
             $y = $location[1];
         } else {
             throw new \Exception(App::txt('The location must be an instance of \\MapasCulturais\\Types\\GeoPoint or an array with two numeric values'));
         }
         $location = new GeoPoint($x, $y);
     }
     if (is_numeric($x) && is_numeric($y)) {
         $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
         $sql = "SELECT ST_GeographyFromText('POINT({$location->longitude} {$location->latitude})') AS geo";
         $rsm->addScalarResult('geo', 'geo');
         $query = App::i()->em->createNativeQuery($sql, $rsm);
         $this->_geoLocation = $query->getSingleScalarResult();
     }
     $this->location = $location;
 }
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:47,代码来源:EntityGeoLocation.php

示例3: setLongitude

 /**
  * Sets the Longitude of the point.
  *
  * @param float $val Longitude
  *
  * @throws \Exception if the value is greater than 180 or less then -180
  */
 public function setLongitude($val)
 {
     if ($val > 180 || $val < -180) {
         throw new \Exception(App::txt('Longitude must be a float between 180 and -180'));
     }
     $this->longitude = $val;
 }
开发者ID:baldasso,项目名称:mapasculturais,代码行数:14,代码来源:GeoPoint.php

示例4: setParent

 function setParent(\MapasCulturais\Entity $parent = null)
 {
     if (is_object($this->parent) && is_object($parent) && $this->parent->equals($parent)) {
         return;
     }
     $error1 = App::txt('O pai não pode ser o filho.');
     $error2 = App::txt('O pai deve ser do mesmo tipo que o filho.');
     if (!key_exists('parent', $this->_validationErrors)) {
         $this->_validationErrors['parent'] = [];
     }
     if ($parent && $parent->id === $this->id) {
         $this->_validationErrors['parent'][] = $error1;
     } elseif (key_exists('parent', $this->_validationErrors) && in_array($error1, $this->_validationErrors['parent'])) {
         $key = array_search($error, $this->_validationErrors['parent']);
         unset($this->_validationErrors['parent'][$key]);
     }
     if ($parent && $parent->className !== $this->className) {
         $this->_validationErrors['parent'][] = $error2;
     } elseif (key_exists('parent', $this->_validationErrors) && in_array($error2, $this->_validationErrors['parent'])) {
         $key = array_search($error, $this->_validationErrors['parent']);
         unset($this->_validationErrors['parent'][$key]);
     }
     if (!$this->_validationErrors['parent']) {
         unset($this->_validationErrors['parent']);
     }
     $this->_newParent = $parent;
 }
开发者ID:pedrokoblitz,项目名称:mapa-de-hackers,代码行数:27,代码来源:EntityNested.php

示例5: setParent

 /**
  * Set the parent entity.
  * 
  * @param \MapasCulturais\Entity $parent
  */
 function setParent(\MapasCulturais\Entity $parent = null)
 {
     if (is_object($this->parent) && is_object($parent) && $this->parent->equals($parent)) {
         return;
     }
     $error_diff_type = App::txt('The parent entity must be of the same type');
     $error_same_obj = App::txt('The parent and the child are the same object');
     $error_circ_ref = App::txt('Circular reference');
     $is_object = $parent && is_object($parent);
     if (!key_exists('parent', $this->_validationErrors)) {
         $this->_validationErrors['parent'] = [];
     }
     if ($is_object) {
         if ($parent->equals($this)) {
             $this->_validationErrors['parent'][] = $error_same_obj;
         } else {
             if ($parent->getClassName() !== $this->getClassName()) {
                 $this->_validationErrors['parent'][] = $error_diff_type;
             } else {
                 $_parent = $parent;
                 while ($_parent = $_parent->getParent()) {
                     if ($_parent->equals($this)) {
                         $this->_validationErrors['parent'][] = $error_circ_ref;
                         continue;
                     }
                 }
             }
         }
     }
     if (!$this->_validationErrors['parent']) {
         unset($this->_validationErrors['parent']);
     }
     $this->_newParent = $parent;
 }
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:39,代码来源:EntityNested.php

示例6: getGroup

 function getGroup()
 {
     if ($this->group == 'registration') {
         return App::txt("project registration");
     } else {
         return $this->group;
     }
 }
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:8,代码来源:ProjectAgentRelation.php

示例7: getError

 /**
  * Validates the file and if it is not valid returns the error message
  *
  */
 function getError(\MapasCulturais\Entities\File $file)
 {
     $ok = false;
     foreach ($this->_validations as $validation) {
         if (preg_match("#{$validation}#i", $file->mimeType)) {
             $ok = true;
             break;
         }
     }
     return !$ok ? App::txt($this->errorMessage) : '';
 }
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:15,代码来源:FileGroup.php

示例8: getApiOutput

 /**
  * Returns the ApiOutput Object.
  *
  * @return \MapasCulturais\ApiOutput
  */
 protected function getApiOutput()
 {
     $app = App::i();
     $type = key_exists('@type', $this->data) ? $this->data['@type'] : $app->config['app.defaultApiOutput'];
     $responder = $app->getRegisteredApiOutputById($type);
     if (!$responder) {
         echo sprintf(App::txt("type %s is not registered."), $type);
         App::i()->stop();
     } else {
         return $responder;
     }
 }
开发者ID:rafaelchavesfreitas,项目名称:mapasculturais,代码行数:17,代码来源:ControllerAPI.php

示例9: addStylesToArray

 public function addStylesToArray($group, $script, array &$array)
 {
     if (!in_array($script[1], $array)) {
         foreach ($script[2] as $dep) {
             if (key_exists($dep, $this->_enqueuedStyles[$group])) {
                 $this->addScriptToArray($group, $this->_enqueuedStyles[$group][$dep], $array);
             } else {
                 throw new \Exception(sprintf(App::txt('Missing script dependence: %s depends on %s'), $script[0], $dep));
             }
         }
         $array[] = $script[1];
     }
 }
开发者ID:baldasso,项目名称:mapasculturais,代码行数:13,代码来源:App.php

示例10: getValidationErrors

 /**
  * Validates the entity properties and returns the errors messages.
  *
  * The entity errors messages uses php gettext.
  *
  * If this entity uses metadata, this method will call getMetadataValidationErrors() method
  *
  * <code>
  * /**
  *  * Example of the array of errors:
  *  {@*}
  * array(
  *     'name' => [ 'The name is required' ],
  *     'email' => [ 'The first error message', 'The second error message' ]
  * )
  * </code>
  *
  * @see \MapasCulturais\App::txt() The MapasCulturais GetText method
  * @see \MapasCulturais\Traits\Metadata::getMetadataValidationErrors() Metadata Validation Errors
  *
  * @return array
  */
 public function getValidationErrors()
 {
     $errors = $this->_validationErrors;
     $class = get_called_class();
     foreach ($class::$validations as $property => $validations) {
         if (!$this->{$property} && !key_exists('required', $validations)) {
             continue;
         }
         foreach ($validations as $validation => $error_message) {
             $validation = trim($validation);
             $ok = true;
             if ($validation == 'required') {
                 $ok = (bool) $this->{$property};
             } elseif ($validation == 'unique') {
                 $ok = $this->validateUniquePropertyValue($property);
             } elseif (strpos($validation, 'v::') === 0) {
                 $validation = str_replace('v::', 'MapasCulturais\\Validator::', $validation);
                 eval('$ok = ' . $validation . '->validate($this->' . $property . ');');
             } else {
                 $value = $this->{$property};
                 eval('$ok = ' . $validation . ';');
             }
             if (!$ok) {
                 if (!key_exists($property, $errors)) {
                     $errors[$property] = [];
                 }
                 $errors[$property][] = App::txt($error_message);
             }
         }
     }
     if ($this->usesTypes() && !$this->_type) {
         $errors['type'] = [App::txt('The type is required')];
     } elseif ($this->usesTypes() && !$this->validateType()) {
         $errors['type'] = [App::txt('Invalid type')];
     }
     if ($this->usesMetadata()) {
         $errors = $errors + $this->getMetadataValidationErrors();
     }
     if ($this->usesTaxonomies()) {
         $errors = $errors + $this->getTaxonomiesValidationErrors();
     }
     return $errors;
 }
开发者ID:pedrokoblitz,项目名称:mapa-de-hackers,代码行数:65,代码来源:Entity.php

示例11: foreach

 /**
  * Handle file uploads and creates the File Entities associating them to the owner of the id.
  *
  * You can upload files with description.
  *
  * For example, if you want to change the avatar of the agent with id 99 you need to post the below form:
  * <code>
  * <form method="post" action="/agent/upload/id:99" enctype="multipart/form-data">
  *      <input type="file" name="avatar" />
  * </form>
  * </code>
  *
  * Example of form to upload a file with description:
  * <code>
  * <form method="post" action="/agent/upload/id:99" enctype="multipart/form-data">
  *      <input type="file" name="download" />
  *      <input type="text" name="description[downloads]" />
  * </form>
  * </code>
  *
  * This action response a json with uploaded files info or errors.
  *
  * Example of an error response:
  * <code>
  * [{"error":"The uploaded file is not a valid image."}]
  * </code>
  *
  * Example of a successfull avatar upload response:
  * <code>
  * {"avatar":{"url":"http:\/\/mapasculturais.domain/files/filesuploaded.jpg","description":null}}
  * </code>
  *
  *
  * @see http://wideimage.sourceforge.net/documentation/manipulating-images/
  *
  */
 function POST_upload()
 {
     /**
      * @todo Melhores Mensagens de erro
      */
     $this->requireAuthentication();
     $owner = $this->requestedEntity;
     if (!$owner) {
         $this->errorJson(App::txt('the owner not exists'));
         return;
     }
     $file_class_name = $owner->getFileClassName();
     $app = App::i();
     // if no files uploaded or no id in request data, return an error
     if (empty($_FILES) || !$this->data['id']) {
         $this->errorJson(App::txt('no files uploaded'));
         return;
     }
     $result = [];
     $files = [];
     // the group of the files is the key in $_FILES array
     foreach (array_keys($_FILES) as $group_name) {
         //            $this->errorJson('asd '.$this->id.' '.$group_name.' '.$app->getRegisteredFileGroup($this->id, $group_name));
         $upload_group = $app->getRegisteredFileGroup($this->id, $group_name);
         // if the group exists
         if ($upload_group = $app->getRegisteredFileGroup($this->id, $group_name)) {
             try {
                 $file = $app->handleUpload($group_name, $file_class_name);
                 // if multiple files was uploaded and this group is unique, don't save this group of files.
                 if (is_array($file) && $upload_group->unique) {
                     continue;
                     // else if multiple files was uploaded and this group accepts multiple files, set the group to this files and add them to $files array
                 } elseif (is_array($file) && !$upload_group->unique) {
                     foreach ($file as $f) {
                         if ($error = $upload_group->getError($f)) {
                             $files[] = ['error' => $error, 'group' => $upload_group];
                         } else {
                             $f->group = $group_name;
                             $files[] = $f;
                         }
                     }
                     // else if a single file was uploaded, add the group to this file and add this file to $files array
                 } else {
                     if (key_exists('description', $this->data) && is_array($this->data['description']) && key_exists($group_name, $this->data['description'])) {
                         $file->description = $this->data['description'][$group_name];
                     }
                     if ($error = $upload_group->getError($file)) {
                         $files[] = ['error' => $error, 'group' => $upload_group];
                     } else {
                         $file->group = $group_name;
                         $files[] = $file;
                     }
                 }
             } catch (\MapasCulturais\Exceptions\FileUploadError $e) {
                 $files[] = ['error' => App::txt($e->message), 'group' => $upload_group];
             }
         }
     }
     // if no files was added to $files array, return an error
     if (empty($files)) {
         $this->errorJson(App::txt('no valid files uploaded'));
         return;
     } else {
         $all_files_contains_error = true;
//.........这里部分代码省略.........
开发者ID:wagnertw,项目名称:mapasculturais,代码行数:101,代码来源:ControllerUploads.php


注:本文中的MapasCulturais\App::txt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。