HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/honger.komma.pro/app/KommaApp/Vacancies/Kms/VacancySection.php
<?php
/**
 *
 *
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma
 */

namespace App\KommaApp\Vacancies\Kms;

//The new object oriented attributes
use App\KommaApp\Categories\Kms\CategoryService;
use App\KommaApp\Kms\Core\Attributes\AutocompleteInput;
use App\KommaApp\Kms\Core\Attributes\DatePicker;
use App\KommaApp\Kms\Core\Attributes\Documents;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicChecklistSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicIntroBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\SelectOption;
use App\KommaApp\Kms\Core\Attributes\Select;
use App\KommaApp\Kms\Core\Sections\AllUsedLanguagesTabsDirector;
use App\KommaApp\Kms\Core\Sections\NoLanguageTabsDirector;
use App\KommaApp\Kms\Core\Sections\Section;
use App\KommaApp\Routes\RouteService;
use App\KommaApp\Sites\Kms\SiteService;
use App\KommaApp\Users\Kms\UserService;
use App\KommaApp\Users\Roles;
use App\KommaApp\Kms\Core\Attributes\Attribute;
use App\KommaApp\Kms\Core\Attributes\Dynamic;
use App\KommaApp\Kms\Core\Attributes\Images;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicContentBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicFullImageBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicFullTextBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicMultipleImagesBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicMultipleImageTabSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicTwoColumnBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\DynamicVideoBlockSettings;
use App\KommaApp\Kms\Core\Attributes\Models\ImageProperty;
use App\KommaApp\Kms\Core\Attributes\OnOff;
use App\KommaApp\Kms\Core\Attributes\Seperator;
use App\KommaApp\Kms\Core\Attributes\TextArea;
use App\KommaApp\Kms\Core\Attributes\TextField;

use App\KommaApp\Kms\Core\Attributes\Title;
use App\KommaApp\Kms\Core\Kms;
use App\KommaApp\Kms\Core\Sections\SectionTabGroups;
use App\KommaApp\Kms\Core\Sections\SectionTabItem;
use App\KommaApp\Kms\Core\Sections\SectionTabsBuilder;
use App\KommaApp\Kms\Core\ValidationSet;
use App\KommaApp\Vacancies\Models\Vacancy;
use Illuminate\Database\Eloquent\Collection;

class VacancySection extends Section
{
    protected $title = "Vacancies";
    protected $subTitle = "All vacancies";
    protected $slug = "vacancies";

    private $siteService;
    /**
     * @var CategoryService
     */
    private $categoryService;
    /**
     * @var UserService
     */
    private $userService;

    /**
     * PageSection constructor.
     * @param VacancyService $sectionService
     * @param RouteService $routeService
     * @param CategoryService $categoryService
     * @param SiteService $siteService
     */
//    function __construct(Kms $kms, PageRepository $repository)
    function __construct(
        VacancyService $sectionService,
        RouteService $routeService,
        CategoryService $categoryService,
        UserService $userService,
        SiteService $siteService)
    {
        $sectionTabDirector = new NoLanguageTabsDirector(new SectionTabsBuilder()); //Can make tabs for us. also see KmsSection::__construct

        $this->siteService = $siteService;

        parent::__construct($sectionService, $routeService, $sectionTabDirector);
        $this->categoryService = $categoryService;
        $this->userService = $userService;
    }

