Project

General

Profile

« Previous | Next » 

Revision 1983

Added by Dietmar about 11 years ago

! /framework/class.wb.php::getLanguagesDetailsInUsed() optimized
+ /framework/class.wb.php::getAvailableLanguagesObjectInstance()
! /framework/class.wb.php::getLanguagesInUsed() method optimized
! /framework/class.frontend.php update changes made in class.wb.php
! /framework/functions.php::rebuild_all_accessfiles() is no longer creating FolderProtectFiles

View differences:

class.wb.php
30 30

  
31 31
class wb extends SecureForm
32 32
{
33
/** @var object instance of the database object */
34
	protected $_oDb      = null;
35
/** @var object instance holds several values from the application global scope */
36
	protected $_oReg     = null;
37
/** @var object instance holds all of the translations */
38
	protected $_oTrans   = null;
33 39

  
34 40
 	public $password_chars = 'a-zA-Z0-9\_\-\!\#\*\+\@\$\&\:';	// General initialization function
35 41

  
36 42
	// performed when frontend or backend is loaded.
37 43
	public function  __construct($mode = SecureForm::FRONTEND) {
38 44
		parent::__construct($mode);
45

  
46
		$this->_oDb    = WbDatabase::getInstance();
47
		$this->_oReg   = WbAdaptor::getInstance();
48
		$this->_oTrans = Translate::getInstance();
39 49
	}
40 50

  
41 51
/**
42 52
 *
43 53
 *
54
 * @return object instance of the database object of all visible languages with defined fields
55
 *
56
 */
57
	public function getAvailableLanguagesObjectInstance( ) {
58

  
59
			$sql = 'SELECT `directory`,`name` '
60
			     . 'FROM `'.$this->_oDb->TablePrefix.'addons` '
61
		         . 'WHERE `type` = \'language\' '
62
		         . 'ORDER BY `directory`';
63
        return ($this->_oDb->query($sql));
64
	}
65

  
66

  
67
/**
68
 *
69
 *
70
 * @return array of all visible languages with defined fields
71
 *
72
 */
73
	public function getAvailableLanguages( ) {
74
        $aRetval = array();
75
        if($oRes = $this->getAvailableLanguagesObjectInstance())
76
        {
77
            while($aRow = $oRes->fetchRow(MYSQL_ASSOC))
78
            {
79
                $aRetval[$aRow['directory']] = $aRow['name'];
80
            }
81
        }
82
        
83
        return ( $aRetval);
84
	}
85

  
86
/**
87
 *
88
 *
44 89
 * @return array of first visible language pages with defined fields
45 90
 *
46 91
 */
47
	public function GetLanguagesDetailsInUsed ( ) {
48
        global $database;
92
	public function getLanguagesDetailsInUsed ( ) {
93
//        global $database;
49 94
        $aRetval = array();
50
        $sql =
51
            'SELECT DISTINCT `language`'.
52
            ', `page_id`,`level`,`parent`,`root_parent`,`page_code`,`link`,`language`'.
53
            ', `visibility`,`viewing_groups`,`viewing_users`,`position` '.
54
            'FROM `'.TABLE_PREFIX.'pages` '.
55
            'WHERE `level`= \'0\' '.
56
              'AND `root_parent`=`page_id` '.
57
              'AND `visibility`!=\'none\' '.
58
              'AND `visibility`!=\'hidden\' '.
59
            'GROUP BY `language` '.
60
            'ORDER BY `position`';
61

  
62
            if($oRes = $database->query($sql))
95
		$sql = 'SELECT DISTINCT `language`, `page_id`, `level`, `parent`, `root_parent`, '
96
			 .                 '`page_code`, `link`, `language`, `visibility`, '
97
			 .                 '`viewing_groups`,`viewing_users`,`position` '
98
			 . 'FROM `'.$this->_oDb->TablePrefix.'pages` '
99
			 . 'WHERE `level`= \'0\' '
100
			 .       'AND `root_parent`=`page_id` '
101
			 .       'AND `visibility`!=\'none\' '
102
			 .       'AND `visibility`!=\'hidden\' '
103
			 . 'GROUP BY `language` '
104
			 . 'ORDER BY `position`';
105
        if($oRes = $this->_oDb->query($sql))
106
        {
107
            while($aRow = $oRes->fetchRow(MYSQL_ASSOC))
63 108
            {
64
                while($page = $oRes->fetchRow(MYSQL_ASSOC))
65
                {
66
                    if(!$this->page_is_visible($page)) {continue;}
67
                    $aRetval[$page['language']] = $page;
68
                }
109
                if(!$this->page_is_visible($aRow)) {continue;}
110
                $aRetval[$aRow['language']] = $aRow;
69 111
            }
112
        }
70 113
        return $aRetval;
71 114
	}
72 115

  
116

  
117

  
118

  
73 119
/**
74 120
 *
75 121
 *
76 122
 * @return comma separate list of first visible languages
77 123
 *
78 124
 */
79
	public function GetLanguagesInUsed ( ) {
80
        return implode(',', array_keys($this->GetLanguagesDetailsInUsed()));
125
	public function getLanguagesInUsed ( ) {
126
        $aRetval = array_keys($this->getLanguagesDetailsInUsed()) ;
127
        if(sizeof($aRetval)==0) { return null; }
128
        return implode(',', $aRetval);
81 129
  	}
82 130

  
83 131

  

Also available in: Unified diff