Show
Ignore:
Timestamp:
11/15/07 17:30:27 (5 years ago)
Author:
teiko
Message:

Расширенный режим efio/admin. Можно выбрать несколько элементов из базы и применить к ним общее действие

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • efio/autoname.class.php

    r7 r8  
    8686 
    8787    function listUnchecked() { 
    88         $where_q = "WHERE correct=0"; // show all except blocked 
    89         $order_q = "ORDER BY $this->_tbl_key"; 
    90          
    91         $query = "SELECT * FROM $this->_tbl $where_q $order_q"; 
    92         $this->_db->setQuery($query); 
    93         $rows = $this->_db->loadRowList(); 
    94         $res = array(); 
    95         foreach($rows as $row) { 
    96             array_push($res, 
    97                 array("name" =>  mb_convert_case($row["name"], MB_CASE_TITLE, 'UTF-8'), 
    98                       "correct" => $row["correct"])); 
    99         } 
    100         if (!$this->_db->query()) { 
    101             echo $this->_db->stderr(); 
    102             return array(); 
    103         } 
    104         return $res;             
     88        $where_q = "WHERE correct=0"; // show all except blocked 
     89        $order_q = "ORDER BY $this->_tbl_key"; 
     90         
     91        $query = "SELECT * FROM $this->_tbl $where_q $order_q"; 
     92        $this->_db->setQuery($query); 
     93        $rows = $this->_db->loadRowList(); 
     94        $res = array(); 
     95        foreach($rows as $row) { 
     96            array_push($res, 
     97                array("name" =>  mb_convert_case($row["name"], MB_CASE_TITLE, 'UTF-8'), 
     98                      "correct" => $row["correct"])); 
     99        } 
     100        if (!$this->_db->query()) { 
     101            echo $this->_db->stderr(); 
     102            return array(); 
     103        } 
     104        return $res;             
     105    } 
     106 
     107    function listAll() { 
     108        $order_q = "ORDER BY $this->_tbl_key"; 
     109         
     110        $query = "SELECT * FROM $this->_tbl $order_q"; 
     111        $this->_db->setQuery($query); 
     112        $rows = $this->_db->loadRowList(); 
     113        $res = array(); 
     114        foreach($rows as $row) { 
     115            array_push($res, 
     116                array("name" =>  mb_convert_case($row["name"], MB_CASE_TITLE, 'UTF-8'), 
     117                      "correct" => $row["correct"])); 
     118        } 
     119        if (!$this->_db->query()) { 
     120            echo $this->_db->stderr(); 
     121            return array(); 
     122        } 
     123        return $res;             
    105124    } 
    106125     
     
    108127        if (empty($names)) return; 
    109128        foreach($names as $n) { 
    110             $n = str_replace("'", "''", $n); 
     129        $n = str_replace("'", "''", $n); 
    111130            $req = "UPDATE $this->_tbl SET correct=1 WHERE $this->_tbl_key=UPPER('$n') LIMIT 1;"; 
    112131            $this->_db->setQuery($req); 
     
    120139        if (empty($names)) return; 
    121140        foreach($names as $n) { 
     141            $n = str_replace("'", "''", $n); 
    122142            $req = "UPDATE $this->_tbl SET correct=2 WHERE $this->_tbl_key=UPPER('$n') LIMIT 1;"; 
    123143            $this->_db->setQuery($req); 
    124144            if (!$this->_db->query()) { 
    125                 echo $this->_db->stderr(); 
     145                    echo $this->_db->stderr(); 
    126146            } 
    127147        } 
     148    } 
     149 
     150    function uncheck($names) { 
     151        if (empty($names)) return; 
     152        foreach($names as $n) { 
     153            $n = str_replace("'", "''", $n); 
     154            $req = "UPDATE $this->_tbl SET correct=null WHERE $this->_tbl_key = UPPER('$n') LIMIT 1;"; 
     155                    $this->_db->setQuery($req); 
     156            if (!$this->_db->query()) { 
     157                  echo $this->_db->stderr(); 
     158            } 
     159        } 
    128160    } 
    129161