static function replaceTags($entries, $params, $matches)
 {
     /*
      * Make sure the template tag has a matching array element
      */
     if (array_key_exists(strtolower($matches[1]), $entries)) {
         $val = $entries[strtolower($matches[1])];
         // Run htmlentities() is the parameter is set to TRUE
         if ($params['htmlentities'] === TRUE) {
             $val = htmlentities($val, ENT_QUOTES);
         }
         // Run strip_tags() if the parameter is set to TRUE
         if ($params['strip_tags'] === TRUE) {
             $whitelist = NULL;
             if (isset($params['strip_tags_whitelist'])) {
                 $whitelist = $params['strip_tags_whitelist'];
             }
             $val = strip_tags($val, $whitelist);
             //TODO: Finish the attribute stripping function
             //                $val = Utilities::strip_tags_attr($val, $whitelist);
         }
         // Create a text preview if one the parameter is set to TRUE
         if ($params['text_preview'] === TRUE && $matches[1] == 'body') {
             $val = Utilities::textPreview($val, $params['text_preview_length']);
         }
         return $val;
     } else {
         return "{" . $matches[1] . "}";
     }
 }
 protected function displayPreview($entries)
 {
     $id = isset($entries[0]['id']) ? $entries[0]['id'] : NULL;
     $entry = $this->admin_general_options($this->url0, $id, false);
     if (isset($entries[0]['title'])) {
         // Number of results
         $n = count($entries);
         $entry_array = array();
         // Initialize the variable to avoid a notice
         foreach ($entries as $e) {
             // Entry options for the admin, if logged in
             $e['admin'] = $this->admin_gallery_options($this->url0, $e['id'], $n, $e['data7']);
             /*
              * URLs for different versions of the image
              */
             $gal = $this->getGalleryImages($e['id'], TRUE);
             /*
              * Store the count
              */
             $e['photo-count'] = count($gal);
             /*
              * Grab the first image
              */
             $image = array_shift($gal);
             if (!empty($image)) {
                 /*
                  * Display the latest two galleries
                  */
                 $e['image'] = '/' . GAL_SAVE_DIR . $this->url0 . $e['id'] . $image;
                 $e['preview'] = '/' . GAL_SAVE_DIR . $this->url0 . $e['id'] . '/preview/' . $image;
                 $e['thumb'] = '/' . GAL_SAVE_DIR . $this->url0 . $e['id'] . '/thumbs/' . $image;
             } else {
                 $e['image'] = '/assets/images/no-image.jpg';
                 $e['preview'] = '/assets/images/no-image.jpg';
                 $e['thumb'] = '/assets/images/no-image-thumb.jpg';
             }
             /*
              * Entry URL
              */
             $e['url'] = isset($e['data6']) ? $e['data6'] : urlencode($e['title']);
             /*
              * Text options
              */
             $e['text-preview'] = Utilities::textPreview($e['body'], 45);
             $entry_array[] = $e;
         }
         $template_file = $this->url0 . '-preview.inc';
     } else {
         $entry_array[] = array('admin' => NULL, 'title' => 'No Entry Found', 'body' => "<p>That entry doesn't appear to exist.</p>");
         $template_file = 'default.inc';
     }
     /*
      * Set up header and footer information
      */
     if ($this->url1 == 'category') {
         $name = $entry_array[0]['category-name'];
         $count = count($entry_array);
         $gal = $count == 1 ? 'gallery' : 'galleries';
         $extra = array('header' => array('title' => "Viewing Category: {$name} ({$count} {$gal})"), 'footer' => array('backlink' => '<p><a href="/' . $this->url0 . '">&laquo; Back to All Photos</a></p>'));
     } else {
         $extra = array('header' => array('title' => 'Latest Galleries'), 'footer' => array('backlink' => NULL));
     }
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     $entry .= UTILITIES::parseTemplate($entry_array, $template, $extra);
     return $entry;
 }
Beispiel #3
0
 public function get_page_description()
 {
     if ($this->url0 === DB_Actions::get_default_page() && empty($this->url1)) {
         return SITE_DESCRIPTION;
     } else {
         if (isset($this->entries[0]->excerpt)) {
             return htmlentities(strip_tags($this->entries[0]->excerpt), ENT_QUOTES);
         } else {
             if (isset($this->entries[0]->entry)) {
                 $preview = Utilities::textPreview($this->entries[0]->entry, 25);
                 return htmlentities(strip_tags($preview), ENT_QUOTES);
             } else {
                 return SITE_DESCRIPTION;
             }
         }
     }
 }