/**
  * Constructor
  * @param Form $form
  * @param \samson\activerecord\field $db_field
  * @param string $locale
  */
 public function __construct(Form &$form, &$db_field, $field_type)
 {
     // Set field header name
     $this->name = !empty($db_field->Description) ? $db_field->Description : $db_field->Name;
     // Save pointers to database field object
     $this->db_field =& $db_field;
     // Call parent
     parent::__construct($form);
     // Prepare locales array with one default locale by default
     $locales = array('');
     // If field supports localization - set full locales array
     if ($db_field->local == 1) {
         $locales = SamsonLocale::$locales;
     }
     // Iterate defined locales
     if (sizeof(SamsonLocale::$locales)) {
         foreach ($locales as $locale) {
             // Try to find existing CMSMaterialField record
             if (!dbQuery('\\samson\\cms\\CMSMaterialField')->MaterialID($form->material->id)->FieldID($db_field->id)->locale($locale)->first($db_mf)) {
                 // Create CMSMaterialField record
                 $db_mf = new \samson\cms\CMSMaterialField(false);
                 $db_mf->Active = 1;
                 $db_mf->MaterialID = $this->form->material->id;
                 $db_mf->FieldID = $db_field->id;
                 $db_mf->locale = $locale;
                 $db_mf->save();
             }
             //elapsed($this->name.'-'.$locale.'-'.$db_mf->Value.'-'.$db_mf->id);
             // Add child tab
             $this->tabs[] = new MaterialFieldTab($form, $this, $db_mf, $locale, $field_type);
         }
     }
 }
 /**
  * Constructor
  * @param Form $form Pointer to form
  */
 public function __construct(Form &$form, FormTab &$parent = null, $locale = null)
 {
     // Call parent constructor
     parent::__construct($form, $parent);
     // Save tab header name as locale name
     $this->name = $locale == '' ? t('все', true) : $locale;
     // Add locale to identifier
     $this->id = $parent->id . ($locale == '' ? '' : '-' . $locale);
     // Set pointer to CMSMaterial
     $material =& $form->material;
     $this->content_html = m('related_material')->getRelatedTable($material->id, $locale);
 }
 /**
  * Constructor
  * @param Form $form
  * @param FormTab $parent
  * @param CMSMaterialField $db_mf
  * @param string $locale
  * @param string $field_type
  */
 public function __construct(Form &$form, FormTab &$parent, CMSMaterialField &$db_mf, $locale = null, $field_type = 'WYSIWYG')
 {
     // Create CMS Field object from CMSMaterialField object
     $this->cmsfield = m('samsoncms_input_wysiwyg_application')->createField(new dbQuery(), $db_mf);
     // Save tab header name as locale name
     $this->name = $locale;
     // Generate unique html identifier
     $this->id = utf8_translit($parent->name) . '_' . $this->name . '_tab';
     // Save pointers to database CMSMaterialField object
     $this->db_mf =& $db_mf;
     // Call parent
     parent::__construct($form, $parent);
     //elapsed($this->content_view.'!!!!!!!!!!!!!!');
     // Render CMS Field
     $this->content_html = m('material')->view($this->content_view)->cmsfield($this->cmsfield)->output();
 }
示例#4
0
 /**
  * Constructor
  * @param Form $form Pointer to form
  */
 public function __construct(Form &$form, FormTab &$parent = null, $locale = null)
 {
     // Call parent constructor
     parent::__construct($form, $parent);
     // Add generic tab
     $allTab = new FieldTab($form, $this, '');
     if ($allTab->filled()) {
         $this->tabs[] = $allTab;
     }
     // Iterate available locales if fields exists
     if (sizeof($form->fields) && sizeof(SamsonLocale::$locales)) {
         foreach (SamsonLocale::$locales as $locale) {
             // Create child tab
             $tab = new FieldTab($form, $this, $locale);
             // If it is not empty
             if ($tab->filled()) {
                 $this->tabs[] = $tab;
             }
         }
     }
 }
示例#5
0
 /** @see \samson\cms\web\material\FormTab::content() */
 public function content()
 {
     // Iterate all loaded CMSNavs
     $parent_select = '';
     foreach (dbQuery('samson\\cms\\CMSNav')->exec() as $db_structure) {
         // If material is related to current CMSNav
         $selected = '';
         if (isset($this->form->navs[$db_structure->id])) {
             $selected = 'selected';
         }
         // Generate CMSNav option
         $parent_select .= '<option ' . $selected . ' value="' . $db_structure->id . '">' . $db_structure->Name . '</option>';
     }
     // Get user object
     //		$user = isset($this->form->material->onetoone['_user']) ? $this->form->material->onetoone['_user']  : auth()->user;
     $user = isset($this->form->material->onetoone['_user']) ? $this->form->material->onetoone['_user'] : m('social')->user();
     // Render content into inner content html
     $this->content_html = m()->view($this->content_view)->material($this->form->material)->user($user)->parent_select($parent_select)->output();
     // Render parent tab view
     return parent::content();
 }
 /**
  * Constructor
  * @param Form $form Pointer to form
  */
 public function __construct(Form &$form, FormTab &$parent = null)
 {
     // Call parent constructor
     parent::__construct($form, $parent);
     // If material type is related than show this tab
     if ($form->material->type == 1) {
         // Create all locale sub tab
         $allTab = new MaterialTab($form, $this, '');
         $this->tabs[] = $allTab;
         // Iterate available locales if fields exists
         if (sizeof(SamsonLocale::$locales)) {
             foreach (SamsonLocale::$locales as $locale) {
                 // Create child tab
                 $tab = new MaterialTab($form, $this, $locale);
                 // If it is not empty
                 if ($tab->filled()) {
                     $this->tabs[] = $tab;
                 }
             }
         }
     }
 }
示例#7
0
 /**
  * Constructor 
  * @param Form $form Pointer to form
  */
 public function __construct(Form &$form, FormTab &$parent = null, $locale = null)
 {
     // Call parent constructor
     parent::__construct($form, $parent);
     // Save tab header name as locale name
     $this->name = $locale == '' ? t('все', true) : $locale;
     // Add locale to identifier
     $this->id = $parent->id . ($locale == '' ? '' : '-' . $locale);
     // Set pointer to CMSMaterial
     $material =& $form->material;
     // If material has no related CMSNavs  - Disable tab rendering
     if (!isset($material->onetomany['_structure'])) {
         $this->render = false;
     } else {
         // Create FormFieldTable instance
         $this->field_table = new FormFieldTable($form->material, $form, $locale);
         // Render tab content
         $this->content_html = $this->field_table->render(null, 'material');
         // If field table is empty - clear output, we don't need empty tables
         if ($this->field_table->last_render_count == 0) {
             $this->content_html = '';
         }
     }
 }