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


PHP data_generate_default_template函数代码示例

本文整理汇总了PHP中data_generate_default_template函数的典型用法代码示例。如果您正苦于以下问题:PHP data_generate_default_template函数的具体用法?PHP data_generate_default_template怎么用?PHP data_generate_default_template使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: array

 * Regular expression replacement section *
 ******************************************/
if ($data->addtemplate) {
    $possiblefields = $DB->get_records('data_fields', array('dataid' => $data->id), 'id');
    ///then we generate strings to replace
    foreach ($possiblefields as $eachfield) {
        $field = data_get_field($eachfield, $data);
        $patterns[] = "[[" . $field->field->name . "]]";
        $replacements[] = $field->display_add_field($rid);
        $patterns[] = "[[" . $field->field->name . "#id]]";
        $replacements[] = 'field_' . $field->field->id;
    }
    $newtext = str_ireplace($patterns, $replacements, $data->{$mode});
} else {
    //if the add template is not yet defined, print the default form!
    echo data_generate_default_template($data, 'addtemplate', $rid, true, false);
    $newtext = '';
}
echo $newtext;
echo '<div class="mdl-align"><input type="submit" name="saveandview" value="' . get_string('saveandview', 'data') . '" />';
if ($rid) {
    echo '&nbsp;<input type="submit" name="cancel" value="' . get_string('cancel') . '" onclick="javascript:history.go(-1)" />';
} else {
    if (!$data->maxentries || has_capability('mod/data:manageentries', $context) || data_numentries($data) < $data->maxentries - 1) {
        echo '&nbsp;<input type="submit" value="' . get_string('saveandadd', 'data') . '" />';
    }
}
echo '</div>';
echo $OUTPUT->box_end();
echo '</div></form>';
/// Finish the page
开发者ID:nigeldaley,项目名称:moodle,代码行数:31,代码来源:edit.php

示例2: data_print_template

             data_print_template('singletemplate', $records, $data, $search, $page);
             echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
         } else {
             // List template
             $baseurl = 'view.php?d=' . $data->id . '&amp;';
             //send the advanced flag through the URL so it is remembered while paging.
             $baseurl .= 'advanced=' . $advanced . '&amp;';
             if (!empty($search)) {
                 $baseurl .= 'filter=1&amp;';
             }
             //pass variable to allow determining whether or not we are paging through results.
             $baseurl .= 'paging=' . $paging . '&amp;';
             echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
             if (empty($data->listtemplate)) {
                 echo $OUTPUT->notification(get_string('nolisttemplate', 'data'));
                 data_generate_default_template($data, 'listtemplate', 0, false, false);
             }
             echo $data->listtemplateheader;
             data_print_template('listtemplate', $records, $data, $search, $page);
             echo $data->listtemplatefooter;
             echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
         }
     }
 }
 $search = trim($search);
 if (empty($records)) {
     $records = array();
 }
 if ($mode == '' && !empty($CFG->enableportfolios)) {
     require_once $CFG->libdir . '/portfoliolib.php';
     $button = new portfolio_add_button();
开发者ID:hatone,项目名称:moodle,代码行数:31,代码来源:view.php

示例3: data_print_preference_form


//.........这里部分代码省略.........
    if ($order == 'DESC') {
        echo '<option value="DESC" selected="selected">'.get_string('descending','data').'</option>';
    } else {
        echo '<option value="DESC">'.get_string('descending','data').'</option>';
    }
    echo '</select>';

    if ($advanced) {
        $checked = ' checked="checked" ';
    }
    else {
        $checked = '';
    }
    $PAGE->requires->js('/mod/data/data.js');
    echo '&nbsp;<input type="hidden" name="advanced" value="0" />';
    echo '&nbsp;<input type="hidden" name="filter" value="1" />';
    echo '&nbsp;<input type="checkbox" id="advancedcheckbox" name="advanced" value="1" '.$checked.' onchange="showHideAdvSearch(this.checked);" /><label for="advancedcheckbox">'.get_string('advancedsearch', 'data').'</label>';
    echo '&nbsp;<input type="submit" value="'.get_string('savesettings','data').'" />';

    echo '<br />';
    echo '<div class="dataadvancedsearch" id="data_adv_form" style="display: ';

    if ($advanced) {
        echo 'inline';
    }
    else {
        echo 'none';
    }
    echo ';margin-left:auto;margin-right:auto;" >';
    echo '<table class="boxaligncenter">';

    // print ASC or DESC
    echo '<tr><td colspan="2">&nbsp;</td></tr>';
    $i = 0;

    // Determine if we are printing all fields for advanced search, or the template for advanced search
    // If a template is not defined, use the deafault template and display all fields.
    if(empty($data->asearchtemplate)) {
        data_generate_default_template($data, 'asearchtemplate');
    }

    static $fields = NULL;
    static $isteacher;
    static $dataid = NULL;

    if (empty($dataid)) {
        $dataid = $data->id;
    } else if ($dataid != $data->id) {
        $fields = NULL;
    }

    if (empty($fields)) {
        $fieldrecords = $DB->get_records('data_fields', array('dataid'=>$data->id));
        foreach ($fieldrecords as $fieldrecord) {
            $fields[]= data_get_field($fieldrecord, $data);
        }

        $isteacher = has_capability('mod/data:managetemplates', $context);
    }

    // Replacing tags
    $patterns = array();
    $replacement = array();

    // Then we generate strings to replace for normal tags
    foreach ($fields as $field) {
        $fieldname = $field->field->name;
        $fieldname = preg_quote($fieldname, '/');
        $patterns[] = "/\[\[$fieldname\]\]/i";
        $searchfield = data_get_field_from_id($field->field->id, $data);
        if (!empty($search_array[$field->field->id]->data)) {
            $replacement[] = $searchfield->display_search_field($search_array[$field->field->id]->data);
        } else {
            $replacement[] = $searchfield->display_search_field();
        }
    }
    $fn = !empty($search_array[DATA_FIRSTNAME]->data) ? $search_array[DATA_FIRSTNAME]->data : '';
    $ln = !empty($search_array[DATA_LASTNAME]->data) ? $search_array[DATA_LASTNAME]->data : '';
    $patterns[]    = '/##firstname##/';
    $replacement[] = '<input type="text" size="16" name="u_fn" value="'.$fn.'" />';
    $patterns[]    = '/##lastname##/';
    $replacement[] = '<input type="text" size="16" name="u_ln" value="'.$ln.'" />';

    // actual replacement of the tags
    $newtext = preg_replace($patterns, $replacement, $data->asearchtemplate);

    $options = new stdClass();
    $options->para=false;
    $options->noclean=true;
    echo '<tr><td>';
    echo format_text($newtext, FORMAT_HTML, $options);
    echo '</td></tr>';

    echo '<tr><td colspan="4" style="text-align: center;"><br/><input type="submit" value="'.get_string('savesettings','data').'" /><input type="submit" name="resetadv" value="'.get_string('resetsettings','data').'" /></td></tr>';
    echo '</table>';
    echo '</div>';
    echo '</div>';
    echo '</form>';
    echo '</div>';
}
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:lib.php

