Esempio n. 1
0
 /**
  * list locations
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the location
         $url = Locations::get_url($item['id']);
         // initialize variables
         $prefix = $suffix = '';
         // flag new locations
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // build a valid label
         if ($item['geo_place_name']) {
             $label = Skin::strip($item['geo_place_name'], 10);
         } else {
             $label = $item['latitude'] . ', ' . $item['longitude'];
         }
         // the distance, if any
         $distance = '';
         if ($item['distance']) {
             $distance = ' ' . round($item['distance'], -1) . ' km';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Esempio n. 2
0
File: view.php Progetto: rair/yacs
    }
    // page details
    if (is_array($details)) {
        $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
    }
    // insert anchor suffix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_suffix();
    }
    // back to the anchor page
    if (is_object($anchor) && $anchor->is_viewable()) {
        $menu = array(Skin::build_link($anchor->get_url(), i18n::s('Back to main page'), 'button'));
        $context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
    }
    //
    // populate the extra panel
    //
    // commands for associates and editors
    if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
        $context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'edit'), i18n::s('Edit'));
        $context['page_tools'][] = Skin::build_link(Locations::get_url($id, 'delete'), i18n::s('Delete'));
        // commands for the author
    } elseif (Surfer::is($item['edit_id'])) {
        $context['page_tools'][] = Skin::build_link(Locations::get_url($item['id'], 'edit'), i18n::s('Edit'));
    }
    // referrals, if any, in a sidebar
    //
    $context['components']['referrals'] =& Skin::build_referrals(Locations::get_url($item['id']));
}
// render the skin
render_skin();
Esempio n. 3
0
 /**
  * get next and previous items, if any
  *
  * @see shared/anchor.php
  *
  * @param string the item type (eg, 'image', 'file', etc.)
  * @param array the anchored item asking for neighbours
  * @return an array($previous_url, $previous_label, $next_url, $next_label, $option_url, $option_label), or NULL
  */
 function get_neighbours($type, $item)
 {
     global $context;
     // no item bound
     if (!isset($this->item['id'])) {
         return NULL;
     }
     // initialize components
     $previous_url = $previous_label = $next_url = $next_label = $option_url = $option_label = '';
     // previous and next comments
     if ($type == 'comment') {
         // load the adequate library
         include_once $context['path_to_root'] . 'comments/comments.php';
         $order = 'date';
         // get previous url
         if ($previous_url = Comments::get_previous_url($item, 'article:' . $this->item['id'], $order)) {
             $previous_label = i18n::s('Previous');
         }
         // get next url
         if ($next_url = Comments::get_next_url($item, 'article:' . $this->item['id'], $order)) {
             $next_label = i18n::s('Next');
         }
         // previous and next files
     } elseif ($type == 'file') {
         // select appropriate order
         if (preg_match('/\\bfiles_by_title\\b/', $this->item['options'])) {
             $order = 'title';
         } else {
             $order = 'date';
         }
         // get previous url
         if ($previous_url = Files::get_previous_url($item, 'article:' . $this->item['id'], $order)) {
             $previous_label = i18n::s('Previous');
         }
         // get next url
         if ($next_url = Files::get_next_url($item, 'article:' . $this->item['id'], $order)) {
             $next_label = i18n::s('Next');
         }
         // previous and next images
     } elseif ($type == 'image') {
         // load the adequate library
         include_once $context['path_to_root'] . 'images/images.php';
         // extract all images references from the introduction and from the description
         preg_match_all('/\\[image=(\\d+)/', $this->item['introduction'] . $this->item['description'], $matches);
         // locate the previous image, if any
         $previous = NULL;
         reset($matches[1]);
         $index = 0;
         while (list($key, $value) = each($matches[1])) {
             $index++;
             if ($item['id'] == $value) {
                 break;
             }
             $previous = $value;
         }
         // make a link to the previous image
         if ($previous) {
             $previous_url = Images::get_url($previous);
             $previous_label = i18n::s('Previous');
         }
         // locate the next image, if any
         if (!(list($key, $next) = each($matches[1]))) {
             $next = NULL;
         } else {
             $next_url = Images::get_url($next);
             $next_label = i18n::s('Next');
         }
         // add a label
         $option_label = sprintf(i18n::s('Image %d of %d'), $index, count($matches[1]));
         // previous and next location
     } elseif ($type == 'location') {
         // load the adequate library
         include_once $context['path_to_root'] . 'locations/locations.php';
         // extract all location references from the introduction and from the description
         preg_match_all('/\\[location=(\\d+)/', $this->item['introduction'] . $this->item['description'], $matches);
         // locate the previous location, if any
         $previous = NULL;
         reset($matches[1]);
         $index = 0;
         while (list($key, $value) = each($matches[1])) {
             $index++;
             if ($item['id'] == $value) {
                 break;
             }
             $previous = $value;
         }
         // make a link to the previous location
         if ($previous) {
             $previous_url = Locations::get_url($previous);
             $previous_label = i18n::s('Previous');
         }
         // locate the next location, if any
         if (!(list($key, $next) = each($matches[1]))) {
             $next = NULL;
         } else {
             $next_url = Locations::get_url($next);
             $next_label = i18n::s('Next');
         }
         // add a label
         $option_label = sprintf(i18n::s('Location %d of %d'), $index, count($matches[1]));
     }
     // return navigation info
     return array($previous_url, $previous_label, $next_url, $next_label, $option_url, $option_label);
 }
