<commit_before><?php
/**
 * Part of CoolMS Content Management System
 *
 * @copyright (c) 2011 <NAME> (http://www.slamecka.cz)
 * 
 * License within file license.txt in the root folder.
 * 
 */

namespace MenuModule;

use \Application\Entity\Menuitem,
    \Nette\ComponentModel\IContainer,
    \Nette\Http\SessionSection;

class MenuitemForm extends \Application\Form
{

    /** @var \Nette\ComponentModel\IContainer */
    private $parent;

    /** @var \Nette\Http\SessionSection */
    private $session;

    /** @var \Application\ModuleManager */
    private $moduleManager;

    /** @var \Application\Repository\Menuitem */
    private $menuitems;

    /**/
    private $editingMode;
    private $menuitemType;

    /**
     * @param \Nette\ComponentModel\IContainer
     * @param string
     */
    public function __construct(IContainer $parent, SessionSection $session, \Application\ModuleManager $moduleManager, \Application\Repository\Menuitem $menuitemRepository)
    {
        $this->parent = $parent;
        $this->session = $session;
        $this->moduleManager = $moduleManager;
        $this->menuitems = $menuitemRepository;

        $this->editingMode = false;
        $this->menuitemType = Menuitem::TYPE_MODULE;


        /* Set default values to module preferences */
        if (empty($this->chosenModule)) {
            $m = $moduleManager->getLinkableModules();
            reset($m);
            $this->chosenModule = key($m);
        }

        if (empty($this->chosenModuleView)) {
            $views = $moduleManager->getModuleViews($this->chosenModule);
            $views = array_keys($views);
            $this->chosenModuleView = array_shift($views);
        }

        parent::__construct($parent, 'menuitemForm'); // calls setup
    }

    /* --------------------------- GENERAL METHODS -------------------------- */

    /**
     * Turns the form into editing mode
     * @param int $id Item id 
     */
    public function toggleEditing($id)
    {
        $this->editingMode = true;

        /* Form texts */
        $labels = array(
            'type' => 'Link is a',
            'module_name' => 'It\'s linking to the module',
            'module_view' => 'and it\'s view',
            'module_view_param' => 'with parameter',<commit_msg>ModuleManager: Fix.<commit_after><?php
/**
 * Part of CoolMS Content Management System
 *
 * @copyright (c) 2011 <NAME> (http://www.slamecka.cz)
 * 
 * License within file license.txt in the root folder.
 * 
 */

namespace MenuModule;

use \Application\Entity\Menuitem,
    \Nette\ComponentModel\IContainer,
    \Nette\Http\SessionSection;

class MenuitemForm extends \Application\Form
{

    /** @var \Nette\ComponentModel\IContainer */
    private $parent;

    /** @var \Nette\Http\SessionSection */
    private $session;

    /** @var \Application\ModuleManager */
    private $moduleManager;

    /** @var \Application\Repository\Menuitem */
    private $menuitems;

    /**/
    private $editingMode;
    private $menuitemType;

    /**
     * @param \Nette\ComponentModel\IContainer
     * @param string
     */
    public function __construct(IContainer $parent, SessionSection $session, \Application\ModuleManager $moduleManager, \Application\Repository\Menuitem $menuitemRepository)
    {
        $this->parent = $parent;
        $this->session = $session;
        $this->moduleManager = $moduleManager;
        $this->menuitems = $menuitemRepository;

        $this->editingMode = false;
        $this->menuitemType = Menuitem::TYPE_MODULE;

        /* Set default values to module preferences */
        if (empty($this->chosenModule)) {
            $m = $moduleManager->getLinkableModules();
            reset($m);
            $this->session->chosenModule = key($m); // DON'T use setter!!
        }

        if (empty($this->chosenModuleView)) {
            $views = $moduleManager->getModuleViews($this->chosenModule);
            $views = array_keys($views);
            $this->session->chosenModuleView = array_shift($views); // DON'T use setter!!
        }

        parent::__construct($parent, 'menuitemForm'); // calls setup       
    }

    /* --------------------------- GENERAL METHODS -------------------------- */

    /**
     * Turns the form into editing mode
     * @param int $id Item id 
     */
    public function toggleEditing($id)
    {
        $this->editingMode = true;

        /* Form texts */
        $labels = array(
            'type' => 'Link is a',
            'module_name' => 'It\'s linking to the module',
            'module_view' => 'and it\'s view',
            'module_view_param' => 'with parameter',
{'fraction_non_alphanumeric': 0.15593952483801296, 'fraction_numerical': 0.0017278617710583153, 'mean_word_length': 2.218207088255733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '368616', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1318, 'n_words': 286}