| | 113 | |
|---|
| | 114 | // if the priority is a tag, then we look for the real priority to insert it before that |
|---|
| | 115 | // tag. If the tag does not exists, then we put it at the very end which may not be |
|---|
| | 116 | // desired but it puts it somewhere |
|---|
| | 117 | // |
|---|
| | 118 | if (!ctype_digit($priority)) { |
|---|
| | 119 | $new_priority = false; |
|---|
| | 120 | $count = 0; |
|---|
| | 121 | if (isset($this->_exts[$section][$extension])) { |
|---|
| | 122 | foreach($this->_exts[$section][$extension] as $pri => $curr_command) { |
|---|
| | 123 | if ($curr_command['tag'] == $priority) { |
|---|
| | 124 | $new_priority = $count; |
|---|
| | 125 | break; |
|---|
| | 126 | } |
|---|
| | 127 | $count++; |
|---|
| | 128 | } |
|---|
| | 129 | } |
|---|
| | 130 | $priority = ($new_priority === false) ? $count : $new_priority; |
|---|
| | 131 | } |
|---|
| 127 | | $array = isset($this->_exts[$section][$extension]) ? $this->_exts[$section][$extension] : array(); |
|---|
| 128 | | $ky = $priority; |
|---|
| 129 | | $val = $newcommand; |
|---|
| 130 | | $n = $ky; |
|---|
| 131 | | foreach($array as $key => $value) |
|---|
| 132 | | { |
|---|
| 133 | | $backup_array[$key] = $array[$key]; |
|---|
| 134 | | } |
|---|
| 135 | | $upper_limit = count($array); |
|---|
| 136 | | while($n <= $upper_limit) |
|---|
| 137 | | { |
|---|
| 138 | | if($n == $ky) |
|---|
| 139 | | { |
|---|
| 140 | | $array[$n] = $val; |
|---|
| 141 | | // echo $n; |
|---|
| 142 | | } |
|---|
| 143 | | else |
|---|
| 144 | | { |
|---|
| 145 | | $i = $n - "1"; |
|---|
| 146 | | $array[$n] = $backup_array[$i]; |
|---|
| 147 | | } |
|---|
| 148 | | $n++; |
|---|
| 149 | | } |
|---|
| 150 | | |
|---|
| | 149 | $array = isset($this->_exts[$section][$extension]) ? $this->_exts[$section][$extension] : array(); |
|---|
| | 150 | $ky = $priority; |
|---|
| | 151 | $val = $newcommand; |
|---|
| | 152 | $n = $ky; |
|---|
| | 153 | foreach($array as $key => $value) { |
|---|
| | 154 | $backup_array[$key] = $array[$key]; |
|---|
| | 155 | } |
|---|
| | 156 | $upper_limit = count($array); |
|---|
| | 157 | while($n <= $upper_limit) { |
|---|
| | 158 | if($n == $ky) { |
|---|
| | 159 | $array[$n] = $val; |
|---|
| | 160 | // echo $n; |
|---|
| | 161 | } else { |
|---|
| | 162 | $i = $n - "1"; |
|---|
| | 163 | $array[$n] = $backup_array[$i]; |
|---|
| | 164 | } |
|---|
| | 165 | $n++; |
|---|
| | 166 | } |
|---|
| | 167 | |
|---|