Пример #1
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2');
     if ($urls[0] == '') {
         if (!is_null(post_param_integer('id', NULL))) {
             $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1);
             $urls = $rows[0];
             $url = $urls['url'];
             $thumb_url = $urls['thumb_url'];
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
         }
     } else {
         $url = $urls[0];
         $thumb_url = $urls[1];
     }
     $caption = comcode_to_tempcode(post_param('caption', ''));
     $title = comcode_to_tempcode(post_param('title', ''));
     require_code('images');
     $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true);
     $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url;
     $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title));
     return array($preview, NULL);
 }
Пример #2
0
 /**
  * Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls).
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @return string			XML in the special category,entry format
  */
 function run($id, $options, $default = NULL)
 {
     if ($id === NULL) {
         $id = '';
     }
     require_code('files2');
     require_code('images');
     $fullpath = get_custom_file_base() . '/uploads/filedump';
     if ($id != '') {
         $fullpath .= '/' . $id;
     }
     $folder = isset($options['folder']) && $options['folder'];
     // We want to select folders, not files
     $out = '';
     if (has_actual_page_access(NULL, 'filedump') && file_exists($fullpath)) {
         $files = get_directory_contents($fullpath, '', false, false);
         foreach ($files as $f) {
             $description = $GLOBALS['SITE_DB']->query_value_null_ok('filedump', 'description', array('name' => basename($f), 'path' => $id . '/'));
             if (isset($options['attachment_ready']) && $options['attachment_ready']) {
                 $entry_id = 'url_' . 'uploads/filedump/' . ($id == '' ? '' : rawurlencode($id) . '/') . rawurlencode($f);
             } else {
                 $entry_id = 'uploads/filedump/' . ($id == '' ? '' : rawurlencode($id) . '/') . rawurlencode($f);
             }
             if (is_dir($fullpath . '/' . $f)) {
                 $has_children = count(get_directory_contents($fullpath . '/' . $f, '', false, false)) > 0;
                 $out .= '<category id="' . xmlentities(($id == '' ? '' : $id . '/') . $f) . '" title="' . xmlentities($f) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . ($folder ? 'true' : 'false') . '"></category>';
             } elseif (!$folder) {
                 if (!isset($options['only_images']) || !$options['only_images'] || is_image($f)) {
                     if (is_null($description) || get_translated_text($description) == '') {
                         $_description = '';
                         if (is_image($f)) {
                             $url = get_custom_base_url() . '/uploads/filedump/' . ($id == '' ? '' : $id . '/') . $f;
                             $_description = static_evaluate_tempcode(do_image_thumb($url, '', true, true));
                         }
                     } else {
                         $_description = escape_html(get_translated_text($description));
                     }
                     $out .= '<entry id="' . xmlentities($entry_id) . '" title="' . xmlentities($f) . '" description_html="' . xmlentities($_description) . '" selectable="true"></entry>';
                 }
             }
         }
         // Mark parent cats for pre-expansion
         if (!is_null($default) && $default != '') {
             $cat = '';
             foreach (explode('/', $default) as $_cat) {
                 if ($_cat != '') {
                     $cat .= '/';
                     $cat .= $_cat;
                 }
                 $out .= '<expand>' . $cat . '</expand>';
             }
         }
     }
     return '<result>' . $out . '</result>';
 }
Пример #3
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     $urls = get_url('', 'file', 'safe_mode_temp', 0, OCP_UPLOAD_IMAGE, false);
     if ($urls[0] == '') {
         if (!is_null(post_param_integer('id', NULL))) {
             $rows = $GLOBALS['SITE_DB']->query_select('calendar_types', array('t_logo'), array('id' => post_param_integer('id')), '', 1);
             $urls = $rows[0];
             $url = find_theme_image($urls['t_logo']);
         } elseif (!is_null(post_param('theme_img_code', NULL))) {
             $url = find_theme_image(post_param('theme_img_code'));
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
         }
     } else {
         $url = $urls[0];
     }
     require_code('images');
     $preview = do_image_thumb(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, post_param('title'), true);
     return array($preview, NULL);
 }
Пример #4
0
 /**
  * Standard modular run function for preview hooks.
  *
  * @return array			A pair: The preview, the updated post Comcode
  */
 function run()
 {
     require_code('uploads');
     $cat = post_param('cat');
     $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_IMAGE, true, '', 'file2');
     if ($urls[0] == '') {
         if (!is_null(post_param_integer('id', NULL))) {
             $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1);
             $urls = $rows[0];
             $url = $urls['url'];
             $thumb_url = $urls['thumb_url'];
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
         }
     } else {
         $url = $urls[0];
         $thumb_url = $urls[1];
     }
     require_code('images');
     $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, post_param('comments'), true);
     $preview = hyperlink(url_is_local($url) ? get_custom_base_url() . '/' . $url : $url, $thumb);
     return array($preview, NULL);
 }
Пример #5
0
/**
 * Get a templated view of the subcategories directly under the specified category.
 *
 * @param  AUTO_LINK		The category the subcategories are being found for
 * @param  ?AUTO_LINK	The pretend root of our download system (NULL: true root). This system is provided for large sites to be able to do virtually seperated download systems
 * @param  ?ID_TEXT		The zone the download module we're using is in (NULL: find it)
 * @param  ?string		The order to show results in (NULL: default)
 * @return tempcode		The templated view
 */
