<commit_before><?php
namespace Concrete\Core\Page\Controller;

use Concrete\Controller\Element\Navigation\AccountMenu;
use Concrete\Core\Attribute\Context\DashboardFormContext;
use Concrete\Core\Attribute\Context\FrontendFormContext;
use Concrete\Core\Attribute\Form\Renderer;
use Concrete\Core\Page\Desktop\DesktopList;
use Concrete\Core\Page\Theme\ThemeRouteCollection;
use Concrete\Core\User\User;
use Loader;
use Concrete\Core\Page\Controller\PageController as CorePageController;

class AccountPageController extends CorePageController
{
    public $helpers = array('html', 'form', 'text');

    public function on_start()
    {
        $u = $this->app->make(User::class);
        if (!$u->isRegistered()) {
            return $this->replace('/login');
        }
        $profile = \UserInfo::getByID($u->getUserID());

        $dh = \Core::make('helper/concrete/dashboard');
        $desktop = DesktopList::getMyDesktop();

        $collection = $this->app->make(ThemeRouteCollection::class);
        $theme = $collection->getThemeByRoute('/account');

        if ($theme[0] === VIEW_CORE_THEME || !$theme[0]) {
            // We're using the default theme, so let's do our fancy dashboard overriding of the theme if we can.
            if ($dh->inDashboard($desktop) && $this->getPageObject()->getCollectionPath() != '/account/welcome') {
                $this->setTheme('dashboard');
                $this->set('pageTitle', t('My Account'));
                $this->set(
                    'profileFormRenderer',
                    new Renderer(
                        new DashboardFormContext(),
                        $profile
                    )
                );
            } else {
                $this->setTheme('concrete');
                $this->set(
                    'profileFormRenderer',
                    new Renderer(
                        new FrontendFormContext(),
                        $profile
                    )
                );
            }
        }

        $this->setThemeViewTemplate('account.php');
        $this->error = Loader::helper('validation/error');
        $this->token = Loader::helper('validation/token');
        $this->set('valt', $this->token);
        $this->set('av', Loader::helper('concrete/avatar'));

        $this->set('profile', $profile);

        $nav = new AccountMenu($this->getPageObject());
        $this->set('nav', $nav);

    }

    public function on_before_render()
    {
        $this->set('error', $this->error);
    }

    /**
     * {@inheritdoc}
     *
     * @see \Concrete\Core\Page\Controller\PageController::useUserLocale()
     */
    public function useUserLocale()
    {
        return true;
    }
}
<commit_msg>fixing profile form edit form context on custom themes with edit profile support<commit_after><?php
namespace Concrete\Core\Page\Controller;

use Concrete\Controller\Element\Navigation\AccountMenu;
use Concrete\Core\Attribute\Context\DashboardFormContext;
use Concrete\Core\Attribute\Context\FrontendFormContext;
use Concrete\Core\Attribute\Form\Renderer;
use Concrete\Core\Page\Desktop\DesktopList;
use Concrete\Core\Page\Theme\ThemeRouteCollection;
use Concrete\Core\User\User;
use Loader;
use Concrete\Core\Page\Controller\PageController as CorePageController;

class AccountPageController extends CorePageController
{
    public $helpers = array('html', 'form', 'text');

    public function on_start()
    {
        $u = $this->app->make(User::class);
        if (!$u->isRegistered()) {
            return $this->replace('/login');
        }
        $profile = \UserInfo::getByID($u->getUserID());

        $dh = \Core::make('helper/concrete/dashboard');
        $desktop = DesktopList::getMyDesktop();

        $collection = $this->app->make(ThemeRouteCollection::class);
        $theme = $collection->getThemeByRoute('/account');

        $profileFormRenderer = null;
        if ($theme[0] === VIEW_CORE_THEME || !$theme[0]) {
            // We're using the default theme, so let's do our fancy dashboard overriding of the theme if we can.
            if ($dh->inDashboard($desktop) && $this->getPageObject()->getCollectionPath() != '/account/welcome') {
                $this->setTheme('dashboard');
                $this->set('pageTitle', t('My Account'));
                $profileFormRenderer = new Renderer(
                    new DashboardFormContext(),
                    $profile
                );

            } else {
                $this->setTheme('concrete');
            }
        }

        if (!$profileFormRenderer) {
            $profileFormRenderer = new Renderer(
                new FrontendFormContext(),
                $profile
            );
        }

        $this->set('profileFormRenderer', $profileFormRenderer);

        $this->setThemeViewTemplate('account.php');
        $this->error = Loader::helper('validation/error');
        $this->token = Loader::helper('validation/token');
        $this->set('valt', $this->token);
        $this->set('av', Loader::helper('concrete/avatar'));

        $this->set('profile', $profile);

        $nav = new AccountMenu($this->getPageObject());
        $this->set('nav', $nav);

    }

    public function on_before_render()
    {
        $this->set('error', $this->error);
    }

    /**
     * {@inheritdoc}
     *
     * @see \Concrete\Core\Page\Controller\PageController::useUserLocale()
     */
    public function useUserLocale()
    {
        return true;
    }
}

{'fraction_non_alphanumeric': 0.14662273476112025, 'fraction_numerical': 0.0007321984257733846, 'mean_word_length': 2.3155339805825244, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6956398', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1481, 'n_words': 268}