Esempio n. 1
0
/**
 * Include a file in the current plugin directory
 * @param string $file File to include relative to the current plugin directory
 * @since 3.5.3
 */
function gpPlugin_incl($file)
{
    global $addonPathCode, $dataDir;
    if (gp_safe_mode) {
        return;
    }
    IncludeScript($addonPathCode . '/' . $file);
}
Esempio n. 2
0
 /**
  * Execute a set of directives for theme areas, hooks and special pages
  *
  */
 static function ExecInfo($info, $args = array())
 {
     global $dataDir, $addonFolderName, $installed_addon, $config, $page, $gp_overwrite_scripts;
     //addonDir is deprecated as of 2.0b3
     if (isset($info['addonDir'])) {
         if (gp_safe_mode) {
             return;
         }
         gpPlugin::SetDataFolder($info['addonDir']);
     } elseif (isset($info['addon'])) {
         if (gp_safe_mode) {
             return;
         }
         gpPlugin::SetDataFolder($info['addon']);
     }
     //if addon was just installed
     if ($installed_addon && $installed_addon === $addonFolderName) {
         gpPlugin::ClearDataFolder();
         return $args;
     }
     // check for fatal errors
     if (self::FatalNotice('exec', $info)) {
         return $args;
     }
     //data
     if (!empty($info['data'])) {
         IncludeScript($dataDir . $info['data'], 'include_if', array('page', 'dataDir', 'langmessage'));
     }
     //script
     $has_script = false;
     if (isset($info['script'])) {
         if (is_array($gp_overwrite_scripts) && isset($gp_overwrite_scripts[$info['script']])) {
             $full_path = $gp_overwrite_scripts[$info['script']];
         } else {
             $full_path = $dataDir . $info['script'];
         }
         if (!file_exists($full_path)) {
             $name =& $config['addons'][$addonFolderName]['name'];
             trigger_error('gpEasy Error: Addon hook script doesn\'t exist. Script: ' . $info['script'] . ' Addon: ' . $name);
         } elseif (IncludeScript($full_path, 'include_once', array('page', 'dataDir', 'langmessage'))) {
             $has_script = true;
         }
     }
     //class & method
     if (!empty($info['class'])) {
         if (class_exists($info['class'])) {
             $object = new $info['class']($args);
             if (!empty($info['method'])) {
                 if (method_exists($object, $info['method'])) {
                     $args[0] = call_user_func_array(array($object, $info['method']), $args);
                 } elseif ($has_script) {
                     trigger_error('gpEasy Error: Addon hook method doesn\'t exist. Script: ' . $info['method']);
                 }
             }
         } elseif ($has_script) {
             $name =& $config['addons'][$addonFolderName]['name'];
             trigger_error('gpEasy Error: Addon class doesn\'t exist. Class: ' . $info['class'] . ' Addon: ' . $name);
         } else {
             trigger_error('gpEasy Error: Addon class doesn\'t exist. Class: ' . $info['class']);
         }
     } elseif (!empty($info['method'])) {
         $callback = $info['method'];
         //object callbacks since gpEasy 3.0
         if (is_string($callback) && strpos($callback, '->') !== false) {
             $has_script = true;
             list($object, $method) = explode('->', $callback);
             if (isset($GLOBALS[$object]) && is_object($GLOBALS[$object]) && method_exists($GLOBALS[$object], $method)) {
                 $callback = array($GLOBALS[$object], $method);
             }
         }
         if (is_callable($callback)) {
             $args[0] = call_user_func_array($callback, $args);
             $method_called = true;
         } elseif ($has_script) {
             $name =& $config['addons'][$addonFolderName]['name'];
             trigger_error('gpEasy Error: Addon hook method doesn\'t exist. Script: ' . $info['method'] . ' Addon: ' . $name);
         }
     }
     gpPlugin::ClearDataFolder();
     gpOutput::PopCatchable();
     return $args;
 }
