mambax7/extgallery

View on GitHub
admin/photo.php

Summary

Maintainability
D
1 day
Test Coverage

File photo.php has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use Xmf\Request;

/**
Severity: Minor
Found in admin/photo.php - About 7 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        case 'add_photo':
    
            /** @var Extgallery\PublicPhotoHandler $photoHandler */
            $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
            $result       = $photoHandler->postPhotoTraitement('photo_file', false);
    Severity: Major
    Found in admin/photo.php and 1 other location - About 4 hrs to fix
    public-upload.php on lines 41..57

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 171.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

                    if (0 == $cat->getVar('cat_nb_photo')) {
                        $criteria = new \CriteriaCompo();
                        $criteria->add(new \Criteria('nleft', $cat->getVar('nleft'), '<'));
                        $criteria->add(new \Criteria('nright', $cat->getVar('nright'), '>'));
                        $catHandler->updateFieldValue('cat_nb_album', 'cat_nb_album + 1', $criteria);
    Severity: Major
    Found in admin/photo.php and 3 other locations - About 50 mins to fix
    admin/photo.php on lines 242..247
    public-modify.php on lines 86..91
    public-modify.php on lines 93..98

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

                    if (0 == $cat->getVar('cat_nb_photo')) {
                        $criteria = new \CriteriaCompo();
                        $criteria->add(new \Criteria('nleft', $cat->getVar('nleft'), '<'));
                        $criteria->add(new \Criteria('nright', $cat->getVar('nright'), '>'));
                        $catHandler->updateFieldValue('cat_nb_album', 'cat_nb_album + 1', $criteria);
    Severity: Major
    Found in admin/photo.php and 3 other locations - About 50 mins to fix
    admin/photo.php on lines 183..188
    public-modify.php on lines 86..91
    public-modify.php on lines 93..98

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    The CASE body must start on the line following the statement
    Open

                case 'default':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The DEFAULT body must start on the line following the statement
    Open

                default:
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The CASE body must start on the line following the statement
    Open

        case 'rebuildthumb':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The CASE body must start on the line following the statement
    Open

        case 'add_photo':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The CASE body must start on the line following the statement
    Open

        case 'batchApprove':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The CASE body must start on the line following the statement
    Open

        case 'batchAdd':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The CASE body must start on the line following the statement
    Open

        case 'modify':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    The CASE body must start on the line following the statement
    Open

        case 'default':
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 148 characters
    Open

                        $scriptSelect   .= $first ? '\'catId[' . $photo->getVar('photo_id') . ']\'' : ', \'catId[' . $photo->getVar('photo_id') . ']\'';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 174 characters
    Open

                    echo '<input type="submit" name="modify" value="' . _AM_EXTGALLERY_APPLY_CHANGE . '">&nbsp;&nbsp;<input type="submit" name="delete" value="' . _DELETE . '">';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 168 characters
    Open

            echo '<b>' . _AM_EXTGALLERY_BATCH_PATH . '</b> : ' . XOOPS_ROOT_PATH . '/modules/extgallery/batch/<br><br>' . sprintf(_AM_EXTGALLERY_ADD_BATCH_INFO, $nbPhotos);
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 173 characters
    Open

                echo '<a href="photo.php?op=modify&id=' . $photo->getVar('photo_id') . '"><img src="../assets/images/edit.png" style="vertical-align:middle;"></a>&nbsp;' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 145 characters
    Open

                    $globalCatSelect = $catHandler->getLeafSelect('changeAllCat', false, $_GET['cat_id'], ' onChange="return changeAllCategory();"');
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 225 characters
    Open

                        echo '<textarea name="photoDesc[' . $photo->getVar('photo_id') . ']" id="photoDesc[' . $photo->getVar('photo_id') . ']" rows="1" cols="57">' . $photo->getVar('photo_desc', 'e') . '</textarea></td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 132 characters
    Open

            echo '<img src="../assets/images/edit.png" style="vertical-align:middle;">&nbsp;&nbsp;' . _AM_EXTGALLERY_EDIT_INFO . '<br>';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 171 characters
    Open

                        echo '<td><input type="checkbox" name="photoId[' . $photo->getVar('photo_id') . '][]" id="photoId[' . $photo->getVar('photo_id') . '][]"></td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 157 characters
    Open

                    $pageNav         = new \XoopsPageNav($nbPhoto, $helper->getConfig('admin_nb_photo'), $start, 'start', 'op=modify&cat_id=' . $_GET['cat_id']);
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 139 characters
    Open

                    echo '<th><input type="checkbox" name="selectAllPhoto" id="selectAllPhoto" onClick="return checkAllPhoto();"></th>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 154 characters
    Open

                        echo '<td><img src="' . XOOPS_URL . '/uploads/extgallery/public-photo/thumb/thumb_' . $photo->getVar('photo_name') . '"></td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 123 characters
    Open

            echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTGALLERY_EDITDELETE_PHOTO . '</legend>';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 127 characters
    Open

            echo '<img src="../assets/images/delete.png" style="vertical-align:middle;">&nbsp;&nbsp;' . _AM_EXTGALLERY_DELETE_INFO;
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 174 characters
    Open

                //echo '<a href="photo.php?op=approve&id='.$photo->getVar('photo_id').'"><img src="../assets/images/on.png" style="vertical-align:middle;"></a>&nbsp;&nbsp;'."\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 139 characters
    Open

            $form->addElement(new \XoopsFormLabel(_AM_EXTGALLERY_ALBUMS, $catHandler->getLeafSelect('cat_id', false, 0, '', 'public_upload')));
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 131 characters
    Open

            echo '<th><input type="checkbox" name="selectAllPhoto" id="selectAllPhoto" onClick="return checkAllPhoto();"></th>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 128 characters
    Open

                redirect_header('photo.php', 3, _AM_EXTGALLERY_UPLOAD_ERROR . ' :<br>' . $photoHandler->photoUploader->getErrors());
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 169 characters
    Open

                echo '<a href="photo.php?op=delete&id=' . $photo->getVar('photo_id') . '"><img src="../assets/images/delete.png" style="vertical-align:middle;"></a>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 129 characters
    Open

                    echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTGALLERY_APPROVE . '</legend>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 126 characters
    Open

            $form->addElement(new \XoopsFormFile(_AM_EXTGALLERY_PHOTO, 'photo_file', $helper->getConfig('max_photosize')), false);
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 147 characters
    Open

                        echo '<td>' . $catHandler->getLeafSelect('catId[' . $photo->getVar('photo_id') . ']', false, $_GET['cat_id']) . '</td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 240 characters
    Open

                        echo '<td><input type="text" name="photoPoids[' . $photo->getVar('photo_id') . ']" id="photoPoids[' . $photo->getVar('photo_id') . ']" value="' . $photo->getVar('photo_weight') . '" size="3" maxlength="14"></td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 271 characters
    Open

                        echo '<td  style="text-align:left;"><input type="text" name="photoTitre[' . $photo->getVar('photo_id') . ']" id="photoTitre[' . $photo->getVar('photo_id') . ']" value="' . $photo->getVar('photo_title', 'e') . '" size="60" maxlength="150"><br>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 136 characters
    Open

                $script .= $first ? '\'photoId[' . $photo->getVar('photo_id') . ']\'' : ', \'photoId[' . $photo->getVar('photo_id') . ']\'';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 133 characters
    Open

                    echo '<fieldset><legend style="font-weight:bold; color:#0A3760;">' . _AM_EXTGALLERY_INFORMATION . '</legend>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 156 characters
    Open

                        $scriptCheckbox .= $first ? '\'photoId[' . $photo->getVar('photo_id') . '][]\'' : ', \'photoId[' . $photo->getVar('photo_id') . '][]\'';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 129 characters
    Open

                    $extraTags['X_ITEM_URL'] = XOOPS_URL . "/modules/{$moduleDirName}/public-album.php?id=" . $cat->getVar('cat_id');
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 131 characters
    Open

            //echo '<img src="../assets/images/on.png" style="vertical-align:middle;">&nbsp;&nbsp;'._AM_EXTGALLERY_APPROVE_INFO.'<br>';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 146 characters
    Open

                echo '<td><img src="' . XOOPS_URL . '/uploads/extgallery/public-photo/thumb/thumb_' . $photo->getVar('photo_name') . '"></td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 126 characters
    Open

            $editor = $utility::getWysiwygForm(_AM_EXTGALLERY_DESC, 'photo_desc', '', 15, 60, '100%', '350px', 'hometext_hidden');
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 159 characters
    Open

                echo '<td><input type="checkbox" name="photoId[' . $photo->getVar('photo_id') . ']" id="photoId[' . $photo->getVar('photo_id') . ']"></td>' . "\n";
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    Line exceeds 120 characters; contains 162 characters
    Open

            echo '<input type="submit" name="approve" value="' . _AM_EXTGALLERY_APPROVE . '">&nbsp;&nbsp;<input type="submit" name="delete" value="' . _DELETE . '">';
    Severity: Minor
    Found in admin/photo.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status