本文整理汇总了PHP中serendipity_plugin_api::traverse_plugin_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_plugin_api::traverse_plugin_dir方法的具体用法?PHP serendipity_plugin_api::traverse_plugin_dir怎么用?PHP serendipity_plugin_api::traverse_plugin_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serendipity_plugin_api
的用法示例。
在下文中一共展示了serendipity_plugin_api::traverse_plugin_dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: traverse_plugin_dir
/**
* Traverse a specific directory and search if a serendipity plugin exists there.
*
* @access public
* @param string The path to start from (usually '.')
* @param array A referenced array of currently found classes
* @param boolean If true, only event plugins will be searched. If false, only sidebar plugins will be searched.
* @param string The maindir where we started searching from [for recursive use]
* @return
*/
function traverse_plugin_dir($ppath, &$classes, $event_only, $maindir = '')
{
$d = @opendir($ppath);
if ($d) {
while (($f = readdir($d)) !== false) {
if ($f[0] == '.' || $f == 'CVS' || !is_dir($ppath . '/' . $f) || !is_readable($ppath . '/' . $f)) {
continue;
}
$subd = opendir($ppath . '/' . $f);
if (!$subd) {
continue;
}
// Instead of only looking for directories, search for files within subdirectories
$final_loop = false;
while (($subf = readdir($subd)) !== false) {
if ($subf[0] == '.' || $subf == 'CVS') {
continue;
}
if (!$final_loop && is_dir($ppath . '/' . $f . '/' . $subf) && $maindir != $ppath . '/' . $f) {
// Search for another level of subdirectories
serendipity_plugin_api::traverse_plugin_dir($ppath . '/' . $f, $classes, $event_only, $f . '/');
// We can break after that operation because the current directory has been fully checked already.
$final_loop = true;
}
if (!preg_match('@^[^_]+_(event|plugin)_.+\\.php$@i', $subf)) {
continue;
}
$class_name = str_replace('.php', '', $subf);
// If an external plugin/event already exists as internal, remove the internal reference because its redundant
if (isset($classes['@' . $class_name])) {
unset($classes['@' . $class_name]);
}
// A local plugin will be preferred over general plugins [used when calling this function the second time]
if (isset($classes[$class_name])) {
unset($classes[$class_name]);
}
if (!is_null($event_only) && $event_only && !serendipity_plugin_api::is_event_plugin($subf)) {
continue;
}
if (!is_null($event_only) && !$event_only && serendipity_plugin_api::is_event_plugin($subf)) {
continue;
}
$classes[$class_name] = array('name' => $class_name, 'true_name' => $class_name, 'type' => 'additional_plugin', 'pluginPath' => $maindir . $f);
}
closedir($subd);
}
closedir($d);
}
}
示例2: get_plugins
function get_plugins()
{
global $serendipity;
serendipity_plugin_api::traverse_plugin_dir($this->pluginpath, $this->plugins['event'], true);
serendipity_plugin_api::traverse_plugin_dir($this->pluginpath, $this->plugins['sidebar'], false);
$this->load_plugin($this->plugins['event']);
$this->load_plugin($this->plugins['sidebar']);
}