Ejemplo n.º 1
0
 public function batchaddAction()
 {
     $dms = array();
     list($ids, $name, $parentid, $joinname) = $this->getInput(array('id', 'name', 'parentid', 'joinname'), 'post');
     Wind::import('WSRV:area.dm.WindidAreaDm');
     foreach ($ids as $k => $id) {
         $dm = new WindidAreaDm();
         $dm->setAreaid($id);
         isset($name[$k]) && $dm->setName($name[$k]);
         isset($parentid[$k]) && $dm->setParentid($parentid[$k]);
         isset($joinname[$k]) && $dm->setJoinname($joinname[$k]);
         $dms[] = $dm;
     }
     $result = $this->_getAreaDs()->batchAddArea($dms);
     $this->output(WindidUtility::result($result));
 }
Ejemplo n.º 2
0
 /**
  * 更新地区
  */
 public function updateAction()
 {
     list($update, $add, $parentid) = $this->getInput(array('update', 'add', 'parentid'), 'post');
     is_array($update) || ($update = array());
     is_array($add) || ($add = array());
     $joinname = '';
     if ($parentid) {
         $rout = $this->_loadAreaService()->getAreaRout($parentid);
         switch (count($rout)) {
             case 0:
                 $this->showError('ADMIN:area.parentid.error');
                 break;
             case 3:
                 $this->showError('ADMIN:area.level.limit');
                 break;
         }
         $joinnames = array();
         foreach ($rout as $i) {
             $joinnames[] = $i['name'];
         }
         $joinname = implode('|', $joinnames);
     }
     foreach ($update as $id => $name) {
         $dm = new WindidAreaDm();
         $dm->setAreaid($id)->setName($name)->setJoinname($joinname ? $joinname . '|' . $name : $name);
         if (true !== ($r = $this->_loadAreaDs()->updateArea($dm))) {
             $this->showError(array('ADMIN:area.error.' . $r->getCode(), array('{flag}' => "“& \" ' < > \\ / ”")));
         }
     }
     $addDms = array();
     foreach ($add as $name) {
         $dm = new WindidAreaDm();
         $dm->setName($name)->setParentid($parentid)->setJoinname($joinname ? $joinname . '|' . $name : $name);
         if (true !== ($r = $dm->beforeAdd())) {
             $this->showError(array('ADMIN:area.error.' . $r->getCode(), array('{flag}' => "“& \" ' < > \\ / ”")));
         }
         $addDms[] = $dm;
     }
     $this->_loadAreaDs()->batchAddArea($addDms);
     //$this->_loadAreaService()->updateCache();
     $this->showMessage('success', 'admin/windid/areadata/run?parentid=' . $parentid);
 }