Jump to content

Il controller AdminHome manca o non è valido.


Recommended Posts

Buonasera,

ho un problema su una installazione prestashop 1.7.5.0 installazione pulita + template acquistato su themeforest.

Quando vado su design -> link widget mi appare l'errore "Il controller AdminHome manca o non è valido."

come posso risolvere il problema? allego shot.

grazie molte

Luca

Schermata 2019-02-07 alle 17.01.25.png

Link to comment
Share on other sites

2 ore fa, lucav87 dice:

Buonasera,

ho un problema su una installazione prestashop 1.7.5.0 installazione pulita + template acquistato su themeforest.

Quando vado su design -> link widget mi appare l'errore "Il controller AdminHome manca o non è valido."

come posso risolvere il problema? allego shot.

grazie molte

Luca

Schermata 2019-02-07 alle 17.01.25.png

Ciao, se è una nuova installazione probabile si sia perso qualche file o configurazione in fase di installazione. Se è tutto nuovo prova a reinstallare PS oppure è successo dopo l'installazione del nuovo tema?

Edited by luca1711 (see edit history)
Link to comment
Share on other sites

grazie mille per l'aiuto.

il file c'è.. ti incollo il codice:

 

<?php

class AdminLinkWidgetController extends ModuleAdminController
{
    public $className = 'LinkBlock';
    private $name;
    private $repository;

