toArray() public method

返回目录的数组信息
public toArray ( )
 /**
  * 获取当前所有的表情
  * @param boolean $flush 是否更新缓存,默认为false
  * @return array 返回表情数据
  */
 public function getAllExpression($flush = false)
 {
     $cache_id = '_model_expression';
     if (($res = S($cache_id)) === false || $flush === true) {
         global $ts;
         // $pkg = $ts['site']['expression'];
         $pkg = 'miniblog';
         //TODO 临时写死
         $filepath = THEME_PUBLIC_PATH . '/image/expression/' . $pkg;
         require_once ADDON_PATH . '/library/io/Dir.class.php';
         $expression = new Dir($filepath);
         $expression_pkg = $expression->toArray();
         $res = array();
         foreach ($expression_pkg as $value) {
             /*				
                             if(!is_utf8($value['filename'])){
             					$value['filename'] = auto_charset($value['filename'],'GBK','UTF8');
             				}*/
             list($file) = explode(".", $value['filename']);
             $temp['title'] = $file;
             $temp['emotion'] = '[' . $file . ']';
             $temp['filename'] = $value['filename'];
             $temp['type'] = $pkg;
             $res[$temp['emotion']] = $temp;
         }
         S($cache_id, $res);
     }
     return $res;
 }
 public function getAllExpression($flush = false)
 {
     $cache_id = '_model_expression';
     if (($res = F($cache_id)) === false || $flush === true) {
         global $ts;
         $pkg = $ts['site']['expression'];
         $filepath = SITE_PATH . '/public/themes/' . $ts['site']['site_theme'] . '/images/expression/' . $pkg;
         require_once ADDON_PATH . '/libs/Io/Dir.class.php';
         $expression = new Dir($filepath);
         $expression_pkg = $expression->toArray();
         $res = array();
         foreach ($expression_pkg as $value) {
             if (!is_utf8($value['filename'])) {
                 $value['filename'] = auto_charset($value['filename'], 'GBK', 'UTF8');
             }
             list($file) = explode(".", $value['filename']);
             $temp['title'] = $file;
             $temp['emotion'] = '[' . $file . ']';
             $temp['filename'] = $value['filename'];
             $temp['type'] = $pkg;
             $res[$temp['emotion']] = $temp;
         }
         F($cache_id, $res);
     }
     return $res;
 }
 public function add()
 {
     $dao = D("App");
     import('ORG.Io.Dir');
     if ($_REQUEST['appname']) {
         // 添加内容的页面
         $strAppname = h($_GET['appname']);
         $result = $dao->where("url='{$strAppname}'")->count();
         if ($result) {
             $this->error('此应用已安装过');
             exit;
         } else {
             $appConfig = (require SITE_PATH . '/apps/' . $strAppname . '/appinfo/config.php');
         }
         $this->assign('appConfig', $appConfig);
         $this->assign('selected', 'true');
     } else {
         $pDir = new Dir(SITE_PATH . '/apps/');
         $arrDirs = $pDir->toArray();
         $applist = $dao->findall();
         foreach ($applist as $value) {
             $apps[] = $value['enname'];
         }
         foreach ($arrDirs as $value) {
             if (!in_array($value['filename'], $apps) && is_file($value['pathname'] . '/appinfo/config.php')) {
                 $config = (include $value['pathname'] . '/appinfo/config.php');
                 $config['icon'] = str_replace('http://{APP_URL}', SITE_URL . '/apps/' . $value['filename'], $config['icon']);
                 $appList[$value['filename']] = $config;
             }
         }
         $this->assign('appList', $appList);
     }
     $this->display();
 }
