Ejemplo n.º 1
0
 public function Sort()
 {
     $this->layout_view = null;
     $table = $_POST['table'];
     $idSet = explode(",", $_POST['id_set']);
     $q_related = AdaptorMysql::queryRow("SELECT * FROM " . BLACKBIRD_TABLE_PREFIX . "relations WHERE table_parent = '{$_POST['table_parent']}' AND table_child = '{$table}'");
     $config = _ControllerFront::parseConfig($q_related['config']);
     for ($i = 0; $i < count($idSet); $i++) {
         AdaptorMysql::update($table, array(array('field' => $config['col_order'], 'value' => $i + 1)), "id", $idSet[$i]);
     }
     //send signal back somewhere, why not
     if (isset($config['post_save'])) {
         $file = CUSTOM . DS . 'plugins' . DS . 'image_browser.php';
         if (file_exists($file) && (include_once $file)) {
             @eval($config['post_save']);
         }
     }
 }
Ejemplo n.º 2
0
 public static function sortPosition($table, $sql, $id, $pos, $field = 'position')
 {
     $q = AdaptorMysql::query($sql);
     $tA = array();
     for ($i = 0; $i < count($q); $i++) {
         if ($id != $q[$i]['id']) {
             $tA[] = $q[$i]['id'];
         }
     }
     array_splice($tA, $pos - 1, 0, $id);
     for ($i = 0; $i < count($tA); $i++) {
         $sqlA = array();
         $sqlA[] = array('field' => $field, 'value' => $i + 1);
         AdaptorMysql::update($table, $sqlA, 'id', $tA[$i]);
     }
 }