コード例 #1
0
 public function update()
 {
     if (IS_POST) {
         if (D('Category')->create()) {
             if (false !== D('Category')->save_data()) {
                 $this->success('编辑成功', U('Category/index'));
             } else {
                 $this->error('编辑失败');
             }
         }
     } else {
         $cid = I('id', 0, 'intval');
         $cate = D('Category')->find($cid);
         $category = D('Category')->order('sort asc')->select();
         import('Common/Org/Util/Data');
         $MyClass = new \Data();
         $category = $MyClass::tree($category, 'name');
         foreach ($category as $k => $c) {
             if ($MyClass::isChild($category, $c['cid'], $cid)) {
                 $category[$k]['disabled'] = "disabled='disabled'";
             } else {
                 $category[$k]['disabled'] = '';
             }
         }
         $this->files = html_file();
         $this->assign('category', $category);
         $this->assign('cate', $cate);
         $this->assign('cid', $cid);
         $this->display();
     }
 }
コード例 #2
0
function add_directory_listing($dir, $disabled, $makediff, $stats, &$list)
{
    global $diffpath;
    $handle = opendir($dir);
    while (($entry = readdir($handle)) !== false) {
        if ($entry != '.' && $entry != '..') {
            $type = filetype($dir . $entry);
            if ($type == 'file') {
                $file = $dir . $entry;
                $hash = get_file_hash($file);
                $parsed = array('file' => $file, 'hash' => $hash);
                $parsed['state'] = 'New';
                $parsed['staged'] = 'N';
                if ($makediff) {
                    $command = $diffpath;
                    $args = array('-u', '/dev/null', $parsed['file']);
                    $h = start_command($command, $args);
                    close_stdin($h);
                    $diff = htmlentities(get_all_data($h));
                    clean_up($h);
                } else {
                    $diff = false;
                }
                list($str, $prefix) = html_file($file, $parsed['state'], $parsed['staged'], $parsed['hash'], $diff, $disabled);
                echo $str;
                $parsed['prefix'] = $prefix;
                $list[] = $parsed;
            } elseif ($type == 'dir') {
                add_directory_listing($dir . $entry . '/', $disabled, $makediff, $stats, $list);
            } else {
                interpret_not_supported($dir . $entry, __FILE__, __LINE__);
            }
        }
    }
    return $list;
}
コード例 #3
0
ファイル: ContentModel.class.php プロジェクト: xupp/ThinkPHP
 public function _list_style($v, $value)
 {
     $files = html_file();
     $str = '';
     $str = "<input type='text' name='list_style' value='{$value}'  autocomplete='off'/><a href='javascript:;' a='1' id='checkHtml' class='btn2' >选择模板文件</a>\n<div id='file'>\n<ul>\n";
     foreach ($files as $k => $f) {
         $str .= "<li class='list_style' >{$f}</li>\n";
     }
     $str .= "</ul>\n</div>\n";
     return $str;
 }