Esempio n. 1
0
$auth = new auth("EXPORT");
$page = new page("Export");
$wizard = new Wizard($lang->get("export_data", "Export Content and Templates Wizard"));
$wizard->setTitleText($lang->get("wz_export_title", "This wizard is used to exchange clusters, cluster-templates and page-templates between your N/X installation and others. The wizard generates a XML File, which you can store on your local hard drive and exchange with other N/X-Users."));
////// STEP 1 //////
$step = new Step();
$step->setTitle($lang->get("wzt_export_type", "Select type to export"));
$step->setExplanation($lang->get("wze_export_type", "On the right you need to select the type of data you want to export. Clusters are storing content. When you export clusters, the templates are automatically exported too. Cluster-Templates are schemes for creating clusters. Page-Templates are used for creating pages in the website. Cluster-Templates, Meta-Templates and layout are automatically exported when you export a Page-Template."));
$resources[0][0] = $lang->get("cluster", "Cluster");
$resources[0][1] = "CLUSTER";
$resources[1][0] = $lang->get("cluster_template", "Cluster Template");
$resources[1][1] = "CLUSTERTEMPLATE";
$resources[2][0] = $lang->get("page_template", "Page Template");
$resources[2][1] = "PAGETEMPLATE";
$step->add(new WZRadio("resource_type", $resources));
////// STEP 2 //////
$step2 = new STSelectResource();
$step2->setTitle($lang->get("wzt_sel_exp_res", "Select Resource for export"));
////// STEP 3 //////
$step3 = new Step();
$step3->setTitle($lang->get("wzt_descr", "Add description"));
$step3->setExplanation($lang->get("wzt_descr_expl", "You should add a short description to the exported data.<br/><br/> Anyone who will import the data will easier understand, what he exports."));
$step3->add(new WZText("exp_description", $lang->get("description", "Description"), "TEXTAREA"));
////// Step 4 //////
$step4 = new STExportResource();
$wizard->add($step);
$wizard->add($step2);
$wizard->add($step3);
$wizard->add($step4);
$page->add($wizard);
$page->draw();
Esempio n. 2
0
 public function edit()
 {
     $this->assertLoggedIn();
     $this->set('area', 'bots');
     try {
         //how do we find them?
         if ($this->args('id')) {
             $bot = new Bot($this->args('id'));
         } else {
             throw new Exception("Could not find that bot.");
         }
         //did we really get someone?
         if (!$bot->isHydrated()) {
             throw new Exception("Could not find that bot.");
         }
         if (!$bot->isMine()) {
             throw new Exception("You cannot view that bot.");
         }
         $this->setTitle('Edit Bot - ' . $bot->getName());
         $wizard = new Wizard('bot', $this->args());
         if (!$this->args('setup')) {
             $wizard->disableWizardMode();
         }
         // Create our forms
         $infoForm = $this->_createInfoForm($bot);
         $queuesForm = $this->_createQueueForm($bot);
         $slicingForm = $this->_createSlicingForm($bot);
         $driverForm = $this->_createDriverForm($bot);
         // Add them to the wizard
         $wizard->add("Information / Details", $infoForm);
         $wizard->add("Queues", $queuesForm);
         $wizard->add("Slicing Setup", $slicingForm);
         $wizard->add("Driver Configuration", $driverForm);
         //handle our forms
         if ($infoForm->checkSubmitAndValidate($this->args())) {
             $bot->set('name', $infoForm->data('name'));
             $bot->set('manufacturer', $infoForm->data('manufacturer'));
             $bot->set('model', $infoForm->data('model'));
             $bot->set('electronics', $infoForm->data('electronics'));
             $bot->set('firmware', $infoForm->data('firmware'));
             $bot->set('extruder', $infoForm->data('extruder'));
             $bot->save();
             Activity::log("edited the information for bot " . $bot->getLink() . ".");
         } else {
             if ($queuesForm->checkSubmitAndValidate($this->args())) {
                 $sql = "DELETE FROM bot_queues WHERE bot_id = ?";
                 db()->execute($sql, array($bot->id));
                 $priority = 1;
                 $used = array();
                 foreach ($this->args() as $key => $value) {
                     if (substr($key, 0, 6) === "queue-" && $value != 0) {
                         if (in_array($value, $used)) {
                             continue;
                         } else {
                             $used[] = $value;
                         }
                         $sql = "INSERT INTO bot_queues VALUES(?, ?, ?)";
                         $data = array($value, $bot->id, $priority);
                         $priority++;
                         db()->execute($sql, $data);
                     }
                 }
             } else {
                 if ($slicingForm->checkSubmitAndValidate($this->args())) {
                     $bot->set('slice_engine_id', $slicingForm->data('slice_engine_id'));
                     $bot->set('slice_config_id', $slicingForm->data('slice_config_id'));
                     $config = $bot->getDriverConfig();
                     $config->can_slice = (bool) $slicingForm->data('can_slice');
                     $bot->set('driver_config', json::encode($config));
                     $bot->save();
                     Activity::log("edited the slicing info for bot " . $bot->getLink() . ".");
                 } else {
                     if ($driverForm->checkSubmitAndValidate($this->args())) {
                         $bot->set('oauth_token_id', $driverForm->data('oauth_token_id'));
                         $bot->set('driver_name', $driverForm->data('driver_name'));
                         //create and save our config
                         $config = $bot->getDriverConfig();
                         $config->driver = $bot->get('driver_name');
                         if ($bot->get('driver_name') == 'dummy') {
                             if ($this->args('delay')) {
                                 $config->delay = $this->args('delay');
                             }
                         } elseif ($bot->get('driver_name') == 'printcore' || $bot->get('driver_name') == 's3g') {
                             $config->port = $this->args('serial_port');
                             $config->port_id = $this->args('port_id');
                             $config->baud = $this->args('baudrate');
                         }
                         //did we get webcam info?
                         if ($this->args('webcam_device')) {
                             if (!isset($config->webcam)) {
                                 $config->webcam = new stdClass();
                             }
                             $config->webcam->device = $this->args('webcam_device');
                             if ($this->args('webcam_id')) {
                                 $config->webcam->id = $this->args('webcam_id');
                             }
                             if ($this->args('webcam_name')) {
                                 $config->webcam->name = $this->args('webcam_name');
                             }
                             if ($this->args('webcam_brightness')) {
                                 $config->webcam->brightness = (int) $this->args('webcam_brightness');
                             }
                             if ($this->args('webcam_contrast')) {
                                 $config->webcam->contrast = (int) $this->args('webcam_contrast');
                             }
                         } else {
                             unset($config->webcam);
                         }
                         //save it all to the bot as json.
                         $bot->set('driver_config', json::encode($config));
                         $bot->save();
                         Activity::log("edited the driver configuration for bot " . $bot->getLink() . ".");
                     }
                 }
             }
         }
         if ($wizard->isFinished()) {
             $this->forwardToURL($bot->getUrl());
         }
         $this->set('bot_id', $bot->id);
         $this->set('wizard', $wizard);
     } catch (Exception $e) {
         $this->set('megaerror', $e->getMessage());
         $this->setTitle("Bot Edit - Error");
     }
 }