/**
  * Chargement des contrôles via un template de formulaire.
  *
  * @access    private
  * @return    Zend_Form     Objet du formulaire une foix le template parsé et le formulaire initialisé.
  *
  * @author Etienne de Longeaux <*****@*****.**>
  * @since 2012-06-26
  */
 private function setFormByControls()
 {
     //set instance
     $Allgroup = array();
     //         $instance             = $this->_session->_addInstance();
     //         $instanceElement     = $this->_form->createElement('hidden', 'form_instance');
     //         $instanceElement->setValue($instance);
     //         $this->_form->addElement($instanceElement);
     if ($this->_controls) {
         foreach ($this->_controls as $control) {
             $attribs = $control->attributes();
             $id = (string) $attribs['id'];
             $type = (string) $attribs['type'];
             $this->_AllTypesControls[$type] = $type;
             if ($type == "select") {
                 $opts = explode(';', (string) $attribs['opt']);
                 foreach ($opts as $opts => $values) {
                     $v = explode('_', $values);
                     $_o = $v[0];
                     $_v = $v[1];
                     $options[$_o] = $_v;
                 }
             }
             unset($attribs['id']);
             unset($attribs['type']);
             if (isset($attribs['label'])) {
                 $label = (string) $attribs['label'];
                 unset($attribs['label']);
             } else {
                 $label = $id;
                 // $view->getTranslation($id);
                 $label = str_replace('_', '_', $label);
             }
             $elet_attrib = array();
             if (isset($attribs['size'])) {
                 $elet_attrib['size'] = (string) $attribs['size'];
             }
             $control = $this->_form->createElement($type, $id, $elet_attrib);
             $control->setLabel($this->container->get('translator')->trans($label))->addFilter('StripTags')->addFilter('StringTrim');
             if (isset($attribs['desc']) && (string) $attribs['desc'] != '') {
                 $control->setDescription((string) $attribs['desc']);
             }
             if (isset($attribs['required']) && (string) $attribs['required'] == 'true') {
                 $control->setAttrib('required', 'required');
                 $control->setRequired(true);
             }
             if (isset($attribs['pattern'])) {
                 $control->setAttrib('pattern', (string) $attribs['pattern']);
             }
             if (isset($attribs['maxlength'])) {
                 $control->setAttrib('maxlength', (string) $attribs['maxlength']);
             }
             if (isset($attribs['minlength'])) {
                 $control->setAttrib('minlength', (string) $attribs['minlength']);
             }
             if (isset($attribs['data-equals'])) {
                 $control->setAttrib('data-equals', (string) $attribs['data-equals']);
             }
             if (isset($attribs['rows'])) {
                 $control->setAttrib('rows', (string) $attribs['rows']);
             }
             if (isset($attribs['cols'])) {
                 $control->setAttrib('cols', (string) $attribs['cols']);
             }
             if (isset($attribs['width'])) {
                 $control->setAttrib('width', (string) $attribs['width']);
             }
             if (isset($attribs['class']) && (string) $attribs['class'] != '') {
                 $control->setAttrib('class', (string) $attribs['class']);
             }
             if (isset($attribs['step'])) {
                 $control->setAttrib('step', (string) $attribs['step']);
             }
             if ($type == "select") {
                 $control->addMultiOptions($options);
             }
             if (isset($attribs['value'])) {
                 $control->setValue($attribs['value']);
             }
             $control->setAttrib('rel', isset($attribs['group']) ? (string) $attribs['group'] : 'main');
             $this->_form->addElement($control);
             if (isset(self::$_content['DisplayGroup']) && self::$_content['DisplayGroup'] == true) {
                 // set the display group
                 $NameGroup = isset($attribs['group']) ? (string) $attribs['group'] : 'main';
                 //$this->_form->addDisplayGroup(array($id), $NameGroup, array('legend' => 'Role'));
                 if (isset($Allgroup[$NameGroup]) && !empty($Allgroup[$NameGroup])) {
                     $Allgroup[$NameGroup] = array_merge(array($id), $Allgroup[$NameGroup]);
                 } else {
                     $Allgroup[$NameGroup] = array($id);
                 }
             }
         }
     } else {
         throw new \Zend_Exception("Les controls du formulaire n'ont pas pu être chargés !");
     }
     foreach ($Allgroup as $Name => $elements) {
         $elements = array_reverse($elements);
         $this->_form->addDisplayGroup($elements, $Name, array('legend' => 'Role'));
     }
 }
