Example #1
0
 protected function getData()
 {
     if ($this->element->sql) {
         $db = JFactory::GetDBO();
         $db->setQuery($this->element->sql);
         $options = $db->loadObjectList();
         return $options;
     }
     // Initialize variables.
     $options = array();
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         $item = new stdClass();
         $item->id = (string) $option['value'];
         $item->display = JText::_(trim((string) $option));
         $options[] = $item;
     }
     reset($options);
     return $options;
 }
Example #2
0
			public function load_db(){
        		global $wpdb;
		        if(class_exists('JFactory')){
		            $db =& JFactory::GetDBO();
		            if(isset($db->_resource))//J1.5
	            		$this->db = new Guardian($db->_resource);
		            else//J1.6
	            		$this->db = new Guardian($db->getConnection());
				}
				else if(!empty($wpdb) && isset($wpdb->dbh)){
					$this->db = new Guardian($wpdb->dbh);
				}
				else{
					$this->load_db_settings();
			        if(!empty($this->db_database) && !empty($this->db_host) && !empty($this->db_password) && !empty($this->db_username)){
	            		$this->db = new Guardian($this->db_host, $this->db_username, $this->db_password, $this->db_database);	
					}
				}
			}