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


PHP portfolio_instance_sanity_check函数代码示例

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


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

示例1: definition

 /**
  * prepare form
  */
 public function definition()
 {
     global $CFG;
     $this->plugin = $this->_customdata['plugin'];
     $this->instance = isset($this->_customdata['instance']) && is_subclass_of($this->_customdata['instance'], 'portfolio_plugin_base') ? $this->_customdata['instance'] : null;
     $this->portfolio = $this->_customdata['portfolio'];
     $this->action = $this->_customdata['action'];
     $this->visible = $this->_customdata['visible'];
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'pf', $this->portfolio);
     $mform->setType('pf', PARAM_ALPHA);
     $mform->addElement('hidden', 'action', $this->action);
     $mform->setType('action', PARAM_ALPHA);
     $mform->addElement('hidden', 'visible', $this->visible);
     $mform->setType('visible', PARAM_INT);
     $mform->addElement('hidden', 'plugin', $this->plugin);
     $mform->setType('plugin', PARAM_PLUGIN);
     if (!$this->instance) {
         $insane = portfolio_instance_sanity_check($this->instance);
     } else {
         $insane = portfolio_plugin_sanity_check($this->plugin);
     }
     if (isset($insane) && is_array($insane)) {
         $insane = array_shift($insane);
     }
     if (isset($insane) && is_string($insane)) {
         // something went wrong, warn...
         $mform->addElement('warning', 'insane', null, get_string($insane, 'portfolio_' . $this->plugin));
     }
     $mform->addElement('text', 'name', get_string('name'), 'maxlength="100" size="30"');
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     // let the plugin add the fields they want (either statically or not)
     if (portfolio_static_function($this->plugin, 'has_admin_config')) {
         if (!$this->instance) {
             require_once $CFG->libdir . '/portfolio/plugin.php';
             require_once $CFG->dirroot . '/portfolio/' . $this->plugin . '/lib.php';
             call_user_func(array('portfolio_plugin_' . $this->plugin, 'admin_config_form'), $mform);
         } else {
             $this->instance->admin_config_form($mform);
         }
     }
     // and set the data if we have some.
     if ($this->instance) {
         $data = array('name' => $this->instance->get('name'));
         foreach ($this->instance->get_allowed_config() as $config) {
             $data[$config] = $this->instance->get_config($config);
         }
         $this->set_data($data);
     } else {
         $this->set_data(array('name' => portfolio_static_function($this->plugin, 'get_name')));
     }
     $this->add_action_buttons(true, get_string('save', 'portfolio'));
 }
开发者ID:nmicha,项目名称:moodle,代码行数:57,代码来源:forms.php