    /**
     * Generates the attributes for this section. They all must extend the App\KommaApp\Kms\Core\Attributes\Attribute class
     * This is the place where you need to setup your sections appearance. Just make sure you build an array of attributes
     * and put each attribute in a AbstractSectionTabItem with a SectionTabGroups constant to link them to a tab.
     *
     * @see PageRepository::saveModel()
     * @return Collection A collection of SectionTabItems
     */
    protected function generateAttributes(): Collection
    {

        //*****************************************************************************************\\
        //*** Generate the attributes                                                           ***\\
        //*****************************************************************************************\\
        $attributes = [];

        //Build the general attributes and put them in the attributes array

        $attributes[] = (new OnOff())
            ->setLabelText(__('kms/global.active'))
            ->mapValueFrom(Attribute::ValueFromModel, 'active');


        $optionModels = $this->getSectionService()->getOptionsForSelect();
        $attributes[] = (new Select())
            ->setItems($optionModels)
            ->setLabelText(__('kms/pages.parent_page'))
            ->setExcludeCurrentModelItem(true)
            ->setStyleClass('hidden')
            ->mapValueFrom(Attribute::ValueFromModel, 'parent_id');

//        $attributes[] = (new Documents())
//            ->setLabelText('Hoofd afbeelding')
//            ->setMaxDocuments(1)
//            ->setSubFolder('pages')
//            ->setImageProperties([
//                (new ImageProperty())->setName('thumb')->setCropMethod(ImageProperty::Fit)->setWidth(100),
//                (new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(360),
//                (new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(754),
//                (new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(1270),
//                (new ImageProperty())->setName('original')->setCropMethod(ImageProperty::Resize)->setWidth(2000),
//            ])
//            ->mapValueFrom(Attribute::ValueFromDocuments, 'pages');

        $attributes[] = (new Images())
            ->setImageSizes([
                (new ImageProperty())->setName('thumb')->setCropMethod(ImageProperty::Fit)->setWidth(100),
                (new ImageProperty())->setName('small')->setCropMethod(ImageProperty::Resize)->setWidth(360),
                (new ImageProperty())->setName('medium')->setCropMethod(ImageProperty::Resize)->setWidth(754),
                (new ImageProperty())->setName('large')->setCropMethod(ImageProperty::Resize)->setWidth(1270),
                (new ImageProperty())->setName('original')->setCropMethod(ImageProperty::Resize)->setWidth(2000),
            ])
            ->setLabelText("Afbeelding")
            ->setMaxImages(1)
            ->setSubFolder('vacancy')
            ->mapValueFrom(Attribute::ValueFromImages, 'images');

        $photoTemplateOptions= [];

        foreach (["Foto's algemeen/overhead", "Foto's designer","Foto's developer"] as $value => $content)
        {
            $photoTemplateOptions[] = (new SelectOption())
                ->setContent($content)
                ->setHtmlContent($content)
                ->setValue($value);
        }


        $attributes[] = (new Select())
            ->setItems($photoTemplateOptions)
            ->setLabelText("Fotografie")
            ->mapValueFrom(Attribute::ValueFromModel, 'photo_template');

        //Build an array with attributes for each current site language
        $languageIndexedAttributes = $this->createAttributesFromExistingAttributeForAllUsedLanguagesBySites($this->getLanguageFields());

        //****************************************************************************************************************************************\\
        //*** Put the all attributes in a SectionTabItem so we can track for which tab they are. And then put SectionTabItems in a Collection  ***\\
        //****************************************************************************************************************************************\\
        $tabItems = new Collection();
        foreach($attributes as $attribute) $tabItems->push(new SectionTabItem($attribute, SectionTabGroups::General));
        foreach($languageIndexedAttributes as $attribute) $tabItems->push(new SectionTabItem($attribute, SectionTabGroups::General));



        return $tabItems;
    }

    private function getLanguageFields () {

        $fields = [];

        $fields[] = (new TextField(__('kms/global.title')))
            ->setPlaceholderText(__('kms/global.enterTitle'))
            ->mapValueFrom(Attribute::ValueFromTranslationModel, 'name');

        $fields[] = (new TextArea())
                ->setLabelText(__('kms/global.metaDescription'))
                ->setPlaceholderText(__('kms/global.enterMetaDescription'))
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'meta_description');

        $fields[] = (new Seperator());

        $fields[] = (new Title('Intro'));

        $fields[] = (new TextField("Titel (over afbeelding)"))
                ->setPlaceholderText('Vul titel in (bv. Designer)')
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'image_title');

        $fields[] = (new TextArea())
                ->setLabelText('Omschrijving')
                ->setPlaceholderText('Vul omschrijving in')
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'intro_description');

        $fields[] = (new TextField("Ondertitel"))
                ->setPlaceholderText('Vul ondertitel in (bv. Full-Time - Budel)')
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'intro_appendix');

        $fields[] = (new Seperator());

//        $fields[] = (new Title('Komma biedt'));
//
//        for($i = 1; $i <= Vacancy::$amountOfBenefits; $i++)
//        {
//            $fields[] = (new TextField("Voordeel " . $i))
//                ->setPlaceholderText('Vul voordeel in')
//                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'benefit_' . $i);
//        }


        $fields[] = (new Title('Jij bent'));

        for($i = 1; $i <= Vacancy::$amountOfPersonalityMarks; $i++)
        {
            $fields[] = (new TextField($i . " - titel"))
                ->setPlaceholderText('Vul eigenschap in.')
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'personality_title_' . $i);

            $fields[] = (new TextArea())
                ->setLabelText($i . ' - Omschrijving')
                ->setPlaceholderText('Vul omschrijving in')
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'personality_description_' . $i);
        }

        $fields[] = (new Seperator());

        $fields[] = (new Title('Skills'));

        for($i = 1; $i <= Vacancy::$amountOfSkills; $i++)
        {
            $fields[] = (new TextField("Skill " . $i))
                ->setPlaceholderText('Vul skill in')
                ->mapValueFrom(Attribute::ValueFromTranslationModel, 'skill_' . $i);
        }

        $fields[] = (new Dynamic())
            ->setLabelText(__('kms/dynamic.blocks'))
            ->setSubFolder('dynamic')
            ->setBlockSettings([
                (new DynamicFullTextBlockSettings()),
                (new DynamicChecklistSettings()),

            ])
            ->mapValueFrom(Attribute::ValueFromTranslationModel, 'description');


        return $fields;
    }


    /**
     * This method will stop the load entities of the kmsSiteSection
     *
     * @return array
     *
     */
    public function loadEntities(){
        return [];
    }
}