Exemplo n.º 1
0
 /**
  * Constructor
  * @param   object    $title   the caption of the form
  * @param   string    $key            the key
  * @param   object    $object         reference to targetobject (@todo, which object will be passed here?)
  */
 function __construct($title, $key, $object)
 {
     parent::__construct($title, ' ');
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_URLLINK_URL));
     $this->addElement(new Xmf_Object_Form_Element_Text($object, 'url_' . $key));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_CAPTION));
     $this->addElement(new Xmf_Object_Form_Element_Text($object, 'caption_' . $key));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_DESC . '<br/>'));
     $this->addElement(new Xmf_Form_Element_Textarea('', 'desc_' . $key, $object->getVar('description')));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_URLLINK_TARGET));
     $targ_val = $object->getVar('target');
     $targetRadio = new Xmf_Form_Element_Radio('', 'target_' . $key, $targ_val != '' ? $targ_val : '_blank');
     $control = $object->getControl('target');
     $targetRadio->addOptionArray($control['options']);
     $this->addElement($targetRadio);
 }
Exemplo n.º 2
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     parent::__construct($var['title'], $key, $object->getVar($key, 'e'));
     // Adding the options inside this SelectBox
     // If the custom method is not from a module, than it's from the core
     $control = $object->getControl($key);
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find out if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the XoopsFormSelect
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!$control['module']) {
                     // Creating the specified core object handler
                     $control_handler =& xoops_gethandler($control['itemHandler']);
                 } else {
                     $control_handler =& xoops_getmodulehandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 // TODO : How could I pass the parameters in the following call ...
                 if ($option_array = $control_handler->{$control}['method']()) {
                     // Adding the options array to the XoopsFormSelect
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @param	string	$caption
  * @param	string	$name
  * @param	string	$value		Pre-selected value, can be "0" (No) or "1" (Yes)
  * @param	string	$yes		String for "Yes"
  * @param	string	$no			String for "No"
  */
 function __construct($caption, $name, $value = null, $yes = _YES, $no = _NO)
 {
     parent::__construct($caption, $name, $value);
     $this->addOption(1, $yes);
     $this->addOption(0, $no);
 }
Exemplo n.º 4
0
 /**
  * Gets a control from the targetobject (@todo, which object will be passed here?)
  *
  * @param	string  $controlName   name of the control element
  * @param	string  $key           key of the form variables in the targetobject
  */
 function getControl($controlName, $key)
 {
     if (!$controlName) {
         $controlName = 'select';
     }
     switch ($controlName) {
         case 'check':
             $control = $this->targetObject->getControl($key);
             $controlObj = new Xmf_Form_Element_Checkbox_Check($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key));
             $controlObj->addOptionArray($control['options']);
             return $controlObj;
             break;
         case 'color':
             $control = $this->targetObject->getControl($key);
             $controlObj = new Xmf_Form_Element_Colorpicker($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key));
             return $controlObj;
             break;
         case 'radio':
             $control = $this->targetObject->getControl($key);
             $controlObj = new Xmf_Form_Element_Radio($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key));
             $controlObj->addOptionArray($control['options']);
             return $controlObj;
             break;
         case 'label':
             return new Xmf_Form_Element_Label($this->targetObject->vars[$key]['title'], $this->targetObject->getVar($key));
             break;
         case 'textarea':
             $form_rows = isset($this->targetObject->controls[$key]['rows']) ? $this->targetObject->controls[$key]['rows'] : 5;
             $form_cols = isset($this->targetObject->controls[$key]['cols']) ? $this->targetObject->controls[$key]['cols'] : 60;
             $editor = new Xmf_Form_Element_Textarea($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key, 'e'), $form_rows, $form_cols);
             if ($this->targetObject->vars[$key]['desc']) {
                 $editor->setDescription($this->targetObject->vars[$key]['desc']);
             }
             return $editor;
             break;
         case 'dhtmltextarea':
             $editor = new Xmf_Form_Element_Textarea_Dhtml($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key, 'e'), 20, 60);
             if ($this->targetObject->vars[$key]['desc']) {
                 $editor->setDescription($this->targetObject->vars[$key]['desc']);
             }
             return $editor;
             break;
         case 'theme':
             return $this->getThemeSelect($key, $this->targetObject->vars[$key]);
         case 'theme_multi':
             return $this->getThemeSelect($key, $this->targetObject->vars[$key], true);
             break;
         case 'timezone':
             return new Xmf_Form_Element_Select_Timezone($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key));
             break;
         case 'group':
             return new Xmf_Form_Element_Select_Group($this->targetObject->vars[$key]['title'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
             break;
         case 'group_multi':
             return new Xmf_Form_Element_Select_Group($this->targetObject->vars[$key]['title'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
             break;
             /*case 'user':
               return new XoopsFormSelectUser($this->targetObject->vars[$key]['title'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
               break;*/
         /*case 'user':
           return new XoopsFormSelectUser($this->targetObject->vars[$key]['title'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
           break;*/
         case 'user_multi':
             return new Xmf_Form_Element_Select_User($this->targetObject->vars[$key]['title'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
             break;
         case 'password':
             return new Xmf_Form_Element_Password($this->targetObject->vars[$key]['title'], $key, 50, 255, $this->targetObject->getVar($key, 'e'));
             break;
         case 'country':
             return new Xmf_Form_Element_Select_Country($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key, 'e'));
             break;
         case 'urllink':
             return new Xmf_Object_Form_Element_Tray_UrlLink($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getUrlLinkObj($key));
             break;
         case 'richfile':
             return new Xmf_Object_Form_Element_Tray_Richfile($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getFileObj($key));
             break;
         case 'source':
         case 'sourceeditor':
             return new Xmf_Form_Element_Textarea_Sourceeditor($this->targetObject->vars[$key]['title'], $key, $this->targetObject->getVar($key, 'e'));
             break;
         case 'hidden':
             return new Xmf_Form_Element_Hidden($key, $this->targetObject->vars[$key]['value']);
             break;
             /*case 'readonly';
               $control =  new Xmf_Form_Element_Hidden($key, $this->targetObject->vars[$key]['value']);
               $control->setExtra('disabled="disabled"');
               $control->setName($key . '-readonly');
               return $control;
               break;*/
         /*case 'readonly';
           $control =  new Xmf_Form_Element_Hidden($key, $this->targetObject->vars[$key]['value']);
           $control->setExtra('disabled="disabled"');
           $control->setName($key . '-readonly');
           return $control;
           break;*/
         default:
             $classname = "Xmf_Object_Form_Element_" . ucfirst($controlName) . "";
             return new $classname($this->targetObject, $key);
             break;
     }
 }