Beispiel #2
0
for ($x = 0; $x <= $aperture / 2; $x = $x + $stepX) {
    $y = $k * pow($x, 2) + $bottom;
    $xd = round($x - 2 * $delta1 * $k * $x / sqrt(1 + pow(2 * $k * $x, 2)), $precX);
    $yd = round($y + $delta1 / sqrt(1 + pow(2 * $k * $x, 2)), $precY);
    if ($y > $height) {
        break;
    }
    $count++;
    addElement($xmldoc, $profile, $result_file, $xd . "\t" . $yd);
    $xda[$count] = $xd * -1;
    $yda[$count] = $yd;
}
addElement($xmldoc, $profile, $result_file, $aperture / 2 - $delta1 . "\t" . ($height + $bottom));
if ($width / 2 > $aperture / 2 - $delta1) {
    addElement($xmldoc, $profile, $result_file, $width / 2 . "\t" . ($height + $bottom));
}
addElement($xmldoc, $profile, $result_file, $width / 2 . "\t" . 0);
addElement($xmldoc, $profile, $result_file, -($width / 2) . "\t" . 0);
if ($width / 2 > $aperture / 2 - $delta1) {
    addElement($xmldoc, $profile, $result_file, -($width / 2) . "\t" . ($height + $bottom));
}
addElement($xmldoc, $profile, $result_file, -($aperture / 2 - $delta1) . "\t" . ($height + $bottom));
for ($count; $count > 0; $count--) {
    addElement($xmldoc, $profile, $result_file, $xda[$count] . "\t" . $yda[$count]);
}
addElement($xmldoc, $profile, $result_file, '#');
addElement($xmldoc, $profile, $result_file, ' 1' . "\t" . '100');
addElement($xmldoc, $profile, $result_file, '#');
$xmldoc->appendChild($profile);
fclose($result_file);
echo $xmldoc->saveXML();
 //	case 'details_course':				showCourseDetails( $option );					break;
 case 'orderup_topic':
     orderTopic($course_id, $topic_ordering, -1);
     break;
 case 'orderdown_topic':
     orderTopic($course_id, $topic_ordering, 1);
     break;
 case 'delete_topic':
     deleteTopic($course_id, $topic_id);
     break;
 case 'add_topic_element':
     $course = new JLMS_Course_HomePage($course_id, true);
     $course->listElements($topic_id);
     break;
 case 'add_submit_topic_element':
     addElement($course_id, $topic_id, $t_id);
     break;
 case 'publish_topic':
     publishTopic($course_id, $topic_id, mosGetParam($_REQUEST, 'state', 0));
     break;
 case 'add_topic':
 case 'edit_topic':
     editTopic($course_id, $topic_id);
     break;
 case 'cancel_topic':
     JLMSRedirect(sefRelToAbs("index.php?option={$option}&task=details_course&id={$course_id}&Itemid={$Itemid}#topic_" . intval(mosGetParam($_REQUEST, 'id', 0))));
     break;
 case 'save_topic':
     saveTopic($course_id);
     break;
 case 'orderup_element':
