コード例 #1
0
ファイル: pi.pages.php プロジェクト: nob/joi
 /**
  * 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' => 'pages', 'conditions' => trim($this->fetchParam('conditions', ""))));
     // 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
             $content_set->limit($limit, $offset);
         }
     }
     // manually supplement
     $content_set->supplement(array('total_found' => $total_entries));
     // check for results
     if (!$content_set->count()) {
         return 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));
 }
コード例 #2
0
ファイル: pi.entries.php プロジェクト: jalmelb/24hl2015
    /**
     * Returns a ContentSet object with the appropriate content
     *
     * @param array  $settings  Settings for filtering content and such
     * @return ContentSet
     */
    private function getContentSet($settings)
    {
        // create a unique hash for these settings
        $content_hash = Helper::makeHash($settings);

        if ($this->blink->exists($content_hash)) {
            // blink content exists, use that
            $content_set = new ContentSet($this->blink->get($content_hash));
        } else {
            // no blink content exists, get data the hard way
            if ($settings['taxonomy']) {
                $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, $settings['folders']);
            } else {
                $content_set = ContentService::getContentByFolders($settings['folders']);
            }

            // filter
            $content_set->filter($settings);

            // grab total entries for setting later
            $total_entries = $content_set->count();

            // pre-sort supplement
            $content_set->supplement(array('total_found' => $total_entries) + $settings);

            // sort
            $content_set->multisort($settings['sort']);            
            
            // post-sort supplement
            $content_set->supplement(array(
                'group_by_date' => trim($this->fetchParam("group_by_date", null, null, false, false))
            ), true);

            // store content as blink content for future use
            $this->blink->set($content_hash, $content_set->extract());
        }

        return $content_set;
    }
コード例 #3
0
ファイル: routes.php プロジェクト: jalmelb/24hl2015
        $data['current_url'] = $current_url;
        $data['slug']        = basename($current_url);

        // if this is an entry, default to the `post` template
        if ($data['_is_entry']) {
            $template_list[] = array_get($data, '_template', 'default');
            $template_list[] = "post";
        }

        if ($path !== "/404") {
            $content_found = true;
        }

    // url is taxonomy-based
    } elseif (Taxonomy::isTaxonomyURL($path)) {
        list($type, $slug) = Taxonomy::getCriteria($path);

        // create data array
        $data = array_merge(Config::getAll(), array(
            'homepage'       => Config::getSiteRoot(),
            'raw_url'        => Request::getResourceURI(),
            'page_url'       => Request::getResourceURI(),
            'taxonomy_slug'  => urldecode($slug),
            'taxonomy_name'  => Taxonomy::getTaxonomyName($type, $slug)
        ));

        $template_list[] = "taxonomies";
        $template_list[] = $type;
        $content_found = true;
    }
コード例 #4
0
 /**
  * Gets the target data from the cache
  *
  * @param array  $config  Configuration array
  * @return array
  */
 public function getData($config)
 {
     // load data
     if ($config['taxonomy']) {
         $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, $config['folders']);
     } else {
         $content_set = ContentService::getContentByFolders($config['folders']);
     }
     // filters
     $content_set->filter($config);
     // custom filter, remove the 404 page if needed
     if (!$config['include_404']) {
         $content_set->customFilter(function ($item) {
             return $item['url'] !== '/404';
         });
     }
     // custom filter, remove any excluded folders
     if ($config['exclude']) {
         $excluded = Parse::pipeList($config['exclude']);
         $content_set->customFilter(function ($item) use($excluded) {
             foreach ($excluded as $exclude) {
                 if ($exclude === "*" || $exclude === "/*") {
                     // exclude all
                     return false;
                 } elseif (substr($exclude, -1) === "*") {
                     // wildcard check
                     if (strpos($item['_folder'], substr($exclude, 0, -1)) === 0) {
                         return false;
                     }
                 } else {
                     // plain check
                     if ($exclude == $item['_folder']) {
                         return false;
                     }
                 }
             }
             return true;
         });
     }
     $content_set->supplement(array('merge_with_data' => false));
     $content_set->prepare($config['include_content']);
     $data = $content_set->get();
     return $data;
 }
