예제 #1
0
 public function add($param = "")
 {
     global $myAdmin;
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     $this->LANG_DATAS = $myAdmin->LANG_DATAS;
     parent::add();
     $smarty->assign('this', $this);
     $smarty->assign('param', $param);
     $smarty->assign('language', $thisSite->LIST_LANG_COMP[$myAdmin->LANG_INTERFACE]);
     $toolbars = array();
     $toolbars["Default"][1] = "cut copy paste pastetext | undo redo | bold italic underline strikethrough | subscript superscript | removeformat | charmap emoticons hr nonbreaking";
     $toolbars["Default"][2] = "bullist numlist | outdent indent | alignleft aligncenter alignright alignjustify | image | inserttable tableprops deletetable cell row column | link unlink | anchor  | template  | visualblocks | code";
     $toolbars["Default"][3] = "styleselect  fontselect fontsizeselect | forecolor backcolor";
     $toolbars["Basic"][1] = "bold italic underline strikethrough | subscript superscript | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent";
     $toolbars["Basic"][2] = "styleselect | link unlink | image charmap | code";
     $toolbars["Simple"][1] = "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist | link unlink | image charmap | code";
     $toolbars["Image"][1] = "image | code";
     $smarty->assign('toolbar', $toolbars[$this->toolbar]);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.editortm.tpl');
     addStructure("addJsStructure", DOS_OUTILS_ADMIN . "tinymceJQ/jquery.tinymce.min.js");
     addStructure("addJsStructure", DOS_OUTILS_ADMIN . "tinymceJQ/tinymce.min.js");
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #2
0
 public function add($param = "")
 {
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     $smarty->assign('this', $this);
     $rangeLg = array();
     foreach ($this->list_lang as $clg => $extlg) {
         $value = $this->getValue($clg);
         $values = explode(",", $value);
         if (count($values) == 2) {
             $range = 1;
         } else {
             if (count($values) == 1) {
                 $range = 0;
             } else {
                 return false;
             }
         }
         $rangeLg[$clg] = $range;
     }
     $smarty->assign('rangeLg', $rangeLg);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.slider.tpl');
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #3
0
 public function add($param = "")
 {
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     $smarty->assign('this', $this);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.file.tpl');
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #4
0
 public function add($param = "")
 {
     global $myAdmin;
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     $smarty->assign('this', $this);
     $smarty->assign('param', $param);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.editorck.tpl');
     addStructure("addJsStructure", DOS_OUTILS_ADMIN . "ckeditor/ckeditor.js");
     addStructure("addJsStructure", DOS_OUTILS_ADMIN . "ckeditor/adapters/jquery.js");
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #5
0
 public function add($param = "")
 {
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     $smarty->assign('this', $this);
     $liste = array();
     for ($indice = $this->max; $indice >= 1; $indice--) {
         //for ($indice = 1; $indice <= $this->max; $indice++) {
         $liste[] = $indice;
     }
     $smarty->assign('liste', $liste);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.rating.tpl');
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #6
0
 public function add($param = "")
 {
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     $smarty->assign('this', $this);
     $src_valueLg = array();
     foreach ($this->list_lang as $clg => $extlg) {
         $value = $this->getValue($clg);
         $src_value = format_date($value, ".");
         $src_valueLg[$clg] = $src_value;
     }
     $smarty->assign('src_valueLg', $src_valueLg);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.date.tpl');
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #7
0
 public function add($param = "")
 {
     global $myAdmin;
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     if ($this->insideForm == false) {
         $this->fileRequired = true;
         $this->legendeEnabled = true;
     }
     if ($this->insideForm == true) {
         $prefixe_field = $this->field . "__";
         $mySelect = new mySelect(__FILE__);
         $mySelect->tables = $thisSite->PREFIXE_TBL_GEN . "medias";
         $mySelect->fields = "*";
         $mySelect->orderby = "id DESC";
         // pour prendre le premier élément
         $mySelect->where = "field_media=:field_media AND id_parent=:id_parent";
         $mySelect->whereValue["field_media"] = array($this->field, PDO::PARAM_STR);
         //$formMaj->tables . "." .
         $id_parent = $formMaj->datasForm[$myAdmin->LANG_DATAS]["id"];
         if ($id_parent == "") {
             $id_parent = $formMaj->datasForm[""]["id"];
         }
         $mySelect->whereValue["id_parent"] = array($id_parent, PDO::PARAM_INT);
         $resultmySelect = $mySelect->query();
         foreach ($resultmySelect as $rowS) {
             $lg = $rowS["lg"];
             $value_fichier_media[$lg] = $rowS["fichier_media"];
             $value_titre_media[$lg] = $rowS["titre_media"];
             if ($lg == $myAdmin->LANG_DEF) {
                 // pour les données monolangue
                 $value_idMedia = $rowS["id"];
                 $value_fichier_media[""] = $rowS["fichier_media"];
                 $value_titre_media[""] = $rowS["titre_media"];
             }
         }
     } else {
         $prefixe_field = "";
     }
     $newfield = new file();
     $newfield->field = $prefixe_field . "fichier_media";
     $newfield->multiLang = $this->multiLangType;
     if ($this->insideForm == true) {
         $newfield->label = $this->label;
     } else {
         $newfield->label = $datas_lang["fichier_media"];
     }
     $newfield->value = $value_fichier_media;
     $newfield->startFolder = $this->startFolder;
     $newfield->tooltip = $this->tooltip;
     $newfield->addClass = $this->addClass;
     $newfield->extensionsAuthorized = "";
     if ($this->extensionsAuthorized != "") {
         $newfield->extensionsAuthorized = $this->extensionsAuthorized;
     }
     $newfield->multi = $this->multi;
     $newfield->upload = $this->upload;
     $newfield->uploadDirect = $this->uploadDirect;
     $newfield->widthLabel = 2;
     $newfield->widthField = 9;
     $newfield->placeholder = $this->placeholder;
     $result = $newfield->add();
     $field_fichier_media = $result;
     if ($this->fileRequired == true) {
         $newfield->rule("required", true);
     }
     // champ Titre: légende de l'image, du fichier ou du lien
     if ($this->legendeEnabled == true) {
         $newfield = new input();
         $newfield->field = $prefixe_field . "titre_media";
         $newfield->multiLang = true;
         $newfield->value = $value_titre_media;
         $newfield->label = $datas_lang["legende"];
         $newfield->tooltip = $datas_lang["tooltipsLegende"];
         $newfield->widthLabel = 2;
         $newfield->widthField = 9;
         $result = $newfield->add();
         $field_titre_media = $result;
     }
     $smarty->assign('field_fichier_media', $field_fichier_media);
     $smarty->assign('field_titre_media', $field_titre_media);
     if ($this->insideForm == true) {
         $newfield = new hidden();
         $newfield->field = "fieldMedia__" . $this->field;
         $newfield->multiLang = false;
         $newfield->value = serialize(array("type" => $this->type, "field_media" => $this->field, "idMedia" => $value_idMedia));
         $result = $newfield->add();
         $smarty->assign('fieldMediaField', $result);
     }
     $smarty->assign('this', $this);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.mediaFile.tpl');
     if ($this->insideForm == true) {
         $this->smartAssign($this->field, $data);
     } else {
         $this->smartAssign("media", $data);
     }
     return $data;
 }
예제 #8
0
 public function add($param = "")
 {
     if (!is_array($this->items) && $this->tags != true) {
         return 0;
     }
     global $myAdmin;
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     if ($this->tags == true) {
         $this->multiLang = false;
         // multilangue géré par la table des tags
     }
     $this->LIST_LANG_EXTENSION_FIELD = $myAdmin->LIST_LANG_EXTENSION_FIELD;
     parent::add();
     $smarty->assign('this', $this);
     $listDisabled = array();
     if (!is_array($this->valuesDisabled)) {
         $valuesDisabled = explode(",", $this->valuesDisabled);
         $listDisabled = $valuesDisabled;
     } else {
         $listDisabled = $this->valuesDisabled;
     }
     foreach ($this->list_lang as $clg => $extlg) {
         $value = $this->getValue($clg);
         $values = explode(",", $value);
         if (!is_array($values)) {
             $values = array();
         }
         if ($this->tags == true) {
             if ($listItems == "") {
                 $listItems = array();
                 $mySelect2 = new mySelect(__FILE__);
                 $mySelect2->tables = $thisSite->PREFIXE_TBL_GEN . "tags";
                 $mySelect2->fields = "*";
                 $mySelect2->where = "parent=:parent AND lg=:lg";
                 $mySelect2->whereValue["parent"] = array($this->field, PDO::PARAM_STR);
                 $mySelect2->whereValue["lg"] = array("fr", PDO::PARAM_STR);
                 $mySelect2->orderby = "titre ASC";
                 $result2 = $mySelect2->query();
                 foreach ($result2 as $row2) {
                     $listItems[$row2['id']] = $row2['titre'];
                 }
             }
         } else {
             $listItems = $this->items;
         }
         if ($this->iconeLangue() == true || $this->tags == true) {
             $smarty->assign('marginLeft', 50);
         } else {
             $smarty->assign('marginLeft', 0);
         }
         $indice = 0;
         $datasItem = array();
         $count_items = count($listItems);
         $myGroup = "";
         foreach ($listItems as $val => $text) {
             $val = delQuotes($val);
             $value = delQuotes($value);
             if (in_array($val, $listDisabled)) {
                 $stateDisabled = "state-disabled";
                 $disabled = "disabled";
             } else {
                 $stateDisabled = "";
                 $disabled = "";
             }
             if (in_array(htmlspecialchars($val, ENT_QUOTES), $values)) {
                 $selected = "selected";
             } else {
                 $selected = "";
             }
             if ($count_items == 1) {
                 $str_indice = "";
             } else {
                 $str_indice = "_" . $indice;
             }
             $idField = $this->field . $extlg . $str_indice;
             $datasItem[$indice] = array("val" => $val, "text" => $text, "idField" => $idField, "stateDisabled" => $stateDisabled, "disabled" => $disabled, "selected" => $selected);
             $myGroup = $idField;
             $indice++;
             $marginLeft = 0;
         }
         //echoa($datasItem);
         $datasItemByLg[$clg] = $datasItem;
     }
     // lg
     $smarty->assign('datasItemByLg', $datasItemByLg);
     $allmyGroup = $smarty->getTemplateVars("myGroup");
     $allmyGroup .= $this->field . $extlg . ":\"" . $myGroup . "\",\n";
     $smarty->assign("myGroup", $allmyGroup);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.selectM.tpl');
     addStructure("addJsStructure", DOS_OUTILS_ADMIN . "multiple-select/jquery.multiple.select.js");
     $this->smartAssign($this->field, $data);
     return $data;
 }
예제 #9
0
 public function add($param = "")
 {
     if (!is_array($this->items)) {
         return 0;
     }
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     $smarty->assign('this', $this);
     $smarty->assign('classPlus', "inline-group");
     $listDisabled = array();
     if (!is_array($this->valuesDisabled)) {
         $valuesDisabled = explode(",", $this->valuesDisabled);
         $listDisabled = $valuesDisabled;
     } else {
         $listDisabled = $this->valuesDisabled;
     }
     $listItemsByLg = array();
     foreach ($this->list_lang as $clg => $extlg) {
         $value = $this->getValue($clg);
         $listItems = array();
         if (isset($this->noneItem)) {
             if ($this->noneItem === true) {
                 $listItems["noneItem"] = $datas_lang["noneItem"];
             } else {
                 $listItems["noneItem"] = $this->noneItem;
             }
         }
         if (isset($this->allItems)) {
             if ($this->allItems === true) {
                 $listItems["allItems"] = $datas_lang["allItems"];
             } else {
                 $listItems["allItems"] = $this->allItems;
             }
         }
         $listItems += $this->items;
         if ($this->iconeLangue() == true) {
             $marginLeft = 50;
         } else {
             $marginLeft = 0;
         }
         $indice = 0;
         $datasItem = array();
         foreach ($listItems as $val => $text) {
             $val = delQuotes($val);
             $value = delQuotes($value);
             if (in_array($val, $listDisabled)) {
                 $stateDisabled = "state-disabled";
                 $disabled = "disabled";
             } else {
                 $stateDisabled = "";
                 $disabled = "";
             }
             if (htmlspecialchars($val, ENT_QUOTES) == $value) {
                 $checked = "checked";
             } else {
                 $checked = "";
             }
             $idField = $this->field . $extlg . "_" . $indice;
             $datasItem[$indice] = array("val" => $val, "text" => $text, "idField" => $idField, "stateDisabled" => $stateDisabled, "disabled" => $disabled, "checked" => $checked, "marginLeft" => $marginLeft);
             $indice++;
             $marginLeft = 0;
         }
         //echoa($datasItem);
         $datasItemByLg[$clg] = $datasItem;
     }
     // lg
     $smarty->assign('datasItemByLg', $datasItemByLg);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.radio.tpl');
     $this->smartAssign($this->field, $data);
     return $data;
 }
 function action_editfield()
 {
     global $CURMAN;
     $level = $this->required_param('level', PARAM_ACTION);
     $ctxlvl = context_level_base::get_custom_context_level($level, 'block_curr_admin');
     if (!$ctxlvl) {
         print_error('invalid_context_level', 'block_curr_admin');
     }
     $id = $this->optional_param('id', NULL, PARAM_INT);
     require_once CURMAN_DIRLOCATION . '/form/customfieldform.class.php';
     $tmppage = new customfieldpage(array('level' => $level, 'action' => 'editfield'), $this);
     $form = new customfieldform($tmppage->get_moodle_url(), $this);
     if ($form->is_cancelled()) {
         $tmppage = new customfieldpage(array('level' => $level));
         redirect($tmppage->get_url(), get_string('edit_cancelled', 'block_curr_admin'));
     } else {
         if ($data = $form->get_data()) {
             $field = new field($data);
             if ($id) {
                 $field->id = $id;
                 $field->update();
             } else {
                 $field->add();
                 // assume each field only belongs to one context level (for now)
                 $fieldcontext = new field_contextlevel();
                 $fieldcontext->fieldid = $field->id;
                 $fieldcontext->contextlevel = $ctxlvl;
                 $fieldcontext->add();
             }
             //don't use !empty here because we might be storing a 0 or similar value
             if ($data->defaultdata != '') {
                 // save the default value
                 $defaultdata = $data->defaultdata;
                 if ($field->multivalued) {
                     // parse as a CSV string
                     // until we can use str_getcsv from PHP 5.3...
                     $temp = fopen("php://memory", "rw");
                     fwrite($temp, $defaultdata);
                     rewind($temp);
                     $defaultdata = fgetcsv($temp);
                     fclose($temp);
                 }
                 field_data::set_for_context_and_field(NULL, $field, $defaultdata);
             } else {
                 if ($field->multivalued) {
                     field_data::set_for_context_and_field(NULL, $field, array());
                 } else {
                     field_data::set_for_context_and_field(NULL, $field, NULL);
                 }
             }
             $plugins = get_list_of_plugins('curriculum/plugins');
             foreach ($plugins as $plugin) {
                 if (is_readable(CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php')) {
                     include_once CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php';
                     if (function_exists("{$plugin}_field_save_form_data")) {
                         call_user_func("{$plugin}_field_save_form_data", $form, $field, $data);
                     }
                 }
             }
             $tmppage = new customfieldpage(array('level' => $level));
             redirect($tmppage->get_url(), get_string('field_saved', 'block_curr_admin', $field));
         } else {
             if (!empty($id)) {
                 if ($this->optional_param('from', NULL, PARAM_CLEAN) == 'moodle' && $level == 'user') {
                     $moodlefield = $CURMAN->db->get_record('user_info_field', 'id', $id);
                     if (!$moodlefield) {
                         print_error('invalidfieldid', 'block_curr_admin');
                     }
                     unset($moodlefield->id);
                     $data_array = (array) $moodlefield;
                     $data_array['datatype'] = 'text';
                     $data_array['manual_field_control'] = $moodlefield->datatype;
                     switch ($moodlefield->datatype) {
                         case field::checkbox:
                             $data_array['datatype'] = 'bool';
                             break;
                         case field::menu:
                             $data_array['datatype'] = 'char';
                             $data_array['manual_field_options'] = $moodlefield->param1;
                             break;
                         case field::textarea:
                             $data_array['manual_field_columns'] = $moodlefield->param1;
                             $data_array['manual_field_rows'] = $moodlefield->param2;
                             break;
                         case field::text:
                             if ($moodlefield->param3) {
                                 $data_array['manual_field_control'] = 'password';
                             }
                             $data_array['manual_field_columns'] = $moodlefield->param1;
                             $data_array['manual_field_maxlength'] = $moodlefield->param2;
                             break;
                     }
                 } else {
                     $data = new field($id);
                     $data_array = $data->to_array();
                     $defaultdata = field_data::get_for_context_and_field(NULL, $data);
                     if (!empty($defaultdata)) {
                         if ($data->multivalued) {
                             $values = array();
                             // extract the data
                             foreach ($defaultdata as $data) {
                                 $values[] = $data->data;
                             }
                             // represent as a CSV string
                             $fh = fopen("php://memory", "rw");
                             fputcsv($fh, $values);
                             rewind($fh);
                             $defaultdata = fgets($fh);
                             fclose($fh);
                         } else {
                             $defaultdata = current($defaultdata);
                             $defaultdata = $defaultdata->data;
                         }
                     }
                     $data_array['defaultdata'] = $defaultdata;
                     $plugins = get_list_of_plugins('curriculum/plugins');
                     foreach ($plugins as $plugin) {
                         if (is_readable(CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php')) {
                             include_once CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php';
                             if (function_exists("{$plugin}_field_get_form_data")) {
                                 $data_array += call_user_func("{$plugin}_field_get_form_data", $form, $data);
                             }
                         }
                     }
                 }
                 $form->set_data($data_array);
             }
             $form->display();
         }
     }
 }