Beispiel #1
0
 private function createManifestFile()
 {
     //------------------------- 创建xml文件 start
     //创建xml文件
     $xml_data['application'] = ['name' => ['@cdata' => $_POST['name']], 'title' => ['@cdata' => $_POST['title']], 'url' => ['@cdata' => $_POST['url']], 'industry' => ['@cdata' => $_POST['industry']], 'version' => ['@cdata' => $_POST['version']], 'resume' => ['@cdata' => $_POST['resume']], 'author' => ['@cdata' => $_POST['author']], 'position' => ['@cdata' => $_POST['position']], 'thumb' => ['@cdata' => $_POST['thumb']], 'module' => ['@cdata' => $_POST['module']]];
     $manifest = Xml::toXml('manifest', $xml_data);
     file_put_contents('theme/' . $_POST['name'] . '/manifest.xml', $manifest);
 }
Beispiel #2
0
 public static function toXml($data, $parent = 'root')
 {
     if (!$parent instanceof XmlNode) {
         $parent = new XmlElement((string) $parent);
     }
     switch (true) {
         case is_array($data):
         case is_object($data):
             $parent->setAttribute('type', 'structure');
             foreach ($data as $key => $value) {
                 if (is_int($key)) {
                     $key = 'element';
                 }
                 $node = new XmlElement($key);
                 $parent->addChild($node);
                 Xml::toXml($value, $node);
             }
             break;
         case is_bool($data):
             $parent->setAttribute('type', 'boolean');
             $parent->addChild(new XmlText($data ? 'true' : 'false'));
             break;
         case is_int($data):
             $parent->setAttribute('type', 'integer');
             $parent->addChild(new XmlText($data));
             break;
         case is_string($data):
             $parent->setAttribute('type', 'string');
             $parent->addChild(new XmlText($data));
             break;
         case is_float($data):
             $parent->setAttribute('type', 'float');
             $parent->addChild(new XmlText($data));
             break;
         case is_double($data):
             $parent->setAttribute('type', 'double');
             $parent->addChild(new XmlText($data));
             break;
         case is_null($data):
             //break;
         //break;
         default:
             $parent->addChild(new XmlText($data));
             break;
     }
     return $parent;
 }
Beispiel #3
0
 protected function asXml($value, $rootName = 'response')
 {
     $this->setSkipView(true);
     $xml = Xml::toXml($value, $rootName);
     header('Content-type: text/xml');
     echo $xml;
     Pimple::instance()->end();
 }
Beispiel #4
0
 private function createManifestFile()
 {
     //------------------------- 创建xml文件 start
     //模块动作
     $bindings = [];
     foreach (['cover', 'rule', 'business', 'home', 'profile', 'member', 'web'] as $type) {
         $d = $_POST['bindings'][$type];
         foreach ($d['title'] as $k => $v) {
             if (!empty($d['title'][$k]) && preg_match('/^\\w+$/i', $d['do'][$k])) {
                 $bindings[$type]['entry'][] = ['@attributes' => ['title' => $d['title'][$k], 'do' => $d['do'][$k], 'data' => $d['data'][$k], 'directly' => isset($d['directly'][$k]) ? $d['directly'][$k] : TRUE]];
             }
         }
     }
     //消息处理
     $platformXml = ['subscribes' => [], 'processors' => []];
     if (isset($_POST['subscribes'])) {
         foreach ($_POST['subscribes'] as $m) {
             $platformXml['subscribes']['message'][] = ['@attributes' => ['type' => $m]];
         }
     }
     if (isset($_POST['processors'])) {
         foreach ($_POST['processors'] as $m) {
             $platformXml['processors']['message'][] = ['@attributes' => ['type' => $m]];
         }
     }
     //创建xml文件
     $xml_data = ['@attributes' => ['versionCode' => implode(',', $_POST['versionCode'])], 'application' => ['@attributes' => ['setting' => isset($_POST['setting']) ? TRUE : FALSE], 'name' => ['@cdata' => $_POST['name']], 'title' => ['@cdata' => $_POST['title']], 'url' => ['@cdata' => $_POST['url']], 'version' => ['@cdata' => $_POST['version']], 'industry' => ['@cdata' => $_POST['industry']], 'resume' => ['@cdata' => $_POST['resume']], 'detail' => ['@cdata' => $_POST['detail']], 'author' => ['@cdata' => $_POST['author']], 'industry' => ['@cdata' => $_POST['industry']], 'thumb' => ['@cdata' => $_POST['thumb']], 'cover' => ['@cdata' => $_POST['cover']], 'rule' => ['@attributes' => ['embed' => isset($_POST['rule']) ? $_POST['rule'] : FALSE]]], 'platform' => $platformXml, 'bindings' => $bindings, 'permission' => ['@cdata' => $_POST['permission']], 'install' => ['@cdata' => $_POST['install']], 'uninstall' => ['@cdata' => $_POST['uninstall']], 'upgrade' => ['@cdata' => $_POST['upgrade']]];
     $manifest = Xml::toXml('manifest', $xml_data);
     file_put_contents('addons/' . $_POST['name'] . '/manifest.xml', $manifest);
 }