public function count() { // grab parameters $from = $this->fetchParam('from', URL::getCurrent()); $exclude = $this->fetchParam('exclude', false); $max_depth = $this->fetchParam('max_depth', 1, 'is_numeric'); $include_entries = $this->fetchParam('include_entries', false, false, true); $folders_only = $this->fetchParam('folders_only', true, false, true); $include_content = $this->fetchParam('include_content', false, false, true); $show_hidden = $this->fetchParam('show_hidden', false, null, true); // add in left-/ if not present if (substr($from, 0, 1) !== '/') { $from = '/' . $from; } // if this doesn't start with the site root, add the site root if (!Pattern::startsWith($from, Config::getSiteRoot())) { $from = Path::tidy(Config::getSiteRoot() . '/' . $from); } // standardize excludes if ($exclude && !is_array($exclude)) { $exclude = Helper::explodeOptions($exclude, array()); foreach ($exclude as $key => $value) { $exclude[$key] = Path::tidy(Config::getSiteRoot() . '/' . $value); } } // option hash $hash = Helper::makeHash($from, $exclude, $max_depth, $include_entries, $folders_only, $include_content, $show_hidden); // load the content tree from cache if ($this->blink->exists($hash)) { $tree = $this->blink->get($hash); } else { $tree = ContentService::getContentTree($from, $max_depth, $folders_only, $include_entries, $show_hidden, $include_content, $exclude); $this->blink->set($hash, $tree); } if ($this->content) { return Parse::template($this->content, array('count' => count($tree))); } elseif (count($tree)) { return count($tree); } return ''; }