Example #1
0
    public function index()
    {
        if (App::getConfig('devmode') == 0) {
            App::redirect(__ADMINPANE__ . '/mainside');
        }
        if ((int) $this->getParam() == 0) {
            $form = new FormEngine\Elements\Form(array('name' => 'exchange', 'action' => '', 'method' => 'post'));
            $requiredData = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'type_pane', 'label' => _('TXT_EXCHANGE_TYPE_MIGRATION_SETTINGS'))));
            $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Podaj adres URL wtyczki integracyjnej.</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
            $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'apiurl', 'label' => _('TXT_MIGRATION_API_URL'))));
            $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Podaj klucz jaki został ustawiony w pliku integracyjnym ($key)</p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
            $requiredData->AddChild(new FormEngine\Elements\TextField(array('name' => 'apikey', 'label' => _('TXT_MIGRATION_API_KEY'))));
            $requiredData->AddChild(new FormEngine\Elements\Tip(array('tip' => '<p>Wybierz rodzaj importowanych danych.Sugerujemy import w następującej kolejności:
							<ul>
							<li>Zdjęcia</li>
							<li>Producenci</li>
							<li>Kategorie</li>
							<li>Wartości cech</li>
							<li>Produkty</li>
							</ul></p>', 'direction' => FormEngine\Elements\Tip::DOWN)));
            $requiredData->AddChild(new FormEngine\Elements\Select(array('name' => 'entity', 'label' => _('TXT_EXCHANGE_ENTITY'), 'options' => array(new FormEngine\Option(1, _('TXT_PRODUCTS')), new FormEngine\Option(2, _('TXT_CATEGORIES')), new FormEngine\Option(3, _('TXT_PRODUCERS')), new FormEngine\Option(4, _('TXT_PHOTOS')), new FormEngine\Option(5, _('TXT_ATTRIBUTES')), new FormEngine\Option(6, _('TXT_ORDERS')), new FormEngine\Option(7, _('TXT_SIMILARPRODUCT'))), 'default' => 1)));
            $form->AddFilter(new FormEngine\Filters\Trim());
            $form->AddFilter(new FormEngine\Filters\Secure());
            if ($form->Validate(FormEngine\FE::SubmittedData())) {
                $Data = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT);
                Session::setActiveMigrationData(json_encode($Data));
                App::redirect(__ADMINPANE__ . '/migration/index/' . $Data['entity']);
            }
            $this->registry->template->assign('form', $form->Render());
            $this->registry->xajax->processRequest();
            $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript());
            $this->registry->template->display($this->loadTemplate('index.tpl'));
        } else {
            if (Session::getActiveMigrationData() == NULL) {
                App::redirect(__ADMINPANE__ . '/migration/');
            }
            $form = new FormEngine\Elements\Form(array('name' => 'add_migration', 'action' => '', 'method' => 'post'));
            $progress = $form->AddChild(new FormEngine\Elements\Fieldset(array('name' => 'progres_data', 'label' => 'Aktualizacja')));
            $progress->AddChild(new FormEngine\Elements\ProgressIndicator(array('name' => 'progress', 'label' => 'Postęp migracji', 'chunks' => 1, 'load' => array(App::getModel('migration'), 'doLoadQueque'), 'process' => array(App::getModel('migration'), 'doProcessQueque'), 'success' => array(App::getModel('migration'), 'doSuccessQueque'), 'preventSubmit' => true)));
            $form->AddFilter(new FormEngine\Filters\Trim());
            $form->AddFilter(new FormEngine\Filters\Secure());
            $this->registry->template->assign('form', $form->Render());
            $this->registry->xajax->processRequest();
            $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript());
            $this->registry->template->display($this->loadTemplate('index.tpl'));
        }
    }