Beispiel #1
0
<?php

loader_import('saf.Misc.RPC');
echo rpc_init('
	if (arguments[0] == false) {
		alert ("' . intl_get('Error adding bookmark!') . '");
	} else {
		alert ("' . intl_get('Bookmark added.') . '");
	}
');
loader_import('saf.GUI.Prompt');
echo template_simple('bookmark_button.spt');
Beispiel #2
0
    /**
     * Returns the display HTML for this widget.  The optional
     * parameter determines whether or not to automatically display the widget
     * nicely, or whether to simply return the widget (for use in a template).
     * 
     * @access	public
     * @param	boolean	$generate_html
     * @return	string
     * 
     */
    function display($generate_html = 0)
    {
        $data = '';
        $attrstr = $this->getAttrs();
        $selected = explode(',', $this->data_value);
        loader_import('saf.Misc.RPC');
        echo rpc_init('return false');
        $this->size = false;
        $this->multiple = false;
        if ($this->size) {
            $multiple = ' size="' . $this->size . '"';
            $braces = '';
            if ($this->multiple) {
                $multiple = ' multiple="multiple"' . $multiple;
                $braces = '[]';
            }
        } else {
            $multiple = '';
            $braces = '';
        }
        loader_import('saf.GUI.Prompt');
        page_add_script('
			var cms_' . $this->name . '_form = false;
			var cms_' . $this->name . '_elem = false;
			var cms_' . $this->name . '_action = false;
			var cms_' . $this->name . '_oldhandler;

			//var rpc_handler = new Function ("if (arguments[0] == true) { if (cms_' . $this->name . '_action == \'add\') { cms_' . $this->name . '_add_item (); } else { cms_' . $this->name . '_remove_item (); } } else { if (cms_' . $this->name . '_action == \'add\') { cms_' . $this->name . '_add_alert (); } else { cms_' . $this->name . '_remove_alert (); } }");

			function cms_' . $this->name . '_add_item (res) {
				if (res == false) {
					cms_' . $this->name . '_add_alert ();
					return;
				}

				f = cms_' . $this->name . '_form;
				words = cms_' . $this->name . '_elem;

				// 2. add the selected keywords to the list
				for (i = 0; i < words.length; i++) {
					if (document.all) {
						f.elements[\'' . $this->name . $braces . '\'].options[f.elements[\'' . $this->name . $braces . '\'].options.length + 1] = new Option ("/" + words[i], words[i], false, true);
					} else {
						o = document.createElement (\'option\');
						o.text = words[i];
						o.value = words[i];
						f.elements[\'' . $this->name . $braces . '\'].add (o, null);
					}
				}

				rpc_handler = null;
				rpc_handler = cms_' . $this->name . '_oldhandler;
			}

			function cms_' . $this->name . '_remove_item (res) {
				if (res == false) {
					cms_' . $this->name . '_remove_alert ();
					return;
				}

				f = cms_' . $this->name . '_form;

				// 2. remove the selected keywords from the list
				for (i = f.elements[\'' . $this->name . $braces . '\'].options.length - 1; i >= 0; i--) {
					if (f.elements[\'' . $this->name . $braces . '\'].options[i].selected) {
						// remove
						if (document.all) {
							f.elements[\'' . $this->name . $braces . '\'].options.remove (i);
						} else {
							f.elements[\'' . $this->name . $braces . '\'].options[i] = null;
						}
						break;
					}
				}

				rpc_handler = null;
				rpc_handler = cms_' . $this->name . '_oldhandler;
			}

			function cms_' . $this->name . '_add_alert () {
				alert (\'Failed to add folder: Permission denied.  Please check your server permissions and try again.\');
			}

			function cms_' . $this->name . '_remove_alert () {
				alert (\'Failed to remove folder: Permission denied.  Please check that the selected folder is empty, and that your server permissions are correct, and try again.\');
			}

			function cms_' . $this->name . '_add (f) {
				cms_' . $this->name . '_form = f;

				// 0. collect our new items(s) from the user
				prompt (
					\'New folder(s) -- separate multiple with commas (one, two, three)\',
					\'\',
					function (word) {
						if (word == null || word.length == 0) {
							return false;
						}
						words = word.split (/, ?/);

						cms_' . $this->name . '_oldhandler = rpc_handler;
						rpc_handler = null;
						rpc_handler = cms_' . $this->name . '_add_item;

						// 1. call {site/prefix}/index/' . str_replace('/', '-', $this->addAction) . '-action in a popup
						cms_' . $this->name . '_form = f;
						cms_' . $this->name . '_elem = words;
						cms_' . $this->name . '_action = "add";

						rpc_handler = new Function ("if (arguments[0] == true) { if (cms_' . $this->name . '_action == \'add\') { cms_' . $this->name . '_add_item (); } else { cms_' . $this->name . '_remove_item (); } } else { if (cms_' . $this->name . '_action == \'add\') { cms_' . $this->name . '_add_alert (); } else { cms_' . $this->name . '_remove_alert (); } }");

						rpc_call (\'' . site_prefix() . '/index/' . str_replace('/', '-', $this->addAction) . '-action?path=' . $this->basedir . '&items=\' + word);
					}
				);

				// 3. cancel the click
				return false;
			}

			function cms_' . $this->name . '_remove (f) {
				// 0. collect the selected items from the "items" field
				word = \'\';
				sep = \'\';
				for (i = 0; i < f.elements[\'' . $this->name . $braces . '\'].options.length; i++) {
					if (f.elements[\'' . $this->name . $braces . '\'].options[i].selected) {
						word = word + sep + f.elements[\'' . $this->name . $braces . '\'].options[i].value;
						sep = \',\';
					}
				}

				// 0.1. confirm that they want to delete the selected list
				c = confirm (\'' . intl_get('Are you sure you want to remove this folder?') . '  \' + word);
				if (! c) {
					return false;
				}

				cms_' . $this->name . '_oldhandler = rpc_handler;
				rpc_handler = null;
				rpc_handler = cms_' . $this->name . '_remove_item;

				// 1. call {site/prefix}/index/' . str_replace('/', '-', $this->addAction) . '-action in a popup
				cms_' . $this->name . '_form = f;
				cms_' . $this->name . '_action = "remove";
				rpc_call (\'' . site_prefix() . '/index/' . str_replace('/', '-', $this->removeAction) . '-action?path=' . $this->basedir . '&items=\' + word);

				// 3. cancel the click
				return false;
			}
		');
        if ($generate_html) {
            $data .= '<tr>
				<td class="label"' . $this->invalid() . ' valign="top">
					<label for="' . $this->name . '" id="' . $this->name . '-label">' . template_simple($this->label_template, $this, '', true) . '</label>
				</td>
				<td class="field">
					<table border="0" cellpadding="3" cellspacing="0">
						<tr>
							<td valign="top">
					<select name="' . $this->name . $braces . '" ' . $multiple . $attrstr . ' ' . $this->extra . '>' . NEWLINE;
            foreach ($this->getList() as $k => $v) {
                $data .= TABx2 . TABx2 . TABx2 . '<option value="' . $k . '"';
                if (in_array($k, $selected)) {
                    $data .= ' selected="selected"';
                }
                $data .= '>' . $v . '</option>' . NEWLINE;
            }
            $data .= '</select>
							</td>
							<td valign="top" width="100%">
					<input type="submit" value="' . intl_get('Add') . '" onclick="return cms_' . $this->name . '_add (this.form)" /><br />
					<input type="submit" value="' . intl_get('Remove') . '" onclick="return cms_' . $this->name . '_remove (this.form)" />
							</td>
						</tr>
					</table>
				</td>
			</tr>' . NEWLINEx2;
        } else {
        }
        return $data;
    }
Beispiel #3
0
    /**
     * Returns the display HTML for this widget.  The optional
     * parameter determines whether or not to automatically display the widget
     * nicely, or whether to simply return the widget (for use in a template).
     * 
     * @access	public
     * @param	boolean	$generate_html
     * @return	string
     * 
     */
    function display($generate_html = 0)
    {
        $data = '';
        $attrstr = $this->getAttrs();
        $selected = explode(',', $this->data_value);
        loader_import('saf.Misc.RPC');
        echo rpc_init('return false');
        $mult = 'false';
        if ($this->size) {
            $multiple = ' size="' . $this->size . '"';
            $braces = '';
            if ($this->multiple) {
                $multiple = ' multiple="multiple"' . $multiple;
                $braces = '[]';
                $mult = 'true';
            }
        } else {
            $multiple = '';
            $braces = '';
        }
        if (session_is_resource($this->table) && !session_allowed($this->table, 'rw', 'resource')) {
            $allowed = false;
        } else {
            $allowed = true;
        }
        if ($allowed) {
            loader_import('saf.GUI.Prompt');
            if ($this->title) {
                page_add_script('
			var cms_' . $this->name . '_form;

			var cms_' . $this->name . '_oldhandler;

			function cms_' . $this->name . '_add_handler (words) {
				f = cms_' . $this->name . '_form;

				// 2. add the selected keywords to the list
				for (i = 0; i < words.length; i++) {
					if (document.all) {
						f.elements[\'' . $this->name . $braces . '\'].options[f.elements[\'' . $this->name . $braces . '\'].options.length + 1] = new Option (words[i].text, words[i].value, false, true);
					} else {
						o = document.createElement (\'option\');
						o.text = words[i].text;
						o.value = words[i].value;
						f.elements[\'' . $this->name . $braces . '\'].add (o, null);
					}
				}

				rpc_handler = null;
				rpc_handler = cms_' . $this->name . '_oldhandler;
			}

			function cms_' . $this->name . '_add (f) {
				cms_' . $this->name . '_form = f;

				// 0. collect our new items(s) from the user
				prompt (
					\'New items(s) -- separate multiple with commas (one, two, three)\',
					\'\',
					function (word) {
						if (word == null || word.length == 0 || word == false) {
							return false;
						}
						words = word.split (/, ?/);

						cms_' . $this->name . '_oldhandler = rpc_handler;
						rpc_handler = null;
						rpc_handler = cms_' . $this->name . '_add_handler;

						// 1. call {site/prefix}/index/' . str_replace('/', '-', $this->addAction) . '-action in a popup
						rpc_call (\'' . site_prefix() . '/index/' . str_replace('/', '-', $this->addAction) . '-action?table=' . $this->table . '&key=' . $this->key . '&title=' . $this->title . '&items=\' + word);
					}
				);

				// 3. cancel the click
				return false;
			}

			function cms_' . $this->name . '_remove (f) {
				// 0. collect the selected items from the "items" field
				word = \'\';
				show = \'\';
				sep = \'\';
				for (i = 0; i < f.elements[\'' . $this->name . $braces . '\'].options.length; i++) {
					if (f.elements[\'' . $this->name . $braces . '\'].options[i].selected) {
						word = word + sep + f.elements[\'' . $this->name . $braces . '\'].options[i].value;
						show = show + sep + f.elements[\'' . $this->name . $braces . '\'].options[i].text;
						sep = \',\';
					}
				}

				// 0.1. confirm that they want to delete the selected list
				c = confirm (\'' . intl_get('Are you sure you want to remove these items?') . '  \' + show);
				if (! c) {
					return false;
				}

				// 1. call {site/prefix}/index/' . str_replace('/', '-', $this->addAction) . '-action in a popup
				rpc_call (\'' . site_prefix() . '/index/' . str_replace('/', '-', $this->removeAction) . '-action?table=' . $this->table . '&key=' . $this->key . '&title=' . $this->title . '&items=\' + word);

				// 2. remove the selected keywords from the list
				multiple = ' . $mult . ';
				for (i = f.elements[\'' . $this->name . $braces . '\'].options.length - 1; i >= 0; i--) {
					if (f.elements[\'' . $this->name . $braces . '\'].options[i].selected) {
						// remove
						if (document.all) {
							f.elements[\'' . $this->name . $braces . '\'].options.remove (i);
						} else {
							f.elements[\'' . $this->name . $braces . '\'].options[i] = null;
						}
						if (! multiple) {
							break;
						}
					}
				}

				// 3. cancel the click
				return false;
			}
		');
            } else {
                page_add_script('
			function cms_' . $this->name . '_add (f) {
				cms_' . $this->name . '_form = f;

				// 0. collect our new items(s) from the user
				prompt (
					\'New items(s) -- separate multiple with commas (one, two, three)\',
					\'\',
					function (word) {
						if (word == null || word.length == 0 || word == false) {
							return false;
						}
						words = word.split (/, ?/);

						f = cms_' . $this->name . '_form;

						// 1. call {site/prefix}/index/' . str_replace('/', '-', $this->addAction) . '-action in a popup
						rpc_call (\'' . site_prefix() . '/index/' . str_replace('/', '-', $this->addAction) . '-action?table=' . $this->table . '&key=' . $this->key . '&items=\' + word);

						// 2. add the selected keywords to the list
						for (i = 0; i < words.length; i++) {
							if (document.all) {
								f.elements[\'' . $this->name . $braces . '\'].options[f.elements[\'' . $this->name . $braces . '\'].options.length + 1] = new Option (words[i], words[i], false, true);
							} else {
								o = document.createElement (\'option\');
								o.text = words[i];
								o.value = words[i];
								f.elements[\'' . $this->name . $braces . '\'].add (o, null);
							}
						}
					}
				);

				// 3. cancel the click
				return false;
			}

			function cms_' . $this->name . '_remove (f) {
				// 0. collect the selected items from the "items" field
				word = \'\';
				sep = \'\';
				for (i = 0; i < f.elements[\'' . $this->name . $braces . '\'].options.length; i++) {
					if (f.elements[\'' . $this->name . $braces . '\'].options[i].selected) {
						word = word + sep + f.elements[\'' . $this->name . $braces . '\'].options[i].value;
						sep = \',\';
					}
				}

				// 0.1. confirm that they want to delete the selected list
				c = confirm (\'' . intl_get('Are you sure you want to remove these items?') . '  \' + word);
				if (! c) {
					return false;
				}

				// 1. call {site/prefix}/index/' . str_replace('/', '-', $this->addAction) . '-action in a popup
				rpc_call (\'' . site_prefix() . '/index/' . str_replace('/', '-', $this->removeAction) . '-action?table=' . $this->table . '&key=' . $this->key . '&items=\' + word);

				// 2. remove the selected keywords from the list
				multiple = ' . $mult . ';
				for (i = f.elements[\'' . $this->name . $braces . '\'].options.length - 1; i >= 0; i--) {
					if (f.elements[\'' . $this->name . $braces . '\'].options[i].selected) {
						// remove
						if (document.all) {
							f.elements[\'' . $this->name . $braces . '\'].options.remove (i);
						} else {
							f.elements[\'' . $this->name . $braces . '\'].options[i] = null;
						}
						if (! multiple) {
							break;
						}
					}
				}

				// 3. cancel the click
				return false;
			}
		');
            }
            // end title
        }
        // end allowed
        if ($generate_html) {
            $data .= '<tr>
				<td class="label"' . $this->invalid() . ' valign="top">
					<label for="' . $this->name . '" id="' . $this->name . '-label">' . template_simple($this->label_template, $this, '', true) . '</label>
				</td>
				<td class="field">
					<table border="0" cellpadding="3" cellspacing="0">
						<tr>
							<td valign="top">
					<select name="' . $this->name . $braces . '" ' . $multiple . $attrstr . ' ' . $this->extra . '>' . NEWLINE;
            foreach ($this->getList() as $obj) {
                if (!$this->title) {
                    $key = $obj->{$this->key};
                    $keyword = $obj->{$this->key};
                } else {
                    $key = $obj->{$this->key};
                    $keyword = $obj->{$this->title};
                }
                $data .= TABx2 . TABx2 . TABx2 . '<option value="' . $key . '"';
                if (in_array($key, $selected)) {
                    $data .= ' selected="selected"';
                }
                $data .= '>' . $keyword . '</option>' . NEWLINE;
            }
            $data .= '</select>
							</td>' . NEWLINE;
            if ($allowed) {
                $data .= '				<td valign="top" width="100%">
					<input type="submit" value="' . intl_get('Add') . '" onclick="return cms_' . $this->name . '_add (this.form)" /><br />
					<input type="submit" value="' . intl_get('Remove') . '" onclick="return cms_' . $this->name . '_remove (this.form)" />
							</td>
						</tr>
					</table>
				</td>' . NEWLINE;
            } else {
                $data .= '</tr></table></td>';
            }
            $data .= '			</tr>' . NEWLINEx2;
        } else {
        }
        return $data;
    }
Beispiel #4
0
        } elseif ($rid > $res->revision) {
            $res->forward++;
            if ($res->next == 0 || $rid < $res->next) {
                $res->next = $rid;
            }
        }
    }
    if ($res->forward == 0) {
        $res->rollback = false;
        $res->editable = $level >= $res->edit_level ? true : false;
    }
} else {
    $res->revision = false;
    $res->editable = $level >= $res->edit_level ? true : false;
    $res->back = db_shift('select count(*) from sitewiki_page_sv where id = ?', $res->id);
    $res->back--;
    $res->prev = db_shift('select sv_autoid from sitewiki_page_sv where id = ? order by sv_autoid desc limit 1, 1', $res->id);
    $res->forward = 0;
    $res->next = false;
}
$res->linked_from = db_shift_array('select id from sitewiki_page where body like "%' . $res->id . '%" and id != ?', $res->id);
$res->files = db_fetch_array('select * from sitewiki_file where page_id = ? order by name asc', $res->id);
foreach (array_keys($res->files) as $k) {
    $res->files[$k]->size = filesize('inc/app/sitewiki/data/' . $res->id . '_' . $res->files[$k]->id);
}
loader_import('sitewiki.Filters');
loader_import('saf.Misc.RPC');
page_title(sitewiki_filter_id($res->id));
echo template_simple('page.spt', $res);
echo rpc_init();
//info ($res, true);
Beispiel #5
0
    /**
     * Returns the display HTML for this widget.  The optional
     * parameter determines whether or not to automatically display the widget
     * nicely, or whether to simply return the widget (for use in a template).
     * 
     * @access	public
     * @param	boolean	$generate_html
     * @return	string
     * 
     */
    function display($generate_html = 0)
    {
        $data = '';
        $attrstr = $this->getAttrs();
        $selected = explode(',', $this->data_value);
        loader_import('saf.Misc.RPC');
        echo rpc_init('return false');
        loader_import('saf.GUI.Prompt');
        page_add_script('
			var cms_' . $this->name . '_form;
			var cms_' . $this->name . '_oldhandler;

			function cms_position_add (f) {
				cms_' . $this->name . '_form = f;

				// 0. collect our new position(s) from the user
				prompt (
					\'New position(s) -- separate multiple with commas (one, two, three)\',
					\'\',
					function (word) {
						if (word == null || word.length == 0) {
							return false;
						}
						words = word.split (\',\');

						cms_' . $this->name . '_oldhandler = rpc_handler;
						rpc_handler = null;
						rpc_handler = cms_position_handler;

						// 1. call {site/prefix}/index/cms-sidebar-position-add-action in a popup
						//window.open (\'' . site_prefix() . '/index/cms-sidebar-position-add-action?name=\' + word, \'Position\', \'top=100,left=100,height=50,width=50\');
						rpc_call (\'' . site_prefix() . '/index/cms-sidebar-position-add-action?name=\' + word);

						// 2. add the selected keywords to the list
						for (i = 0; i < words.length; i++) {
							if (document.all) {
								f.elements[\'position\'].options[f.elements[\'position\'].options.length + 1] = new Option (words[i], words[i], false, true);
							} else {
								o = document.createElement (\'option\');
								o.text = words[i];
								o.value = words[i];
								f.elements[\'position\'].add (o, null);
							}
						}
					}
				);

				// 3. cancel the click
				return false;
			}

			function cms_position_handler () {
				rpc_handler = null;
				rpc_handler = cms_' . $this->name . '_oldhandler;
			}

			function cms_position_remove (f) {
				// 0. collect the selected positions from the "position" field
				word = \'\';
				sep = \'\';
				for (i = 0; i < f.elements[\'position\'].options.length; i++) {
					if (f.elements[\'position\'].options[i].selected) {
						word = word + sep + f.elements[\'position\'].options[i].value;
						sep = \',\';
					}
				}

				// 0.1. confirm that they want to delete the selected list
				c = confirm (\'' . intl_get('Are you sure you want to remove this position?') . '  \' + word);
				if (! c) {
					return false;
				}

				// 1. call {site/prefix}/index/cms-sidebar-position-delete-action in a popup
				//window.open (\'' . site_prefix() . '/index/cms-sidebar-position-delete-action?name=\' + word, \'Position\', \'top=100,left=100,height=50,width=50\');
				rpc_call (\'' . site_prefix() . '/index/cms-sidebar-position-delete-action?name=\' + word);

				// 2. remove the selected keywords from the list
				for (i = f.elements[\'position\'].options.length - 1; i >= 0; i--) {
					if (f.elements[\'position\'].options[i].selected) {
						// remove
						if (document.all) {
							f.elements[\'position\'].options.remove (i);
						} else {
							f.elements[\'position\'].options[i] = null;
						}
						break;
					}
				}

				// 3. cancel the click
				return false;
			}
		');
        if ($generate_html) {
            $data .= '<tr>
				<td class="label"' . $this->invalid() . ' valign="top">
					<label for="' . $this->name . '" id="' . $this->name . '-label">' . template_simple($this->label_template, $this, '', true) . '</label>
				</td>
				<td class="field">
					<table border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td valign="top">
					<select name="' . $this->name . '" ' . $attrstr . ' ' . $this->extra . '>' . NEWLINE;
            foreach ($this->getPositions() as $keyword) {
                $data .= TABx2 . TABx2 . TABx2 . '<option value="' . $keyword . '"';
                if (in_array($keyword, $selected)) {
                    $data .= ' selected="selected"';
                }
                $data .= '>' . $keyword . '</option>' . NEWLINE;
            }
            $data .= '</select>
							</td>
							<td valign="top">
					<input type="submit" value="' . intl_get('Add') . '" onclick="return cms_position_add (this.form)" /><br />
					<input type="submit" value="' . intl_get('Remove') . '" onclick="return cms_position_remove (this.form)" />
							</td>
						</tr>
					</table>
				</td>
			</tr>' . NEWLINEx2;
        } else {
        }
        return $data;
    }