Ejemplo n.º 1
0
 /**
  * Position an Element
  * @param array $elements Array of Elements
  * @param array $ele The Element to insert
  * @return array The new Array of Elements
  */
 public function orderElement($name, $elements, $ele)
 {
     $positions = array('after', 'before');
     if (!isset($ele['name'])) {
         $ele['name'] = $name;
     }
     foreach ($positions as $pos) {
         if (isset($ele[$pos])) {
             if (isset($elements[$ele[$pos]])) {
                 $keyPos = $ele[$pos];
                 unset($ele[$pos]);
                 $elements = \Dxapp\Utility\ArrayManager::array_insert($elements, $keyPos, array($name => $ele), $pos);
                 return $elements;
             }
         }
     }
     $elements[$name] = $ele;
     return $elements;
 }
Ejemplo n.º 2
0
 /**
  * Reposition Contents
  * @param type $array
  * @return array
  */
 protected function reposition($array)
 {
     $newArray = $array;
     foreach ($array as $key => $content) {
         if (is_array($content)) {
             $pos = 'after';
             $reposition = FALSE;
             if (isset($content['before']) && !empty($content['before'])) {
                 $reposition = TRUE;
                 $pos = 'before';
                 $index = $content['before'];
             }
             if (isset($content['after']) && !empty($content['after'])) {
                 $reposition = TRUE;
                 $pos = 'after';
                 $index = $content['after'];
             }
             if ($reposition && isset($newArray[$index])) {
                 $contentx = $newArray[$key];
                 unset($newArray[$key]);
                 $newArray = \Dxapp\Utility\ArrayManager::array_insert($newArray, $index, array($key => $contentx), $pos);
             }
         }
     }
     return $newArray;
 }