Exemplo n.º 1
0
 /**
  * Removes the specified key from the specified group (if it exists).
  * Returns FALSE if the key is not found for removal, TRUE otherwise.
  *
  * @param string $Name The name of the configuration setting with dot notation.
  * @return boolean Wether or not the key was found.
  * @todo This method may have to be recursive to remove empty arrays.
  */
 public function Remove($Name, $Save = TRUE)
 {
     // Make sure the config settings are in the right format
     if (!is_array($this->Data)) {
         return FALSE;
     }
     $Found = FALSE;
     $Keys = explode('.', $Name);
     // If splitting is off, HANDLE IT
     if (!$this->Splitting) {
         $FirstKey = GetValue(0, $Keys);
         if ($FirstKey == $this->DefaultGroup) {
             $Keys = array(array_shift($Keys), implode('.', $Keys));
         } else {
             $Keys = array($Name);
         }
     }
     $KeyCount = count($Keys);
     $Settings =& $this->Data;
     for ($i = 0; $i < $KeyCount; ++$i) {
         $Key = $Keys[$i];
         // Key will always be in here if it is anywhere at all
         if (array_key_exists($Key, $Settings)) {
             if ($i == $KeyCount - 1) {
                 // We are at the setting, so unset it.
                 $Found = TRUE;
                 unset($Settings[$Key]);
             } else {
                 // Advance the pointer
                 $Settings =& $Settings[$Key];
             }
         } else {
             $Found = FALSE;
             break;
         }
     }
     if ($Save && $this->Dynamic) {
         $this->Dynamic->Remove($Name);
     }
     return $Found;
 }