获取整组图文素材
@method getArticles
@since 0.0.1
@param {object} [&$manager] wechat扩展对象
@return {array}
@example $this->getArticles($manager);
519053
public function getArticles(&$manager = null) {
		$articles = [];
		foreach($this->items as $item) {
			$item->manager = $manager;
			$articles[] = $item->json;
		}

		return $articles;
	}
780389
public function getNewestArticles(int $size = null) : Collection
    {
        $size = $size ?? $this->articles->count();
        return $this->articles->reverse()->values()->take($size);
    }
406337
public function getApps($page=1, $size=10) {
        $pageable = new Pageable(['page'=>$page, 'size'=>$size]);
        $appClient = new AppClient($this->client);
        $response = $appClient->listAll($pageable);
        return $this->parseResponse($response, '获取App列表');
    }
592532
public function showArticles (string $lang, string $year = null, string $month = null, string $day = null, string $slug = null)
    {
        //URL -> articles/2017/03/23/page-name
        if ($slug)
            return $this->showArticle($lang, $year, $month, $day, $slug);

        if ($day)
            return $this->showByDate((new Carbon($year . '-' . $month . '-' . $day))->startOfDay(), (new Carbon($year . '-' . $month . '-' . $day))->endOfDay());

        if ($month)
            return $this->showByDate((new Carbon($year . '-' . $month))->startOfMonth(), (new Carbon($year . '-' . $month))->endOfMonth());

        if ($year)
            return $this->showByDate((new Carbon($year))->startOfYear(), (new Carbon($year))->endOfYear());

        abort(404, 'Page not found');
    }
418279
protected function getAdminNavId()
    {
        // 1. 从当前视图获取(控制器或行为中的变量)
        $adminNavId = $this->view['adminNavId'];
        if ($adminNavId) {
            return $adminNavId;
        }

        // 2. 从插件配置中获取
        $pluginId = $this->app->getPlugin();
        if ($pluginId) {
            return $this->plugin->getOneById($pluginId)->getOption('adminNavId');
        }

        return null;
    }
451597
public function getArticles($iStart = null, $iNrofArticles = null, $blReload = false)
    {
        // cached ?
        if ($this->_oArticles !== null && !$blReload) {
            return $this->_oArticles;
        }

        $this->_oArticles = oxNew(\OxidEsales\Eshop\Application\Model\ArticleList::class);

        if ($iStart !== null && $iNrofArticles !== null) {
            $this->_oArticles->setSqlLimit($iStart, $iNrofArticles);
        }

        // loading basket items
        $this->_oArticles->loadRecommArticles($this->getId(), $this->_sArticlesFilter);

        return $this->_oArticles;
    }
104277
public function getTopStartActionArticles()
    {
        if ($this->_oActionArticles === null) {
            $this->_oActionArticles = false;
            if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadAktion')) {
                $oArtList = oxNew(\OxidEsales\Eshop\Application\Model\ArticleList::class);
                $oArtList->loadActionArticles('OXTOPSTART');
                if ($oArtList->count()) {
                    $this->_oTopArticle = $oArtList->current();
                    $this->_oActionArticles = $oArtList;
                }
            }
        }

        return $this->_oActionArticles;
    }
100069
public function actionManage($id)
    {
        $model = $this->findModel($id);
        $this->setWechat($model);
        $this->flash('当前管理公众号设置为"' . $model->name . '", 您现在可以管理该公众号了', 'success');
        return $this->redirect(['/wechat']);
    }
183907
public function generateReplyArticles(Article $articles, $search = [], $replace = [])
    {
        $wei = $this->wei;
        $data = [];
        foreach ($articles as $article) {
            // 如果指定了关键词,替换描述内容里的关键词
            if ($search) {
                $article['title'] = str_replace($search, $replace, $article['title']);
                $article['intro'] = str_replace($search, $replace, $article['intro']);
            }

            // 上传的封面图片,不以http开头
            if (!$wei->isStartsWith($article['thumb'], 'http')) {
                $article['thumb'] = $wei->request->getUrlFor($article['thumb']);
            }

            $data[] = [
                'title' => $article['title'],
                'description' => $articles->length() > 1 ? '' : $article['intro'],
                'picUrl' => $article['thumb'],
                'url' => $article->getFullUrl(),
            ];
        }

        return $data;
    }
