Example #1
0
 /**
  * render a chart
  *
  * @param string chart data, in JSON format
  * @param string chart parameters
  * @return string the rendered text
  **/
 public static function render_chart($data, $variant)
 {
     global $context;
     // split parameters
     $attributes = preg_split("/\\s*,\\s*/", $variant, 4);
     // set a default size
     if (!isset($attributes[0])) {
         $attributes[0] = 320;
     }
     if (!isset($attributes[1])) {
         $attributes[1] = 240;
     }
     // object attributes
     $width = $attributes[0];
     $height = $attributes[1];
     $flashvars = '';
     if (isset($attributes[2])) {
         $flashvars = $attributes[2];
     }
     // allow several charts to co-exist in the same page
     static $chart_index;
     if (!isset($chart_index)) {
         $chart_index = 1;
     } else {
         $chart_index++;
     }
     $url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/open-flash-chart.swf';
     $text = '<div id="open_flash_chart_' . $chart_index . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
     Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "opaque";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "open_flash_chart_' . $chart_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", {"get-data":"get_open_flash_chart_' . $chart_index . '"}, params);' . "\n" . "\n" . 'var chart_data_' . $chart_index . ' = ' . trim(str_replace(array('<br />', "\n"), ' ', $data)) . ';' . "\n" . "\n" . 'function get_open_flash_chart_' . $chart_index . '() {' . "\n" . '	return $.toJSON(chart_data_' . $chart_index . ');' . "\n" . '}' . "\n");
     return $text;
 }