    public function __construct()
    {
        $this->bootstrap = true;
        $this->display = 'view';

        parent::__construct();
        $this->meta_title = $this->trans('Link Widget', array(), 'Modules.Linklist.Admin');

        if (!$this->module->active) {
            Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));
        }

        $this->name = 'LinkWidget';

        $this->repository = new LinkBlockRepository(
            Db::getInstance(),
            $this->context->shop,
            $this->context->getTranslator()
        );
    }

    public function init()
    {
        if (Tools::isSubmit('edit'.$this->className)) {
            $this->display = 'edit';
        } elseif (Tools::isSubmit('addLinkBlock')) {
            $this->display = 'add';
        }

        parent::init();
    }

    public function postProcess()
    {
        if (Tools::isSubmit('action')) {
            switch (Tools::getValue('action')) {
                case 'updatePositions':
                    $this->updatePositions();
                    break;
            }
        } elseif (Tools::isSubmit('submit'.$this->className)) {
            if (!$this->manageLinkList()) {
                return false;
            }

            $hook_name = Hook::getNameById(Tools::getValue('id_hook'));
            if (!Hook::isModuleRegisteredOnHook($this->module, $hook_name, $this->context->shop->id)) {
                Hook::registerHook($this->module, $hook_name);
            }

            $this->module->_clearCache($this->module->templateFile);

            Tools::redirectAdmin($this->context->link->getAdminLink('Admin'.$this->name));
        } elseif (Tools::isSubmit('delete'.$this->className)) {
            if (!$this->deleteLinkList()) {
                return false;
            }

            $this->module->_clearCache($this->module->templateFile);

            Tools::redirectAdmin($this->context->link->getAdminLink('Admin'.$this->name));
        }

        return parent::postProcess();
    }

    public function renderView()
    {
        $title = $this->trans('Link block configuration', array(), 'Modules.Linklist.Admin');

        $this->fields_form[]['form'] = array(
            'legend' => array(
                'title' => $title,
                'icon' => 'icon-list-alt'
            ),
            'input' => array(
                array(
                    'type' => 'link_blocks',
                    'label' => $this->trans('Link Blocks', array(), 'Modules.Linklist.Admin'),
                    'name' => 'link_blocks',
                    'values' => $this->repository->getCMSBlocksSortedByHook(),
                ),
            ),
            'buttons' => array(
                'newBlock' => array(
                    'title' => $this->trans('New block', array(), 'Modules.Linklist.Admin'),
                    'href' => $this->context->link->getAdminLink('Admin'.$this->name).'&amp;addLinkBlock',
                    'class' => 'pull-right',
                    'icon' => 'process-icon-new'
                ),
            ),
        );

        $this->getLanguages();


        $helper = $this->buildHelper();
        $helper->submit_action = '';
        $helper->title = $title;

        $helper->fields_value = $this->fields_value;

        return $helper->generateForm($this->fields_form);
    }

    public function renderForm()
    {
        $block = new LinkBlock((int)Tools::getValue('id_link_block'));

        $this->fields_form[0]['form'] = array(
            'tinymce' => true,
            'legend' => array(
                'title' => isset($block) ? $this->trans('Edit the link block.', array(), 'Modules.Linklist.Admin') : $this->trans('New link block', array(), 'Modules.Linklist.Admin'),
                'icon' => isset($block) ? 'icon-edit' : 'icon-plus-square'
            ),
            'input' => array(
                array(
                    'type' => 'hidden',
                    'name' => 'id_link_block',
                ),
                array(
                    'type' => 'text',
                    'label' => $this->trans('Name of the link block', array(), 'Modules.Linklist.Admin'),
                    'name' => 'name',
                    'lang' => true,
                    'required' => true,
                ),
                array(
                    'type' => 'select',
                    'label' => $this->trans('Hook', array(), 'Admin.Global'),
                    'name' => 'id_hook',
                    'class' => 'input-lg',
                    'options' => array(
                        'query' => $this->repository->getDisplayHooksForHelper(),
                        'id' => 'id',
                        'name' => 'name'
                    )
                ),
                array(
                    'type' => 'cms_pages',
                    'label' => $this->trans('Content pages', array(), 'Modules.Linklist.Admin'),
                    'name' => 'cms[]',
                    'values' => $this->repository->getCmsPages(),
                    'desc' => $this->trans('Please mark every page that you want to display in this block.', array(), 'Modules.Linklist.Admin')
                ),
                array(
                    'type' => 'product_pages',
                    'label' => $this->trans('Product pages', array(), 'Modules.Linklist.Admin'),
                    'name' => 'product[]',
                    'values' => $this->repository->getProductPages(),
                    'desc' => $this->trans('Please mark every page that you want to display in this block.', array(), 'Modules.Linklist.Admin')
                ),
                array(
                    'type' => 'static_pages',
                    'label' => $this->trans('Static content', array(), 'Modules.Linklist.Admin'),
                    'name' => 'static[]',
                    'values' => $this->repository->getStaticPages(),
                    'desc' => $this->trans('Please mark every page that you want to display in this block.', array(), 'Modules.Linklist.Admin')
                ),
                array(
                    'type' => 'custom_pages',
                    'label' => $this->trans('Custom content', array(), 'Modules.Linklist.Admin'),
                    'name' => 'custom[]',
                    'values' => $this->repository->getCustomPages($block),
                    'desc' => $this->trans('Please add every page that you want to display in this block.', array(), 'Modules.Linklist.Admin')
                ),
            ),
            'buttons' => array(
                'cancelBlock' => array(
                    'title' => $this->trans('Cancel', array(), 'Admin.Actions'),
                    'href' => (Tools::safeOutput(Tools::getValue('back', false)))
                                ?: $this->context->link->getAdminLink('Admin'.$this->name),
                    'icon' => 'process-icon-cancel'
                )
            ),
            'submit' => array(
                'name' => 'submit'.$this->className,
                'title' => $this->trans('Save', array(), 'Admin.Actions'),
            )
        );

        if ($id_hook = Tools::getValue('id_hook')) {
            $block->id_hook = (int)$id_hook;
        }

        if (Tools::getValue('name')) {
            $block->name = Tools::getValue('name');
        }

        $helper = $this->buildHelper();
        if (isset($id_link_block)) {
            $helper->currentIndex = AdminController::$currentIndex.'&id_link_block='.$id_link_block;
            $helper->submit_action = 'edit'.$this->className;
        } else {
            $helper->submit_action = 'addLinkBlock';
        }

        $helper->fields_value = (array)$block;

        return $helper->generateForm($this->fields_form);
    }

    protected function buildHelper()
    {
        $helper = new HelperForm();

        $helper->module = $this->module;
        $helper->override_folder = 'linkwidget/';
        $helper->identifier = $this->className;
        $helper->token = Tools::getAdminTokenLite('Admin'.$this->name);
        $helper->languages = $this->_languages;
        $helper->currentIndex = $this->context->link->getAdminLink('Admin'.$this->name);
        $helper->default_form_language = $this->default_form_language;
        $helper->allow_employee_form_lang = $this->allow_employee_form_lang;
        $helper->toolbar_scroll = true;
        $helper->toolbar_btn = $this->initToolbar();

        return $helper;
    }

    public function initToolBarTitle()
    {
        $this->toolbar_title[] = $this->trans('Themes', array(), 'Modules.Linklist.Admin');
        $this->toolbar_title[] = $this->trans('Link Widget', array(), 'Modules.Linklist.Admin');
    }

    public function setMedia($isNewTheme = false)
    {
        parent::setMedia($isNewTheme);

        $this->addJqueryPlugin('tablednd');
        $this->addJS(_PS_JS_DIR_.'admin/dnd.js');
    }

    private function updatePositions()
    {
        if (!Tools::isSubmit('link_block_0')) {
            return false;
        }

        $linkBlocks = Tools::getValue('link_block_0');
        $query = 'UPDATE `' . _DB_PREFIX_ . 'link_block` SET `position` = CASE `id_link_block` ';

        foreach ($linkBlocks as $position => $linkBlock) {
            preg_match('/tr_\d+_(\d+)_\d+/', $linkBlock, $matches);
            if (isset($matches[1])) {
                $query .= 'WHEN ' . $matches[1] . ' THEN ' . $position . ' ';
            }
        }

        $query .= 'ELSE `position` END';
        return DB::getInstance()->execute($query);
    }

    private function manageLinkList()
    {
        $success = true;

        $id_link_block = (int) Tools::getValue('id_link_block');
        $id_hook = (int) Tools::getValue('id_hook');

        if (!empty($id_hook)) {
            $content = '';

            $cms = Tools::getValue('cms');
            $content .= '{"cms":[' . (empty($cms) ? 'false': '"' . implode('","', array_map('intval', $cms)) . '"') . '],';

            $product = Tools::getValue('product');
            $content .= '"product":[' . (empty($product) ? 'false': '"' . implode('","', array_map('bqSQL', $product)) . '"') . '],';

            $static = Tools::getValue('static');
            $content .= '"static":[' . (empty($static) ? 'false': '"' . implode('","', array_map('bqSQL', $static)) . '"') . ']}';

            $customs = Tools::getValue('custom');
            foreach ($customs as &$custom) {
                $custom = json_encode(array_filter($custom, function ($el) {
                    if (empty($el['title']) || empty($el['url'])) {
                        return false;
                    }
                    return true;
                }));
            }

            return $this->repository->createOrUpdateLinkList(
                $id_link_block,
                $id_hook,
                $content,
                $customs
            );
        }

        return $success;
    }

    private function deleteLinkList()
    {
        $success = true;

        $id_link_block = (int) Tools::getValue('id_link_block');

        if (!empty($id_link_block)) {
            $success &= Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'link_block` WHERE `id_link_block` = '.$id_link_block);

            if ($success) {
                $success &= Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'link_block_lang` WHERE `id_link_block` = '.$id_link_block);
            }
        }

        return $success;
    }
}

 