function get_download_sub_categories($category_id, $root = NULL, $zone = NULL, $order = NULL)
{
    if (is_null($order)) {
        $order = 't.text_original ASC';
    }
    if (is_null($root)) {
        $root = db_get_first_id();
    }
    if (is_null($zone)) {
        $zone = get_module_zone('downloads');
    }
    $rows = $GLOBALS['SITE_DB']->query_select('download_categories c LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND c.category=t.id', array('rep_image', 'c.id', 'category', 'text_original', 'description'), array('parent_id' => $category_id), $order == 't.text_original ASC' ? '' : 'ORDER BY ' . $order, 400);
    if ($order == 't.text_original ASC') {
        global $M_SORT_KEY;
        $M_SORT_KEY = 'text_original';
        usort($rows, 'multi_sort');
    }
    if (count($rows) == 400) {
        $rows = array();
    }
    // Too much, performance issue
    $out = new ocp_tempcode();
    foreach ($rows as $myrow) {
        if (!has_category_access(get_member(), 'downloads', strval($myrow['id']))) {
            continue;
        }
        if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($myrow['text_original'])) {
            $myrow['text_original'] = get_translated_text($myrow['category']);
        }
        $child_id = $myrow['id'];
        $child_title = $myrow['text_original'];
        $info = count_download_category_children($child_id);
        $num_children = $info['num_children'];
        $num_downloads = $info['num_downloads_children'];
        $display_string = do_lang_tempcode('CATEGORY_SUBORDINATE', integer_format($num_downloads), integer_format($num_children));
        $url = build_url(array('page' => 'downloads', 'type' => 'misc', 'id' => $child_id == db_get_first_id() ? NULL : $child_id, 'root' => $root == db_get_first_id() ? NULL : $root, 'order' => get_param('order', NULL)), $zone);
        if ($myrow['rep_image'] != '') {
            require_code('images');
            $rep_image = do_image_thumb($myrow['rep_image'], '');
        } else {
            $rep_image = new ocp_tempcode();
        }
        $ajax_edit_url = '_SEARCH:cms_downloads:type=__ec:id=' . strval($child_id);
        $description = get_translated_tempcode($myrow['description']);
        $out->attach(do_template('CATEGORY_ENTRY', array('_GUID' => '8bfb36d75a85e2a7fbf5222f8fc61c7d', 'DESCRIPTION' => $description, 'ID' => strval($child_id), 'NAME_FIELD' => 'category', 'AJAX_EDIT_URL' => $ajax_edit_url, 'URL' => $url, 'REP_IMAGE' => $rep_image, 'CHILDREN' => $display_string, 'NAME' => $child_title, 'NAME_PLAIN' => $child_title)));
    }
    if ($out->is_empty()) {
        return $out;
    }
    return do_template('CATEGORY_LIST', array('_GUID' => '2de3e2cdd0180a584b4f4ec72652716f', 'CONTENT' => $out));
}
Пример #6
0
 /**
  * The UI to view a download.
  *
  * @return tempcode		The UI
  */
 function dloadinfo_screen()
 {
     $id = get_param_integer('id');
     $root = get_param_integer('root', db_get_first_id(), true);
     // Basic Init
     $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('SECTION_DOWNLOADS'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=' . strval($myrow['category_id']);
     if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) {
         access_denied('CATEGORY_ACCESS');
     }
     $name = get_translated_text($myrow['name']);
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems(get_page_name(), strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $id), '_SELF', NULL, false, false, true), $name, get_value('comment_forum__downloads'));
     // Views
     if (get_db_type() != 'xml') {
         $myrow['download_views']++;
         $GLOBALS['SITE_DB']->query_update('download_downloads', array('download_views' => $myrow['download_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     // Tree
     $tree = download_breadcrumbs($myrow['category_id'], $root, false, get_zone_name());
     $title_to_use = do_lang_tempcode('DOWNLOAD_TITLE', escape_html($name));
     $title_to_use_2 = do_lang('DOWNLOAD_TITLE', $name);
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('download', strval($id));
     } else {
         $awards = array();
     }
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     seo_meta_load_for('downloads_download', strval($id), $title_to_use_2);
     $warning_details = new ocp_tempcode();
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '5b1781b8fbb1ef9b8f47693afcff02b9', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))));
     }
     // Cost warning
     if ($myrow['download_cost'] != 0 && addon_installed('points')) {
         require_lang('points');
         $warning_details->attach(do_template('WARNING_TABLE', array('_GUID' => '05fc448bf79b373385723c5af5ec93af', 'WARNING' => do_lang_tempcode('WILL_COST', integer_format($myrow['download_cost'])))));
     }
     // Admin functions
     $edit_url = new ocp_tempcode();
     $add_img_url = new ocp_tempcode();
     if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_downloads', array('downloads', $myrow['category_id']))) {
         $edit_url = build_url(array('page' => 'cms_downloads', 'type' => '_ed', 'id' => $id), get_module_zone('cms_downloads'));
     }
     if (addon_installed('galleries')) {
         if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) {
             require_lang('galleries');
             $add_img_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => 'download_' . strval($id)), get_module_zone('cms_galleries'));
         }
     }
     // Outmoding
     if (!is_null($myrow['out_mode_id'])) {
         $outmode_url = build_url(array('page' => '_SELF', 'type' => 'entry', 'id' => $myrow['out_mode_id'], 'root' => $root == db_get_first_id() ? NULL : $root), '_SELF');
     } else {
         $outmode_url = new ocp_tempcode();
     }
     // Stats
     $add_date = get_timezoned_date($myrow['add_date'], false);
     // Additional information
     $additional_details = get_translated_tempcode($myrow['comments']);
     // Edit date
     if (!is_null($myrow['edit_date'])) {
         $edit_date = make_string_tempcode(get_timezoned_date($myrow['edit_date'], false));
     } else {
         $edit_date = new ocp_tempcode();
     }
     $images_details = new ocp_tempcode();
     $image_url = '';
     $counter = 0;
     if (addon_installed('galleries')) {
         // Images
         require_lang('galleries');
         $cat = 'download_' . strval($id);
         $map = array('cat' => $cat);
         if (!has_specific_permission(get_member(), 'see_unvalidated')) {
             $map['validated'] = 1;
         }
         $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200);
         $div = 2;
         $_out = new ocp_tempcode();
         $_row = new ocp_tempcode();
         require_code('images');
         while (array_key_exists($counter, $rows)) {
             $row = $rows[$counter];
             //		$view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries'));
             $view_url = $row['url'];
             if ($image_url == '') {
                 $image_url = $row['url'];
             }
             if (url_is_local($view_url)) {
                 $view_url = get_custom_base_url() . '/' . $view_url;
             }
             $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']);
             $comment = get_translated_tempcode($row['comments']);
             $thumb = do_image_thumb($thumb_url, '');
             if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $row['submitter'], 'cms_galleries', array('galleries', 'download_' . strval($id)))) {
                 $iedit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ed', 'id' => $row['id']), get_module_zone('cms_galleries'));
             } else {
                 $iedit_url = new ocp_tempcode();
             }
             $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment));
             $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content)));
             if ($counter % $div == 1 && $counter != 0) {
                 $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row)));
                 $_row = new ocp_tempcode();
             }
             $counter++;
         }
         if (!$_row->is_empty()) {
             $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row)));
         }
         $images_details = $_out;
     }
     // Download link
     $author = $myrow['author'];
     $author_url = addon_installed('authors') ? build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')) : new ocp_tempcode();
     // Licence
     $licence_title = NULL;
     $licence_url = NULL;
     $licence_hyperlink = NULL;
     $licence = $myrow['download_licence'];
     if (!is_null($licence)) {
         $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence));
         if (!is_null($licence_title)) {
             $keep = symbol_tempcode('KEEP');
             $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate();
             $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license'));
         } else {
             $licence = NULL;
             // Orphaned
         }
     }
     breadcrumb_add_segment($tree, $title_to_use);
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $myrow['author'], 'publisher' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Download', 'title' => get_translated_text($myrow['name']), 'identifier' => '_SEARCH:downloads:view:' . strval($id), 'description' => get_translated_text($myrow['description']), 'image' => $image_url);
     return do_template('DOWNLOAD_SCREEN', array('_GUID' => 'a9af438f84783d0d38c20b5f9a62dbdb', 'ORIGINAL_FILENAME' => $myrow['original_filename'], 'URL' => $myrow['url'], 'NUM_IMAGES' => strval($counter), 'TAGS' => get_loaded_tags('downloads'), 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink, 'SUBMITTER' => strval($myrow['submitter']), 'EDIT_DATE' => $edit_date, 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'VIEWS' => integer_format($myrow['download_views']), 'NAME' => $name, 'DATE' => $add_date, 'DATE_RAW' => strval($myrow['add_date']), 'NUM_DOWNLOADS' => integer_format($myrow['num_downloads']), 'TITLE' => $title, 'OUTMODE_URL' => $outmode_url, 'WARNING_DETAILS' => $warning_details, 'EDIT_URL' => $edit_url, 'ADD_IMG_URL' => $add_img_url, 'DESCRIPTION' => get_translated_tempcode($myrow['description']), 'ADDITIONAL_DETAILS' => $additional_details, 'IMAGES_DETAILS' => $images_details, 'ID' => strval($id), 'FILE_SIZE' => clean_file_size($myrow['file_size']), 'AUTHOR_URL' => $author_url, 'AUTHOR' => $author, 'TRACKBACK_DETAILS' => $trackback_details, 'RATING_DETAILS' => $rating_details, 'COMMENTS_DETAILS' => $comment_details));
 }
Пример #7
0
/**
 * Get a map of the fields for the given entry.
 *
 * @param  array			A database row of the entry we are working with
 * @param  ?array			A database row of the catalogue we are working with (NULL: read it in here)
 * @param  ID_TEXT		The view type we're doing
 * @set    PAGE SEARCH CATEGORY
 * @param  ID_TEXT		The template set we are rendering this category using
 * @param  ?AUTO_LINK	The virtual root for display of this category (NULL: none)
 * @param  ?array			The database rows for the fields for this catalogue (NULL: find them)
 * @param  ?array			A list of fields that we are limiting ourselves to (NULL: get ALL fields)
 * @param  boolean		Whether to grab the feedback details
 * @param  boolean		Whether to grab the tree details
 * @param  ?integer		Field index to order by (NULL: none)
 * @return array			A map of information relating to the entry. The map contains 'FIELDS' (tempcode for all accumulated fields), 'FIELD_x' (for each field x applying to the entry), STAFF_DETAILS, COMMENT_DETAILS, RATING_DETAILS, VIEW_URL, TREE (tempcode category tree to this entry)
 */