13500
protected function lists($action)
    {
        //查询实例
        $query = Attachment::find()->where(['user_id' => Yii::$app->user->id])->orderBy(['id' => SORT_DESC]);
        /* 判断类型 */
        switch ($action) {
            /* 列出文件 */
            case 'list-file':
                $query->andWhere(['ext' => explode(',', Yii::$app->settings->get('fileAllowFiles', 'attachment'))]);
                break;
            /* 列出图片 */
            case 'list-image':
            default:
                $query->andWhere(['ext' => explode(',', Yii::$app->settings->get('imageAllowFiles', 'attachment'))]);
        }
        $offset = Yii::$app->request->get('start', 0);
        $limit = Yii::$app->request->get('size', $this->options['imageManagerListSize']);
        $total = $query->count();
        if ($total > 0) {
            $files = $query->limit($limit)->offset($offset)->asArray()->all();
            $lists = [];
            foreach ($files as $file) {
                array_push($lists, [
                    'original' => $file['filename'],
                    'url' => $this->getSetting('storeUrl') . $file['path'],
                    'mtime' => $file['created_at']
                ]);
            }
            return ["state" => "SUCCESS", "list" => $lists, "start" => 0, "total" => $total];
        } else {
            return ["state" => "no match file", "list" => [], "start" => $offset, "total" => $total];
        }
    }
371468
public function getBasketArticles()
    {
        if ($this->_oBasketArtList === null) {
            $this->_oBasketArtList = false;
            if ($oBasket = $this->getBasket()) {
                $this->_oBasketArtList = $oBasket->getBasketArticles();
            }
        }

        return $this->_oBasketArtList;
    }
1138223
public function api()
    {
        //处理消息
        $this->wechat->server->setMessageHandler(function ($m) {
            $this->m = $m;
            Log::info($m);

            if ($m->Event != 'unsubscribe' && $m->Event != 'LOCATION' && $m->Event != 'VIEW' && $m->Event != 'TEMPLATESENDJOBFINISH') {
                //存上行消息
                $msg = new Message();
                $msg->from_user_name = $m->FromUserName;
                $msg->to_user_name = $m->ToUserName;
                $msg->create_time = $m->CreateTime;
                $msg->msg_type = $m->MsgType;
//                $msg->msg_id = isset($m->MsgId) ? $m->MsgId : 0;
                $msg->content = isset($m->Content) ? $m->Content : '';
                $msg->pic_url = isset($m->PicUrl) ? $m->PicUrl : '';
//                $msg->location_x = isset($m->Location_X) ? $m->Location_X : '';
//                $msg->location_x = isset($m->Location_Y) ? $m->Location_Y : '';
//                $msg->scale = isset($m->Scale) ? $m->Scale : '';
                $msg->label = isset($m->Label) ? $m->Label : '';
                $msg->title = isset($m->Title) ? $m->Title : '';
                $msg->description = isset($m->Description) ? $m->Description : '';
                $msg->url = isset($m->Url) ? $m->Url : '';
                $msg->media_id = isset($m->MediaId) ? $m->MediaId : '';
                $msg->thumb_media_id = $m->ThumbMediaId;
                $msg->event = $m->Event;
                $msg->event_key = $m->EventKey;
                $msg->save();
            }

            //从上行消息中提取关键词
            $key = '';
            switch ($m->MsgType) {
                case 'text':
                    $key = $m->Content;

                    break;
                case 'event':
                    switch ($m->Event) {
                        case 'CLICK':
                            $key = $m->EventKey;
                            break;
                        case 'subscribe'://关注事件
                            UserSns::where('openid', $m->FromUserName)->update(['status' => 0]);
                            break;
                        case 'unsubscribe'://取消关注事件
                            UserSns::where('openid', $m->FromUserName)->update(['status' => 1]);
                            break;
                        case 'SCAN':
                    }
                    break;
            }
            $this->key = $key;
            Log::info($this->key);

//            //帮用户生成本站用户数据
//            if (!$this->reg()) {
//                return 'whops';
//            }

            //判断关注默认回复的关键词
            if ($m->Event == 'subscribe' && empty($m->EventKey)) {
                $this->key = $this->keyFollow;
            }

            //事件key会抽风夹带类似这种的 last_trade_no_4009012001201605306519754434
            if (strpos($m->EventKey, 'last_trade_no') === 0) {
                $this->key = $this->keyFollow;
            }

            //根据关键词处理回复
            $res = FALSE;
            if (!empty($this->key)) {
                $this->r = $this->returnReply();
            } else {
                $this->r = '';
            }

            //入库消息.取关和地理位置不记录

            return $this->r;

        });

        return $this->wechat->server->serve();

    }
