<commit_before><?php
namespace Concrete\Package\CommunityStore\Src\CommunityStore\Utilities;

use Package;
use BlockType;
use BlockTypeSet;
use SinglePage;
use Core;
use Page;
use PageTemplate;
use PageType;
use Group;
use Database;
use FileSet;
use Config;
use Localization;
use Concrete\Core\Attribute\Key\Category as AttributeKeyCategory;
use Concrete\Core\Attribute\Key\UserKey as UserAttributeKey;
use Concrete\Core\Attribute\Type as AttributeType;
use AttributeSet;
use Concrete\Core\Page\Type\PublishTarget\Type\AllType as PageTypePublishTargetAllType;
use Concrete\Core\Page\Type\PublishTarget\Configuration\AllConfiguration as PageTypePublishTargetAllConfiguration;
use Concrete\Package\CommunityStore\Src\Attribute\Key\StoreOrderKey as StoreOrderKey;
use Concrete\Package\CommunityStore\Src\CommunityStore\Payment\Method as StorePaymentMethod;
use Concrete\Package\CommunityStore\Src\CommunityStore\Shipping\Method\ShippingMethodType as StoreShippingMethodType;
use Concrete\Package\CommunityStore\Src\CommunityStore\Order\OrderStatus\OrderStatus as StoreOrderStatus;
use Concrete\Package\CommunityStore\Src\CommunityStore\Tax\TaxClass as StoreTaxClass;

defined('C5_EXECUTE') or die(_("Access Denied."));

class Installer
{
    public static function installSinglePages(Package $pkg)
    {
        //install our dashboard single pages
        self::installSinglePage('/dashboard/store', $pkg);
        self::installSinglePage('/dashboard/store/orders/', $pkg);
        self::installSinglePage('/dashboard/store/products/', $pkg);
        self::installSinglePage('/dashboard/store/discounts/', $pkg);
        self::installSinglePage('/dashboard/store/products/attributes', $pkg);
        self::installSinglePage('/dashboard/store/settings/', $pkg);
        self::installSinglePage('/dashboard/store/settings/shipping', $pkg);
        self::installSinglePage('/dashboard/store/settings/shipping/clerk', $pkg);
        self::installSinglePage('/dashboard/store/settings/tax', $pkg);
        self::installSinglePage('/dashboard/store/reports', $pkg);
        self::installSinglePage('/dashboard/store/reports/sales', $pkg);
        self::installSinglePage('/dashboard/store/reports/products', $pkg);
        self::installSinglePage('/cart', $pkg);
        self::installSinglePage('/checkout', $pkg);
        self::installSinglePage('/checkout/complete', $pkg);
        Page::getByPath('/cart/')->setAttribute('exclude_nav', 1);
        Page::getByPath('/checkout/')->setAttribute('exclude_nav', 1);
        Page::getByPath('/checkout/complete')->setAttribute('exclude_nav', 1);
    }
    public static function installSinglePage($path, $pkg)
    {
        $page = Page::getByPath($path);
        if (!is_object($page) || $page->isError()) {
            SinglePage::add($path, $pkg);
        }
    }
    public static function installProductParentPage(Package $pkg)
    {
        $productParentPage = Page::getByPath('/products');
        if (!is_object($productParentPage) || $productParentPage->isError()) {
            $productParentPage = Page::getByID(1)->add(
                PageType::getByHandle('page'),
                array(
                    'cName' => t('Products'),
                    'cHandle' => 'products',
                    'pkgID' => $pkg->getPackageID(),
                ),
                PageTemplate::getByHandle('full')
            );
        }
        $productParentPage->setAttribute('exclude_nav', 1);
    }
    public static function installStoreProductPageType(Package $pkg)
    {
        //install product detail page type
        $pageType = PageType::getByHandle('store_product');
        if (!is_object($pageType)) {
            $template = PageTemplate::getByHandle('full');
            PageType::add(
                array(
                    'handle' => 'store_product',
                    'name' => 'Product Page',
                    'defaultTemplate' => $template,
                    'allowedTemplates' => 'C',
                    'templates' => array($template),
                    'ptLaunchInComposer' => 0,
                    'ptIsFrequentlyAdded' => 0,
                ),
                $pkg
            )->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
        }
    }