Esempio n. 3
0
 static function _ExecInfo($info, $args = array())
 {
     global $dataDir, $gp_overwrite_scripts;
     // get data
     if (!empty($info['data'])) {
         IncludeScript($dataDir . $info['data'], 'include_if', array('page', 'dataDir', 'langmessage'));
     }
     // get script
     $has_script = false;
     if (!empty($info['script'])) {
         if (is_array($gp_overwrite_scripts) && isset($gp_overwrite_scripts[$info['script']])) {
             $full_path = $gp_overwrite_scripts[$info['script']];
         } else {
             $full_path = $dataDir . $info['script'];
         }
         if (!file_exists($full_path)) {
             self::ExecError('gpEasy Error: Addon hook script doesn\'t exist.', $info, 'script');
             return $args;
         }
         if (IncludeScript($full_path, 'include_once', array('page', 'dataDir', 'langmessage'))) {
             $has_script = true;
         }
     }
     //class & method execution
     $exec_class = false;
     if (!empty($info['class_admin']) && common::LoggedIn()) {
         $exec_class = $info['class_admin'];
     } elseif (!empty($info['class'])) {
         $exec_class = $info['class'];
     }
     if ($exec_class) {
         if (!class_exists($exec_class)) {
             self::ExecError('gpEasy Error: Addon class doesn\'t exist.', $info, 'class');
             return $args;
         }
         $object = new $exec_class($args);
         if (!empty($info['method'])) {
             if (method_exists($object, $info['method'])) {
                 $args[0] = call_user_func_array(array($object, $info['method']), $args);
             } elseif ($has_script) {
                 self::ExecError('gpEasy Error: Addon hook method doesn\'t exist (1).', $info, 'method');
             }
         }
         return $args;
     }
     //method execution
     if (!empty($info['method'])) {
         $callback = $info['method'];
         //object callbacks since gpEasy 3.0
         if (is_string($callback) && strpos($callback, '->') !== false) {
             $has_script = true;
             list($object, $method) = explode('->', $callback);
             if (isset($GLOBALS[$object]) && is_object($GLOBALS[$object]) && method_exists($GLOBALS[$object], $method)) {
                 $callback = array($GLOBALS[$object], $method);
             }
         }
         if (is_callable($callback)) {
             $args[0] = call_user_func_array($callback, $args);
         } elseif ($has_script) {
             self::ExecError('gpEasy Error: Addon hook method doesn\'t exist (2).', $info, 'method');
         }
     }
     return $args;
 }
Esempio n. 4
0
 public static function _ExecInfo($info, $args = array())
 {
     global $dataDir, $gp_overwrite_scripts;
     // get data
     if (!empty($info['data'])) {
         IncludeScript($dataDir . $info['data'], 'include_if', array('page', 'dataDir', 'langmessage'));
     }
     // get script
     $has_script = false;
     if (!empty($info['script'])) {
         if (is_array($gp_overwrite_scripts) && isset($gp_overwrite_scripts[$info['script']])) {
             $full_path = $gp_overwrite_scripts[$info['script']];
         } else {
             $full_path = $dataDir . $info['script'];
         }
         if (!file_exists($full_path)) {
             self::ExecError(CMS_NAME . ' Error: Addon hook script doesn\'t exist.', $info, 'script');
             return $args;
         }
         if (IncludeScript($full_path, 'include_once', array('page', 'dataDir', 'langmessage'))) {
             $has_script = true;
         }
     }
     //class & method execution
     if (!empty($info['class_admin']) && \gp\tool::LoggedIn()) {
         return self::ExecClass($has_script, $info['class_admin'], $info, $args);
     } elseif (!empty($info['class'])) {
         return self::ExecClass($has_script, $info['class'], $info, $args);
     }
     //method execution
     if (!empty($info['method'])) {
         return self::ExecMethod($has_script, $info, $args);
     }
     return $args;
 }