Beispiel #1
0
    $anchor = Anchors::get($_REQUEST['anchor']);
} elseif (isset($context['arguments'][1])) {
    $anchor = Anchors::get($context['arguments'][0] . ':' . $context['arguments'][1]);
}
// reflect access rights from anchor
if (!isset($item['active']) && is_object($anchor)) {
    $item['active'] = $anchor->get_active();
}
// get the related overlay, if any -- overlay_type will be considered later on
$overlay = NULL;
if (isset($item['overlay']) && $item['overlay']) {
    $overlay = Overlay::load($item, 'file:' . $item['id']);
} elseif (isset($_REQUEST['variant']) && $_REQUEST['variant']) {
    $overlay = Overlay::bind($_REQUEST['variant']);
} elseif (isset($_SESSION['pasted_variant']) && $_SESSION['pasted_variant']) {
    $overlay = Overlay::bind($_SESSION['pasted_variant']);
    unset($_SESSION['pasted_variant']);
    // set a new overlay instance, except if some template has been defined for this anchor
} elseif (!isset($item['id']) && is_object($anchor)) {
    $overlay = $anchor->get_overlay('file_overlay');
}
// get parent of the anchor too
$parent = NULL;
if (is_object($anchor) && ($parent = $anchor->get_parent())) {
    $parent = Anchors::get($parent);
}
// we are allowed to add a new file
if (!isset($item['id']) && is_object($anchor) && Files::allow_creation($anchor->get_values(), $parent, $anchor->get_type())) {
    $permitted = TRUE;
} elseif (isset($item['id']) && Files::allow_modification($item, $anchor)) {
    $permitted = TRUE;
Beispiel #2
0
 /**
  * get the default overlay type for anchored items, if any
  *
  * This function is mainly used to associate overlays with sections.
  *
  * @param string name of the attribute that contains overlay class
  * @return a string
  */
 function get_overlay($name = 'content_overlay')
 {
     $overlay = NULL;
     if ($this->item && isset($this->item[$name])) {
         $overlay = Overlay::bind($this->item[$name]);
     }
     return $overlay;
 }
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // maximum number of items
     if (isset($this->layout_variant) && $this->layout_variant > 3) {
         $maximum_items = $this->layout_variant;
     } elseif (defined('YAHOO_LIST_SIZE')) {
         $maximum_items = YAHOO_LIST_SIZE;
     } else {
         $maximum_items = 7;
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // process all items in the list
     $family = '';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             $text .= '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n";
         }
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = $icon = $hover = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag sections that are draft, dead, or created or updated very recently
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // display introduction field on hovering
         if ($item['introduction']) {
             $hover .= strip_tags(Codes::beautify_introduction($item['introduction']));
         }
         // details and content
         $details = array();
         $content = array();
         // count related sub-elements
         $related_count = 0;
         // info on related articles
         if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
             if ($count > $maximum_items) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             } elseif (Surfer::is_empowered()) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             }
             $related_count += $count;
             // get the overlay for content of this section, if any
             $content_overlay = NULL;
             if (isset($item['content_overlay'])) {
                 $content_overlay = Overlay::bind($item['content_overlay']);
             }
             // no room to list articles
             if (count($content) >= $maximum_items) {
             } elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) {
                 if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) {
                     foreach ($related as $sub_url => $label) {
                         $sub_prefix = $sub_suffix = $sub_hover = '';
                         if (is_array($label)) {
                             $sub_prefix = $label[0];
                             $sub_suffix = $label[2];
                             if (@$label[5]) {
                                 $sub_hover = $label[5];
                             }
                             $label = $label[1];
                         }
                         $content[] = $sub_prefix . $label . $sub_suffix;
                     }
                 }
                 // regular rendering of related articles
             } else {
                 if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                     $order = $matches[1];
                 } else {
                     $order = 'edition';
                 }
                 if ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) {
                     foreach ($related as $sub_url => $label) {
                         $sub_prefix = $sub_suffix = $sub_hover = '';
                         if (is_array($label)) {
                             $sub_prefix = $label[0];
                             $sub_suffix = $label[2];
                             if (@$label[5]) {
                                 $sub_hover = $label[5];
                             }
                             $label = $label[1];
                         }
                         $content[] = $sub_prefix . $label . $sub_suffix;
                     }
                 }
             }
         }
         // info on related files
         if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
             // add related files if necessary
             if (count($content) < $maximum_items && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
                 foreach ($related as $sub_url => $label) {
                     $sub_prefix = $sub_suffix = $sub_hover = '';
                     if (is_array($label)) {
                         $sub_prefix = $label[0];
                         $sub_suffix = $label[2];
                         if (@$label[5]) {
                             $sub_hover = $label[5];
                         }
                         $label = $label[1];
                     }
                     $content[] = $sub_prefix . $label . $sub_suffix;
                 }
             }
         }
         // info on related links
         if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             $related_count += $count;
             // add related links if necessary
             if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
                 foreach ($related as $sub_url => $label) {
                     $sub_prefix = $sub_suffix = $sub_hover = '';
                     if (is_array($label)) {
                         $sub_prefix = $label[0];
                         $sub_suffix = $label[2];
                         if (@$label[5]) {
                             $sub_hover = $label[5];
                         }
                         $label = $label[1];
                     }
                     $content[] = $sub_prefix . $label . $sub_suffix;
                 }
             }
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             $related_count += $count;
         }
         // info on related sections
         if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
             if ($count > $maximum_items) {
                 $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             } elseif (Surfer::is_empowered()) {
                 $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             }
             $related_count += $count;
             // add sub-sections
             if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) {
                 foreach ($related as $sub_url => $label) {
                     $sub_prefix = $sub_suffix = $sub_hover = '';
                     if (is_array($label)) {
                         $sub_prefix = $label[0];
                         $sub_suffix = $label[2];
                         if (@$label[5]) {
                             $sub_hover = $label[5];
                         }
                         $label = $label[1];
                     }
                     $content[] = $sub_prefix . $label . $sub_suffix;
                 }
             }
         }
         // give me more
         if (count($content) && $related_count > $maximum_items) {
             $content[] = '...' . MORE_IMG;
         }
         // layout details
         if (count($content)) {
             $hover .= '<ul><li>' . implode('</li><li>', $content) . '</li></ul>';
         }
         // add a link to the main page
         if (!$hover) {
             $hover = i18n::s('View the section');
         }
         // use the title to label the link
         $title = Skin::strip($item['title'], 50);
         // new or updated flag
         if ($suffix) {
             $details[] = $suffix;
         }
         // append details
         if (count($details)) {
             $title .= BR . '<span class="details">' . implode(', ', $details) . '</span>';
         }
         // look for an image
         $icon = '';
         if (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // use the thumbnail for this section
         if ($icon) {
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
                 $icon = $context['url_to_root'] . $icon;
             }
             // use parameter of the control panel for this one
             $options = '';
             if (isset($context['classes_for_thumbnail_images'])) {
                 $options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="" ' . $options . ' />';
             // use default icon if nothing to display
         } else {
             $icon = MAP_IMG;
         }
         // use tipsy on hover
         $content = '<a href="' . $url . '" id="titles_' . $item['id'] . '">' . $icon . BR . $prefix . $title . '</a>';
         Page::insert_script('$(function() {' . "\n" . '	$("a#titles_' . $item['id'] . '").each(function() {' . "\n" . '		$(this).tipsy({fallback: \'<div style="text-align: left;">' . str_replace(array("'", "\n"), array('"', '<br />'), $hover) . '</div>\',' . "\n" . '		 html: true,' . "\n" . '		 gravity: $.fn.tipsy.autoWE,' . "\n" . '		 fade: true,' . "\n" . '		 offset: 8,' . "\n" . '		 opacity: 1.0});' . "\n" . '	});' . "\n" . '});' . "\n");
         // add a floating box
         $text .= Skin::build_box(NULL, $content, 'floating');
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // end of processing
     SQL::free($result);
     return $text;
 }