Beispiel #4
0
 public function show()
 {
     $dirpath = $this->dirpath();
     $dirup = $this->dirup();
     import("ORG.Io.Dir");
     $dir = new Dir($dirpath);
     $dirlist = $dir->toArray();
     if (strpos($dirup, 'Template') > 0) {
         $this->assign('dirup', $dirup);
     }
     if (empty($dirlist)) {
         $this->error('该文件夹下面没有任何文件!');
     }
     if ($_GET['mytpl']) {
         foreach ($dirlist as $key => $value) {
             if (strpos($value['filename'], 'my_') === false) {
                 unset($dirlist[$key]);
             }
         }
     }
     $_SESSION['tpl_reurl'] = C('cms_admin') . '?s=Admin/Tpl/Show/id/' . str_replace('/', '*', $dirpath);
     if ($dirup && $dirup != '.') {
         $this->assign('dirup', $dirup);
     }
     $this->assign('mytpl', $_GET['mytpl']);
     $this->assign('dir', list_sort_by($dirlist, 'mtime', 'desc'));
     $this->assign('dirpath', $dirpath);
     $this->display('./views/admin/tpl_show.html');
 }
 public function siteopt()
 {
     $site_opt = model('Xdata')->lget('siteopt');
     $this->assign($site_opt);
     require_once ADDON_PATH . '/libs/Io/Dir.class.php';
     $theme_list = new Dir(SITE_PATH . '/public/themes/');
     $this->assign('theme_list', $theme_list->toArray());
     $this->display();
 }
 public function index()
 {
     $smiletype = D('Smile')->getSmileType();
     $this->assign('smilelist', $smiletype);
     $opt = D("Option")->getOpts4Edit();
     import('ORG.Io.Dir');
     $pDir = new Dir(SITE_PATH . '/public/themes/');
     $this->assign('themelist', $pDir->toArray());
     $this->assign("verify", unserialize($opt["verify"]));
     $this->assign("newuser_time", $opt["newuser_time"]);
     $this->assign("newuser_fri_num", $opt["newuser_fri_num"]);
     $this->assign("opt", $opt);
     $this->display();
 }
Beispiel #7
0
 /**
  * 数据库备份/还原列表
  * @param  String $type import-还原,export-备份
  */
 public function index($type = 'export')
 {
     switch ($type) {
         /* 数据还原 */
         case 'import':
             //列出备份文件列表
             import("ORG.Io.Dir");
             $path = realpath(C('DATA_BACKUP_PATH'));
             $dir = new Dir($path, '*.sql.gz');
             $glob = $dir->toArray();
             $list = array();
             foreach ($glob as $file) {
                 $name = $file['filename'];
                 if (preg_match('/^\\d{8,8}-\\d{6,6}-\\d+\\.sql(?:\\.gz)?$/', $name)) {
                     $fileSize = $file['size'];
                     $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
                     $date = "{$name[0]}-{$name[1]}-{$name[2]}";
                     $time = "{$name[3]}:{$name[4]}:{$name[5]}";
                     $part = $name[6];
                     if (isset($list["{$date} {$time}"])) {
                         $info = $list["{$date} {$time}"];
                         $info['part'] = max($info['part'], $part);
                         $info['size'] = $info['size'] + $fileSize;
                     } else {
                         $info['part'] = $part;
                         $info['size'] = $fileSize;
                     }
                     $extension = strtoupper($file['ext']);
                     $info['compress'] = $extension === 'SQL' ? '-' : $extension;
                     $info['time'] = strtotime("{$date} {$time}");
                     $list["{$date} {$time}"] = $info;
                 }
             }
             break;
             /* 数据备份 */
         /* 数据备份 */
         case 'export':
             $Db = M();
             $list = $Db->query('SHOW TABLE STATUS');
             $list = array_map('array_change_key_case', $list);
             break;
         default:
             $this->error('参数错误!');
     }
     //渲染模板
     $this->assign('meta_title', $title);
     $this->assign('list', $list);
     $this->display($type);
 }
 public function siteopt()
 {
     $site_opt = model('Xdata')->lget('siteopt');
     if (!$site_opt['site_logo']) {
         $site_opt['site_logo'] = 'logo.png';
         $this->assign('site_logo', THEME_URL . '/images/' . $site_opt['site_logo']);
     }
     $this->assign($site_opt);
     require_once ADDON_PATH . '/libs/Io/Dir.class.php';
     $theme_list = new Dir(SITE_PATH . '/public/themes/');
     $expression_list = new Dir(SITE_PATH . '/public/themes/' . $site_opt['site_theme'] . '/images/expression/');
     $this->assign('expression_list', $expression_list->toArray());
     $this->assign('theme_list', $theme_list->toArray());
     $this->display();
 }
 public function fileshow()
 {
     $id = $_GET['id'];
     if ($id) {
         $dirup = substr($id, 0, strrpos($id, '*'));
         $dirpath = str_replace('*', '/', $id);
     } else {
         $dirpath = './' . C('upload_path');
     }
     if (!strpos($dirpath, trim(C('upload_path')))) {
         $this->error('不在附件文件夹的范围内!');
     }
     import("ORG.Io.Dir");
     $dir = new Dir($dirpath);
     $dirlist = $dir->toArray();
     if (strpos($dirup, C('upload_path')) > 0) {
         $this->assign('dirup', $dirup);
     }
     $this->assign('dir', $dirlist);
     $this->display('./views/admin/upload_fileshow.html');
 }
 public function index()
 {
     $dirpath = $this->dirpath();
     //当前目录
     $dirlast = $this->dirlast();
     //上一层目录
     import("ORG.Util.Dir");
     $dir = new Dir($dirpath);
     $list_dir = $dir->toArray();
     if (empty($list_dir)) {
         $this->error('该文件夹下面没有文件!');
     }
     foreach ($list_dir as $key => $value) {
         $list_dir[$key]['pathfile'] = dami_url_repalce($value['path'], 'desc') . '|' . $value['filename'];
     }
     $_SESSION['tpl_jumpurl'] = '?s=Tpl/index/id/' . dami_url_repalce($dirpath, 'desc');
     if ($dirlast && $dirlast != '.') {
         $this->assign('dirlast', dami_url_repalce($dirlast, 'desc'));
     }
     $this->assign('dirpath', $dirpath);
     $this->assign('list_dir', list_sort_by($list_dir, 'mtime', 'desc'));
     $this->display('index');
 }
