Пример #1
0
 public static function getInstance() {
   if (!self::$instance instanceof self) {
     RivetyCore_Log::info("Creating plugin manager"); 
     self::$instance = new self;
   }
   return self::$instance;
 }
Пример #2
0
	function filter($url, array $params = null) {
		$this->_rivety_plugin = RivetyCore_Plugin::getInstance();
		$out_url = $url;

		// LOCALIZATION
		if (RivetyCore_Registry::get('enable_localization') == '1') {
			if (stripos($url, "/") === 0) {
				// for virtual URLs
				$locale_code = $params['locale_code'];
				if (!is_null($locale_code)) {
					// localize the URL by injecting the locale code at the root
					if (RivetyCore_Translate::validateLocaleCode($locale_code)) {
						$out_url = "/".$locale_code.$url;
					}
				}
			} else {
				// TODO - add other cases, such as absolute and relative URLs
			}
		}

		// SSL
		if (RivetyCore_Registry::get('enable_ssl') == '1') {
			$secure_urls = RivetyCore_Registry::get('secure_urls');
			if (!empty($secure_urls)) {
				$secure_urls = explode('|', $secure_urls);
				if (stripos($url, "/") === 0) {
					// for virtual URLs
					// $tmp_url = '/'.trim('/', $url); // get rid of the last slash
					if (in_array($url, $secure_urls)) {
						$out_url = str_replace('http://', 'https://', RivetyCore_Registry::get('site_url').$out_url);
					} 
				} else {
					// TODO - add other cases, such as absolute and relative URLs
				}
			}
		}

		// FORCE ABSOLUTE URL
		if (array_key_exists('absolute', $params) || in_array('absolute', $params)) {
			if (stripos($url, "/") === 0) {
				$out_url = RivetyCore_Registry::get('site_url').$out_url;
			} else {
				$out_url = RivetyCore_Registry::get('site_url').'/'.$out_url;
			}
		}
		$params = array('url' => $out_url);
		$params = $this->_rivety_plugin->doFilter('url_post_filter', $params); // FILTER HOOK
		return $params['url'];
	}
Пример #3
0
	function setup($module_id) {
		$basepath = Zend_Registry::get("basepath");
		$module_dir = $basepath."/modules";
		$full_dir = $module_dir."/".$module_id;
		$subdirs = array("models", "plugins", "controllers", "lib");
		$tmp_include_path = "";
		try{
			$module_cfg = $this->parseIni($module_id);

			if (is_dir($full_dir)) {
			   	foreach ($subdirs as $subdir) {
					$includable_dir = $full_dir."/".$subdir;
					if (is_dir($includable_dir)) {
						$tmp_include_path .= PATH_SEPARATOR.$includable_dir;
					}
				}
				set_include_path(get_include_path().$tmp_include_path);
			}

			$this->upgradeDatabase($module_id);
			$this->setDefaultConfig($module_id);

			$ap = RivetyCore_Plugin::getInstance();

			if (count($module_cfg['plugins']) > 0) {
				foreach ($module_cfg['plugins'] as $hook => $plugin) {
					$hook_type = substr($hook, 0, strpos($hook, "."));
					$hook_name = substr($hook, strpos($hook, ".") + 1);
					$callback_class = substr($plugin, 0, strpos($plugin, "::"));
					$callback_method = substr($plugin, strpos($plugin, "::") + 2);
					if ($hook_type == "filter") {
						$ap->addFilter($hook_name, $callback_class, $callback_method, 10);
					}
					if ($hook_type == "action") {
						$ap->addAction($hook_name, $callback_class, $callback_method, 10);
					}
				}
			}
		} catch (Exception $e) {
			RivetyCore_Log::report("Could not set up ".$module_id, $e, Zend_Log::ERR);
			// $where = $this->getAdapter()->quoteInto("id = ?", $module_id);
			// $this->delete($where);
		}
	}
Пример #4
0
	function getNavArrayByParentId($parent_id)
	{
		$select = $this->select();
		$select->where("parent_id = ?", $parent_id);
		$select->where("role_id in (" . implode($this->all_roles, ",") . ")");
		$select->order('sort_order asc');
		$nav_items = $this->fetchAllArray($select);
		if (!is_null($nav_items))
		{
			$params = array('nav_items' => $nav_items, 'locale_code' => $this->locale_code);
			$params = RivetyCore_Plugin::getInstance()->doFilter('default_nav_filter', $params); // FILTER HOOK
			return $params['nav_items'];
		}
		else
		{
			// return an empty array instead of null so a foreach on the result doesn't throw a warning
			return array();
		}
	}
Пример #5
0
	if ($is_cli) $log_filename = $config['application']['log_filename_cli'];
	else $log_filename = $config['application']['log_filename'];

	Zend_Registry::set('basepath', $basepath);
	Zend_Registry::set('config_file', $config_file);
	Zend_Registry::set('host_id', $host_id);

	// create logger
	$writer = new Zend_Log_Writer_Stream($log_filename);
	$filter = new Zend_Log_Filter_Priority($log_level);
	$writer->addFilter($filter);
	RivetyCore_Log::registerLogger('rivety', $writer, true);
	RivetyCore_Log::report("Log Started", null, Zend_Log::INFO);

	// Create Plugin Manager
	$RivetyCore_plugin = RivetyCore_Plugin::getInstance();

	// define constants
	$constants = new Constants();
	set_include_path(get_include_path() . PATH_SEPARATOR . $config['application']['addtl_includes']);
	$databases = new Zend_Config_Ini($config_file, 'databases');
	$dbAdapters = array();
	foreach ($databases->db as $config_name => $db)
	{
		$dbAdapters[$config_name] = Zend_Db::factory($db->adapter, $db->config->toArray());
		if ((boolean)$db->config->default)
		{
			Zend_Db_Table::setDefaultAdapter($dbAdapters[$config_name]);
		}
	}
	// Store the adapter for use anywhere in our app
Пример #6
0
	public function insert(array $data)
	{
		$params = array(
			"data" => $data,
			"errors" => $this->_errors,
			"table" => $this->_name,
			"module" => $this->_module_id,
			"primary" => $this->_primary,
		);
		if (isset($this->_use_adapter)) $params['use_adapter'] = $this->_use_adapter;
		else $params['use_adapter'] = null;
		// rethrowing exceptions here because of a weird php issue where the trace isn't getting passed
		try
		{
			$params = RivetyCore_Plugin::getInstance()->doFilter('db_table_insert', $params);
		}
		catch (Exception $e)
		{
			throw($e);
		}
		if (count($params['errors']) == 0)
		{
			$params['insert_id'] = parent::insert($params['data']);
			RivetyCore_Plugin::getInstance()->doAction('db_table_post_insert', $params);
			return $params['insert_id'];
		}
		else
		{
			$this->_errors = $params['errors'];
			return false;
		}
	}