示例#1
0
文件: sxe_005.php 项目: badlamer/hhvm
 function count()
 {
     echo __METHOD__ . "\n";
     return parent::count();
 }
 protected function updateAPP()
 {
     if (is_file($this->applist) && is_writable($this->applist)) {
         try {
             $doc = new SimpleXMLIterator($this->applist, null, true);
         } catch (Exception $e) {
             $this->error[] = "发生异常:" . $e->getMessage() . "  文件:" . $e->getFile() . "  行号:" . $e->getLine();
             return false;
         }
         if ($doc->getName() != "apps") {
             $this->error[] = "applist.xml的根元素必须是apps";
             return false;
         }
         $i = $doc->count();
         if ($i !== 0) {
             $apps = $doc->app;
             foreach ($apps as $app) {
                 if ($app['name'] == $this->app_name) {
                     $this->error[] = "项目列表存在重名项目,请修改项目名称";
                     return false;
                 }
             }
         }
         $doc->addChild("app");
         $doc->app[$i]->addAttribute("name", $this->app_name);
         $doc->app[$i]->addAttribute("path", $this->app_path);
         $doc->app[$i]->addAttribute("index", $this->app_index);
         if ($doc->asXML($this->applist)) {
             return true;
         } else {
             $this->error[] = "TinkPHP助手/data/applist.xml 写入失败";
             return false;
         }
     } else {
         $this->error[] = "TinkPHP助手/data/applist.xml不存在";
         return false;
     }
 }