Example #2
0
File: day.php Project: rair/yacs
 /**
  * get form fields to change the day
  *
  * @see overlays/overlay.php
  *
  * @param array hosting attributes
  * @return a list of ($label, $input, $hint)
  */
 function get_fields($host, $field_pos = NULL)
 {
     global $context;
     $options = '<input type="hidden" name="time_stamp" value="12:00" />' . '<input type="hidden" name="duration" value="1440" />';
     // default value is now
     if (!isset($this->attributes['date_stamp']) || $this->attributes['date_stamp'] <= NULL_DATE) {
         $this->attributes['date_stamp'] = gmstrftime('%Y-%m-%d %H:%M', time() + Surfer::get_gmt_offset() * 3600);
     } else {
         $this->attributes['date_stamp'] = Surfer::from_GMT($this->attributes['date_stamp']);
     }
     // split date from time
     list($date, $time) = explode(' ', $this->attributes['date_stamp']);
     // event time
     $label = i18n::s('Date');
     $input = Skin::build_input_time('date_stamp', $date, 'date') . $options;
     $hint = i18n::s('Use format YYYY-MM-DD');
     $fields[] = array($label, $input, $hint);
     // ensure that we do have a date
     Page::insert_script('func' . 'tion validateOnSubmit(container) {' . "\n" . "\n" . '	if(!Yacs.trim(container.date_stamp.value)) {' . "\n" . '		alert("' . i18n::s('Please provide a date.') . '");' . "\n" . '		container.date_stamp.focus();' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n\n" . '	return true;' . "\n" . '}' . "\n");
     return $fields;
 }
Example #3
0
File: jssor.php Project: rair/yacs
 /**
  * build the HTML structure for 1 jssor slider
  * 
  * @param array $slides of images & captions & thumbs
  * @param array $options to provide with this instance
  * @return string formated HTML
  */
 public static function Make($slides, $options = null)
 {
     $slider = '';
     // unique id for the slider
     static $slidenum;
     $slidenum = isset($slidenum) ? $slidenum + 1 : 1;
     // main div
     $slider .= '<div id="slider' . $slidenum . '_container" class="sor-container" >' . "\n";
     // loading screen, if required
     if (isset($option['loading_screen'])) {
         $slider .= '<!-- Loading Screen -->' . "\n" . '<div data-u="loading" class="sor-loading">' . "\n" . $option['loading_screen'] . "\n" . '</div>' . "\n";
     }
     // slider container
     $slider .= '<!-- Slides Container -->' . "\n" . '<div data-u="slides" class="sor-slides">' . "\n";
     // Parse $slides to make slides
     foreach ($slides as $slide) {
         // start slide
         $slider .= '<div>' . "n";
         // main image
         if (isset($slide['image_src'])) {
             $slider .= '<img data-u="image" src="' . $slide['image_src'] . '" />' . "\n";
         }
         // caption
         if (isset($slide['caption'])) {
             $slider .= '<div data-u="caption" data-t="caption-transition-name" class="sor-caption">' . "\n" . $slide['caption'] . "\n" . '</div>' . "\n";
         }
         // thumb
         // close slide
         $slider .= '</div>' . "n";
     }
     // end slider container
     $slider .= '</div>' . "\n";
     // end main div
     $slider .= '</div>' . "\n";
     // javascript initalization
     $js_options = isset($option['js']) ? $option['js'] : array('$AutoPlay' => 'true');
     $rootname = 'slider' . $slidenum . '_';
     Page::insert_script('$(document).ready(function ($) {' . "\n" . 'var ' . $rootname . 'options = ' . json_encode($js_options) . ";\n" . 'var ' . $rootname . 'jssor = new $JssorSlider$("' . $rootname . 'container", ' . $rootname . 'options );' . '});');
     return $slider;
 }
Example #4
0
 /** 
  * render a sound object with dewplayer
  * 
  * @global type $context
  * @param type $id
  * @return string 
  */
 public static function render_sound($id)
 {
     global $context;
     // maybe an alternate title has been provided
     $attributes = preg_split("/\\s*,\\s*/", $id, 2);
     $id = $attributes[0];
     $flashvars = '';
     if (isset($attributes[1])) {
         $flashvars = $attributes[1];
     }
     // get the file
     if (!($item = Files::get($id))) {
         $output = '[sound=' . $id . ']';
         return $output;
     }
     // where to get the file
     if (isset($item['file_href']) && $item['file_href']) {
         $url = $item['file_href'];
     } else {
         $url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
     }
     // several ways to play flash
     switch (strtolower(substr(strrchr($url, '.'), 1))) {
         // stream a sound file
         case 'mp3':
             // a flash player to stream a sound
             $dewplayer_url = $context['url_to_root'] . 'included/browser/dewplayer.swf';
             if ($flashvars) {
                 $flashvars = 'son=' . $url . '&' . $flashvars;
             } else {
                 $flashvars = 'son=' . $url;
             }
             $output = '<div id="sound_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
             Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $dewplayer_url . '", "sound_' . $item['id'] . '", "200", "20", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
             return $output;
             // link to file page
         // link to file page
         default:
             // link label
             $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
             // make a link to the target page
             $url = Files::get_download_url($item);
             // return a complete anchor
             $output =& Skin::build_link($url, $text, 'basic');
             return $output;
     }
 }
Example #5
0
// list available avatars, except on error
if (!count($context['error']) && isset($item['id'])) {
    // upload an image
    //
    if (Images::allow_creation($item, null, 'user')) {
        // the form to post an image
        $text = '<form method="post" action="' . $context['url_to_root'] . 'images/edit.php" id="main_form" enctype="multipart/form-data"><div>' . '<input type="hidden" name="anchor" value="user:'******'id'] . '" />' . '<input type="hidden" name="action" value="set_as_avatar" />';
        $fields = array();
        // the image
        $text .= '<input type="file" name="upload" id="upload" size="30" accesskey="i" title="' . encode_field(i18n::s('Press to select a local file')) . '" />';
        $text .= ' ' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
        $text .= BR . '<span class="details">' . i18n::s('Select a .png, .gif or .jpeg image.') . ' (&lt;&nbsp;' . Skin::build_number($image_maximum_size, i18n::s('bytes')) . ')</span>';
        // end of the form
        $text .= '</div></form>';
        // the script used for form handling at the browser
        Page::insert_script('$("#upload").focus();');
        $context['text'] .= Skin::build_content(NULL, i18n::s('Upload an image'), $text);
    }
    // use the library
    //
    // where images are
    $path = 'skins/_reference/avatars';
    // browse the path to list directories and files
    if ($dir = Safe::opendir($context['path_to_root'] . $path)) {
        $text = '';
        if (Surfer::may_upload()) {
            $text .= '<p>' . i18n::s('Click on one image below to make it your new picture.') . '</p>' . "\n";
        }
        // build the lists
        while (($image = Safe::readdir($dir)) !== FALSE) {
            // skip some files
Example #6
0
File: upload.php Project: rair/yacs
    // ask for something to process, except on error
} elseif (!count($context['error'])) {
    // the splash message
    $context['text'] .= '<p>' . i18n::s('This script allows you to install or update a theme for your YACS server.') . "</p>\n";
    // the form to post an file
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form" enctype="multipart/form-data"><div>';
    // upload an archive
    $context['text'] .= '<p>' . i18n::s('Select the archive file that you want to install remotely.') . '</p>';
    // the file
    $context['text'] .= '<input type="file" name="upload" id="focus" size="30" />' . ' (&lt;&nbsp;' . $context['file_maximum_size'] . i18n::s('bytes') . ')';
    // the submit button
    $context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
    // end of the form
    $context['text'] .= '</div></form>';
    // the script used for form handling at the browser
    Page::insert_script('$("#focus").focus();');
    // use an available archive
    $context['text'] .= '<p>' . i18n::s('Alternatively, this script is able to handle archives that have been put in the directory <code>inbox/skins</code>.') . '</p>';
    // find available skin archives
    $archives = array();
    if ($dir = Safe::opendir("../inbox/skins")) {
        // scan the file system
        while (($file = Safe::readdir($dir)) !== FALSE) {
            // skip special files
            if ($file[0] == '.' || $file[0] == '~') {
                continue;
            }
            // skip non-archive files
            if (!preg_match('/(\\.bz2|\\.tar|\\.tar.gz|\\.tgz|\\.zip)/i', $file)) {
                continue;
            }
Example #7
0
 /**
  * integrate content of a newsfeed
  *
  * @param string address of the newsfeed to get
  * @return string the rendered text
  **/
 public static function render_newsfeed($url, $variant = 'ajax')
 {
     global $context;
     // we allow multiple calls
     static $count;
     if (!isset($count)) {
         $count = 1;
     } else {
         $count++;
     }
     switch ($variant) {
         case 'ajax':
             // asynchronous loading
         // asynchronous loading
         default:
             $text = '<div id="newsfeed_' . $count . '" class="no_print"></div>' . "\n";
             Page::insert_script('$(function() { Yacs.spin("newsfeed_' . $count . '"); Yacs.call( { method: \'feed.proxy\', params: { url: \'' . $url . '\' }, id: 1 }, function(s) { if(s.text) { $("#newsfeed_' . $count . '").html(s.text.toString()); } else { $("#newsfeed_' . $count . '").html("***error***"); } } ) } );');
             return $text;
         case 'embed':
             // integrate newsfeed into the page
             include_once $context['path_to_root'] . 'feeds/proxy_hook.php';
             $parameters = array('url' => $url);
             if ($output = Proxy_hook::serve($parameters)) {
                 $text = $output['text'];
             }
             return $text;
     }
 }
Example #8
0
File: view.php Project: rair/yacs
         list($item['latitude'], $item['longitude']) = preg_split('/[\\s,;]+/', $item['geo_position']);
     }
     // link to anchor page
     $description = '';
     if ($anchor = Anchors::get($item['anchor'])) {
         $description .= Skin::build_link($anchor->get_url(), $anchor->get_title());
     }
     // item type
     if (strpos($item['anchor'], 'user:'******'user';
     } else {
         $type = 'other';
     }
     // do the job
     Page::defer_script('http://maps.google.com/maps/api/js?v=3&amp;sensor=false');
     Page::insert_script('var point = new google.maps.LatLng(parseFloat("' . $item['latitude'] . '"), parseFloat("' . $item['longitude'] . '"));' . "\n" . "\n" . 'var mapOptions = {' . "\n" . '	zoom: 10,' . "\n" . '	center: point,' . "\n" . '	mapTypeId: google.maps.MapTypeId.ROADMAP' . "\n" . '};' . "\n" . 'var map = new google.maps.Map($("#map")[0], mapOptions);' . "\n" . '	var marker = new google.maps.Marker({ position: point, map: map });' . "\n" . '	var infoWindow = new google.maps.InfoWindow();' . "\n" . 'google.maps.event.addDomListener(marker, "click", function() {' . "\n" . '	infoWindow.setContent("' . addcslashes($description, '\'\\"' . "\n\r") . '");' . "\n" . '	infoWindow.open(map, marker);' . "\n" . '	});' . "\n" . '$("body").bind("yacs", function(e) {' . "\n" . '	google.maps.event.trigger(map, "resize");' . "\n" . '	map.setZoom( map.getZoom() );' . "\n" . '	map.setCenter(point);' . "\n" . '});' . "\n");
 }
 // geo country
 if ($item['geo_country']) {
     $context['text'] .= '<p>' . sprintf(i18n::s('Regional position: %s'), $item['geo_country']) . "</p>\n";
 }
 // display the full text
 $context['text'] .= Skin::build_block($item['description'], 'description');
 // information on uploader
 $details = array();
 if (Surfer::is_member() && $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']));
 }
 // page details
 if (is_array($details)) {
     $context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
Example #9
0
File: invite.php Project: rair/yacs
    $label = i18n::s('Message content');
    $input = Surfer::get_editor('message', $content);
    $fields[] = array($label, $input);
    // build the form
    $context['text'] .= Skin::build_form($fields);
    //
    // bottom commands
    //
    $menu = array();
    // the submit button
    $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
    // cancel button
    if (isset($item['id'])) {
        $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('Cancel'), 'span');
    }
    // insert the menu in the page
    $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
    // get a copy of the sent message
    $context['text'] .= '<p><input type="checkbox" name="self_copy" value="Y" checked="checked" /> ' . i18n::s('Send me a copy of this message.') . '</p>';
    // transmit the id as a hidden field
    $context['text'] .= '<input type="hidden" name="id" value="' . $item['id'] . '" />';
    // end of the form
    $context['text'] .= '</div></form>';
    // append the script used for data checking on the browser
    Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	if(!container.subject.value) {' . "\n" . '		alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	if(!container.message.value) {' . "\n" . '		alert("' . i18n::s('Message content can not be empty.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	return true;' . "\n" . '}' . "\n" . '$(function() {' . "\n" . '	$("#names").focus();' . "\n" . '	Yacs.autocomplete_names("names");' . "\n" . '});  ' . "\n");
    // help message
    $help = '<p>' . i18n::s('New e-mail addresses are converted to new user profiles. Because of this, you should not use e-mail addresses that have multiple recipients.') . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
}
// render the skin
render_skin();
Example #10
0
File: select.php Project: rair/yacs
 // the form to link additional users
 $form = '<form method="post" action="' . $context['script_url'] . '" id="main_form">';
 // horizontal layout
 $cells = array();
 // users only have followers
 if (!strncmp($anchor->get_reference(), 'user:'******'category:', 9)) {
 } elseif (!$anchor->is_hidden()) {
     $cells[] = '<span class="small">' . '<input type="radio" name="assignment" value="watcher" checked="checked" /> ' . i18n::s('notify on update (watcher)') . BR . '<input type="radio" name="assignment" value="editor" /> ' . i18n::s('moderate content (editor)') . '</span>';
 }
 // capture a new name with auto completion
 $cells[] = '<input type="text" name="assigned_name" id="assigned_name" size="45" maxlength="255" />' . ' <input type="submit" id="submit_button" value="' . i18n::s('Submit') . '" style="display: none;" />' . '<p class="details">' . i18n::s('To add a person, type some letters to look for a name, then select one profile at a time.') . '</p>';
 // finalize the capture form
 $form .= Skin::layout_horizontally($cells) . '<input type="hidden" name="member" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="assign">' . '</form>' . "\n";
 // enable autocompletion
 Page::insert_script('$(function() {' . "\n" . '	// set the focus on first form field' . "\n" . '	$("#assigned_name").focus();' . "\n" . '	// enable name autocompletion' . "\n" . '	Yacs.autocomplete_names("assigned_name",true, "", function(data) { Yacs.startWorking(); $("#submit_button").show().click(); });' . "\n" . '});  ' . "\n");
 // title says it all
 if (!strncmp($anchor->get_reference(), 'user:'******'Who do you want to follow?');
     } else {
         $title = sprintf(i18n::s('Persons followed by %s'), $anchor->get_title());
     }
 } elseif (!strncmp($anchor->get_reference(), 'category:', 9)) {
     $title = sprintf(i18n::s('Add a member to %s'), $anchor->get_title());
 } else {
     $title = i18n::s('Add a participant');
 }
 // finalize the box
 $context['text'] .= Skin::build_box($title, $form, 'header1');
 // looking at category members
Example #11
0
 /**
  * render a dynamic table
  *
  * @param string the table content
  * @param string the variant, if any
  * @return string the rendered text
  **/
 public static function render_dynamic_table($id, $variant = 'inline')
 {
     global $context;
     // refresh on every page load
     Cache::poison();
     // get actual content
     include_once $context['path_to_root'] . 'tables/tables.php';
     // use SIMILE Exhibit
     if ($variant == 'filter') {
         // load the SIMILE Exhibit javascript library in shared/global.php
         $context['javascript']['exhibit'] = TRUE;
         // load data
         $context['page_header'] .= "\n" . '<link href="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_json') . '" type="application/json" rel="exhibit/data" />';
         // exhibit data in a table
         $text = '<div ex:role="exhibit-view" ex:viewClass="Exhibit.TabularView" ex:columns="' . Tables::build($id, 'json-labels') . '" ex:columnLabels="' . Tables::build($id, 'json-titles') . '" ex:border="0" ex:cellSpacing="0" ex:cellPadding="0" ex:showToolbox="true" ></div>' . "\n";
         // allow for filtering
         $facets = '<div class="exhibit-facet">' . '<div class="exhibit-facet-header"><span class="exhibit-facet-header-title">' . i18n::s('Filter') . '</span></div>' . '<div class="exhibit-facet-body-frame" style="margin: 0 2px 1em 0;">' . '<div ex:role="facet" ex:facetClass="TextSearch" style="display: block;"></div>' . '</div></div>';
         // facets from first columns
         $facets .= Tables::build($id, 'json-facets');
         // filter and facets aside
         $context['components']['boxes'] .= $facets;
         // build sparkline
     } elseif ($variant == 'bars') {
         $text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=0&gap;0.5" alt="" />';
         // buid a Flash chart
     } elseif ($variant == 'chart') {
         // split parameters
         $attributes = preg_split("/\\s*,\\s*/", $id, 4);
         // set a default size
         if (!isset($attributes[1])) {
             $attributes[1] = 480;
         }
         if (!isset($attributes[2])) {
             $attributes[2] = 360;
         }
         // object attributes
         $width = $attributes[1];
         $height = $attributes[2];
         $flashvars = '';
         if (isset($attributes[3])) {
             $flashvars = $attributes[3];
         }
         // allow several charts to co-exist in the same page
         static $chart_index;
         if (!isset($chart_index)) {
             $chart_index = 1;
         } else {
             $chart_index++;
         }
         // get data in the suitable format
         $data = Tables::build($attributes[0], 'chart');
         // load it through Javascript
         $url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/open-flash-chart.swf';
         $text = '<div id="table_chart_' . $chart_index . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
         Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "opaque";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "table_chart_' . $chart_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", {"get-data":"table_chart_' . $chart_index . '"}, params);' . "\n" . "\n" . 'var chart_data_' . $chart_index . ' = ' . trim(str_replace(array('<br />', "\n"), ' ', $data)) . ';' . "\n" . "\n" . 'function table_chart_' . $chart_index . '() {' . "\n" . '	return $.toJSON(chart_data_' . $chart_index . ');' . "\n" . '}' . "\n");
         // build sparkline
     } elseif ($variant == 'line') {
         $text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=2&gap=0.0" alt="" />';
         // we do the rendering ourselves
     } else {
         $text = Tables::build($id, $variant);
     }
     // put that into the web page
     return $text;
 }
Example #12
0
     $label = i18n::s('E-mail address');
     $field = $item['email'];
     $fields[] = array($label, $field);
 }
 // surfer is changing password
 if (Surfer::is_logged()) {
     // the password
     $label = i18n::s('New password');
     $input = '<input type="password" name="password" id="password" size="20" value="' . encode_field(isset($_REQUEST['password']) ? $_REQUEST['password'] : '') . '" />';
     $fields[] = array($label, $input);
     // the password has to be repeated for confirmation
     $label = i18n::s('Password confirmation');
     $input = '<input type="password" name="confirm" size="20" value="' . encode_field(isset($_REQUEST['confirm']) ? $_REQUEST['confirm'] : '') . '" />';
     $fields[] = array($label, $input);
     // append the script used for data checking on the browser
     Page::insert_script('$("#password").focus();');
 }
 // stop replay attacks and robots
 if ($field = Surfer::get_robot_stopper()) {
     $fields[] = $field;
 }
 // build the form
 $context['text'] .= Skin::build_form($fields);
 // cancel link
 if (!isset($item['id'])) {
     $cancel_url = $context['url_to_home'] . $context['url_to_root'];
 } else {
     $cancel_url = Users::get_permalink($item);
 }
 // bottom commands
 $context['text'] .= Skin::finalize_list(array(Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'), Skin::build_link($cancel_url, i18n::s('Cancel'), 'span')), 'assistant_bar');
Example #13
0
File: ajax.php Project: rair/yacs
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.confirm(\'' . i18n::s('AJAX demonstration') . '\', function(choice) { if(choice) { alert(\'' . i18n::s('OK') . '\') } })" class="button"><span>' . i18n::s('Confirmation box') . '</span></a> - ' . i18n::s('Click on the button to make your choice') . '</p>' . "\n";
// notifications
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.handleAlertNotification({ title: &quot;' . i18n::s('Alert notification') . '&quot;,' . 'nick_name: &quot;Foo Bar&quot;,' . 'address: &quot;http://www.google.com/&quot; })" class="button"><span>' . i18n::s('Alert notification') . '</span></a>' . ' <a href="#" onclick="Yacs.handleBrowseNotification({ message: &quot;' . i18n::s('Browse notification') . '&quot;,' . 'nick_name: &quot;Foo Bar&quot;,' . 'address: &quot;http://www.google.com/&quot; })" class="button"><span>' . i18n::s('Browse notification') . '</span></a>' . ' <a href="#" onclick="Yacs.handleHelloNotification({ message: &quot;' . i18n::s('Hello notification') . '&quot;,' . 'nick_name: &quot;Foo Bar&quot; })" class="button"><span>' . i18n::s('Hello notification') . '</span></a> - ' . i18n::s('Click on buttons to process notifications') . '</p>' . "\n";
// a scaled iframe for preview
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="http://www.cisco.com/" class="button tipsy_preview"><span>' . i18n::s('Cisco') . '</span></a> - ' . i18n::s('Hover the button to display a preview') . '</p>' . "\n";
// a popup box
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="http://www.cisco.com/" onclick="Yacs.popup( { url: this.href, width: \'100%\', height: \'100%\' } ); return false;" class="button"><span>' . i18n::s('Cisco') . '</span></a> - ' . i18n::s('Click on the button to trigger the popup window') . '</p>' . "\n";
// a JSON-RPC call -- see services/rpc_echo_hook.php
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.call( { method: \'echo\', params: { message: \'' . i18n::s('AJAX demonstration') . '\' }, id: 123 }, function(s) { if(s.message) { alert(s.message); } else { alert(\'failed!\'); } } ); return false;" class="button"><span>JSON-RPC echo</span></a> - ' . i18n::s('Click on the button to call a remote function') . '</p>' . "\n";
// another JSON-RPC call -- see services/rpc_activity_hook.php
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.call( { method: \'user.activity\', params: { anchor: \'tools/ajax.php\', action: \'test\' } } ); alert(\'record has been added to table yacs_activities\'); return false;" class="button"><span>JSON-RPC activity</span></a> - ' . i18n::s('Click on the button to remember some on-line activity') . '</p>' . "\n";
// a popup box with content
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.popup( { content: \'<html><head><title>Popup</title></head><body><p>' . i18n::s('Hello world') . '</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p><a href=&quot;javascript:self.close()&quot;>' . i18n::s('Close') . '</a></p></body></html>\' } ); return false;" class="button"><span>' . i18n::s('Hello world') . '</span></a> - ' . i18n::s('Click on the button to trigger the popup window') . '</p>' . "\n";
// contextual handling of elements in a list
$context['text'] .= '<div class="onDemandTools mutable" style="position:relative; width: 400px; padding: 0.5em; border: 1px dotted #ccc;"><b>' . i18n::s('Hover me to access tools') . '</b>' . '<p class="properties" style="display: none">Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>' . '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>' . '</div>' . "\n";
// a sortable list
$context['text'] .= '<p style="margin-bottom: 1em;"><b>' . i18n::s('Drag and drop following elements') . '</b></p>' . '<div id="sortables" style="position:relative; width: 510px; padding: 0.5em; border: 1px dotted #ccc;">' . '<div class="sortable">1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>' . '<div class="sortable">2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>' . '<div class="sortable">3. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>' . '</div>' . "\n";
// filtering floating numbers
$context['text'] .= '<p style="margin-bottom: 1em;"><b>' . i18n::s('Interactive filters') . '</b></p>' . '<form>' . '<p><input type="text" size="6" onkeypress="return Yacs.filterInteger(this, event)" /> - ' . i18n::s('Enter an integer') . '</p>' . '<p><input type="text" size="6" onkeypress="return Yacs.filterFloat(this, event)" /> - ' . i18n::s('Enter a floating number') . '</p>' . '</form>' . "\n";
// autocompletion field
$context['text'] .= '<p style="margin-bottom: 1em;"><b>' . i18n::s('autocompletion') . '</b></p>' . '<form>' . '<p>' . Skin::build_autocomplete_tag_input('test_auto', 'test_auto', '', 'keywords') . '</p>' . '</form>' . "\n";
// calling raw content of a page
$context['text'] .= '<p>';
$context['text'] .= '<a class="button" id="view_1"><span>Press to open article 1 viewing page</span></a>';
$context['text'] .= '<a class="button" id="edit_1"><span>Press to open article 1 edition form</span></a>';
$context['text'] .= '</p>';
$context['text'] .= '<p><textarea size="3"></textarea>';
// some AJAX to make it work
Page::insert_script('$("#sortables .sortable").each( function() { ' . 'Yacs.addOnDemandTools($(this));}); ' . "\n" . '$("#sortables").sortable({axis: "y", handle: ".drag_handle"});' . "\n" . '$("#view_1").click(function(){Yacs.displayOverlaid(url_to_root+"articles/view.php?id=1")});' . '$("#edit_1").click(function(){Yacs.displayOverlaid(url_to_root+"articles/edit.php?id=1",true,true)});');
// render the page according to the loaded skin
render_skin();
Example #14
0
File: index.php Project: rair/yacs
 // members can use additional tools
 if (Surfer::is_member()) {
     // introduce bookmarklets
     $box = '<p>' . i18n::s('To install following bookmarklets, right-click over them and add them to your bookmarks or favorites. Then recall them at any time while browsing the Internet, to add content to this site.') . '</p>' . "\n" . '<ul>';
     // the blogging bookmarklet uses YACS codes
     $bookmarklet = "javascript:function findFrame(f){var i;try{isThere=f.document.selection.createRange().text;}catch(e){isThere='';}if(isThere==''){for(i=0;i&lt;f.frames.length;i++){findFrame(f.frames[i]);}}else{s=isThere}return s}" . "var s='';" . "d=document;" . "s=d.selection?findFrame(window):window.getSelection();" . "window.location='" . $context['url_to_home'] . $context['url_to_root'] . "articles/edit.php?" . "title='+escape(d.title)+'" . "&amp;text='+escape('%22'+s+'%22%5Bnl]-- %5Blink='+d.title+']'+d.location+'%5B/link]')+'" . "&amp;source='+escape(d.location);";
     $box .= '<li><a href="' . $bookmarklet . '">' . sprintf(i18n::s('Blog at %s'), $context['site_name']) . '</a></li>' . "\n";
     // the bookmarking bookmarklet
     $bookmarklet = "javascript:function findFrame(f){var i;try{isThere=f.document.selection.createRange().text;}catch(e){isThere='';}if(isThere==''){for(i=0;i&lt;f.frames.length;i++){findFrame(f.frames[i]);}}else{s=isThere}return s}" . "var s='';" . "d=document;" . "s=d.selection?findFrame(window):window.getSelection();" . "window.location='" . $context['url_to_home'] . $context['url_to_root'] . "links/edit.php?" . "link='+escape(d.location)+'" . "&amp;title='+escape(d.title)+'" . "&amp;text='+escape(s);";
     $box .= '<li><a href="' . $bookmarklet . '">' . sprintf(i18n::s('Bookmark at %s'), $context['site_name']) . '</a></li>' . "\n";
     // end of bookmarklets
     $box .= '</ul>' . "\n";
     // the command to add a side panel
     $box .= '<p>' . sprintf(i18n::s('If your browser supports side panels and javascript, click on the following link to %s.'), '<a onclick="addSidePanel()">' . i18n::s('add a blogging panel') . '</a>.') . '</p>' . "\n";
     // the actual javascript code to add a panel
     Page::insert_script('function addSidePanel() {' . "\n" . '	if((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {' . "\n" . '		window.sidebar.addPanel("' . strip_tags($context['site_name']) . '", "' . $context['url_to_home'] . $context['url_to_root'] . 'panel.php", "");' . "\n" . '		alert("' . i18n::s('The panel has been added. You may have to ask your browser to make it visible (Ctrl-B for Firefox).') . '");' . "\n" . '	} else {' . "\n" . '		if(document.all) {' . "\n" . '			window.open("' . $context['url_to_home'] . $context['url_to_root'] . 'panel.php?target=_main" ,"_search");' . "\n" . '		} else {' . "\n" . '			var rv = alert("' . i18n::s('Your browser does not support side panels. Have you considered to upgrade to Mozilla Firefox?') . '");' . "\n" . '			if(rv)' . "\n" . '				document.location.href = "http://www.mozilla.org/products/firefox/";' . "\n" . '		}' . "\n" . '	}' . "\n" . '}' . "\n");
     // make a nice box out of it
     $text .= Skin::build_box(i18n::s('Blogging tools'), $box);
 }
 // build another tab
 $all_tabs = array_merge($all_tabs, array(array('content', i18n::s('Content'), 'content_panel', $text)));
 //
 // System Management tab
 //
 $text = '';
 // display a system overview if not a crawler
 if (!Surfer::is_crawler()) {
     // use a neat table for the layout
     $box = Skin::table_prefix('wide');
     $lines = 1;
     // yacs version
Example #15
0
    // the submit button
    $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
    // control panel
    if (file_exists('../parameters/control.include.php')) {
        $menu[] = Skin::build_link('control/', i18n::s('Control Panel'), 'span');
    }
    // all skins
    if (file_exists('../parameters/control.include.php')) {
        $menu[] = Skin::build_link('scripts/', i18n::s('Server software'), 'span');
    }
    // insert the menu in the page
    $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
    // end of the form
    $context['text'] .= '</div></form>';
    // set the focus
    Page::insert_script('$("#reference_server").focus();');
    // general help on this form
    $help = '<p>' . i18n::s('Indicate only the DNS name or IP address of the reference server.') . '</p>';
    // no modifications in demo mode
} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // save updated parameters
} else {
    // backup the old version
    Safe::unlink($context['path_to_root'] . 'parameters/scripts.include.php.bak');
    Safe::rename($context['path_to_root'] . 'parameters/scripts.include.php', $context['path_to_root'] . 'parameters/scripts.include.php.bak');
    // build the new configuration file
    $content = '<?php' . "\n" . '// This file has been created by the configuration script scripts/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . '$context[\'home_at_root\']=\'' . addcslashes($_REQUEST['home_at_root'], "\\'") . "';\n" . '$context[\'reference_server\']=\'' . addcslashes($_REQUEST['reference_server'], "\\'") . "';\n" . '?>' . "\n";
    // update the parameters file
    if (!Safe::file_put_contents('parameters/scripts.include.php', $content)) {
Example #16
0
 /**
  * list articles
  *
  * @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;
     }
     // the script used to check all pages at once
     Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . '	$("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // table prefix
     $text .= Skin::table_prefix('yc-grid');
     // table headers
     $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />';
     $cells = array($main, i18n::s('Page'), i18n::s('Rank'));
     $text .= Skin::table_row($cells, 'header');
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $count = 0;
     while ($item = SQL::fetch($result)) {
         $cells = array();
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // column to select the row
         $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />';
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y') {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($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;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // the introductory text
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name'] != $item['edit_name']) {
                 $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
             } else {
                 $details[] = sprintf(i18n::s('by %s'), $item['create_name']);
             }
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         $stats = Files::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']);
         }
         // info on related links
         $stats = Links::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']);
         }
         // info on related comments
         $stats = Comments::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ucfirst(trim(implode(', ', $details)));
         }
         // list up to three categories by title, if any
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (count($anchors)) {
             $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors));
         }
         // end of details
         $suffix .= '</span>';
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         }
         // commands
         $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'));
         // link to this page
         $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix;
         // ranking
         $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />';
         // append the row
         $text .= Skin::table_row($cells, $count++);
     }
     // select all rows
     $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), '');
     $text .= Skin::table_row($cells, $count++);
     // table suffix
     $text .= Skin::table_suffix();
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #17
0
    // the submit button
    $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
    // control panel
    if (file_exists('../parameters/control.include.php')) {
        $menu[] = Skin::build_link('control/', i18n::s('Control Panel'), 'span');
    }
    // all skins
    if (file_exists('../parameters/control.include.php')) {
        $menu[] = Skin::build_link('files/', i18n::s('Files'), 'span');
    }
    // insert the menu in the page
    $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
    // end of the form
    $context['text'] .= '</div></form>';
    // set the focus
    Page::insert_script('$("#files_extensions").focus();');
    // general help on this form
    $help = '<p>' . i18n::s('Shared files are not put in the database, but in the file system of the web server.') . '</p>' . '<p>' . i18n::s('If you cannot upload files because of permissions settings, use the configuration panel for users to disable all uploads.') . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
    // no modifications in demo mode
} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // save updated parameters
} else {
    // backup the old version
    Safe::unlink($context['path_to_root'] . 'parameters/files.include.php.bak');
    Safe::rename($context['path_to_root'] . 'parameters/files.include.php', $context['path_to_root'] . 'parameters/files.include.php.bak');
    // build the new configuration file
    $content = '<?php' . "\n" . '// This file has been created by the configuration script files/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . 'global $context;' . "\n";
    if (isset($_REQUEST['files_extensions'])) {
Example #18
0
     $fields[] = array($label, $input);
     // home panel
     $label = i18n::s('Front page');
     $input = i18n::s('Should content of this section be displayed at the front page?') . BR;
     $input .= '<input type="radio" name="index_map" value="Y" checked="checked" /> ' . i18n::s('Yes') . BR;
     $input .= '<input type="radio" name="index_map" value="N" /> ' . i18n::s('No');
     $fields[] = array($label, $input);
     // build the form
     $context['text'] .= Skin::build_form($fields);
     $fields = array();
     // the submit button
     $context['text'] .= '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Add content'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
     // end of the form
     $context['text'] .= '</div></form>';
     // append the script used for data checking on the browser
     Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	if(!container.title.value) {' . "\n" . '		alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	return true;' . "\n" . '}' . "\n" . "\n" . '$("#title").focus();' . "\n");
     // create a section
 } else {
     $fields = array();
     $fields['anchor'] = $_REQUEST['anchor'];
     $fields['title'] = $_REQUEST['title'];
     $fields['introduction'] = $_REQUEST['introduction'];
     $fields['description'] = $_REQUEST['description'];
     $fields['active_set'] = $_REQUEST['active'];
     $fields['index_map'] = $_REQUEST['index_map'];
     $fields['articles_layout'] = 'tagged';
     // the preferred layout for wikis
     $fields['options'] = 'articles_by_title';
     // alphabetical order
     $fields['content_options'] = 'view_as_wiki auto_publish edit_as_simple with_export_tools';
     if ($_REQUEST['contribution'] == 'Y') {
 /**
  * list articles
  *
  * @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;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = 'map';
     }
     // put in cache
     $cache_id = Cache::hash('articles/layout_articles_as_carrousel:' . $this->focus) . '.xml';
     // save for one minute
     if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) {
         // content of the slideshow
         $content = '<?xml version="1.0" encoding="utf-8"?><!-- fhShow Carousel 2.0 configuration file Please visit http://www.flshow.net/ -->' . "\n" . '<slide_show>' . "\n" . '	<options>' . "\n" . '		<debug>false</debug>				  <!-- true, false -->' . "\n" . '		<background>transparent</background>	  <!-- #RRGGBB, transparent -->' . "\n" . '		<friction>5</friction>			  <!-- [1,100] -->' . "\n" . '		<fullscreen>false</fullscreen>	  <!-- true, false -->' . "\n" . '		<margins>' . "\n" . '			<top>0</top>								  <!-- [-1000,1000] pixels -->' . "\n" . '			<left>0</left>							  <!-- [-1000,1000] pixels -->' . "\n" . '			<bottom>0</bottom>						  <!-- [-1000,1000] pixels -->' . "\n" . '			<right>0</right>							  <!-- [-1000,1000] pixels -->' . "\n" . '			<horizontal_ratio>20%</horizontal_ratio>	  <!-- [1,50] a photo may occupy at most horizontalRatio percent of the Carousel width -->' . "\n" . '			<vertical_ratio>90%</vertical_ratio>		  <!-- [1,100] a photo may occupy at most verticalRatio percent of the Carousel height -->' . "\n" . '		</margins>' . "\n" . '		<interaction>' . "\n" . '			<rotation>mouse</rotation>			<!-- auto, mouse, keyboard -->' . "\n" . '			<view_point>none</view_point>		   <!-- none, mouse, keyboard -->' . "\n" . '			<speed>15</speed>						<!-- [-360,360] degrees per second -->' . "\n" . '			<default_speed>15</default_speed>				<!-- [-360,360] degrees per second -->' . "\n" . '			<default_view_point>20%</default_view_point>	<!-- [0,100] percentage -->' . "\n" . '			<reset_delay>20</reset_delay>					<!-- [0,600] seconds, 0 means never reset -->' . "\n" . '		</interaction>' . "\n" . '		<far_photos>' . "\n" . '			<size>50%</size>					<!-- [0,100] percentage -->' . "\n" . '			<amount>50%</amount>				<!-- [0,100] percentage -->' . "\n" . '			<blur>10</blur>					<!-- [0,100] amount -->' . "\n" . '			<blur_quality>3</blur_quality>	<!-- [1,3] 1=low - 3=high -->' . "\n" . '		</far_photos>' . "\n" . '		<reflection>' . "\n" . '			<amount>25</amount>	   <!-- [0,1000] pixels -->' . "\n" . '			<blur>2</blur>			<!-- [0,100] blur amount -->' . "\n" . '			<distance>0</distance>	<!-- [-1000,1000] pixels -->' . "\n" . '			<alpha>40%</alpha>		<!-- [0,100] percentage -->' . "\n" . '		</reflection>' . "\n" . '		<titles>' . "\n" . '			<style>font-size: 14px; font-family: Verdana, _serif; color: #000000;</style>' . "\n" . '			<position>above center</position>			  <!-- [above, below] [left,center,right]-->' . "\n" . '			<background>' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/layouts/carrousel_bubble.png</background>	   <!-- image url -->' . "\n" . '			<scale9>35 35 35 35</scale9>				 <!-- [0,1000] pixels -->' . "\n" . '			<padding>8 15 10 15</padding>					<!-- [-1000,1000] pixels -->' . "\n" . '		</titles>' . "\n" . '	</options>' . "\n";
         // get a default image
         if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif';
         } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif';
         } else {
             $default_href = NULL;
         }
         // process all items in the list
         while ($item = SQL::fetch($result)) {
             // get the related overlay
             $overlay = Overlay::load($item, 'article:' . $item['id']);
             // get the anchor
             $anchor = Anchors::get($item['anchor']);
             // this is visual
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $image = $item['icon_url'];
             } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
                 $image = $item['thumbnail_url'];
             } elseif (is_callable(array($anchor, 'get_bullet_url')) && ($image = $anchor->get_bullet_url())) {
             } elseif ($default_href) {
                 $image = $default_href;
             } else {
                 continue;
             }
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $image)) {
                 $image = $context['url_to_home'] . $context['url_to_root'] . $image;
             }
             // build a title
             if (is_object($overlay)) {
                 $title = Codes::beautify_title($overlay->get_text('title', $item));
             } else {
                 $title = Codes::beautify_title($item['title']);
             }
             // the url to view this item
             $url = Articles::get_permalink($item);
             // add to the list
             $content .= '	<photo>' . "\n" . '		<title>' . $title . '</title>' . "\n" . '		<src>' . $image . '</src>' . "\n" . '		<href>' . $url . '</href>' . "\n" . '		<target>_self</target>' . "\n" . '	</photo>' . "\n";
         }
         // finalize slideshow content
         $content .= '</slide_show>';
         // put in cache
         Safe::file_put_contents($cache_id, $content);
     }
     // allow multiple instances
     static $count;
     if (!isset($count)) {
         $count = 1;
     } else {
         $count++;
     }
     // load the right file
     $text = '<div id="articles_as_carrousel_' . $count . '"></div>' . "\n";
     Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"articles_as_carrousel_' . $count . '",' . "\n" . '"100%",' . "\n" . '"150",' . "\n" . '"9.0.0",' . "\n" . 'false,' . "\n" . '{xmlfile:"' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", loaderColor:"0x666666"},' . "\n" . '{wmode: "transparent"},' . "\n" . '{});' . "\n");
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #20
0
 /**
  * add text to the bottom of the page
  *
  * This is where video streams from OpenTok are included
  *
  * @see overlays/event.php
  *
  * @param array the hosting record, if any
  * @return some HTML to be inserted into the resulting page
  */
 function &get_trailer_text($host = NULL)
 {
     global $context;
     // meeting is not on-going
     $text = '';
     if ($this->attributes['status'] != 'started') {
         return $text;
     }
     // use services/configure.php to activate OpenTok
     if (!isset($context['opentok_api_key']) || !$context['opentok_api_key']) {
         return $text;
     }
     // no session id!
     if (!isset($this->attributes['session_id']) || !$this->attributes['session_id']) {
         Logger::error(sprintf('OpenTok error: %s', 'no session id has been found'));
         return $text;
     }
     // prepare the authentication token
     $credentials = 'session_id=' . $this->attributes['session_id'] . '&create_time=' . time() . '&role=publisher' . '&nonce=' . microtime(true) . mt_rand();
     // hash credentials using secret
     $hash = hash_hmac('sha1', $credentials, $context['opentok_api_secret']);
     // finalize the authentication token expected by OpenTok
     $token = 'T1==' . base64_encode('partner_id=' . $context['opentok_api_key'] . '&sig=' . $hash . ':' . $credentials);
     // delegate audio processing to OpenTok too
     $with_audio = 'true';
     // except if twilio has been activated instead
     if (isset($context['twilio_account_sid']) && $context['twilio_account_sid']) {
         $with_audio = 'false';
     }
     // load the OpenTok javascript library in shared/global.php
     $context['javascript']['opentok'] = TRUE;
     // interface with the OpenTok API
     $js_script = 'var OpenTok = {' . "\n" . "\n" . '	apiKey: ' . $context['opentok_api_key'] . ',' . "\n" . '	sessionId: "' . $this->attributes['session_id'] . '",' . "\n" . '	tokenString: "' . $token . '",' . "\n" . "\n" . '	deviceManager: null,' . "\n" . '	publisher: null,' . "\n" . '	session: null,' . "\n" . '	subscribers: {},' . "\n" . '	tentatives: 3,' . "\n" . '	watchdog: null,' . "\n" . '	withAudio: ' . $with_audio . ',' . "\n" . "\n" . '	// user has denied access to the camera from Flash' . "\n" . '	accessDeniedHandler: function() {' . "\n" . '		$("#opentok .me").empty();' . "\n" . '	},' . "\n" . "\n" . '	// attempt to reconnect to the server' . "\n" . '	connectAgain: function() {' . "\n" . '		OpenTok.growl("' . i18n::s('Connecting again to OpenTok') . '");' . "\n" . '		OpenTok.session.connect(OpenTok.apiKey, OpenTok.tokenString);' . "\n" . '	},' . "\n" . "\n" . '	// successful detection of local devices' . "\n" . '	devicesDetectedHandler: function(event) {' . "\n" . "\n" . '		// no adequate hardware to move forward' . "\n" . '		if(event.cameras.length == 0) {' . "\n" . '			OpenTok.growl("' . i18n::s('A webcam is required to be visible') . '");' . "\n" . "\n" . '		// at least one camera is available' . "\n" . '		} else {' . "\n" . "\n" . '			// create one placeholder div for my own camera' . "\n" . '			OpenTok.growl("' . i18n::s('Adding local video stream') . '");' . "\n" . '			$("#opentok .me").append(\'<div class="frame subscriber"><div id="placeholder"></div></div>\');' . "\n" . "\n" . '			// bind this div with my own camera' . "\n" . '			var streamProps = {width: 120, height: 90,' . "\n" . '					publishAudio: false, publishVideo: true, name: "' . str_replace('"', "'", Surfer::get_name()) . '" };' . "\n" . '			OpenTok.publisher = OpenTok.session.publish("placeholder", streamProps);' . "\n" . "\n" . '			// monitor the publishing session' . "\n" . '			OpenTok.publisher.addEventListener("accessDenied", OpenTok.accessDeniedHandler);' . "\n" . '			OpenTok.publisher.addEventListener("deviceInactive", OpenTok.deviceInactiveHandler);' . "\n" . "\n" . '		}' . "\n" . "\n" . '	},' . "\n" . "\n" . '	// for some reason the user is not publishing anymore' . "\n" . '	deviceInactiveHandler: function(event) {' . "\n" . '		if(event.camera) {' . "\n" . '			OpenTok.growl("' . i18n::s('You are not visible') . '");' . "\n" . '		}' . "\n" . '		if(event.microphone) {' . "\n" . '			OpenTok.growl("' . i18n::s('You have been muted') . '");' . "\n" . '			$("#opentok .me .frame").removeClass("talker");' . "\n" . '		}' . "\n" . '	},' . "\n" . "\n" . '	// we have been killed by an asynchronous exception' . "\n" . '	exceptionHandler: function(event) {' . "\n" . "\n" . '		OpenTok.growl(event.code + " " + event.title + " - " + event.message);' . "\n" . "\n" . '		OpenTok.tentatives--;' . "\n" . '		if((OpenTok.tentatives > 0) && (event.code === 1006 || event.code === 1008 || event.code === 1014)) {' . "\n" . '			OpenTok.session.connecting = false;' . "\n" . '			window.setTimeout("OpenTok.connectAgain()", 3000);' . "\n" . '		}' . "\n" . '	},' . "\n" . "\n" . '	// display a message for some seconds' . "\n" . '	growl: function(message) {' . "\n" . '		if(typeof OpenTok.growlId != "number") {' . "\n" . '			OpenTok.growlId = 1;' . "\n" . '		} else {' . "\n" . '			OpenTok.growlId++;' . "\n" . '		}' . "\n" . '		var myId = OpenTok.growlId++;' . "\n" . '		$("#opentok .growl").append(\'<span id="growl\'+myId+\'">\'+message+"</span>");' . "\n" . '		window.setTimeout("$(\'#growl"+myId+"\').fadeOut(\'slow\')", 5000);' . "\n" . '	},' . "\n" . "\n" . '	// launch the video chat based on OpenTok' . "\n" . '	initialize: function() {' . "\n" . "\n" . '		// report on error, if any' . "\n" . '		TB.setLogLevel(TB.DEBUG);' . "\n" . '		TB.addEventListener("exception", OpenTok.exceptionHandler);' . "\n" . "\n" . '		// check system capabilities before activating the service' . "\n" . '		if(TB.checkSystemRequirements() == TB.HAS_REQUIREMENTS) {' . "\n" . "\n" . '			// slide to page bottom, because this is not obvious to end-user' . "\n" . '			OpenTok.growl("' . i18n::s('Connecting to OpenTok') . '");' . "\n" . "\n" . '			// bind to local hardware via a device manager' . "\n" . '			OpenTok.deviceManager = TB.initDeviceManager(OpenTok.apiKey);' . "\n" . '			OpenTok.deviceManager.addEventListener("devicesDetected", OpenTok.devicesDetectedHandler);' . "\n" . "\n" . '			// bind to the API via a session' . "\n" . '			OpenTok.session = TB.initSession(OpenTok.sessionId);' . "\n" . '			OpenTok.session.addEventListener("sessionConnected", OpenTok.sessionConnectedHandler);' . "\n" . '			OpenTok.session.addEventListener("signalReceived", OpenTok.signalReceivedHandler);' . "\n" . '			OpenTok.session.addEventListener("streamCreated", OpenTok.streamCreatedHandler);' . "\n" . '			OpenTok.session.addEventListener("streamDestroyed", OpenTok.streamDestroyedHandler);' . "\n" . '			OpenTok.session.addEventListener("streamPropertyChanged", OpenTok.streamPropertyChangedHandler);' . "\n" . "\n" . '			// connect to back-end servers' . "\n" . '			OpenTok.session.connect(OpenTok.apiKey, OpenTok.tokenString);' . "\n" . "\n" . '		// no way to use the service' . "\n" . '		} else {' . "\n" . '			OpenTok.growl("' . i18n::s('This system is not supported by OpenTok') . '");' . "\n" . '		}' . "\n" . '	},' . "\n" . "\n" . '	// successful connection to the OpenTok back-end servers' . "\n" . '	sessionConnectedHandler: function(event) {' . "\n" . "\n" . '		// display streams already attached to this session' . "\n" . '		OpenTok.subscribeToStreams(event.streams);' . "\n" . "\n" . '		// attach the local webcam and microphone if detected' . "\n" . '		OpenTok.deviceManager.detectDevices();' . "\n" . '	},' . "\n" . "\n" . '	// send a signal to other parties' . "\n" . '	signal: function() {' . "\n" . '		if(OpenTok.session)' . "\n" . '			OpenTok.session.signal();' . "\n" . '	},' . "\n" . "\n" . '	// signal received, refresh the page' . "\n" . '	signalReceivedHandler: function(event) {' . "\n" . "\n" . '		// refresh the chat area' . "\n" . '		if(typeof Comments == "object")' . "\n" . '			Comments.subscribe();' . "\n" . '	},' . "\n" . "\n" . '	// i start to talk' . "\n" . '	startTalking: function() {' . "\n" . '		for(var i = 0; i < OpenTok.subscribers.length; i++) {' . "\n" . '			OpenTok.subscribers[i].subscribeToAudio(false);' . "\n" . '		}' . "\n" . '		OpenTok.publisher.publishAudio(true);' . "\n" . "\n" . '		document.getElementById("pushToTalk").onclick = OpenTok.stopTalking;' . "\n" . '		document.getElementById("pushToTalk").value = "' . i18n::s('Stop talking') . '";' . "\n";
     // identify the chairman or, if unknown, the owner of this page
     $chairman = array();
     if (isset($this->attributes['chairman']) && $this->attributes['chairman']) {
         $chairman = Users::get($this->attributes['chairman']);
     }
     if (!isset($chairman['id']) && ($owner = $this->anchor->get_value('owner_id'))) {
         $chairman = Users::get($owner);
     }
     // if this surfer is the chairman of this meeting, he will take over after three seconds of silence
     if (isset($chairman['id']) && Surfer::is($chairman['id'])) {
         $js_script .= 'OpenTok.watchdog = setInterval(function () {' . 'if(!$("#opentok .talker").length) {OpenTok.startTalking();}' . '}, 3000);' . "\n";
     }
     // end of javascript snippet
     $js_script .= '	},' . "\n" . "\n" . '	// i am back to listening mode' . "\n" . '	stopTalking: function() {' . "\n" . '		if(OpenTok.watchdog) { clearInterval(OpenTok.watchdog); OpenTok.watchdog = null; }' . "\n" . '		OpenTok.publisher.publishAudio(false);' . "\n" . '		for(var i = 0; i < OpenTok.subscribers.length; i++) {' . "\n" . '			OpenTok.subscribers[i].subscribeToAudio(true);' . "\n" . '		}' . "\n" . "\n" . '		document.getElementById("pushToTalk").onclick = OpenTok.startTalking;' . "\n" . '		document.getElementById("pushToTalk").value = "' . i18n::s('Start talking') . '";' . "\n" . '	},' . "\n" . "\n" . '	// display new streams on people arrival' . "\n" . '	streamCreatedHandler: function(event) {' . "\n" . '		OpenTok.subscribeToStreams(event.streams);' . "\n" . '	},' . "\n" . "\n" . '	// remove a stream that has been destroyed' . "\n" . '	streamDestroyedHandler: function(event) {' . "\n" . '		for(i = 0; i < event.streams.length; i++) {' . "\n" . '			var stream = event.streams[i];' . "\n" . '			$("#opentok_"+stream.streamId).remove();' . "\n" . '		}' . "\n" . '	},' . "\n" . "\n" . '	// a stream has started or stopped' . "\n" . '	streamPropertyChangedHandler: function(event) {' . "\n" . '		switch(event.changedProperty) {' . "\n" . '			case "hasAudio":' . "\n" . '				if(event.newValue) {' . "\n" . '					OpenTok.growl("' . i18n::s("%s is talking") . '".replace(/%s/, event.stream.name));' . "\n" . '					if(event.stream.connection.connectionId != OpenTok.session.connection.connectionId) {' . "\n" . '						$("#opentok_"+event.stream.streamId).addClass("talker");' . "\n" . '						OpenTok.stopTalking();' . "\n" . '					} else {' . "\n" . '						$("#opentok .me .frame").addClass("talker");' . "\n" . '					}' . "\n" . '				} else {' . "\n" . '					OpenTok.growl("' . i18n::s("%s is listening") . '".replace(/%s/, event.stream.name));' . "\n" . '					if(event.stream.connection.connectionId != OpenTok.session.connection.connectionId) {' . "\n" . '						$("#opentok_"+event.stream.streamId).removeClass("talker");' . "\n" . '					} else {' . "\n" . '						$("#opentok .me .frame").removeClass("talker");' . "\n" . '					}' . "\n" . '				}' . "\n" . '				break;' . "\n" . '			case "hasVideo":' . "\n" . '				if(!event.newValue) {' . "\n" . '					OpenTok.growl("' . i18n::s("%s is not visible") . '".replace(/%s/, event.stream.name));' . "\n" . '				}' . "\n" . '				break;' . "\n" . '		}' . "\n" . '	},' . "\n" . "\n" . '	// add new streams to the user interface' . "\n" . '	subscribeToStreams: function(streams) {' . "\n" . "\n" . '		// some remote stream in the list?' . "\n" . '		for(i = 0; i < streams.length; i++) {' . "\n" . '			if(streams[i].connection.connectionId != OpenTok.session.connection.connectionId) {' . "\n" . '				OpenTok.growl("' . i18n::s('Adding remote video streams') . '");' . "\n" . '				break;' . "\n" . '			}' . "\n" . '		}' . "\n" . "\n" . '		for(i = 0; i < streams.length; i++) {' . "\n" . '			var stream = streams[i];' . "\n" . "\n" . '			// subscribe to all streams, except my own camera' . "\n" . '			if(stream.connection.connectionId != OpenTok.session.connection.connectionId) {' . "\n" . "\n" . '				// create one div per subscribed stream and give it the id of the stream' . "\n" . '				$("#opentok .others").append(\'<span id="opentok_\'+stream.streamId+\'"><span id="placeholder"></span></span>\');' . "\n" . '				$("#opentok_"+stream.streamId).addClass("ibox subscriber").css({width: 120, height: 90 });' . "\n" . "\n" . '				// bind the stream to this div' . "\n" . '				var streamProps = {width: 120, height: 90, subscribeToAudio: true, subscribeToVideo: true};' . "\n" . '				OpenTok.subscribers[stream.streamId] = OpenTok.session.subscribe(stream, "placeholder", streamProps);' . "\n" . "\n" . '				// the remote stream is active' . "\n" . '				if(stream.hasAudio) {' . "\n" . '					OpenTok.growl("' . i18n::s("%s is talking") . '".replace(/%s/, stream.name));' . "\n" . '					$("#opentok_"+stream.streamId).addClass("talker");' . "\n" . '				}' . "\n" . "\n" . '			// the default is to push to talk' . "\n" . '			} else if(OpenTok.withAudio) {' . "\n" . '				$("#opentok .me").append(\'<div style="text-align: center; padding: 2px 0;">' . '<input type="button" id="pushToTalk" value="' . i18n::s('Start talking') . '" onClick="OpenTok.startTalking()" />' . '</div>\');' . "\n" . '				OpenTok.growl("' . i18n::s("Click on the button before talking") . '");' . "\n" . '			}' . "\n" . '		}' . "\n" . '		$("#opentok .me .frame").addClass("subscriber").css({width: 120, height: 90});' . "\n" . '		$("#description").focus();' . "\n" . '	}' . "\n" . "\n" . '}' . "\n" . "\n" . '// bind to OpenTok' . "\n" . '$(document).ready(OpenTok.initialize);' . "\n" . "\n";
     Page::insert_script($js_script);
     // video streams are put above the chat area
     $text = '<div id="opentok">' . '<div class="growl" style="height: 1.6em;" > </div>' . '<table class="layout"><tr>' . '<td class="me"></td>' . '<td class="others"></td>' . '</tr></table>' . '</div>' . "\n";
     return $text;
 }
Example #21
0
File: check.php Project: rair/yacs
                }
            } 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
    $menu = array('comments/' => i18n::s('Threads'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // which check?
} else {
    // the splash message
    $context['text'] .= '<p>' . i18n::s('Please select the action to perform.') . "</p>\n";
    // the form
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form">';
    // look for orphan articles
    $context['text'] .= '<p><input type="radio" name="action" id="action" value="orphans" /> ' . i18n::s('Look for orphan records') . '</p>';
    // the submit button
    $context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Start')) . '</p>' . "\n";
    // end of the form
    $context['text'] .= '</form>';
    // set the focus on the button
    Page::insert_script('$("#action").focus();');
}
// render the skin
render_skin();
Example #22
0
File: search.php Project: rair/yacs
    $last_offset = $offset;
    foreach ($result as $item) {
        $items[] = $item[1];
        $last_offset = $item[0];
    }
    // avoid that the first item of the next slice is the last item of current slice
    $last_offset -= 1.0E-13;
    // stack all results
    $text = Skin::finalize_list($items, 'rows');
    // offer to fetch more results
    if ($more_results) {
        // make a valid id
        $id = str_replace('.', '_', $last_offset);
        // the button to get more results
        $text .= '<div style="margin-top: 1em; text-align: center;" id="div' . $id . '"><a href="#" class="button wide" id="a' . $id . '">' . i18n::s('Get more results') . '</a></div>';
        Page::insert_script('$(function(){' . '$("#div' . $id . ' a").click( function() {' . 'Yacs.update("div' . $id . '", "' . $context['self_url'] . '", {' . 'data: "offset=' . $last_offset . '",' . 'complete: function() {' . 'setTimeout(function() {$("#div' . $id . '").animate({"marginTop":0})}, 500); ' . '}' . '});' . 'return false;' . '});' . '});');
    }
    // return a slice of results to update the search page through ajax call
    if ($offset < 1.0) {
        echo $text;
        return;
    }
} else {
    $text = sprintf(i18n::s('<p>No page has been found. This will happen with very short words (less than %d letters), that are not fully indexed. This can happen as well if more than half of pages contain the searched words. Try to use most restrictive words and to suppress "noise" words.</p>'), MINIMUM_TOKEN_SIZE) . "\n";
}
// in a separate panel
$panels[] = array('results', i18n::s('Results'), 'result', $text);
// add an extra panel
if (isset($context['skins_delegate_search']) && $context['skins_delegate_search'] == 'X') {
    $text = '';
    // typically, a form and a button to search at another place
Example #23
0
 /**
  * list users
  *
  * @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 (!($count = SQL::count($result))) {
         return $text;
     }
     // allow for several lists in the same page
     static $serial;
     if (isset($serial)) {
         $serial++;
     } else {
         $serial = 1;
     }
     // don't blast too many people
     if ($count > 100) {
         $checked = '';
     } elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') {
         $checked = '';
     } else {
         $checked = ' checked="checked"';
     }
     // div prefix
     $text .= '<div id="users_as_mail_panel_' . $serial . '">';
     // allow to select/deslect multiple rows at once
     $text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR;
     // process all items in the list
     $count = 0;
     while ($item = SQL::fetch($result)) {
         // we need some address
         if (!$item['email']) {
             continue;
         }
         // do not write to myself
         if ($item['id'] == Surfer::get_id()) {
             continue;
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'user:'******'id']);
         // column to select the row
         $text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />';
         // signal restricted and private users
         if ($item['active'] == 'N') {
             $text .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $text .= RESTRICTED_FLAG;
         }
         // the url to view this item
         $url = Users::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['full_name']);
         }
         // sanity check
         if (!$title) {
             $title = $item['nick_name'];
         }
         // link to this page
         $text .= Skin::build_link($url, $title, 'user');
         // the introductory text
         if ($item['introduction']) {
             $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>';
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('list', $item);
         }
         // display all tags
         if ($item['tags']) {
             $text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>';
         }
         // append the row
         $text .= BR;
         $count++;
     }
     // the script used to check all items at once
     Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . '	$(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // div suffix
     $text .= '</div>';
     // no valid account has been found
     if (!$count) {
         $text = '';
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #24
0
File: new.php Project: rair/yacs
    $input .= '/> ' . i18n::s('Community - Access is granted to any identified surfer') . ' ' . BR . '<input type="radio" name="active" value="N"';
    if (isset($item['active']) && $item['active'] == 'N') {
        $input .= ' checked="checked"';
    }
    $input .= '/> ' . i18n::s('Private - Access is restricted to selected persons');
    $fields[] = array($label, $input);
    // actually build the form
    $context['text'] .= Skin::build_form($fields);
    $fields = array();
    //
    // bottom commands
    //
    $menu = array();
    // the submit button
    $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
    // cancel button
    if (Surfer::get_id()) {
        $menu[] = Skin::build_link(Users::get_url(Surfer::get_id()), i18n::s('Back to my profile'), 'span');
    }
    // insert the menu in the page
    $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
    // end of the form
    $context['text'] .= '</div></form>';
    // append the script used for data checking on the browser
    Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	if(!container.title.value) {' . "\n" . '		alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	return true;' . "\n" . '}' . "\n" . 'func' . 'tion detectChanges() {' . "\n" . '	$("form#main_form input").each(function () {' . "\n" . '		$(this).change(function() { $("#preferred_editor").attr("disabled", true); });' . "\n" . '	});' . "\n" . "\n" . '	$("form#main_form textarea").each(function () {;' . "\n" . '		$(this).change(function() { $("#preferred_editor").attr("disabled", true); });' . "\n" . '	});' . "\n" . "\n" . '	$("form#main_form select").each(function () {;' . "\n" . '		$(this).change(function() { $("#preferred_editor").attr("disabled", true); });' . "\n" . '	});' . "\n" . '}' . "\n" . "\n" . '$(document).ready( detectChanges);' . "\n" . "\n" . '$("#title").focus();' . "\n");
    // general help on this form
    $help = '<p>' . sprintf(i18n::s('%s and %s are available to enhance text rendering.'), Skin::build_link('codes/', 'YACS codes', 'open'), Skin::build_link('smileys/', 'smileys', 'open')) . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
}
// render the skin
render_skin();
Example #25
0
File: delete.php Project: rair/yacs
        }
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
} else {
    // commands
    $menu = array();
    $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this table'), NULL, NULL, 'confirmed');
    if (is_object($anchor)) {
        $menu[] = Skin::build_link($anchor->get_url(), i18n::s('Cancel'), 'span');
    }
    // the submit button
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n";
    // set the focus
    Page::insert_script('$("#confirmed").focus();');
    // the title of the table
    if (isset($item['title'])) {
        $context['text'] .= Skin::build_block($item['title'], 'title');
    }
    // display the full text
    $context['text'] .= Skin::build_block($item['description'], 'description');
    // execute the query string to build the table
    if (isset($item['query']) && $item['query']) {
        $context['text'] .= Tables::build($item['id'], 'sortable');
    }
    // display the query string, if any
    if (isset($item['query']) && $item['query']) {
        $context['text'] .= BR . '<pre>' . $item['query'] . '</pre>' . BR . "\n";
    }
    // details
Example #26
0
    // the submit button
    $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
    // control panel
    if (file_exists('../parameters/control.include.php')) {
        $menu[] = Skin::build_link('control/', i18n::s('Control Panel'), 'span');
    }
    // all skins
    if (file_exists('../parameters/control.include.php')) {
        $menu[] = Skin::build_link('feeds/', i18n::s('Information channels'), 'span');
    }
    // insert the menu in the page
    $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
    // end of the form
    $context['text'] .= '</div></form>';
    // set the focus
    Page::insert_script('$("#channel_title").focus();');
    // general help on this form
    $help = '<p>' . sprintf(i18n::s('To ban some hosts or domains, go to the %s.'), Skin::build_link('servers/configure.php', i18n::s('configuration panel for servers'), 'shortcut')) . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
    // no modifications in demo mode
} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // save updated parameters
} else {
    // backup the old version
    Safe::unlink($context['path_to_root'] . 'parameters/feeds.include.php.bak');
    Safe::rename($context['path_to_root'] . 'parameters/feeds.include.php', $context['path_to_root'] . 'parameters/feeds.include.php.bak');
    // minimum values
    if ($_REQUEST['minutes_between_feeds'] < 5) {
        $_REQUEST['minutes_between_feeds'] = 5;
Example #27
0
File: new.php Project: rair/yacs
    // letter recipients
    $label = i18n::s('Recipients');
    $input = '<input type="radio" name="letter_recipients" size="40" value="all" checked="checked" /> ' . i18n::s('All subscribers of the community') . BR . "\n";
    $input .= '<input type="radio" name="letter_recipients" size="40" value="members" /> ' . i18n::s('Members only') . BR . "\n";
    $input .= '<input type="radio" name="letter_recipients" size="40" value="associates" /> ' . i18n::s('Associates only') . BR . "\n";
    $input .= '<input type="radio" name="letter_recipients" size="40" value="custom" /> ' . i18n::s('Specific addresses:') . ' <input type="text" name="mail_to"  onfocus="document.main_form.letter_recipients[3].checked=\'checked\'" size="40" />' . BR . "\n";
    $hint = i18n::s('The recipients that will receive the letter');
    $fields[] = array($label, $input, $hint);
    // build the form
    $context['text'] .= Skin::build_form($fields);
    // the submit button
    $context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Send'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
    // end of the form
    $context['text'] .= '</div></form>';
    // the script used for form handling at the browser
    Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	// letter_title is mandatory' . "\n" . '	if(!container.letter_title.value) {' . "\n" . '		alert("' . i18n::s('No title has been provided.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	return true;' . "\n" . '}' . "\n" . "\n" . 'document.main_form.letter_title.focus();' . "\n");
    // no mail in demo mode
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' && file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // handle posted data
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    // ensure all letters will be sent even if the browser connection dies
    Safe::ignore_user_abort(TRUE);
    // always archive the letter
    $anchor = Sections::lookup('letters');
    // no section yet, create one
    if (!$anchor) {
        $context['text'] .= i18n::s('Creating a section for archived letters') . BR . "\n";
        $fields['nick_name'] = 'letters';
        $fields['title'] = i18n::c('Archived letters');
Example #28
0
File: query.php Project: rair/yacs
    $fields[] = array($label, $input, $hint);
    // build the form
    $context['text'] .= Skin::build_form($fields);
    // bottom commands
    $menu = array();
    // the submit button
    $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
    // step back
    if (isset($_SERVER['HTTP_REFERER'])) {
        $menu[] = Skin::build_link($_SERVER['HTTP_REFERER'], i18n::s('Cancel'), 'span');
    }
    // display the menu
    $context['text'] .= Skin::finalize_list($menu, 'menu_bar');
    // end of the form
    $context['text'] .= '</div></form>';
    // append the script used for data checking on the browser
    Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . '	if(!container.edit_name.value) {' . "\n" . '		alert("' . i18n::s('Please give your first and last names') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	if(!container.edit_address.value) {' . "\n" . '		alert("' . i18n::s('Please give your e-mail address') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . '	if(!container.title.value) {' . "\n" . '		alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . "\n" . '	if(container.description.value.length > 64000){' . "\n" . '		alert("' . i18n::s('The description should not exceed 64000 characters.') . '");' . "\n" . '		Yacs.stopWorking();' . "\n" . '		return false;' . "\n" . '	}' . "\n" . "\n" . '	return true;' . "\n" . '}' . "\n" . '$("#edit_name").focus();' . "\n");
    // general help on this form
    $text = i18n::s('<p>Use this form to submit any kind of request you can have, from simple suggestions to complex questions.</p><p>Hearty discussion and unpopular viewpoints are welcome, but please keep queries civil. Flaming, trolling, and smarmy queries are discouraged and may be deleted. In fact, we reserve the right to delete any post for any reason. Don\'t make us do it.</p>');
    if (Surfer::is_associate()) {
        $text .= '<p>' . i18n::s('If you paste some existing HTML content and want to avoid the implicit formatting insert the code <code>[formatted]</code> at the very beginning of the description field.');
    } else {
        $text .= '<p>' . i18n::s('Most HTML tags are removed.');
    }
    $text .= ' ' . sprintf(i18n::s('You can use %s to beautify your post'), Skin::build_link('codes/', i18n::s('YACS codes'), 'open')) . '.</p>';
    // locate mandatory fields
    $text .= '<p>' . i18n::s('Mandatory fields are marked with a *') . '</p>';
    $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $text, 'boxes', 'help');
}
// render the skin
render_skin();
Example #29
0
 /**
  * main function to render layout
  * 
  * @param type $result MySQL object
  * @return string the rendering
  */
 public function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // type of listed object
     $items_type = $this->listed_type;
     // this level root reference
     if (isset($this->focus) && $this->focus) {
         $root_ref = $this->focus;
     } elseif (isset($context['current_item']) && $context['current_item']) {
         $root_ref = $context['current_item'];
     } else {
         $root_ref = $items_type . ':index';
     }
     $this->tree_only = $this->has_variant('tree_only');
     // drag&drop zone
     $text .= '<div class="tm-ddz tm-drop" data-ref="' . $root_ref . '" data-variant="' . $this->layout_variant . '" >' . "\n";
     // root create command
     $text .= $this->btn_create();
     // root ul
     $text .= '<ul class="tm-sub_elems tm-root">' . "\n";
     while ($item = SQL::fetch($result)) {
         // get the object interface, this may load parent and overlay
         $entity = new $items_type($item);
         // title
         $title = '<a class="tm-zoom" href="' . $entity->get_permalink() . '"><span class="tm-folder">' . $entity->get_title() . '</span></a>';
         // sub elements of this entity
         $sub = $this->get_sub_level($entity);
         // command related to this entity
         $cmd = $this->get_interactive_menu();
         // one <li> per entity of this level of the tree
         $text .= '<li class="tm-drag tm-drop" data-ref="' . $entity->get_reference() . '">' . $title . $cmd . $sub . '</li>' . "\n";
     }
     // this level may have childs that are not folders (exept index)
     // do not search in variant tree_only is setted
     if (!preg_match('/index$/', $root_ref) && !$this->tree_only) {
         $thislevel = Anchors::get($root_ref);
         $text .= $this->get_sub_level($thislevel, true);
         // do not search for folders
     }
     // we have bound styles and scripts, but do not provide on ajax requests
     if (!isset($context['AJAX_REQUEST']) || !$context['AJAX_REQUEST']) {
         $this->load_scripts_n_styles();
         // init js depending on user privilege for this level
         if (isset($thislevel)) {
             // get surfer privilege for this level
             $powered = $thislevel->allows('creation');
         } else {
             $powered = Surfer::is_associate();
         }
         $powered = $powered ? 'powered' : '';
         // cast to string
         Page::insert_script('TreeManager.init("' . $powered . '");');
     }
     // end drag drop zone
     $text .= '</ul></div>' . "\n";
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #30
0
// display a specific form
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>';
$label = i18n::s('Server address');
$input = '<input type="text" name="target" id="target" size="30" maxlength="128" value="' . encode_field($target) . '" />' . "\n" . ' ' . Skin::build_submit_button(i18n::s('Go'));
$hint = i18n::s('The name or the IP address of the yacs server');
$fields[] = array($label, $input, $hint);
$label = i18n::s('User name');
$input = '<input type="text" name="user_name" size="30" maxlength="128" value="' . encode_field($user_name) . '" />';
$fields[] = array($label, $input);
$label = i18n::s('User password');
$input = '<input type="password" name="user_password" size="30" maxlength="128" value="' . $user_password . '" />';
$fields[] = array($label, $input);
$context['text'] .= Skin::build_form($fields);
$context['text'] .= '</div></form>';
// set the focus at the first field
Page::insert_script('$("#target").focus();');
// do the test
if (isset($_REQUEST['target'])) {
    // call blog web service
    $url = 'http://' . $_REQUEST['target'] . '/services/blog.php';
    // blogger.getUserInfo
    $context['text'] .= Skin::build_block('blogger.getUserInfo', 'title');
    $parameters = array('dummy_appkey', $user_name, $user_password);
    $result = Call::invoke($url, 'blogger.getUserInfo', $parameters, 'XML-RPC');
    $status = @$result[0];
    $data = @$result[1];
    // display call result
    if (!$status) {
        $context['text'] .= $data;
    } elseif (is_array($data) && isset($data['faultString']) && $data['faultString']) {
        $context['text'] .= $data['faultString'];