function get_catalogue_entry_map($entry, $catalogue, $view_type, $tpl_set, $root = NULL, $fields = NULL, $only_fields = NULL, $feedback_details = false, $tree_details = false, $order_by = NULL)
{
    $id = $entry['id'];
    if (is_null($catalogue)) {
        $catalogue_rows = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $entry['c_name']), '', 1);
        if (!array_key_exists(0, $catalogue_rows)) {
            warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
        }
        $catalogue = $catalogue_rows[0];
    }
    // Views
    if (get_db_type() != 'xml') {
        $entry['ce_views']++;
    }
    $catalogue_name = $catalogue['c_name'];
    $fields = get_catalogue_entry_field_values($catalogue_name, $entry, $only_fields, $fields, false, $view_type);
    $map = array();
    $map['FIELDS'] = new ocp_tempcode();
    $map['FIELDS_TABLE'] = new ocp_tempcode();
    $map['fields'] = $fields;
    $fields_1d = array();
    $fields_2d = array();
    $all_visible = true;
    require_code('fields');
    foreach ($fields as $i => $field) {
        if (!array_key_exists('effective_value', $field)) {
            $all_visible = false;
            continue;
        }
        $ev = $field['effective_value'];
        $dereference_ev = is_object($field['effective_value']) ? $field['effective_value']->evaluate() : $field['effective_value'];
        $use_ev = $dereference_ev;
        $ob = get_fields_hook($field['cf_type']);
        $use_ev = $ob->render_field_value($field, $ev, $i, $only_fields);
        if ($i == 0 && $catalogue['c_display_type'] == 1) {
            //$use_ev=hyperlink(build_url(array('page'=>'catalogues','type'=>'entry','id'=>$id,'root'=>$root),get_module_zone('catalogues')),$ev,false,!is_object($ev));
            $use_ev = $ev;
        }
        //Set image thumbnail in to the map array
        if ($field['cf_type'] == 'picture') {
            if (!is_null($ev) && $dereference_ev != '') {
                require_code('images');
                $map['FIELD_' . strval($i) . '_THUMB'] = do_image_thumb($dereference_ev, $i == 0 ? '' : (is_object($map['FIELD_0']) ? $map['FIELD_0']->evaluate() : $map['FIELD_0']), false, false, 100, 100);
            } else {
                $map['FIELD_' . strval($i) . '_THUMB'] = new ocp_tempcode();
            }
            $map['_FIELD_' . strval($field['id']) . '_THUMB'] = $map['FIELD_' . strval($i) . '_THUMB'];
        }
        $map['FIELD_' . strval($i)] = $use_ev;
        $map['_FIELD_' . strval($field['id'])] = $use_ev;
        $map['FIELD_' . strval($i) . '_PLAIN'] = $ev;
        $map['_FIELD_' . strval($field['id']) . '_PLAIN'] = $ev;
        if (array_key_exists('effective_value_pure', $field)) {
            $map['FIELD_' . strval($i) . '_PURE'] = $field['effective_value_pure'];
            $map['_FIELD_' . strval($field['id']) . '_PURE'] = $field['effective_value_pure'];
        }
        $field_name = get_translated_text($field['cf_name']);
        $map['FIELDNAME_' . strval($i)] = $field_name;
        $fields_2d[] = array('NAME' => $field_name, 'VALUE' => $use_ev);
        $field_type = $field['cf_type'];
        $map['FIELDTYPE_' . strval($i)] = $field_type;
        if ($view_type == 'PAGE' || $field['cf_put_in_category'] == 1 && $view_type == 'CATEGORY' || $field['cf_put_in_search'] == 1 && $view_type == 'SEARCH') {
            $use_ev_enhanced = $use_ev;
            /*if (($view_type!='PAGE') && ($i==0) && (($field['cf_type']=='short_trans') || ($field['cf_type']=='short_text')))
            		{
            			foreach ($fields as $field_temp)
            			{
            				if ((array_key_exists('effective_value',$field_temp)) && ($field_temp['cf_type']=='url') && (!((($field_temp['cf_put_in_category']==1) && ($view_type=='CATEGORY')) || (($field_temp['cf_put_in_search']==1) && ($view_type=='SEARCH')))) && ($field_temp['cf_visible']==1))
            				{
            					if ($field_temp['effective_value']!='')
            					{
            						$use_ev_enhanced=hyperlink($field_temp['effective_value'],$use_ev,true);
            						break;
            					}
            				}
            			}
            		}*/
            if ($field['cf_visible'] == 1 || $i == 0) {
                $_field = do_template('CATALOGUE_' . $tpl_set . '_ENTRY_FIELD', array('ENTRYID' => strval($id), 'CATALOGUE' => $catalogue_name, 'TYPE' => $field['cf_type'], 'FIELD' => $field_name, 'FIELDID' => strval($i), '_FIELDID' => strval($field['id']), 'FIELDTYPE' => $field_type, 'VALUE_PLAIN' => $ev, 'VALUE' => $use_ev_enhanced), NULL, false, 'CATALOGUE_DEFAULT_ENTRY_FIELD');
                if (!is_string($ev) || $ev != '') {
                    $map['FIELDS']->attach($_field);
                }
                $_field = do_template('CATALOGUE_' . $tpl_set . '_TAB_FIELD', array('ENTRYID' => strval($id), 'CATALOGUE' => $catalogue_name, 'TYPE' => $field['cf_type'], 'FIELD' => $field_name, 'FIELDID' => strval($i), '_FIELDID' => strval($field['id']), 'FIELDTYPE' => $field_type, 'VALUE_PLAIN' => $ev, 'VALUE' => $use_ev_enhanced), NULL, false, 'CATALOGUE_DEFAULT_TAB_FIELD');
                $map['FIELDS_TABLE']->attach($_field);
            }
        } else {
            $all_visible = false;
        }
        $fields_1d[] = $field;
        if (!($field['cf_visible'] == 1 || $i == 0 || $order_by === $i)) {
            $all_visible = false;
        }
    }
    $map['FIELDS_1D'] = $fields_1d;
    $map['FIELDS_2D'] = $fields_2d;
    // Admin functions
    if (has_actual_page_access(NULL, 'cms_catalogues', NULL, NULL) && has_edit_permission('mid', get_member(), $entry['ce_submitter'], 'cms_catalogues', array('catalogues_catalogue', $catalogue_name, 'catalogues_category', $entry['cc_id']))) {
        $map['EDIT_URL'] = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_entry', 'catalogue_name' => $catalogue_name, 'id' => $id), get_module_zone('cms_catalogues'));
    } else {
        $map['EDIT_URL'] = '';
    }
    $map['SUBMITTER'] = strval($entry['ce_submitter']);
    $map['VIEWS'] = strval($entry['ce_views']);
    $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']);
    $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']);
    $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']);
    $map['EDIT_DATE'] = get_timezoned_date($entry['ce_edit_date']);
    $map['ID'] = strval($id);
    if (get_option('is_on_comments') == '1' && !has_no_forum() && $entry['allow_comments'] >= 1) {
        $map['COMMENT_COUNT'] = '1';
    }
    // Feedback
    //Set basic rating display of item to the map array
    require_code('feedback');
    $c_value = array_key_exists('FIELD_0_PLAIN_PURE', $map) ? $map['FIELD_0_PLAIN_PURE'] : $map['FIELD_0_PLAIN'];
    if (is_object($c_value)) {
        $c_value = $c_value->evaluate();
    }
    $self_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id), get_module_zone('catalogues'), NULL, false, false, true);
    if ($feedback_details || $only_fields !== array(0)) {
        $map['RATING'] = $entry['allow_rating'] == 1 ? display_rating($self_url, $c_value, 'catalogues__' . $catalogue_name, strval($id), 'RATING_INLINE_STATIC', $entry['ce_submitter']) : new ocp_tempcode();
    }
    if ($feedback_details) {
        list($map['RATING_DETAILS'], $map['COMMENT_DETAILS'], $map['TRACKBACK_DETAILS']) = embed_feedback_systems('catalogues__' . $catalogue_name, strval($id), $entry['allow_rating'], $entry['allow_comments'], $entry['allow_trackbacks'], $entry['ce_validated'], $entry['ce_submitter'], $self_url, $c_value, get_value('comment_forum__catalogues__' . $catalogue_name));
    }
    if (get_option('is_on_comments') == '1' && $entry['allow_comments'] >= 1 || get_option('is_on_rating') == '1' && $entry['allow_rating'] == 1 || get_option('is_on_trackbacks') == '1' && $entry['allow_trackbacks'] == 1 || !$all_visible) {
        $map['VIEW_URL'] = $tpl_set == 'WML' ? make_string_tempcode('wap.php?page=catalogues&type=entry&id=' . strval($id)) : build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $id, 'root' => $root == -1 ? NULL : $root), get_module_zone('catalogues'));
    } else {
        $map['VIEW_URL'] = '';
    }
    if ($tree_details) {
        $map['TREE'] = '';
        if ($catalogue['c_is_tree'] == 1 && is_null($only_fields)) {
            $tree = catalogue_category_breadcrumbs($entry['cc_id'], $root, false);
            $map['TREE'] = $tree;
        }
    }
    $map['CATALOGUE'] = $catalogue_name;
    $map['CAT'] = strval($entry['cc_id']);
    return $map;
}
Пример #8
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('iotds');
     require_css('iotds');
     $mode = array_key_exists('param', $map) ? $map['param'] : 'current';
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('iotds');
     if (has_actual_page_access(NULL, 'cms_iotds', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_iotds')) {
         $submit_url = build_url(array('page' => 'cms_iotds', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_iotds'));
     } else {
         $submit_url = new ocp_tempcode();
     }
     if ($mode == 'current') {
         $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('is_current' => 1), 'ORDER BY id DESC', 1);
     } elseif (is_numeric($mode)) {
         $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('id' => intval($mode)), '', 1);
         if (!array_key_exists(0, $iotd)) {
             return do_template('BLOCK_NO_ENTRIES', array('HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url));
         }
     } else {
         $cnt = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1));
         if ($cnt == 0) {
             return do_template('BLOCK_NO_ENTRIES', array('HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url));
         }
         $at = mt_rand(0, $cnt - 1);
         $iotd = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), '', 1, $at);
     }
     if (!array_key_exists(0, $iotd)) {
         return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '62baa388e068d4334f7a6c6093ead56a', 'HIGH' => true, 'TITLE' => do_lang_tempcode('IOTD'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IOTD'), 'SUBMIT_URL' => $submit_url));
     }
     $myrow = $iotd[0];
     $image_url = $myrow['url'];
     if (url_is_local($image_url)) {
         $image_url = get_custom_base_url() . '/' . $image_url;
     }
     $view_url = build_url(array('page' => 'iotds', 'wide' => 1, 'type' => 'view', 'id' => $myrow['id']), $zone);
     require_code('images');
     $thumb_url = ensure_thumbnail($myrow['url'], $myrow['thumb_url'], 'iotds', 'iotd', $myrow['id']);
     $caption = get_translated_tempcode($myrow['i_title']);
     $image = do_image_thumb($thumb_url, do_lang('IOTD'));
     $archive_url = build_url(array('page' => 'iotds', 'type' => 'misc'), $zone);
     $tpl = do_template('IOTD', array('_GUID' => 'ca9c4b4941c12c15f7bdfe4cb57cd266', 'ID' => strval($myrow['id']), 'IMAGE_URL' => $image_url, 'SUBMITTER' => strval($myrow['submitter']), 'VIEW_URL' => $view_url, 'CAPTION' => $caption, 'IMAGE' => $image));
     $map2 = array('_GUID' => 'd710da3675a1775867168ae37db02ad4', 'CURRENT' => $mode == 'current', 'FULL_URL' => $view_url, 'ID' => strval($myrow['id']), 'CONTENT' => $tpl, 'ARCHIVE_URL' => $archive_url, 'SUBMIT_URL' => $submit_url);
     if (get_option('is_on_comments') == '1' && get_forum_type() != 'none' && $myrow['allow_comments'] >= 1) {
         $map2['COMMENT_COUNT'] = '1';
     }
     return do_template('BLOCK_MAIN_IOTD', $map2);
 }
Пример #9
0
/**
 * Get preview detailing for a gallery.
 *
 * @param  array			The database row of the gallery
 * @param  ID_TEXT		The virtual root of the gallery
 * @param  boolean		Whether to show member stats if it is a member owned gallery
 * @param  ID_TEXT		The zone that the gallery module we are linking to is in
 * @param  boolean		Whether to not show anything if the gallery is empty
 * @param  boolean		Whether only to show 'preview' details
 * @return tempcode		The preview
 */
function show_gallery_box($child, $root = 'root', $show_member_stats_if_appropriate = false, $zone = '_SEARCH', $quit_if_empty = true, $preview = false)
{
    $member_id = get_member_id_from_gallery_name($child['name'], $child, true);
    $url = build_url(array('page' => 'galleries', 'type' => 'misc', 'root' => $root == 'root' ? NULL : $root, 'id' => $child['name']), $zone);
    $_title = get_translated_text($child['fullname']);
    $pic = $child['rep_image'];
    $is_member = !is_null($member_id);
    if ($pic == '' && $is_member) {
        $pic = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id);
    }
    $add_date = get_timezoned_date($child['add_date'], false);
    $comments = get_translated_tempcode($child['description']);
    if ($show_member_stats_if_appropriate) {
        if ($is_member && get_forum_type() == 'ocf') {
            require_code('ocf_members');
            require_code('ocf_members2');
            $member_info = ocf_show_member_box($member_id, true);
        } else {
            $member_info = new ocp_tempcode();
        }
    } else {
        $member_info = new ocp_tempcode();
    }
    list($num_children, $num_images, $num_videos) = get_recursive_gallery_details($child['name']);
    if ($quit_if_empty && $num_images == 0 && $num_videos == 0 && $num_children == 0) {
        return new ocp_tempcode();
    }
    $thumb_order = 'ORDER BY id ASC';
    if (get_option('reverse_thumb_order') == '1') {
        $thumb_order = 'ORDER BY id DESC';
    }
    if ($pic == '') {
        $pic = $GLOBALS['SITE_DB']->query_value_null_ok('images', 'thumb_url', array('cat' => $child['name'], 'validated' => 1), $thumb_order);
        if ($pic === '') {
            require_code('images');
            $temp = $GLOBALS['SITE_DB']->query_select('images', array('id', 'url'), array('cat' => $child['name'], 'validated' => 1), $thumb_order, 1);
            $thumb_url = ensure_thumbnail($temp[0]['url'], '', 'galleries', 'images', $temp[0]['id']);
        }
    }
    if (is_null($pic)) {
        $pic = $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'thumb_url', array('cat' => $child['name'], 'validated' => 1), $thumb_order);
    }
    if (is_null($pic)) {
        $pic = '';
    }
    if ($pic != '' && url_is_local($pic)) {
        $pic = get_custom_base_url() . '/' . $pic;
    }
    if ($pic != '') {
        require_code('images');
        $thumb = do_image_thumb($pic, '');
    } else {
        $thumb = new ocp_tempcode();
    }
    if ($num_children == 0) {
        if ($child['accept_videos'] == 0) {
            $lang = do_lang_tempcode('_SUBGALLERY_BITS_IMAGES', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos));
        } elseif ($child['accept_images'] == 0) {
            $lang = do_lang_tempcode('_SUBGALLERY_BITS_VIDEOS', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos));
        } else {
            $lang = do_lang_tempcode('_SUBGALLERY_BITS', integer_format($num_images), integer_format($num_videos), integer_format($num_images + $num_videos));
        }
    } else {
        if ($child['accept_videos'] == 0) {
            $lang = do_lang_tempcode('SUBGALLERY_BITS_IMAGES', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos)));
        } elseif ($child['accept_images'] == 0) {
            $lang = do_lang_tempcode('SUBGALLERY_BITS_VIDEOS', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos)));
        } else {
            $lang = do_lang_tempcode('SUBGALLERY_BITS', integer_format($num_children), integer_format($num_images), array(integer_format($num_videos), integer_format($num_images + $num_videos)));
        }
    }
    $tpl = do_template('GALLERY_SUBGALLERY', array('_GUID' => '0dbec2f11de63b0402471fe5c8b32865', 'NUM_VIDEOS' => strval($num_videos), 'NUM_IMAGES' => strval($num_images), 'NUM_CHILDREN' => strval($num_children), 'ID' => $child['name'], 'LANG' => $lang, 'ADD_DATE' => $add_date, 'ADD_DATE_RAW' => strval($child['add_date']), 'MEMBER_INFO' => $member_info, 'URL' => $url, 'THUMB' => $thumb, 'PIC' => $pic, 'TITLE' => $_title, 'COMMENTS' => $comments));
    return $tpl;
}
Пример #10
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_css('galleries');
     require_lang('galleries');
     require_code('galleries');
     require_code('images');
     require_code('feedback');
     require_code('ocfiltering');
     $cat = array_key_exists('param', $map) ? $map['param'] : 'root';
     $cat_select = ocfilter_to_sqlfragment($cat, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false);
     $title = array_key_exists('title', $map) ? $map['title'] : '';
     /*if ((file_exists(get_custom_file_base().'/themes/default/templates_custom/JAVASCRIPT_GALLERIES.tpl')) || (file_exists(get_file_base().'/themes/default/templates/JAVASCRIPT_GALLERIES.tpl')))
     		require_javascript('javascript_galleries');*/
     $max = get_param_integer('mge_max', array_key_exists('max', $map) ? intval($map['max']) : 30);
     $start = get_param_integer('mge_start', 0);
     if (!array_key_exists('select', $map)) {
         $map['select'] = '*';
     }
     $image_select = ocfilter_to_sqlfragment($map['select'], 'id');
     if (!array_key_exists('video_select', $map)) {
         $map['video_select'] = '*';
     }
     $video_select = ocfilter_to_sqlfragment($map['video_select'], 'id');
     $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries');
     $_days = array_key_exists('days', $map) ? $map['days'] : '';
     $days = mixed();
     $days = $_days == '' ? NULL : intval($_days);
     $where_sup = '';
     if (!is_null($days)) {
         $where_sup .= ' AND add_date>=' . strval(time() - $days * 60 * 60 * 24);
     }
     $sort = array_key_exists('sort', $map) ? $map['sort'] : 'add_date DESC';
     if ($sort != 'random ASC' && $sort != 'fixed_random ASC' && $sort != 'compound_rating DESC' && $sort != 'compound_rating ASC' && $sort != 'add_date DESC' && $sort != 'add_date ASC' && $sort != 'url DESC' && $sort != 'url ASC') {
         $sort = 'add_date DESC';
     }
     list($_sort, $_dir) = explode(' ', $sort, 2);
     $total_images = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'images WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup);
     $total_videos = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'videos WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup);
     if ($_sort == 'random') {
         $start = 0;
         $max = min($total_images + $total_videos, $max);
         $done_images = '1=1';
         $done_videos = '1=1';
         $rows_images = array();
         $rows_videos = array();
         for ($i = 0; $i < $max; $i++) {
             if (mt_rand(0, 1) == 0 || $total_videos - count($rows_videos) == 0) {
                 $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' AND ' . $done_images, 1, mt_rand(0, $total_images - count($rows_images) - 1));
                 $rows_images[] = $rows[0];
                 $done_images .= ' AND ';
                 $done_images .= 'id<>' . strval($rows[0]['id']);
             } else {
                 $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' AND ' . $done_videos, 1, mt_rand(0, $total_videos - count($rows_videos) - 1));
                 $rows_videos[] = $rows[0];
                 $done_videos .= ' AND ';
                 $done_videos .= 'id<>' . strval($rows[0]['id']);
             }
         }
     } else {
         if ($_sort == 'compound_rating') {
             $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'images') . ' AND rating_for_id=e.id) AS compound_rating';
         } elseif ($_sort == 'fixed_random') {
             $rating_sort = ',(MOD(id,3.142)) AS fixed_random';
         } else {
             $rating_sort = '';
         }
         $rows_images = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $cat_select . ' AND ' . $image_select . $where_sup . ' ORDER BY ' . $sort, $max + $start);
         if ($_sort == 'compound_rating') {
             $rating_sort = ',(SELECT AVG(rating) FROM ' . get_table_prefix() . 'rating WHERE ' . db_string_equal_to('rating_for_type', 'videos') . ' AND rating_for_id=e.id) AS compound_rating';
         } elseif ($_sort == 'fixed_random') {
             $rating_sort = ',(MOD(id,3.142)) AS fixed_random';
         } else {
             $rating_sort = '';
         }
         $rows_videos = $GLOBALS['SITE_DB']->query('SELECT *' . $rating_sort . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $cat_select . ' AND ' . $video_select . $where_sup . ' ORDER BY ' . $sort, $max + $start);
     }
     // Sort
     $combined = array();
     foreach ($rows_images as $row_image) {
         $combined[] = array($row_image, 'image', $_sort == 'random' ? NULL : $row_image[$_sort]);
     }
     foreach ($rows_videos as $row_video) {
         $combined[] = array($row_video, 'video', $_sort == 'random' ? NULL : $row_video[$_sort]);
     }
     if ($_sort == 'random') {
         shuffle($combined);
     } else {
         global $M_SORT_KEY;
         $M_SORT_KEY = 2;
         usort($combined, 'multi_sort');
         if ($_dir == 'DESC') {
             $combined = array_reverse($combined);
         }
     }
     // Display
     $entries = new ocp_tempcode();
     foreach ($combined as $i => $c) {
         if ($i >= $start) {
             switch ($c[1]) {
                 case 'image':
                     // Display image
                     $row_image = $c[0];
                     $view_url = build_url(array('page' => 'galleries', 'type' => 'image', 'wide' => 1, 'id' => $row_image['id']), $zone);
                     $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']);
                     $thumb = do_image_thumb($thumb_url, '', true);
                     $full_url = $row_image['url'];
                     $file_size = url_is_local($full_url) ? file_exists(get_custom_file_base() . '/' . rawurldecode($full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($full_url))) : '' : '';
                     if (url_is_local($full_url)) {
                         $full_url = get_custom_base_url() . '/' . $full_url;
                     }
                     $thumb_url = $row_image['thumb_url'];
                     if (url_is_local($thumb_url)) {
                         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
                     }
                     $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL;
                     $entry_map = array('_GUID' => '043ac7d15ce02715ac02309f6e8340ff', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'ID' => strval($row_image['id']), 'FILE_SIZE' => $file_size, 'SUBMITTER' => strval($row_image['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date']));
                     $entry = do_template('GALLERY_IMAGE', $entry_map);
                     $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => '13134830e1ebea158ab44885eeec0953', 'ENTRY' => $entry) + $entry_map));
                     break;
                 case 'video':
                     // Display video
                     $row_video = $c[0];
                     $view_url = build_url(array('page' => 'galleries', 'type' => 'video', 'wide' => 1, 'id' => $row_video['id']), $zone);
                     $thumb_url = $row_video['thumb_url'];
                     if ($thumb_url != '' && url_is_local($thumb_url)) {
                         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
                     }
                     if ($thumb_url == '') {
                         $thumb_url = find_theme_image('na');
                     }
                     $thumb = do_image_thumb($thumb_url, '', true);
                     $full_url = $row_video['url'];
                     if (url_is_local($full_url)) {
                         $full_url = get_custom_base_url() . '/' . $full_url;
                     }
                     $thumb_url = $row_video['thumb_url'];
                     if ($thumb_url != '' && url_is_local($thumb_url)) {
                         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
                     }
                     $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating($view_url, get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL;
                     $entry_map = array('_GUID' => '66b7fb4d3b61ef79d6803c170d102cbf', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'ID' => strval($row_video['id']), 'CAT' => $cat, 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'SUBMITTER' => strval($row_video['submitter']), 'FULL_URL' => $full_url, 'THUMB_URL' => $thumb_url, 'VIDEO_DETAILS' => show_video_details($row_video), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date']));
                     $entry = do_template('GALLERY_VIDEO', $entry_map);
                     $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'a0ff010ae7fd1f7b3341993072ed23cf', 'ENTRY' => $entry) + $entry_map));
                     break;
             }
         }
         $i++;
         if ($i == $start + $max) {
             break;
         }
     }
     if (!isset($map['render_if_empty']) || $map['render_if_empty'] != '1') {
         if ($entries->is_empty()) {
             if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_galleries', array('galleries', $cat))) {
                 $submit_url = build_url(array('page' => 'cms_galleries', 'type' => 'ad', 'cat' => $cat, 'redirect' => SELF_REDIRECT), get_module_zone('cms_galleries'));
             } else {
                 $submit_url = new ocp_tempcode();
             }
             return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'bf84d65b8dd134ba6cd7b1b7bde99de2', 'HIGH' => false, 'TITLE' => do_lang_tempcode('GALLERY'), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('ADD_IMAGE'), 'SUBMIT_URL' => $submit_url));
         }
     }
     // Results browser
     require_code('templates_results_browser');
     $_selectors = array_map('intval', explode(',', get_option('gallery_selectors')));
     $root = get_param('root', 'root');
     $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'mge_start', $max, 'mge_max', $total_videos + $total_images, $root, 'misc', true, false, 10, $_selectors);
     $tpl = do_template('BLOCK_MAIN_GALLERY_EMBED', array('_GUID' => 'b7b969c8fe8c398dd6e3af7ee06717ea', 'IMAGE_SELECT' => $map['select'], 'VIDEO_SELECT' => $map['video_select'], 'DAYS' => $_days, 'SORT' => $sort, 'BLOCK_PARAMS' => block_params_arr_to_str($map), 'RESULTS_BROWSER' => $results_browser, 'TITLE' => $title, 'CAT' => $cat, 'IMAGES' => $entries, 'MAX' => strval($max), 'ZONE' => $zone, 'TOTAL_VIDEOS' => strval($total_videos), 'TOTAL_IMAGES' => strval($total_images), 'TOTAL' => strval($total_videos + $total_images)));
     return $tpl;
 }
