/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, Navigation $structure) { $this->name = $structure->Name; $this->id .= $structure->Url != '' ? '_' . $structure->Url : '_' . $structure->Name; $this->structure = $structure; $this->entity = $entity; $rows = $query->entity(Material::class)->where(Material::F_PARENT, $entity->id)->where(Material::F_DELETION, true)->fields(Material::F_PRIMARY); if (count($rows)) { $this->size = $query->entity(NavigationMaterial::class)->where(NavigationMaterial::F_MATERIALID, $rows)->where(NavigationMaterial::F_STRUCTUREID, $structure->id)->where(NavigationMaterial::F_ACTIVE, true)->count(); } // Get data about current tab $fieldWithMaterialCount = $query->entity(NavigationField::class)->join('field')->where('field_Type', 6)->where(NavigationField::F_STRUCTURE, $this->structure->id)->count(); $localizedFieldsCount = $query->entity(NavigationField::class)->join('field')->where('field_local', 1)->where(NavigationField::F_STRUCTURE, $this->structure->id)->count(); // If in this tab exists only material type field or don't exists localized fields if ($fieldWithMaterialCount > 0 || $localizedFieldsCount == 0) { // Create default sub tab $this->subTabs[] = new MaterialTableLocalized($renderer, $query, $entity, $structure, ''); // If in this tab exists not material type fields and this fields localized then include their } else { //if (($fieldWithMaterialCount == 0) && ($localizedFieldsCount > 0)) // Iterate available locales if we have localized fields foreach (SamsonLocale::$locales as $locale) { // Create child tab $subTab = new MaterialTableLocalized($renderer, $query, $entity, $structure, $locale); $this->subTabs[] = $subTab; } } // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, \samson\activerecord\field $field) { $this->name = $field->Description != '' ? $field->Description : $field->Name; $this->id .= '_' . $field->Name; // Prepare locales array with one default locale by default $locales = array(null); // If field supports localization - set full locales array if ($field->local == 1) { $locales = SamsonLocale::$locales; } /** @var MaterialField $materialField */ $materialField = null; // Iterate defined locales if (sizeof(SamsonLocale::$locales)) { foreach ($locales as $locale) { // Try to find existing MaterialField record if (!dbQuery('\\samsoncms\\api\\MaterialField')->MaterialID($entity->id)->FieldID($field->id)->locale($locale)->first($materialField)) { // Create MaterialField record $materialField = new \samsoncms\api\MaterialField(false); $materialField->Active = 1; $materialField->MaterialID = $entity->id; $materialField->FieldID = $field->id; $materialField->locale = $locale; $materialField->save(); } // Add child tab $this->subTabs[] = new MaterialFieldLocalized($renderer, $query, $entity, $materialField, $locale); } } // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); Event::fire('samsoncms.material.materialfieldtab.created', array(&$this, $field)); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, Navigation $structure) { $this->name = $structure->Name; $this->id .= $structure->Url != '' ? '_' . $structure->Url : '_' . $structure->Name; $this->structure = $structure; // Get data about current tab $fieldWithMaterialCount = dbQuery('structurefield')->join('field')->cond('StructureID', $this->structure->id)->cond('field_Type', 6)->count(); $localizedFieldsCount = dbQuery('structurefield')->join('field')->cond('StructureID', $this->structure->id)->cond('field_local', 1)->count(); // If in this tab exists only material type field or don't exists localized fields if ($fieldWithMaterialCount > 0 || $localizedFieldsCount == 0) { // Create default sub tab $this->subTabs[] = new MaterialTableLocalized($renderer, $query, $entity, $structure, ''); // If in this tab exists not material type fields and this fields localized then include their } else { //if (($fieldWithMaterialCount == 0) && ($localizedFieldsCount > 0)) // Iterate available locales if we have localized fields foreach (SamsonLocale::$locales as $locale) { // Create child tab $subTab = new MaterialTableLocalized($renderer, $query, $entity, $structure, $locale); $this->subTabs[] = $subTab; } } // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity) { // If fields are not configured if (!sizeof($this->fields)) { // Add all entity attributes to fields array foreach ($entity::$_attributes as $field) { $this->fields[] = new \samsoncms\form\field\Generic($field); } } // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, $locale = SamsonLocale::DEF) { $this->locale = $locale; if ($locale !== null) { $this->id .= '-' . $this->locale; $this->name = $this->locale; } else { $this->name = 'all'; } // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, Navigation $structure, $locale = SamsonLocale::DEF) { $this->locale = $locale; if ($locale != '') { $this->id .= '-' . $this->locale; $this->name = $this->locale; } else { $this->name = 'all'; } $this->id .= $structure->Url != '' ? '_' . $structure->Url : '_' . $structure->Name; $this->structure = $structure; // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** * @param RenderInterface $renderer * @param QueryInterface $query * @param Record $entity * @param MaterialField $materialField * @param string $locale */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, \samsoncms\api\MaterialField $materialField, $locale = null) { // Get type of filed $field = dbQuery('field')->cond('FieldID', $materialField->FieldID)->first(); // Create CMS Field object from MaterialField object $this->inputField = m('samsoncms_input_application')->createFieldByType(new dbQuery(), $field->Type, $materialField); // Save tab header name as locale name $this->name = $locale; // Generate unique html identifier $this->id = $this->id . '_' . $this->name; $this->id .= $materialField->id; // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity, field $field) { // Check if material have this gallery additional field stored if (!$query->className('materialfield')->cond('MaterialID', $entity->id)->cond('FieldID', $field->id)->first($this->materialField)) { // Create materialfield object $this->materialField = new \samson\activerecord\materialfield(false); $this->materialField->FieldID = $field->id; $this->materialField->MaterialID = $entity->id; $this->materialField->Active = 1; $this->materialField->save(); } // Form tab name $this->name = t(isset($field->Name[0]) ? $field->Name : $this->name, true); // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); }
/** @inheritdoc */ public function __construct(RenderInterface $renderer, QueryInterface $query, Record $entity) { $this->name = t($this->name, true); $this->show = false; $entity = dbQuery('\\samsoncms\\api\\Material')->cond('MaterialID', $entity->id)->join('structurematerial')->join('structure')->first(); if (isset($entity['onetomany']) && isset($entity['onetomany']['_structure'])) { $structures = $entity['onetomany']['_structure']; $nonLocalizedFieldsCount = dbQuery('structurefield')->join('field')->cond('StructureID', array_keys($structures))->cond('field_local', 0)->count(); $newStructuresId = array(); // Get all structure which not table foreach ($structures as $structure) { if ($structure->type == 0) { $newStructuresId[] = $structure->id; } } // If there no structures with localized fields then count of localized fields equal 0 if (empty($newStructuresId)) { $localizedFieldsCount = 0; } else { $localizedFieldsCount = dbQuery('structurefield')->join('field')->cond('StructureID', $newStructuresId)->cond('field_local', 1)->cond('field_Type', 5, dbRelation::LOWER)->count(); } // If we have not localized fields // Don't display the non localized fields /*if ($nonLocalizedFieldsCount > 0) { // Create default sub tab $this->subTabs[] = new FieldLocalized($renderer, $query, $entity, ''); $this->show = true; }*/ // Iterate available locales if we have localized fields if (sizeof(SamsonLocale::$locales) && $localizedFieldsCount > 0) { foreach (SamsonLocale::$locales as $locale) { // Create child tab $subTab = new LocaleTab($renderer, $query, $entity, $locale); $this->subTabs[] = $subTab; } $this->show = true; } } // Call parent constructor to define all class fields parent::__construct($renderer, $query, $entity); // Trigger special additional field Event::fire('samsoncms.material.fieldtab.created', array(&$this)); }