Browse Source

文件优化

tags/6.2.6
叙述、别离 2 years ago
parent
commit
82ee4554e1
37 changed files with 64 additions and 286 deletions
  1. +1
    -25
      src/system/libraries/jsonq/Condition.php
  2. +1
    -0
      src/system/libraries/jsonq/Exceptions/ConditionNotAllowedException.php
  3. +1
    -0
      src/system/libraries/jsonq/Exceptions/FileNotFoundException.php
  4. +1
    -0
      src/system/libraries/jsonq/Exceptions/InvalidJsonException.php
  5. +1
    -0
      src/system/libraries/jsonq/Exceptions/InvalidNodeException.php
  6. +1
    -0
      src/system/libraries/jsonq/Exceptions/NullValueException.php
  7. +1
    -81
      src/system/libraries/jsonq/JsonQueriable.php
  8. +2
    -107
      src/system/libraries/jsonq/Jsonq.php
  9. +2
    -1
      src/system/libraries/jsonq/Results/ValueNotFound.php
  10. +1
    -1
      src/system/taglib/help/adminname.txt
  11. +1
    -1
      src/system/taglib/help/arclist.txt
  12. +1
    -1
      src/system/taglib/help/arclistsg.txt
  13. +5
    -7
      src/system/taglib/help/ask.txt
  14. +1
    -1
      src/system/taglib/help/autochannel.txt
  15. +4
    -8
      src/system/taglib/help/bookcontentlist.txt
  16. +1
    -1
      src/system/taglib/help/booklist.txt
  17. +1
    -1
      src/system/taglib/help/channel.txt
  18. +7
    -9
      src/system/taglib/help/channelartlist.txt
  19. +1
    -1
      src/system/taglib/help/demotag.txt
  20. +3
    -5
      src/system/taglib/help/feedback.txt
  21. +4
    -4
      src/system/taglib/help/flink.txt
  22. +3
    -5
      src/system/taglib/help/group.txt
  23. +1
    -3
      src/system/taglib/help/groupthread.txt
  24. +1
    -1
      src/system/taglib/help/hotwords.txt
  25. +1
    -1
      src/system/taglib/help/infoguide.txt
  26. +1
    -1
      src/system/taglib/help/infolink.txt
  27. +4
    -2
      src/system/taglib/help/jsonq.txt
  28. +1
    -1
      src/system/taglib/help/likepage.txt
  29. +1
    -1
      src/system/taglib/help/likesgpage.txt
  30. +1
    -1
      src/system/taglib/help/loop.txt
  31. +1
    -1
      src/system/taglib/help/memberlist.txt
  32. +1
    -1
      src/system/taglib/help/myad.txt
  33. +2
    -2
      src/system/taglib/help/mytag.txt
  34. +2
    -2
      src/system/taglib/help/sonchannel.txt
  35. +1
    -1
      src/system/taglib/help/tag.txt
  36. +1
    -1
      src/system/taglib/help/type.txt
  37. +1
    -8
      src/system/taglib/jsonq.lib.php

+ 1
- 25
src/system/libraries/jsonq/Condition.php View File

@@ -14,7 +14,6 @@ class Condition
{ {
return $value == $comparable; return $value == $comparable;
} }

/** /**
* Strict equals * Strict equals
* *
@@ -27,7 +26,6 @@ class Condition
{ {
return $value === $comparable; return $value === $comparable;
} }

/** /**
* Simple not equal * Simple not equal
* *
@@ -40,7 +38,6 @@ class Condition
{ {
return $value != $comparable; return $value != $comparable;
} }

/** /**
* Strict not equal * Strict not equal
* *
@@ -53,7 +50,6 @@ class Condition
{ {
return $value !== $comparable; return $value !== $comparable;
} }

/** /**
* Strict greater than * Strict greater than
* *
@@ -66,7 +62,6 @@ class Condition
{ {
return $value > $comparable; return $value > $comparable;
} }

/** /**
* Strict less than * Strict less than
* *
@@ -79,7 +74,6 @@ class Condition
{ {
return $value < $comparable; return $value < $comparable;
} }

/** /**
* Greater or equal * Greater or equal
* *
@@ -92,7 +86,6 @@ class Condition
{ {
return $value >= $comparable; return $value >= $comparable;
} }

/** /**
* Less or equal * Less or equal
* *
@@ -105,7 +98,6 @@ class Condition
{ {
return $value <= $comparable; return $value <= $comparable;
} }

/** /**
* In array * In array
* *
@@ -118,7 +110,6 @@ class Condition
{ {
return (is_array($comparable) && in_array($value, $comparable)); return (is_array($comparable) && in_array($value, $comparable));
} }

/** /**
* Not in array * Not in array
* *
@@ -131,7 +122,6 @@ class Condition
{ {
return (is_array($comparable) && !in_array($value, $comparable)); return (is_array($comparable) && !in_array($value, $comparable));
} }

/** /**
* Is null equal * Is null equal
* *
@@ -143,7 +133,6 @@ class Condition
{ {
return is_null($value); return is_null($value);
} }

/** /**
* Is not null equal * Is not null equal
* *
@@ -155,7 +144,6 @@ class Condition
{ {
return !is_null($value); return !is_null($value);
} }

/** /**
* Start With * Start With
* *
@@ -169,14 +157,11 @@ class Condition
if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) { if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
return false; return false;
} }
if (preg_match("/^$comparable/", $value)) { if (preg_match("/^$comparable/", $value)) {
return true; return true;
} }

return false; return false;
} }

/** /**
* End with * End with
* *
@@ -190,14 +175,11 @@ class Condition
if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) { if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
return false; return false;
} }
if (preg_match("/$comparable$/", $value)) { if (preg_match("/$comparable$/", $value)) {
return true; return true;
} }

return false; return false;
} }

/** /**
* Match with pattern * Match with pattern
* *
@@ -211,16 +193,12 @@ class Condition
if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) { if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
return false; return false;
} }
$comparable = trim($comparable); $comparable = trim($comparable);

if (preg_match("/^$comparable$/", $value)) { if (preg_match("/^$comparable$/", $value)) {
return true; return true;
} }

return false; return false;
} }

/** /**
* Contains substring in string * Contains substring in string
* *
@@ -233,7 +211,6 @@ class Condition
{ {
return (strpos($value, $comparable) !== false); return (strpos($value, $comparable) !== false);
} }

/** /**
* Dates equal * Dates equal
* *
@@ -247,7 +224,6 @@ class Condition
$date = date($format, strtotime($value)); $date = date($format, strtotime($value));
return $date == $comparable; return $date == $comparable;
} }

/** /**
* Months equal * Months equal
* *
@@ -261,7 +237,6 @@ class Condition
$month = date('m', strtotime($value)); $month = date('m', strtotime($value));
return $month == $comparable; return $month == $comparable;
} }

/** /**
* Years equal * Years equal
* *
@@ -276,3 +251,4 @@ class Condition
return $year == $comparable; return $year == $comparable;
} }
} }
?>

+ 1
- 0
src/system/libraries/jsonq/Exceptions/ConditionNotAllowedException.php View File

@@ -7,3 +7,4 @@ class ConditionNotAllowedException extends \Exception
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }
?>

+ 1
- 0
src/system/libraries/jsonq/Exceptions/FileNotFoundException.php View File

@@ -7,3 +7,4 @@ class FileNotFoundException extends \Exception
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }
?>

+ 1
- 0
src/system/libraries/jsonq/Exceptions/InvalidJsonException.php View File

@@ -7,3 +7,4 @@ class InvalidJsonException extends \Exception
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }
?>

+ 1
- 0
src/system/libraries/jsonq/Exceptions/InvalidNodeException.php View File

@@ -7,3 +7,4 @@ class InvalidNodeException extends \Exception
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }
?>

+ 1
- 0
src/system/libraries/jsonq/Exceptions/NullValueException.php View File

@@ -7,3 +7,4 @@ class NullValueException extends \Exception
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }
?>

+ 1
- 81
src/system/libraries/jsonq/JsonQueriable.php View File

@@ -5,7 +5,6 @@ require_once(dirname(__FILE__)."/Exceptions/FileNotFoundException.php");
require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php"); require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php");
require_once(dirname(__FILE__)."/Results/ValueNotFound.php"); require_once(dirname(__FILE__)."/Results/ValueNotFound.php");
require_once(dirname(__FILE__)."/Condition.php"); require_once(dirname(__FILE__)."/Condition.php");

trait JsonQueriable trait JsonQueriable
{ {
/** /**
@@ -13,44 +12,37 @@ trait JsonQueriable
* @var string|array * @var string|array
*/ */
protected $_node = ''; protected $_node = '';

/** /**
* contain prepared data for process * contain prepared data for process
* @var mixed * @var mixed
*/ */
protected $_map; protected $_map;

/** /**
* contains column names * contains column names
* @var array * @var array
*/ */
protected $_select = []; protected $_select = [];

/** /**
* contains column names for except * contains column names for except
* @var array * @var array
*/ */
protected $_except = []; protected $_except = [];

/** /**
* Stores base contents. * Stores base contents.
* *
* @var array * @var array
*/ */
protected $_baseContents = []; protected $_baseContents = [];

/** /**
* Stores all conditions. * Stores all conditions.
* *
* @var array * @var array
*/ */
protected $_conditions = []; protected $_conditions = [];

/** /**
* @var bool * @var bool
*/ */
protected $_isProcessed = false; protected $_isProcessed = false;

/** /**
* map all conditions with methods * map all conditions with methods
* @var array * @var array
@@ -84,8 +76,6 @@ trait JsonQueriable
'month' => 'monthEqual', 'month' => 'monthEqual',
'year' => 'yearEqual', 'year' => 'yearEqual',
]; ];


/** /**
* import data from file * import data from file
* *
@@ -106,7 +96,6 @@ trait JsonQueriable


throw new FileNotFoundException(); throw new FileNotFoundException();
} }

/** /**
* Prepare data from desire conditions * Prepare data from desire conditions
* *
@@ -118,7 +107,6 @@ trait JsonQueriable
if ($this->_isProcessed) { if ($this->_isProcessed) {
return $this; return $this;
} }

if (count($this->_conditions) > 0) { if (count($this->_conditions) > 0) {
$calculatedData = $this->processConditions(); $calculatedData = $this->processConditions();
$this->_map = $this->objectToArray($calculatedData); $this->_map = $this->objectToArray($calculatedData);
@@ -128,12 +116,10 @@ trait JsonQueriable
$this->_isProcessed = true; $this->_isProcessed = true;
return $this; return $this;
} }

$this->_isProcessed = true; $this->_isProcessed = true;
$this->_map = $this->objectToArray($this->getData()); $this->_map = $this->objectToArray($this->getData());
return $this; return $this;
} }

/** /**
* Our system will cache processed data and prevend multiple time processing. If * Our system will cache processed data and prevend multiple time processing. If
* you want to reprocess this method can help you * you want to reprocess this method can help you
@@ -145,7 +131,6 @@ trait JsonQueriable
$this->_isProcessed = false; $this->_isProcessed = false;
return $this; return $this;
} }

/** /**
* Parse object to array * Parse object to array
* *
@@ -157,18 +142,14 @@ trait JsonQueriable
if (!is_array($obj) && !is_object($obj)) { if (!is_array($obj) && !is_object($obj)) {
return $obj; return $obj;
} }

if (is_array($obj)) { if (is_array($obj)) {
return $obj; return $obj;
} }

if (is_object($obj)) { if (is_object($obj)) {
$obj = get_object_vars($obj); $obj = get_object_vars($obj);
} }

return array_map([$this, 'objectToArray'], $obj); return array_map([$this, 'objectToArray'], $obj);
} }

/** /**
* Check given value is multidimensional array * Check given value is multidimensional array
* *
@@ -180,12 +161,9 @@ trait JsonQueriable
if (!is_array($arr)) { if (!is_array($arr)) {
return false; return false;
} }

rsort($arr); rsort($arr);

return isset($arr[0]) && is_array($arr[0]); return isset($arr[0]) && is_array($arr[0]);
} }

/** /**
* Check given value is valid JSON * Check given value is valid JSON
* *
@@ -199,22 +177,16 @@ trait JsonQueriable
if (is_array($value) || is_object($value)) { if (is_array($value) || is_object($value)) {
return false; return false;
} }

$data = json_decode($value, true); $data = json_decode($value, true);

if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
return false; return false;
} }

return $isReturnMap ? $data : true; return $isReturnMap ? $data : true;
} }


public function takeColumn($array) public function takeColumn($array)
{ {
return $this->selectColumn($this->exceptColumn($array)); return $this->selectColumn($this->exceptColumn($array));
} }

/** /**
* selecting specific column * selecting specific column
* *
@@ -224,14 +196,11 @@ trait JsonQueriable
protected function selectColumn($array) protected function selectColumn($array)
{ {
$keys = $this->_select; $keys = $this->_select;

if (count($keys) == 0) { if (count($keys) == 0) {
return $array; return $array;
} }

return array_intersect_key($array, array_flip((array) $keys)); return array_intersect_key($array, array_flip((array) $keys));
} }

/** /**
* selecting specific column * selecting specific column
* *
@@ -241,15 +210,11 @@ trait JsonQueriable
protected function exceptColumn($array) protected function exceptColumn($array)
{ {
$keys = $this->_except; $keys = $this->_except;

if (count($keys) == 0) { if (count($keys) == 0) {
return $array; return $array;
} }

return array_diff_key($array, array_flip((array) $keys)); return array_diff_key($array, array_flip((array) $keys));
} }


/** /**
* Prepare data for result * Prepare data for result
* *
@@ -260,11 +225,9 @@ trait JsonQueriable
protected function prepareResult($data, $isObject) protected function prepareResult($data, $isObject)
{ {
$output = []; $output = [];

if (is_null($data) || is_scalar($data)) { if (is_null($data) || is_scalar($data)) {
return $data; return $data;
} }

if ($this->isMultiArray($data)) { if ($this->isMultiArray($data)) {
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
$val = $this->takeColumn($val); $val = $this->takeColumn($val);
@@ -273,10 +236,8 @@ trait JsonQueriable
} else { } else {
$output = json_decode(json_encode($this->takeColumn($data)), $isObject); $output = json_decode(json_encode($this->takeColumn($data)), $isObject);
} }

return $output; return $output;
} }

/** /**
* Read JSON data from file * Read JSON data from file
* *
@@ -293,20 +254,14 @@ trait JsonQueriable
'header' => 'Content-Type: '.$type.'; charset=utf-8', 'header' => 'Content-Type: '.$type.'; charset=utf-8',
], ],
]; ];

$context = stream_context_create($opts); $context = stream_context_create($opts);
$data = file_get_contents($file, 0, $context); $data = file_get_contents($file, 0, $context);
$json = $this->isJson($data, true); $json = $this->isJson($data, true);

if (!$json) { if (!$json) {
throw new InvalidJsonException(); throw new InvalidJsonException();
} }

return $json; return $json;
} }



/** /**
* Get data from nested array * Get data from nested array
* *
@@ -319,32 +274,24 @@ trait JsonQueriable
if (empty($node) || $node == '.') { if (empty($node) || $node == '.') {
return $map; return $map;
} }

if ($node) { if ($node) {
$terminate = false; $terminate = false;
$path = explode('.', $node); $path = explode('.', $node);

foreach ($path as $val) { foreach ($path as $val) {
if (!is_array($map)) return $map; if (!is_array($map)) return $map;

if (!array_key_exists($val, $map)) { if (!array_key_exists($val, $map)) {
$terminate = true; $terminate = true;
break; break;
} }

$map = &$map[$val]; $map = &$map[$val];
} }

if ($terminate) { if ($terminate) {
return new ValueNotFound(); return new ValueNotFound();
} }

return $map; return $map;
} }

return new ValueNotFound(); return new ValueNotFound();
} }

/** /**
* get data from node path * get data from node path
* *
@@ -354,7 +301,6 @@ trait JsonQueriable
{ {
return $this->getFromNested($this->_map, $this->_node); return $this->getFromNested($this->_map, $this->_node);
} }

/** /**
* process AND and OR conditions * process AND and OR conditions
* *
@@ -375,10 +321,8 @@ trait JsonQueriable
if (!method_exists(Condition::class, $function)) { if (!method_exists(Condition::class, $function)) {
throw new ConditionNotAllowedException("Exception: $function condition not allowed"); throw new ConditionNotAllowedException("Exception: $function condition not allowed");
} }

$function = [Condition::class, $function]; $function = [Condition::class, $function];
} }

$value = $this->getFromNested($val, $rule['key']); $value = $this->getFromNested($val, $rule['key']);
$return = $value instanceof ValueNotFound ? false : call_user_func_array($function, [$value, $rule['value']]); $return = $value instanceof ValueNotFound ? false : call_user_func_array($function, [$value, $rule['value']]);
$tmp &= $return; $tmp &= $return;
@@ -387,10 +331,8 @@ trait JsonQueriable
} }
return $res; return $res;
}); });

return $result; return $result;
} }

/** /**
* make WHERE clause * make WHERE clause
* *
@@ -405,13 +347,11 @@ trait JsonQueriable
$value = $condition; $value = $condition;
$condition = '='; $condition = '=';
} }

if (count($this->_conditions) < 1) { if (count($this->_conditions) < 1) {
array_push($this->_conditions, []); array_push($this->_conditions, []);
} }
return $this->makeWhere($key, $condition, $value); return $this->makeWhere($key, $condition, $value);
} }

/** /**
* make WHERE clause with OR * make WHERE clause with OR
* *
@@ -426,12 +366,9 @@ trait JsonQueriable
$value = $condition; $value = $condition;
$condition = '='; $condition = '=';
} }

array_push($this->_conditions, []); array_push($this->_conditions, []);

return $this->makeWhere($key, $condition, $value); return $this->makeWhere($key, $condition, $value);
} }

/** /**
* generator for AND and OR where * generator for AND and OR where
* *
@@ -448,18 +385,14 @@ trait JsonQueriable
$key($this); $key($this);
return $this; return $this;
} }

array_push($current, [ array_push($current, [
'key' => $key, 'key' => $key,
'condition' => $condition, 'condition' => $condition,
'value' => $value, 'value' => $value,
]); ]);

$this->_conditions[$index] = $current; $this->_conditions[$index] = $current;

return $this; return $this;
} }

/** /**
* make WHERE IN clause * make WHERE IN clause
* *
@@ -473,7 +406,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE NOT IN clause * make WHERE NOT IN clause
* *
@@ -486,7 +418,6 @@ trait JsonQueriable
$this->where($key, 'notin', $value); $this->where($key, 'notin', $value);
return $this; return $this;
} }

/** /**
* make WHERE NULL clause * make WHERE NULL clause
* *
@@ -498,8 +429,6 @@ trait JsonQueriable
$this->where($key, 'null', 'null'); $this->where($key, 'null', 'null');
return $this; return $this;
} }


/** /**
* make WHERE Boolean clause * make WHERE Boolean clause
* *
@@ -513,7 +442,6 @@ trait JsonQueriable
} }
return $this; return $this;
} }

/** /**
* make WHERE NOT NULL clause * make WHERE NOT NULL clause
* *
@@ -526,7 +454,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE START WITH clause * make WHERE START WITH clause
* *
@@ -540,7 +467,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE ENDS WITH clause * make WHERE ENDS WITH clause
* *
@@ -554,7 +480,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE MATCH clause * make WHERE MATCH clause
* *
@@ -568,7 +493,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE CONTAINS clause * make WHERE CONTAINS clause
* *
@@ -582,7 +506,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE DATE clause * make WHERE DATE clause
* *
@@ -596,7 +519,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE month clause * make WHERE month clause
* *
@@ -610,7 +532,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make WHERE Year clause * make WHERE Year clause
* *
@@ -624,7 +545,6 @@ trait JsonQueriable


return $this; return $this;
} }

/** /**
* make macro for custom where clause * make macro for custom where clause
* *
@@ -638,7 +558,7 @@ trait JsonQueriable
self::$_rulesMap[$name] = $fn; self::$_rulesMap[$name] = $fn;
return true; return true;
} }

return false; return false;
} }
} }
?>

+ 2
- 107
src/system/libraries/jsonq/Jsonq.php View File

@@ -6,12 +6,9 @@ require_once(dirname(__FILE__)."/Exceptions/InvalidJsonException.php");
require_once(dirname(__FILE__)."/Exceptions/InvalidNodeException.php"); require_once(dirname(__FILE__)."/Exceptions/InvalidNodeException.php");
require_once(dirname(__FILE__)."/Exceptions/NullValueException.php"); require_once(dirname(__FILE__)."/Exceptions/NullValueException.php");
require_once(dirname(__FILE__)."/JsonQueriable.php"); require_once(dirname(__FILE__)."/JsonQueriable.php");


class Jsonq class Jsonq
{ {
use JsonQueriable; use JsonQueriable;

/** /**
* this constructor set main json file path * this constructor set main json file path
* otherwise create it and read file contents * otherwise create it and read file contents
@@ -27,7 +24,6 @@ class Jsonq
$this->import($jsonFile); $this->import($jsonFile);
} }
} }

/** /**
* Deep copy current instance * Deep copy current instance
* *
@@ -37,7 +33,6 @@ class Jsonq
{ {
return clone $this; return clone $this;
} }

/** /**
* Set node path, where JsonQ start to prepare * Set node path, where JsonQ start to prepare
* *
@@ -48,16 +43,12 @@ class Jsonq
public function from($node = null) public function from($node = null)
{ {
$this->_isProcessed = false; $this->_isProcessed = false;

if (is_null($node) || $node == '') { if (is_null($node) || $node == '') {
throw new NullValueException("Null node exception"); throw new NullValueException("Null node exception");
} }

$this->_node = $node; $this->_node = $node;

return $this; return $this;
} }

/** /**
* Alias of from() method * Alias of from() method
* *
@@ -69,7 +60,6 @@ class Jsonq
{ {
return $this->from($node); return $this->from($node);
} }

/** /**
* select desired column * select desired column
* *
@@ -82,10 +72,8 @@ class Jsonq
if (count($args) > 0 ){ if (count($args) > 0 ){
$this->_select = $args; $this->_select = $args;
} }

return $this; return $this;
} }

/** /**
* select desired column for except * select desired column for except
* *
@@ -98,10 +86,8 @@ class Jsonq
if (count($args) > 0 ){ if (count($args) > 0 ){
$this->_except = $args; $this->_except = $args;
} }

return $this; return $this;
} }

/** /**
* getting prepared data * getting prepared data
* *
@@ -112,10 +98,8 @@ class Jsonq
public function get($object = false) public function get($object = false)
{ {
$this->prepare(); $this->prepare();

return $this->prepareResult($this->_map, $object); return $this->prepareResult($this->_map, $object);
} }

/** /**
* alias of get method * alias of get method
* *
@@ -127,7 +111,6 @@ class Jsonq
{ {
return $this->get($object); return $this->get($object);
} }

/** /**
* check data exists in system * check data exists in system
* *
@@ -140,7 +123,6 @@ class Jsonq


return (!empty($this->_map) && !is_null($this->_map)); return (!empty($this->_map) && !is_null($this->_map));
} }

/** /**
* reset given data to the $_map * reset given data to the $_map
* *
@@ -153,20 +135,16 @@ class Jsonq
if (!is_null($data)) { if (!is_null($data)) {
$this->_baseContents = $data; $this->_baseContents = $data;
} }

if ($instance) { if ($instance) {
$self = new self(); $self = new self();
$self->collect($this->_baseContents); $self->collect($this->_baseContents);


return $self; return $self;
} }

$this->_map = $this->_baseContents; $this->_map = $this->_baseContents;
$this->reProcess(); $this->reProcess();

return $this; return $this;
} }

/** /**
* getting group data from specific column * getting group data from specific column
* *
@@ -177,7 +155,6 @@ class Jsonq
public function groupBy($column) public function groupBy($column)
{ {
$this->prepare(); $this->prepare();

$data = []; $data = [];
foreach ($this->_map as $map) { foreach ($this->_map as $map) {
$value = $this->getFromNested($map, $column); $value = $this->getFromNested($map, $column);
@@ -185,34 +162,27 @@ class Jsonq
$data[$value][] = $map; $data[$value][] = $map;
} }
} }

$this->_map = $data; $this->_map = $data;
return $this; return $this;
} }

public function countGroupBy($column) public function countGroupBy($column)
{ {

$this->prepare(); $this->prepare();

$data = []; $data = [];
foreach ($this->_map as $map) { foreach ($this->_map as $map) {
$value = $this->getFromNested($map, $column); $value = $this->getFromNested($map, $column);
if (!$value) { if (!$value) {
continue; continue;
} }

if (isset($data[$value])) { if (isset($data[$value])) {
$data[$value] ++; $data[$value] ++;
} else { } else {
$data[$value] = 1; $data[$value] = 1;
} }
} }

$this->_map = $data; $this->_map = $data;
return $this; return $this;
} }

/** /**
* count prepared data * count prepared data
* *
@@ -222,10 +192,8 @@ class Jsonq
public function count() public function count()
{ {
$this->prepare(); $this->prepare();

return count($this->_map); return count($this->_map);
} }

/** /**
* size is an alias of count * size is an alias of count
* *
@@ -236,7 +204,6 @@ class Jsonq
{ {
return $this->count(); return $this->count();
} }

/** /**
* sum prepared data * sum prepared data
* @param int $column * @param int $column
@@ -246,7 +213,6 @@ class Jsonq
public function sum($column = null) public function sum($column = null)
{ {
$this->prepare(); $this->prepare();

$sum = 0; $sum = 0;
if (is_null($column)) { if (is_null($column)) {
$sum = array_sum($this->_map); $sum = array_sum($this->_map);
@@ -256,13 +222,10 @@ class Jsonq
if (is_scalar($value)) { if (is_scalar($value)) {
$sum += $value; $sum += $value;
} }

} }
} }

return $sum; return $sum;
} }

/** /**
* getting max value from prepared data * getting max value from prepared data
* *
@@ -273,16 +236,13 @@ class Jsonq
public function max($column = null) public function max($column = null)
{ {
$this->prepare(); $this->prepare();

if (is_null($column)) { if (is_null($column)) {
$max = max($this->_map); $max = max($this->_map);
} else { } else {
$max = max(array_column($this->_map, $column)); $max = max(array_column($this->_map, $column));
} }

return $max; return $max;
} }

/** /**
* getting min value from prepared data * getting min value from prepared data
* *
@@ -293,16 +253,13 @@ class Jsonq
public function min($column = null) public function min($column = null)
{ {
$this->prepare(); $this->prepare();

if (is_null($column)) { if (is_null($column)) {
$min = min($this->_map); $min = min($this->_map);
} else { } else {
$min = min(array_column($this->_map, $column)); $min = min(array_column($this->_map, $column));
} }

return $min; return $min;
} }

/** /**
* getting average value from prepared data * getting average value from prepared data
* *
@@ -313,10 +270,8 @@ class Jsonq
public function avg($column = null) public function avg($column = null)
{ {
$this->prepare(); $this->prepare();

$count = $this->count(); $count = $this->count();
$total = $this->sum($column); $total = $this->sum($column);

return ($total/$count); return ($total/$count);
} }


@@ -330,15 +285,12 @@ class Jsonq
public function first($object = false) public function first($object = false)
{ {
$this->prepare(); $this->prepare();

$data = $this->_map; $data = $this->_map;
if (count($data) > 0) { if (count($data) > 0) {
return $this->prepareResult(reset($data), $object); return $this->prepareResult(reset($data), $object);
} }

return null; return null;
} }

/** /**
* getting last element of prepared data * getting last element of prepared data
* *
@@ -349,12 +301,10 @@ class Jsonq
public function last($object = false) public function last($object = false)
{ {
$this->prepare(); $this->prepare();

$data = $this->_map; $data = $this->_map;
if (count($data) > 0) { if (count($data) > 0) {
return $this->prepareResult(end($data), $object); return $this->prepareResult(end($data), $object);
} }

return null; return null;
} }


@@ -369,24 +319,19 @@ class Jsonq
public function nth($index, $object = false) public function nth($index, $object = false)
{ {
$this->prepare(); $this->prepare();

$data = $this->_map; $data = $this->_map;
$total_elm = count($data); $total_elm = count($data);
$idx = abs($index); $idx = abs($index);

if (!is_integer($index) || $total_elm < $idx || $index == 0 || !is_array($this->_map)) { if (!is_integer($index) || $total_elm < $idx || $index == 0 || !is_array($this->_map)) {
return null; return null;
} }

if ($index > 0) { if ($index > 0) {
$result = $data[$index - 1]; $result = $data[$index - 1];
} else { } else {
$result = $data[$this->count() + $index]; $result = $data[$this->count() + $index];
} }

return $this->prepareResult($result, $object); return $this->prepareResult($result, $object);
} }

/** /**
* sorting from prepared data * sorting from prepared data
* *
@@ -398,37 +343,30 @@ class Jsonq
public function sortBy($column, $order = 'asc') public function sortBy($column, $order = 'asc')
{ {
$this->prepare(); $this->prepare();

if (!is_array($this->_map)) { if (!is_array($this->_map)) {
return $this; return $this;
} }

usort($this->_map, function ($a, $b) use ($column, $order) { usort($this->_map, function ($a, $b) use ($column, $order) {
$val1 = $this->getFromNested($a, $column); $val1 = $this->getFromNested($a, $column);
$val2 = $this->getFromNested($b, $column); $val2 = $this->getFromNested($b, $column);
if (is_string($val1)) { if (is_string($val1)) {
$val1 = strtolower($val1); $val1 = strtolower($val1);
} }

if (is_string($val2)) { if (is_string($val2)) {
$val2 = strtolower($val2); $val2 = strtolower($val2);
} }

if ($val1 == $val2) { if ($val1 == $val2) {
return 0; return 0;
} }
$order = strtolower(trim($order)); $order = strtolower(trim($order));

if ($order == 'desc') { if ($order == 'desc') {
return ($val1 > $val2) ? -1 : 1; return ($val1 > $val2) ? -1 : 1;
} else { } else {
return ($val1 < $val2) ? -1 : 1; return ($val1 < $val2) ? -1 : 1;
} }
}); });

return $this; return $this;
} }

/** /**
* Sort prepared data using a custom sort function. * Sort prepared data using a custom sort function.
* *
@@ -440,16 +378,12 @@ class Jsonq
public function sortByCallable(callable $sortFunc) public function sortByCallable(callable $sortFunc)
{ {
$this->prepare(); $this->prepare();

if (!is_array($this->_map)) { if (!is_array($this->_map)) {
return $this; return $this;
} }

usort($this->_map, $sortFunc); usort($this->_map, $sortFunc);

return $this; return $this;
} }

/** /**
* Sort an array value * Sort an array value
* *
@@ -460,13 +394,11 @@ class Jsonq
{ {
if ($order == 'desc') { if ($order == 'desc') {
rsort($this->_map); rsort($this->_map);
}else{
} else {
sort($this->_map); sort($this->_map);
} }

return $this; return $this;
} }

/** /**
* getting data from desire path * getting data from desire path
* *
@@ -480,7 +412,6 @@ class Jsonq
{ {
return $this->from($path)->prepare()->get($object); return $this->from($path)->prepare()->get($object);
} }

/** /**
* take action of each element of prepared data * take action of each element of prepared data
* *
@@ -495,7 +426,6 @@ class Jsonq
$fn($key, $val); $fn($key, $val);
} }
} }

/** /**
* transform prepared data by using callable function * transform prepared data by using callable function
* *
@@ -506,15 +436,12 @@ class Jsonq
public function transform(callable $fn) public function transform(callable $fn)
{ {
$this->prepare(); $this->prepare();

$new_data = []; $new_data = [];
foreach ($this->_map as $key => $val) { foreach ($this->_map as $key => $val) {
$new_data[$key] = $fn($val); $new_data[$key] = $fn($val);
} }

return $this->prepareResult($new_data, false); return $this->prepareResult($new_data, false);
} }

/** /**
* pipe send output in next pipe * pipe send output in next pipe
* *
@@ -526,18 +453,14 @@ class Jsonq
public function pipe(callable $fn, $class = null) public function pipe(callable $fn, $class = null)
{ {
$this->prepare(); $this->prepare();

if (is_string($fn) && !is_null($class)) { if (is_string($fn) && !is_null($class)) {
$instance = new $class; $instance = new $class;

$this->_map = call_user_func_array([$instance, $fn], [$this]); $this->_map = call_user_func_array([$instance, $fn], [$this]);
return $this; return $this;
} }

$this->_map = $fn($this); $this->_map = $fn($this);
return $this; return $this;
} }

/** /**
* filtered each element of prepared data * filtered each element of prepared data
* *
@@ -549,7 +472,6 @@ class Jsonq
public function filter(callable $fn, $key = false) public function filter(callable $fn, $key = false)
{ {
$this->prepare(); $this->prepare();

$data = []; $data = [];
foreach ($this->_map as $k => $val) { foreach ($this->_map as $k => $val) {
if ($fn($val)) { if ($fn($val)) {
@@ -560,10 +482,8 @@ class Jsonq
} }
} }
} }

return $this->prepareResult($data, false); return $this->prepareResult($data, false);
} }

/** /**
* then method set position of working data * then method set position of working data
* *
@@ -575,12 +495,9 @@ class Jsonq
public function then($node) public function then($node)
{ {
$this->_map = $this->prepare()->first(false); $this->_map = $this->prepare()->first(false);

$this->from($node); $this->from($node);

return $this; return $this;
} }

/** /**
* import raw JSON data for process * import raw JSON data for process
* *
@@ -590,14 +507,11 @@ class Jsonq
public function json($data) public function json($data)
{ {
$json = $this->isJson($data, true); $json = $this->isJson($data, true);

if ($json) { if ($json) {
return $this->collect($json); return $this->collect($json);
} }

return $this; return $this;
} }

/** /**
* import parsed data from raw json * import parsed data from raw json
* *
@@ -608,10 +522,8 @@ class Jsonq
{ {
$this->_map = $this->objectToArray($data); $this->_map = $this->objectToArray($data);
$this->_baseContents = &$this->_map; $this->_baseContents = &$this->_map;

return $this; return $this;
} }

/** /**
* implode resulting data from desire key and delimeter * implode resulting data from desire key and delimeter
* *
@@ -623,23 +535,19 @@ class Jsonq
public function implode($key, $delimiter = ',') public function implode($key, $delimiter = ',')
{ {
$this->prepare(); $this->prepare();

$implode = []; $implode = [];
if (is_string($key)) { if (is_string($key)) {
return $this->makeImplode($key, $delimiter); return $this->makeImplode($key, $delimiter);
} }

if (is_array($key)) { if (is_array($key)) {
foreach ($key as $k) { foreach ($key as $k) {
$imp = $this->makeImplode($k, $delimiter); $imp = $this->makeImplode($k, $delimiter);
$implode[$k] = $imp; $implode[$k] = $imp;
} }

return $implode; return $implode;
} }
return ''; return '';
} }

/** /**
* process implode from resulting data * process implode from resulting data
* *
@@ -650,14 +558,11 @@ class Jsonq
protected function makeImplode($key, $delimiter) protected function makeImplode($key, $delimiter)
{ {
$data = array_column($this->_map, $key); $data = array_column($this->_map, $key);

if (is_array($data)) { if (is_array($data)) {
return implode($delimiter, $data); return implode($delimiter, $data);
} }

return null; return null;
} }

/** /**
* getting specific key's value from prepared data * getting specific key's value from prepared data
* *
@@ -668,10 +573,8 @@ class Jsonq
public function column($column) public function column($column)
{ {
$this->prepare(); $this->prepare();

return array_column($this->_map, $column); return array_column($this->_map, $column);
} }

/** /**
* getting raw JSON from prepared data * getting raw JSON from prepared data
* *
@@ -681,10 +584,8 @@ class Jsonq
public function toJson() public function toJson()
{ {
$this->prepare(); $this->prepare();

return json_encode($this->_map); return json_encode($this->_map);
} }

/** /**
* getting all keys from prepared data * getting all keys from prepared data
* *
@@ -694,10 +595,8 @@ class Jsonq
public function keys() public function keys()
{ {
$this->prepare(); $this->prepare();

return array_keys($this->_map); return array_keys($this->_map);
} }

/** /**
* getting all values from prepared data * getting all values from prepared data
* *
@@ -707,10 +606,8 @@ class Jsonq
public function values() public function values()
{ {
$this->prepare(); $this->prepare();

return array_values($this->_map); return array_values($this->_map);
} }

/** /**
* getting chunk values from prepared data * getting chunk values from prepared data
* *
@@ -722,10 +619,8 @@ class Jsonq
public function chunk($amount, callable $fn = null) public function chunk($amount, callable $fn = null)
{ {
$this->prepare(); $this->prepare();

$chunk_value = array_chunk($this->_map, $amount); $chunk_value = array_chunk($this->_map, $amount);
$chunks = []; $chunks = [];

if (!is_null($fn) && is_callable($fn)) { if (!is_null($fn) && is_callable($fn)) {
foreach ($chunk_value as $chunk) { foreach ($chunk_value as $chunk) {
$return = $fn($chunk); $return = $fn($chunk);
@@ -735,7 +630,7 @@ class Jsonq
} }
return count($chunks) > 0 ? $chunks : null; return count($chunks) > 0 ? $chunks : null;
} }

return $chunk_value; return $chunk_value;
} }
} }
?>

+ 2
- 1
src/system/libraries/jsonq/Results/ValueNotFound.php View File

@@ -4,4 +4,5 @@ if (!defined('DEDEINC')) exit('dedebiz');
* This class represents a query result where a given * This class represents a query result where a given
* value was queried but did not exist. * value was queried but did not exist.
*/ */
class ValueNotFound {}
class ValueNotFound {}
?>

+ 1
- 1
src/system/taglib/help/adminname.txt View File

@@ -1,4 +1,4 @@
获得作者名称
作者名称标签
>>dede>> >>dede>>
{dede:adminname/} {dede:adminname/}
>>dede>> >>dede>>

+ 1
- 1
src/system/taglib/help/arclist.txt View File

@@ -1,4 +1,4 @@
文档列表调用标记
文档列表标签
>>dede>> >>dede>>
{dede:arclist typeid='' row='' col='' titlelen='' flag='h' infolen='' imgwidth='' imgheight='' listtype='' orderby='' keyword='' limit='0,1'} {dede:arclist typeid='' row='' col='' titlelen='' flag='h' infolen='' imgwidth='' imgheight='' listtype='' orderby='' keyword='' limit='0,1'}
<a href='[field:arcurl/]'>[field:title/]</a> <a href='[field:arcurl/]'>[field:title/]</a>


+ 1
- 1
src/system/taglib/help/arclistsg.txt View File

@@ -1,4 +1,4 @@
自定义模型的文档列表调用标记
自定义模型文档列表标签
>>dede>> >>dede>>
{dede:arclistsg typeid='' row='' flag='h' col='' titlelen='' orderway='' keyword='' limit='0,1'} {dede:arclistsg typeid='' row='' flag='h' col='' titlelen='' orderway='' keyword='' limit='0,1'}
<a href='[field:arcurl/]'>[field:title/]</a> <a href='[field:arcurl/]'>[field:title/]</a>


+ 5
- 7
src/system/taglib/help/ask.txt View File

@@ -1,13 +1,11 @@
问答调用标签
问答标签
>>dede>> >>dede>>
{dede:ask row='6' qtype='new' tid='0' titlelen='24'}
<dd>
<span class="tclass">[<a href='[field:typeurl/]'>[field:tidname/]</a>]</span>
<span class="tlink"><a href="[field:url/]">[field:title/]</a></span>
</dd>
{dede:ask row='6' qtype='new' tid='0' titlelen='30'}
[<a href='[field:typeurl/]'>[field:tidname/]</a>]
<a href="[field:url/]">[field:title/]</a>
{/dede:ask} {/dede:ask}
>>dede>> >>dede>>
row='6' 调用条数 row='6' 调用条数
qtype='new' 排序类型commend推荐、ok表示已解决问题、high高分问题 、new最新问题 qtype='new' 排序类型commend推荐、ok表示已解决问题、high高分问题 、new最新问题
tid='0' 栏目id,默认是全部 tid='0' 栏目id,默认是全部
titlelen='24' 标题长度
titlelen='30' 标题长度

+ 1
- 1
src/system/taglib/help/autochannel.txt View File

@@ -1,4 +1,4 @@
按排序位置获取单个栏目链接信息
按排序位置获取单个栏目链接信息
>>dede>> >>dede>>
{dede:autochannel partsort='' typeid=''}{/dede:autochannel} {dede:autochannel partsort='' typeid=''}{/dede:autochannel}
>>dede>> >>dede>>


+ 4
- 8
src/system/taglib/help/bookcontentlist.txt View File

@@ -1,13 +1,9 @@
连载图书最新文档调用
连载图书最新文档标签
>>dede>> >>dede>>
{dede:bookcontentlist row='12' booktype='-1' orderby='lastpost' author='' keyword=''} {dede:bookcontentlist row='12' booktype='-1' orderby='lastpost' author='' keyword=''}
<table width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width='40%'>[[field:cataloglink/]] [field:booklink/]</td>
<td width='40%'>[field:contentlink/]</td>
<td width='20%'>[field:lastpost function="GetDateMk(@me)"/]</td>
</tr>
</table>
[field:cataloglink/] [field:booklink/]
[field:contentlink/]
[field:lastpost function="GetDateMk(@me)"/]
{/dede:bookcontentlist} {/dede:bookcontentlist}
>>dede>> >>dede>>
这个标签和booklist实际是完全相同的,只是默认底层模板不同 这个标签和booklist实际是完全相同的,只是默认底层模板不同


+ 1
- 1
src/system/taglib/help/booklist.txt View File

@@ -1,4 +1,4 @@
连载图书调用
连载图书标签
>>dede>> >>dede>>
{dede:booklist row='12' booktype='-1' orderby='lastpost' author='' keyword=''} {dede:booklist row='12' booktype='-1' orderby='lastpost' author='' keyword=''}
<a href='[field:bookurl/]'>[field:bookname/]</a> <a href='[field:bookurl/]'>[field:bookname/]</a>


+ 1
- 1
src/system/taglib/help/channel.txt View File

@@ -1,7 +1,7 @@
获取栏目列表标签 获取栏目列表标签
>>dede>> >>dede>>
{dede:channel type='top' typeid='' notypeid='' row='8' currentstyle="<li><a href='~typelink~' class='thisclass'>~typename~</a></li>"} {dede:channel type='top' typeid='' notypeid='' row='8' currentstyle="<li><a href='~typelink~' class='thisclass'>~typename~</a></li>"}
<li><a href='[field:typelink/]'>[field:typename/]</a> </li>
<li><a href='[field:typelink/]'>[field:typename/]</a></li>
{/dede:channel} {/dede:channel}
>>dede>> >>dede>>
typeid='' 调用栏目id,用英文逗号分开表示多个栏目 typeid='' 调用栏目id,用英文逗号分开表示多个栏目


+ 7
- 9
src/system/taglib/help/channelartlist.txt View File

@@ -1,21 +1,19 @@
获取当前栏目下级栏目文档列表标签
当前栏目下级栏目文档列表标签
>>dede>> >>dede>>
{dede:channelartlist typeid='' notypeid='' row='6'} {dede:channelartlist typeid='' notypeid='' row='6'}
<dl>
<dt><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></dt>
<dd>
<ul>
<li><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a>
{dede:arclist titlelen='42' row='10'} {dede:arclist titlelen='42' row='10'}
<ul class='autod'>
<ul>
<li><a href="[field:arcurl/]">[field:title/]</a></li> <li><a href="[field:arcurl/]">[field:title/]</a></li>
<li>([field:pubdate function="MyDate('m-d',@me)"/])</li> <li>([field:pubdate function="MyDate('m-d',@me)"/])</li>
</ul> </ul>
{/dede:arclist} {/dede:arclist}
</dd>
</dl>
</li>
{/dede:channelartlist} {/dede:channelartlist}
>>dede>> >>dede>>
typeid='' 调用栏目id,用英文逗号分开表示多个栏目 typeid='' 调用栏目id,用英文逗号分开表示多个栏目
notypeid='' 不调用栏目id,用英文逗号分开表示多个栏目 notypeid='' 不调用栏目id,用英文逗号分开表示多个栏目
row='20' 获取的栏目返回值 row='20' 获取的栏目返回值
除了宏标记外,channelArtlist 是唯一一个可以直接嵌套其它标记的标记,不过仅限于嵌套
{dede:type}{/dede:type}和{dede:arclist}{/dede:arclist}两个标
除了宏标签外,channelArtlist 是唯一一个可以直接嵌套其它标签的标签,不过仅限于嵌套
{dede:type}{/dede:type}和{dede:arclist}{/dede:arclist}两个标

+ 1
- 1
src/system/taglib/help/demotag.txt View File

@@ -1,4 +1,4 @@
这仅是一个演示标签
演示标签
>>dede>> >>dede>>
{dede:demotag/} {dede:demotag/}
>>dede>> >>dede>>


+ 3
- 5
src/system/taglib/help/feedback.txt View File

@@ -1,10 +1,8 @@
调用最新评论
调用最新评论标签
>>dede>> >>dede>>
{dede:feedback} {dede:feedback}
<ul>
<li class='fbtitle'>[field:username function="(@me=='guest' ? '游客' : @me)"/]对[field:title/]的评论:</li>
<li class='fbmsg'><a href="apps/feedback.php?aid=[field:aid/]">[field:msg/]</a></li>
</ul>
[field:username function="(@me=='guest' ? '游客' : @me)"/]对[field:title/]的评论
<a href="apps/feedback.php?aid=[field:aid/]">[field:msg/]</a></li>
{/dede:feedback} {/dede:feedback}
>>dede>> >>dede>>
row='12' 调用评论条数 row='12' 调用评论条数


+ 4
- 4
src/system/taglib/help/flink.txt View File

@@ -1,9 +1,9 @@
友情链接
友情链接标签
>>dede>> >>dede>>
{dede:flink row='24'/}
{dede:flink row='30'/}
>>dede>> >>dede>>
type='image' 或textall,图片链接,text文字链接; type='image' 或textall,图片链接,text文字链接;
row='24' 链接数量
row='30' 链接数量
titlelen='24' 站点文字的长度 titlelen='24' 站点文字的长度
linktype='1' 链接位置(1首页,2内页) linktype='1' 链接位置(1首页,2内页)
typeid='0' 所有类型
typeid='0' 所有类型

+ 3
- 5
src/system/taglib/help/group.txt View File

@@ -1,10 +1,8 @@
圈子调用标签
圈子标签
>>dede>> >>dede>>
{dede:group row='6' orderby='threads' titlelen='30'} {dede:group row='6' orderby='threads' titlelen='30'}
<li>
<span><img style="visibility: inherit;" title="[field:groupname/]" src="[field:icon/]" /></span>
<span><a href="[field:url/]" title="[field:groupname/]" target="_blank">[field:groupname/]</a></span>
</li>
<img style="visibility: inherit;" title="[field:groupname/]" src="[field:icon/]">
<a href="[field:url/]" title="[field:groupname/]" target="_blank">[field:groupname/]</a>
{/dede:group} {/dede:group}
>>dede>> >>dede>>
row='6' 调用条数 row='6' 调用条数


+ 1
- 3
src/system/taglib/help/groupthread.txt View File

@@ -1,10 +1,8 @@
圈子主题调用标签
圈子主题标签
>>dede>> >>dede>>
{dede:groupthread gid='0' orderby='dateline' orderway='desc' row='12' titlelen='30'} {dede:groupthread gid='0' orderby='dateline' orderway='desc' row='12' titlelen='30'}
<li>
<a href='[field:groupurl/]' target="_blank">[[field:groupname function="cn_substr(@me,10)"/]]</a> <a href='[field:groupurl/]' target="_blank">[[field:groupname function="cn_substr(@me,10)"/]]</a>
<a href="[field:url/]" title="[field:subject/]" target="_blank">[field:subject/]</a>([field:lastpost function="GetDateMk('@me')"/]) <a href="[field:url/]" title="[field:subject/]" target="_blank">[field:subject/]</a>([field:lastpost function="GetDateMk('@me')"/])
</li>
{/dede:groupthread} {/dede:groupthread}
>>dede>> >>dede>>
gid='0' 圈子id,默认为全部 gid='0' 圈子id,默认为全部


+ 1
- 1
src/system/taglib/help/hotwords.txt View File

@@ -1,4 +1,4 @@
获取网站搜索热门关键词
网站搜索热门关键词标签
>>dede>> >>dede>>
{dede:hotwords/} {dede:hotwords/}
>>dede>> >>dede>>


+ 1
- 1
src/system/taglib/help/infoguide.txt View File

@@ -1,4 +1,4 @@
分类信息地区与小分类搜索
分类信息地区与小分类搜索标签
>>dede>> >>dede>>
{dede:infoguide/} {dede:infoguide/}
>>dede>> >>dede>>

+ 1
- 1
src/system/taglib/help/infolink.txt View File

@@ -1,4 +1,4 @@
分类信息地区与类型快捷链接
分类信息地区与类型快捷链接标签
>>dede>> >>dede>>
{dede:infolink/} {dede:infolink/}
>>dede>> >>dede>>

+ 4
- 2
src/system/taglib/help/jsonq.txt View File

@@ -1,7 +1,9 @@
JSONQ标签 JSONQ标签
>>dede>> >>dede>>
{dede:jsonq url='https://www.dedebiz.com/api/v1/ping' path='list' cachetime=3600}[field:id/] - [field:name/]<br/>{/dede:jsonq}
{dede:jsonq url='https://www.dedebiz.com/api/v1/ping' path='list' cachetime='3600'}
<a href="[field:arcurl/]">[field:title/]</a>
{/dede:json}
>>dede>> >>dede>>
url='' JSON接口地址 url='' JSON接口地址
path='' 路径(可选),如果为空[field:path/]可获取指定path的值 path='' 路径(可选),如果为空[field:path/]可获取指定path的值
cachetime=3600 缓存时间
cachetime='3600' 缓存时间

+ 1
- 1
src/system/taglib/help/likepage.txt View File

@@ -1,4 +1,4 @@
单页文档相同标识调用标签
单页文档相同标识标签
>>dede>> >>dede>>
{dede:likepage likeid='' row=''/} {dede:likepage likeid='' row=''/}
>>dede>> >>dede>>


+ 1
- 1
src/system/taglib/help/likesgpage.txt View File

@@ -1,4 +1,4 @@
单页文档调用标签
单页文档标签
>>dede>> >>dede>>
{dede:likespage row=''/} {dede:likespage row=''/}
>>dede>> >>dede>>

+ 1
- 1
src/system/taglib/help/loop.txt View File

@@ -1,4 +1,4 @@
调用任意表数据标签
任意表数据标签
>>dede>> >>dede>>
{dede:loop table='dede_archives' sort='' row='4' if=''} {dede:loop table='dede_archives' sort='' row='4' if=''}
<a href='[field:arcurl/]'>[field:title/]</a> <a href='[field:arcurl/]'>[field:title/]</a>


+ 1
- 1
src/system/taglib/help/memberlist.txt View File

@@ -1,4 +1,4 @@
会员信息调用标签
会员信息标签
>>dede>> >>dede>>
{dede:memberlist orderby='scores' row='20'} {dede:memberlist orderby='scores' row='20'}
<a href="../user/index.php?uid={dede:field.userid/}">{dede:field.userid/}</a> <a href="../user/index.php?uid={dede:field.userid/}">{dede:field.userid/}</a>


+ 1
- 1
src/system/taglib/help/myad.txt View File

@@ -1,4 +1,4 @@
广告调用
广告标签
>>dede>> >>dede>>
{dede:myad name=''/} {dede:myad name=''/}
>>dede>> >>dede>>


+ 2
- 2
src/system/taglib/help/mytag.txt View File

@@ -1,6 +1,6 @@
自定义宏标记调用标签
自定义宏标标签
>>dede>> >>dede>>
{dede:mytag typeid='0' name=''/} {dede:mytag typeid='0' name=''/}
>>dede>> >>dede>>
typeid='0' 栏目id,0为全站栏目 typeid='0' 栏目id,0为全站栏目
name='' 标
name='' 标

+ 2
- 2
src/system/taglib/help/sonchannel.txt View File

@@ -1,8 +1,8 @@
子栏目调用标签
子栏目标签
>>dede>> >>dede>>
{dede:sonchannel} {dede:sonchannel}
<a href='[field:typeurl/]'>[field:typename/]</a> <a href='[field:typeurl/]'>[field:typename/]</a>
{/dede:sonchannel} {/dede:sonchannel}
>>dede>> >>dede>>
row='100' 返回数目 row='100' 返回数目
col='1' 默认单列显示
col='1' 默认单列显示

+ 1
- 1
src/system/taglib/help/tag.txt View File

@@ -1,4 +1,4 @@
TAG调用标签
TAG标签
>>dede>> >>dede>>
{dede:tag row='30' sort='new'/} {dede:tag row='30' sort='new'/}
>>dede>> >>dede>>


+ 1
- 1
src/system/taglib/help/type.txt View File

@@ -1,4 +1,4 @@
指定的单个栏目的链接标签
指定单个栏目数据标签
>>dede>> >>dede>>
{dede:type} {dede:type}
<a href="[field:typelink/]">[field:typename/]</a> <a href="[field:typelink/]">[field:typename/]</a>


+ 1
- 8
src/system/taglib/jsonq.lib.php View File

@@ -1,5 +1,4 @@
<?php <?php

/** /**
* JSONQ标签 * JSONQ标签
* *
@@ -16,9 +15,7 @@ function lib_jsonq(&$ctag, &$refObj)
$attlist = "url|,path|,cachetime|3600"; $attlist = "url|,path|,cachetime|3600";
FillAttsDefault($ctag->CAttribute->Items, $attlist); FillAttsDefault($ctag->CAttribute->Items, $attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP); extract($ctag->CAttribute->Items, EXTR_SKIP);

$Innertext = trim($ctag->GetInnerText()); $Innertext = trim($ctag->GetInnerText());

if ($url == '' || $Innertext == '') return ''; if ($url == '' || $Innertext == '') return '';
$key = md5($url); $key = md5($url);
try { try {
@@ -42,7 +39,6 @@ function lib_jsonq(&$ctag, &$refObj)
SetCache("tagjsonq2", $key, $revalue, $cachetime); SetCache("tagjsonq2", $key, $revalue, $cachetime);
return $revalue; return $revalue;
} }
$row = GetCache("tagjsonq", $key); $row = GetCache("tagjsonq", $key);
if (!is_array($row) || $cachetime == 0) { if (!is_array($row) || $cachetime == 0) {
$jsonq = new Jsonq($url); $jsonq = new Jsonq($url);
@@ -52,14 +48,11 @@ function lib_jsonq(&$ctag, &$refObj)
if (!is_array($row)) { if (!is_array($row)) {
return ""; return "";
} }

$ctp = new DedeTagParse(); $ctp = new DedeTagParse();
$ctp->SetNameSpace('field', '[', ']'); $ctp->SetNameSpace('field', '[', ']');
$ctp->LoadSource($Innertext); $ctp->LoadSource($Innertext);

$GLOBALS['autoindex'] = 0; $GLOBALS['autoindex'] = 0;
$revalue = ""; $revalue = "";

foreach ($row as $key => $value) { foreach ($row as $key => $value) {
$GLOBALS['autoindex']++; $GLOBALS['autoindex']++;
foreach ($ctp->CTags as $tagid => $ctag) { foreach ($ctp->CTags as $tagid => $ctag) {
@@ -75,9 +68,9 @@ function lib_jsonq(&$ctag, &$refObj)
} }
$revalue .= $ctp->GetResult(); $revalue .= $ctp->GetResult();
} }

return $revalue; return $revalue;
} catch (Exception $e) { } catch (Exception $e) {
return ""; return "";
} }
} }
?>

Loading…
Cancel
Save