当前位置: 首页>>代码示例>>PHP>>正文


PHP object::createElement方法代码示例

本文整理汇总了PHP中object::createElement方法的典型用法代码示例。如果您正苦于以下问题:PHP object::createElement方法的具体用法?PHP object::createElement怎么用?PHP object::createElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object的用法示例。


在下文中一共展示了object::createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: appendChildren

 /**
  * Convert object to XML.
  * 
  * @param object $doc DOMDocument
  * @param object $parent DOMElement
  * @param string $nodeName name of the node you want to convert to
  * @param array $arrayToConvert array (or 2d array) you are trying to convert
  *
  * Adds one or more properly formatted xml nodes to the parent
  */
 public function appendChildren($doc, $parent, $nodeName, $arrayToConvert)
 {
     if (array_key_exists($nodeName, $arrayToConvert)) {
         //one object was sent.
         $elem = $doc->createElement($nodeName, $arrayToConvert[$nodeName]);
         $parent->appendChild($elem);
         foreach ($arrayToConvert as $key => $val) {
             if ($key != $nodeName) {
                 $attrName = $doc->createAttribute($key);
                 $elem->appendChild($attrName);
                 $attrVal = $doc->createTextNode($val);
                 $attrName->appendChild($attrVal);
             }
         }
     } else {
         //array of objects was sent
         foreach ($arrayToConvert as $key => $val) {
             $elem = $doc->createElement($nodeName, $val[$nodeName]);
             $parent->appendChild($elem);
             foreach ($val as $attrName => $attrVal) {
                 if ($attrName != $nodeName) {
                     $attribute = $doc->createAttribute($attrName);
                     $elem->appendChild($attribute);
                     $attributevalue = $doc->createTextNode($attrVal);
                     $attribute->appendChild($attributevalue);
                 }
             }
         }
     }
 }
开发者ID:electromute,项目名称:gnip-php,代码行数:40,代码来源:GnipDOMDocument.php

示例2: array

 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffle', 'quiz'), null, null, array(0, 1));
     $mform->setHelpButton('shuffleanswers', array('matchshuffle', get_string('shuffle', 'quiz'), 'quiz'));
     $mform->setDefault('shuffleanswers', 1);
     $mform->addElement('static', 'answersinstruct', get_string('choices', 'quiz'), get_string('filloutthreequestions', 'quiz'));
     $mform->closeHeaderBefore('answersinstruct');
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('questionno', 'quiz', '{no}'));
     $repeated[] =& $mform->createElement('textarea', 'subquestions', get_string('question', 'quiz'), array('cols' => 40, 'rows' => 3));
     $repeated[] =& $mform->createElement('text', 'subanswers', get_string('answer', 'quiz'), array('size' => 50));
     if (isset($this->question->options)) {
         $countsubquestions = count($this->question->options->subquestions);
     } else {
         $countsubquestions = 0;
     }
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = QUESTION_NUMANS_START > $countsubquestions + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countsubquestions + QUESTION_NUMANS_ADD;
     } else {
         $repeatsatstart = $countsubquestions;
     }
     $mform->setType('subanswer', PARAM_TEXT);
     $mform->setType('subquestion', PARAM_TEXT);
     $this->repeat_elements($repeated, $repeatsatstart, array(), 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreqblanks', 'qtype_match'));
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:30,代码来源:edit_match_form.php

示例3: array

 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     $mform->addElement('static', 'answersinstruct', get_string('choices', 'quiz'), get_string('filloutthreeitems', 'qtype_order'));
     $mform->closeHeaderBefore('answersinstruct');
     $mform->addElement('advcheckbox', 'horizontal', get_string('horizontal', 'qtype_order'), null, null, array(0, 1));
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('itemno', 'qtype_order', '{no}'));
     // change elements to support htmleditor (nadavkav)
     $repeated[] =& $mform->createElement('htmleditor', 'subquestions', '', array('cols' => 40, 'rows' => 13));
     if (isset($this->question->options)) {
         $countsubquestions = count($this->question->options->subquestions);
     } else {
         $countsubquestions = 0;
     }
     $repeatsatstart = QUESTION_NUMANS_START > $countsubquestions + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countsubquestions + QUESTION_NUMANS_ADD;
     $mform->setType('subquestion', PARAM_TEXT);
     $this->repeat_elements($repeated, $repeatsatstart, array(), 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreqblanks', 'qtype_order'));
     $repeats = optional_param('noanswers', '', PARAM_INT);
     $addfields = optional_param('addanswers', '', PARAM_TEXT);
     if (!empty($addfields)) {
         $repeats += QUESTION_NUMANS_ADD;
     }
     for ($count = 0; $count < $repeats; $count++) {
         $mform->addElement('hidden', 'subanswers[' . $count . ']', $count + 1);
     }
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:edit_order_form.php

示例4: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform) {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name.'_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 5);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name.'_grp');
     }
 }
开发者ID:Burick,项目名称:moodle,代码行数:14,代码来源:text.php

示例5: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('text', '', 'filters'));
     $mform->setDefault($this->_name, $this->_value);
     $mform->setDefault($this->_name . '_op', $this->_operator);
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:14,代码来源:text.php

示例6: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform) {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name .'_rl', null, $this->get_roles());
     $objs[] =& $mform->createElement('select', $this->_name .'_ct', null, $this->get_course_categories());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name.'_grp');
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:14,代码来源:courserole.php

示例7: createElement

 /**
  * Createa an XML element (tag)
  * @param 	string $name 		Name of the element
  * @param  	object $bind 		Parent object to bind the new element to
  * @param   string $value 		The value of the element (if any) 
  * @param  	array  $attributes 	Associative array of tag attributes "attribute" => "value"
  * @return 	The created XML element
  */
 public function createElement($name, $bind, $value = null, $attributes = array())
 {
     $item = $bind->appendChild($this->dom->createElement($name));
     if ($value) {
         $this->addText($value, $item);
     }
     foreach ($attributes as $k => $v) {
         $this->createAttribute($k, $v, $item);
     }
     return $item;
 }
