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


PHP is_valid_plugin_name函数代码示例

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


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

示例1: test_is_valid_plugin_name

 public function test_is_valid_plugin_name()
 {
     $this->assertTrue(is_valid_plugin_name('forum'));
     $this->assertTrue(is_valid_plugin_name('forum2'));
     $this->assertTrue(is_valid_plugin_name('feedback360'));
     $this->assertTrue(is_valid_plugin_name('online_users'));
     $this->assertTrue(is_valid_plugin_name('blond_online_users'));
     $this->assertFalse(is_valid_plugin_name('online__users'));
     $this->assertFalse(is_valid_plugin_name('forum '));
     $this->assertFalse(is_valid_plugin_name('forum.old'));
     $this->assertFalse(is_valid_plugin_name('xx-yy'));
     $this->assertFalse(is_valid_plugin_name('2xx'));
     $this->assertFalse(is_valid_plugin_name('Xx'));
     $this->assertFalse(is_valid_plugin_name('_xx'));
     $this->assertFalse(is_valid_plugin_name('xx_'));
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:16,代码来源:moodlelib_test.php

示例2: early_get_cache_plugins

 /**
  * Returns an array of plugins without using core methods.
  *
  * This function explicitly does NOT use core functions as it will in some circumstances be called before Moodle has
  * finished initialising. This happens when loading configuration for instance.
  *
  * @return string
  */
 public static function early_get_cache_plugins()
 {
     global $CFG;
     $result = array();
     $ignored = array('CVS', '_vti_cnf', 'simpletest', 'db', 'yui', 'tests');
     $fulldir = $CFG->dirroot . '/cache/stores';
     $items = new DirectoryIterator($fulldir);
     foreach ($items as $item) {
         if ($item->isDot() or !$item->isDir()) {
             continue;
         }
         $pluginname = $item->getFilename();
         if (in_array($pluginname, $ignored)) {
             continue;
         }
         if (!is_valid_plugin_name($pluginname)) {
             // Better ignore plugins with problematic names here.
             continue;
         }
         $result[$pluginname] = $fulldir . '/' . $pluginname;
         unset($item);
     }
     unset($items);
     return $result;
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:33,代码来源:helper.php

示例3: clean_param


//.........这里部分代码省略.........
                                break 2;
                            } else {
                                $open = true;
                            }
                        }
                        if ($open) {
                            break;
                        }
                        return $param;
                    }
                }
            } while (false);
            // Easy, just strip all tags, if we ever want to fix orphaned '&' we have to do that in format_string().
            return strip_tags($param);
        case PARAM_COMPONENT:
            // We do not want any guessing here, either the name is correct or not
            // please note only normalised component names are accepted.
            if (!preg_match('/^[a-z]+(_[a-z][a-z0-9_]*)?[a-z0-9]+$/', $param)) {
                return '';
            }
            if (strpos($param, '__') !== false) {
                return '';
            }
            if (strpos($param, 'mod_') === 0) {
                // Module names must not contain underscores because we need to differentiate them from invalid plugin types.
                if (substr_count($param, '_') != 1) {
                    return '';
                }
            }
            return $param;
        case PARAM_PLUGIN:
        case PARAM_AREA:
            // We do not want any guessing here, either the name is correct or not.
            if (!is_valid_plugin_name($param)) {
                return '';
            }
            return $param;
        case PARAM_SAFEDIR:
            // Remove everything not a-zA-Z0-9_- .
            return preg_replace('/[^a-zA-Z0-9_-]/i', '', $param);
        case PARAM_SAFEPATH:
            // Remove everything not a-zA-Z0-9/_- .
            return preg_replace('/[^a-zA-Z0-9\\/_-]/i', '', $param);
        case PARAM_FILE:
            // Strip all suspicious characters from filename.
            $param = fix_utf8($param);
            $param = preg_replace('~[[:cntrl:]]|[&<>"`\\|\':\\\\/]~u', '', $param);
            if ($param === '.' || $param === '..') {
                $param = '';
            }
            return $param;
        case PARAM_PATH:
            // Strip all suspicious characters from file path.
            $param = fix_utf8($param);
            $param = str_replace('\\', '/', $param);
            // Explode the path and clean each element using the PARAM_FILE rules.
            $breadcrumb = explode('/', $param);
            foreach ($breadcrumb as $key => $crumb) {
                if ($crumb === '.' && $key === 0) {
                    // Special condition to allow for relative current path such as ./currentdirfile.txt.
                } else {
                    $crumb = clean_param($crumb, PARAM_FILE);
                }
                $breadcrumb[$key] = $crumb;
            }
            $param = implode('/', $breadcrumb);
开发者ID:lucaboesch,项目名称:moodle,代码行数:67,代码来源:moodlelib.php

示例4: get_plugin_list

/**
 * Simplified version of get_list_of_plugins()
 * @param string $plugintype type of plugin
 * @return array name=>fulllocation pairs of plugins of given type
 */
function get_plugin_list($plugintype)
{
    global $CFG;
    // We use the dirroot as an identifier here because if it has changed the whole cache
    // can be considered invalid.
    $cache = cache::make('core', 'pluginlist', array('dirroot' => $CFG->dirroot));
    $cached = $cache->get($plugintype);
    if ($cached !== false) {
        return $cached;
    }
    $ignored = array('CVS', '_vti_cnf', 'simpletest', 'db', 'yui', 'tests');
    if ($plugintype == 'auth') {
        // Historically we have had an auth plugin called 'db', so allow a special case.
        $key = array_search('db', $ignored);
        if ($key !== false) {
            unset($ignored[$key]);
        }
    }
    if ($plugintype === '') {
        $plugintype = 'mod';
    }
    $fulldirs = array();
    if ($plugintype === 'mod') {
        // mod is an exception because we have to call this function from get_plugin_types()
        $fulldirs[] = $CFG->dirroot . '/mod';
    } else {
        if ($plugintype === 'editor') {
            // Exception also needed for editor for same reason.
            $fulldirs[] = $CFG->dirroot . '/lib/editor';
        } else {
            if ($plugintype === 'theme') {
                $fulldirs[] = $CFG->dirroot . '/theme';
                // themes are special because they may be stored also in separate directory
                if (!empty($CFG->themedir) and file_exists($CFG->themedir) and is_dir($CFG->themedir)) {
                    $fulldirs[] = $CFG->themedir;
                }
            } else {
                $types = get_plugin_types(true);
                if (!array_key_exists($plugintype, $types)) {
                    $cache->set($plugintype, array());
                    return array();
                }
                $fulldir = $types[$plugintype];
                if (!file_exists($fulldir)) {
                    $cache->set($plugintype, array());
                    return array();
                }
                $fulldirs[] = $fulldir;
            }
        }
    }
    $result = array();
    foreach ($fulldirs as $fulldir) {
        if (!is_dir($fulldir)) {
            continue;
        }
        $items = new DirectoryIterator($fulldir);
        foreach ($items as $item) {
            if ($item->isDot() or !$item->isDir()) {
                continue;
            }
            $pluginname = $item->getFilename();
            if (in_array($pluginname, $ignored)) {
                continue;
            }
            if (!is_valid_plugin_name($pluginname)) {
                // Better ignore plugins with problematic names here.
                continue;
            }
            $result[$pluginname] = $fulldir . '/' . $pluginname;
            unset($item);
        }
        unset($items);
    }
    //TODO: implement better sorting once we migrated all plugin names to 'pluginname', ksort does not work for unicode, that is why we have to sort by the dir name, not the strings!
    ksort($result);
    $cache->set($plugintype, $result);
    return $result;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:84,代码来源:moodlelib.php


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