示例2: to_html

 public function to_html($format = null, $addstr = null)
 {
     global $CFG, $COURSE, $OUTPUT, $USER;
     if (!$this->is_renderable()) {
         return;
     }
     if (empty($this->callbackclass) || empty($this->callbackfile)) {
         throw new portfolio_button_exception('mustsetcallbackoptions', 'portfolio');
     }
     if (empty($this->formats)) {
         // use the caller defaults
         $this->set_formats();
     }
     $url = new moodle_url('/portfolio/add.php');
     foreach ($this->callbackargs as $key => $value) {
         if (!empty($value) && !is_string($value) && !is_numeric($value)) {
             $a = new stdClass();
             $a->key = $key;
             $a->value = print_r($value, true);
             debugging(get_string('nonprimative', 'portfolio', $a));
             return;
         }
         $url->param('ca_' . $key, $value);
     }
     $url->param('sesskey', sesskey());
     $url->param('callbackfile', $this->callbackfile);
     $url->param('callbackclass', $this->callbackclass);
     $url->param('course', !empty($COURSE) ? $COURSE->id : 0);
     $url->param('callerformats', implode(',', $this->formats));
     $mimetype = null;
     if ($this->file instanceof stored_file) {
         $mimetype = $this->file->get_mimetype();
     } else {
         if ($this->intendedmimetype) {
             $mimetype = $this->intendedmimetype;
         }
     }
     $selectoutput = '';
     if (count($this->instances) == 1) {
         $tmp = array_values($this->instances);
         $instance = $tmp[0];
         $formats = portfolio_supported_formats_intersect($this->formats, $instance->supported_formats());
         if (count($formats) == 0) {
             // bail. no common formats.
             //debugging(get_string('nocommonformats', 'portfolio', (object)array('location' => $this->callbackclass, 'formats' => implode(',', $this->formats))));
             return;
         }
         if ($error = portfolio_instance_sanity_check($instance)) {
             // bail, plugin is misconfigured
             //debugging(get_string('instancemisconfigured', 'portfolio', get_string($error[$instance->get('id')], 'portfolio_' . $instance->get('plugin'))));
             return;
         }
         if (!$instance->allows_multiple_exports() && ($already = portfolio_existing_exports($USER->id, $instance->get('plugin')))) {
             //debugging(get_string('singleinstancenomultiallowed', 'portfolio'));
             return;
         }
         if ($mimetype && !$instance->file_mime_check($mimetype)) {
             // bail, we have a specific file or mimetype and this plugin doesn't support it
             //debugging(get_string('mimecheckfail', 'portfolio', (object)array('plugin' => $instance->get('plugin'), 'mimetype' => $mimetype)));
             return;
         }
         $url->param('instance', $instance->get('id'));
     } else {
         if (!($selectoutput = portfolio_instance_select($this->instances, $this->formats, $this->callbackclass, $mimetype, 'instance', true))) {
             return;
         }
     }
     // if we just want a url to redirect to, do it now
     if ($format == PORTFOLIO_ADD_FAKE_URL) {
         return $url->out(false);
     }
     if (empty($addstr)) {
         $addstr = get_string('addtoportfolio', 'portfolio');
     }
     if (empty($format)) {
         $format = PORTFOLIO_ADD_FULL_FORM;
     }
     $formoutput = '<form method="post" action="' . $CFG->wwwroot . '/portfolio/add.php" id="portfolio-add-button">' . "\n";
     $formoutput .= html_writer::input_hidden_params($url);
     $linkoutput = '<a class="portfolio-add-link" title="' . $addstr . '" href="' . $url->out();
     switch ($format) {
         case PORTFOLIO_ADD_FULL_FORM:
             $formoutput .= $selectoutput;
             $formoutput .= "\n" . '<input type="submit" value="' . $addstr . '" />';
             $formoutput .= "\n" . '</form>';
             break;
         case PORTFOLIO_ADD_ICON_FORM:
             $formoutput .= $selectoutput;
             $formoutput .= "\n" . '<input class="portfolio-add-icon" type="image" src="' . $OUTPUT->pix_url('t/portfolioadd') . '" alt=' . $addstr . '" />';
             $formoutput .= "\n" . '</form>';
             break;
         case PORTFOLIO_ADD_ICON_LINK:
             $linkoutput .= '"><img class="portfolio-add-icon" src="' . $OUTPUT->pix_url('t/portfolioadd') . '" alt="' . $addstr . '" /></a>';
             break;
         case PORTFOLIO_ADD_TEXT_LINK:
             $linkoutput .= '">' . $addstr . '</a>';
             break;
         default:
             debugging(get_string('invalidaddformat', 'portfolio', $format));
     }
//.........这里部分代码省略.........
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:101,代码来源:portfoliolib.php

示例3: to_html

 public function to_html($format = null, $addstr = null)
 {
     if ($this->alreadyexporting) {
         return $this->already_exporting($format, $addstr);
     }
     global $CFG, $COURSE, $OUTPUT;
     if (!$this->is_renderable()) {
         return;
     }
     if (empty($this->callbackclass) || empty($this->callbackfile)) {
         throw new portfolio_button_exception('mustsetcallbackoptions', 'portfolio');
     }
     if (empty($this->formats)) {
         // use the caller defaults
         $this->set_formats();
     }
     $formoutput = '<form method="post" action="' . $CFG->wwwroot . '/portfolio/add.php" id="portfolio-add-button">' . "\n";
     $linkoutput = '<a href="' . $CFG->wwwroot . '/portfolio/add.php?';
     foreach ($this->callbackargs as $key => $value) {
         if (!empty($value) && !is_string($value) && !is_numeric($value)) {
             $a->key = $key;
             $a->value = print_r($value, true);
             debugging(get_string('nonprimative', 'portfolio', $a));
             return;
         }
         $linkoutput .= 'ca_' . $key . '=' . $value . '&amp;';
         $formoutput .= "\n" . '<input type="hidden" name="ca_' . $key . '" value="' . $value . '" />';
     }
     $formoutput .= "\n" . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
     $linkoutput .= 'sesskey=' . sesskey() . '&amp;';
     $formoutput .= "\n" . '<input type="hidden" name="callbackfile" value="' . $this->callbackfile . '" />';
     $formoutput .= "\n" . '<input type="hidden" name="callbackclass" value="' . $this->callbackclass . '" />';
     $formoutput .= "\n" . '<input type="hidden" name="course" value="' . (!empty($COURSE) ? $COURSE->id : 0) . '" />';
     $linkoutput .= 'callbackfile=' . $this->callbackfile . '&amp;callbackclass=' . $this->callbackclass . '&amp;course=' . (!empty($COURSE) ? $COURSE->id : 0);
     $selectoutput = '';
     if (count($this->instances) == 1) {
         $tmp = array_values($this->instances);
         $instance = $tmp[0];
         //$instance = array_shift($this->instances);
         $formats = portfolio_supported_formats_intersect($this->formats, $instance->supported_formats());
         if (count($formats) == 0) {
             // bail. no common formats.
             debugging(get_string('nocommonformats', 'portfolio', $this->callbackclass));
             return;
         }
         if ($error = portfolio_instance_sanity_check($instance)) {
             // bail, plugin is misconfigured
             debugging(get_string('instancemisconfigured', 'portfolio', get_string($error[$instance->get('id')], 'portfolio_' . $instance->get('plugin'))));
             return;
         }
         $formoutput .= "\n" . '<input type="hidden" name="instance" value="' . $instance->get('id') . '" />';
         $linkoutput .= '&amp;instance=' . $instance->get('id');
     } else {
         $selectoutput = portfolio_instance_select($this->instances, $this->formats, $this->callbackclass, 'instance', true);
     }
     if (empty($addstr)) {
         $addstr = get_string('addtoportfolio', 'portfolio');
     }
     if (empty($format)) {
         $format = PORTFOLIO_ADD_FULL_FORM;
     }
     switch ($format) {
         case PORTFOLIO_ADD_FULL_FORM:
             $formoutput .= $selectoutput;
             $formoutput .= "\n" . '<input type="submit" value="' . $addstr . '" />';
             $formoutput .= "\n" . '</form>';
             break;
         case PORTFOLIO_ADD_ICON_FORM:
             $formoutput .= $selectoutput;
             $formoutput .= "\n" . '<input type="image" src="' . $OUTPUT->old_icon_url('t/portfolio') . '" alt=' . $addstr . '" />';
             $formoutput .= "\n" . '</form>';
             break;
         case PORTFOLIO_ADD_ICON_LINK:
             $linkoutput .= '"><img src="' . $OUTPUT->old_icon_url('t/portfolio') . '" alt=' . $addstr . '" /></a>';
             break;
         case PORTFOLIO_ADD_TEXT_LINK:
             $linkoutput .= '">' . $addstr . '</a>';
             break;
         default:
             debugging(get_string('invalidaddformat', 'portfolio', $format));
     }
     $output = in_array($format, array(PORTFOLIO_ADD_FULL_FORM, PORTFOLIO_ADD_ICON_FORM)) ? $formoutput : $linkoutput;
     return $output;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:84,代码来源:portfoliolib.php

示例4: output_html

 /**
  * Builds XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string XHTML to display the control
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $OUTPUT;
     $output = $OUTPUT->box_start('generalbox');
     $namestr = get_string('name');
     $pluginstr = get_string('plugin', 'portfolio');
     $plugins = get_plugin_list('portfolio');
     $plugins = array_keys($plugins);
     $instances = portfolio_instances(false, false);
     $alreadyplugins = array();
     // to avoid notifications being sent out while admin is editing the page
     define('ADMIN_EDITING_PORTFOLIO', true);
     $insane = portfolio_plugin_sanity_check($plugins);
     $insaneinstances = portfolio_instance_sanity_check($instances);
     $output .= portfolio_report_insane($insane, null, true);
     $output .= portfolio_report_insane($insaneinstances, $instances, true);
     $table = new html_table();
     $table->head = array($namestr, $pluginstr, '');
     $table->data = array();
     foreach ($instances as $i) {
         $row = '';
         $row .= '<a href="' . $this->baseurl . '&edit=' . $i->get('id') . '"><img src="' . $OUTPUT->old_icon_url('t/edit') . '" alt="' . get_string('edit') . '" /></a>' . "\n";
         $row .= '<a href="' . $this->baseurl . '&delete=' . $i->get('id') . '"><img src="' . $OUTPUT->old_icon_url('t/delete') . '" alt="' . get_string('delete') . '" /></a>' . "\n";
         if (array_key_exists($i->get('plugin'), $insane) || array_key_exists($i->get('id'), $insaneinstances)) {
             $row .= '<img src="' . $OUTPUT->old_icon_url('t/show') . '" alt="' . get_string('hidden', 'portfolio') . '" />' . "\n";
         } else {
             $row .= ' <a href="' . $this->baseurl . '&hide=' . $i->get('id') . '"><img src="' . $OUTPUT->old_icon_url('t/' . ($i->get('visible') ? 'hide' : 'show')) . '" alt="' . get_string($i->get('visible') ? 'hide' : 'show') . '" /></a>' . "\n";
         }
         $table->data[] = array($i->get('name'), $i->get_name() . ' (' . $i->get('plugin') . ')', $row);
         if (!in_array($i->get('plugin'), $alreadyplugins)) {
             $alreadyplugins[] = $i->get('plugin');
         }
     }
     $output .= $OUTPUT->table($table);
     $instancehtml = '<br /><br />' . get_string('addnewportfolio', 'portfolio') . ': <br /><br />';
     $addable = 0;
     foreach ($plugins as $p) {
         if (!portfolio_static_function($p, 'allows_multiple') && in_array($p, $alreadyplugins)) {
             continue;
         }
         if (array_key_exists($p, $insane)) {
             continue;
         }
         $instancehtml .= '<a href="' . $this->baseurl . '&amp;new=' . $p . '">' . portfolio_static_function($p, 'get_name') . ' (' . s($p) . ')' . '</a><br />' . "\n";
         $addable++;
     }
     if ($addable) {
         $output .= $instancehtml;
     }
     $output .= $OUTPUT->box_end();
     return highlight($query, $output);
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:59,代码来源:adminlib.php

示例5: portfolio_export_pagesetup

        }
    }
    portfolio_export_pagesetup($PAGE, $exporter->get('caller'));
    // this calls require_login($course) if it can..
    // completely new request, look to see what information we've been passed and set up the exporter object.
} else {
    // you cannot get here with no information for us, we must at least have the caller.
    if (empty($_GET) && empty($_POST)) {
        portfolio_exporter::print_expired_export();
    }
    // we'e just posted here for the first time and have might the instance already
    if ($instanceid) {
        // this can throw exceptions but there's no point catching and rethrowing here
        // as the exporter isn't created yet.
        $instance = portfolio_instance($instanceid);
        if ($broken = portfolio_instance_sanity_check($instance)) {
            throw new portfolio_exception($broken[$instance->get('id')], 'portfolio_' . $instance->get('plugin'));
        }
        $instance->set('user', $USER);
    } else {
        $instance = null;
    }
    // we must be passed this from the caller, we cannot start a new export
    // without knowing information about what part of moodle we come from.
    if (empty($callbackcomponent) || empty($callbackclass)) {
        debugging('no callback file or class');
        portfolio_exporter::print_expired_export();
    }
    // so each place in moodle can pass callback args here
    // process the entire request looking for ca_*
    // be as lenient as possible while still being secure
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:add.php

示例6: get_string

 // Get strings that are used
 $strshow = get_string('on', 'portfolio');
 $strhide = get_string('off', 'portfolio');
 $strdelete = get_string('disabledinstance', 'portfolio');
 $strsettings = get_string('settings');
 $actionchoicesforexisting = array('show' => $strshow, 'hide' => $strhide, 'delete' => $strdelete);
 $actionchoicesfornew = array('newon' => $strshow, 'newoff' => $strhide, 'delete' => $strdelete);
 $output = $OUTPUT->box_start('generalbox');
 $plugins = core_component::get_plugin_list('portfolio');
 $plugins = array_keys($plugins);
 $instances = portfolio_instances(false, false);
 $usedplugins = array();
 // to avoid notifications being sent out while admin is editing the page
 define('ADMIN_EDITING_PORTFOLIO', true);
 $insane = portfolio_plugin_sanity_check($plugins);
 $insaneinstances = portfolio_instance_sanity_check($instances);
 $table = new html_table();
 $table->head = array(get_string('plugin', 'portfolio'), '', '');
 $table->data = array();
 foreach ($instances as $i) {
     $settings = '<a href="' . $sesskeyurl . '&amp;action=edit&amp;pf=' . $i->get('id') . '">' . $strsettings . '</a>';
     // Set some commonly used variables
     $pluginid = $i->get('id');
     $plugin = $i->get('plugin');
     $pluginname = $i->get('name');
     // Check if the instance is misconfigured
     if (array_key_exists($plugin, $insane) || array_key_exists($pluginid, $insaneinstances)) {
         if (!empty($insane[$plugin])) {
             $information = $insane[$plugin];
         } else {
             if (!empty($insaneinstances[$pluginid])) {
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:portfolio.php


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