123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
-
- namespace app\admin\model;
-
- use think\Db;
- use think\Model;
-
-
- class Custom extends Model
- {
-
- protected function initialize()
- {
-
- parent::initialize();
- }
-
-
-
- public function afterSave($aid, $post, $opt, $table)
- {
- $post['aid'] = $aid;
-
-
-
- if(!empty($post['addonFieldExt']['down_eyou_remote'])){
- $remoteFile = $post['addonFieldExt']['down_eyou_remote'];
- $headers = get_headers($remoteFile, true);
- $fileSize = $headers['Content-Length'];
- $post['addonFieldExt']['size'] = $fileSize;
- }
-
-
-
- $addonFieldExt = !empty($post['addonFieldExt']) ? $post['addonFieldExt'] : array();
- model('Field')->dealChannelPostData($post['channel'], $post, $addonFieldExt);
-
-
- if (is_dir('./weapp/Waimao/')) {
- $waimaoLogic = new \weapp\Waimao\logic\WaimaoLogic;
- $waimaoLogic->update_htmlfilename($aid, $post, $opt);
- }
-
-
- model('Taglist')->savetags($aid, $post['typeid'], $post['tags'], $post['arcrank'], $opt);
-
- if ('edit' == $opt) {
-
- Db::name('sql_cache_table')->execute('TRUNCATE TABLE '.config('database.prefix').'sql_cache_table');
- model('SqlCacheTable')->InsertSqlCacheTable(true);
- } else {
-
- if (isset($post['arcrank']) && -1 == $post['arcrank'] && -1 == $post['old_arcrank'] && !empty($post['users_id'])) {
-
- model('SqlCacheTable')->UpdateDraftSqlCacheTable($post, $opt);
- } else if (isset($post['arcrank'])) {
-
- $post['old_typeid'] = intval($post['attr']['typeid']);
- model('SqlCacheTable')->UpdateSqlCacheTable($post, $opt, $table);
- }
- }
- }
-
-
-
- public function getInfo($aid, $field = null, $isshowbody = true)
- {
- $result = array();
- $field = !empty($field) ? $field : '*';
- $result = Db::name('archives')->field($field)
- ->where([
- 'aid' => $aid,
- 'lang' => get_admin_lang(),
- ])
- ->find();
- if ($isshowbody) {
- $tableName = Db::name('channeltype')->where('id','eq',$result['channel'])->getField('table');
- $result['addonFieldExt'] = Db::name($tableName.'_content')->where('aid',$aid)->find();
- }
-
-
- if (!empty($result)) {
- $typeid = isset($result['typeid']) ? $result['typeid'] : 0;
- $tags = model('Taglist')->getListByAid($aid, $typeid);
- $result['tags'] = $tags['tag_arr'];
- $result['tag_id'] = $tags['tid_arr'];
- }
-
- return $result;
- }
-
-
-
- public function afterDel($aidArr = array(), $table)
- {
- if (is_string($aidArr)) {
- $aidArr = explode(',', $aidArr);
- }
-
- Db::name($table.'_content')->where(array('aid'=>array('IN', $aidArr)))->delete();
-
- model('Taglist')->delByAids($aidArr);
- }
- }
|