public function __call($method, $arguments) { // Get all the parameter/filters $filters = $this->attributes; // Default content to context $content = $this->context; // Override content by a specific page if needed if ($from = $this->fetchParam('from')) { $content = current(ContentService::getContentByURL($from)->get()); unset($filters['from']); } // Grab the field data $field_data = array_get($content, $method); // Filter down to what we're looking for $values = array_values(array_filter($field_data, function ($i) use($filters) { foreach ($filters as $key => $val) { $match = array_get($i, $key) == $val; if (!$match) { break; } } return $match; })); // No results? if (empty($values)) { return array('no_results' => true); } // Got something. Yay. Return it. return Parse::tagLoop($this->content, $values, true); }
public function listing() { $role = $this->fetchParam('role', false); $limit = $this->fetchParam('limit', null, 'is_numeric'); // defaults to none $offset = $this->fetchParam('offset', 0, 'is_numeric'); // defaults to zero $sort_by = $this->fetchParam('sort_by', 'title'); // defaults to date $sort_dir = $this->fetchParam('sort_dir', 'desc'); // defaults to desc $members = Statamic_Auth::get_user_list(false); if (is_array($members) && count($members) > 0) { $members = array_slice($members, $offset, $limit, true); if ($sort_by == 'random') { shuffle($list); } elseif ($sort_by != 'title' || $sort_by != 'username') { # sort by any other field usort($members, function ($a, $b) use($sort_by) { if (isset($a[$sort_by]) && isset($b[$sort_by])) { return strcmp($b[$sort_by], $a[$sort_by]); } }); } // default sort is asc if ($sort_dir == 'desc') { $members = array_reverse($members); } return Parse::tagLoop($this->content, $members); } else { return array('no_results' => true); } }
public function index() { $from = $this->fetchParam('from', false); if (!$from) { return null; } // account for subfolder if (strpos($from, Config::getSiteRoot()) !== 0) { $from = Path::tidy(Config::getSiteRoot() . $from); } $from = Path::addStartingSlash($from); $content_set = ContentService::getContentByURL($from); // filter $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)))); // limit $limit = $this->fetchParam('limit', 1, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $content_set->limit($limit, $offset); // check for results if (!$content_set->count()) { return Parse::tagLoop($this->content, array(array('no_results' => true))); } // if content is used in this entries loop, parse it $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content); return Parse::tagLoop($this->content, $content_set->get($parse_content), false, $this->context); }
/** * Lists entries based on passed parameters * * @return array|string */ public function getContent($variable) { $urls = array_get($this->context, $variable); if (!$urls) { return null; } // grab common parameters $settings = $this->parseCommonParameters(); // grab content set based on the common parameters // $content_set = $this->getContentSet($settings); $content_set = ContentService::getContentByURL($urls); $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)))); // limit $limit = $this->fetchParam('limit', null, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); if ($limit || $offset) { $content_set->limit($limit, $offset); } // sort $sort_by = $this->fetchParam('sort_by'); $sort_dir = $this->fetchParam('sort_dir'); if ($sort_by || $sort_dir) { $content_set->sort($sort_by, $sort_dir); } // check for results if (!$content_set->count()) { return Parse::template($this->content, array('no_results' => true)); } return Parse::tagLoop($this->content, $content_set->get(), false, $this->context); }
/** * Get Instagram media * @return array parsed response from a public Instagram feed */ public function index() { $username = $this->fetch('username'); $limit = $this->fetch('limit', false, 'is_numeric'); $offset = $this->fetch('offset', 0, 'is_numeric'); $media = $this->tasks->getMedia($username, $limit, $offset); return Parse::tagLoop($this->content, $media); }
public function count() { $url = $this->fetchParam('from', URL::getCurrent()); $url = Path::resolve($url); $max_depth = $this->fetchParam('max_depth', 1, 'is_numeric'); $tree = Statamic::get_content_tree($url, 1, $max_depth); if ($this->content != '') { return Parse::tagLoop($this->content, $tree); } else { return count($tree); } }
/** * Email Form * * Allows you to create an email form and parses the posted data. */ public function index() { // Setup the gazillion options $options['to'] = $this->fetchParam('to'); $options['cc'] = $this->fetchParam('cc', ''); $options['bcc'] = $this->fetchParam('bcc', ''); $options['from'] = $this->fetchParam('from', ''); $options['msg_header'] = $this->fetchParam('msg_header', 'New Message', false, false, false); $options['msg_footer'] = $this->fetchParam('msg_footer', '', false, false, false); $options['subject'] = $this->fetchParam('subject', 'Email Form', false, false, false); $options['class'] = $this->fetchParam('class', ''); $options['id'] = $this->fetchParam('id', ''); $options['data'] = $this->fetchParam('data', ''); $required = $this->fetchParam('required'); $honeypot = $this->fetchParam('honeypot', false, false, true); #boolen param // Set up some default vars. $output = ''; $vars = array(array()); // If the page has post data process it. if (isset($_POST) and !empty($_POST)) { if (!$this->validate($_POST, $required)) { $vars = array(array('error' => true, 'errors' => $this->validation)); } elseif ($this->send($_POST, $options)) { $vars = array(array('success' => true)); } else { $vars = array(array('error' => true, 'errors' => 'Could not send email')); } } // Display the form on the page. $output .= '<form method="post"'; if ($options['class'] != '') { $output .= ' class="' . $options['class'] . '"'; } if ($options['id'] != '') { $output .= ' id="' . $options['id'] . '"'; } if ($options['data'] != '') { $output .= ' data="' . $options['data'] . '"'; } $output .= '>'; $output .= Parse::tagLoop($this->content, $vars); //inject the honeypot if true if ($honeypot) { $output .= '<input type="text" name="username" value="" style="display:none" />'; } $output .= '</form>'; return $output; }
/** * Lists entries based on passed parameters * * @return array|string */ public function listing() { $folders = $this->fetchParam('folder', $this->fetchParam('folders', ltrim($this->fetchParam('from', URL::getCurrent()), "/"))); $folders = $folders === "/" ? "" : $folders; if ($this->fetchParam('taxonomy', false, null, true, null)) { $taxonomy_parts = Taxonomy::getCriteria(URL::getCurrent()); $taxonomy_type = $taxonomy_parts[0]; $taxonomy_slug = Config::get('_taxonomy_slugify') ? Slug::humanize($taxonomy_parts[1]) : urldecode($taxonomy_parts[1]); $content_set = ContentService::getContentByTaxonomyValue($taxonomy_type, $taxonomy_slug, $folders); } else { $content_set = ContentService::getContentByFolders($folders); } // filter $content_set->filter(array('show_all' => $this->fetchParam('show_hidden', false, null, true, false), 'since' => $this->fetchParam('since'), 'until' => $this->fetchParam('until'), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'entries', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)))); // sort $content_set->sort($this->fetchParam('sort_by', 'order_key'), $this->fetchParam('sort_dir')); // grab total entries for setting later $total_entries = $content_set->count(); // limit $limit = $this->fetchParam('limit', null, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $paginate = $this->fetchParam('paginate', true, null, true, false); if ($limit || $offset) { if ($limit && $paginate && !$offset) { // pagination requested, isolate the appropriate page $content_set->isolatePage($limit, URL::getCurrentPaginationPage()); } else { // just limit or offset $content_set->limit($limit, $offset); } } // manually supplement $content_set->supplement(array('total_found' => $total_entries, 'group_by_date' => $this->fetchParam("group_by_date", null, null, false, false))); // check for results if (!$content_set->count()) { return Parse::tagLoop($this->content, array(array('no_results' => true))); } // if content is used in this entries loop, parse it $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content); return Parse::tagLoop($this->content, $content_set->get($parse_content)); }
public function listing() { // grab a taxonomy set from the content service $taxonomy_set = ContentService::getTaxonomiesByType($this->fetchParam('type', null)); // folders $folders = $this->fetchParam('folder', $this->fetchParam('folders', ltrim($this->fetchParam('from', URL::getCurrent()), "/"))); // now filter that down to just what we want $taxonomy_set->filter(array('folders' => $folders, 'show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'since' => $this->fetchParam('since', null), 'until' => $this->fetchParam('until', null), 'min_count' => $this->fetchParam('min_count', 1, 'is_numeric'), 'show_future' => $this->fetchParam('show_future', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true, false), 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)), 'where' => trim($this->fetchParam('where', null, false, false, false)))); // sort as needed $taxonomy_set->sort($this->fetchParam('sort_by', 'name'), $this->fetchParam('sort_dir', 'asc')); // trim to limit the number of results $taxonomy_set->limit($this->fetchParam('limit', null, 'is_numeric')); // contextualize the urls to the given folder $taxonomy_set->contextualize($this->fetchParam('folder', null)); $output = $taxonomy_set->get(); // no results found, return so if (!count($output)) { return array('no_results' => true); } // results found, parse the tag loop with our content return Parse::tagLoop($this->content, $output, true, $this->context); }
/** * Paginate search results * * @return string */ public function pagination() { // determine configuration $dataset = $this->fetch('dataset', null, false, false, false); $parameters = $this->gatherParameters(); $config = $this->tasks->loadDataset($dataset, $parameters); // short-circuit this if no query if (!trim($config['query'])) { return Parse::tagLoop($this->content, array(array('no_query' => true, '_query' => ''))); } // do search $output = $this->tasks->lookUp($config['query'], $config); // get limit $limit = $config['limit'] ? $config['limit'] : 10; // get the query variables $query_var = $config['query_variable']; $query = urlencode($config['query']); // count the content available $count = count($output); // take page_limit into account if ($config['page_limit'] && $count > $config['page_limit'] * $limit) { $count = $config['page_limit'] * $limit; } // check for errors if (isset($output[0]['no_results']) || isset($output[0]['no_query'])) { return Parse::tagLoop($this->content, $output); } $pagination_variable = Config::getPaginationVariable(); $page = Request::get($pagination_variable, 1); $data = array('total_items' => (int) max(0, $count), 'items_per_page' => (int) max(1, $limit), 'total_pages' => (int) ceil($count / $limit), 'current_page' => (int) min(max(1, $page), max(1, $page)), 'current_first_item' => (int) min(($page - 1) * $limit + 1, $count)); $data['current_last_item'] = (int) min($data['current_first_item'] + $limit - 1, $count); $data['previous_page'] = $data['current_page'] > 1 ? "?{$pagination_variable}=" . ($data['current_page'] - 1) . "&{$query_var}={$query}" : FALSE; $data['next_page'] = $data['current_page'] < $data['total_pages'] ? "?{$pagination_variable}=" . ($data['current_page'] + 1) . "&{$query_var}={$query}" : FALSE; $data['first_page'] = $data['current_page'] === 1 ? FALSE : "?{$pagination_variable}=1&{$query_var}={$query}"; $data['last_page'] = $data['current_page'] >= $data['total_pages'] ? FALSE : "?{$pagination_variable}=" . $data['total_pages'] . "&{$query_var}={$query}"; $data['offset'] = (int) (($data['current_page'] - 1) * $limit); return Parse::template($this->content, $data); }
public function index() { $from = $this->fetchParam('from', false); // defaults to null if (!$from) { return null; } $from = Path::addStartingSlash($from); $from = strlen($from) > 1 ? rtrim($from, "/") : $from; $content_set = ContentService::getContentByURL($from); // filter $content_set->filter(array('show_all' => $this->fetchParam('show_hidden', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)))); // limit $limit = $this->fetchParam('limit', 1, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $content_set->limit($limit, $offset); // check for results if (!$content_set->count()) { return Parse::tagLoop($this->content, array(array('no_results' => true))); } // if content is used in this entries loop, parse it $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content); return Parse::tagLoop($this->content, $content_set->get($parse_content)); }
public function breadcrumbs() { $url = $this->fetchParam('from', URL::getCurrent()); $include_home = $this->fetchParam('include_home', true, false, true); $reverse = $this->fetchParam('reverse', false, false, true); $backspace = $this->fetchParam('backspace', false, 'is_numeric', false); $include_content = $this->fetchParam('include_content', false, null, true); $trim = $this->fetchParam('trim', true, null, true); $tag_content = $trim ? trim($this->content) : $this->content; // add in left-/ if not present if (substr($url, 0, 1) !== '/') { $url = '/' . $url; } // if this doesn't start with the site root, add the site root if (!Pattern::startsWith($url, Config::getSiteRoot())) { $url = Path::tidy(Config::getSiteRoot(), $url); } // start crumbs $crumbs = array(); // we only want to show breadcrumbs when we're not on the homepage if ($url !== Config::getSiteRoot()) { $segments = explode('/', ltrim(str_replace(Config::getSiteRoot(), '/', $url), '/')); $segment_count = count($segments); $segment_urls = array(); // create crumbs from segments for ($i = 1; $i <= $segment_count; $i++) { $segment_urls[] = '/' . join($segments, '/'); array_pop($segments); } // should we also include the homepage? if ($include_home) { $segment_urls[] = Config::getSiteRoot(); } // grab data for each foreach ($segment_urls as $url) { $this_url = Path::tidy(Config::getSiteRoot() . '/' . $url); $content = Content::get($this_url, $include_content); if ($content) { // standard stuff $crumbs[$this_url] = $content; } else { // no content found? this could be a taxonomy $crumbs[$this_url] = array('url' => $this_url, 'title' => ucwords(substr($url, strrpos($url, '/') + 1))); } $crumbs[$this_url]['is_current'] = URL::getCurrent() == $this_url; } // correct order if (!$reverse) { $crumbs = array_reverse($crumbs); } // add first, last, and index $i = 1; $crumb_count = count($crumbs); foreach ($crumbs as $key => $crumb) { $crumbs[$key]['first'] = $i === 1; $crumbs[$key]['last'] = $i === $crumb_count; $crumbs[$key]['index'] = $i; $i++; } if (!count($crumbs)) { $output = Parse::template($tag_content, array('no_results' => true)); if ($backspace) { $output = substr($output, 0, -$backspace); } } else { $output = Parse::tagLoop($tag_content, $crumbs); if ($backspace) { $output = substr($output, 0, -$backspace); } } } else { $output = Parse::template($tag_content, array('no_results' => true)); } // parse the loop return $output; }
/** * Lists entries based on passed parameters * * @return array|string */ public function listing() { // grab common parameters $settings = $this->parseCommonParameters(); // grab content set based on the common parameters $content_set = $this->getContentSet($settings); // limit $limit = $this->fetchParam('limit', null, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $paginate = $this->fetchParam('paginate', true, null, true, false); if ($limit || $offset) { if ($limit && $paginate && !$offset) { // pagination requested, isolate the appropriate page $content_set->isolatePage($limit, URL::getCurrentPaginationPage()); } else { // just limit or offset $content_set->limit($limit, $offset); } } // check for results if (!$content_set->count()) { return Parse::template($this->content, array('no_results' => true)); } return Parse::tagLoop($this->content, $content_set->get(), false, $this->context); }
public function listing() { if (Config::get('disable_member_cache')) { $this->log->error("Cannot use `member:listing` when `_disable_member_cache` is `true`."); return Parse::template($this->content, array('no_results' => true)); } // grab common parameters $settings = $this->parseCommonParameters(); // grab member set based on the common parameters $member_set = $this->getMemberSet($settings); // grab total members for setting later $total_members = $member_set->count(); // no users found? return no results if (!$total_members) { return Parse::template($this->content, array('no_results' => true)); } // limit $limit = $this->fetchParam('limit', null, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $paginate = $this->fetchParam('paginate', true, null, true, false); if ($limit || $offset) { if ($limit && $paginate && !$offset) { // pagination requested, isolate the appropriate page $member_set->isolatePage($limit, URL::getCurrentPaginationPage()); } else { // just limit or offset $member_set->limit($limit, $offset); } } // manually supplement $member_set->supplement(array('total_found' => $total_members)); // check for results if (!$member_set->count()) { return Parse::template($this->content, array('no_results' => true)); } return Parse::tagLoop($this->content, $member_set->get(), true, $this->context); }
/** * Parses through this plugin's content, replacing variables with variables from $data * * @deprecated Use Parse::tagLoop() instead * * @param string $content Content template to replace variables in * @param array $data Associated array of data to replace * @return string */ public function parse_loop($content, array $data) { $this->log->warn('Use of $this->parse_loop() is deprecated. Use Parse::tagLoop() instead.'); return Parse::tagLoop($content, $data); }
/** * Pull a single github repo * * Usage: * <pre> * {{ github:repo account="blainsmith" name="Statamic-GitHub-Plugin" }} * {{ description }} * {{ /github:repo }} * </pre> */ public function repo() { $account = $this->fetch_param('account', 'statamic'); $repo = $this->fetch_param('repo', 'Plugin-Dribbble'); //try { $data = json_decode($this->_curl($this->endpoint_url . '/repos/' . $account . '/' . $repo)); // Convert the object into a multi dimension array so we can use it in a loop. $data = array(0 => (array) $data); return Parse::tagLoop($this->content, $data); // } catch(Exception $e) { // return ''; // } }
public function index() { /* |-------------------------------------------------------------------------- | Paramers |-------------------------------------------------------------------------- | | Match overrides Extension. Exclusion applies in both cases. | */ $match = $this->fetchParam('match', false); $exclude = $this->fetchParam('exclude', false); $extension = $this->fetchParam(array('extension', 'type'), false); $in = $this->fetchParam(array('in', 'folder', 'from'), false); $not_in = $this->fetchParam('not_in', false); $file_size = $this->fetchParam('file_size', false); $file_date = $this->fetchParam('file_date', false); $depth = $this->fetchParam('depth', false); $sort_by = $this->fetchParam(array('sort_by', 'order_by'), false); $sort_dir = $this->fetchParam(array('sort_dir', 'sort_direction'), 'asc'); $limit = $this->fetchParam('limit', false); if ($in) { $in = Helper::explodeOptions($in); } if ($not_in) { $not_in = Helper::explodeOptions($not_in); } if ($file_size) { $file_size = Helper::explodeOptions($file_size); } if ($extension) { $extension = Helper::explodeOptions($extension); } /* |-------------------------------------------------------------------------- | Finder |-------------------------------------------------------------------------- | | Get_Files implements most of the Symfony Finder component as a clean | tag wrapper mapped to matched filenames. | */ $finder = new Finder(); if ($in) { foreach ($in as $location) { $finder->in(Path::fromAsset($location)); } } /* |-------------------------------------------------------------------------- | Name |-------------------------------------------------------------------------- | | Match is the "native" Finder name() method, which is supposed to | implement string, glob, and regex. The glob support is only partial, | so "extension" is a looped *single* glob rule iterator. | */ if ($match) { $finder->name($match); } elseif ($extension) { foreach ($extension as $ext) { $finder->name("*.{$ext}"); } } /* |-------------------------------------------------------------------------- | Exclude |-------------------------------------------------------------------------- | | Exclude directories from matching. Remapped to "not in" to allow more | intuitive differentiation between filename and directory matching. | */ if ($not_in) { foreach ($not_in as $location) { $finder->exclude($location); } } /* |-------------------------------------------------------------------------- | Not Name |-------------------------------------------------------------------------- | | Exclude files matching a given pattern: string, regex, or glob. | By default we don't allow looking for PHP files. Be smart. | */ if ($this->fetchParam('allow_php', false) !== TRUE) { $finder->notName("*.php"); } if ($exclude) { $finder->notName($exclude); } /* |-------------------------------------------------------------------------- | File Size |-------------------------------------------------------------------------- | | Restrict files by size. Can be chained and allows comparison operators. | */ if ($file_size) { foreach ($file_size as $size) { $finder->size($size); } } /* |-------------------------------------------------------------------------- | File Date |-------------------------------------------------------------------------- | | Restrict files by last modified date. Can use comparison operators, and | since/after is aliased to >, and until/before to <. | */ if ($file_date) { $finder->date($file_date); } /* |-------------------------------------------------------------------------- | Depth |-------------------------------------------------------------------------- | | Recursively traverse directories, starting at 0. | */ if ($depth) { $finder->depth($depth); } /* |-------------------------------------------------------------------------- | Sort By |-------------------------------------------------------------------------- | | Sort by name, file, or type | */ if ($sort_by) { if ($sort_by === 'file' || $sort_by === 'name') { $finder->sortByName(); } elseif ($sort_by === 'type') { $finder->sortByType(); } } /* |-------------------------------------------------------------------------- | Assemble File Array |-------------------------------------------------------------------------- | | Select the important bits of data on the list of files. | */ $matches = $finder->files()->followLinks(); $files = array(); foreach ($matches as $file) { $files[] = array('extension' => $file->getExtension(), 'filename' => $file->getFilename(), 'file' => Path::toAsset($file->getPathname()), 'name' => Path::toAsset($file->getPathname()), 'size' => File::getHumanSize($file->getSize()), 'size_bytes' => $file->getSize(), 'size_kilobytes' => number_format($file->getSize() / 1024, 2), 'size_megabytes' => number_format($file->getSize() / 1048576, 2), 'size_gigabytes' => number_format($file->getSize() / 1073741824, 2), 'is_image' => File::isImage($file->getPathname())); } /* |-------------------------------------------------------------------------- | Sort Direction |-------------------------------------------------------------------------- | | Set the sort direction, defaulting to "asc" (ascending) | */ if ($sort_dir === 'desc') { $files = array_reverse($files); } /* |-------------------------------------------------------------------------- | Randomizing |-------------------------------------------------------------------------- | | You can't sort randomly using Symfony finder, so we'll do it manually. | */ if ($sort_by === 'random') { shuffle($files); } /* |-------------------------------------------------------------------------- | Limit Files |-------------------------------------------------------------------------- | | Limit the number of files returned. Needs to be run after sort_dir to | ensure consistency. | */ if ($limit) { $files = array_slice($files, 0, $limit); } return Parse::tagLoop($this->content, $files, true, $this->context); }
public function index() { /* |-------------------------------------------------------------------------- | Paramers |-------------------------------------------------------------------------- | | Match overrides Extension. Exclusion applies in both cases. | */ $match = $this->fetchParam('match', false); $exclude = $this->fetchParam('exclude', false); $extension = $this->fetchParam('extension', false); $in = $this->fetchParam('in', false); $not_in = $this->fetchParam('not_in', false); $file_size = $this->fetchParam('file_size', false); $file_date = $this->fetchParam('file_date', false); $depth = $this->fetchParam('depth', false); if ($file_size) { $file_size = Helper::explodeOptions($file_size); } if ($extension) { $extension = Helper::explodeOptions($extension); } /* |-------------------------------------------------------------------------- | Finder |-------------------------------------------------------------------------- | | Get_Files implements most of the Symfony Finder component as a clean | tag wrapper mapped to matched filenames. | */ $finder = new Finder(); $finder->in($in); // Finder doesn't respect multiple glob options, // so this will need to wait until later. // // $match = str_replace('{{', '{', $match); // $match = str_replace('}}', '}', $match); /* |-------------------------------------------------------------------------- | Name |-------------------------------------------------------------------------- | | Match is the "native" Finder name() method, which is supposed to | implement string, glob, and regex. The glob support is only partial, | so "extension" is a looped *single* glob rule iterator. | */ if ($match) { $finder->name($match); } elseif ($extension) { foreach ($extension as $ext) { $finder->name("*.{$ext}"); } } /* |-------------------------------------------------------------------------- | Exclude |-------------------------------------------------------------------------- | | Exclude directories from matching. Remapped to "not in" to allow more | intuitive differentiation between filename and directory matching. | */ if ($not_in) { $finder->exclude($not_in); } /* |-------------------------------------------------------------------------- | Not Name |-------------------------------------------------------------------------- | | Exclude files matching a given pattern: string, regex, or glob. | */ if ($exclude) { $finder->notName($exclude); } /* |-------------------------------------------------------------------------- | File Size |-------------------------------------------------------------------------- | | Restrict files by size. Can be chained and allows comparison operators. | */ if ($file_size) { foreach ($file_size as $size) { $finder->size($size); } } /* |-------------------------------------------------------------------------- | File Date |-------------------------------------------------------------------------- | | Restrict files by last modified date. Can use comparison operators, and | since/after is aliased to >, and until/before to <. | */ if ($file_date) { $finder->date($file_date); } /* |-------------------------------------------------------------------------- | Depth |-------------------------------------------------------------------------- | | Recursively traverse directories, starting at 0. | */ if ($depth) { $finder->depth($depth); } $matches = $finder->files(); /* |-------------------------------------------------------------------------- | Return and Parse |-------------------------------------------------------------------------- | | This tag returns the matched filenames mapped to {{ file }}. | */ $files = array(); foreach ($matches as $file) { $files[] = array('file' => '/' . $in . '/' . $file->getRelativePathname()); // $files[] = YAML::parse($file->getContents()); } return Parse::tagLoop($this->content, $files); }