Esempio n. 4
0
 /**
  * list locations
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolocation
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Locations::get_url($item['id']);
         // build a valid label
         if ($item['geo_place_name']) {
             $label = Skin::strip($item['geo_place_name'], 10);
         } else {
             $label = $item['latitude'] . ', ' . $item['longitude'];
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Locations::get_url($item['id'], 'edit') => i18n::s('Edit'), Locations::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if (isset($this->layout_variant) && $this->layout_variant != 'no_author') {
             if ($item['edit_name']) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         } else {
             $details[] = Anchors::get_action_label($item['edit_action']);
         }
         // show an anchor location
         if (isset($this->layout_variant) && $this->layout_variant != 'no_anchor' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'location', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Esempio n. 5
0
File: check.php Progetto: rair/yacs
     return;
     // parse the whole list
 } else {
     // fetch one anchor and the linked member
     $errors_count = 0;
     while ($row = SQL::fetch($result)) {
         // animate user screen and take care of time
         $count++;
         if (!($count % 100)) {
             $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
             // ensure enough execution time
             Safe::set_time_limit(30);
         }
         // check that the anchor exists, if any
         if ($row['anchor'] && !Anchors::get($row['anchor'])) {
             $context['text'] .= sprintf(i18n::s('Orphan: %s'), 'location ' . Skin::build_link(Locations::get_url($row['id']), $row['id'] . ' ' . $row['geo_place_name'])) . BR . "\n";
             if (++$errors_count >= 5) {
                 $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n";
                 break;
             }
         } else {
             $errors_count = 0;
         }
     }
 }
 // ending message
 $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
 // display the execution time
 $time = round(get_micro_time() - $context['start_time'], 2);
 $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
 // forward to the index page
Esempio n. 6
0
File: edit.php Progetto: rair/yacs
        if (!Surfer::is_associate() && is_object($anchor)) {
            $label = sprintf(i18n::c('New location in %s'), strip_tags($anchor->get_title()));
            $link = $context['url_to_home'] . $context['url_to_root'] . Locations::get_url($_REQUEST['id']);
            $description = $_REQUEST['geo_place_name'] . "\n" . sprintf(i18n::c('at %s'), '<a href="' . $link . '">' . $link . '</a>');
            Logger::notify('locations/edit.php: ' . $label, $description);
        }
        // update of an existing location
    } else {
        // increment the post counter of the surfer
        Users::increment_posts(Surfer::get_id());
        // touch the related anchor
        $anchor->touch('location:update', $_REQUEST['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y');
        // clear cache
        Locations::clear($_REQUEST);
        // forward to the view page
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . Locations::get_url($_REQUEST['id']));
    }
    // display the form on GET
} else {
    $with_form = TRUE;
}
// display the form
if ($with_form) {
    // reference the anchor page
    if (is_object($anchor) && $anchor->is_viewable()) {
        $context['text'] .= '<p>' . sprintf(i18n::s('On page %s'), Skin::build_link($anchor->get_url(), $anchor->get_title())) . "</p>\n";
    }
    // the form to edit an location
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form" name="main_form"><div>';
    // form fields
    $fields = array();
Esempio n. 7
0
File: index.php Progetto: rair/yacs
    $context['text'] .= $text;
}
// the suffix hook for the index of members
if (is_callable(array('Hooks', 'include_scripts'))) {
    $context['text'] .= Hooks::include_scripts('users/index.php#suffix');
}
// page tools
if (Surfer::is_associate()) {
    $context['page_tools'][] = Skin::build_link('users/edit.php', i18n::s('Add a user'));
} elseif (Surfer::get_id()) {
    $context['page_tools'][] = Skin::build_link('users/view.php', i18n::s('My profile'));
} else {
    $context['page_tools'][] = Skin::build_link('users/edit.php', i18n::s('Register'));
}
if (isset($context['google_api_key']) && $context['google_api_key']) {
    $context['page_tools'][] = Skin::build_link(Locations::get_url('users', 'map_on_google'), i18n::s('Google map'));
}
$context['page_tools'][] = Skin::build_link('users/review.php', i18n::s('Review profiles'));
// side bar with the list of present users --don't cache, this will change on each request anyway
include_once $context['path_to_root'] . 'users/visits.php';
if ($items = Users::list_present(0, 200, 'compact')) {
    $context['components']['boxes'] = Skin::build_box(i18n::s('Present users'), $items, 'boxes');
}
// page extra content
$cache_id = 'users/index.php#extra';
if (!($text = Cache::get($cache_id))) {
    // side bar with the list of newest users
    if ($items = Users::list_by_date(0, COMPACT_LIST_SIZE, 'compact')) {
        $text .= Skin::build_box(i18n::s('Newest Members'), Skin::build_list($items, 'compact'), 'boxes');
    }
    // side boxes for related categories, if any