コード例 #5
0
 public static function get_content_tree($directory = '/', $depth = 1, $max_depth = 5, $folders_only = false, $include_entries = false, $hide_hidden = true, $include_content = false, $site_root = false)
 {
     // $folders_only = true only page.md
     // folders_only = false includes any numbered or non-numbered page (excluding anything with a fields.yaml file)
     // if include_entries is true then any numbered files are included
     $content_root = Config::getContentRoot();
     $content_type = Config::getContentType();
     $site_root = $site_root ? $site_root : Config::getSiteRoot();
     $current_url = Path::tidy($site_root . '/' . Request::getResourceURI());
     $taxonomy_url = false;
     if (Taxonomy::isTaxonomyURL($current_url)) {
         list($taxonomy_type, $taxonomy_name) = Taxonomy::getCriteria($current_url);
         $taxonomy_url = self::remove_taxonomy_from_path($current_url, $taxonomy_type, $taxonomy_name);
     }
     $directory = '/' . $directory . '/';
     #ensure proper slashing
     if ($directory != '/') {
         $base = Path::tidy("{$content_root}/{$directory}");
     } elseif ($directory == '/') {
         $base = "{$content_root}";
     } else {
         $base = "{$content_root}";
     }
     $files = glob("{$base}/*");
     $data = array();
     if ($files) {
         foreach ($files as $path) {
             $current_name = basename($path);
             if (!Pattern::endsWith($current_name, '.yaml')) {
                 // Hidden page that should be removed
                 if ($hide_hidden && Pattern::startsWith($current_name, '_')) {
                     continue;
                 }
                 $node = array();
                 $file = substr($path, strlen($base) + 1, strlen($path) - strlen($base) - strlen($content_type) - 2);
                 if (is_dir($path)) {
                     $folder = substr($path, strlen($base) + 1);
                     $node['type'] = 'folder';
                     $node['slug'] = basename($folder);
                     $node['title'] = ucwords(basename($folder));
                     $node['numeric'] = Slug::getOrderNumber($folder);
                     $node['file_path'] = Path::tidy($site_root . '/' . $directory . '/' . $folder . '/page');
                     if (Slug::isNumeric($folder)) {
                         $pos = strpos($folder, ".");
                         if ($pos !== false) {
                             $node['raw_url'] = Path::tidy(Path::clean($site_root . '/' . $directory . '/' . $folder));
                             $node['url'] = Path::clean($node['raw_url']);
                             $node['title'] = ucwords(basename(substr($folder, $pos + 1)));
                         } else {
                             $node['title'] = ucwords(basename($folder));
                             $node['raw_url'] = Path::tidy($site_root . '/' . $directory . '/' . $folder);
                             $node['url'] = Path::clean($node['raw_url']);
                         }
                     } else {
                         $node['title'] = ucwords(basename($folder));
                         $node['raw_url'] = Path::tidy($site_root . '/' . $directory . '/' . $folder);
                         $node['url'] = Path::clean($node['raw_url']);
                     }
                     $node['depth'] = $depth;
                     $node['children'] = $depth < $max_depth ? self::get_content_tree($directory . $folder . '/', $depth + 1, $max_depth, $folders_only, $include_entries, $hide_hidden, $include_content, $site_root) : null;
                     $node['is_current'] = $node['raw_url'] == $current_url || $node['url'] == $current_url ? true : false;
                     $node['is_parent'] = false;
                     if ($node['url'] == URL::popLastSegment($current_url) || $taxonomy_url && $node['url'] == $taxonomy_url) {
                         $node['is_parent'] = true;
                     }
                     $node['has_children'] = $node['children'] ? true : false;
                     // has entries?
                     if (File::exists(Path::tidy($path . "/fields.yaml"))) {
                         $node['has_entries'] = true;
                     } else {
                         $node['has_entries'] = false;
                     }
                     $meta = self::get_content_meta("page", Path::tidy($directory . "/" . $folder), false, true);
                     //$meta = self::get_content_meta("page", Statamic_Helper::reduce_double_slashes($directory."/".$folder));
                     if (isset($meta['title'])) {
                         $node['title'] = $meta['title'];
                     }
                     if (isset($meta['last_modified'])) {
                         $node['last_modified'] = $meta['last_modified'];
                     }
                     if ($hide_hidden === true && (isset($meta['status']) && ($meta['status'] == 'hidden' || $meta['status'] == 'draft'))) {
                         // placeholder condition
                     } else {
                         $data[] = $include_content ? array_merge($meta, $node) : $node;
                         // print_r($data);
                     }
                 } else {
                     if (Pattern::endsWith($path, $content_type)) {
                         if ($folders_only == false) {
                             if ($file == 'page' || $file == 'feed' || $file == '404') {
                                 // $node['url'] = $directory;
                                 // $node['title'] = basename($directory);
                                 // $meta = self::get_content_meta('page', substr($directory, 1));
                                 // $node['depth'] = $depth;
                             } else {
                                 $include = true;
                                 // date based is never included
                                 if (Config::getEntryTimestamps() && Slug::isDateTime(basename($path))) {
                                     $include = false;
                                 } elseif (Slug::isDate(basename($path))) {
                                     $include = false;
                                 } elseif (Slug::isNumeric(basename($path))) {
                                     if ($include_entries == false) {
                                         if (File::exists(Path::tidy(dirname($path) . "/fields.yaml"))) {
                                             $include = false;
                                         }
                                     }
                                 }
                                 if ($include) {
                                     $node['type'] = 'file';
                                     $node['raw_url'] = Path::tidy($directory) . basename($path);
                                     $pretty_url = Path::clean($node['raw_url']);
                                     $node['url'] = substr($pretty_url, 0, -1 * (strlen($content_type) + 1));
                                     $node['is_current'] = $node['url'] == $current_url || $node['url'] == $current_url ? true : false;
                                     $node['slug'] = substr(basename($path), 0, -1 * (strlen($content_type) + 1));
                                     $meta = self::get_content_meta(substr(basename($path), 0, -1 * (strlen($content_type) + 1)), substr($directory, 1), false, true);
                                     //$node['meta'] = $meta;
                                     if (isset($meta['title'])) {
                                         $node['title'] = $meta['title'];
                                     }
                                     $node['depth'] = $depth;
                                     if ($hide_hidden === true && (isset($meta['status']) && ($meta['status'] == 'hidden' || $meta['status'] == 'draft'))) {
                                     } else {
                                         $data[] = $include_content ? array_merge($meta, $node) : $node;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
コード例 #6
0
ファイル: pi.entries.php プロジェクト: jeffreyDcreative/gkp
 /**
  * Returns a ContentSet object with the appropriate content
  *
  * @param array  $settings  Settings for filtering content and such
  * @return ContentSet
  */
 private function getContentSet($settings)
 {
     // create a unique hash for these settings
     $content_hash = Helper::makeHash($settings);
     if ($this->blink->exists($content_hash)) {
         // blink content exists, use that
         $content_set = new ContentSet($this->blink->get($content_hash));
     } else {
         // no blink content exists, get data the hard way
         if ($settings['taxonomy']) {
             $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, $settings['folders']);
         } else {
             $content_set = ContentService::getContentByFolders($settings['folders']);
         }
         // filter
         $content_set->filter($settings);
         // sort
         $content_set->sort($settings['sort_by'], $settings['sort_dir']);
         // store content as blink content for future use
         $this->blink->set($content_hash, $content_set->extract());
     }
     return $content_set;
 }
コード例 #7
0
ファイル: statamic.php プロジェクト: nob/joi
 public static function get_taxonomy_criteria($path)
 {
     Log::warn("Use of Statamic::get_taxonomy_criteria() is deprecated. Use Taxonomy::getCriteria() instead.", "core", "Statamic_Helper");
     return Taxonomy::getCriteria($path);
 }
コード例 #8
0
 } elseif ($data = Content::get($complete_current_url)) {
     $add_prev_next = true;
     $page = basename($path);
     $data['current_url'] = $current_url;
     $data['slug'] = basename($current_url);
     // if this is an entry, default to the `post` template
     if ($data['_is_entry']) {
         $template_list[] = array_get($data, '_template', 'default');
         $template_list[] = "post";
     }
     if ($path !== "/404") {
         $content_found = true;
     }
     // url is taxonomy-based
 } elseif (Taxonomy::isTaxonomyURL($path)) {
     $taxonomy = Taxonomy::getCriteria($path);
     // create data array
     $data = array_merge(Config::getAll(), array('homepage' => Config::getSiteRoot(), 'raw_url' => Request::getResourceURI(), 'page_url' => Request::getResourceURI(), 'taxonomy_slug' => $taxonomy['slug'], 'taxonomy_name' => Taxonomy::getTaxonomyName($taxonomy['type'], $taxonomy['slug'])));
     $template_list[] = "taxonomies";
     $template_list[] = $taxonomy['type'];
     if (!$taxonomy['slug']) {
         $template_list[] = "taxonomy-index";
         $template_list[] = $taxonomy['type'] . "-index";
     }
     $content_found = true;
 }
 // content was found
 if ($content_found) {
     // mark milestone for debug panel
     Debug::markMilestone('content found');
     // protect
コード例 #9
0
ファイル: pi.entries.php プロジェクト: nob/joi
 /**
  * Displays entries on a map
  *
  * @return string
  */
 public function map()
 {
     // check for valid center point
     if (!preg_match(Pattern::COORDINATES, $this->fetchParam('center_point'), $matches)) {
         print_r($this->fetchParam('center_point'));
         $this->log->error("Could not create map, invalid center point coordinates given");
         return NULL;
     } else {
         $latitude = $matches[1];
         $longitude = $matches[2];
     }
     // pop-up template
     $pop_up_template = NULL;
     // check for a valid pop_up template
     if (preg_match_all("/(?:\\{\\{\\s*pop_up\\s*\\}\\})\\s*(.*)\\s*(?:\\{\\{\\s*\\/pop_up\\s*\\}\\})/ism", $this->content, $matches) && is_array($matches[1]) && isset($matches[1][0])) {
         $pop_up_template = trim($matches[1][0]);
     }
     $folders = $this->fetchParam('folder', 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))));
     // supplement
     $content_set->supplement(array('locate_with' => $this->fetchParam('locate_with'), 'center_point' => $this->fetchParam('center_point'), 'pop_up_template' => $pop_up_template));
     // re-filter, we only want entries that have been found
     $content_set->filter(array('located' => true));
     // sort
     $content_set->sort($this->fetchParam('sort_by', 'order_key'), $this->fetchParam('sort_dir'));
     // 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
             $content_set->limit($limit, $offset);
         }
     }
     // get content
     $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content);
     $content = $content_set->get($parse_content);
     // set variables
     $map_id = $this->fetchParam('map_id', Helper::getRandomString());
     $zoom = $this->fetchParam('zoom', 12);
     // cluster options
     $clusters = $this->fetchParam('clusters', TRUE, NULL, TRUE);
     $clusters = $clusters ? "true" : "false";
     $spiderfy_on_max_zoom = $this->fetchParam('spiderfy_on_max_zoom', TRUE, NULL, TRUE);
     $spiderfy_on_max_zoom = $spiderfy_on_max_zoom ? "true" : "false";
     $show_coverage_on_hover = $this->fetchParam('show_coverage_on_hover', TRUE, NULL, TRUE);
     $show_coverage_on_hover = $show_coverage_on_hover ? "true" : "false";
     $zoom_to_bounds_on_click = $this->fetchParam('zoom_to_bounds_on_click', TRUE, NULL, TRUE);
     $zoom_to_bounds_on_click = $zoom_to_bounds_on_click ? "true" : "false";
     $single_marker_mode = $this->fetchParam('single_marker_mode', FALSE, NULL, TRUE);
     $single_marker_mode = $single_marker_mode ? "true" : "false";
     $animate_adding_markers = $this->fetchParam('animate_adding_markers', TRUE, NULL, TRUE);
     $animate_adding_markers = $animate_adding_markers ? "true" : "false";
     $disable_clustering_at_zoom = $this->fetchParam('disable_clustering_at_zoom', 15, 'is_numeric');
     $max_cluster_radius = $this->fetchParam('max_cluster_radius', 80, 'is_numeric');
     // create output
     $html = '<div class="map" id="' . $map_id . '"></div>';
     $html .= "\n";
     // only render inline javascript if a valid pop_up template was found
     $html .= '<script type="text/javascript">';
     $html .= "try{_location_maps.length;}catch(e){var _location_maps={};}\n";
     $html .= '_location_maps["' . $map_id . '"] = { markers: [ ';
     $markers = array();
     foreach ($content as $item) {
         $marker = array('latitude' => $item['latitude'], 'longitude' => $item['longitude'], 'marker_content' => $item['marker_pop_up_content']);
         array_push($markers, json_encode($marker));
     }
     $html .= join(",\n", $markers);
     $html .= '    ], ';
     $html .= ' clusters: ' . $clusters . ',';
     // cluster options
     $html .= ' spiderfy_on_max_zoom: ' . $spiderfy_on_max_zoom . ',';
     $html .= ' show_coverage_on_hover: ' . $show_coverage_on_hover . ',';
     $html .= ' zoom_to_bounds_on_click: ' . $zoom_to_bounds_on_click . ',';
     $html .= ' single_marker_mode: ' . $single_marker_mode . ',';
     $html .= ' animate_adding_markers: ' . $animate_adding_markers . ',';
     $html .= ' disable_clustering_at_zoom: ' . $disable_clustering_at_zoom . ',';
     $html .= ' max_cluster_radius: ' . $max_cluster_radius . ',';
     $html .= ' starting_latitude: ' . $latitude . ',';
     $html .= ' starting_longitude: ' . $longitude . ',';
     $html .= ' starting_zoom: ' . $zoom . ' };';
     $html .= '</script>';
     return $html;
 }
コード例 #10
0
ファイル: pi.location.php プロジェクト: jalmelb/24hl2015
    /**
     * Returns a ContentSet object with the appropriate content
     *
     * @param array  $settings  Settings for filtering content and such
     * @return ContentSet
     */
    private function getContentSet($settings)
    {
        // create a unique hash for these settings
        $content_hash = Helper::makeHash($settings);

        if ($this->blink->exists($content_hash)) {
            // blink content exists, use that
            $content_set = new ContentSet($this->blink->get($content_hash));
        } else {
            // no blink content exists, get data the hard way
            if ($settings['taxonomy']) {
                $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, $settings['folders']);
            } else {
                $content_set = ContentService::getContentByFolders($settings['folders']);
            }

            // filter
            $content_set->filter($settings);

            // supplement
            $content_set->supplement(array(
                'locate_with'     => $settings['locate_with'],
                'center_point'    => $settings['center_point'],
                'pop_up_template' => $this->content
            ));

            // re-filter, we only want entries that have been found
            $content_set->filter(array('located' => true));

            // sort
            $content_set->sort($settings['sort_by'], $settings['sort_dir']);

            // store content as blink content for future use
            $this->blink->set($content_hash, $content_set->extract());
        }

        return $content_set;
    }