开发者ID:jenwachter,项目名称:data-encoder,代码行数:19,代码来源:DOM.php

示例8: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_rl', null, $this->getRoles());
     $objs[] =& $mform->createElement('select', $this->_name . '_ct', null, $this->getCourseCategories());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $grp->setHelpButton(array('courserole', '', 'filters'));
     $mform->setDefault($this->_name, $this->_value);
     $mform->setDefault($this->_name . '_rl', $this->_roleid);
     $mform->setDefault($this->_name . '_ct', $this->_categoryid);
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:16,代码来源:courserole.php

示例9: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     if (!is_null($this->_offoption)) {
         $objs[] =& $mform->createElement('radio', $this->_name, null, get_string('anyvalue', 'filters'), $this->_offoption);
     }
     foreach ($this->_options as $k => $v) {
         $objs[] =& $mform->createElement('radio', $this->_name, null, $v, $k);
     }
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setDefault($this->_name, $this->_value);
     $grp->setHelpButton(array('radios', '', 'filters'));
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:17,代码来源:radios.php

示例10: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('static', $this->_name . '_sck', null, get_string('isafter', 'filters'));
     $objs[] = $mform->createElement('date_selector', $this->_name . '_sdt', null, array('optional' => true));
     $objs[] = $mform->createElement('static', $this->_name . '_break', null, '<br/>');
     $objs[] = $mform->createElement('static', $this->_name . '_edk', null, get_string('isbefore', 'filters'));
     $objs[] = $mform->createElement('date_selector', $this->_name . '_edt', null, array('optional' => true));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:17,代码来源:date.php

示例11: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name . '_op', null, $this->get_operators());
     $objs[] =& $mform->createElement('select', $this->_name, null, $this->_options);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 0);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:18,代码来源:select.php

示例12: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform)
 {
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_uniqueid . '_op', null, $this->getOperators());
     $objs[] =& $mform->createElement('text', $this->_uniqueid, null);
     $grp =& $mform->addElement('group', $this->_uniqueid . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_uniqueid, PARAM_RAW);
     $mform->addHelpButton($this->_uniqueid . '_grp', $this->_filterhelp[0], $this->_filterhelp[2]);
     // TBV
     $mform->disabledIf($this->_uniqueid, $this->_uniqueid . '_op', 'eq', 5);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_uniqueid . '_grp');
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:18,代码来源:text.php

示例13: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 function setupForm(&$mform) {
     $profile_fields = $this->get_profile_fields();
     if (empty($profile_fields)) {
         return;
     }
     $objs = array();
     $objs[] =& $mform->createElement('select', $this->_name.'_fld', null, $profile_fields);
     $objs[] =& $mform->createElement('select', $this->_name.'_op', null, $this->get_operators());
     $objs[] =& $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name.'_grp');
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:18,代码来源:profilefield.php

示例14: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param object $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs['select'] = $mform->createElement('select', $this->_name . '_op', null, $this->getOperators());
     $objs['text'] = $mform->createElement('text', $this->_name, null);
     $objs['select']->setLabel(get_string('limiterfor', 'filters', $this->_label));
     $objs['text']->setLabel(get_string('valuefor', 'filters', $this->_label));
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_name, PARAM_RAW);
     $mform->disabledIf($this->_name, $this->_name . '_op', 'eq', 5);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:18,代码来源:text.php

示例15: array

 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $QTYPES;
     $menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice'));
     $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu);
     $mform->setDefault('single', 1);
     $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1));
     $mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers', 'qtype_multichoice'), 'quiz'));
     $mform->setDefault('shuffleanswers', 1);
     $numberingoptions = $QTYPES[$this->qtype()]->get_numbering_styles();
     $menu = array();
     foreach ($numberingoptions as $numberingoption) {
         $menu[$numberingoption] = get_string('answernumbering' . $numberingoption, 'qtype_multichoice');
     }
     $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), $menu);
     $mform->setDefault('answernumbering', 'abc');
     /*        $mform->addElement('static', 'answersinstruct', get_string('choices', 'qtype_multichoice'), get_string('fillouttwochoices', 'qtype_multichoice'));
             $mform->closeHeaderBefore('answersinstruct');
     */
     $creategrades = get_grade_options();
     $gradeoptions = $creategrades->gradeoptionsfull;
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('choiceno', 'qtype_multichoice', '{no}'));
     $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 50));
     $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
     $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid));
     if (isset($this->question->options)) {
         $countanswers = count($this->question->options->answers);
     } else {
         $countanswers = 0;
     }
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = max(5, QUESTION_NUMANS_START, $countanswers + QUESTION_NUMANS_ADD);
     } else {
         $repeatsatstart = $countanswers;
     }
     $repeatedoptions = array();
     $repeatedoptions['fraction']['default'] = 0;
     $mform->setType('answer', PARAM_RAW);
     $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice'));
     $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice'));
     $mform->addElement('htmleditor', 'correctfeedback', get_string('correctfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid));
     $mform->setType('correctfeedback', PARAM_RAW);
     $mform->addElement('htmleditor', 'partiallycorrectfeedback', get_string('partiallycorrectfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid));
     $mform->setType('partiallycorrectfeedback', PARAM_RAW);
     $mform->addElement('htmleditor', 'incorrectfeedback', get_string('incorrectfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid));
     $mform->setType('incorrectfeedback', PARAM_RAW);
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:53,代码来源:edit_multichoice_form.php


注:本文中的object::createElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。