Пример #11
0
 /**
  * Standard modular run function for rendering a search result.
  *
  * @param  array		The data row stored when we retrieved the result
  * @return tempcode	The output
  */
 function render($row)
 {
     require_code('images');
     $url = build_url(array('page' => 'iotds', 'type' => 'view', 'id' => $row['id']), get_module_zone('iotds'));
     $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'iotds', 'iotd', $row['id']);
     return put_in_standard_box(hyperlink($url, do_image_thumb($thumb_url, get_translated_tempcode($row['i_title']), true)), do_lang_tempcode('IOTD'));
 }
Пример #12
0
 /**
  * Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls).
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @return string			XML in the special category,entry format
  */
 function run($id, $options, $default = NULL)
 {
     require_code('downloads');
     if (!is_numeric($id) && $id != '') {
         if (substr($id, 0, 8) == 'Version ') {
             $id_float = floatval(substr($id, 8));
             do {
                 $str = 'Version ' . float_to_raw_string($id_float, 1);
                 $_id = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=c.category', 'c.id', array('parent_id' => 3, 'text_original' => $str));
                 if (is_null($_id)) {
                     $id_float -= 0.1;
                 }
             } while (is_null($_id) && $id_float != 0.0);
         } else {
             $_id = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON t.id=c.category', 'c.id', array('text_original' => $id));
         }
         if (is_null($_id)) {
             warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
         }
         $id = strval($_id);
     }
     $only_owned = array_key_exists('only_owned', $options) ? is_null($options['only_owned']) ? NULL : intval($options['only_owned']) : NULL;
     $shun = array_key_exists('shun', $options) ? $options['shun'] : NULL;
     $editable_filter = array_key_exists('editable_filter', $options) ? $options['editable_filter'] : false;
     $tar_filter = array_key_exists('tar_filter', $options) ? $options['original_filename'] : false;
     $tree = get_downloads_tree($only_owned, is_null($id) ? NULL : intval($id), NULL, NULL, $shun, is_null($id) ? 0 : 1, false, $editable_filter, $tar_filter);
     if (!has_actual_page_access(NULL, 'downloads')) {
         $tree = array();
     }
     $file_type = get_param('file_type', '');
     $out = '';
     foreach ($tree as $t) {
         $_id = $t['id'];
         if ($id === strval($_id)) {
             asort($t['entries']);
             foreach ($t['entries'] as $eid => $etitle) {
                 $row = $GLOBALS['SITE_DB']->query_select('download_downloads', array('description', 'original_filename'), array('id' => $eid), '', 1);
                 if ($file_type != '') {
                     if (substr($row[0]['original_filename'], -strlen($file_type) - 1) != '.' . $file_type) {
                         continue;
                     }
                 }
                 $lang_id = $row[0]['description'];
                 $description = get_translated_text($lang_id);
                 $description_html = get_translated_tempcode($lang_id);
                 $images_details = new ocp_tempcode();
                 if (addon_installed('galleries')) {
                     // Images
                     $_out = new ocp_tempcode();
                     require_lang('galleries');
                     $cat = 'download_' . strval($eid);
                     $map = array('cat' => $cat);
                     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
                         $map['validated'] = 1;
                     }
                     $rows = $GLOBALS['SITE_DB']->query_select('images', array('*'), $map, 'ORDER BY id', 200);
                     $counter = 0;
                     $div = 2;
                     $_out = new ocp_tempcode();
                     $_row = new ocp_tempcode();
                     require_code('images');
                     while (array_key_exists($counter, $rows)) {
                         $row = $rows[$counter];
                         //		$view_url=build_url(array('page'=>'galleries','type'=>'image','wide'=>1,'id'=>$row['id']),get_module_zone('galleries'));
                         $view_url = $row['url'];
                         if (url_is_local($view_url)) {
                             $view_url = get_custom_base_url() . '/' . $view_url;
                         }
                         $thumb_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', 'images', $row['id']);
                         $comment = get_translated_tempcode($row['comments']);
                         $thumb = do_image_thumb($thumb_url, '');
                         $iedit_url = new ocp_tempcode();
                         $_content = do_template('DOWNLOAD_SCREEN_IMAGE', array('_GUID' => 'fba0e309aa0ae04891e32c65a625b177', 'ID' => strval($row['id']), 'VIEW_URL' => $view_url, 'EDIT_URL' => $iedit_url, 'THUMB' => $thumb, 'COMMENT' => $comment));
                         $_row->attach(do_template('DOWNLOAD_GALLERY_IMAGE_CELL', array('_GUID' => '8400a832dbed64bb63f264eb3a038895', 'CONTENT' => $_content)));
                         if ($counter % $div == 1 && $counter != 0) {
                             $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => '205c4f5387e98c534d5be1bdfcccdd7d', 'CELLS' => $_row)));
                             $_row = new ocp_tempcode();
                         }
                         $counter++;
                     }
                     if (!$_row->is_empty()) {
                         $_out->attach(do_template('DOWNLOAD_GALLERY_ROW', array('_GUID' => 'e9667ca2545ac72f85a873f236cbbd6f', 'CELLS' => $_row)));
                     }
                     $images_details = put_in_standard_box($_out);
                 }
                 $description_html->attach($images_details);
                 $out .= '<entry id="' . xmlentities(strval($eid)) . '" description="' . xmlentities(strip_comcode($description)) . '" description_html="' . xmlentities($description_html->evaluate()) . '" title="' . xmlentities($etitle) . '" selectable="true"></entry>';
             }
             continue;
         }
         $title = $t['title'];
         $has_children = $t['child_count'] != 0 || $t['child_entry_count'] != 0;
         $out .= '<category id="' . xmlentities(strval($_id)) . '" title="' . xmlentities($title) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="false"></category>';
     }
     // Mark parent cats for pre-expansion
     if (!is_null($default) && $default != '') {
         $cat = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'category_id', array('id' => intval($default)));
         while (!is_null($cat)) {
             $out .= '<expand>' . strval($cat) . '</expand>';
             $cat = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories', 'parent_id', array('id' => $cat));
         }
     }
     return '<result>' . $out . '</result>';
 }
