setDefault('parentId=0'); /** 初始化回调函数 */ if (function_exists('singlePing')) { $this->customSinglePingCallback = true; } } /** * 输出文章回响数 * * @param mixed ...$args 评论数格式化数据 */ public function num(...$args) { if (empty($args)) { $args[] = '%d'; } echo sprintf($args[$this->length] ?? array_pop($args), $this->length); } /** * execute * * @access public * @return void * @throws Exception */ public function execute() { if (!$this->parameter->parentId) { return; } $select = $this->select()->where('table.comments.status = ?', 'approved') ->where('table.comments.cid = ?', $this->parameter->parentId) ->where('table.comments.type <> ?', 'comment') ->order('table.comments.coid', 'ASC'); $this->db->fetchAll($select, [$this, 'push']); } /** * 列出回响 * * @param mixed $singlePingOptions 单个回响自定义选项 */ public function listPings($singlePingOptions = null) { if ($this->have()) { //初始化一些变量 $parsedSinglePingOptions = Config::factory($singlePingOptions); $parsedSinglePingOptions->setDefault([ 'before' => '
    ', 'after' => '
', 'beforeTitle' => '', 'afterTitle' => '', 'beforeDate' => '', 'afterDate' => '', 'dateFormat' => $this->options->commentDateFormat ]); echo $parsedSinglePingOptions->before; while ($this->next()) { $this->singlePingCallback($parsedSinglePingOptions); } echo $parsedSinglePingOptions->after; } } /** * 回响回调函数 * * @param string $singlePingOptions 单个回响自定义选项 */ private function singlePingCallback(string $singlePingOptions): void { if ($this->customSinglePingCallback) { singlePing($this, $singlePingOptions); return; } ?>
  • beforeTitle(); $this->author(true); $singlePingOptions->afterTitle(); ?>
    beforeDate(); $this->date($singlePingOptions->dateFormat); $singlePingOptions->afterDate(); ?>
    content(); ?>
  • parameter->parentContent; } }