本文整理汇总了PHP中g11n3t函数的典型用法代码示例。如果您正苦于以下问题:PHP g11n3t函数的具体用法?PHP g11n3t怎么用?PHP g11n3t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了g11n3t函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: prepareResponse
/**
* Prepare the response.
*
* @return void
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
/* @type \JTracker\Application $application */
$application = $this->getContainer()->get('app');
$user = $application->getUser();
$project = $application->getProject();
if (!$user->check('edit')) {
throw new \Exception('You are not allowed to alter this item.');
}
$issueId = $application->input->getUint('issueId');
if (!$issueId) {
throw new \Exception('No issue ID received.');
}
$this->dispatcher = $application->getDispatcher();
$this->addEventListener('tests');
$this->setProjectGitHubBot($project);
$data = new \stdClass();
$result = new \stdClass();
$result->user = $application->input->getUsername('user');
$result->value = $application->input->getUint('result');
$issueModel = new IssueModel($this->getContainer()->get('db'));
$data->testResults = $issueModel->saveTest($issueId, $result->user, $result->value);
$issueNumber = $issueModel->getIssueNumberById($issueId);
$event = (new ActivityModel($this->getContainer()->get('db')))->addActivityEvent('alter_testresult', 'now', $user->username, $project->project_id, $issueNumber, null, json_encode($result));
$this->triggerEvent('onTestAfterSubmit', ['issueNumber' => $issueNumber, 'data' => $data->testResults]);
$data->event = new \stdClass();
foreach ($event as $k => $v) {
$data->event->{$k} = $v;
}
$data->event->text = json_decode($data->event->text);
$this->response->data = json_encode($data);
$this->response->message = g11n3t('Test successfully added');
}
开发者ID:biodamasceno,项目名称:jissues,代码行数:41,代码来源:Alter.php
示例2: prepareResponse
/**
* Prepare the response.
*
* @return void
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
if (false == $this->getContainer()->get('app')->getUser()->check('manage')) {
throw new \Exception('You are not authorized');
}
$input = $this->getContainer()->get('app')->input;
$db = $this->getContainer()->get('db');
$user = $input->getCmd('user');
$groupId = $input->getInt('group_id');
$assign = $input->getInt('assign');
if (!$groupId) {
throw new \Exception('Missing group id');
}
$tableUsers = new TableUsers($this->getContainer()->get('db'));
$tableUsers->loadByUserName($user);
if (!$tableUsers->id) {
throw new \Exception('User not found');
}
$check = $db->setQuery($db->getQuery(true)->from($db->quoteName('#__user_accessgroup_map', 'm'))->select('COUNT(*)')->where($db->quoteName('group_id') . ' = ' . (int) $groupId)->where($db->quoteName('user_id') . ' = ' . (int) $tableUsers->id))->loadResult();
if ($assign) {
if ($check) {
throw new \Exception('The user is already assigned to this group.');
}
$this->assign($tableUsers->id, $groupId);
$this->response->data->message = g11n3t('The user has been assigned.');
} else {
if (!$check) {
throw new \Exception('The user is not assigned to this group.');
}
$this->unAssign($tableUsers->id, $groupId);
$this->response->data->message = g11n3t('The user has been unassigned.');
}
}
开发者ID:dextercowley,项目名称:jissues,代码行数:41,代码来源:Assign.php
示例3: execute
/**
* Execute the controller.
*
* @return string
*
* @since 1.0
*/
public function execute()
{
$table = new GroupsTable($this->getContainer()->get('db'));
$table->load($this->getContainer()->get('app')->input->getInt('group_id'))->delete();
$this->getContainer()->get('app')->enqueueMessage(g11n3t('The group has been deleted.'), 'success');
return parent::execute();
}
开发者ID:dextercowley,项目名称:jissues,代码行数:14,代码来源:Delete.php
示例4: execute
/**
* Execute the controller.
*
* @return string The rendered view.
*
* @since 1.0
* @throws \UnexpectedValueException
*/
public function execute()
{
/* @type \JTracker\Application $application */
$application = $this->getContainer()->get('app');
$id = $application->input->getUint('id');
if (!$id) {
throw new \UnexpectedValueException('No id given');
}
if (!$application->getUser()->check('admin')) {
if ($application->getUser()->id != $id) {
$application->enqueueMessage(g11n3t('You are not authorized to refresh this user.'), 'error')->redirect($application->get('uri.base.path') . 'user/' . $id);
}
}
/* @type \Joomla\Github\Github $github */
$gitHub = $this->getContainer()->get('gitHub');
$loginHelper = new GitHubLoginHelper($this->getContainer());
$gitHubUser = $gitHub->users->getAuthenticatedUser();
$user = new GithubUser($application->getProject(), $this->getContainer()->get('db'));
$user->loadGitHubData($gitHubUser)->loadByUserName($user->username);
// Refresh the avatar
$loginHelper->refreshAvatar($user->username);
try {
$loginHelper->setEmail($user->id, $gitHubUser->email);
} catch (\RuntimeException $e) {
$application->enqueueMessage(g11n3t('An error has occurred during email refresh.'), 'error');
}
$application->enqueueMessage(g11n3t('The profile has been refreshed.'), 'success')->redirect($application->get('uri.base.path') . 'user/' . $id);
return parent::execute();
}
开发者ID:joomlla,项目名称:jissues,代码行数:37,代码来源:Refresh.php
示例5: render
/**
* Method to render the view.
*
* @return string The rendered view.
*
* @since 1.0
* @throws \UnexpectedValueException
*/
public function render()
{
$type = $this->getLogType();
switch ($type) {
case 'php':
$path = $this->getDebugger()->getLogPath('php');
break;
case '403':
case '404':
case '500':
case 'app':
case 'cron':
case 'database':
case 'error':
case 'github_issues':
case 'github_comments':
case 'github_pulls':
$path = $this->getDebugger()->getLogPath('root') . '/' . $type . '.log';
break;
default:
throw new \UnexpectedValueException('Invalid log type');
break;
}
$log = realpath($path) ? $this->processLog($type, $path) : [sprintf(g11n3t('No %s log file found.'), $type)];
$this->renderer->set('log', $log);
$this->renderer->set('log_type', $type);
return parent::render();
}
开发者ID:joomlla,项目名称:jissues,代码行数:36,代码来源:LogsHtmlView.php
示例6: prepareResponse
/**
* Prepare the response.
*
* @return void
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
/* @type \JTracker\Application $application */
$application = $this->getContainer()->get('app');
$user = $application->getUser();
$project = $application->getProject();
if (!$user->id) {
throw new \Exception('You are not allowed to test this item.');
}
$issueId = $application->input->getUint('issueId');
$result = $application->input->getUint('result');
if (!$issueId) {
throw new \Exception('No issue ID received.');
}
$issueModel = new IssueModel($this->getContainer()->get('db'));
$data = new \stdClass();
$data->testResults = $issueModel->saveTest($issueId, $user->username, $result);
$event = (new ActivityModel($this->getContainer()->get('db')))->addActivityEvent('test_item', 'now', $user->username, $project->project_id, $issueModel->getIssueNumberById($issueId), null, json_encode($result));
$data->event = new \stdClass();
foreach ($event as $k => $v) {
$data->event->{$k} = $v;
}
$data->event->text = json_decode($data->event->text);
$this->response->data = json_encode($data);
$this->response->message = g11n3t('Test successfully added');
}
开发者ID:joomlla,项目名称:jissues,代码行数:34,代码来源:Submit.php
示例7: prepareResponse
/**
* Prepare the response.
*
* @return mixed
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
// Verify the user has permissions to perform this action
if (!$this->getContainer()->get('app')->getUser()->authorize('view')) {
throw new \Exception('Anonymous votes are not allowed.');
}
/* @type Input $input */
$input = $this->getContainer()->get('app')->input;
$issue = $input->getUint('issueId');
$experienced = $input->getInt('experienced');
$importance = $input->getInt('importance');
$userID = $this->getContainer()->get('app')->getUser()->id;
if (!$issue) {
throw new \Exception('No issue ID received.');
}
if (!$importance) {
throw new \Exception('Issue importance not received');
}
$model = new IssueModel($this->getContainer()->get('db'));
$data = $model->vote($issue, $experienced, $importance, $userID);
// Add the new score
$data->importanceScore = $data->score / $data->votes;
$this->response->data = $data;
$this->response->message = g11n3t('Vote successfully added');
}
开发者ID:dextercowley,项目名称:jissues,代码行数:33,代码来源:Vote.php
示例8: fetchTags
/**
* Fetch Tags.
*
* @param array $packages List of installed packages
* @param boolean $allTags Fetch all tags or only the "most recent".
*
* @return $this
*
* @since 1.0
*/
private function fetchTags(array $packages, $allTags = false)
{
foreach ($packages as $package) {
$this->out($package->name);
if (!preg_match('|https://github.com/([A-z0-9\\-]+)/([A-z0-9\\-\\.]+).git|', $package->source->url, $matches)) {
$this->out('CAN NOT PARSE: ' . $package->source->url);
continue;
}
$owner = $matches[1];
$repo = $matches[2];
$tags = $this->github->repositories->getListTags($owner, $repo);
$found = false;
foreach ($tags as $tag) {
if ($tag->name == $package->version) {
$this->out($tag->name . ' <= ' . g11n3t('Installed'));
$found = true;
if (!$allTags) {
break;
}
} else {
$this->out($tag->name);
}
}
if (!$found) {
$this->out(sprintf(g11n3t('Installed: %s'), $package->version));
}
$this->out();
}
return $this;
}
开发者ID:dextercowley,项目名称:jissues,代码行数:40,代码来源:Composertags.php
示例9: prepareResponse
/**
* Prepare the response.
*
* @return mixed
*
* @since 1.0
*/
protected function prepareResponse()
{
/* @type \JTracker\Application $application */
$application = $this->getContainer()->get('app');
$files = $application->input->files->get('files');
if (!empty($files)) {
$file = new File($application);
// Prepare response data
$host = $application->get('uri')->base->host;
$destName = md5(time() . $file->getName()) . '.' . $file->getExtension();
$destDir = $application->getProject()->project_id;
$fullPath = $host . '/' . $application->get('system.upload_dir') . '/' . $destDir . '/' . $destName;
$data = array(array('url' => $fullPath, 'thumbnailUrl' => $fullPath, 'name' => $file->getName(), 'type' => $file->getMimetype(), 'size' => $file->getSize(), 'alt' => 'screen shot ' . date('Y-m-d') . ' at ' . date('H i s'), 'deleteUrl' => '/upload/delete/?file=' . $destName, 'deleteType' => "POST", 'editorId' => $application->input->get('editorId')));
// Try to upload file
try {
$file->upload($destName);
} catch (\Exception $e) {
$errors = array();
foreach ($file->getErrors() as $error) {
$errors[] = g11n3t($error);
}
$data = array(array('error' => $errors));
}
$this->response->files = $data;
}
}
开发者ID:joomlla,项目名称:jissues,代码行数:33,代码来源:Put.php
示例10: execute
/**
* Execute the command.
*
* @return void
*
* @since 1.0
*/
public function execute()
{
$this->getApplication()->outputTitle(g11n3t('Get Translations'));
$this->languages = $this->getApplication()->get('languages');
// Remove English from the language array
unset($this->languages[0]);
$this->logOut(g11n3t('Start fetching translations.'))->setupTransifex()->fetchTranslations()->out()->logOut(g11n3t('Finished.'));
}
开发者ID:dextercowley,项目名称:jissues,代码行数:15,代码来源:Transifex.php
示例11: execute
/**
* Execute the controller.
*
* @return string
*
* @since 1.0
*/
public function execute()
{
$app = $this->getContainer()->get('app');
$app->getUser()->authorize('admin');
$table = new ArticlesTable($this->getContainer()->get('db'));
$table->delete($app->input->getInt('id'));
$app->enqueueMessage(g11n3t('The article has been deleted.'), 'success');
$this->getContainer()->get('app')->input->set('view', 'articles');
return parent::execute();
}
开发者ID:dextercowley,项目名称:jissues,代码行数:17,代码来源:Delete.php
示例12: execute
/**
* Execute the controller.
*
* @return string
*
* @since 1.0
*/
public function execute()
{
$app = $this->getContainer()->get('app');
$app->getUser()->authorize('admin');
$table = new ArticlesTable($this->getContainer()->get('db'));
/* @type \Joomla\Github\Github $gitHub */
$table->setGitHub($this->getContainer()->get('gitHub'));
$table->save($app->input->get('article', array(), 'array'));
$app->enqueueMessage(g11n3t('The article has been saved.'), 'success');
return parent::execute();
}
开发者ID:dextercowley,项目名称:jissues,代码行数:18,代码来源:Save.php
示例13: execute
/**
* Execute the controller.
*
* @return void
*
* @since 1.0
*/
public function execute()
{
$application = $this->getContainer()->get('app');
try {
g11n::cleanCache();
$application->enqueueMessage(g11n3t('The cache has been cleared.'), 'success');
} catch (\Exception $e) {
$application->enqueueMessage($e->getMessage(), 'error');
}
$application->redirect('/');
}
开发者ID:dextercowley,项目名称:jissues,代码行数:18,代码来源:Clearcache.php
示例14: prepareResponse
/**
* Prepare the response.
*
* @return void
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
/* @type \JTracker\Application $application */
$application = $this->getContainer()->get('app');
$user = $application->getUser();
$project = $application->getProject();
if (!$user->id) {
throw new \Exception('You are not allowed to test this item.');
}
$issueId = $application->input->getUint('issueId');
$result = $application->input->getUint('result');
$userComment = $application->input->get('comment', '', 'raw');
$sha = $application->input->getCmd('sha');
if (!$issueId) {
throw new \Exception('No issue ID received.');
}
$this->dispatcher = $application->getDispatcher();
$this->addEventListener('tests');
$this->setProjectGitHubBot($project);
$issueModel = new IssueModel($this->getContainer()->get('db'));
$data = new \stdClass();
$data->testResults = $issueModel->saveTest($issueId, $user->username, $result, $sha);
$issueNumber = $issueModel->getIssueNumberById($issueId);
$event = (new ActivityModel($this->getContainer()->get('db')))->addActivityEvent('test_item', 'now', $user->username, $project->project_id, $issueNumber, null, json_encode($result));
$this->triggerEvent('onTestAfterSubmit', ['issueNumber' => $issueNumber, 'data' => $data->testResults]);
$data->event = new \stdClass();
foreach ($event as $k => $v) {
$data->event->{$k} = $v;
}
$data->event->text = json_decode($data->event->text);
$gitHubHelper = new GitHubHelper($this->getContainer()->get('gitHub'));
// Create a comment to submitted on GitHub.
switch ($result) {
case 0:
$comment = 'I have not tested this item.';
break;
case 1:
$comment = 'I have tested this item :white_check_mark: successfully on ' . $sha;
break;
case 2:
$comment = 'I have tested this item :red_circle: unsuccessfully on ' . $sha;
break;
default:
throw new \UnexpectedValueException('Unexpected test result value.');
break;
}
$comment .= $userComment ? '<br /><br />' . $userComment : '';
$comment .= $gitHubHelper->getApplicationComment($application, $project, $issueNumber);
$data->comment = $gitHubHelper->addComment($project, $issueNumber, $comment, $user->username, $this->getContainer()->get('db'));
$this->response->data = json_encode($data);
$this->response->message = g11n3t('Test successfully added');
}
开发者ID:shamsbd71,项目名称:jissues,代码行数:60,代码来源:Submit.php
示例15: prepareResponse
/**
* Prepare the response.
*
* @return mixed
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
$this->getContainer()->get('app')->getUser()->authorize('create');
$comment = $this->getContainer()->get('app')->input->get('text', '', 'raw');
$issue_number = $this->getContainer()->get('app')->input->getInt('issue_number');
if (!$issue_number) {
throw new \Exception('No issue number received.');
}
if (!$comment) {
throw new \Exception('You should write a comment first...');
}
// @todo removeMe :(
$comment .= sprintf('<br /><br />*This comment was created with the <a href="%1$s">%2$s Application</a> at <a href="%3$s">%4$s</a>.*', 'https://github.com/joomla/jissues', 'J!Tracker', $this->getContainer()->get('app')->get('uri')->base->full, $this->getContainer()->get('app')->get('uri')->base->full);
$project = $this->getContainer()->get('app')->getProject();
/* @type \Joomla\Github\Github $github */
$github = $this->getContainer()->get('gitHub');
$data = new \stdClass();
$db = $this->getContainer()->get('db');
if ($project->gh_user && $project->gh_project) {
$gitHubResponse = $github->issues->comments->create($project->gh_user, $project->gh_project, $issue_number, $comment);
if (!isset($gitHubResponse->id)) {
throw new \Exception('Invalid response from GitHub');
}
$data->created_at = $gitHubResponse->created_at;
$data->opened_by = $gitHubResponse->user->login;
$data->comment_id = $gitHubResponse->id;
$data->text_raw = $gitHubResponse->body;
$data->text = $github->markdown->render($comment, 'gfm', $project->gh_user . '/' . $project->gh_project);
} else {
$date = new Date();
$data->created_at = $date->format($db->getDateFormat());
$data->opened_by = $this->getContainer()->get('app')->getUser()->username;
$data->comment_id = '???';
$data->text_raw = $comment;
$data->text = $github->markdown->render($comment, 'markdown');
}
$table = new ActivitiesTable($db);
$table->event = 'comment';
$table->created_date = $data->created_at;
$table->project_id = $project->project_id;
$table->issue_number = $issue_number;
$table->gh_comment_id = $data->comment_id;
$table->user = $data->opened_by;
$table->text = $data->text;
$table->text_raw = $data->text_raw;
$table->store();
$data->activities_id = $table->activities_id;
$this->response->data = $data;
$this->response->message = g11n3t('Your comment has been submitted');
}
开发者ID:dextercowley,项目名称:jissues,代码行数:58,代码来源:Submit.php
示例16: check
/**
* Method to perform sanity checks on the AbstractDatabaseTable instance properties to ensure
* they are safe to store in the database.
*
* @return $this Method allows chaining
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function check()
{
$errors = array();
if (trim($this->issue_id) == '') {
$errors[] = g11n3t('Issue id is needed');
}
if (trim($this->category_id) == '') {
$errors[] = g11n3t('Category ID is needed.');
}
if ($errors) {
throw new \InvalidArgumentException(implode("\n", $errors));
}
return $this;
}
开发者ID:dextercowley,项目名称:jissues,代码行数:23,代码来源:IssueCategoryMappingTable.php
示例17: execute
/**
* Execute the controller.
*
* @return string
*
* @since 1.0
*/
public function execute()
{
/* @type \JTracker\Application $application */
$application = $this->getContainer()->get('app');
$model = new CategoryModel($this->getContainer()->get('db'));
try {
$model->delete($application->input->get('id'));
$application->enqueueMessage(g11n3t('The category has been deleted'), 'success');
} catch (\Exception $exception) {
$application->enqueueMessage($exception->getMessage(), 'error');
}
$application->redirect($application->get('uri.base.path') . 'category/' . $application->getProject()->alias);
return parent::execute();
}
开发者ID:dextercowley,项目名称:jissues,代码行数:21,代码来源:Delete.php
示例18: getItem
/**
* Get an item.
*
* @param integer $id The id of the category
*
* @return CategoryTable
*
* @throws \RuntimeException
*
* @since 1.0
*/
public function getItem($id)
{
if ($id == null) {
throw new \RuntimeException(g11n3t('Missing ID'));
}
$db = $this->getDb();
$query = $db->getQuery(true);
$table = new CategoryTable($db);
$item = $db->setQuery($query->select('*')->from($db->quoteName($table->getTableName()))->where($db->quoteName('id') . '=' . (int) $id))->loadObject();
if (!$item) {
throw new \RuntimeException(g11n3t('Invalid Category'));
}
return $item;
}
开发者ID:joomlla,项目名称:jissues,代码行数:25,代码来源:CategoryModel.php
示例19: check
/**
* Method to perform sanity checks on the AbstractDatabaseTable instance properties to ensure
* they are safe to store in the database.
*
* @return $this Method allows chaining
*
* @since 1.0
* @throws \UnexpectedValueException
*/
public function check()
{
if (!$this->title) {
throw new \UnexpectedValueException(g11n3t('A title is required'));
}
if (!$this->short_title) {
throw new \UnexpectedValueException(g11n3t('A short title is required'));
}
if (!$this->alias) {
$this->alias = $this->title;
}
$this->alias = $this->stringURLSafe($this->alias);
return $this;
}
开发者ID:dextercowley,项目名称:jissues,代码行数:23,代码来源:ProjectsTable.php
示例20: prepareResponse
/**
* Prepare the response.
*
* @return void
*
* @since 1.0
* @throws \Exception
*/
protected function prepareResponse()
{
// Only registered users are able to use the preview using their credentials.
if (!$this->getContainer()->get('app')->getUser()->id) {
throw new \Exception('not auth..');
}
$text = $this->getContainer()->get('app')->input->get('text', '', 'raw');
if (!$text) {
throw new \Exception(g11n3t('Nothing to preview...'));
}
$project = $this->getContainer()->get('app')->getProject();
/* @type \Joomla\Github\Github $github */
$github = $this->getContainer()->get('gitHub');
$this->response->data = $github->markdown->render($text, 'gfm', $project->gh_user . '/' . $project->gh_project);
}
开发者ID:dextercowley,项目名称:jissues,代码行数:23,代码来源:Preview.php
注:本文中的g11n3t函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论