Пример #13
0
 /**
  * Show shopping cart entries
  *
  * @param  tempcode	Tempcode object of shopping cart result table.
  * @param  array		Details of new entry to the shopping cart.
  * @return tempcode	Tempcode object of shopping cart result table.
  */
 function show_cart_entry(&$shopping_cart, $entry)
 {
     $tpl_set = 'cart';
     require_code('images');
     $edit_qnty = do_template('SHOPPING_ITEM_QUANTITY_FIELD', array('PRODUCT_ID' => strval($entry['product_id']), 'QUANTITY' => strval($entry['quantity'])));
     $tax = $this->calculate_tax($entry['price'], $entry['price_pre_tax']);
     $shipping_cost = $this->calculate_shipping_cost($entry['product_weight']);
     $del_item = do_template('SHOPPING_ITEM_REMOVE_FIELD', array('PRODUCT_ID' => strval($entry['product_id'])));
     $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'c_name', array('id' => $entry['product_id']));
     $image = $this->get_product_image($catalogue_name, $entry['product_id']);
     if ($image == '') {
         $product_image = do_image_thumb('themes/default/images/no_image.png', do_lang('NO_IMAGE'), do_lang('NO_IMAGE'), false, 50, 50);
     } else {
         $product_image = do_image_thumb(url_is_local($image) ? get_custom_base_url() . '/' . $image : $image, $entry['product_name'], $entry['product_name'], false, 50, 50);
     }
     $currency = ecommerce_get_currency_symbol();
     $price = round(round($entry['price'] + $tax + $shipping_cost, 2) * $entry['quantity'], 2);
     $total_tax = $tax * $entry['quantity'];
     $total_shipping = $shipping_cost * $entry['quantity'];
     $order_price = $entry["price"] * $entry['quantity'];
     $product_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $entry['product_id']), '_SELF');
     $product_link = hyperlink($product_url, $entry['product_name'], false, false, do_lang('INDEX'));
     $shopping_cart->attach(results_entry(array($product_image, $product_link, $currency . escape_html(float_format(round($entry["price"], 2))), $edit_qnty, $currency . escape_html(float_format($order_price)), $currency . escape_html(float_format(round($total_tax, 2))), $currency . escape_html(float_format(round($total_shipping, 2))), $currency . escape_html(float_format(round($price, 2))), $del_item), false, $tpl_set));
     return $shopping_cart;
 }
