Ejemplo n.º 1
0
/**
 * Loads a zenpage news article
 * Sets up $_zp_current_zenpage_news and returns it as the function result.
 *
 * @param array $request an array with one member: the key is "date", "category", or "title" and specifies
 * what you want loaded. The value is the date or title of the article wanted
 *
 * @return object
 */
function load_zenpage_news($request)
{
    global $_zp_current_zenpage_news, $_zp_current_category, $_zp_post_date;
    if (isset($request['date'])) {
        add_context(ZP_ZENPAGE_NEWS_DATE);
        $_zp_post_date = zpFunctions::removeTrailingSlash(sanitize($request['date']));
    }
    if (isset($request['category'])) {
        $titlelink = sanitize(rtrim($request['category'], '/'));
        $_zp_current_category = new ZenpageCategory($titlelink);
        if ($_zp_current_category->loaded) {
            add_context(ZP_ZENPAGE_NEWS_CATEGORY);
        } else {
            $_GET['p'] = 'CATEGORY:' . $titlelink;
            unset($_GET['category']);
            return false;
        }
    }
    if (isset($request['title'])) {
        $titlelink = sanitize(rtrim($request['title'], '/'));
        $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
        $result = query_single_row($sql);
        if (is_array($result)) {
            add_context(ZP_ZENPAGE_NEWS_ARTICLE | ZP_ZENPAGE_SINGLE);
            $_zp_current_zenpage_news = new ZenpageNews($titlelink);
        } else {
            $_GET['p'] = 'NEWS:' . $titlelink;
        }
        return $_zp_current_zenpage_news;
    }
    return true;
}
Ejemplo n.º 2
0
 /**
  * Constuctor
  *
  * @param bool $dynamic_album set true for dynamic albums (limits the search fields)
  * @return SearchEngine
  */
 function __construct($dynamic_album = false)
 {
     global $_zp_exifvars, $_zp_gallery;
     switch ((int) getOption('exact_tag_match')) {
         case 0:
             // partial
             $this->tagPattern = array('type' => 'like', 'open' => '%', 'close' => '%');
             break;
         case 1:
             // exact
             $this->tagPattern = array('type' => '=', 'open' => '', 'close' => '');
             break;
         case 2:
             //word
             $this->tagPattern = array('type' => 'regexp', 'open' => '[[:<:]]', 'close' => '[[:>:]]');
             break;
     }
     switch ((int) getOption('exact_string_match')) {
         case 0:
             // pattern
             $this->pattern = array('type' => 'like', 'open' => '%', 'close' => '%');
             break;
         case 1:
             // partial start
             $this->pattern = array('type' => 'regexp', 'open' => '[[:<:]]', 'close' => '');
             break;
         case 2:
             //word
             $this->pattern = array('type' => 'regexp', 'open' => '[[:<:]]', 'close' => '[[:>:]]');
             break;
     }
     $this->extraparams['albumssorttype'] = getOption('search_album_sort_type');
     $this->extraparams['albumssortdirection'] = getOption('search_album_sort_direction') ? 'DESC' : '';
     $this->extraparams['imagessorttype'] = getOption('search_image_sort_type');
     $this->extraparams['imagessortdirection'] = getOption('search_image_sort_direction') ? 'DESC' : '';
     $this->extraparams['newssorttype'] = 'date';
     $this->extraparams['newssortdirection'] = 'DESC';
     $this->extraparams['pagesssorttype'] = 'title';
     $this->extraparams['pagessortdirection'] = '';
     //image/album fields
     $this->search_structure['title'] = gettext('Title');
     $this->search_structure['desc'] = gettext('Description');
     $this->search_structure['tags'] = gettext('Tags');
     $this->search_structure['tags_exact'] = '';
     //	internal use only field
     $this->search_structure['filename'] = gettext('File/Folder name');
     $this->search_structure['date'] = gettext('Date');
     $this->search_structure['custom_data'] = gettext('Custom data');
     $this->search_structure['location'] = gettext('Location/Place');
     $this->search_structure['city'] = gettext('City');
     $this->search_structure['state'] = gettext('State');
     $this->search_structure['country'] = gettext('Country');
     $this->search_structure['copyright'] = gettext('Copyright');
     $this->search_structure['owner'] = gettext('Owner');
     $this->search_structure['credit'] = gettext('Credit');
     if (extensionEnabled('zenpage') && !$dynamic_album) {
         //zenpage fields
         $this->search_structure['content'] = gettext('Content');
         $this->search_structure['extracontent'] = gettext('ExtraContent');
         $this->search_structure['author'] = gettext('Author');
         $this->search_structure['lastchangeauthor'] = gettext('Last Editor');
         $this->search_structure['titlelink'] = gettext('TitleLink');
         $this->search_structure['news_categories'] = gettext('Categories');
     }
     //metadata fields
     foreach ($_zp_exifvars as $field => $row) {
         if ($row[4] && $row[5]) {
             //	only those that are "real" and "processed"
             $this->search_structure[strtolower($field)] = $row[2];
         }
     }
     $this->search_structure = zp_apply_filter('searchable_fields', $this->search_structure);
     if (isset($_REQUEST['words'])) {
         $this->words = zpFunctions::removeTrailingSlash(strtr(sanitize($_REQUEST['words'], 4), array('__23__' => '#', '__25__' => '%', '__26__' => '&', '__2F__' => '/')));
     } else {
         $this->words = NULL;
         if (isset($_REQUEST['date'])) {
             // words & dates are mutually exclusive
             $this->dates = zpFunctions::removeTrailingSlash(sanitize($_REQUEST['date'], 3));
             if (isset($_REQUEST['whichdate'])) {
                 $this->whichdates = sanitize($_REQUEST['whichdate']);
             }
         } else {
             $this->dates = NULL;
         }
     }
     $this->fieldList = $this->parseQueryFields();
     if (isset($_REQUEST['inalbums'])) {
         $list = trim(sanitize($_REQUEST['inalbums'], 3));
         if (strlen($list) > 0) {
             switch ($list) {
                 case "0":
                     $this->search_no_albums = true;
                     setOption('search_no_albums', 1, false);
                     break;
                 case "1":
                     $this->search_no_albums = false;
                     setOption('search_no_albums', 0, false);
                     break;
                 default:
                     $this->album_list = explode(',', $list);
                     break;
             }
         }
     }
     if (isset($_REQUEST['inimages'])) {
         $list = trim(sanitize($_REQUEST['inimages'], 3));
         if (strlen($list) > 0) {
             switch ($list) {
                 case "0":
                     $this->search_no_images = true;
                     setOption('search_no_images', 1, false);
                     break;
                 case "1":
                     $this->search_no_images = false;
                     setOption('search_no_images', 0, false);
                     break;
             }
         }
     }
     if (isset($_REQUEST['inpages'])) {
         $list = trim(sanitize($_REQUEST['inpages'], 3));
         if (strlen($list) > 0) {
             switch ($list) {
                 case "0":
                     $this->search_no_pages = true;
                     setOption('search_no_pages', 1, false);
                     break;
             }
         }
     }
     if (isset($_REQUEST['innews'])) {
         $list = trim(sanitize($_REQUEST['innews'], 3));
         if (strlen($list) > 0) {
             switch ($list) {
                 case "0":
                     $this->search_no_news = true;
                     setOption('search_no_news', 1, false);
                     break;
                 case "1":
                     break;
                 default:
                     $this->category_list = explode(',', $list);
                     break;
             }
         }
     }
     $this->images = NULL;
     $this->albums = NULL;
     $this->searches = array('images' => NULL, 'albums' => NULL, 'pages' => NULL, 'news' => NULL);
     zp_apply_filter('search_instantiate', $this);
 }