/
Tutorials.php
558 lines (545 loc) · 39.4 KB
/
Tutorials.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<?php
/**
* This is the model class for table "{{tutorials}}".
*
* The followings are the available columns in table '{{tutorials}}':
* @property integer $tid
* @property string $name
* @property string $description
* @property integer $active
* @property string $permission
* @property string $permission_grade
*
* The followings are the available model relations:
* @property TutorialEntry[] $tutorialEntries
*/
class Tutorials extends LSActiveRecord
{
private $preBuiltPackage = [];
public function __construct()
{
$this->_generatePreBuiltPackage();
parent::__construct();
}
private function _generatePreBuiltPackage()
{
$this->preBuiltPackage = array(
'firstStartTour' => array(
'name' => 'firstStartTour',
'steps' => array(
array( //1
'element' => '#lime-logo',
'orphan' => true,
'backdrop' => true,
'path' => Yii::app()->createUrl('/admin/index'),
'title' => gT('Welcome to LimeSurvey!'),
'placement' => 'bottom',
'content' => gT("This tour will help you to easily get a basic understanding of LimeSurvey.")."<br/>"
.gt("We would like to help you with a quick tour of the most essential functions and features."),
'redirect' => false,
'onShow' => "(function(tour){ $('#welcomeModal').modal('hide'); })"
),
array( //2
'element' => '.selector__create_survey',
'path' => Yii::app()->createUrl('/admin/index'),
'backdrop' => true,
'title' => gT('The basic functions'),
'content' => gT("The three top boxes are the most basic functions of LimeSurvey.")."<br/>"
.gT("From left to right it should be 'Create survey', 'List surveys' and 'Global settings'. Best we start by creating a survey.")
.'<p class="alert bg-warning">'.gT("Click on the 'Create survey' box - or 'Next' in this tutorial").'</p>',
'reflex' => '.selector__create_survey',
'redirect' => true,
'onShow' => "(function(tour){ $('#welcomeModal').modal('hide'); $('.selector__create_survey').on('click', function(){tour.next();});})"
),
array( //3
'element' => '#surveyls_title',
'path' => Yii::app()->createUrl('/admin/survey/sa/newsurvey'),
'title' => gT('The survey title'),
'content' => gT("This is the title of your survey.")."<br/>"
.gT("Your participants will see this title as well in the browser's title bar, as also on the welcome screen.")
."<p class='bg-warning alert'>".gT("You have to put in at least a title for the survey to be saved.").'</p>',
'redirect' => true,
),
array( //4
'element' => '#cke_description',
'path' => Yii::app()->createUrl('/admin/survey/sa/newsurvey'),
'title' => gT('The survey description'),
'placement' => 'top',
'content' => gT("This is the description of the survey.")."<br/>"
.gT("Your participants will see this at first on their welcome screen.").' '
.gT("Try to describe what your survey is about, but don't ask any question just yet."),
'redirect' => false,
),
array( //5
'element' => '.bootstrap-switch-id-createsample',
'path' => Yii::app()->createUrl('/admin/survey/sa/newsurvey'),
'title' => gT('Create a sample question and question group'),
'content' => gT("In this tutorial we will be creating a question group and a question, so no need to automatically create it."),
'redirect' => false,
),
array( //6
'element' => '#cke_welcome',
'path' => Yii::app()->createUrl('/admin/survey/sa/newsurvey'),
'title' => gT('The welcome message'),
'placement' => 'top',
'content' => gT("This message is shown directly below the survey description on the welcome page. You may leave this blank for now but it is a good way to introduce your participants to the survey."),
'redirect' => false,
),
array( //7
'element' => '#cke_endtext',
'path' => Yii::app()->createUrl('/admin/survey/sa/newsurvey'),
'title' => gT('The end message'),
'placement' => 'top',
'content' => gT("This message is shown at the end of your survey to every participant. It's a great way to say thank you or give some links or hints where to go next."),
'redirect' => false,
),
array( //8
'element' => '#save-form-button',
'path' => Yii::app()->createUrl('/admin/survey/sa/newsurvey'),
'title' => gT('Now save your survey'),
'placement' => 'bottom',
'content' => gT("You may play around with more settings, but let's save and start adding questions to your survey now. Just click on 'Save'."),
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#save-form-button').trigger('click');
return Promise.resolve(tour);
})",
),
array( //9
'element' => '#sidebar',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'right',
'title' => gT('The sidebar'),
'content' => gT('This is the sidebar.').'<br/>'
.gT('All important settings can be reached in this sidebar.').'<br/>'
.gT('You may resize it to fit your screen, so you can easier navigate your survey structure.').' '
.gT('It may be collapsed to show the quick-menu.').' '
.gT('To collapse it either click on the arrow button or drag it to the left.'),
'redirect' => false,
'onShow' => "(function(tour){
return Promise.resolve(tour);
})"
),
array( //10
'element' => '#adminpanel__sidebar--selectorSettingsButton',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('The settings tab with the survey menu'),
'content' => gT('This tab shows the survey settings.').' '
.gT('Any setting for your survey is accessible from this menu.').' '
.gT('If you want to know more about the settings, have a look at our manual.'),
'redirect' => false,
),
array( //11
'element' => '#surveybarid',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('The top bar'),
'content' => gT('This is the top bar.').'<br/>'
.gT('This bar will change as you move through the functionalities.').' '
.gT('This view contains the most important LimeSurvey functionalities like activating and previewing the survey.'),
'redirect' => false,
),
array( //12
'element' => '#adminpanel__sidebar--selectorStructureButton',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('The survey structure'),
'content' => gT('This is the structure view of your survey. Here you can see all your question groups and questions.'),
'redirect' => false,
'onShow' => "(function(tour){
$('#adminpanel__sidebar--selectorStructureButton').trigger('click');
return Promise.resolve(tour);
})",
),
array( //13
'element' => '#adminpanel__sidebar--selectorCreateQuestionGroup',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'right',
'title' => gT("Let's add another question group"),
'content' => gT("What good would your survey be without questions?").' '
.gT('In LimeSurvey a survey is organized in question groups and questions. To begin creating questions we first need a question group.')
.'<p class="alert bg-warning">'.gT("Click on the 'Add question group' button").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
document.location.href = $('#adminpanel__sidebar--selectorCreateQuestionGroup').attr('href');
return Promise.resolve(tour);
})",
),
array( //14
'element' => '#group_name_en',
'path' => [Yii::app()->createUrl('/admin/questiongroups/sa/add', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Enter a title for your first question group'),
'content' => gT('The title will be visible to your participants and cannot be empty.').' '
.gT('Question groups are important to logically group your questions. In the default setting each question group (with included questions) is shown on its own page.'),
'redirect' => false,
),
array( //15
'element' => 'label[for=description_en]',
'path' => [Yii::app()->createUrl('/admin/questiongroups/sa/add', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'top',
'title' => gT('A description for your question group'),
'content' => gT('This description is also visible to your participants. You do not need to add a description to your question group, but sometimes it makes sense to add a little extra information for your participants.'),
'redirect' => false,
),
array( //16
'element' => '#randomization_group',
'path' => [Yii::app()->createUrl('/admin/questiongroups/sa/add', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'left',
'title' => gT('Advanced settings'),
'content' => gT("For now it's best to leave these additional settings as they are. If you want to know more about randomization and relevance settings, have a look at our manual."),
'redirect' => false,
),
array( //17
'element' => '#save-and-new-question-button',
'path' => [Yii::app()->createUrl('/admin/questiongroups/sa/add', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Save and add a new question'),
'content' => gT("Now when you are finished click on 'Save and add question'.").'<br/>'
.gT('This will directly add a question to the current question group.')
.'<p class="alert bg-warning">'.gT("Now click on 'Save and add question'.").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#save-and-new-question-button').trigger('click');
return Promise.resolve(tour);
})",
),
array( //18
'element' => '#title',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'top',
'title' => gT('The title of your question'),
'content' =>
gT("This code is normally not shown to your participants, still it is necessary and has to be unique for the survey.").'<br>'
.gT("This code is also the name of the variable that will be exported to SPSS or Excel.")
.'<p class="alert bg-warning">'.gT("Please type in a code that consists only of letters and numbers, and doesn't start with a number.").'</p>',
'redirect' => false,
),
array( //19
'element' => '#cke_question_en',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'top',
'title' => gT('The actual question text'),
'content' => gT('The content of this box is the actual question text shown to your participants.').' '
.gT('It may be empty, but that is not recommended. You may use all the power of our WYSIWYG editor to make your question shine.'),
'redirect' => false,
),
array( //20
'element' => '#cke_help_en',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'top',
'title' => gT('An additional help text for your question'),
'content' => gT('You can add some additional help text to your question. This may also be empty, then it will not be shown.'),
'redirect' => false,
),
array( //21
'element' => '#question_type_button',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'left',
'title' => gT('Set your question type.'),
'content' => gT("LimeSurvey offers you a lot of different question types.").'<br/>'
.gT("The example question created for you as well as the default setting is the 'Long free text'-type.").'<br/>'
.gT("This type will create a big text input for your participants.")
.'<p class="alert bg-warning">'.gT("Please select the 'Array'-type.").'</p>',
'redirect' => false,
),
array( //22
'element' => '#save-button',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'left',
'title' => gT('Now save the created question'),
'content' => gT('Next we will create subquestions and answer options.').'<br/>'
.gT('Please be sure the question has a valid code with only letters and numbers starting with a letter.'),
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#save-button').trigger('click');
return Promise.resolve(tour);
})",
),
array( //23
'element' => '#questionbarid',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('The question bar'),
'content' => gT('This is the question bar. The most important option here is the edit button.').' '
.gT('Also important are the preview buttons, which we will show in one of the next steps.'),
'redirect' => false,
),
array( //24
'element' => '#adminpanel__topbar--selectorAddSubquestions',
'placement' => 'bottom',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'title' => gT('Add some subquestions to your question'),
'content' => gT("The array question is a type that creates a matrix for the participant.").'<br/>'
.gT("To fully use it you have to add subquestions as well as answer options.").'<br/>'
.gT("Let's start with subquestions.")
.'<p class="alert bg-warning">'.gT("Click on the 'Edit subquestions' button.").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
document.location.href = $('#adminpanel__topbar--selectorAddSubquestions').attr('href');
return Promise.resolve(tour);
})",
),
array( //25
'element' => '#rowcontainer',
'path' => [Yii::app()->createUrl('admin/questions/sa/subquestions/surveyid/[0-9]{4,25}/gid/[0-9]{1,25}/qid/[0-9]{4,25}')],
'placement' => 'bottom',
'title' => gT('Edit subquestions'),
'content' => gT("Here you may add some subquestions for your question.").'<br/>'
.gT("Every row is one subquestion. It's best practice to use logical or numerical codes for the subquestions.").' '
.gT("Your participants cannot see the subquestion code, only the subquestion text itself.")
."<p class='bg-info alert'>".gT("Pro tip: The subquestion may even contain HTML code.").'</p>',
'redirect' => false,
),
array( //26
'element' => '#rowcontainer>tr:first-of-type .btnaddanswer',
'path' => [Yii::app()->createUrl('admin/questions/sa/subquestions/surveyid/[0-9]{4,25}/gid/[0-9]{1,25}/qid/[0-9]{4,25}')],
'placement' => 'left',
'title' => gT('Add subquestion row'),
'content' => gT('Click on the plus sign to add another subquestion to your question.')
."<p class='bg-warning alert'>".gT('Please add at least two subquestions')."</p>",
'redirect' => false,
),
array( //27
'element' => '#save-button',
'path' => [Yii::app()->createUrl('admin/questions/sa/subquestions/surveyid/[0-9]{4,25}/gid/[0-9]{1,25}/qid/[0-9]{4,25}')],
'placement' => 'left',
'title' => gT('Now save the subquestions'),
'content' => gT("You may save empty subquestions, but that would useless.")
."<p class='bg-warning alert'>".gT("Save now and let's edit the answer options.").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#save-button').trigger('click');
return Promise.resolve(tour);
})"
),
array( //28
'element' => '#adminpanel__topbar--selectorAddAnswerOptions',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Add some answer options to your question'),
'content' => gT("Now that we've got some subquestions, we have to add answer options as well.").'<br/>'
.gT("The answer options will be shown for each of your subquestions.")
.'<p class="alert bg-warning">'.gT("Click on the 'Edit answer options' button.").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
document.location.href = $('#adminpanel__topbar--selectorAddAnswerOptions').attr('href');
return Promise.resolve(tour);
})",
),
array( //29
'element' => '#rowcontainer',
'path' => [Yii::app()->createUrl('admin/questions/sa/answeroptions/surveyid/[0-9]{4,25}/gid/[0-9]{1,25}/qid/[0-9]{4,25}')],
'placement' => 'bottom',
'title' => gT('Edit answer options'),
'content' => gT("As you can see the editing of answer options and subquestions is really not much different.")
.'<p class="alert bg-warning">'.gT("Please add at least two answer options to proceed.").'</p>',
'redirect' => false,
),
array( //30
'element' => '#save-button',
'path' => [Yii::app()->createUrl('admin/questions/sa/answeroptions/surveyid/[0-9]{4,25}/gid/[0-9]{1,25}/qid/[0-9]{4,25}')],
'placement' => 'left',
'title' => gT('Now save the answer options'),
'content' => gT("Click on 'Save' or 'Next' to proceed."),
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#save-button').trigger('click');
return Promise.resolve(tour);
})"
),
array( //31
'element' => '.selector__topbar--previewSurvey',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Preview survey'),
'content' => gT("Now is the time to preview your first survey.").'<br/>'
.gT("Just click on this button and a new window will open, where you can test run your survey.").'<br/>'
.gT("Please be aware that your answers will not be saved, because the survey isn't active yet.")
.'<p class="alert bg-warning">'.gT("Click on 'Preview survey' and return to this window when you are done testing.").'</p>',
'redirect' => false,
),
array( //32
'element' => '#breadcrumb-container',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}', 'gid' => '[0-9]{1,25}', 'qid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Easy navigation with the "breadcrumbs"'),
'content' => gT('In the top bar of the admin interface you see the "breadcrumbs".').'<br/>'
.gT("These will always be an easy way to get back to any previous setting.")
.'<p class="alert bg-warning">'.gT("Click on the name of your survey to get back to the survey settings overview.").'</p>',
'reflex' => '#breadcrumb__survey--overview',
'redirect' => false,
'onNext' => "(function(tour){
document.location.href = $('#breadcrumb__survey--overview').attr('href');
return Promise.resolve(tour);
})",
),
array( //33
'element' => '#ls-activate-survey',
'path' => [Yii::app()->createUrl('/admin/survey/sa/view', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Finally, activate your survey'),
'content' => gT("Now activate this simple survey.").'<br/>'
.gT("You can create as many surveys as you like.")
.'<p class="alert bg-warning">'.gT("Click on 'Activate this survey'").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
document.location.href = $('#ls-activate-survey').attr('href');
return Promise.resolve(tour);
})",
),
array( //34
'element' => '#activateSurvey__basicSettings--proceed',
'path' => [Yii::app()->createUrl('/admin/survey/sa/activate', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => gT('Activation settings'),
'content' => gT('These settings cannot be changed once the survey is online.').'<br/>'
.gT("For this simple survey the default settings are ok, but read the disclaimer carefully when you activate your own surveys.").'<br/>'
.gT("For more information consult our manual, or our forums.")
.'<p class="alert bg-warning">'.gT('Now click on "Save & activate survey"').'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#activateSurvey__basicSettings--proceed').trigger('click');
return Promise.resolve(tour);
})",
),
array( //35
'element' => '#activateTokenTable__selector--no',
'path' => [Yii::app()->createUrl('/admin/survey/sa/activate', ['surveyid' => '[0-9]{4,25}'])],
'placement' => 'bottom',
'title' => ('Activate token table'),
'content' => gT("Here you can select to start your survey in closed access mode.")."<br/>"
.gT("For our simple survey it is better to start in open access mode.")."<br/>"
.gT("The closed access mode needs a participant list, which you may create by clicking on the menu entry 'Participants'.")."<br/>"
.gT("For more information please consult our manual or our forum.")
.'<p class="alert bg-warning">'.gT("Click on 'No, thanks'").'</p>',
'reflex' => true,
'redirect' => false,
'onNext' => "(function(tour){
$('#activateTokenTable__selector--no').trigger('click');
return Promise.resolve(tour);
})",
),
array( //36
'element' => '#adminpanel__surveysummary--mainLanguageLink',
'path' => [Yii::app()->createUrl('/').'(index.php)?'],
'placement' => 'top',
'title' => gT('Share this link'),
'content' => gT("Just share this link with some of your friends and of course, test it yourself.")
.'<p class="alert bg-success lstutorial__typography--white">'.gT("Thank you for taking the tour!").'</p>',
'redirect' => false
),
),
'debug' => true,
'orphan' => true,
'keyboard' => false,
'template' => "<div class='popover tour lstutorial__template--mainContainer'> <div class='arrow'></div> <h3 class='popover-title lstutorial__template--title'></h3> <div class='popover-content lstutorial__template--content'></div> <div class='popover-navigation lstutorial__template--navigation'> <div class='btn-group col-xs-8' role='group' aria-label='...'> <button class='btn btn-default col-xs-6' data-role='prev'>".gT('Previous')."</button> <button class='btn btn-primary col-xs-6' data-role='next'>".gT('Next')."</button> </div> <div class='col-xs-4'> <button class='btn btn-warning' data-role='end'>".gT('End tour')."</button> </div> </div></div>",
'onShown' => "(function(tour){ console.log($('#notif-container').children()); $('#notif-container').children().remove(); })"
)
);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return '{{tutorials}}';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('name, description, active, permission, permission_grade', 'required'),
array('active', 'numerical', 'integerOnly'=>true),
array('name, permission, permission_grade', 'length', 'max'=>128),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('tid, name, description, active, permission, permission_grade', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'tutorialEntries' => array(self::HAS_MANY, 'TutorialEntry', 'tid'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'tid' => 'Tid',
'name' => 'Name',
'description' => 'Description',
'active' => 'Active',
'permission' => 'Permission',
'permission_grade' => 'Permission Grade',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('tid', $this->tid);
$criteria->compare('name', $this->name, true);
$criteria->compare('description', $this->description, true);
$criteria->compare('active', $this->active);
$criteria->compare('permission', $this->permission, true);
$criteria->compare('permission_grade', $this->permission_grade, true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public function getPrebuilt($prebuiltName)
{
if (isset($this->preBuiltPackage[$prebuiltName])) {
return $this->preBuiltPackage[$prebuiltName];
}
return [];
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Tutorials the static model class
*/
public static function model($className = __CLASS__)
{
/** @var Tutorials $model */
$model = parent::model($className);
return $model;
}
}