function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
 {
     // Append assets
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/dynamictextgroup/lib/stage/stage.publish.js', 101, false);
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/dynamictextgroup/lib/stage/stage.publish.css', 'screen', 102, false);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/dynamictextgroup/assets/dynamictextgroup.publish.js', 103, false);
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/dynamictextgroup/assets/dynamictextgroup.publish.css', 'screen', 104, false);
     // Get settings
     $settings = array();
     $stage = Stage::getComponents($this->get('id'));
     if (in_array('constructable', $stage)) {
         $settings[] = 'multiple';
     } else {
         $settings[] = 'single';
     }
     $fieldCount = $this->get('fieldcount');
     $entryCount = count($data['textfield1']);
     // Check if schema exists and compile info
     $schema = $this->get('schema');
     if ($schema && $schema != '') {
         $fieldLabels = array();
         $fieldWidths = array();
         $splitMe = explode('|', $schema);
         foreach ($splitMe as $i => $field) {
             $index = $i + 1;
             $splitAgain = explode(',', $field);
             $fieldLabels[$i] = $splitAgain[0] && $splitAgain[0] != null ? $splitAgain[0] : null;
             $fieldWidths[$i] = $splitAgain[1] && $splitAgain[1] != null ? (int) $splitAgain[1] : null;
         }
     } else {
         $fieldLabels = null;
         $fieldWidths = null;
     }
     $fieldWidths = Textgroup::getWidths($fieldCount, $fieldWidths);
     // Populate existing entries
     $content = array();
     if (is_array($data)) {
         $fieldValues = array();
         for ($i = 0; $i < $fieldCount; $i++) {
             if (!is_array($data['textfield' . ($i + 1)])) {
                 $data['textfield' . ($i + 1)] = array($data['textfield' . ($i + 1)]);
             }
         }
         for ($i = 0; $i < $entryCount; $i++) {
             for ($n = 0; $n < $fieldCount; $n++) {
                 $entryValues[$i][$n] = $data['textfield' . ($n + 1)][$i];
             }
             $content[] = Textgroup::createNewTextGroup($this->get('element_name'), $fieldCount, $entryValues[$i], null, $fieldLabels, $fieldWidths);
         }
     } else {
         $content[] = Textgroup::createNewTextGroup($this->get('element_name'), $fieldCount, NULL, NULL, $fieldLabels, $fieldWidths);
     }
     // Add template
     $content[] = Textgroup::createNewTextGroup($this->get('element_name'), $fieldCount, NULL, 'template empty create', $fieldLabels, $fieldWidths);
     // Create stage
     $stage = Stage::create('dynamictextgroup', $this->get('id'), implode($settings, ' '), $content);
     // Field label
     $holder = new XMLElement('div');
     $label = new XMLElement('label', $this->get('label') . '<i>' . __('Help') . '</i>');
     $holder->appendChild($label);
     // Append Stage
     if ($stage) {
         $holder->appendChild($stage);
     }
     if ($flagWithError != NULL) {
         $wrapper->appendChild(Widget::wrapFormElementWithError($holder, $flagWithError));
     } else {
         $wrapper->appendChild($holder);
     }
 }
Exemple #2
0
 /**
  * @see http://symphony-cms.com/learn/api/2.2/toolkit/field/#displayPublishPanel
  */
 function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
 {
     // Houston, we have problem: we've been called out of context!
     $callback = Administration::instance()->getPageCallback();
     if ($callback['context']['page'] != 'edit' && $callback['context']['page'] != 'new') {
         return;
     }
     // Stage
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/datetime/lib/stage/stage.publish.js', 101, false);
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/datetime/lib/stage/stage.publish.css', 'screen', 102, false);
     // Datetime
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/datetime/assets/datetime.publish.js', 103, false);
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/datetime/assets/datetime.publish.css', 'screen', 104, false);
     // Calendar
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/datetime/lib/calendar/calendar.publish.css', 'screen', 105, false);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/datetime/lib/calendar/calendar.publish.js', 106, false);
     // Timer
     Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/datetime/lib/timer/timer.publish.css', 'screen', 107, false);
     Administration::instance()->Page->addScriptToHead(URL . '/extensions/datetime/lib/timer/timer.publish.js', 108, false);
     // Help
     $help = '';
     if ($this->get('range') == 1 && $this->get('required') == 'yes') {
         $help = '<i>' . __('Range: <code>shift</code> + click') . '</i>';
     } elseif ($this->get('range') == 1 && $this->get('required') == 'no') {
         $help = '<i>' . __('Optional') . ', ' . __('range: <code>shift</code> + click') . '</i>';
     } elseif ($this->get('range') == 0 && $this->get('required') == 'no') {
         $help = '<i>' . __('Optional') . '</i>';
     }
     // Field label
     $fieldname = 'fields[' . $this->get('element_name') . ']';
     $label = new XMLElement('label', $this->get('label') . $help);
     $wrapper->appendChild($label);
     // Get settings
     $settings = array();
     $stage = Stage::getComponents($this->get('id'));
     if (in_array('constructable', $stage)) {
         $settings[] = 'multiple';
     } else {
         $settings[] = 'single';
     }
     if ($this->get('prepopulate') == 1) {
         $settings[] = 'prepopulate';
     }
     if ($this->get('range') == 0) {
         $settings[] = 'simple';
     }
     // Existing dates
     $content = array();
     if (is_array($data)) {
         if (!is_array($data['start'])) {
             $data['start'] = array($data['start']);
         }
         if (!is_array($data['end'])) {
             $data['end'] = array($data['end']);
         }
         for ($i = 0; $i < count($data['start']); $i++) {
             $content[] = Calendar::createDate($this->get('element_name'), $data['start'][$i], $data['end'][$i], NULL, $this->get('prepopulate'), $this->get('time'));
         }
     } else {
         $content[] = Calendar::createDate($this->get('element_name'), NULL, NULL, NULL, $this->get('prepopulate'), $this->get('time'));
     }
     // Add template
     $content[] = Calendar::createDate($this->get('element_name'), NULL, NULL, 'template empty create', $this->get('prepopulate'), $this->get('time'));
     // Create stage
     $stage = Stage::create('datetime', $this->get('id'), implode($settings, ' '), $content);
     // Append Stage
     if ($stage) {
         if (!is_null($flagWithError)) {
             $wrapper->appendChild(Widget::wrapFormElementWithError($stage, $flagWithError));
         } else {
             $wrapper->appendChild($stage);
         }
     }
 }