Пример #14
0
 /**
  * The UI for an "regular mode" gallery.
  *
  * @param  tempcode		Rating area
  * @param  tempcode		Commenting area
  * @param  ID_TEXT		Our gallery ID
  * @param  ID_TEXT		Virtual root gallery
  * @param  tempcode		The description of the gallery
  * @param  tempcode		The tempcode for our visible child galleries
  * @param  boolean		Whether may "download this gallery"
  * @param  tempcode		The URL to "edit this gallery"
  * @param  tempcode		The URL to "add a gallery"
  * @param  tempcode		The URL to "submit an image to this gallery"
  * @param  tempcode		The URL to "submit a video to this gallery"
  * @param  tempcode		The title of the page (our of get_page_title)
  * @param  string			The gallery title
  * @param  tempcode		Sorting UI
  * @return tempcode		The UI
  */
 function do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting)
 {
     $max = get_param_integer('max', get_default_gallery_max());
     $start = get_param_integer('start', 0);
     if ($max < 1) {
         $max = 1;
     }
     $page_num = $max == 0 ? 0 : intval(floor(floatval($start) / floatval($max))) + 1;
     // Work out totals
     $num_images = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)', array('cat' => $cat));
     $num_videos = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)', array('cat' => $cat));
     $total_rows = $num_images + $num_videos;
     $total_pages = $max == 0 ? 1 : intval(ceil(floatval($total_rows) / floatval($max)));
     if ($total_pages == 0) {
         $total_pages = 1;
     }
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     $where = db_string_equal_to('cat', $cat);
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $where .= ' AND validated=1';
     }
     if (get_param('days', '') != '') {
         $where .= ' AND add_date>' . strval(time() - get_param_integer('days') * 60 * 60 * 24);
     }
     $rows = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_videos . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $where . ' ORDER BY ' . $sort, $max, $start);
     if (count($rows) < $max) {
         $where = db_string_equal_to('cat', $cat);
         if (!has_specific_permission(get_member(), 'see_unvalidated')) {
             $where .= ' AND validated=1';
         }
         $rows2 = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_images . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $where . ' ORDER BY ' . $sort, $max - count($rows), max(0, $start - $num_videos));
     } else {
         $rows2 = array();
     }
     $entries = new ocp_tempcode();
     $image_select = get_param('select', '*');
     $video_select = get_param('video_select', '*');
     // Display videos
     foreach ($rows as $row_video) {
         $view_url = build_url(array('page' => '_SELF', 'type' => 'video', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_video['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $start == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF');
         $thumb_url = ensure_thumbnail($row_video['url'], $row_video['thumb_url'], 'galleries', 'videos', $row_video['id']);
         if ($thumb_url == '') {
             $thumb_url = find_theme_image('na');
         }
         $thumb = do_image_thumb($thumb_url, '', true);
         $this_full_url = $row_video['url'];
         if (url_is_local($this_full_url)) {
             $this_full_url = get_custom_base_url() . '/' . $this_full_url;
         }
         $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL;
         $map = array('_GUID' => '395f0aa1212e69da5752d228a6efe54d', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_video['id']), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date']), 'SUBMITTER' => strval($row_video['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIDEO_DETAILS' => show_video_details($row_video));
         $entry = do_template('GALLERY_VIDEO', $map);
         $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'bc0d3de5d0160b00e3250d78658888c1', 'ENTRY' => $entry) + $map));
     }
     // Display images
     foreach ($rows2 as $row_image) {
         $view_url = build_url(array('page' => '_SELF', 'type' => 'image', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_image['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $max == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF');
         $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']);
         $thumb = do_image_thumb($thumb_url, '', true);
         $this_full_url = $row_image['url'];
         if (url_is_local($this_full_url)) {
             $file_size = file_exists(get_custom_file_base() . '/' . rawurldecode($this_full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($this_full_url))) : '';
             $this_full_url = get_custom_base_url() . '/' . $this_full_url;
         } else {
             $file_size = '';
         }
         $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL;
         $map = array('_GUID' => 'aa70f543297e25379c49fa25d6dbcac0', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'FILE_SIZE' => $file_size, 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_image['id']), 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date']), 'SUBMITTER' => strval($row_image['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url);
         $entry = do_template('GALLERY_IMAGE', $map);
         $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'ea12d7acf47eab493b6fb4658b3c0346', 'ENTRY' => $entry) + $map));
     }
     // Member gallery?
     $member_id = get_member_id_from_gallery_name($cat, NULL, true);
     if (get_forum_type() == 'ocf') {
         require_code('ocf_members');
         require_code('ocf_members2');
     }
     $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id);
     // Results browser
     require_code('templates_results_browser');
     $_selectors = array_map('intval', explode(',', get_option('gallery_selectors')));
     $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'start', $max, 'max', $total_rows, $root, 'misc', true, false, 10, $_selectors);
     return do_template('GALLERY_REGULAR_MODE_SCREEN', array('_GUID' => 'cec405597f47f5079b7c7f581fa6b5c2', 'SORTING' => $sorting, '_TITLE' => $fullname, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'RESULTS_BROWSER' => $results_browser, 'TAGS' => get_loaded_tags('galleries'), 'CAT' => $cat, 'MEMBER_DETAILS' => $member_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'ADD_GALLERY_URL' => $add_gallery_url, 'EDIT_URL' => $edit_url, 'CHILDREN' => $children, 'TITLE' => $title, 'DESCRIPTION' => $description, 'IMAGE_URL' => $submit_image_url, 'VIDEO_URL' => $submit_video_url, 'MAY_DOWNLOAD' => $may_download, 'ENTRIES' => $entries));
 }
Пример #15
0
 /**
  * Standard modular run function for search results.
  *
  * @param  string			Search string
  * @param  boolean		Whether to only do a META (tags) search
  * @param  ID_TEXT		Order direction
  * @param  integer		Start position in total results
  * @param  integer		Maximum results to return in total
  * @param  boolean		Whether only to search titles (as opposed to both titles and content)
  * @param  string			Where clause that selects the content according to the main search string (SQL query fragment) (blank: full-text search)
  * @param  SHORT_TEXT	Username/Author to match for
  * @param  ?MEMBER		Member-ID to match for (NULL: unknown)
  * @param  TIME			Cutoff date
  * @param  string			The sort type (gets remapped to a field in this function)
  * @set    title add_date
  * @param  integer		Limit to this number of results
  * @param  string			What kind of boolean search to do
  * @set    or and
  * @param  string			Where constraints known by the main search code (SQL query fragment)
  * @param  string			Comma-separated list of categories to search under
  * @param  boolean		Whether it is a boolean search
  * @return array			List of maps (template, orderer)
  */
 function run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $limit_to, $boolean_operator, $where_clause, $search_under, $boolean_search)
 {
     unset($author_id);
     unset($where_clause);
     require_lang('zones');
     // Calculate our where clause (search)
     if ($author != '') {
         return array();
     }
     require_code('files2');
     if ($search_under == '!') {
         $search_under = '';
     }
     $files = get_directory_contents(get_custom_file_base() . '/uploads/filedump/' . ($search_under == '' ? '' : $search_under . '/'));
     $_rows = $GLOBALS['SITE_DB']->query_select('filedump');
     $rows = array();
     foreach ($_rows as $row) {
         $rows[$row['path']] = $row;
     }
     $i = 0;
     $out = array();
     foreach ($files as $_path) {
         if ($search_under != '') {
             $_path = $search_under . '/' . $_path;
         }
         $path = get_custom_file_base() . '/uploads/filedump/' . $_path;
         if (filemtime($path) < $cutoff) {
             continue;
         }
         if (in_memory_search_match(array('content' => $content, 'conjunctive_operator' => $boolean_operator), $path)) {
             $caption = array_key_exists($_path, $rows) ? $rows[$_path] : $_path;
             $dirs = explode('/', dirname($_path));
             $pre = '';
             $file_breadcrumbs = new ocp_tempcode();
             $breadcrumbs_url = build_url(array('page' => 'filedump', 'place' => $pre . '/'), get_module_zone('filedump'));
             $file_breadcrumbs->attach(hyperlink($breadcrumbs_url, do_lang('ROOT')));
             foreach ($dirs as $dir) {
                 $file_breadcrumbs->attach(do_template('BREADCRUMB_SEPARATOR', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c4')));
                 $breadcrumbs_url = build_url(array('page' => 'filedump', 'place' => $pre . $dir . '/'), get_module_zone('filedump'));
                 $file_breadcrumbs->attach(hyperlink($breadcrumbs_url, $dir));
                 $pre .= $dir . '/';
             }
             $url = get_custom_base_url() . '/uploads/filedump/' . $_path;
             require_code('images');
             if (!is_image($url)) {
                 $tpl = paragraph(hyperlink($url, escape_html($caption), true), 'dfdsfu09wl;f');
                 if (!$file_breadcrumbs->is_empty()) {
                     $tpl->attach(paragraph(do_lang_tempcode('LOCATED_IN', $file_breadcrumbs)));
                 }
                 $out[$i]['template'] = do_template('SIMPLE_PREVIEW_BOX', array('_GUID' => '51bc0cf751f4ccbd0b7f1a247b092368', 'TITLE' => basename($_path), 'SUMMARY' => $tpl));
             } else {
                 if (function_exists('set_time_limit')) {
                     @set_time_limit(5);
                 }
                 $tpl = do_image_thumb($url, $caption, true, true);
                 $out[$i]['template'] = do_template('SIMPLE_PREVIEW_BOX', array('_GUID' => '61bc0cf751f4ccbd0b7f1a247b092368', 'TITLE' => basename($_path), 'SUMMARY' => $tpl, 'BREADCRUMBS' => $file_breadcrumbs, 'URL' => $url));
             }
             if ($sort == 'title') {
                 $out[$i]['orderer'] = $path;
             } elseif ($sort == 'add_date') {
                 $out[$i]['orderer'] = filectime($path);
             } elseif ($sort == 'file_size') {
                 $out[$i]['orderer'] = filesize($path);
             }
             $i++;
         }
     }
     return $out;
 }
Пример #16
0
 /**
  * The UI to browse IOTDs.
  *
  * @return tempcode		The UI
  */
 function iotd_browse()
 {
     $title = get_page_title('IOTD_ARCHIVE');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 20);
     $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('*'), array('used' => 1), 'ORDER BY date_and_time DESC', $max, $start);
     $max_rows = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)', array('used' => 1));
     $content = new ocp_tempcode();
     foreach ($rows as $myrow) {
         $date = get_timezoned_date($myrow['date_and_time']);
         $url = build_url(array('page' => '_SELF', 'type' => 'view', 'wide' => 1, 'id' => $myrow['id']), '_SELF');
         $thumb_url = $myrow['thumb_url'];
         $caption = get_translated_tempcode($myrow['i_title']);
         require_code('images');
         $thumb_url = ensure_thumbnail($myrow['url'], $thumb_url, 'iotds', 'iotd', $myrow['id']);
         $thumb = do_image_thumb($thumb_url, '');
         $content->attach(do_template('IOTD_VIEW_SCREEN_IOTD', array('SUBMITTER' => strval($myrow['submitter']), 'ID' => strval($myrow['id']), 'VIEWS' => integer_format($myrow['iotd_views']), 'THUMB' => $thumb, 'DATE' => $date, 'DATE_RAW' => strval($myrow['date_and_time']), 'URL' => $url, 'CAPTION' => $caption)));
     }
     if ($content->is_empty()) {
         inform_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $page_num = intval(floor(floatval($start) / floatval($max))) + 1;
     $num_pages = intval(ceil(floatval($max_rows) / floatval($max)));
     $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max == 0 ? NULL : $start - $max), '_SELF');
     $next_url = count($rows) != $max ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF');
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => 'b6933ab44e16fef7e1bec62014254383', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     return do_template('NEXT_BROWSER_SCREEN', array('_GUID' => 'd8a493c2b007d98074f104ea433c8091', 'TITLE' => $title, 'CONTENT' => $content, 'BROWSE' => $browse));
 }
