* @copyright 2022 ECSoft * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of ECSoft */ include_once dirname(__FILE__) . '/EcsGtmProModelAbstract.php'; class EcsGtmProGtmGeneralConfig extends EcsGtmProModelAbstract { public $enable; public $exclude_internal; public $gtm_id; public $format; public $resend_orders; public $max_resend; public $max_category; public $sandbox; public $allowed_ips; public $debug; public function attributeTypes() { return array( 'gtm_id' => 'text', 'format' => 'select', 'max_resend' => 'text', 'max_category' => 'text', 'allowed_ips' => 'textarea', ); } public function attributeDefaults() { return array( 'enable' => 1, 'exclude_internal' => 1, 'format' => 'ga4', 'resend_orders' => 1, 'max_resend' => 7, 'max_category' => 30, ); } public function formatSelectOptions() { return array( array( 'id' => 'gau', 'name' => $this->l('Universal Google Analytics'), ), array( 'id' => 'ga4', 'name' => $this->l('Google Analytics 4'), ), ); } public function attributeLabels() { return array( 'enable' => $this->l('Enable Google Tag Manager', 'EcsGtmProGtmGeneralConfig'), 'exclude_internal' => $this->l('Exclude internal traffic', 'EcsGtmProGtmGeneralConfig'), 'gtm_id' => $this->l('Google Tag Manager ID', 'EcsGtmProGtmGeneralConfig'), 'format' => $this->l('Google Tag DataLayer format', 'EcsGtmProGtmGeneralConfig'), 'resend_orders' => $this->l('Re-send orders automatically', 'EcsGtmProGtmGeneralConfig'), 'max_resend' => $this->l('Maximum period to re-send orders', 'EcsGtmProGtmGeneralConfig'), 'max_category' => $this->l('Maximum category entries in datalayer', 'EcsGtmProGtmGeneralConfig'), 'sandbox' => $this->l('Sandbox mode', 'EcsGtmProGtmGeneralConfig'), 'allowed_ips' => $this->l('Allowed IPs', 'EcsGtmProGtmGeneralConfig'), 'debug' => $this->l('Debug mode', 'EcsGtmProGtmGeneralConfig'), ); } public function fieldSuffix() { return array( 'max_resend' => $this->l('days', 'EcsGtmProGtmGeneralConfig'), ); } public function attributePlaceholders() { return array( 'gtm_id' => 'GTM-XXXXXX', ); } public function attributeDescriptions() { return array( 'resend_orders' => $this->l('Re-send orders if order was not sent.', 'EcsGtmProGtmGeneralConfig'), 'max_resend' => $this->l('Maximum number of days after the order has been placed to re-send it.', 'EcsGtmProGtmGeneralConfig'), 'max_category' => $this->l('Maximum number of items sent to datalayer in category pages. If ou have big product name, please lower this value so the datalayer does not exceed size limit.', 'EcsGtmProGtmGeneralConfig'), 'sandbox' => $this->l('Enable module on allowed IPs only.', 'EcsGtmProGtmGeneralConfig'), 'allowed_ips' => $this->l('One IP per line.', 'EcsGtmProGtmGeneralConfig'), 'debug' => $this->l('Show debug pannel. You can also turn debug mode using XDebug helper plugin for browser.', 'EcsGtmProGtmGeneralConfig'), ); } public function rules() { return array( array( array( 'enable', 'exclude_internal', 'gtm_id', 'format', 'resend_orders', 'max_resend', 'max_category', 'sandbox', 'allowed_ips', 'debug', ), 'safe' ), array( array( 'gtm_id' ), 'validateRequired' ), array( array( 'max_resend', 'max_category', ), 'validateInteger' ) ); } public function validateInteger($value) { return Validate::isInt($value) || preg_match('/^\d+$/is', $value); } public function configKey() { return 'ecsgtm_general'; } public function getActiveTab() { return 'EcsGtmProGtmConfig'; } }