mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-16 15:01:09 +03:00
code style by Kohana standard
This commit is contained in:
parent
ab5d2efacd
commit
9dfd04c707
|
@ -64,12 +64,12 @@ $modules = [
|
|||
'application' => APPPATH, // Main application module
|
||||
'auth' => $vendor_path.'kohana/auth', // Basic authentication
|
||||
'cache' => $vendor_path.'kohana/cache', // Caching with multiple backends
|
||||
//'codebench' => $vendor_path.'kohana/codebench', // Benchmarking tool
|
||||
// 'codebench' => $vendor_path.'kohana/codebench', // Benchmarking tool
|
||||
'database' => $vendor_path.'kohana/database', // Database access
|
||||
//'image' => $vendor_path.'kohana/image', // Image manipulation
|
||||
// 'image' => $vendor_path.'kohana/image', // Image manipulation
|
||||
'minion' => $vendor_path.'kohana/minion', // CLI Tasks
|
||||
'orm' => $vendor_path.'kohana/orm', // Object Relationship Mapping
|
||||
//'unittest' => $vendor_path.'kohana/unittest', // Unit testing
|
||||
// 'unittest' => $vendor_path.'kohana/unittest', // Unit testing
|
||||
'kostache' => $vendor_path.'zombor/kostache', // Logic-less Mustache views
|
||||
'email' => $vendor_path.'tscms/email',// Electronic mail class
|
||||
'debug-toolbar' => MODPATH.'debug-toolbar', // Debug toolbar
|
||||
|
@ -88,19 +88,6 @@ unset($modules);
|
|||
*/
|
||||
I18n::lang('ru');
|
||||
|
||||
if ( ! function_exists('__'))
|
||||
{
|
||||
/**
|
||||
* I18n translate alias function.
|
||||
*
|
||||
* @deprecated 3.4 Use I18n::translate() instead
|
||||
*/
|
||||
function __($string, array $values = NULL, $lang = 'en-us')
|
||||
{
|
||||
return I18n::translate($string, $values, $lang);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SERVER['SERVER_PROTOCOL']))
|
||||
{
|
||||
// Replace the default protocol.
|
||||
|
@ -135,8 +122,8 @@ Kohana::init(array(
|
|||
'base_url' => '/',
|
||||
'index_file' => false,
|
||||
'errors' => TRUE,
|
||||
'profile' => (Kohana::$environment == Kohana::DEVELOPMENT),
|
||||
'caching' => (Kohana::$environment == Kohana::PRODUCTION)
|
||||
'profile' => (Kohana::$environment == Kohana::DEVELOPMENT),
|
||||
'caching' => (Kohana::$environment == Kohana::PRODUCTION)
|
||||
));
|
||||
|
||||
/**
|
||||
|
@ -162,12 +149,12 @@ Cookie::$salt = 'YehsmJK:*$jel_@dj';
|
|||
* defaults for the URI.
|
||||
*/
|
||||
Route::set('minion', 'minion(/<action>)', array('action' => '.+'))
|
||||
->defaults(array(
|
||||
->defaults(array(
|
||||
'controller' => 'Minion',
|
||||
));
|
||||
|
||||
Route::set('error', 'error/<action>(/<message>)', array('action' => '[0-9]++','message' => '.+'))
|
||||
->defaults(array(
|
||||
->defaults(array(
|
||||
'controller' => 'Error',
|
||||
));
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ class Controller_Client extends Controller_Layout {
|
|||
public function action_index()
|
||||
{
|
||||
$this->template = new View_Client_Index;
|
||||
$this->template->title = __('Clients');
|
||||
$this->template->title = I18n::translate('Clients');
|
||||
$group_id = $this->request->post('group_id');
|
||||
if ($group_id) {
|
||||
$group = ORM::factory('Group', $group_id);
|
||||
if (!$group->loaded()) {
|
||||
if ( ! $group->loaded()) {
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title .= ' - ' . $group->name;
|
||||
$this->template->title .= ' - '.$group->name;
|
||||
$this->template->items = $group
|
||||
->clients
|
||||
->filter_by_page($this->request->param('page'))
|
||||
|
@ -45,17 +45,17 @@ class Controller_Client extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->model = ORM::factory('Client');
|
||||
$this->template->title = __('New client');
|
||||
$this->template->title = I18n::translate('New client');
|
||||
$this->_edit($this->template->model);
|
||||
}
|
||||
|
||||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('Edit client info');
|
||||
$this->template->title = I18n::translate('Edit client info');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Client', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ class Controller_Client extends Controller_Layout {
|
|||
$this->template = new View_Delete;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Client', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Delete client');
|
||||
$this->template->title = I18n::translate('Delete client');
|
||||
$this->template->content_title = $model->name;
|
||||
$this->template->content = $model->email;
|
||||
|
||||
|
@ -89,7 +89,7 @@ class Controller_Client extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Client_Index;
|
||||
$this->template->show_create = FALSE;
|
||||
$this->template->title = __('Clients');
|
||||
$this->template->title = I18n::translate('Clients');
|
||||
$query = $this->request->post('query');
|
||||
$this->template->items = ORM::factory('Client')
|
||||
->search($query)
|
||||
|
|
|
@ -13,11 +13,11 @@ class Controller_Course extends Controller_Layout {
|
|||
'period' => 'input',
|
||||
'price' => 'input'
|
||||
);
|
||||
|
||||
|
||||
public function action_index()
|
||||
{
|
||||
$this->template = new View_Course_Index;
|
||||
$this->template->title = __('Course index');
|
||||
$this->template->title = I18n::translate('Course index');
|
||||
$this->template->items = ORM::factory('Course')
|
||||
->filter_by_page($this->request->param('page'))
|
||||
->find_all();
|
||||
|
@ -27,7 +27,7 @@ class Controller_Course extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->model = ORM::factory('Course');
|
||||
$this->template->title = __('New course');
|
||||
$this->template->title = I18n::translate('New course');
|
||||
$this->_edit($this->template->model);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class Controller_Course extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Course_Simple;
|
||||
$this->template->controls = array();
|
||||
$this->template->title = __('New course');
|
||||
$this->template->title = I18n::translate('New course');
|
||||
$course = ORM::factory('Course');
|
||||
$letter = ORM::factory('Letter');
|
||||
if ($this->request->method() === Request::POST) {
|
||||
|
@ -84,10 +84,10 @@ class Controller_Course extends Controller_Layout {
|
|||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('Edit course');
|
||||
$this->template->title = I18n::translate('Edit course');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Course', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -99,11 +99,11 @@ class Controller_Course extends Controller_Layout {
|
|||
$this->template = new View_Delete;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Course', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Delete course');
|
||||
$this->template->title = I18n::translate('Delete course');
|
||||
$this->template->content_title = $model->title;
|
||||
$this->template->content = $model->description;
|
||||
|
||||
|
@ -118,11 +118,11 @@ class Controller_Course extends Controller_Layout {
|
|||
$this->template = new View_Letter_Index;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Course', $id)->with('letters');
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Course').' '.$model->title;
|
||||
$this->template->title = I18n::translate('Course').' '.$model->title;
|
||||
$this->template->course_id = $id;
|
||||
$this->template->items = $model->letters
|
||||
->filter_by_page($this->request->param('page'))
|
||||
|
@ -135,7 +135,7 @@ class Controller_Course extends Controller_Layout {
|
|||
$this->template = new View_Course_Subscribe;
|
||||
$id = $this->request->param('id');
|
||||
$course = ORM::factory('Course', $id);
|
||||
if (!$course->loaded())
|
||||
if ( ! $course->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class Controller_Course extends Controller_Layout {
|
|||
$this->template->controls = $controls;
|
||||
$this->template->errors = array();
|
||||
$model = ORM::factory('Client');
|
||||
|
||||
|
||||
if ($this->request->method() === Request::POST) {
|
||||
$model = ORM::factory('Client')->where('email', '=', $this->request->post('email'))->find();
|
||||
$model->values($this->request->post(), array_keys($controls));
|
||||
|
@ -158,7 +158,7 @@ class Controller_Course extends Controller_Layout {
|
|||
if ($validation->check())
|
||||
{
|
||||
$model->save();
|
||||
if (!$model->has('course', $course))
|
||||
if ( ! $model->has('course', $course))
|
||||
{
|
||||
$model->add('course', $course);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class Controller_Course extends Controller_Layout {
|
|||
}
|
||||
if (empty($this->template->errors))
|
||||
{
|
||||
Session::instance()->set('flash_success', __('You were subscribed. A welcome email has been sent to you. Please check your inbox.'));
|
||||
Session::instance()->set('flash_success', I18n::translate('You were subscribed. A welcome email has been sent to you. Please check your inbox.'));
|
||||
}
|
||||
}
|
||||
$this->template->model = $model;
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Error extends Controller_Layout {
|
||||
class Controller_Error extends Controller_Layout {
|
||||
/**
|
||||
* Pre determine error display logic
|
||||
*/
|
||||
public function before() {
|
||||
parent::before();
|
||||
*/
|
||||
public function before()
|
||||
{
|
||||
parent::before();
|
||||
$this->template = new View_Message;
|
||||
|
||||
// Sub requests only!
|
||||
if ($this->request->is_initial()) $this->request->action(404);
|
||||
$this->response->status((int) $this->request->action());
|
||||
}
|
||||
// Sub requests only!
|
||||
if ($this->request->is_initial())
|
||||
return $this->request->action(404);
|
||||
$this->response->status( (int) $this->request->action());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serves HTTP 404 error page
|
||||
*/
|
||||
public function action_404() {
|
||||
public function action_404()
|
||||
{
|
||||
$this->template->title = 'Страница не найдена';
|
||||
$this->template->message = 'Запрошенная вами страница не найдена. Скорее всего, это была просто опечатка. Проверьте строку адреса.';
|
||||
}
|
||||
|
@ -24,7 +27,7 @@ class Controller_Error extends Controller_Layout {
|
|||
/**
|
||||
* Serves HTTP 403 Access Denied page
|
||||
**/
|
||||
public function action_403()
|
||||
public function action_403()
|
||||
{
|
||||
$this->template->title = 'Доступ запрещён';
|
||||
$this->template->message = 'Вам запрещён доступ к этому адресу.';
|
||||
|
@ -32,9 +35,10 @@ class Controller_Error extends Controller_Layout {
|
|||
|
||||
/**
|
||||
* Serves HTTP 500 error page
|
||||
*/
|
||||
public function action_500() {
|
||||
*/
|
||||
public function action_500()
|
||||
{
|
||||
$this->template->message = 'Произошла внутренняя ошибка. Не волнуйтесь, её должны скоро исправить.';
|
||||
$this->template->title ='Внутренняя ошибка сервера';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ class Controller_Group extends Controller_Layout {
|
|||
public function action_index()
|
||||
{
|
||||
$this->template = new View_Index;
|
||||
$this->template->title = __('Groups');
|
||||
$this->template->title = I18n::translate('Groups');
|
||||
$this->template->header = [
|
||||
__('Group name'),
|
||||
__('Edit'),
|
||||
__('Delete'),
|
||||
I18n::translate('Group name'),
|
||||
I18n::translate('Edit'),
|
||||
I18n::translate('Delete'),
|
||||
];
|
||||
$this->template->items = ORM::factory('Group')
|
||||
->filter_by_page($this->request->param('page'))
|
||||
|
@ -36,17 +36,17 @@ class Controller_Group extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->model = ORM::factory('Group');
|
||||
$this->template->title = __('New group');
|
||||
$this->template->title = I18n::translate('New group');
|
||||
$this->_edit($this->template->model);
|
||||
}
|
||||
|
||||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('Edit group info');
|
||||
$this->template->title = I18n::translate('Edit group info');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Group', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ class Controller_Group extends Controller_Layout {
|
|||
$this->template = new View_Delete;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Group', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Delete group');
|
||||
$this->template->title = I18n::translate('Delete group');
|
||||
$this->template->content_title = $model->name;
|
||||
// $this->template->content = $model->email;
|
||||
// TODO - display a list of subscribers in group
|
||||
|
@ -89,7 +89,7 @@ class Controller_Group extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Client_Index;
|
||||
$this->template->show_create = FALSE;
|
||||
$this->template->title = __('Groups');
|
||||
$this->template->title = I18n::translate('Groups');
|
||||
$query = $this->request->post('query');
|
||||
$this->template->items = ORM::factory('Group')
|
||||
->search($query)
|
||||
|
|
|
@ -16,13 +16,13 @@ class Controller_Instant extends Controller_Layout {
|
|||
$this->template = new View_Edit;
|
||||
$id = $this->request->param('id');
|
||||
$subscription = ORM::factory('Subscription', $id);
|
||||
if (!$subscription->loaded())
|
||||
if ( ! $subscription->loaded())
|
||||
{
|
||||
$this->redirect('error/500');
|
||||
}
|
||||
$this->template->model = ORM::factory('Instant');
|
||||
$this->template->model->subscription_id = $id;
|
||||
$this->template->title = __('New letter');
|
||||
$this->template->title = I18n::translate('New letter');
|
||||
$this->_edit($this->template->model);
|
||||
}
|
||||
public function action_index()
|
||||
|
@ -30,11 +30,11 @@ class Controller_Instant extends Controller_Layout {
|
|||
$this->template = new View_Instant_Index;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Subscription', $id)->with('instants');
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Subscription').' '.$model->title;
|
||||
$this->template->title = I18n::translate('Subscription').' '.$model->title;
|
||||
$this->template->subscription_id = $id;
|
||||
$this->template->items = $model->instants
|
||||
->filter_by_page($this->request->param('page'))
|
||||
|
@ -45,10 +45,10 @@ class Controller_Instant extends Controller_Layout {
|
|||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('Instant editing');
|
||||
$this->template->title = I18n::translate('Instant editing');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Instant', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ class Controller_Instant extends Controller_Layout {
|
|||
public function action_send()
|
||||
{
|
||||
$this->template = new View_Message;
|
||||
$this->template->title = __('Send instant to all subscribers');
|
||||
$this->template->title = I18n::translate('Send instant to all subscribers');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Instant', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ class Controller_Instant extends Controller_Layout {
|
|||
$model->send($client->email, $client->token);
|
||||
}
|
||||
$model->save();
|
||||
$this->template->message = __('The instant has been sent.');
|
||||
$this->template->message = I18n::translate('The instant has been sent.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,19 +15,15 @@ class Controller_Layout extends Controller {
|
|||
{
|
||||
parent::before();
|
||||
$action_name = $this->request->action();
|
||||
if (
|
||||
Kohana::$environment === Kohana::PRODUCTION &&
|
||||
is_array($this->secure_actions) &&
|
||||
in_array($action_name, $this->secure_actions, TRUE)
|
||||
)
|
||||
if (Kohana::$environment === Kohana::PRODUCTION
|
||||
AND is_array($this->secure_actions)
|
||||
AND in_array($action_name, $this->secure_actions, TRUE))
|
||||
{
|
||||
if ( Auth::instance()->logged_in() === FALSE)
|
||||
if (Auth::instance()->logged_in() === FALSE)
|
||||
{
|
||||
$this->redirect('user/signin');
|
||||
}
|
||||
else
|
||||
{
|
||||
//user is clear to go but his pages are cache-sensitive
|
||||
} else {
|
||||
// user is clear to go but his pages are cache-sensitive
|
||||
$this->is_private = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +32,7 @@ class Controller_Layout extends Controller {
|
|||
{
|
||||
if ($this->auto_render)
|
||||
{
|
||||
if (!empty($this->controls) && empty($this->template->controls))
|
||||
if ( ! empty($this->controls) AND empty($this->template->controls))
|
||||
{
|
||||
$this->template->controls = $this->controls;
|
||||
}
|
||||
|
@ -55,9 +51,9 @@ class Controller_Layout extends Controller {
|
|||
**/
|
||||
protected function _edit($model, $controls = NULL)
|
||||
{
|
||||
if (!($model instanceof ORM))
|
||||
if ( ! ($model instanceof ORM))
|
||||
{
|
||||
Log::instance()->add(Log::ERROR, __('Attempt to call _edit() on non-ORM model. Parameter class should be ORM, not ').get_class($model).'.');
|
||||
Log::instance()->add(Log::ERROR, I18n::translate('Attempt to call _edit() on non-ORM model. Parameter class should be ORM, not ').get_class($model).'.');
|
||||
$this->redirect('error/500');
|
||||
}
|
||||
$this->template->errors = array();
|
||||
|
|
|
@ -16,29 +16,29 @@ class Controller_Letter extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Edit;
|
||||
$id = $this->request->param('id');
|
||||
if (!Model_Course::exists($id))
|
||||
if ( ! Model_Course::exists($id))
|
||||
{
|
||||
$this->redirect('error/500');
|
||||
}
|
||||
$this->template->model = ORM::factory('Letter');
|
||||
$this->template->model->course_id = $id;
|
||||
$this->template->title = __('New letter');
|
||||
$this->template->title = I18n::translate('New letter');
|
||||
$this->_edit($this->template->model);
|
||||
}
|
||||
|
||||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('Letter editing');
|
||||
$this->template->title = I18n::translate('Letter editing');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Letter', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->_edit($model);
|
||||
}
|
||||
|
||||
|
||||
protected function _edit_redirect($model)
|
||||
{
|
||||
return Route::url('default', array('controller' => 'Course','action' => 'view','id' => $model->course_id));
|
||||
|
@ -49,11 +49,11 @@ class Controller_Letter extends Controller_Layout {
|
|||
$this->template = new View_Delete;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Letter', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Delete letter');
|
||||
$this->template->title = I18n::translate('Delete letter');
|
||||
$this->template->content_title = $model->title;
|
||||
$this->template->content = $model->description;
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Controller_Letter extends Controller_Layout {
|
|||
{
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Letter', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -85,15 +85,15 @@ class Controller_Letter extends Controller_Layout {
|
|||
$letter = ORM::factory('Letter', $id);
|
||||
$token = $this->request->query('token');
|
||||
$email = $this->request->query('email');
|
||||
if (!$letter->loaded() || empty($token) || empty($email))
|
||||
if ( ! $letter->loaded() OR empty($token) OR empty($email))
|
||||
{
|
||||
$this->redirect('error/500');
|
||||
}
|
||||
$client = ORM::factory('Client')->where('email', '=', $email)->and_where('token', '=', $token)->find();
|
||||
$course = ORM::factory('Course', $letter->course_id);
|
||||
if (!$client->loaded() || !$course->loaded())
|
||||
if ( ! $client->loaded() OR ! $course->loaded())
|
||||
{
|
||||
Session::instance()->set_once('flash_error', __('Client not found. Possible subscription token problem.'));
|
||||
Session::instance()->set_once('flash_error', I18n::translate('Client not found. Possible subscription token problem.'));
|
||||
$this->redirect('error/403');
|
||||
}
|
||||
// token is valid, client is found, letter is found - we can unsubscribe him now
|
||||
|
@ -101,7 +101,7 @@ class Controller_Letter extends Controller_Layout {
|
|||
Log::instance()->add(Log::NOTICE, 'Client '.$client->name.' has been unsubscribed from course '.$course->title);
|
||||
Model_Task::cancel($client->id, $course->id);
|
||||
$this->template = new View_Message;
|
||||
$this->template->message = __('You have been successfully unsubscribed from course %s', array('%s' => $course->title));
|
||||
$this->template->message = I18n::translate('You have been successfully unsubscribed from course %s', array('%s' => $course->title));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,21 +16,21 @@ class Controller_Page extends Controller_Layout {
|
|||
$this->auto_render = FALSE;
|
||||
$id = $this->request->param('id');
|
||||
$page = ORM::factory('Page', $id);
|
||||
if (!$page->loaded())
|
||||
if ( ! $page->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$is_admin = Auth::instance()->logged_in('admin');
|
||||
if ($page->is_draft AND !$is_admin)
|
||||
if ($page->is_draft AND ! $is_admin)
|
||||
{
|
||||
$this->redirect('error/403');
|
||||
}
|
||||
$cache = Cache::instance('apcu');
|
||||
$latest_change = $page->posted_at;
|
||||
if (!$is_admin)
|
||||
if ( ! $is_admin)
|
||||
{
|
||||
$body = $cache->get('page_'.$id);
|
||||
if (!empty($body))
|
||||
if ( ! empty($body))
|
||||
{
|
||||
if ($cache->get('page_'.$id.'_changed') === $latest_change)
|
||||
{
|
||||
|
@ -48,13 +48,13 @@ class Controller_Page extends Controller_Layout {
|
|||
$this->template->content = $page->content;
|
||||
if ($page->is_draft)
|
||||
{
|
||||
$this->template->title .= ' ('.__('draft').')';
|
||||
$this->template->title .= ' ('.I18n::translate('draft').')';
|
||||
}
|
||||
$renderer = Kostache_Layout::factory('layout');
|
||||
$body = $renderer->render($this->template, $this->template->_view);
|
||||
if (!$is_admin)
|
||||
if ( ! $is_admin)
|
||||
{
|
||||
$cache->set('page_'.$id, $body, 60*60*24); //cache page for 1 day
|
||||
$cache->set('page_'.$id, $body, 60*60*24); // cache page for 1 day
|
||||
}
|
||||
$cache->set('page_'.$id.'_changed', $latest_change);
|
||||
$this->response->body($body);
|
||||
|
@ -65,24 +65,24 @@ class Controller_Page extends Controller_Layout {
|
|||
public function action_index()
|
||||
{
|
||||
$this->template = new View_Index;
|
||||
$this->template->title = __('Page index');
|
||||
$this->template->title = I18n::translate('Page index');
|
||||
$this->template->show_date = FALSE;
|
||||
$this->template->items = ORM::factory('Page')
|
||||
->where('is_draft', '=', '0')
|
||||
->order_by('name', 'ASC')
|
||||
->filter_by_page($this->request->param('page'))
|
||||
->find_all();
|
||||
->find_all();
|
||||
}
|
||||
public function action_delete()
|
||||
{
|
||||
$this->template = new View_Delete;
|
||||
$id = $this->request->param('id');
|
||||
$page = ORM::factory('Page', $id);
|
||||
if (!$page->loaded())
|
||||
if ( ! $page->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Delete page');
|
||||
$this->template->title = I18n::translate('Delete page');
|
||||
$this->template->content_title = $page->name;
|
||||
$this->template->content = $page->content;
|
||||
|
||||
|
@ -98,7 +98,7 @@ class Controller_Page extends Controller_Layout {
|
|||
public function action_create()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('New page');
|
||||
$this->template->title = I18n::translate('New page');
|
||||
$this->template->errors = array();
|
||||
$this->template->model = ORM::factory('Page');
|
||||
$this->_edit($this->template->model);
|
||||
|
@ -109,10 +109,10 @@ class Controller_Page extends Controller_Layout {
|
|||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Page_Edit;
|
||||
$this->template->title = __('Edit page');
|
||||
$this->template->title = I18n::translate('Edit page');
|
||||
$id = $this->request->param('id');
|
||||
$this->template->model = ORM::factory('Page', $id);
|
||||
if (!$this->template->model->loaded())
|
||||
if ( ! $this->template->model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -125,11 +125,11 @@ class Controller_Page extends Controller_Layout {
|
|||
public function action_drafts()
|
||||
{
|
||||
$this->template = new View_Index;
|
||||
$this->template->title = __('Page drafts');
|
||||
$this->template->title = I18n::translate('Page drafts');
|
||||
$this->template->show_date = FALSE;
|
||||
$this->template->items = ORM::factory('Page')
|
||||
->where('is_draft', '=', '1')
|
||||
->order_by('name', 'DESC')
|
||||
->find_all();
|
||||
->find_all();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Photo management
|
||||
**/
|
||||
class Controller_Photo extends Controller_Layout {
|
||||
protected $secure_actions = array(
|
||||
'edit' => array('login','admin'),
|
||||
);
|
||||
|
||||
/**
|
||||
* View photo by ID
|
||||
**/
|
||||
public function action_view()
|
||||
{
|
||||
$id = $this->request->param('id');
|
||||
$photo = ORM::factory('Photo', $id);
|
||||
if (!$photo->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$view = new View_Message;
|
||||
$this->template->title = $photo->name;
|
||||
$this->template->message = HTML::image($photo->get_image_path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a new photo
|
||||
**/
|
||||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Photo_Edit;
|
||||
$id = $this->request->param('id');
|
||||
$photo = ORM::factory('Photo', $id);
|
||||
$this->template->title = 'Загрузка фотографии';
|
||||
$this->template->errors = array();
|
||||
$this->template->controls = array(
|
||||
'name' => 'input',
|
||||
);
|
||||
if ($photo->loaded())
|
||||
{
|
||||
$this->template->image_path = $photo->image_path;
|
||||
}
|
||||
$this->template->custom_controls = array(
|
||||
'file' => array(
|
||||
'type' => 'file',
|
||||
'label' => 'Файл изображения'
|
||||
)
|
||||
);
|
||||
if (Request::POST == $this->request->method()) {
|
||||
$validation_post = Validation::factory($this->request->post())
|
||||
->rules('name', array(
|
||||
array('not_empty'),
|
||||
));
|
||||
$validation_files = Validation::factory( $_FILES )
|
||||
->rule( 'file', array( 'Upload', 'not_empty' ) )
|
||||
->rule( 'file', array( 'Upload', 'valid' ) )
|
||||
->rule( 'file', 'Upload::type', array(':value', array('jpg', 'png', 'gif')));
|
||||
$file = Arr::get($_FILES, 'file');
|
||||
if ($validation_post->check() AND $validation_files->check() AND isset($file))
|
||||
{
|
||||
$photo->filename = Arr::get($file, 'name');
|
||||
$filename = $photo->file_save($file);
|
||||
if ( $filename === false ) {
|
||||
throw new Exception( 'Unable to save uploaded file.' );
|
||||
}
|
||||
$photo->name = $this->request->post('name');
|
||||
try {
|
||||
if ($photo->check())
|
||||
{
|
||||
$photo->create();
|
||||
}
|
||||
}
|
||||
catch (ORM_Validation_Exception $e)
|
||||
{
|
||||
$this->template->errors = $e->errors();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->template->errors = Arr::merge( $validation_post->errors(), $validation_files->errors() );
|
||||
}
|
||||
if (empty($this->template->errors))
|
||||
{
|
||||
$this->redirect('photo/view/' . $photo->id);
|
||||
}
|
||||
}
|
||||
$this->template->model = $photo;
|
||||
}
|
||||
|
||||
public function action_create()
|
||||
{
|
||||
$this->redirect('photo/edit');
|
||||
}
|
||||
|
||||
public function action_upload()
|
||||
{
|
||||
$this->redirect('photo/edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Index all photos in the database.
|
||||
**/
|
||||
public function action_index()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -12,11 +12,11 @@ class Controller_Subscription extends Controller_Layout {
|
|||
'description' => 'textarea',
|
||||
// 'price' => 'input'
|
||||
);
|
||||
|
||||
|
||||
public function action_index()
|
||||
{
|
||||
$this->template = new View_Subscription_Index;
|
||||
$this->template->title = __('Subscription index');
|
||||
$this->template->title = I18n::translate('Subscription index');
|
||||
$this->template->items = ORM::factory('Subscription')
|
||||
->filter_by_page($this->request->param('page'))
|
||||
->find_all();
|
||||
|
@ -26,17 +26,17 @@ class Controller_Subscription extends Controller_Layout {
|
|||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->model = ORM::factory('Subscription');
|
||||
$this->template->title = __('New subscription');
|
||||
$this->template->title = I18n::translate('New subscription');
|
||||
$this->_edit($this->template->model);
|
||||
}
|
||||
|
||||
public function action_edit()
|
||||
{
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('Edit subscription');
|
||||
$this->template->title = I18n::translate('Edit subscription');
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Subscription', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ class Controller_Subscription extends Controller_Layout {
|
|||
$this->template = new View_Delete;
|
||||
$id = $this->request->param('id');
|
||||
$model = ORM::factory('Subscription', $id);
|
||||
if (!$model->loaded())
|
||||
if ( ! $model->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Delete subscription');
|
||||
$this->template->title = I18n::translate('Delete subscription');
|
||||
$this->template->content_title = $model->title;
|
||||
$this->template->content = $model->description;
|
||||
|
||||
|
@ -72,11 +72,11 @@ class Controller_Subscription extends Controller_Layout {
|
|||
$this->template = new View_Course_Subscribe;
|
||||
$id = $this->request->param('id');
|
||||
$subscription = ORM::factory('Subscription', $id);
|
||||
if (!$subscription->loaded())
|
||||
if ( ! $subscription->loaded())
|
||||
{
|
||||
$this->redirect('error/404');
|
||||
}
|
||||
$this->template->title = __('Subscribe to ').$subscription->title;
|
||||
$this->template->title = I18n::translate('Subscribe to ').$subscription->title;
|
||||
$controls = array(
|
||||
'name' => 'input',
|
||||
'email' => 'input'
|
||||
|
@ -84,7 +84,7 @@ class Controller_Subscription extends Controller_Layout {
|
|||
$this->template->controls = $controls;
|
||||
$this->template->errors = array();
|
||||
$model = ORM::factory('Client');
|
||||
|
||||
|
||||
if ($this->request->method() === Request::POST) {
|
||||
$model = ORM::factory('Client')->where('email', '=', $this->request->post('email'))->find();
|
||||
$model->values($this->request->post(), array_keys($controls));
|
||||
|
@ -95,14 +95,14 @@ class Controller_Subscription extends Controller_Layout {
|
|||
if ($validation->check())
|
||||
{
|
||||
$model->save();
|
||||
if (!$model->has('subscription', $subscription))
|
||||
if ( ! $model->has('subscription', $subscription))
|
||||
{
|
||||
$model->add('subscription', $subscription);
|
||||
}
|
||||
$instant = ORM::factory('Instant');
|
||||
$instant->subscription_id = $id;
|
||||
$instant->subject = __('You were subscribed to ').$subscription->title;
|
||||
$instant->text = __('From now on you will receive letters from this subscription.');
|
||||
$instant->subject = I18n::translate('You were subscribed to ').$subscription->title;
|
||||
$instant->text = I18n::translate('From now on you will receive letters from this subscription.');
|
||||
$instant->send($model->email, $model->token);
|
||||
// instant is not saved because it's just a welcome email
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class Controller_Subscription extends Controller_Layout {
|
|||
}
|
||||
if (empty($this->template->errors))
|
||||
{
|
||||
Session::instance()->set('flash_success', __('You were subscribed. A welcome email has been sent to you. Please check your inbox.'));
|
||||
Session::instance()->set('flash_success', I18n::translate('You were subscribed. A welcome email has been sent to you. Please check your inbox.'));
|
||||
}
|
||||
}
|
||||
$this->template->model = $model;
|
||||
|
|
|
@ -16,21 +16,21 @@ class Controller_User extends Controller_Layout {
|
|||
$this->redirect('post/index');
|
||||
}
|
||||
$this->template = new View_Edit;
|
||||
$this->template->title = __('User login');
|
||||
$this->template->title = I18n::translate('User login');
|
||||
$this->template->errors = array();
|
||||
$this->template->custom_controls = array(
|
||||
'username' => array(
|
||||
'type' => 'input',
|
||||
'label' => __('Username'),
|
||||
'label' => I18n::translate('Username'),
|
||||
'value' => ''
|
||||
),
|
||||
'password' => array(
|
||||
'type' => 'password',
|
||||
'label' => __('Password'),
|
||||
'label' => I18n::translate('Password'),
|
||||
'value' => ''
|
||||
),
|
||||
);
|
||||
if (Request::POST == $this->request->method()) {
|
||||
if ($this->request->method() === Request::POST) {
|
||||
$validation = Validation::factory($this->request->post())
|
||||
->rules('username', array(
|
||||
array('not_empty'),
|
||||
|
@ -44,7 +44,7 @@ class Controller_User extends Controller_Layout {
|
|||
}
|
||||
else
|
||||
{
|
||||
array_push($this->template->errors, __('Authorization error. Please check user login and password.'));
|
||||
array_push($this->template->errors, I18n::translate('Authorization error. Please check user login and password.'));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -45,7 +45,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Input;
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Input;
|
||||
$template->name = $name;
|
||||
$template->label = __(Arr::get($attributes, 'label'));
|
||||
$template->label = I18n::translate(Arr::get($attributes, 'label'));
|
||||
$template->value = $value;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Date;
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = strftime('%Y-%m-%dT%H:%M:%S', strtotime($model->$name));
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Password;
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Password;
|
||||
$template->name = $name;
|
||||
$template->label = __(Arr::get($attributes, 'label'));
|
||||
$template->label = I18n::translate(Arr::get($attributes, 'label'));
|
||||
$template->value = $value;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class Form extends Kohana_Form {
|
|||
$template = new View_Form_Input;
|
||||
$template->_view = 'form/inline/input';
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_inline_control($template);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class Form extends Kohana_Form {
|
|||
$template = new View_Form_Password;
|
||||
$template->_view = 'form/inline/password';
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_inline_control($template);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Textarea;
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class Form extends Kohana_Form {
|
|||
$template = new View_Form_Textarea;
|
||||
$template->_view = 'form/inline/textarea';
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_inline_control($template);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class Form extends Kohana_Form {
|
|||
$template = new View_Form_Textarea;
|
||||
$template->_view = 'form/inline/textarea';
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_inline_control($template);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Textarea;
|
||||
$template->name = $name;
|
||||
$template->label = __(Arr::get($attributes, 'label'));
|
||||
$template->label = I18n::translate(Arr::get($attributes, 'label'));
|
||||
$template->value = $value;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_WYSIWYG;
|
||||
$template->name = $name;
|
||||
$template->label = __($model->get_label($name));
|
||||
$template->label = I18n::translate($model->get_label($name));
|
||||
$template->value = $model->$name;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class Form extends Kohana_Form {
|
|||
**/
|
||||
public static function orm_checkbox($model, $name)
|
||||
{
|
||||
return self::checkbox($name, 1, (boolean) $model->$name, array('label' => $model->get_label($name)));
|
||||
return self::checkbox($name, 1, (bool) $model->$name, array('label' => $model->get_label($name)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,9 +167,9 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Checkbox;
|
||||
$template->name = $name;
|
||||
$template->label = __(Arr::get($attributes, 'label'));
|
||||
$template->is_selected = (boolean) $checked;
|
||||
$template->value = (boolean) $value;
|
||||
$template->label = I18n::translate(Arr::get($attributes, 'label'));
|
||||
$template->is_selected = (bool) $checked;
|
||||
$template->value = (bool) $value;
|
||||
return self::render_control($template);
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ class Form extends Kohana_Form {
|
|||
{
|
||||
$template = new View_Form_Select;
|
||||
$template->name = $name;
|
||||
$template->label = __(Arr::get($attributes, 'label'));
|
||||
$template->label = I18n::translate(Arr::get($attributes, 'label'));
|
||||
$template->options = array();
|
||||
foreach ($options as $value => $text)
|
||||
{
|
||||
|
@ -207,12 +207,12 @@ class Form extends Kohana_Form {
|
|||
}
|
||||
$parameters['class'] = $class;
|
||||
$parameters['type'] = $type;
|
||||
return parent::button($name, __($text), $parameters);
|
||||
return parent::button($name, I18n::translate($text), $parameters);
|
||||
}
|
||||
|
||||
public static function btn_submit($text = 'Send', $is_default = TRUE)
|
||||
{
|
||||
return self::btn('submit', __($text), 'primary', 'submit');
|
||||
return self::btn('submit', I18n::translate($text), 'primary', 'submit');
|
||||
}
|
||||
|
||||
protected static function render_control($template)
|
||||
|
|
|
@ -5,38 +5,38 @@
|
|||
class HTTP_Exception extends Kohana_HTTP_Exception {
|
||||
/**
|
||||
* Generate a Response for all Exceptions without a more specific override
|
||||
*
|
||||
*
|
||||
* The user should see a nice error page, however, if we are in development
|
||||
* mode we should show the normal Kohana error page.
|
||||
*
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function get_response()
|
||||
{
|
||||
// Lets log the Exception, Just in case it's important!
|
||||
Kohana_Exception::log($this);
|
||||
|
||||
if (FALSE && Kohana::$environment >= Kohana::DEVELOPMENT)
|
||||
|
||||
if (FALSE AND Kohana::$environment >= Kohana::DEVELOPMENT)
|
||||
{
|
||||
// Show the normal Kohana error page.
|
||||
return parent::get_response();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Generate a nicer looking "Oops" page using error sub request
|
||||
$attributes = array(
|
||||
// Generate a nicer looking "Oops" page using error sub request
|
||||
$attributes = array(
|
||||
'action' => $this->getCode(),
|
||||
'message' => rawurlencode($this->getMessage())
|
||||
);
|
||||
|
||||
$body = Request::factory(Route::get('error')->uri($attributes))
|
||||
->execute()
|
||||
);
|
||||
|
||||
$body = Request::factory(Route::get('error')->uri($attributes))
|
||||
->execute()
|
||||
->body();
|
||||
|
||||
$response = Response::factory()
|
||||
->status($this->getCode())
|
||||
->body($body);
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ class Model_Client extends ORM {
|
|||
* A function to search by group ID
|
||||
* @param int $group_id
|
||||
*/
|
||||
public function find_by_group($group_id) {
|
||||
public function find_by_group($group_id)
|
||||
{
|
||||
return $this
|
||||
->with('groups')
|
||||
->find()
|
||||
|
|
|
@ -56,7 +56,7 @@ class Model_Instant extends ORM {
|
|||
**/
|
||||
public static function _send($address, $text, $subject, $token = '')
|
||||
{
|
||||
Log::instance()->add(Log::NOTICE, __('Sending letter with subject "%subject" to address %address', array('%subject' => $subject, '%address' => $address)));
|
||||
Log::instance()->add(Log::NOTICE, I18n::translate('Sending letter with subject "%subject" to address %address', array('%subject' => $subject, '%address' => $address)));
|
||||
$sender = Kohana::$config->load('email')->get('sender');
|
||||
$template = new View_Letter_View;
|
||||
$template->content = $text;
|
||||
|
|
|
@ -42,7 +42,7 @@ class Model_Letter extends ORM {
|
|||
|
||||
public function customize()
|
||||
{
|
||||
if(empty($this->order))
|
||||
if($this->order == 0)
|
||||
{
|
||||
$this->order = Model_Course::count_letters($this->course_id) + 1;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class Model_Letter extends ORM {
|
|||
**/
|
||||
public static function _send($address, $text, $subject, $id, $token = '')
|
||||
{
|
||||
Log::instance()->add(Log::NOTICE, __('Sending letter with subject "%subject" to address %address', array('%subject' => $subject, '%address' => $address)));
|
||||
Log::instance()->add(Log::NOTICE, I18n::translate('Sending letter with subject "%subject" to address %address', array('%subject' => $subject, '%address' => $address)));
|
||||
$sender = Kohana::$config->load('email')->get('sender');
|
||||
$template = new View_Letter_View;
|
||||
$template->content = $text;
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
class Model_Photo extends ORM {
|
||||
|
||||
/**
|
||||
* @return array validation rules
|
||||
**/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
'name' => array(
|
||||
array('not_empty'),
|
||||
),
|
||||
'filename' => array(
|
||||
array('not_empty')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public $_labels = array(
|
||||
'name' => 'Название',
|
||||
);
|
||||
|
||||
protected function get_image_dir_path()
|
||||
{
|
||||
return Kohana::$config->load('common.uploads_dir').'/photos';
|
||||
}
|
||||
public function get_image_path()
|
||||
{
|
||||
if ($this->filename) return $this->get_image_dir_path().'/'.$this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that adds suffix _thumb to file name: /home/dhawu.jpeg -> /home/dhawu_thumb.jpeg
|
||||
* @param integer $width
|
||||
* thumbnail width (manages the suffix)
|
||||
* @param integer $height
|
||||
* thumbnail height (manages the suffix)
|
||||
* @retval string
|
||||
*/
|
||||
public function get_thumbnail_path($width = NULL, $height = NULL)
|
||||
{
|
||||
$image_path = $this->get_image_path();
|
||||
return $this->generate_thumbnail($image_path, $width, $height);
|
||||
}
|
||||
|
||||
public static function generate_thumbnail($image_path, $width = 0, $height = 0)
|
||||
{
|
||||
if ($width == 0) $width = Kohana::$config->load('common.thumbnail_width');
|
||||
if ($height == 0) $height = Kohana::$config->load('common.thumbnail_height');
|
||||
if (!is_file(DOCROOT.$image_path))
|
||||
{
|
||||
throw new HTTP_Exception_404('File not found');
|
||||
return $image_path;
|
||||
}
|
||||
|
||||
$thumbnail_path = self::generate_thumbnail_path($image_path, $width, $height);
|
||||
|
||||
if (!is_file(DOCROOT.$thumbnail_path)) {
|
||||
$image = Image::factory(DOCROOT.$image_path);
|
||||
$image->resize($width, $height, Image::WIDTH);
|
||||
$image->crop($width, $height);
|
||||
$image->save(DOCROOT.$thumbnail_path, 80); //save thumbnail with quality of 80
|
||||
}
|
||||
return $thumbnail_path;
|
||||
}
|
||||
|
||||
public static function generate_thumbnail_path($image_path, $width = 0, $height = 0)
|
||||
{
|
||||
if ($width == 0) $width = Kohana::$config->load('common.thumbnail_width');
|
||||
if ($height == 0) $height = Kohana::$config->load('common.thumbnail_height');
|
||||
$parts = explode('.', $image_path);
|
||||
$count = count($parts) - 2;
|
||||
if ($count < 0) $count = 0;
|
||||
$suffix = 'thumb';
|
||||
if ($width) $suffix .= $width;
|
||||
if ($height) $suffix .= '_' . $height;
|
||||
$parts[$count] .= '_' . $suffix;
|
||||
return implode('.', $parts);
|
||||
}
|
||||
|
||||
protected function get_thumbnail_file_path($width = NULL, $height = NULL)
|
||||
{
|
||||
return DOCROOT.$this->get_thumbnail_path($width, $height);
|
||||
}
|
||||
|
||||
public function file_save($file)
|
||||
{
|
||||
return Upload::save($file, $this->filename, DOCROOT.$this->get_image_dir_path());
|
||||
}
|
||||
}
|
|
@ -102,7 +102,7 @@ class Model_Task extends ORM {
|
|||
while ($i < $cnt)
|
||||
{
|
||||
$retval = $letters[$i];
|
||||
if (!in_array($retval, $sent_letters))
|
||||
if ( ! in_array($retval, $sent_letters))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class Model_Task extends ORM {
|
|||
{
|
||||
return $retval;
|
||||
}
|
||||
elseif( $i < count($letters))
|
||||
elseif($i < count( $letters ))
|
||||
{
|
||||
return $letters[$i];
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ class Model_Task extends ORM {
|
|||
->and_where(DB::expr('DATEDIFF(CURDATE(), `date`)'), '=', $period)
|
||||
->execute()
|
||||
->get('date');
|
||||
if (!empty($check))
|
||||
if ( ! empty($check))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ class ORM extends Kohana_ORM {
|
|||
* @param array $_POST data
|
||||
* @return Validation
|
||||
**/
|
||||
public function validate_create($post_data)
|
||||
{
|
||||
public function validate_create($post_data)
|
||||
{
|
||||
$validation = Validation::factory($post_data);
|
||||
$rules = $this->rules();
|
||||
foreach ($rules as $field => $rules)
|
||||
|
@ -122,7 +122,7 @@ class ORM extends Kohana_ORM {
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads model(s) from array of IDs or single ID.
|
||||
**/
|
||||
|
@ -131,7 +131,7 @@ class ORM extends Kohana_ORM {
|
|||
if (empty($id))
|
||||
return FALSE;
|
||||
if (is_array($id))
|
||||
return $this->where($this->_object_name .'.'. $this->_primary_key, 'IN', $id)->find_all();
|
||||
return $this->where($this->_object_name.'.'.$this->_primary_key, 'IN', $id)->find_all();
|
||||
return $this->where('id', '=', $id)->find();
|
||||
}
|
||||
|
||||
|
@ -154,5 +154,7 @@ class ORM extends Kohana_ORM {
|
|||
/**
|
||||
* A utility function to customize model before saving it
|
||||
**/
|
||||
public function customize() {}
|
||||
public function customize()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class Task_Password extends Minion_Task
|
|||
'user' => 'admin',
|
||||
'password' => NULL,
|
||||
];
|
||||
|
||||
|
||||
public function build_validation(Validation $validation)
|
||||
{
|
||||
return parent::build_validation($validation)
|
||||
|
@ -35,6 +35,6 @@ class Task_Password extends Minion_Task
|
|||
$users[$params['user']] = $hash;
|
||||
$config->set('users', $users);
|
||||
Kohana::$config->detach($writer);
|
||||
echo __('The password was successfully changed.');
|
||||
echo I18n::translate('The password was successfully changed.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class Task_Prepare extends Minion_Task
|
|||
$period = Model_Course::get_period($course);
|
||||
$clients = Model_Course::get_client_ids($course, $period);
|
||||
$letters = Model_Course::get_letter_ids($course);
|
||||
if (!is_array($clients))
|
||||
if ( ! is_array($clients))
|
||||
{
|
||||
$this->prepare_letters($clients, $letters, $period);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class Task_Prepare extends Minion_Task
|
|||
{
|
||||
// get courses which have subscribers
|
||||
$courses = Model_Course::get_ids();
|
||||
if (!is_array($courses))
|
||||
if ( ! is_array($courses))
|
||||
{
|
||||
$this->prepare_course($courses);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class Task_Prepare extends Minion_Task
|
|||
foreach ($courses as $course)
|
||||
{
|
||||
$this->prepare_course($course);
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->commit();
|
||||
}
|
||||
|
|
|
@ -13,21 +13,22 @@ class View_Client_Index extends View_Index {
|
|||
public function get_header()
|
||||
{
|
||||
return array(
|
||||
__('Name'),
|
||||
__('Email'),
|
||||
__('Edit'),
|
||||
__('Delete')
|
||||
I18n::translate('Name'),
|
||||
I18n::translate('Email'),
|
||||
I18n::translate('Edit'),
|
||||
I18n::translate('Delete')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Group search field
|
||||
*/
|
||||
public function groups() {
|
||||
public function groups()
|
||||
{
|
||||
return Form::open()
|
||||
. Form::select('group_id', ORM::factory('Group')->find_all()->as_array('id', 'name'))
|
||||
. Form::submit('s', __('Submit'))
|
||||
. Form::close();
|
||||
.Form::select('group_id', ORM::factory('Group')->find_all()->as_array('id', 'name'))
|
||||
.Form::submit('s', I18n::translate('Submit'))
|
||||
.Form::close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +36,7 @@ class View_Client_Index extends View_Index {
|
|||
**/
|
||||
protected function show_item($item)
|
||||
{
|
||||
if (!$item instanceof ORM)
|
||||
if ( ! $item instanceof ORM)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -43,8 +44,8 @@ class View_Client_Index extends View_Index {
|
|||
$output = array(
|
||||
'description' => $item->email,
|
||||
'view_link' => HTML::anchor(Route::url('default', array('controller' => 'Client', 'action' => 'view','id' => $item->id)), $item->name, array('class' => 'link_view')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Client', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Client', 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Client', 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Client', 'action' => 'delete','id' => $item->id)), I18n::translate('Delete'), array('class' => 'link_delete')),
|
||||
);
|
||||
return $output;
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ class View_Course_Index extends View_Index {
|
|||
public function get_header()
|
||||
{
|
||||
return array(
|
||||
__('Title'),
|
||||
__('Description'),
|
||||
__('Subscribers'),
|
||||
__('Edit'),
|
||||
__('Delete')
|
||||
I18n::translate('Title'),
|
||||
I18n::translate('Description'),
|
||||
I18n::translate('Subscribers'),
|
||||
I18n::translate('Edit'),
|
||||
I18n::translate('Delete')
|
||||
);
|
||||
}
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ class View_Course_Index extends View_Index {
|
|||
**/
|
||||
protected function show_item($item)
|
||||
{
|
||||
if (!$item instanceof ORM)
|
||||
if ( ! $item instanceof ORM)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class View_Course_Index extends View_Index {
|
|||
$output = array(
|
||||
'description' => $item->description,
|
||||
'view_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'view','id' => $item->id)),$item->title, array('class' => 'link_view')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), I18n::translate('Delete'), array('class' => 'link_delete')),
|
||||
'client_count' => $item->count_clients(),
|
||||
);
|
||||
return $output;
|
||||
|
|
|
@ -9,7 +9,7 @@ class View_Course_Simple extends View_Edit {
|
|||
public function controls_course()
|
||||
{
|
||||
return array(
|
||||
'heading' => __('New course'),
|
||||
'heading' => I18n::translate('New course'),
|
||||
'controls' => array(
|
||||
Form::orm_input($this->model_course, 'title'),
|
||||
Form::orm_textarea($this->model_course, 'description')
|
||||
|
@ -20,7 +20,7 @@ class View_Course_Simple extends View_Edit {
|
|||
public function controls_letter()
|
||||
{
|
||||
return array(
|
||||
'heading' => __('First letter'),
|
||||
'heading' => I18n::translate('First letter'),
|
||||
'controls' => array(
|
||||
Form::orm_input($this->model_letter, 'subject'),
|
||||
Form::orm_textarea($this->model_letter, 'text')
|
||||
|
|
|
@ -35,7 +35,7 @@ class View_Edit extends View_Layout {
|
|||
}
|
||||
foreach ($this->custom_controls as $key => $value)
|
||||
{
|
||||
if (!isset($value['value']))
|
||||
if ( ! isset($value['value']))
|
||||
{
|
||||
$value['value'] = '';
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* Common control layout view
|
||||
**/
|
||||
class View_Form_Control {
|
||||
public $name; //field name
|
||||
public $value; //default value
|
||||
public $label; //field label
|
||||
public $_view; //template to use
|
||||
public $name; // field name
|
||||
public $value; // default value
|
||||
public $label; // field label
|
||||
public $_view; // template to use
|
||||
/**
|
||||
* Field ID. Convention is '<field type>-<field name>'.
|
||||
* @retval string ID
|
||||
|
|
|
@ -68,7 +68,7 @@ class View_Index extends View_Layout {
|
|||
$result = array();
|
||||
if (is_null($this->items) OR $this->items === FALSE OR count($this->items) === 0)
|
||||
{
|
||||
return __('No objects found to show');
|
||||
return I18n::translate('No objects found to show');
|
||||
};
|
||||
if ($this->item_count === count($this->items))
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ class View_Index extends View_Layout {
|
|||
**/
|
||||
protected function show_item($item)
|
||||
{
|
||||
if (!$item instanceof ORM)
|
||||
if ( ! $item instanceof ORM)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -101,8 +101,8 @@ class View_Index extends View_Layout {
|
|||
);
|
||||
if ($this->is_admin and $this->show_edit)
|
||||
{
|
||||
$output['edit_link'] = HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit'));
|
||||
$output['delete_link'] = HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete'));
|
||||
$output['edit_link'] = HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit'));
|
||||
$output['delete_link'] = HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), I18n::translate('Delete'), array('class' => 'link_delete'));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class View_Index extends View_Layout {
|
|||
protected function get_current_page()
|
||||
{
|
||||
$current_page = Request::current()->param('page');
|
||||
if (!$current_page)
|
||||
if ( ! $current_page)
|
||||
return 1;
|
||||
return $current_page;
|
||||
}
|
||||
|
@ -140,11 +140,11 @@ class View_Index extends View_Layout {
|
|||
protected function view_link_colwidth()
|
||||
{
|
||||
$columns = 3;
|
||||
if (!$this->show_date)
|
||||
if ( ! $this->show_date)
|
||||
{
|
||||
$columns++;
|
||||
}
|
||||
if (!Auth::instance()->logged_in('admin'))
|
||||
if ( ! Auth::instance()->logged_in('admin'))
|
||||
{
|
||||
$columns = $columns + 2;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class View_Index extends View_Layout {
|
|||
{
|
||||
if (Auth::instance()->logged_in())
|
||||
{
|
||||
return '<a href="'.Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'create')).'" class="link_new">'.__('Add').'</a>';
|
||||
return '<a href="'.Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'create')).'" class="link_new">'.I18n::translate('Add').'</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -14,28 +14,28 @@ class View_Instant_Index extends View_Index {
|
|||
**/
|
||||
protected function show_item($item)
|
||||
{
|
||||
if (!$item instanceof ORM)
|
||||
if ( ! $item instanceof ORM)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'description' => $item->text,
|
||||
'view_link' => $item->subject,//HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)), $item->subject, array('class' => 'link_view')),
|
||||
'is_sent' => __('Sent'),
|
||||
'view_link' => $item->subject,
|
||||
'is_sent' => I18n::translate('Sent'),
|
||||
'edit_link' => FALSE,
|
||||
'send_button' => HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'send','id' => $item->id)), Form::btn('send', 'Send to subscribers')),
|
||||
);
|
||||
|
||||
if ($item->sent == 0)
|
||||
{
|
||||
$output['edit_link'] = HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit'));
|
||||
$output['edit_link'] = HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit'));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function link_new()
|
||||
{
|
||||
return HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'create', 'id' => $this->subscription_id)), __('Add'), array('class' => 'link_new'));
|
||||
return HTML::anchor(Route::url('default', array('controller' => 'Instant', 'action' => 'create', 'id' => $this->subscription_id)), I18n::translate('Add'), array('class' => 'link_new'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,22 @@ class View_Layout {
|
|||
/**
|
||||
* Inherited paging function
|
||||
**/
|
||||
public function get_paging() {}
|
||||
public function get_paging()
|
||||
{
|
||||
}
|
||||
|
||||
public function has_errors()
|
||||
{
|
||||
return !empty($this->errors);
|
||||
return ! empty($this->errors);
|
||||
}
|
||||
|
||||
public function site_title()
|
||||
{
|
||||
return Kohana::$config->load('common.title');
|
||||
}
|
||||
public function stylesheet() {
|
||||
|
||||
public function stylesheet()
|
||||
{
|
||||
return Html::style("/style.css")."\n".Html::style("https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css");
|
||||
}
|
||||
|
||||
|
@ -39,8 +43,9 @@ class View_Layout {
|
|||
{
|
||||
$scripts = array_merge ($this->base_scripts, $this->scripts);
|
||||
$temp = "";
|
||||
foreach($scripts as $script):
|
||||
if (strstr($script, '://') === FALSE) //no protocol given, script is local
|
||||
foreach($scripts as $script)
|
||||
{
|
||||
if (strstr($script, '://') === FALSE) // no protocol given, script is local
|
||||
{
|
||||
if ($script === 'jquery') // CDN shortcut
|
||||
{
|
||||
|
@ -55,7 +60,7 @@ class View_Layout {
|
|||
{
|
||||
$temp .= HTML::script($script)."\n";
|
||||
}
|
||||
endforeach;
|
||||
};
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
@ -69,18 +74,18 @@ class View_Layout {
|
|||
$result = array();
|
||||
$navigation = array(
|
||||
);
|
||||
if (!Auth::instance()->logged_in())
|
||||
if ( ! Auth::instance()->logged_in())
|
||||
{
|
||||
$navigation = array_merge($navigation, array('Вход' => 'user/signin'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$navigation = array_merge($navigation, array(
|
||||
__('New course') => 'course/simple',
|
||||
__('Courses') => 'course/index',
|
||||
__('Subscriptions') => 'subscription/index',
|
||||
__('Clients') => 'client/index',
|
||||
__('Groups') => 'group/index',
|
||||
I18n::translate('New course') => 'course/simple',
|
||||
I18n::translate('Courses') => 'course/index',
|
||||
I18n::translate('Subscriptions') => 'subscription/index',
|
||||
I18n::translate('Clients') => 'client/index',
|
||||
I18n::translate('Groups') => 'group/index',
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -120,8 +125,8 @@ class View_Layout {
|
|||
if (Auth::instance()->logged_in())
|
||||
{
|
||||
return array(
|
||||
'button_text' => __('Submit'),
|
||||
'input_text' => __('Search'),
|
||||
'button_text' => I18n::translate('Submit'),
|
||||
'input_text' => I18n::translate('Search'),
|
||||
'action' => Route::url('default', array('controller' => 'Client', 'action' => 'search'))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class View_Letter_Index extends View_Index {
|
|||
**/
|
||||
protected function show_item($item)
|
||||
{
|
||||
if (!$item instanceof ORM)
|
||||
if ( ! $item instanceof ORM)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ class View_Letter_Index extends View_Index {
|
|||
$output = array(
|
||||
'description' => $item->text,
|
||||
'view_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view','id' => $item->id)), $item->subject, array('class' => 'link_view')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'delete','id' => $item->id)), I18n::translate('Delete'), array('class' => 'link_delete')),
|
||||
);
|
||||
return $output;
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ class View_Letter_Index extends View_Index {
|
|||
public function iframe_code()
|
||||
{
|
||||
return array(
|
||||
'text' => __('Subscription code'),
|
||||
'text' => I18n::translate('Subscription code'),
|
||||
'code' => '<iframe src="'.Route::url('default', array('controller' => 'Course', 'action' => 'subscribe', 'id' => $this->course_id), TRUE).'" width="100%" height="400"></iframe>',
|
||||
);
|
||||
}
|
||||
|
||||
public function link_new()
|
||||
{
|
||||
return HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'create', 'id' => $this->course_id)), __('Add'), array('class' => 'link_new'));
|
||||
return HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'create', 'id' => $this->course_id)), I18n::translate('Add'), array('class' => 'link_new'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,22 +24,22 @@ class View_Letter_View extends View {
|
|||
**/
|
||||
public $id = NULL;
|
||||
public $scripts = array();
|
||||
|
||||
|
||||
public function view_link()
|
||||
{
|
||||
return HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view', 'id' => $this->id), TRUE), __('Problems viewing this email? Click here.'));
|
||||
return HTML::anchor(Route::url('default', array('controller' => 'Letter', 'action' => 'view', 'id' => $this->id), TRUE), I18n::translate('Problems viewing this email? Click here.'));
|
||||
}
|
||||
|
||||
public function get_content()
|
||||
{
|
||||
return Kostache::factory()->render($this->content);
|
||||
}
|
||||
|
||||
|
||||
public function unsubscribe()
|
||||
{
|
||||
return self::unsubscribe_link($this->id, $this->address, $this->token);
|
||||
}
|
||||
|
||||
|
||||
public static function unsubscribe_link($id, $address, $token)
|
||||
{
|
||||
return HTML::anchor(
|
||||
|
@ -47,7 +47,7 @@ class View_Letter_View extends View {
|
|||
'email' => $address,
|
||||
'token' => $token
|
||||
)),
|
||||
__('Tired of receiving these emails? Click this link to unsubscribe.')
|
||||
I18n::translate('Tired of receiving these emails? Click this link to unsubscribe.')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Edit photo view controller
|
||||
**/
|
||||
class View_Photo_Edit extends View_Edit {
|
||||
public $image_path;
|
||||
|
||||
public function image()
|
||||
{
|
||||
if($this->image_path)
|
||||
{
|
||||
return HTML::image($image_path);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,11 +11,11 @@ class View_Subscription_Index extends View_Index {
|
|||
public function get_header()
|
||||
{
|
||||
return array(
|
||||
__('Title'),
|
||||
__('Description'),
|
||||
__('Subscribers'),
|
||||
__('Edit'),
|
||||
__('Delete')
|
||||
I18n::translate('Title'),
|
||||
I18n::translate('Description'),
|
||||
I18n::translate('Subscribers'),
|
||||
I18n::translate('Edit'),
|
||||
I18n::translate('Delete')
|
||||
);
|
||||
}
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ class View_Subscription_Index extends View_Index {
|
|||
**/
|
||||
protected function show_item($item)
|
||||
{
|
||||
if (!$item instanceof ORM)
|
||||
if ( ! $item instanceof ORM)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class View_Subscription_Index extends View_Index {
|
|||
$output = array(
|
||||
'description' => $item->description,
|
||||
'view_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'view','id' => $item->id)),$item->title, array('class' => 'link_view')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), __('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), __('Delete'), array('class' => 'link_delete')),
|
||||
'edit_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'edit','id' => $item->id)), I18n::translate('Edit'), array('class' => 'link_edit')),
|
||||
'delete_link' => HTML::anchor(Route::url('default', array('controller' => Request::current()->controller(), 'action' => 'delete','id' => $item->id)), I18n::translate('Delete'), array('class' => 'link_delete')),
|
||||
'client_count' => $item->count_clients(),
|
||||
);
|
||||
return $output;
|
||||
|
|
|
@ -23,7 +23,7 @@ return array
|
|||
'password' => '',
|
||||
'persistent' => FALSE,
|
||||
),
|
||||
'table_prefix' => '', //currently not implemented
|
||||
'table_prefix' => '', // currently not implemented
|
||||
'charset' => 'utf8',
|
||||
'caching' => TRUE,
|
||||
'profiling' => FALSE,
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<form method="POST" enctype='multipart/form-data'>
|
||||
{{#has_errors}}
|
||||
<p class="message">При проверке формы были найдены ошибки:</p>
|
||||
<ul class="errors">
|
||||
{{#get_errors}}
|
||||
<li>{{.}}</li>
|
||||
{{/get_errors}}
|
||||
</ul>
|
||||
{{/has_errors}}
|
||||
<p>{{image}}</p>
|
||||
{{{get_controls}}}
|
||||
</form>
|
|
@ -15,13 +15,14 @@ class CoursesTest extends Unittest_Database_TestCase
|
|||
return $this->createXMLDataSet(Kohana::find_file('tests', 'test_data/courses', 'xml'));
|
||||
}
|
||||
|
||||
public function getSetUpOperation() {
|
||||
public function get_setup_operation()
|
||||
{
|
||||
// whether you want cascading truncates
|
||||
// set false if unsure
|
||||
$cascadeTruncates = false;
|
||||
$cascade_truncates = false;
|
||||
|
||||
return new PHPUnit_Extensions_Database_Operation_Composite(array(
|
||||
new PHPUnit_Extensions_Database_Operation_MySQL55Truncate($cascadeTruncates),
|
||||
new PHPUnit_Extensions_Database_Operation_MySQL55Truncate($cascade_truncates),
|
||||
PHPUnit_Extensions_Database_Operation_Factory::INSERT()
|
||||
));
|
||||
}
|
||||
|
@ -29,14 +30,14 @@ class CoursesTest extends Unittest_Database_TestCase
|
|||
/**
|
||||
* @group Mail
|
||||
**/
|
||||
function testPrepareCourse()
|
||||
function test_prepare_course()
|
||||
{
|
||||
Minion_Task::factory(array('task' => 'prepare'))->execute();
|
||||
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
||||
$this->assertEquals(Model_Task::STATUS_PENDING, $status);
|
||||
}
|
||||
|
||||
function testSendCourse()
|
||||
function test_send_course()
|
||||
{
|
||||
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
||||
if (is_null($status))
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
require_once '../../modules/unittest/bootstrap.php';
|
||||
class PHPUnit_Extensions_Database_Operation_MySQL55Truncate extends PHPUnit_Extensions_Database_Operation_Truncate
|
||||
{
|
||||
public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet) {
|
||||
public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $data_set)
|
||||
{
|
||||
$connection->getConnection()->query("SET @PHAKE_PREV_foreign_key_checks = @@foreign_key_checks");
|
||||
$connection->getConnection()->query("SET foreign_key_checks = 0");
|
||||
parent::execute($connection, $dataSet);
|
||||
parent::execute($connection, $data_set);
|
||||
$connection->getConnection()->query("SET foreign_key_checks = @PHAKE_PREV_foreign_key_checks");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue