Source of file ChunkShortcodeHandler.php
Size: 1,075 Bytes - Last Modified: 2021-12-24T06:43:55+00:00
/var/www/docs.ssmods.com/process/src/code/ChunkShortcodeHandler.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344 | <?php /** * Created by PhpStorm. * User: robert * Date: 05.03.17 * Time: 15:02 */ class ChunkShortcodeHandler extends Object { /** * Use by Shortcode * e.g.[chunk t=MyToken] * can be set by configuration: * ChunkShortcodeHandler: * token_identifier: token # or whatever * * * @var string */ private static $token_identifier = 't'; public static function handle_chunk_shortcode($args, $token = null,$parser = null) { $ident=null; $needle = self::config()->token_identifier; if( is_array($args) && isset($args['id']) ) { $chunk = Chunk::get()->byID((int)$args['id']); return $chunk instanceof Chunk ? $chunk->outputObject() : false; } else { if ($token) { $ident = $token; } elseif (array_key_exists($needle, $args)) { $ident = $args[$needle]; } if ($output = Chunk::by_token($ident)) { return $output; } } return false; } } |