| Conditions | 2 |
| Paths | 2 |
| Total Lines | 75 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 61 | public function __construct($target) |
||
| 62 | { |
||
| 63 | $this->helper = $target->helper; |
||
| 64 | $this->targetObject = $target; |
||
| 65 | |||
| 66 | $title = $this->targetObject->isNew() ? \sprintf(\AM_YOGURT_VIDEO_ADD) : \sprintf(\AM_YOGURT_VIDEO_EDIT); |
||
| 67 | parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
||
| 68 | $this->setExtra('enctype="multipart/form-data"'); |
||
| 69 | |||
| 70 | //include ID field, it's needed so the module knows if it is a new form or an edited form |
||
| 71 | |||
| 72 | $hidden = new XoopsFormHidden( |
||
| 73 | 'video_id', $this->targetObject->getVar( |
||
| 74 | 'video_id' |
||
| 75 | ) |
||
| 76 | ); |
||
| 77 | $this->addElement($hidden); |
||
| 78 | unset($hidden); |
||
| 79 | |||
| 80 | // Video_id |
||
| 81 | $this->addElement( |
||
| 82 | new XoopsFormLabel(\AM_YOGURT_VIDEO_VIDEO_ID, $this->targetObject->getVar('video_id'), 'video_id') |
||
| 83 | ); |
||
| 84 | // Uid_owner |
||
| 85 | $this->addElement( |
||
| 86 | new XoopsFormSelectUser( |
||
| 87 | \AM_YOGURT_VIDEO_UID_OWNER, 'uid_owner', false, $this->targetObject->getVar( |
||
| 88 | 'uid_owner' |
||
| 89 | ), 1, false |
||
| 90 | ), |
||
| 91 | false |
||
| 92 | ); |
||
| 93 | // Video_desc |
||
| 94 | $this->addElement( |
||
| 95 | new XoopsFormTextArea( |
||
| 96 | \AM_YOGURT_VIDEO_VIDEO_DESC, 'video_desc', $this->targetObject->getVar( |
||
| 97 | 'video_desc' |
||
| 98 | ), 4, 47 |
||
| 99 | ), |
||
| 100 | false |
||
| 101 | ); |
||
| 102 | // Youtube_code |
||
| 103 | $this->addElement( |
||
| 104 | new XoopsFormText( |
||
| 105 | \AM_YOGURT_VIDEO_YOUTUBE_CODE, 'youtube_code', 50, 255, $this->targetObject->getVar( |
||
| 106 | 'youtube_code' |
||
| 107 | ) |
||
| 108 | ), |
||
| 109 | false |
||
| 110 | ); |
||
| 111 | // Main_video |
||
| 112 | $this->addElement( |
||
| 113 | new XoopsFormText( |
||
| 114 | \AM_YOGURT_VIDEO_MAIN_VIDEO, 'main_video', 50, 255, $this->targetObject->getVar( |
||
| 115 | 'main_video' |
||
| 116 | ) |
||
| 117 | ), |
||
| 118 | false |
||
| 119 | ); |
||
| 120 | |||
| 121 | // Data_creation |
||
| 122 | $this->addElement( |
||
| 123 | new \XoopsFormTextDateSelect( |
||
| 124 | \AM_YOGURT_VIDEO_DATE_CREATED, 'date_created', 0, formatTimestamp($this->targetObject->getVar('date_created'), 's') |
||
|
|
|||
| 125 | ) |
||
| 126 | ); |
||
| 127 | |||
| 128 | $this->addElement( |
||
| 129 | new \XoopsFormTextDateSelect( |
||
| 130 | \AM_YOGURT_VIDEO_DATE_UPDATED, 'date_updated', 0, formatTimestamp($this->targetObject->getVar('date_updated'), 's') |
||
| 131 | ) |
||
| 132 | ); |
||
| 133 | |||
| 134 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 135 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 136 | } |
||
| 138 |