Beispiel #4
0
         $text .= sprintf(i18n::s('A section "%s" has been created.'), $fields['nick_name']) . BR . "\n";
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // 'bugzilla_page' article
 if (Articles::get('bugzilla_page')) {
     $text .= sprintf(i18n::s('A page "%s" already exists.'), 'bugzilla_page') . BR . "\n";
 } elseif ($anchor = Sections::lookup('bugzilla')) {
     $fields = array();
     $fields['anchor'] = $anchor;
     $fields['nick_name'] = 'bugzilla_page';
     $fields['title'] = i18n::c('I need help');
     $fields['introduction'] = i18n::c('Sample support request');
     $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
     $overlay = Overlay::bind('issue');
     $fields['overlay'] = $overlay->save();
     $fields['overlay_id'] = $overlay->get_id();
     if (Articles::post($fields)) {
         $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['nick_name']) . BR . "\n";
         $overlay->remember('insert', $fields, 'article:' . $fields['id']);
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // add sample comments to 'bugzilla_page'
 if ($anchor = Articles::lookup('bugzilla_page')) {
     // add a bunch of comments
     $stats = Comments::stat_for_anchor($anchor);
     if ($stats['count'] < 50) {
         for ($index = 1; $index <= 10; $index++) {
Beispiel #5
0
 /**
  * restore an instance
  *
  * This function unserializes piggy-back data and uses it to populate an overlay instance.
  *
  * [php]
  * // get the record from the database
  * $item = Articles::get($id);
  *
  * // extract overlay data from $item['overlay']
  * $overlay = Overlay::load($item, 'article:'.$item['id']);
  * [/php]
  *
  * @see articles/delete.php
  * @see articles/edit.php
  * @see articles/view.php
  *
  * @param array the hosting array
  * @param string reference of the containing page (e.g., 'article:123')
  * @return a restored instance, or NULL
  */
 public static final function load($host, $reference = '')
 {
     global $context;
     if (is_object($host)) {
         $data = $host->item;
     } else {
         $data = $host;
     }
     // no overlay yet
     if (!isset($data['overlay']) || !$data['overlay']) {
         return NULL;
     }
     // retrieve the content of the overlay
     if (($attributes = Safe::unserialize($data['overlay'])) === FALSE) {
         return NULL;
     }
     // restore unicode entities
     foreach ($attributes as $name => $value) {
         if (is_string($value)) {
             $attributes[$name] = utf8::from_unicode($value);
         }
     }
     // we need a type
     if (!is_array($attributes) || !isset($attributes['overlay_type'])) {
         return NULL;
     }
     // bind this to current page
     if (isset($data['id'])) {
         $attributes['id'] = $data['id'];
     }
     // use one particular overlay instance
     $overlay = Overlay::bind($attributes['overlay_type']);
     if (is_object($overlay)) {
         $overlay->attributes = $attributes;
         // expose all of the anchor interface to the contained overlay
         if (!is_object($host)) {
             $overlay->anchor = Anchors::get($reference);
         } else {
             $overlay->anchor = $host;
         }
         // ready to use!
         return $overlay;
     }
     // unknown overlay type or empty overlay
     return NULL;
 }
Beispiel #6
0
     $embedded = NULL;
 } else {
     $embedded = Codes::list_embedded($item['description']);
 }
 // build a complete box
 $box = array('bar' => array(), 'text' => '');
 // count the number of files in this section
 //if($count = Files::count_for_anchor('section:'.$item['id'], FALSE, $embedded)) {
 $count = Files::count_for_anchor('section:' . $item['id'], FALSE, $embedded);
 if ($count > 20) {
     $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
 }
 // get overlay for files if any
 $file_overlay = NULL;
 if (isset($item['file_overlay'])) {
     $file_overlay = Overlay::bind($item['file_overlay']);
 }
 // delegate rendering to the overlay, where applicable
 if (is_object($file_overlay) && ($overlaid = $file_overlay->render('files', 'section:' . $item['id'], $zoom_index))) {
     $box['text'] .= $overlaid;
 } elseif ($count) {
     // list files by date (default) or by title (option 'files_by_title')
     $offset = ($zoom_index - 1) * FILES_PER_PAGE;
     if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
         $items = Files::list_by_title_for_anchor('section:' . $item['id'], $offset, FILES_PER_PAGE, 'section:' . $item['id'], $embedded);
     } else {
         $items = Files::list_by_date_for_anchor('section:' . $item['id'], $offset, FILES_PER_PAGE, 'section:' . $item['id'], $embedded);
     }
     // actually render the html
     if (is_array($items)) {
         $box['text'] .= Skin::build_list($items, 'decorated');
Beispiel #7
0
 /**
  * list sections
  *
  * @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 some text
     $text = '';
     // maximum number of items
     if (isset($this->layout_variant) && $this->layout_variant > 3) {
         $maximum_items = $this->layout_variant;
     } elseif (defined('YAHOO_LIST_SIZE')) {
         $maximum_items = YAHOO_LIST_SIZE;
     } else {
         $maximum_items = 7;
     }
     // stack of items
     $items = array();
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $family = '';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             // flush current stack, if any
             if (count($items)) {
                 $text .= Skin::build_list($items, '2-columns');
             }
             $items = array();
             // show the family
             $family = $item['family'];
             $text .= '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n";
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag sections that are draft, dead, or created or updated very recently
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // details and content
         $details = array();
         $content = array();
         // count related sub-elements
         $related_count = 0;
         // info on related articles
         if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
             if ($count > $maximum_items) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             } elseif (Surfer::is_empowered()) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             }
             $related_count += $count;
             // get the overlay for content of this section, if any
             $content_overlay = NULL;
             if (isset($item['content_overlay'])) {
                 $content_overlay = Overlay::bind($item['content_overlay']);
             }
             // no room to list articles
             if (count($content) >= $maximum_items) {
             } elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) {
                 if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) {
                     foreach ($related as $sub_url => $label) {
                         $sub_prefix = $sub_suffix = $sub_hover = '';
                         if (is_array($label)) {
                             $sub_prefix = $label[0];
                             $sub_suffix = $label[2];
                             if (@$label[5]) {
                                 $sub_hover = $label[5];
                             }
                             $label = $label[1];
                         }
                         $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
                     }
                 }
                 // regular rendering of related articles
             } else {
                 if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                     $order = $matches[1];
                 } else {
                     $order = 'edition';
                 }
                 if ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) {
                     foreach ($related as $sub_url => $label) {
                         $sub_prefix = $sub_suffix = $sub_hover = '';
                         if (is_array($label)) {
                             $sub_prefix = $label[0];
                             $sub_suffix = $label[2];
                             if (@$label[5]) {
                                 $sub_hover = $label[5];
                             }
                             $label = $label[1];
                         }
                         $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'article', $sub_hover) . $sub_suffix;
                     }
                 }
             }
         }
         // info on related files
         if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
             // add related files if necessary
             if (count($content) < $maximum_items && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
                 foreach ($related as $sub_url => $label) {
                     $sub_prefix = $sub_suffix = $sub_hover = '';
                     if (is_array($label)) {
                         $sub_prefix = $label[0];
                         $sub_suffix = $label[2];
                         if (@$label[5]) {
                             $sub_hover = $label[5];
                         }
                         $label = $label[1];
                     }
                     $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'file', $sub_hover) . $sub_suffix;
                 }
             }
         }
         // info on related links
         if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             $related_count += $count;
             // add related links if necessary
             if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
                 foreach ($related as $sub_url => $label) {
                     $sub_prefix = $sub_suffix = $sub_hover = '';
                     if (is_array($label)) {
                         $sub_prefix = $label[0];
                         $sub_suffix = $label[2];
                         if (@$label[5]) {
                             $sub_hover = $label[5];
                         }
                         $label = $label[1];
                     }
                     $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'link', $sub_hover) . $sub_suffix;
                 }
             }
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             $related_count += $count;
         }
         // info on related sections
         if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
             if ($count > $maximum_items) {
                 $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             } elseif (Surfer::is_empowered()) {
                 $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             }
             $related_count += $count;
             // add sub-sections
             if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, $maximum_items, 'compact')) {
                 foreach ($related as $sub_url => $label) {
                     $sub_prefix = $sub_suffix = $sub_hover = '';
                     if (is_array($label)) {
                         $sub_prefix = $label[0];
                         $sub_suffix = $label[2];
                         if (@$label[5]) {
                             $sub_hover = $label[5];
                         }
                         $label = $label[1];
                     }
                     $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'section', $sub_hover) . $sub_suffix;
                 }
             }
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify_introduction($item['introduction']);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // give me more
         if (count($content) && $related_count > $maximum_items) {
             $content[] = Skin::build_link(Sections::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the section'));
         }
         // layout details
         if (count($content)) {
             foreach ($content as $line) {
                 $suffix .= '<div>' . YAHOO_ITEM_PREFIX . $line . YAHOO_ITEM_SUFFIX . '</div>';
             }
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 50);
         // put the actual icon in the left column
         if (isset($item['thumbnail_url'])) {
             $icon = $item['thumbnail_url'];
         }
         // some hovering title for this section
         $hover = i18n::s('View the section');
         // list all components for this item --use basic link style to avoid prefix or suffix images, if any
         $items[$url] = array($prefix, $label, $suffix, 'basic', $icon, $hover);
     }
     // flush the stack
     if (count($items)) {
         $text .= Skin::build_list($items, '2-columns');
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Beispiel #8
0
 if (isset($_REQUEST['overlay_type']) && $_REQUEST['overlay_type']) {
     // associates are allowed to change overlay types -- see overlays/select.php
     if (!Surfer::is_associate()) {
         unset($_REQUEST['overlay_type']);
     } elseif (is_object($overlay) && $overlay->get_type() == $_REQUEST['overlay_type']) {
         unset($_REQUEST['overlay_type']);
     }
 }
 // new overlay type
 if (isset($_REQUEST['overlay_type']) && $_REQUEST['overlay_type']) {
     // delete the previous version, if any
     if (is_object($overlay)) {
         $overlay->remember('delete', $_REQUEST, 'section:' . $_REQUEST['id']);
     }
     // new version of page overlay
     $overlay = Overlay::bind($_REQUEST['overlay_type']);
 }
 // when the page has been overlaid
 if (is_object($overlay)) {
     // allow for change detection
     $overlay->snapshot();
     // update the overlay from form content
     $overlay->parse_fields($_REQUEST);
     // save content of the overlay in this item
     $_REQUEST['overlay'] = $overlay->save();
     $_REQUEST['overlay_id'] = $overlay->get_id();
 }
 // branch to another script to save data
 if (isset($_REQUEST['options']) && preg_match('/\\bedit_as_[a-zA-Z0-9_\\.]+?\\b/i', $_REQUEST['options'], $matches) && is_readable($matches[0] . '.php')) {
     include $matches[0] . '.php';
     return;
Beispiel #9
0
 if (!Surfer::is_associate() && ($overlay->attributes['user_status'] == 'donotdisturb' || $overlay->attributes['user_status'] == 'anonymous' || $item['without_alerts'] == 'Y')) {
     $context['text'] .= sprintf(i18n::s('Sorry, %s wish not to receive private message'), $item['nick_name']);
     render_skin();
     finalize_page(TRUE);
 }
 // the new thread
 $article = array();
 $article['anchor'] = $anchor;
 $article['title'] = isset($_REQUEST['title']) ? $_REQUEST['title'] : utf8::transcode(Skin::build_date(gmstrftime('%Y-%m-%d %H:%M:%S GMT'), 'full'));
 $article['active_set'] = 'N';
 // this is private
 $article['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
 // no review is required
 $article['options'] = 'view_as_zic_pm';
 // include some overlay
 $overlay = Overlay::bind('thread');
 $article['overlay'] = $overlay->save();
 $article['overlay_id'] = $overlay->get_id();
 // ensure everything is positioned as expected
 Surfer::empower();
 // post the new thread
 if (!($article['id'] = Articles::post($article))) {
     Logger::error(i18n::s('Impossible to add a page.'));
 } else {
     //get full article
     $article = Articles::get($article['id']);
     // attach some file
     if (isset($_FILES['upload']) && ($file = Files::upload($_FILES['upload'], 'files/article/' . $article['id'], 'article:' . $article['id']))) {
         $_REQUEST['message'] .= $file;
     }
     // make a new comment out of received message, if any
Beispiel #10
0
 function parse_tag_close($parser, $tag)
 {
     global $context;
     global $in_overlay, $overlay_class, $overlay_parameters;
     global $parsed_cdata, $parsed_item, $parsed_overlay, $parsing_report;
     // save gathered data if necessary
     switch ($tag) {
         case 'article':
             // end of article
             // transcode owner id
             $parsed_item['owner_id'] = Surfer::get_id();
             if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
                 $parsed_item['owner_id'] = $user['id'];
             }
             // transcode creator id
             $parsed_item['create_id'] = Surfer::get_id();
             if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
                 $parsed_item['create_id'] = $user['id'];
             }
             // transcode editor id
             $parsed_item['edit_id'] = Surfer::get_id();
             if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
                 $parsed_item['edit_id'] = $user['id'];
             }
             // transcode publisher id
             $parsed_item['publish_id'] = Surfer::get_id();
             if (isset($parsed_item['publish_nick_name']) && ($user = Users::get($parsed_item['publish_nick_name']))) {
                 $parsed_item['publish_id'] = $user['id'];
             }
             // bind to given overlay
             $overlay = NULL;
             if ($overlay_class) {
                 $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters);
             }
             // when the page has been overlaid
             if (is_object($overlay)) {
                 // update the overlay from content
                 foreach ($parsed_overlay as $label => $value) {
                     $overlay->attributes[$label] = $value;
                 }
                 // save content of the overlay in this item
                 $parsed_item['overlay'] = $overlay->save();
                 $parsed_item['overlay_id'] = $overlay->get_id();
             }
             // find anchor from handle
             if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) {
                 $parsed_item['anchor'] = $reference;
             }
             // update an existing page
             if (isset($parsed_item['handle']) && ($item = Articles::get($parsed_item['handle']))) {
                 // transcode page id
                 $parsed_item['id'] = $item['id'];
                 // stop on error
                 if (!Articles::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'article:' . $item['id'])) {
                     Logger::error(sprintf('Unable to save article %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')'));
                 }
                 // create a new page
             } else {
                 unset($parsed_item['id']);
                 // stop on error
                 if (!($parsed_item['id'] = Articles::post($parsed_item))) {
                     Logger::error(sprintf('Unable to save article %s', $parsed_item['title']));
                 } else {
                     // save overlay content
                     if (is_object($overlay)) {
                         $overlay->remember('insert', $parsed_item, 'article:' . $parsed_item['id']);
                     }
                 }
             }
             // report to surfer
             $parsing_report .= '<li>' . Skin::build_link(Articles::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n";
             // ready for next item
             $overlay_class = NULL;
             $overlay_parameters = '';
             $parsed_overlay = array();
             $parsed_item = array();
             Safe::set_time_limit(30);
             break;
         case 'overlay':
             // end of overlay data
             $in_overlay = FALSE;
             break;
         case 'section':
             // end of section
             // transcode owner id
             $parsed_item['owner_id'] = Surfer::get_id();
             if (isset($parsed_item['owner_nick_name']) && ($user = Users::get($parsed_item['owner_nick_name']))) {
                 $parsed_item['owner_id'] = $user['id'];
             }
             // transcode creator id
             $parsed_item['create_id'] = Surfer::get_id();
             if (isset($parsed_item['create_nick_name']) && ($user = Users::get($parsed_item['create_nick_name']))) {
                 $parsed_item['create_id'] = $user['id'];
             }
             // transcode editor id
             $parsed_item['edit_id'] = Surfer::get_id();
             if (isset($parsed_item['edit_nick_name']) && ($user = Users::get($parsed_item['edit_nick_name']))) {
                 $parsed_item['edit_id'] = $user['id'];
             }
             // bind to given overlay
             $overlay = NULL;
             if ($overlay_class) {
                 $overlay = Overlay::bind($overlay_class . ' ' . $overlay_parameters);
             }
             // when the page has been overlaid
             if (is_object($overlay)) {
                 // update the overlay from content
                 foreach ($parsed_overlay as $label => $value) {
                     $overlay->attributes[$label] = $value;
                 }
                 // save content of the overlay in this item
                 $parsed_item['overlay'] = $overlay->save();
                 $parsed_item['overlay_id'] = $overlay->get_id();
             }
             // find anchor from handle
             if (isset($parsed_item['anchor_handle']) && ($reference = Sections::lookup($parsed_item['anchor_handle']))) {
                 $parsed_item['anchor'] = $reference;
             }
             // update an existing section
             if (isset($parsed_item['handle']) && ($item = Sections::get($parsed_item['handle']))) {
                 // transcode section id
                 $parsed_item['id'] = $item['id'];
                 // stop on error
                 if (!Sections::put($parsed_item) || is_object($overlay) && !$overlay->remember('update', $parsed_item, 'section:' . $item['id'])) {
                     Logger::error(sprintf('Unable to save section %s', $parsed_item['title'] . ' (' . $parsed_item['id'] . ')'));
                 }
                 // create a new page
             } else {
                 unset($parsed_item['id']);
                 // stop on error
                 if (!($parsed_item['id'] = Sections::post($parsed_item))) {
                     Logger::error(sprintf('Unable to save section %s', $parsed_item['title']));
                 } else {
                     // save overlay content
                     if (is_object($overlay)) {
                         $overlay->remember('insert', $parsed_item, 'section:' . $parsed_item['id']);
                     }
                 }
             }
             // report to surfer
             $parsing_report .= '<li>' . Skin::build_link(Sections::get_permalink($parsed_item), $parsed_item['title']) . "</li>\n";
             // ready for next item
             $overlay_class = NULL;
             $overlay_parameters = '';
             $parsed_overlay = array();
             $parsed_item = array();
             Safe::set_time_limit(30);
             break;
         default:
             // just another attribute
             // decode cdata
             $parsed_cdata = trim(preg_replace(array('/&lt;/', '/&gt;/'), array('<', '>'), $parsed_cdata));
             // feeding the overlay or the item itself
             if ($in_overlay) {
                 $parsed_overlay[$tag] = $parsed_cdata;
             } else {
                 $parsed_item[$tag] = $parsed_cdata;
             }
             // ready for next attribute
             $parsed_cdata = '';
             break;
     }
 }
Beispiel #11
0
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database, if any
$item = Users::get($id);
// get the related overlay, if any
$overlay = NULL;
if (isset($item['overlay']) && $item['overlay']) {
    $overlay = Overlay::load($item, 'user:'******'id']);
} elseif (isset($context['users_overlay']) && $context['users_overlay']) {
    $overlay = Overlay::bind($context['users_overlay']);
}
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} elseif (isset($item['id']) && Surfer::is($item['id'])) {
    $permitted = TRUE;
} elseif (!isset($item['id']) && !Surfer::is_logged() && (!isset($context['users_without_registration']) || $context['users_without_registration'] != 'Y')) {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// show the edition form only if required to do so
$with_form = FALSE;
// load the skin
load_skin('users');
Beispiel #12
0
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the overlay for content of this section, if any
         $content_overlay = NULL;
         if (isset($item['content_overlay'])) {
             $content_overlay = Overlay::bind($item['content_overlay']);
         }
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // delegate rendering to the overlay, where applicable
         if (is_object($content_overlay) && ($overlaid = $content_overlay->render('articles', 'section:' . $item['id'], 1))) {
             $text .= $overlaid;
             // regular rendering
         } elseif (!isset($item['articles_layout']) || $item['articles_layout'] != 'none') {
             // select a layout
             if (!isset($item['articles_layout']) || !$item['articles_layout']) {
                 include_once '../articles/layout_articles.php';
                 $layout = new Layout_articles();
             } else {
                 $layout = Layouts::new_($item['articles_layout'], 'article');
             }
             // avoid links to this page
             if (is_object($layout) && is_callable(array($layout, 'set_variant'))) {
                 $layout->set_focus('section:' . $item['id']);
             }
             // the maximum number of articles per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = ARTICLES_PER_PAGE;
             }
             // sort and list articles
             $offset = 0;
             if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                 $order = $matches[1];
             } elseif (is_callable(array($layout, 'items_order'))) {
                 $order = $layout->items_order();
             } else {
                 $order = 'edition';
             }
             // create a box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to post a new page
             //if(Articles::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'article')) {
                 Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
                 $url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']);
                 if (is_object($content_overlay) && ($label = $content_overlay->get_label('new_command', 'articles'))) {
                 } else {
                     $label = ARTICLES_ADD_IMG . i18n::s('Add a page');
                 }
                 $box['top_bar'] += array($url => $label);
             }
             // list pages under preparation
             $this_section = new section();
             $this_section->load_by_content($item, $anchor);
             if ($this_section->is_assigned()) {
                 if ($order == 'publication' && ($items =& Articles::list_for_anchor_by('draft', 'section:' . $item['id'], 0, 20, 'compact'))) {
                     if (is_array($items)) {
                         $items = Skin::build_list($items, 'compact');
                     }
                     $box['top_bar'] += array('_draft' => Skin::build_sliding_box(i18n::s('Draft pages'), $items));
                 }
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // get pages
             $items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], $offset, $items_per_page, $layout);
             // items in the middle
             if (is_array($items) && isset($item['articles_layout']) && $item['articles_layout'] == 'compact') {
                 $box['text'] .= Skin::build_list($items, 'compact');
             } elseif (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // no navigation bar with alistapart
             if (!isset($item['articles_layout']) || $item['articles_layout'] != 'alistapart') {
                 // count the number of articles in this section
                 if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
                     if ($count > 20) {
                         $box['bottom_bar'] += array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count));
                     }
                     // navigation commands for articles
                     $home = Sections::get_permalink($item);
                     $prefix = Sections::get_url($item['id'], 'navigate', 'articles');
                     $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
                 }
             }
             // bottom menu
             if ($box['bottom_bar']) {
                 $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
             }
             // there is some box content
             if ($box['text']) {
                 $text .= $box['text'];
             }
         }
         // layout sub-sections
         if (!isset($item['sections_layout']) || $item['sections_layout'] != 'none') {
             // select a layout
             if (!isset($item['sections_layout']) || !$item['sections_layout']) {
                 include_once 'layout_sections.php';
                 $layout = new Layout_sections();
             } else {
                 $layout = Layouts::new_($item['sections_layout'], 'section');
             }
             // the maximum number of sections per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = SECTIONS_PER_PAGE;
             }
             // build a complete box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to add a new section
             //if(Sections::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'section')) {
                 Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
                 $box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section'));
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // list items by family then title
             $offset = 0 * $items_per_page;
             $items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
             // actually render the html for the section
             if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
                 $box['text'] .= Skin::build_list($items, 'compact');
             } elseif (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // count the number of subsections
             if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
                 if ($count > 20) {
                     $box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
                 }
                 // navigation commands for sections
                 $home = Sections::get_permalink($item);
                 $prefix = Sections::get_url($item['id'], 'navigate', 'sections');
                 $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
             }
             // bottom menu
             if ($box['bottom_bar']) {
                 $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
             }
             // there is some box content
             if ($box['text']) {
                 $text .= $box['text'];
             }
         }
         // ensure that the surfer can change content
         if (Sections::allow_modification($item, $anchor)) {
             // view or modify this section
             $menu = array();
             $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the sub-section'), 'span');
             if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) {
                 $label = i18n::s('Edit this sub-section');
             }
             $menu[] = Skin::build_link(Sections::get_url($item['id'], 'edit'), $label, 'span');
             $text .= Skin::finalize_list($menu, 'menu_bar');
         }
         // assemble the full panel
         $panels[] = array('stt' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'stc' . $item['id'], $text);
     }
     // format tabs
     if ($this->has_variant('as_array')) {
         $text = $panels;
     } else {
         $text = Skin::build_tabs($panels);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Beispiel #13
0
         $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']) . BR . "\n";
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // 'ustream_template' article
 if (!Articles::get('ustream_template') && ($anchor = Sections::lookup('templates'))) {
     $fields = array();
     $fields['anchor'] = $anchor;
     $fields['nick_name'] = 'ustream_template';
     $fields['title'] = i18n::c('USTREAM broadcast');
     $fields['introduction'] = i18n::c('Drive your audience to a USTREAM show. At the given date and time participants are invited to join the channel.');
     $fields['options'] = 'edit_as_thread';
     $fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
     $fields['thumbnail_url'] = $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/thumbnails/conference.gif';
     $overlay = Overlay::bind('ustream_meeting');
     $fields['overlay'] = $overlay->save();
     $fields['overlay_id'] = $overlay->get_id();
     if (Articles::post($fields)) {
         $text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['title']) . BR . "\n";
     } else {
         $text .= Logger::error_pop() . BR . "\n";
     }
 }
 // 'wiki_template' article
 if (!Articles::get('wiki_template') && ($anchor = Sections::lookup('templates'))) {
     $fields = array();
     $fields['anchor'] = $anchor;
     $fields['nick_name'] = 'wiki_template';
     $fields['title'] = i18n::c('Wiki page');
     $fields['introduction'] = i18n::c('Create an initial page and invite participants to follow-up. Modifications are saved, to allow for fall-back.');