    public static function setDefaultConfigValues(Package $pkg)
    {
        self::setConfigValue('communitystore.productPublishTarget', Page::getByPath('/products')->getCollectionID());
        self::setConfigValue('communitystore.symbol', '$');
        self::setConfigValue('communitystore.whole', '.');
        self::setConfigValue('communitystore.thousand', ',');
        self::setConfigValue('communitystore.sizeUnit', 'in');
        self::setConfigValue('communitystore.weightUnit', 'lb');
        self::setConfigValue('communitystore.taxName', t('Tax'));
        self::setConfigValue('communitystore.sizeUnit', 'in');
        self::setConfigValue('communitystore.weightUnit', 'lb');
    }
    public static function setConfigValue($key, $value)
    {
        $config = Config::get($key);
        if (empty($config)) {
            Config::save($key, $value);
        }
    }<commit_msg>Missed some config handle updates<commit_after><?php
namespace Concrete\Package\CommunityStore\Src\CommunityStore\Utilities;

use Package;
use BlockType;
use BlockTypeSet;
use SinglePage;
use Core;
use Page;
use PageTemplate;
use PageType;
use Group;
use Database;
use FileSet;
use Config;
use Localization;
use Concrete\Core\Attribute\Key\Category as AttributeKeyCategory;
use Concrete\Core\Attribute\Key\UserKey as UserAttributeKey;
use Concrete\Core\Attribute\Type as AttributeType;
use AttributeSet;
use Concrete\Core\Page\Type\PublishTarget\Type\AllType as PageTypePublishTargetAllType;
use Concrete\Core\Page\Type\PublishTarget\Configuration\AllConfiguration as PageTypePublishTargetAllConfiguration;
use Concrete\Package\CommunityStore\Src\Attribute\Key\StoreOrderKey as StoreOrderKey;
use Concrete\Package\CommunityStore\Src\CommunityStore\Payment\Method as StorePaymentMethod;
use Concrete\Package\CommunityStore\Src\CommunityStore\Shipping\Method\ShippingMethodType as StoreShippingMethodType;
use Concrete\Package\CommunityStore\Src\CommunityStore\Order\OrderStatus\OrderStatus as StoreOrderStatus;
use Concrete\Package\CommunityStore\Src\CommunityStore\Tax\TaxClass as StoreTaxClass;

defined('C5_EXECUTE') or die(_("Access Denied."));

class Installer
{
    public static function installSinglePages(Package $pkg)
    {
        //install our dashboard single pages
        self::installSinglePage('/dashboard/store', $pkg);
        self::installSinglePage('/dashboard/store/orders/', $pkg);
        self::installSinglePage('/dashboard/store/products/', $pkg);
        self::installSinglePage('/dashboard/store/discounts/', $pkg);
        self::installSinglePage('/dashboard/store/products/attributes', $pkg);
        self::installSinglePage('/dashboard/store/settings/', $pkg);
        self::installSinglePage('/dashboard/store/settings/shipping', $pkg);
        self::installSinglePage('/dashboard/store/settings/shipping/clerk', $pkg);
        self::installSinglePage('/dashboard/store/settings/tax', $pkg);
        self::installSinglePage('/dashboard/store/reports', $pkg);
        self::installSinglePage('/dashboard/store/reports/sales', $pkg);
        self::installSinglePage('/dashboard/store/reports/products', $pkg);
        self::installSinglePage('/cart', $pkg);
        self::installSinglePage('/checkout', $pkg);
        self::installSinglePage('/checkout/complete', $pkg);
        Page::getByPath('/cart/')->setAttribute('exclude_nav', 1);
        Page::getByPath('/checkout/')->setAttribute('exclude_nav', 1);
        Page::getByPath('/checkout/complete')->setAttribute('exclude_nav', 1);
    }
    public static function installSinglePage($path, $pkg)
    {
        $page = Page::getByPath($path);
        if (!is_object($page) || $page->isError()) {
            SinglePage::add($path, $pkg);
        }
    }
    public static function installProductParentPage(Package $pkg)
    {
        $productParentPage = Page::getByPath('/products');
        if (!is_object($productParentPage) || $productParentPage->isError()) {
            $productParentPage = Page::getByID(1)->add(
                PageType::getByHandle('page'),
                array(
                    'cName' => t('Products'),
                    'cHandle' => 'products',
                    'pkgID' => $pkg->getPackageID(),
                ),
                PageTemplate::getByHandle('full')
            );
        }
        $productParentPage->setAttribute('exclude_nav', 1);
    }
    public static function installStoreProductPageType(Package $pkg)
    {
        //install product detail page type
        $pageType = PageType::getByHandle('store_product');
        if (!is_object($pageType)) {
            $template = PageTemplate::getByHandle('full');
            PageType::add(
                array(
                    'handle' => 'store_product',
                    'name' => 'Product Page',
                    'defaultTemplate' => $template,
                    'allowedTemplates' => 'C',
                    'templates' => array($template),
                    'ptLaunchInComposer' => 0,
                    'ptIsFrequentlyAdded' => 0,
                ),
                $pkg
            )->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
        }
    }

    public static function setDefaultConfigValues(Package $pkg)
    {
        self::setConfigValue('community_store.productPublishTarget', Page::getByPath('/products')->getCollectionID());
        self::setConfigValue('community_store.symbol', '$');
        self::setConfigValue('community_store.whole', '.');
        self::setConfigValue('community_store.thousand', ',');
        self::setConfigValue('community_store.sizeUnit', 'in');
        self::setConfigValue('community_store.weightUnit', 'lb');
        self::setConfigValue('community_store.taxName', t('Tax'));
        self::setConfigValue('community_store.sizeUnit', 'in');
        self::setConfigValue('community_store.weightUnit', 'lb');
    }
    public static function setConfigValue($key, $value)
    {
        $config = Config::get($key);
        if (empty($config)) {
            Config::save($key, $value);
        }
    }
{'fraction_non_alphanumeric': 0.1377594948818521, 'fraction_numerical': 0.001530661054242801, 'mean_word_length': 3.2756646216768917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '6190754', 'n_tokens_mistral': 2875, 'n_tokens_neox': 2801, 'n_words': 454}