1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198:
<?php
$plugin_description = gettext("Provides deprecated Zenphoto functions.");
$plugin_author = "Stephen Billard (sbillard)";
$plugin_notice = gettext("This plugin is <strong>NOT</strong> required for the Zenphoto distributed functions.");
$option_interface = 'deprecated_functions';
$plugin_category = gettext('Development');
$plugin_is_filter = 900 | CLASS_PLUGIN;
if (OFFSET_PATH == 2)
enableExtension('deprecated-functions', $plugin_is_filter);
zp_register_filter('admin_utilities_buttons', 'deprecated_functions::button');
zp_register_filter('admin_tabs', 'deprecated_functions::tabs');
class deprecated_functions {
var $listed_functions = array();
var $unique_functions = array();
function __construct() {
global $_internalFunctions;
foreach (getPluginFiles('*.php') as $extension => $plugin) {
$deprecated = stripSuffix($plugin) . '/deprecated-functions.php';
if (file_exists($deprecated)) {
$plugin = basename(dirname($deprecated));
$content = file_get_contents($deprecated);
preg_match_all('~@deprecated\s+.*since\s+.*(\d+\.\d+\.\d+)~', $content, $versions);
preg_match_all('/([public static|static]*)\s*function\s+(.*)\s?\(.*\)\s?\{/', $content, $functions);
if ($plugin == 'deprecated-functions') {
$plugin = 'core';
$suffix = '';
} else {
$suffix = ' (' . $plugin . ')';
}
foreach ($functions[2] as $key => $function) {
if ($functions[1][$key]) {
$flag = '_method';
$star = '*';
} else {
$star = $flag = '';
}
$name = $function . $star . $suffix;
$option = 'deprecated_' . $plugin . '_' . $function . $flag;
setOptionDefault($option, 1);
$this->unique_functions[strtolower($function)] = $this->listed_functions[$name] = array(
'plugin' => $plugin,
'function' => $function,
'class' => trim($functions[1][$key]),
'since' => @$versions[1][$key],
'option' => $option,
'multiple' => array_key_exists($function, $this->unique_functions));
}
}
}
}
function getOptionsSupported() {
$options = $deorecated = $list = array();
foreach ($this->listed_functions as $funct => $details) {
$list[$funct] = $details['option'];
}
$options[gettext('Functions')] = array(
'key' => 'deprecated_Function_list',
'type' => OPTION_TYPE_CHECKBOX_UL,
'checkboxes' => $list,
'order' => 1,
'desc' => gettext('Send the <em>deprecated</em> notification message if the function name is checked. Un-checking these boxes will allow you to continue using your theme without warnings while you upgrade its implementation. Functions flagged with an asterisk are class methods. Ones flagged with two asterisks have deprecated parameters.'));
return $options;
}
static function tabs($tabs) {
if (zp_loggedin(ADMIN_RIGHTS)) {
if (!isset($tabs['development'])) {
$tabs['development'] = array(
'text' => gettext("development"),
'subtabs' => NULL);
}
$tabs['development']['subtabs'][gettext("deprecated")] = FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/deprecated-functions/admin_tab.php?page=deprecated&tab=' . gettext('deprecated');
$named = array_flip($tabs['development']['subtabs']);
sortArray($named);
$tabs['development']['subtabs'] = $named = array_flip($named);
$tabs['development']['link'] = array_shift($named);
}
return $tabs;
}
static function notify($use) {
$traces = @debug_backtrace();
$fcn = $traces[1]['function'];
if (empty($fcn))
$fcn = gettext('function');
if (!empty($use))
$use = ' ' . $use;
if (isset($traces[0]['file']) && isset($traces[0]['line'])) {
$script = basename(dirname($traces[0]['file']));
} else {
$script = 'unknown';
}
if ($script == 'deprecated-functions') {
$plugin = 'core';
} else {
$plugin = $script;
}
if (isset($traces[1]['file']) && isset($traces[1]['line'])) {
$script = basename($traces[1]['file']);
$line = $traces[1]['line'];
} else {
$script = $line = gettext('unknown');
}
if (@$traces[1]['class']) {
$flag = '_method';
} else {
$flag = '';
}
$option = 'deprecated_' . $plugin . '_' . $fcn . $flag;
if (($fcn == 'function') || getOption($option)) {
trigger_error(sprintf(gettext('%1$s (called from %2$s line %3$s) is deprecated'), $fcn, $script, $line) . $use . ' ' . sprintf(gettext('You can disable this error message by going to the <em>deprecated-functions</em> plugin options and un-checking <strong>%s</strong> in the list of functions.' . '<br />'), $fcn), E_USER_WARNING);
}
}
static function button($buttons) {
$buttons[] = array(
'category' => gettext('Development'),
'enable' => true,
'button_text' => gettext('Check deprecated use'),
'formname' => 'deprecated_functions_check.php',
'action' => FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/deprecated-functions/check_for_deprecated.php',
'icon' => 'images/magnify.png',
'title' => gettext("Searches PHP scripts for use of deprecated functions."),
'alt' => gettext('Check for update'),
'hidden' => '',
'rights' => ADMIN_RIGHTS
);
return $buttons;
}
static function addPluginScript() {
global $_zp_plugin_scripts;
if (is_array($_zp_plugin_scripts)) {
foreach ($_zp_plugin_scripts as $script) {
echo $script . "\n";
}
}
}
}
require_once(stripSuffix(__FILE__) . '/deprecated-functions.php');
foreach (getPluginFiles('*.php') as $extension => $plugin) {
$deprecated = stripSuffix($plugin) . '/deprecated-functions.php';
if (file_exists($deprecated)) {
require_once($deprecated);
}
unset($deprecated);
}
?>