Пример #17
0
 /**
  * The UI to show a catalogue category.
  *
  * @return tempcode		The UI
  */
 function view_catalogue_category()
 {
     require_code('feedback');
     require_code('images');
     $id = get_param_integer('id', -1);
     if ($id == -1) {
         $id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => get_param('catalogue_name'), 'cc_parent_id' => NULL));
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($id);
     $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $categories)) {
         return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $category = $categories[0];
     // Permission for here?
     if (!has_category_access(get_member(), 'catalogues_catalogue', $category['c_name'])) {
         access_denied('CATALOGUE_ACCESS');
     }
     if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $catalogue_name = $category['c_name'];
     $root = get_param_integer('root', NULL);
     $_title = get_translated_text($category['cc_title']);
     $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
     if (!array_key_exists(0, $catalogues)) {
         warn_exit(do_lang_tempcode('CATALOGUE_NOT_FOUND', $catalogue_name));
     }
     $catalogue = $catalogues[0];
     $tpl_set = $catalogue_name;
     if (is_ecommerce_catalogue($catalogue_name)) {
         $is_ecommerce = true;
         $tpl_set = 'products';
     } else {
         $is_ecommerce = false;
     }
     $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_CATEGORY', escape_html($_title));
     $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_CATEGORY', $_title, NULL, NULL, NULL, false);
     if (is_null($title_to_use_2)) {
         $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_CATEGORY', escape_html($_title));
         $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_CATEGORY', $_title);
     }
     $awards = array();
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = array_merge($awards, find_awards_for('catalogue', $catalogue_name));
         $awards = array_merge($awards, find_awards_for('catalogue_category', strval($id)));
     }
     $title = get_page_title($title_to_use, false, NULL, NULL, $awards);
     if (is_object($title_to_use_2)) {
         $title_to_use_2 = $title_to_use_2->evaluate();
     }
     seo_meta_load_for('catalogue_category', strval($id), $title_to_use_2);
     $max = get_param_integer('max', 30);
     $start = get_param_integer('start', 0);
     list($entry_buildup, $sorting, $entries, $max_rows) = get_catalogue_category_entry_buildup($id, $catalogue_name, $catalogue, 'CATEGORY', $tpl_set, $max, $start, NULL, $root);
     // Build up subcategories
     $rows_subcategories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('cc_parent_id' => $id), '', 600);
     if (count($rows_subcategories) == 300) {
         $rows_subcategories = array();
     }
     // Performance issue, manual browsing will be needed
     foreach ($rows_subcategories as $i => $subcategory) {
         $rows_subcategories[$i]['cc_title'] = get_translated_text($subcategory['cc_title']);
     }
     for ($i = 0; $i < count($rows_subcategories); $i++) {
         for ($j = $i + 1; $j < count($rows_subcategories); $j++) {
             if ($rows_subcategories[$i]['cc_title'] > $rows_subcategories[$j]['cc_title']) {
                 $temp = $rows_subcategories[$j];
                 $rows_subcategories[$j] = $rows_subcategories[$i];
                 $rows_subcategories[$i] = $temp;
             }
         }
     }
     $subcategories = new ocp_tempcode();
     $uses_rep_image = false;
     foreach ($rows_subcategories as $sc) {
         if ($sc['rep_image'] != '') {
             $uses_rep_image = true;
         }
     }
     foreach ($rows_subcategories as $sc) {
         if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($sc['id']))) {
             continue;
         }
         $child_counts = count_catalogue_category_children($sc['id']);
         $num_children = $child_counts['num_children'];
         $num_entries = $child_counts['num_entries_children'];
         $map = array('page' => '_SELF', 'id' => $sc['id'], 'type' => 'category');
         if (!is_null($root)) {
             $map['root'] = $root;
         }
         $url = build_url($map, '_SELF');
         if ($uses_rep_image || $is_ecommerce) {
             $display_string = do_lang_tempcode($catalogue['c_is_tree'] == 1 ? 'CATEGORY_SUBORDINATE' : 'CATEGORY_SUBORDINATE_2', integer_format($num_entries), integer_format($num_children));
             if ($sc['rep_image']) {
                 $rep_image = do_image_thumb($sc['rep_image'], $sc['cc_title'], $sc['cc_title'], false);
             } else {
                 $rep_image = new ocp_tempcode();
             }
             $description = $sc['cc_description'];
             $description = get_translated_tempcode($description);
             $ajax_edit_url = '_SEARCH:cms_catalogues:type=__edit_category:id=' . strval($sc['id']);
             $subcategories->attach(do_template('CATEGORY_' . $tpl_set . '_ENTRY', array('_GUID' => '871f5f5195fcb426fac716e35569d6a3', 'ID' => strval($sc['id']), 'NAME_FIELD' => 'title', 'AJAX_EDIT_URL' => $ajax_edit_url, 'URL' => $url, 'REP_IMAGE' => $rep_image, 'CHILDREN' => $display_string, 'NAME' => $sc['cc_title'], 'NAME_PLAIN' => $sc['cc_title'], 'DESCRIPTION' => $description, 'NUM_CHILDREN' => integer_format($num_children), 'NUM_CHILDREN_RECURSIVE' => integer_format($child_counts['num_children_children']), 'NUM_ENTRIES' => integer_format($num_entries), 'NUM_ENTRIES_DIRECT' => integer_format($child_counts['num_entries'])), NULL, false, 'CATEGORY_ENTRY'));
         } else {
             $subcategories->attach(do_template('CATALOGUE_' . $tpl_set . '_SUBCATEGORY', array('ID' => strval($sc['id']), 'CATALOGUE' => $catalogue_name, 'URL' => $url, 'NUM_CHILDREN' => integer_format($num_children), 'NUM_CHILDREN_RECURSIVE' => integer_format($child_counts['num_children_children']), 'NUM_ENTRIES' => integer_format($num_entries), 'NUM_ENTRIES_DIRECT' => integer_format($child_counts['num_entries']), 'NAME' => $sc['cc_title']), NULL, false, 'CATALOGUE_DEFAULT_SUBCATEGORY'));
         }
     }
     if (!$subcategories->is_empty()) {
         if ($uses_rep_image) {
             $subcategories = do_template('CATEGORY_LIST', array('_GUID' => '3041620a953e52229f752b1bccfbeee3', 'CONTENT' => $subcategories));
         } else {
             $subcategories = do_template('CATALOGUE_' . $tpl_set . '_SUBCATEGORY_WRAP', array('CATALOGUE' => $catalogue_name, 'CONTENT' => $subcategories), NULL, false, 'CATALOGUE_DEFAULT_SUBCATEGORY_WRAP');
         }
     }
     // Links to add to catalogue category etc
     if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name, 'catalogues_category', strval($id)), 'submit_midrange_content')) {
         $add_link = build_url(array('page' => 'cms_catalogues', 'type' => 'add_entry', 'catalogue_name' => $catalogue_name, 'category_id' => $id), get_module_zone('cms_catalogues'));
     } else {
         $add_link = new ocp_tempcode();
     }
     if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name, 'catalogues_category', strval($id)), 'submit_cat_midrange_content')) {
         $add_cat_url = build_url(array('page' => 'cms_catalogues', 'type' => 'add_category', 'catalogue_name' => $catalogue_name, 'parent_id' => $id), get_module_zone('cms_catalogues'));
     } else {
         $add_cat_url = new ocp_tempcode();
     }
     if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name, 'catalogues_category', strval($id)), 'edit_cat_midrange_content')) {
         $edit_cat_url = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_category', 'catalogue_name' => $catalogue_name, 'id' => $id), get_module_zone('cms_catalogues'));
     } else {
         $edit_cat_url = new ocp_tempcode();
     }
     if (has_actual_page_access(NULL, 'cms_catalogues', NULL, get_value('disable_cat_cat_perms') === '1' ? array('catalogues_catalogue', $catalogue_name) : array('catalogues_catalogue', $catalogue_name), 'edit_cat_highrange_content')) {
         $edit_catalogue_url = build_url(array('page' => 'cms_catalogues', 'type' => '_edit_catalogue', 'id' => $catalogue_name), get_module_zone('cms_catalogues'));
     } else {
         $edit_catalogue_url = new ocp_tempcode();
     }
     require_code('templates_results_browser');
     $browser = results_browser(do_lang_tempcode('ENTRIES'), $id, $start, 'start', $max, 'max', $max_rows, $root, 'category', true);
     if ($catalogue['c_is_tree'] == 1) {
         $tree = catalogue_category_breadcrumbs($id, $root);
         if (!$tree->is_empty()) {
             $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         }
         if (has_specific_permission(get_member(), 'open_virtual_roots')) {
             $url = get_self_url(false, false, is_null(get_param('root', NULL)) ? array('root' => $id) : array('root' => $id == -1 ? NULL : $id));
             $tree->attach(hyperlink($url, escape_html($_title), false, false, do_lang_tempcode('VIRTUAL_ROOT')));
         } else {
             $tree->attach('<span>' . escape_html($_title) . '</span>');
         }
     } else {
         $tree = new ocp_tempcode();
         $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF');
         $catalogue_title = get_translated_text($catalogue['c_title']);
         $tree->attach(hyperlink($url, escape_html($catalogue_title), false, false, do_lang_tempcode('GO_BACKWARDS_TO', escape_html($catalogue_name))));
         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         $tree->attach(escape_html($_title));
     }
     breadcrumb_add_segment($tree);
     if (is_null($root)) {
         breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($is_ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES'))));
     }
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $category['cc_add_date']), 'creator' => '', 'publisher' => '', 'modified' => '', 'type' => get_translated_text($catalogue['c_title']) . ' category', 'title' => $_title, 'identifier' => '_SEARCH:catalogues:category:' . strval($id), 'description' => get_translated_text($category['cc_description']));
     $rep_image_str = $category['rep_image'];
     if ($rep_image_str != '') {
         $GLOBALS['META_DATA'] += array('image' => (url_is_local($rep_image_str) ? get_custom_base_url() . '/' : '') . $rep_image_str);
     }
     $cart_link = new ocp_tempcode();
     if ($is_ecommerce) {
         if (get_forum_type() != 'ocf') {
             warn_exit(do_lang_tempcode('NO_OCF'));
         }
         require_code('shopping');
         require_lang('shopping');
         $cart_link = show_cart_image();
     }
     return do_template('CATALOGUE_' . $tpl_set . '_CATEGORY_SCREEN', array('ID' => strval($id), 'ADD_DATE_RAW' => strval($category['cc_add_date']), 'TITLE' => $title, '_TITLE' => $_title, 'TAGS' => get_loaded_tags('catalogue_categories'), 'CATALOGUE' => $catalogue_name, 'BROWSER' => $browser, 'SORTING' => $sorting, 'ADD_LINK' => $add_link, 'ADD_CAT_URL' => $add_cat_url, 'EDIT_CAT_URL' => $edit_cat_url, 'EDIT_CATALOGUE_URL' => $edit_catalogue_url, 'ENTRIES' => $entry_buildup, 'SUBCATEGORIES' => $subcategories, 'DESCRIPTION' => get_translated_tempcode($category['cc_description']), 'CART_LINK' => $cart_link, 'TREE' => $tree), NULL, false, 'CATALOGUE_DEFAULT_CATEGORY_SCREEN');
 }