Example #1
0
 /**
  * Enter description here .
  *
  *
  * ..
  *
  * @param unknown_type $type        	
  * @param PwInstallApplication $install        	
  * @return PwError boolean
  */
 protected function _install($type, $install)
 {
     $manifest = $install->getManifest();
     if (!$this->link) {
         $this->link = 'index.php?m=app&app=' . $manifest->getApplication('alias');
     }
     $dm = new PwNavDm();
     $dm->setLink($this->link)->setType($type);
     if ($type == 'my') {
         $prefix = Wind::getComponent('i18n')->getMessage('ADMIN:nav.my.prefix');
         $dm->setName($prefix . $manifest->getApplication('name'))->setSign($manifest->getApplication('alias'));
     } else {
         $dm->setName($manifest->getApplication('name'));
     }
     $id = $this->_navDs()->addNav($dm);
     if ($id instanceof PwError) {
         return $id;
     }
     $install->addInstallLog('nav', $id);
     $this->update();
     file_put_contents(DATA_PATH . 'tmp/log', 'nav!', FILE_APPEND);
     return true;
 }
Example #2
0
 /**
  * 导航批量修改处理器
  *
  * @return void
  */
 public function dorunAction()
 {
     $homeUrl = '';
     Wekit::load('SRV:nav.dm.PwNavDm');
     $dms = $newDms = $datas = $newdatas = array();
     list($posts, $newposts, $navtype) = $this->getInput(array('data', 'newdata', 'navtype'), 'post');
     $homeid = $this->getInput('home', 'post');
     foreach ($posts as $post) {
         if (!$post['name'] || !$navtype) {
             continue;
         }
         if ($navtype == 'my') {
             $router = $post['sign'];
         } else {
             $router = Wind::getComponent('router')->getRoute('pw')->matchUrl($post['link']);
         }
         Wekit::load('SRV:nav.dm.PwNavDm');
         $dm = new PwNavDm($post['navid']);
         $dm->setName($post['name'])->setLink($post['link'])->setSign($router)->setOrderid($post['orderid'])->setIsshow($post['isshow']);
         $resource = $dm->beforeUpdate();
         if ($resource instanceof PwError) {
             $this->showError($resource->getError());
             break;
         }
         $dms[] = $dm;
         if ($post['navid'] == $homeid) {
             $homeUrl = $post['link'];
         }
     }
     foreach ($newposts as $k => $newpost) {
         if (!$newpost['name'] || !$navtype) {
             continue;
         }
         if ($navtype == 'my') {
             $router = $newpost['sign'];
         } else {
             $router = Wind::getComponent('router')->getRoute('pw')->matchUrl($newpost['link']);
         }
         Wekit::load('SRV:nav.dm.PwNavDm');
         list($isroot, $id) = explode('_', $k);
         $dm = new PwNavDm();
         if ($isroot == 'root') {
             $dm->setParentid(0);
         } elseif ($isroot == 'child') {
             if (is_numeric($newpost['parentid'])) {
                 $dm->setParentid($newpost['parentid']);
             } else {
                 $dm->setParentid((int) $resource);
             }
         }
         $dm->setName($newpost['name'])->setLink($newpost['link'])->setSign($router)->setOrderid($newpost['orderid'])->setIsshow($newpost['isshow'])->setTempid($newpost['tempid'])->setType($navtype);
         $resource = $this->_getNavDs()->addNav($dm);
         if ($resource instanceof PwError) {
             $this->showError($resource->getError());
             break;
         }
         if ($homeid == 'home_' . $k) {
             $homeUrl = $newpost['link'];
         }
     }
     if ($homeUrl) {
         $config = new PwConfigSet('site');
         $homeRouter = Wind::getComponent('router')->getRoute('pw')->matchUrl($homeUrl);
         if ($homeRouter === false) {
             $this->showError('ADMIN:nav.out.link');
         }
         $config->set('homeUrl', $homeUrl)->set('homeRouter', $homeRouter)->flush();
     }
     $this->_getNavDs()->updateNavs($dms);
     $this->_getNavService()->updateConfig();
     $this->showMessage('ADMIN:success');
 }