Link to comment
Share on other sites

ragionando di fretta forse ho detto una fesseria sul file interessato. ora così su due piedi non mi viene in mente niente, però è al quanto strano si sia verificato così dall'oggi al domani.. è possibile che su link widget non ci cliccavi da qualche tempo?

Link to comment
Share on other sites

4 ore fa, lucav87 dice:

L’installazione avrà circa 10 giorni di vita.. sinceramente non riesco a fare un debug del problema in quanto non da nessun errore se non quello incollato... bhooo

magari qualche modifica che hai fatto nei giorni passati o qualche modulo che hai installato a generato il problema oggi hai cliccato su link widget e hai scoperto il problema. Ovviamente se non ci cliccavi da tempo o magari non ci avevi ancora cliccato per configurarlo

Link to comment
Share on other sites

  • 1 year later...

Lista dei files cambiati

Sono stati rilevati file mancanti/cambiati .

File mancanti (33)

vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php

vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php

vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php

vendor/composer/installers/src/Composer/Installers/MayaInstaller.php

vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php

vendor/composer/installers/src/Composer/Installers/YawikInstaller.php

vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php

vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php

vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php

vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php

vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php

vendor/composer/installers/src/Composer/Installers/Plugin.php

vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php

vendor/composer/installers/src/Composer/Installers/MauticInstaller.php

vendor/composer/installers/src/Composer/Installers/ItopInstaller.php

vendor/composer/installers/src/Composer/Installers/PortoInstaller.php

vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php

vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php

vendor/composer/installers/src/Composer/Installers/ModxInstaller.php

vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php

vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php

vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php

vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php

vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php

vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php

vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php

vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php

vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php

vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php

vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php

vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php

vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php

vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php

Files aggiornati (20)

adminxxxxxx/autoupgrade/index.php

adminxxxxxx/autoupgrade/backup/index.php

config/defines.inc.php

vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php

vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php

vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php

vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php

vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php

vendor/composer/installers/src/Composer/Installers/CraftInstaller.php

vendor/composer/installers/src/Composer/Installers/BaseInstaller.php

vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php

vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php

vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php

vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php

vendor/composer/installers/src/Composer/Installers/OxidInstaller.php

vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php

vendor/composer/installers/src/Composer/Installers/Installer.php

vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php

vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php

vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php

 

E grave? 😕

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...