示例4: array

                $event = \mod_data\event\template_updated::create(array('context' => $context, 'courseid' => $course->id, 'other' => array('dataid' => $data->id)));
                $event->trigger();
            }
        }
    }
} else {
    echo '<div class="template_heading">' . get_string('header' . $mode, 'data') . '</div>';
}
/// If everything is empty then generate some defaults
if (empty($data->addtemplate) and empty($data->singletemplate) and empty($data->listtemplate) and empty($data->rsstemplate)) {
    data_generate_default_template($data, 'singletemplate');
    data_generate_default_template($data, 'listtemplate');
    data_generate_default_template($data, 'addtemplate');
    data_generate_default_template($data, 'asearchtemplate');
    //Template for advanced searches.
    data_generate_default_template($data, 'rsstemplate');
}
editors_head_setup();
$format = FORMAT_HTML;
if ($mode === 'csstemplate' or $mode === 'jstemplate') {
    $disableeditor = true;
}
if ($disableeditor) {
    $format = FORMAT_PLAIN;
}
$editor = editors_get_preferred_editor($format);
$strformats = format_text_menu();
$formats = $editor->get_supported_formats();
foreach ($formats as $fid) {
    $formats[$fid] = $strformats[$fid];
}
开发者ID:mongo0se,项目名称:moodle,代码行数:31,代码来源:templates.php