908557
public function onBeforeAddToManager(Manager $manager)
    {
        /* @var DataObjectScaffolder $owner */
        $owner = $this->owner;
        $memberType = StaticSchema::inst()->typeNameForDataObject(Member::class);
        $instance = $owner->getDataObjectInstance();
        $class = $owner->getDataObjectClass();
        if (!$instance->hasExtension(Versioned::class)) {
            return;
        }
        /* @var ObjectType $rawType */
        $rawType = $owner->scaffold($manager);

        $versionName = $this->createVersionedTypeName($class);
        $coreFieldsFn = $rawType->config['fields'];
        // Create the "version" type for this dataobject. Takes the original fields
        // and augments them with the Versioned_Version specific fields
        $versionType = new ObjectType([
            'name' => $versionName,
            'fields' => function () use ($coreFieldsFn, $manager, $memberType) {
                $coreFields = $coreFieldsFn();
                $versionFields = [
                    'Author' => [
                        'type' => $manager->getType($memberType),
                        'resolve' => function ($obj) {
                            return $obj->Author();
                        }
                    ],
                    'Publisher' => [
                        'type' => $manager->getType($memberType),
                        'resolve' => function ($obj) {
                            return $obj->Publisher();
                        }
                    ],
                    'Published' => [
                        'type' => Type::boolean(),
                        'resolve' => function ($obj) {
                            return $obj->WasPublished;
                        }
                    ],
                    'LiveVersion' => [
                        'type' => Type::boolean(),
                        'resolve' => function ($obj) {
                            return $obj->isLiveVersion();
                        }
                    ],
                    'LatestDraftVersion' => [
                        'type' => Type::boolean(),
                        'resolve' => function ($obj) {
                            return $obj->isLatestDraftVersion();
                        }
                    ],
                ];
                // Remove this recursive madness.
                unset($coreFields['Versions']);

                return array_merge($coreFields, $versionFields);
            }
        ]);

        $manager->addType($versionType, $versionName);

        // With the version type in the manager now, add the versioning fields to the dataobject type
        $owner
            ->addFields(['Version'])
            ->nestedQuery('Versions', new ReadVersions($class, $versionName));
    }
441688
public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('Redis manager');
            $content->description('Connections');
            $content->breadcrumb(['text' => 'Redis manager']);

            $connection = request('conn', 'default');

            $manager = $this->manager();

            $variables = [
                'conn'        => $connection,
                'info'        => $manager->getInformation(),
                'connections' => $manager->getConnections(),
                'keys'        => $manager->scan(
                    request('pattern', '*'),
                    request('count', 50)
                ),
            ];

            $content->body(view('laravel-admin-redis-manager::index', $variables));
        });
    }
1027593
protected function getValue($id)
    {
        $file = $this->getFile($id);
        if (!file_exists($file)) {
            return null;
        }
        if (filemtime($file) < time()) { // filemtime : 文件最后修改时间
            @unlink($file);
            return null;
        }
        return file_get_contents($file);
    }
1037848
public function getContentAsArray()
    {
        //$nav_item_page = (new \yii\db\Query())->select('*')->from('cms_nav_item_page t1')->leftJoin('cms_layout', 'cms_layout.id=t1.layout_id')->where(['t1.id' => $this->id])->one();
        $nav_item_page = $this;
        
        if (!$nav_item_page->layout) {
            return [];
        }
        
        $return = [
            'nav_item_page' => ['id' => $nav_item_page->id, 'layout_id' => $nav_item_page->layout_id, 'layout_name' => $nav_item_page->layout->name],
            '__placeholders' => [],
        ];
        
        $config = json_decode($nav_item_page->layout->json_config, true);
        
        if (isset($config['placeholders'])) {
            foreach ($config['placeholders'] as $rowKey => $row) {
                foreach ($row as $placeholderKey => $placeholder) {
                    $placeholder['nav_item_page_id'] = $this->id;
                    $placeholder['prev_id'] = 0;
                    $placeholder['__nav_item_page_block_items'] = [];
                    if (!isset($placeholder['cols'])) {
                        $placeholder['cols'] = '12';
                    }
                    
                    $return['__placeholders'][$rowKey][$placeholderKey] = $placeholder;
                    
                    $placeholderVar = $placeholder['var'];
                    
                    $return['__placeholders'][$rowKey][$placeholderKey]['__nav_item_page_block_items'] = self::getPlaceholder($placeholderVar, 0, $this);
                }
            }
        }
        
        return $return;
    }
1207909
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $currencyDirector
         */
        $currencyDirector = $this->getDirector('currency');

        /**
         * Dollar.
         */
        $currencyDollar = $currencyDirector
            ->create()
            ->setName('Dollar')
            ->setSymbol('$')
            ->setIso('USD');

        $currencyDirector->save($currencyDollar);
        $this->setReference('currency-dollar', $currencyDollar);

        /**Euro
         */
        $currencyEuro = $currencyDirector
            ->create()
            ->setName('Euro')
            ->setSymbol('€')
            ->setIso('EUR');

        $currencyDirector->save($currencyEuro);
        $this->setReference('currency-euro', $currencyEuro);

        /**
         * Pound.
         */
        $currencyPound = $currencyDirector
            ->create()
            ->setName('Pound')
            ->setSymbol('£')
            ->setIso('GBP');

        $currencyDirector->save($currencyPound);
        $this->setReference('currency-pound', $currencyPound);

        /**
         * Ien.
         */
        $currencyIen = $currencyDirector
            ->create()
            ->setName('Yen')
            ->setSymbol('円')
            ->setIso('JPY');

        $currencyDirector->save($currencyIen);
        $this->setReference('currency-ien', $currencyIen);
    }