/** * The Config Class. * * @var Config * @since 3.2.0 */ protected Config $config; /** * The CustomTabs Class. * * @var BuilderCustomTabs * @since 3.2.0 */ protected BuilderCustomTabs $buildercustomtabs; /** * The Language Class. * * @var Language * @since 3.2.0 */ protected Language $language; /** * The Placeholder Class. * * @var Placeholder * @since 3.2.0 */ protected Placeholder $placeholder; /** * The Customcode Class. * * @var Customcode * @since 3.2.0 */ protected Customcode $customcode; /** * Constructor. * * @param Config $config The Config Class. * @param BuilderCustomTabs $buildercustomtabs The CustomTabs Class. * @param Language $language The Language Class. * @param Placeholder $placeholder The Placeholder Class. * @param Customcode $customcode The Customcode Class. * * @since 3.2.0 */ public function __construct(Config $config, BuilderCustomTabs $buildercustomtabs, Language $language, Placeholder $placeholder, Customcode $customcode) { $this->config = $config; $this->buildercustomtabs = $buildercustomtabs; $this->language = $language; $this->placeholder = $placeholder; $this->customcode = $customcode; } /** * Set custom tabs * * @param object $item The view data * * @return void * @since 3.2.0 */ public function set(object &$item) { $item->customtabs = (isset($item->customtabs) && JsonHelper::check($item->customtabs)) ? json_decode((string) $item->customtabs, true) : null; if (ArrayHelper::check($item->customtabs)) { // get the name $name = $item->name_single_code; // setup custom tabs to global data sets $this->buildercustomtabs->set($name, array_map( function ($tab) use (&$name) { // set the view name $tab['view'] = $name; // load the dynamic data $tab['html'] = $this->placeholder->update_( $this->customcode->update($tab['html']) ); // set the tab name $tab['name'] = (isset($tab['name']) && StringHelper::check( $tab['name'] )) ? $tab['name'] : 'Tab'; // set lang $tab['lang'] = $this->config->lang_prefix . '_' . StringHelper::safe( $tab['view'], 'U' ) . '_' . StringHelper::safe( $tab['name'], 'U' ); $this->language->set( 'both', $tab['lang'], $tab['name'] ); // set code name $tab['code'] = StringHelper::safe( $tab['name'] ); // check if the permissions for the tab should be added $_tab = ''; if (isset($tab['permission']) && $tab['permission'] == 1) { $_tab = Indent::_(1); } // check if the php of the tab is set, if not load it now if (strpos((string) $tab['html'], 'uitab.addTab') === false && strpos((string) $tab['html'], 'uitab.endTab') === false) { // add the tab $tmp = PHP_EOL . $_tab . Indent::_(1) . ""; $tmp .= PHP_EOL . $_tab . Indent::_(2) . '