Beispiel #11
0
 public static function getAllExpression($flush = false)
 {
     $cacheId = "expression";
     if (($res = CacheUtil::get($cacheId)) === false || $flush === true) {
         $filepath = "static/image/expression/";
         $expression = new Dir($filepath);
         $expression_pkg = $expression->toArray();
         $res = array();
         $typeMap = array("df" => "默认", "bm" => "暴漫");
         foreach ($expression_pkg as $index => $value) {
             list($file) = explode(".", $value["filename"]);
             list($type) = explode("_", $file);
             $temp["value"] = $file;
             $temp["phrase"] = "[" . $file . "]";
             $temp["icon"] = $value["filename"];
             $temp["type"] = $type;
             $temp["category"] = $typeMap[$type];
             $res[$temp["phrase"]] = $temp;
         }
         CacheUtil::set($cacheId, $res);
     }
     return $res;
 }
 /**
  * 获取目录信息
  * @param $path
  */
 function ImgList($path)
 {
     $dir = new Dir($path);
     if ($dir->isEmpty($path)) {
         return false;
     }
     $dirlist = $dir->toArray();
     return $dirlist;
 }
Beispiel #13
0
 /**
  * 获取所有微博节点列表 - 预留后台查看、编辑微博模板文件
  * @param boolean $ignore 从微博设置里面获取,默认为false
  * @return array 所有微博节点列表
  */
 public function getNodeList($ignore = false)
 {
     if (false === ($feedNodeList = S('FeedNodeList'))) {
         //应用列表
         $apps = C('DEFAULT_APPS');
         $appList = model('App')->getAppList();
         foreach ($appList as $app) {
             $apps[] = $app['app_name'];
         }
         //获得所有feed配置文件
         require_once ADDON_PATH . '/library/io/Dir.class.php';
         $dirs = new Dir(SITE_PATH, '*.feed.php');
         foreach ($apps as $app) {
             $app_config_path = SITE_PATH . '/apps/' . $app . '/Conf/';
             $dirs->listFile($app_config_path, '*.feed.php');
             $files = $dirs->toArray();
             if (is_array($files) && count($files) > 0) {
                 foreach ($files as $file) {
                     $feed_file['app'] = $app;
                     $feed_file['filename'] = $file['filename'];
                     $feed_file['pathname'] = $file['pathname'];
                     $feed_file['mtime'] = $file['mtime'];
                     $feedNodeList[] = $feed_file;
                 }
             }
         }
         S('FeedNodeList', $feedNodeList);
     }
     return $feedNodeList;
     // $xml = simplexml_load_file( $this->_getFeedXml() );
     // $feed = $xml->feedlist->feed;
     // $list = array();
     // foreach($feed as $key => $v) {
     // 	$app = (string)$v['app'];
     // 	$type = (string)$v['type'];
     // 	$list[$app][] = array(
     // 		'app'=>$app,
     // 		'type'=>$type,
     // 		'info'=>(string)$v['info']
     // 	);
     // }
     // return $list;
 }
 public function _getCronFileList()
 {
     $dir = LIB_PATH . "Cron/";
     import("Dir");
     $Dirs = new Dir($dir);
     $fileList = $Dirs->toArray();
     $CronFileList = array();
     foreach ((array) $fileList as $k => $file) {
         if (strpos($file['filename'], "ShuipFCMS") !== 0) {
             unset($fileList[$k]);
         } else {
             $CronFileList[] = $file['filename'];
         }
     }
     return $CronFileList;
 }