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


PHP get_plugin_directory函数代码示例

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


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

示例1: run_enrolment_import

 /**
  * Helper function that runs the user import for a sample enrolment
  *
  * @param array $data Import data to use
  */
 private function run_enrolment_import($data)
 {
     global $CFG;
     $file = get_plugin_directory('dhimport', 'version1elis') . '/version1elis.class.php';
     require_once $file;
     $provider = new rlipimport_version1elis_importprovider_mockenrolment($data);
     $importplugin = new rlip_importplugin_version1elis($provider);
     $importplugin->run();
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:14,代码来源:elis_enrolment_field_mappings_test.php

示例2: test_fsloggerfactoryinstantiatescorrectclass

 /**
  * Validate that the file-system logger factory constructs an object of the
  * correct type
  */
 public function test_fsloggerfactoryinstantiatescorrectclass()
 {
     global $CFG;
     require_once $CFG->dirroot . '/local/datahub/lib/rlip_fslogger.class.php';
     $file = get_plugin_directory('dhimport', 'version1') . '/rlip_import_version1_fslogger.class.php';
     require_once $file;
     // Setup.
     $fslogger = rlip_fslogger_factory::factory('dhexport_version1', null);
     // Validation.
     $this->assertInstanceOf('rlip_fslogger_linebased', $fslogger);
     // Setup.
     $fslogger = rlip_fslogger_factory::factory('dhimport_version1', null);
     // Validation.
     $this->assertInstanceOf('rlip_import_version1_fslogger', $fslogger);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:19,代码来源:plugin_factories_test.php

示例3: get_plugin_generator

 /**
  * Return generator for given plugin
  * @param string $component
  * @return mixed plugin data generator
  */
 public function get_plugin_generator($component)
 {
     list($type, $plugin) = normalize_component($component);
     if ($type !== 'mod' and $type !== 'block') {
         throw new coding_exception("Plugin type {$type} does not support generators yet");
     }
     $dir = get_plugin_directory($type, $plugin);
     if (!isset($this->generators[$type . '_' . $plugin])) {
         $lib = "{$dir}/tests/generator/lib.php";
         if (!(include_once $lib)) {
             throw new coding_exception("Plugin {$component} does not support data generator, missing tests/generator/lib");
         }
         $classname = $type . '_' . $plugin . '_generator';
         $this->generators[$type . '_' . $plugin] = new $classname($this);
     }
     return $this->generators[$type . '_' . $plugin];
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:22,代码来源:data_generator.php

示例4: get_component_directory

/**
 * Return exact path to plugin directory,
 * this method support "simpletest_" prefix designed for unit testing.
 * @param string $component name such as 'moodle', 'mod_forum' or special simpletest value
 * @param bool $fullpaths false means relative paths from dirroot
 * @return directory path, full or relative to dirroot
 */
function get_component_directory($component, $fullpaths = true)
{
    global $CFG;
    $simpletest = false;
    if (strpos($component, 'simpletest_') === 0) {
        $subdir = substr($component, strlen('simpletest_'));
        return $subdir;
    }
    if ($component == 'moodle') {
        $path = $fullpaths ? $CFG->libdir : 'lib';
    } elseif ($component == 'local') {
        $path = ($fullpaths ? $CFG->dirroot . '/' : '') . 'local';
    } else {
        list($type, $plugin) = explode('_', $component, 2);
        $path = get_plugin_directory($type, $plugin, $fullpaths);
    }
    return $path;
}
开发者ID:benavidesrobert,项目名称:elis.base,代码行数:25,代码来源:moodlelib2.0.php

示例5: elis_tasks_load_def

/**
 * Loads the task definitions for the component (from file). If no
 * tasks are defined for the component, we simply return an empty array.
 * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
 * @return array of tasks or empty array if not exists
 *
 * INTERNAL - to be used from cronlib only
 */
function elis_tasks_load_def($component)
{
    global $CFG;
    require_once $CFG->libdir . '/moodlelib2.0.php';
    if ($component == 'moodle') {
        $defpath = $CFG->libdir . '/db/tasks.php';
        //} else if ($component == 'unittest') {
        //    $defpath = $CFG->libdir.'/simpletest/fixtures/tasks.php';
    } else {
        $compparts = explode('/', $component);
        $defpath = get_plugin_directory($compparts[0], $compparts[1]) . '/db/tasks.php';
    }
    $tasks = array();
    if (file_exists($defpath)) {
        require $defpath;
    }
    return $tasks;
}
开发者ID:benavidesrobert,项目名称:elis.base,代码行数:26,代码来源:tasklib.php

示例6: test_fileplugincsvhandlesemptylines

 /**
  * Validate that the CSV file plugin handles empty lines correctly
  */
 public function test_fileplugincsvhandlesemptylines()
 {
     global $CFG;
     require_once $CFG->dirroot . '/local/datahub/lib/rlip_fileplugin.class.php';
     $file = get_plugin_directory('dhfile', 'csv') . '/csv.class.php';
     require_once $file;
     // Fileplugin instance.
     $inputfile = dirname(__FILE__) . '/fixtures/blankline.csv';
     $fileplugin = new rlip_fileplugin_csv($inputfile);
     $fileplugin->open(RLIP_FILE_READ);
     // Simple data validation.
     $headerline = $fileplugin->read();
     $this->assertEquals($headerline, array('header1', 'header2'));
     $dataline = $fileplugin->read();
     $this->assertEquals($dataline, array('nextline', 'isblank'));
     // Line with just a newline character.
     $emptyline = $fileplugin->read();
     $this->assertEquals($emptyline, false);
     // Line with no content.
     $finalline = $fileplugin->read();
     $this->assertEquals($finalline, false);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:25,代码来源:fileplugin_csv_test.php

示例7: get_qtype

 /**
  * Get the question type class for a particular question type.
  * @param string $qtypename the question type name. For example 'multichoice' or 'shortanswer'.
  * @param bool $mustexist if false, the missing question type is returned when
  *      the requested question type is not installed.
  * @return question_type the corresponding question type class.
  */
 public static function get_qtype($qtypename, $mustexist = true)
 {
     global $CFG;
     if (isset(self::$questiontypes[$qtypename])) {
         return self::$questiontypes[$qtypename];
     }
     $file = get_plugin_directory('qtype', $qtypename) . '/questiontype.php';
     if (!is_readable($file)) {
         if ($mustexist || $qtypename == 'missingtype') {
             throw new coding_exception('Unknown question type ' . $qtypename);
         } else {
             return self::get_qtype('missingtype');
         }
     }
     include_once $file;
     $class = 'qtype_' . $qtypename;
     if (!class_exists($class)) {
         throw new coding_exception("Class {$class} must be defined in {$file}");
     }
     self::$questiontypes[$qtypename] = new $class();
     return self::$questiontypes[$qtypename];
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:29,代码来源:bank.php

示例8: factory

 /**
  * Factory method to obtain a default file system logger object
  *
  * @param string $plugin The plugin we are running, either dhimport_* or dhexport_*
  * @param object $fileplugin The file plugin that should be used to write out log data
  * @param boolean $manual True on a manual run, false on a scheduled run
  */
 static function factory($plugin, $fileplugin, $manual = false)
 {
     global $CFG;
     //determine the components of the plugin (type and instance)
     list($type, $instance) = explode('_', $plugin);
     //try to load in the appropriate file
     $file = get_plugin_directory($type, $instance) . '/' . $instance . '.class.php';
     if (!file_exists($file)) {
         //this should only happen during unit tests
         require_once $CFG->dirroot . '/local/datahub/lib/rlip_fslogger.class.php';
         return new rlip_fslogger_linebased($fileplugin, $manual);
     }
     require_once $file;
     //determine classname
     $classname = $plugin;
     $classname = str_replace('dhexport_', 'rlip_exportplugin_', $classname);
     $classname = str_replace('dhimport_', 'rlip_importplugin_', $classname);
     //ask the plugin to provide the logger
     return $classname::get_fs_logger($fileplugin, $manual);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:27,代码来源:rlip_fslogger.class.php

示例9: get_export_data

 /**
  * Fetches our export data as a multi-dimensional array.
  *
  * @param bool $manual          Whether this is a manual run.
  * @param int  $targetstarttime The timestamp representing the theoretical time when this task was meant to be run
  * @param int  $lastruntime     The last time the export was run (required for incremental scheduled export)
  *
  * @return array The export data
  */
 protected function get_export_data($manual = true, $targetstarttime = 0, $lastruntime = 0)
 {
     global $CFG;
     $file = get_plugin_directory('dhexport', 'version1elis') . '/version1elis.class.php';
     require_once $file;
     // Set the export to be incremental.
     set_config('nonincremental', 0, 'dhexport_version1elis');
     // Set the incremental time delta.
     set_config('incrementaldelta', '1d', 'dhexport_version1elis');
     // Plugin for file IO.
     $fileplugin = new rlip_fileplugin_export();
     $fileplugin->open(RLIP_FILE_WRITE);
     // Our specific export.
     $exportplugin = new rlip_exportplugin_version1elis($fileplugin, $manual);
     $exportplugin->init($targetstarttime, $lastruntime);
     $exportplugin->export_records(0);
     $exportplugin->close();
     $fileplugin->close();
     return $fileplugin->get_data();
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:29,代码来源:version1elis_extrafields_test.php

示例10: mnet_setup_dummy_method

/**
 * Figure out exactly what needs to be called and stashes it in $remoteclient
 * Does some further verification that the method is callable
 *
 * @param string   $method the full xmlrpc method that was called eg auth/mnet/auth.php/user_authorise
 * @param array    $callstack  the exploded callstack
 * @param stdclass $rpcrecord  the record from mnet_rpc
 *
 * @throws mnet_server_exception
 */
function mnet_setup_dummy_method($method, $callstack, $rpcrecord) {
    global $CFG;
    $remoteclient = get_mnet_remote_client();
    // verify that the callpath in the stack matches our records
    // callstack will look like array('mod', 'forum', 'lib.php', 'forum_add_instance');
    $path = get_plugin_directory($rpcrecord->plugintype, $rpcrecord->pluginname);
    $path = substr($path, strlen($CFG->dirroot)+1); // this is a bit hacky and fragile, it is not guaranteed that plugins are in dirroot
    array_pop($callstack);
    $providedpath =  implode('/', $callstack);
    if ($providedpath != $path . '/' . $rpcrecord->filename) {
        throw new mnet_server_exception(705, "nosuchfile");
    }
    if (!file_exists($CFG->dirroot . '/' . $providedpath)) {
        throw new mnet_server_exception(705, "nosuchfile");
    }
    require_once($CFG->dirroot . '/' . $providedpath);
    if (!empty($rpcrecord->classname)) {
        if (!class_exists($rpcrecord->classname)) {
            throw new mnet_server_exception(708, 'nosuchclass');
        }
        if (!$rpcrecord->static) {
            try {
                $object = new $rpcrecord->classname;
            } catch (Exception $e) {
                throw new mnet_server_exception(709, "classerror");
            }
            if (!is_callable(array($object, $rpcrecord->functionname))) {
                throw new mnet_server_exception(706, "nosuchfunction");
            }
            $remoteclient->object_to_call($object);
        } else {
            if (!is_callable(array($rpcrecord->classname, $rpcrecord->functionname))) {
                throw new mnet_server_exception(706, "nosuchfunction");
            }
            $remoteclient->static_location($rpcrecord->classname);
        }
    }
}
开发者ID:JP-Git,项目名称:moodle,代码行数:48,代码来源:serverlib.php

示例11: get_test_helper

 /**
  * Get the test helper class for a particular question type.
  * @param $qtype the question type name, e.g. 'multichoice'.
  * @return question_test_helper the test helper class.
  */
 public static function get_test_helper($qtype)
 {
     global $CFG;
     if (array_key_exists($qtype, self::$testhelpers)) {
         return self::$testhelpers[$qtype];
     }
     $file = get_plugin_directory('qtype', $qtype) . '/tests/helper.php';
     if (!is_readable($file)) {
         throw new coding_exception('Question type ' . $qtype . ' does not have test helper code.');
     }
     include_once $file;
     $class = 'qtype_' . $qtype . '_test_helper';
     if (!class_exists($class)) {
         throw new coding_exception('Class ' . $class . ' is not defined in ' . $file);
     }
     self::$testhelpers[$qtype] = new $class();
     return self::$testhelpers[$qtype];
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:23,代码来源:helpers.php

示例12: run_core_userset_import

 /**
  * Helper function that runs the userset import for a sample userset
  *
  * @param array $extradata Extra fields to set for the new userset
  * @param boolean $usedefaultdata If true, use the default userset data,
  *                                  along with any data specifically provided
  */
 private function run_core_userset_import($extradata, $usedefaultdata = true)
 {
     global $CFG;
     $file = get_plugin_directory('dhimport', 'version1elis') . '/version1elis.class.php';
     require_once $file;
     if ($usedefaultdata) {
         $data = $this->get_core_userset_data();
     } else {
         $data = array();
     }
     foreach ($extradata as $key => $value) {
         $data[$key] = $value;
     }
     $provider = new rlipimport_version1elis_importprovider_mockuserset($data);
     $importplugin = new rlip_importplugin_version1elis($provider);
     $importplugin->run();
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:24,代码来源:elis_userset_import_test.php

示例13: generate_page_type_patterns

/**
 * Given a specific page type, parent context and currect context, return all the page type patterns
 * that might be used by this block.
 *
 * @param string $pagetype for example 'course-view-weeks' or 'mod-quiz-view'.
 * @param stdClass $parentcontext Block's parent context
 * @param stdClass $currentcontext Current context of block
 * @return array an array of all the page type patterns that might match this page type.
 */
function generate_page_type_patterns($pagetype, $parentcontext = null, $currentcontext = null)
{
    global $CFG;
    $bits = explode('-', $pagetype);
    $core = get_core_subsystems();
    $plugins = get_plugin_types();
    //progressively strip pieces off the page type looking for a match
    $componentarray = null;
    for ($i = count($bits); $i > 0; $i--) {
        $possiblecomponentarray = array_slice($bits, 0, $i);
        $possiblecomponent = implode('', $possiblecomponentarray);
        // Check to see if the component is a core component
        if (array_key_exists($possiblecomponent, $core) && !empty($core[$possiblecomponent])) {
            $libfile = $CFG->dirroot . '/' . $core[$possiblecomponent] . '/lib.php';
            if (file_exists($libfile)) {
                require_once $libfile;
                $function = $possiblecomponent . '_page_type_list';
                if (function_exists($function)) {
                    if ($patterns = $function($pagetype, $parentcontext, $currentcontext)) {
                        break;
                    }
                }
            }
        }
        //check the plugin directory and look for a callback
        if (array_key_exists($possiblecomponent, $plugins) && !empty($plugins[$possiblecomponent])) {
            //We've found a plugin type. Look for a plugin name by getting the next section of page type
            if (count($bits) > $i) {
                $pluginname = $bits[$i];
                $directory = get_plugin_directory($possiblecomponent, $pluginname);
                if (!empty($directory)) {
                    $libfile = $directory . '/lib.php';
                    if (file_exists($libfile)) {
                        require_once $libfile;
                        $function = $possiblecomponent . '_' . $pluginname . '_page_type_list';
                        if (!function_exists($function)) {
                            $function = $pluginname . '_page_type_list';
                        }
                        if (function_exists($function)) {
                            if ($patterns = $function($pagetype, $parentcontext, $currentcontext)) {
                                break;
                            }
                        }
                    }
                }
            }
            //we'll only get to here if we still don't have any patterns
            //the plugin type may have a callback
            $directory = get_plugin_directory($possiblecomponent, null);
            if (!empty($directory)) {
                $libfile = $directory . '/lib.php';
                if (file_exists($libfile)) {
                    require_once $libfile;
                    $function = $possiblecomponent . '_page_type_list';
                    if (function_exists($function)) {
                        if ($patterns = $function($pagetype, $parentcontext, $currentcontext)) {
                            break;
                        }
                    }
                }
            }
        }
    }
    if (empty($patterns)) {
        $patterns = default_page_type_list($pagetype, $parentcontext, $currentcontext);
    }
    // Ensure that the * pattern is always available if editing block 'at distance', so
    // we always can 'bring back' it to the original context. MDL-30340
    if ((!isset($currentcontext) or !isset($parentcontext) or $currentcontext->id != $parentcontext->id) && !isset($patterns['*'])) {
        // TODO: We could change the string here, showing its 'bring back' meaning
        $patterns['*'] = get_string('page-x', 'pagetype');
    }
    return $patterns;
}
开发者ID:Burick,项目名称:moodle,代码行数:83,代码来源:blocklib.php

示例14: create_mapping_record

 /**
  * Creates an import field mapping record in the database
  *
  * @param string $entitytype The type of entity, such as user or course
  * @param string $standardfieldname The typical import field name
  * @param string $customfieldname The custom import field name
  */
 private function create_mapping_record($entitytype, $standardfieldname, $customfieldname)
 {
     global $DB;
     $file = get_plugin_directory('dhimport', 'version1elis') . '/lib.php';
     require_once $file;
     $record = new stdClass();
     $record->entitytype = $entitytype;
     $record->standardfieldname = $standardfieldname;
     $record->customfieldname = $customfieldname;
     $DB->insert_record(RLIPIMPORT_VERSION1ELIS_MAPPING_TABLE, $record);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:18,代码来源:program_enrolment_fs_log_test.php

示例15: get_string

 /**
  * Get String returns a requested string
  *
  * @param string $identifier The identifier of the string to search for
  * @param string $component The module the string is associated with
  * @param string|object|array $a An object, string or number that can be used
  *      within translation strings
  * @param string $lang moodle translation language, NULL means use current
  * @return string The String !
  */
 public function get_string($identifier, $component = '', $a = NULL, $lang = NULL)
 {
     $this->countgetstring++;
     // there are very many uses of these time formating strings without the 'langconfig' component,
     // it would not be reasonable to expect that all of them would be converted during 2.0 migration
     static $langconfigstrs = array('strftimedate' => 1, 'strftimedatefullshort' => 1, 'strftimedateshort' => 1, 'strftimedatetime' => 1, 'strftimedatetimeshort' => 1, 'strftimedaydate' => 1, 'strftimedaydatetime' => 1, 'strftimedayshort' => 1, 'strftimedaytime' => 1, 'strftimemonthyear' => 1, 'strftimerecent' => 1, 'strftimerecentfull' => 1, 'strftimetime' => 1);
     if (empty($component)) {
         if (isset($langconfigstrs[$identifier])) {
             $component = 'langconfig';
         } else {
             $component = 'moodle';
         }
     }
     if ($lang === NULL) {
         $lang = current_language();
     }
     $string = $this->load_component_strings($component, $lang);
     if (!isset($string[$identifier])) {
         if ($component === 'pix' or $component === 'core_pix') {
             // this component contains only alt tags for emoticons,
             // not all of them are supposed to be defined
             return '';
         }
         if ($identifier === 'parentlanguage' and ($component === 'langconfig' or $component === 'core_langconfig')) {
             // parentlanguage is a special string, undefined means use English if not defined
             return 'en';
         }
         if ($this->usediskcache) {
             // maybe the on-disk cache is dirty - let the last attempt be to find the string in original sources,
             // do NOT write the results to disk cache because it may end up in race conditions see MDL-31904
             $this->usediskcache = false;
             $string = $this->load_component_strings($component, $lang, true);
             $this->usediskcache = true;
         }
         if (!isset($string[$identifier])) {
             // the string is still missing - should be fixed by developer
             list($plugintype, $pluginname) = normalize_component($component);
             if ($plugintype == 'core') {
                 $file = "lang/en/{$component}.php";
             } else {
                 if ($plugintype == 'mod') {
                     $file = "mod/{$pluginname}/lang/en/{$pluginname}.php";
                 } else {
                     $path = get_plugin_directory($plugintype, $pluginname);
                     $file = "{$path}/lang/en/{$plugintype}_{$pluginname}.php";
                 }
             }
             debugging("Invalid get_string() identifier: '{$identifier}' or component '{$component}'. " . "Perhaps you are missing \$string['{$identifier}'] = ''; in {$file}?", DEBUG_DEVELOPER);
             return "[[{$identifier}]]";
         }
     }
     $string = $string[$identifier];
     if ($a !== NULL) {
         // Process array's and objects (except lang_strings)
         if (is_array($a) or is_object($a) && !$a instanceof lang_string) {
             $a = (array) $a;
             $search = array();
             $replace = array();
             foreach ($a as $key => $value) {
                 if (is_int($key)) {
                     // we do not support numeric keys - sorry!
                     continue;
                 }
                 if (is_array($value) or is_object($value) && !$value instanceof lang_string) {
                     // we support just string or lang_string as value
                     continue;
                 }
                 $search[] = '{$a->' . $key . '}';
                 $replace[] = (string) $value;
             }
             if ($search) {
                 $string = str_replace($search, $replace, $string);
             }
         } else {
             $string = str_replace('{$a}', (string) $a, $string);
         }
     }
     return $string;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:89,代码来源:moodlelib.php


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