Beispiel #1
0
 public function run()
 {
     DB::table('stage')->delete();
     Stage::create(array('name' => 'Finale'));
     Stage::create(array('name' => '1/2 finales', 'next_stage' => 1));
     Stage::create(array('name' => '1/4 de finale', 'next_stage' => 2));
     Stage::create(array('name' => '1/8 de finale', 'next_stage' => 3));
     Stage::create(array('name' => '3e place'));
 }
Beispiel #2
0
    /**

     * Create Stage rows from an array, removing those Objects

     * with the same UID, and recreaiting the records from the array data.

     *

     * @param $Stage array.

     * @return void

     */

    public function createStageRows ($Stage)

    {

        foreach ($Stage as $key => $row) {

            $oStage = new Stage();

            if ($oStage->Exists( $row['STG_UID'] )) {

                $oStage->remove( $row['STG_UID'] );

            }

            $res = $oStage->create( $row );

        }

        return;

    }
         if ((int) $aRow['TIMES'] > 0) {
             $iStageNumber += 1;
         } else {
             $bContinue = true;
         }
     }
     $oStage = new Stage();
     $oNewStage = new stdclass();
     $oNewStage->label = G::LoadTranslation('ID_STAGE') . ' ' . $iStageNumber;
     if ($oData->position->x < 0) {
         $oData->position->x *= -1;
     }
     if ($oData->position->y < 0) {
         $oData->position->y *= -1;
     }
     $oNewStage->uid = $oStage->create(array('PRO_UID' => $oData->uid, 'STG_TITLE' => $oNewStage->label, 'STG_POSX' => $oData->position->x, 'STG_POSY' => $oData->position->y, 'STG_INDEX' => $iIndex));
     //$oJSON = new Services_JSON();
     echo Bootstrap::json_encode($oNewStage);
     break;
 case 'saveStagePosition':
     require_once 'classes/model/Stage.php';
     //$oJSON = new Services_JSON();
     $oData = Bootstrap::json_decode(stripslashes($_POST['data']));
     $oStage = new Stage();
     $aFields = $oStage->load($oData->uid);
     $aFields['STG_UID'] = $oData->uid;
     $aFields['STG_POSX'] = $oData->position->x;
     $aFields['STG_POSY'] = $oData->position->y;
     $oStage->update($aFields);
     break;
 case 'deleteStage':
 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);
     }
 }
Beispiel #5
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);
         }
     }
 }