$root = VI_ROOT . "module/" . $appid . "/widget/"; //加载配置 if (file_exists($root) && $group['widget'] && is_array($group['widget'][$appid])) { $app = $_CACHE['system']['module'][$appid]; echo '<dt>' . $app["name"] . '</dt>'; echo '<dd>'; echo '<ul>'; //遍历目录 $list = loop_dir($root); foreach ($list as $file) { // $widget = $file; $doc = $root . $widget . "/config.xml"; //如果配置文件存在 if (file_exists($doc) && in_array($widget, $group['widget'][$appid])) { $config = xml_array(sreadfile($doc)); //var_dump($config); //UTF8 转 GBK if ($_G['product']['charset'] == "gbk") { foreach ($config['widget'] as $key => $val) { if (is_string($val)) { $config['widget'][$key] = $val ? iconv('UTF-8', 'GBK//IGNORE', $val) : $val; } } } //////////////////////////////// // echo '<li rel="' . $file . '">'; echo '<img src="' . VI_BASE . 'module/' . $appid . '/widget/' . $file . '/preview.png" /> <br /> ' . $config['widget']["name"] . ' <br /> '; if (is_array($widgets[$appid]) && in_array($widget, $widgets[$appid])) { echo '<button appid="' . $appid . '" widget="' . $widget . '" class="added">取消</button>';
public static function rewrite($appid) { global $_G; global $_CACHE; //当前目录 $base = VI_ROOT . 'module/' . $appid; //XML 地址 $data = $base . '/rewrite.xml'; //存储目录 $save = $base . '/content/.htaccess'; //找到规则文件 if (file_exists($data)) { //转成数组 $docm = xml_array(sreadfile($data)); //验证是否有效 if (is_array($docm)) { //获取规则模板 $text = $docm['config'][$_G['setting']['global']['rewrite']['platform']]; //修正基准目录 if ($_CACHE['system']['module'][$appid]['domain']) { $text = str_replace('{BASE}', '/', $text); } else { $text = str_replace('{BASE}', VI_BASE . 'module/' . $appid . '/content/', $text); } //转编码(Linux 主机必需为 ANSI 格式) $text = iconv('UTF-8', 'GBK', trim($text)); return create_file($save, $text); } } /* // Load the XML source $xml = new DOMDocument; $xml->load( $data ); $doc = $xml->getElementsByTagName('key'); for ($i=0;$i<$doc->length;$i++){ $ele = $doc->item($i); if( $ele -> getAttribute("name") == $mode ){ $text = trim( $ele -> nodeValue ); //如果有绑定域名 if( $domain ){ $text = str_replace( '{BASE}', '/', $text ); }else{ $text = str_replace( '{BASE}', VI_BASE.'module/'.$this -> appid.'/content/', $text ); } //转编码(Linux 主机必需为 ANSI 格式) $text = iconv('UTF-8','GBK',$text); return create_file( $save , $text ); break; } } */ }