/** * Initialize the application */ public function init() { // Load the application configuration $this->singleton('conf', Conf::getInstance()); // Load the application error Handler $this->singleton('errorHandler', ErrorHandler::getInstance()); // Load the application logger $this->singleton('logger', Logger::getInstance()); // Load the filesystem library $this->singleton('fs', FileSystem::getInstance()); // Load the application session $this->singleton('session', Session::getInstance()); // Load the application router $this->singleton('router', Router::getInstance()); // Load the application HTTP request $this->singleton('request', Request::getInstance()); // Load the application HTTP response $this->singleton('response', Response::getInstance()); // Load the application cache $this->singleton('cache', Cache::getInstance()); }
} if (!$fs->create($thumb_location, "NO_OP", "NO_OP")) { error_log("Error copying thumb " . $thumb_location); } unlink($user_image_location); unlink($thumb_location); } // 10. Save literature file to storage if ($literature_name != "") { $lit_resourcedir = '/tmp/'; $upload_literature_location = $lit_resourcedir . $modified_literature_name; if (!move_uploaded_file($_FILES['upload_literature']['tmp_name'], $upload_literature_location)) { throw new Exception("Error moving uploaded file to {$upload_literature_location}"); } if (!isset($fs)) { $fs = FileSystem::getInstance(); } if (!$fs->create($upload_literature_location, "NO_OP", "NO_OP")) { error_log("Error copying literature " . $upload_literature_location); } unlink($upload_literature_location); } // 11. Update the image names back to the database. // Note: this update is in it's own transaction, after the images are // properly stored. It is a single statement transaction and with autocommit // on, we do not need to start and commit. if (isset($_POST['addeventsubmit'])) { $updatese = new ColumnFamily($conn, 'SOCIALEVENT'); $updatese->insert($eventid, array('imageurl' => $modified_image_name, 'imagethumburl' => $imagethumb, 'literatureurl' => $modified_literature_name)); } else { if (isset($_POST['addeventsubmitupdate'])) {
* * @wordpress-plugin * Plugin Name: SilverWp * Description: SilverWp is a framework to help developers create themes or plugins * Version: 0.1 * Author: Michal Kalkowski * Author URI: http://www.silversite.pl/ * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Text Domain: silverwp * Domain Path: /languages */ namespace SilverWp; // Exit if accessed directly if (!defined('ABSPATH')) { die; } require_once 'vendor/autoload.php'; try { SilverWp::getInstance()->isPlugin(new \SilverWp\Plugin()); $views = SILVERWP_LIBS_PATH . 'ssvafpress/views'; $assets_uri = plugin_dir_url(__FILE__) . 'assets'; FileSystem::getInstance()->addDirectory('assets_uri', $assets_uri); FileSystem::getInstance()->addDirectory('views', $views); Translate::$language_path = plugin_dir_path(__FILE__) . 'languages/'; Translate::$text_domain = 'silverwp'; Translate::init(); } catch (\SilverWp\Exception $ex) { $ex->catchException(); }
/** * Load a file containing the wanted class * * @param string $classname The class to load */ public static function load($classname) { // Load the cache file for the first time the autload is called if (empty(self::$cache) && is_file(Cache::getInstance()->getCacheFilePath(self::CACHE_FILE))) { self::$cache = Cache::getInstance()->includeCache(self::CACHE_FILE); } // Check the class file is registered in cache if (isset(self::$cache[$classname])) { // The file is registered in cache, include it, and exit the function include self::$cache[$classname]; return true; } $parts = explode('\\', $classname); if (count($parts) > 1) { $namespace = implode('\\', array_slice($parts, 0, -1)); } else { $namespace = ''; } $class = end($parts); $filename = "{$class}.php"; // The file is not registered in cache, let's find it. Any class file must be as <classname>.php $dirs = array(); $searchDirectories = array('Hawk' => array(LIB_DIR, CUSTOM_LIB_DIR), 'Hawk\\View\\Plugins' => array(LIB_DIR . 'view-plugins/'), '' => array(LIB_DIR . 'ext', CUSTOM_LIB_DIR)); if (isset($searchDirectories[$namespace])) { $dirs = $searchDirectories[$namespace]; } elseif (strpos($namespace, 'Hawk\\Plugins\\') === 0) { // Find the plugins associated to this namespace $plugins = Plugin::getAll(); foreach ($plugins as $plugin) { if ($plugin->getNamespace() === $namespace) { $dirs = array($plugin->getRootDir()); break; } } } else { // If the class exists, it is in custom-libs directory $dirs = array(CUSTOM_LIB_DIR, LIB_DIR . 'ext/'); } // Cross any search folder to find out the class file foreach ($dirs as $dir) { $files = FileSystem::getInstance()->find($dir, $filename, FileSystem::FIND_FILE_ONLY); if (!empty($files)) { $file = $files[0]; // The class file has been found, include it include $file; // Register this file, associated to the class name, in cache self::$cache[$classname] = $file; self::$cacheUpdated = true; return true; } } if (strpos($namespace, 'Hawk\\Plugins\\') === 0) { // If the class is an hawk class called from a plugin , // create an alias from the Hawk class to the plugin namespace $alias = '\\Hawk\\' . $class; if (class_exists($alias) || trait_exists($alias)) { class_alias($alias, $classname); return true; } } }