示例5: create_field

 /**
  * Creates a field for a mod_data instance.
  * Currently, the field types in the ignoredfieldtypes array aren't supported.
  *
  * @param StdClass $record
  * @param mod_data $data
  * @return data_field_{type}
  */
 public function create_field(stdClass $record = null, $data = null)
 {
     $record = (array) $record;
     if (in_array($record['type'], $this->ignoredfieldtypes)) {
         throw new coding_exception('$record\'s type value must not be same as values in ignoredfieldtypes
                 in phpunit_util::create_field()');
         return false;
     }
     $this->databasefieldcount++;
     if (!isset($data->course)) {
         throw new coding_exception('course must be present in phpunit_util::create_field() $data');
     }
     if (!isset($data->id)) {
         throw new coding_exception('dataid must be present in phpunit_util::create_field() $data');
     } else {
         $record['dataid'] = $data->id;
     }
     if (!isset($record['type'])) {
         throw new coding_exception('type must be present in phpunit_util::create_field() $record');
     }
     if (!isset($record['required'])) {
         $record['required'] = 0;
     }
     if (!isset($record['name'])) {
         $record['name'] = "testField - " . $this->databasefieldcount;
     }
     if (!isset($record['description'])) {
         $record['description'] = " This is testField - " . $this->databasefieldcount;
     }
     if (!isset($record['param1'])) {
         if (in_array($record['type'], array('checkbox', 'menu', 'multimenu', 'radiobutton'))) {
             $record['param1'] = implode("\n", array('one', 'two', 'three', 'four'));
         } else {
             if ($record['type'] === 'text' || $record['type'] === 'url') {
                 $record['param1'] = 1;
             } else {
                 $record['param1'] = '';
             }
         }
     }
     if (!isset($record['param2'])) {
         if ($record['type'] === 'textarea') {
             $record['param2'] = 60;
         } else {
             $record['param2'] = '';
         }
     }
     if (!isset($record['param3'])) {
         if ($record['type'] === 'textarea') {
             $record['param3'] = 35;
         } else {
             $record['param3'] = '';
         }
     }
     if (!isset($record['param4'])) {
         if ($record['type'] === 'textarea') {
             $record['param4'] = 1;
         }
     }
     if (!isset($record['param5'])) {
         if ($record['type'] === 'textarea') {
             $record['param5'] = 0;
         }
     }
     $record = (object) $record;
     $field = data_get_field($record, $data);
     $field->insert_field();
     data_generate_default_template($data, 'addtemplate', 0, false, true);
     return $field;
 }
开发者ID:alexandru-elisei,项目名称:moodle,代码行数:78,代码来源:lib.php

示例6: data_print_preference_form


//.........这里部分代码省略.........
    if ($advanced) {
        $checked = ' checked="checked" ';
    } else {
        $checked = '';
    }
    print '
            
        <script type="text/javascript">
        //<![CDATA[
        <!-- Start
        // javascript for hiding/displaying advanced search form

        function showHideAdvSearch(checked) {
            var divs = document.getElementsByTagName(\'div\');
            for(i=0;i<divs.length;i++) {
                if(divs[i].id.match(\'data_adv_form\')) {
                    if(checked) {
                        divs[i].style.display = \'inline\';
                    }
                    else {
                        divs[i].style.display = \'none\';
                    }
                }
                else if (divs[i].id.match(\'reg_search\')) {
                    if (!checked) {
                        divs[i].style.display = \'inline\';
                    }
                    else {
                        divs[i].style.display = \'none\';
                    }
                }
            }
        }
        //  End -->
        //]]>
        </script>';
    echo '&nbsp;<input type="checkbox" name="advanced" value="1" ' . $checked . ' onchange="showHideAdvSearch(this.checked);" />' . get_string('advancedsearch', 'data');
    echo '&nbsp;<input type="submit" value="' . get_string('savesettings', 'data') . '" />';
    echo '<br />';
    echo '<div class="dataadvancedsearch" id="data_adv_form" style="display: ';
    if ($advanced) {
        echo 'inline';
    } else {
        echo 'none';
    }
    echo ';margin-left:auto;margin-right:auto;" >';
    echo '<table class="boxaligncenter">';
    // print ASC or DESC
    echo '<tr><td colspan="2">&nbsp;</td></tr>';
    $i = 0;
    // Determine if we are printing all fields for advanced search, or the template for advanced search
    // If a template is not defined, use the deafault template and display all fields.
    if (empty($data->asearchtemplate)) {
        data_generate_default_template($data, 'asearchtemplate');
    }
    static $fields = NULL;
    static $isteacher;
    static $dataid = NULL;
    if (empty($dataid)) {
        $dataid = $data->id;
    } else {
        if ($dataid != $data->id) {
            $fields = NULL;
        }
    }
    if (empty($fields)) {
        $fieldrecords = get_records('data_fields', 'dataid', $data->id);
        foreach ($fieldrecords as $fieldrecord) {
            $fields[] = data_get_field($fieldrecord, $data);
        }
        $isteacher = has_capability('mod/data:managetemplates', $context);
    }
    /// Replacing tags
    $patterns = array();
    $replacement = array();
    /// Then we generate strings to replace for normal tags
    foreach ($fields as $field) {
        $patterns[] = '/\\[\\[' . $field->field->name . '\\]\\]/i';
        $searchfield = data_get_field_from_id($field->field->id, $data);
        if (!empty($search_array[$field->field->id]->data)) {
            $replacement[] = $searchfield->display_search_field($search_array[$field->field->id]->data);
        } else {
            $replacement[] = $searchfield->display_search_field();
        }
    }
    ///actual replacement of the tags
    $newtext = preg_replace($patterns, $replacement, $data->asearchtemplate);
    $options = new object();
    $options->para = false;
    $options->noclean = true;
    echo '<tr><td>';
    echo format_text($newtext, FORMAT_HTML, $options);
    echo '</td></tr>';
    echo '<tr><td colspan="4" style="text-align: center;"><br/><input type="submit" value="' . get_string('savesettings', 'data') . '" /><input type="reset" value="' . get_string('resetsettings', 'data') . '" /></td></tr>';
    echo '</table>';
    echo '</div>';
    echo '</div>';
    echo '</form>';
    echo '</div>';
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:lib.php


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