Code Duplication    Length = 40-41 lines in 2 locations

src/Intraface/XMLRPC/Shop/Server0004.php 1 location

@@ 531-571 (lines=41) @@
528
     *
529
     * @return array with pictures for categories
530
     */
531
    public function getProductCategoryPicture($credentials, $shop_id, $category_id)
532
    {
533
        if (is_object($return = $this->checkCredentials($credentials))) {
534
            return $return;
535
        }
536
537
        $this->_factoryWebshop($shop_id);
538
539
        $module = $this->kernel->useModule('filemanager');
540
        require_once 'Intraface/modules/filemanager/AppendFile.php';
541
542
        $pictures = array();
543
544
            $append_file = new AppendFile($this->kernel, 'category', $category_id);
545
            $appendix_list = $append_file->getList();
546
        foreach ($appendix_list as $key => $appendix) {
547
            $tmp_filehandler = new FileHandler($this->kernel, $appendix['file_handler_id']);
548
            $pictures[$key]['id']                   = $appendix['file_handler_id'];
549
            $pictures[$key]['original']['icon_uri'] = $tmp_filehandler->get('icon_uri');
550
            $pictures[$key]['original']['name']     = $tmp_filehandler->get('file_name');
551
            $pictures[$key]['original']['width']    = $tmp_filehandler->get('width');
552
            $pictures[$key]['original']['height']   = $tmp_filehandler->get('height');
553
            $pictures[$key]['original']['file_uri'] = $tmp_filehandler->get('file_uri');
554
            $pictures[$key]['appended_file_id']     = $appendix['id'];
555
556
            if ($tmp_filehandler->get('is_image')) {
557
                $tmp_filehandler->createInstance();
558
                $instances = $tmp_filehandler->instance->getList('include_hidden');
559
                foreach ($instances as $instance) {
560
                    $pictures[$key][$instance['name']]['file_uri'] = $instance['file_uri'];
561
                    $pictures[$key][$instance['name']]['name']     = $instance['name'];
562
                    $pictures[$key][$instance['name']]['width']    = $instance['width'];
563
                    $pictures[$key][$instance['name']]['height']   = $instance['height'];
564
                }
565
            }
566
            $tmp_filehandler->__destruct();
567
            unset($tmp_filehandler);
568
        }
569
570
        return $this->prepareResponseData($pictures);
571
    }
572
573
    /**
574
     * Add product to basket

src/Intraface/XMLRPC/Shop/Server0100.php 1 location

@@ 696-735 (lines=40) @@
693
     *
694
     * @return array with pictures for categories
695
     */
696
    public function getProductCategoryPicture($credentials, $shop_id, $category_id)
697
    {
698
        if (is_object($return = $this->checkCredentials($credentials))) {
699
            return $return;
700
        }
701
702
        $this->_factoryWebshop($shop_id);
703
        $module = $this->kernel->useModule('filemanager');
704
        require_once 'Intraface/shared/filehandler/AppendFile.php';
705
706
        $pictures = array();
707
708
            $append_file = new AppendFile($this->kernel, 'category', $category_id);
709
            $appendix_list = $append_file->getList();
710
        foreach ($appendix_list as $key => $appendix) {
711
            $tmp_filehandler = new FileHandler($this->kernel, $appendix['file_handler_id']);
712
            $pictures[$key]['id']                   = $appendix['file_handler_id'];
713
            $pictures[$key]['original']['icon_uri'] = $tmp_filehandler->get('icon_uri');
714
            $pictures[$key]['original']['name']     = $tmp_filehandler->get('file_name');
715
            $pictures[$key]['original']['width']    = $tmp_filehandler->get('width');
716
            $pictures[$key]['original']['height']   = $tmp_filehandler->get('height');
717
            $pictures[$key]['original']['file_uri'] = $tmp_filehandler->get('file_uri');
718
            $pictures[$key]['appended_file_id']     = $appendix['id'];
719
720
            if ($tmp_filehandler->get('is_image')) {
721
                $tmp_filehandler->createInstance();
722
                $instances = $tmp_filehandler->instance->getList('include_hidden');
723
                foreach ($instances as $instance) {
724
                    $pictures[$key][$instance['name']]['file_uri'] = $instance['file_uri'];
725
                    $pictures[$key][$instance['name']]['name']     = $instance['name'];
726
                    $pictures[$key][$instance['name']]['width']    = $instance['width'];
727
                    $pictures[$key][$instance['name']]['height']   = $instance['height'];
728
                }
729
            }
730
            //$tmp_filehandler->__destruct();
731
            unset($tmp_filehandler);
732
        }
733
734
        return $this->prepareResponseData($pictures);
735
    }
736
737
    /**
738
     * Add product to basket