Beispiel #4
0
function postToXML($post, $setOwnership = FALSE){
  global $DockerUpdate;
  $doc = new DOMDocument('1.0', 'utf-8');
  $doc->preserveWhiteSpace = false;
  $doc->formatOutput = true;
  $root = $doc->createElement('Container');
  $root = $doc->appendChild($root);

  $docName       = $root->appendChild($doc->createElement('Name'));
  if ( isset( $post[ 'Description' ] )) addElement($doc, $root, 'Description', $post[ 'Description' ]);
  if ( isset( $post[ 'Registry' ] ))    addElement($doc, $root, 'Registry', $post[ 'Registry' ]);
  $docRepository = $root->appendChild($doc->createElement('Repository'));
  $BindTime      = $root->appendChild($doc->createElement('BindTime'));
  $Privileged    = $root->appendChild($doc->createElement('Privileged'));
  $Environment   = $root->appendChild($doc->createElement('Environment'));
  $docNetworking = $root->appendChild($doc->createElement('Networking'));
  $Data          = $root->appendChild($doc->createElement('Data'));
  $Version       = $root->appendChild($doc->createElement('Version'));
  $Mode          = $docNetworking->appendChild($doc->createElement('Mode'));
  $Publish       = $docNetworking->appendChild($doc->createElement('Publish'));
  $Name          = preg_replace('/\s+/', '', $post["containerName"]);

  // Editor Values
  if ( isset( $post[ 'WebUI' ] ))  addElement($doc, $root, 'WebUI', $post[ 'WebUI' ]);
  if ( isset( $post[ 'Banner' ] )) addElement($doc, $root, 'Banner', $post[ 'Banner' ]);
  if ( isset( $post[ 'Icon' ] ))   addElement($doc, $root, 'Icon', $post[ 'Icon' ]);

  if ( isset( $post[ 'ExtraParams' ] ))   addElement($doc, $root, 'ExtraParams', $post[ 'ExtraParams' ]);

  $docName->appendChild($doc->createTextNode($Name));
  $docRepository->appendChild($doc->createTextNode($post["Repository"]));
  $BindTime->appendChild($doc->createTextNode((strtolower($post["BindTime"])     == 'on') ? 'true' : 'false'));
  $Privileged->appendChild($doc->createTextNode((strtolower($post["Privileged"]) == 'on') ? 'true' : 'false'));
  $Mode->appendChild($doc->createTextNode(strtolower($post["NetworkType"])));

  for ($i = 0; $i < count($post["hostPort"]); $i++){
    if (! strlen($post["containerPort"][$i])) { continue; }
    $protocol      = $post["portProtocol"][$i];
    $Port          = $Publish->appendChild($doc->createElement('Port'));
    $HostPort      = $Port->appendChild($doc->createElement('HostPort'));
    $ContainerPort = $Port->appendChild($doc->createElement('ContainerPort'));
    $Protocol      = $Port->appendChild($doc->createElement('Protocol'));
    $HostPort->appendChild($doc->createTextNode(trim($post["hostPort"][$i])));
    $ContainerPort->appendChild($doc->createTextNode($post["containerPort"][$i]));
    $Protocol->appendChild($doc->createTextNode($protocol));
  }

  for ($i = 0; $i < count($post["VariableName"]); $i++){
    if (! strlen($post["VariableName"][$i])) { continue; }
    $Variable      = $Environment->appendChild($doc->createElement('Variable'));
    $VariableName  = $Variable->appendChild($doc->createElement('Name'));
    $VariableValue = $Variable->appendChild($doc->createElement('Value'));
    $VariableName->appendChild($doc->createTextNode(trim($post["VariableName"][$i])));
    $VariableValue->appendChild($doc->createTextNode(trim($post["VariableValue"][$i])));
  }

  for ($i = 0; $i < count($post["hostPath"]); $i++){
    if (! strlen($post["hostPath"][$i])) { continue; }
    if (! strlen($post["containerPath"][$i])) { continue; }
    $tmpMode = $post["hostWritable"][$i];
    if ($setOwnership){
      prepareDir($post["hostPath"][$i]);
    }
    $Volume       = $Data->appendChild($doc->createElement('Volume'));
    $HostDir      = $Volume->appendChild($doc->createElement('HostDir'));
    $ContainerDir = $Volume->appendChild($doc->createElement('ContainerDir'));
    $DirMode      = $Volume->appendChild($doc->createElement('Mode'));
    $HostDir->appendChild($doc->createTextNode($post["hostPath"][$i]));
    $ContainerDir->appendChild($doc->createTextNode($post["containerPath"][$i]));
    $DirMode->appendChild($doc->createTextNode($tmpMode));
  }

  $currentVersion = $DockerUpdate->getRemoteVersion($post["Registry"], $post["Repository"]);
  $Version->appendChild($doc->createTextNode($currentVersion));

  return $doc->saveXML();
}