diff --git a/plugins/README b/plugins/README new file mode 100644 index 0000000000000000000000000000000000000000..af885acd08c034bd7d6d03687e1c77623e0c12d1 --- /dev/null +++ b/plugins/README @@ -0,0 +1 @@ +sym-link these plugins in the elgg/mod folder \ No newline at end of file diff --git a/plugins/flexfile/README.txt b/plugins/flexfile/README.txt new file mode 100755 index 0000000000000000000000000000000000000000..3c73f6bc8d027945f5e201a9179304985e15b7a0 --- /dev/null +++ b/plugins/flexfile/README.txt @@ -0,0 +1,57 @@ +/** + * Use form module to add fields to file upload forms and file views + * + * @package flexfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + +The Elgg 1.x flexfile plugin requires the form plugin. + +You can use the "Add form" link on the Manage forms page provided by +the form module to add fields to your file upload form and other file views. +Specify a "file" form when creating your form. + +If you specify a file form, the fields from this form will replace the current +tags field in the file upload form. This is so you can optionally have your +users select from a fixed vocabulary rather than use a free form tags box. + +You can also add other metadata fields (eg. original author and publication +date if the person uploading the document was not the original creator). + +This plugin will not affect the title, description or access boxes. + +You can optionally specify list and display templates if you want to add your new +fields to the list view used for searches or the view used to display a specific +file. If you do not supply these templates, these fields will appear only on the +file upload form. (These values will also affect the result of generic searches +if the user doing the search has access to that file.) + +You can, of course, include a tags box in your file form if you want to add tags +back to the file upload form. If you want it to be formatted in the same way as +in the standard file view, put this in your file form display template: + +<div class="filerepo_tags"> +{{$file_tags}} +</div> + +(assuming that your tags field is called "file tags"). + +Activating the flexfile plugin + +Create a file form as described above. More documentation on creating forms +is contained in the form plugin README.txt. + +Then extract the flexform plugin into the mod directory and activate it as +usual using the Elgg 1.x tool administration. + +Once activated, the file upload form should show the fields that you have +defined for your file form. + +You can safely activate the flexfile plugin even if you have not defined a +file form. If no file form is available, the flexfile profile will display the +standard file views unchanged. + diff --git a/plugins/flexfile/languages/en.php b/plugins/flexfile/languages/en.php new file mode 100755 index 0000000000000000000000000000000000000000..1c08b47299d433501045d3b546a500a97d157df2 --- /dev/null +++ b/plugins/flexfile/languages/en.php @@ -0,0 +1,10 @@ +<?php + + $english = array( + + 'flexfile:add_new_file_form_link' => "Add file form", + ); + + add_translation("en",$english); + +?> \ No newline at end of file diff --git a/plugins/flexfile/manifest.xml b/plugins/flexfile/manifest.xml new file mode 100755 index 0000000000000000000000000000000000000000..2ad0668deea9887c4c9c810af80d50a949f36e7b --- /dev/null +++ b/plugins/flexfile/manifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest> + <field key="author" value="Kevin Jardine <kevin@radagast.biz>" /> + <field key="version" value="0.8" /> + <field key="description" value="Elgg flexible file form plugin." /> + <field key="website" value="http://radagast.biz/" /> + <field key="copyright" value="(C) Radagast Solutions 2009" /> + <field key="licence" value="GNU Public License version 2" /> + <field key="elgg_version" value="2009030101" /> +</plugin_manifest> diff --git a/plugins/flexfile/models/model.php b/plugins/flexfile/models/model.php new file mode 100755 index 0000000000000000000000000000000000000000..f3071107dacf3045dfb285a6b0f786d6db9fe926 --- /dev/null +++ b/plugins/flexfile/models/model.php @@ -0,0 +1,35 @@ +<?php +/** + * Elgg flexfile plugin + * + * @package flexfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load form model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/model.php"); +// Load form profile model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/profile.php"); + +function flexfile_get_file_form($entity,$file_category='') { + return form_get_latest_public_profile_form(3,$file_category); +} + +function flexfile_add_fields($event,$object_type,$object) { + if ((($event == 'create') || ($event == 'update')) && ($object_type == 'object') && ($object->getSubtype() == 'file')) { + $form = flexfile_get_file_form($object,$object->file_category); + if ($form) { + $data = form_get_data_from_form_submit($form->getGUID()); + foreach ($data as $key => $value) { + $object->$key = $value; + } + } + } + + return $object; +} + +?> \ No newline at end of file diff --git a/plugins/flexfile/start.php b/plugins/flexfile/start.php new file mode 100755 index 0000000000000000000000000000000000000000..8023cbf22f34056b5407890e7f6e2ce3fc977dab --- /dev/null +++ b/plugins/flexfile/start.php @@ -0,0 +1,20 @@ +<?php + +/** + * Elgg flexfile plugin + * + * @package flexfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + +// Load flexfile model + require_once(dirname(__FILE__)."/models/model.php"); + + register_elgg_event_handler('create','object','flexfile_add_fields'); + register_elgg_event_handler('update','object','flexfile_add_fields'); + +?> \ No newline at end of file diff --git a/plugins/flexfile/views/default/file/upload.php b/plugins/flexfile/views/default/file/upload.php new file mode 100755 index 0000000000000000000000000000000000000000..4e349da5697d08336af981695ac1656a1583a6e7 --- /dev/null +++ b/plugins/flexfile/views/default/file/upload.php @@ -0,0 +1,133 @@ +<?php + /** + * Elgg file browser uploader + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.com/ + */ + + global $CONFIG; + + if (isset($vars['entity'])) { + $title = sprintf(elgg_echo("blog:editpost"),$object->title); + $action = "file/save"; + $title = $vars['entity']->title; + $description = $vars['entity']->description; + $tags = $vars['entity']->tags; + $access_id = $vars['entity']->access_id; + } else { + $title = elgg_echo("blog:addpost"); + $action = "file/upload"; + $tags = ""; + $title = ""; + $description = ""; + $access_id = get_default_access(); + } + +?> +<div class="contentWrapper"> +<form action="<?php echo $vars['url']; ?>action/<?php echo $action; ?>" enctype="multipart/form-data" method="post"> +<?php + + if ($action == "file/upload") { + +?> + <p> + <label><?php echo elgg_echo("file:file"); ?><br /> + <?php + + echo elgg_view("input/file",array('internalname' => 'upload')); + + ?> + </label> + </p> +<?php + + } + +?> + <p> + <label><?php echo elgg_echo("title"); ?><br /> + <?php + + echo elgg_view("input/text", array( + "internalname" => "title", + "value" => $title, + )); + + ?> + </label> + </p> + <p> + <label><?php echo elgg_echo("description"); ?><br /> + <?php + + echo elgg_view("input/longtext",array( + "internalname" => "description", + "value" => $description, + )); + ?> + </label> + </p> + + <?php + $form = flexfile_get_file_form($vars['entity']); + if ($form) { + $tab_data = form_get_data_for_profile_edit_form($form, $vars['entity']); + + echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0)); + } else { + ?> + <p> + <label><?php echo elgg_echo("tags"); ?><br /> + <?php + + echo elgg_view("input/tags", array( + "internalname" => "tags", + "value" => $tags, + )); + + ?> + </label> + </p> + <?php + } + + ?> + <?php + + $categories = elgg_view('categories',$vars); + if (!empty($categories)) { +?> + + <p> + <?php echo $categories; ?> + </p> + +<?php + } + +?> + <p> + <label> + <?php echo elgg_echo('access'); ?><br /> + <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?> + </label> + </p> + + <p> + <?php + + if (isset($vars['container_guid'])) + echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$vars['container_guid']}\" />"; + if (isset($vars['entity'])) + echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />"; + + ?> + <input type="submit" value="<?php echo elgg_echo("save"); ?>" /> + </p> + +</form> +</div> \ No newline at end of file diff --git a/plugins/flexfile/views/default/object/file.php b/plugins/flexfile/views/default/object/file.php new file mode 100755 index 0000000000000000000000000000000000000000..a58e57edfc08d0b4532e8248766026ddd20def07 --- /dev/null +++ b/plugins/flexfile/views/default/object/file.php @@ -0,0 +1,189 @@ +<?php + /** + * Elgg file browser. + * File renderer. + * + * @package ElggFile + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.com/ + */ + + global $CONFIG; + + $file = $vars['entity']; + + $file_guid = $file->getGUID(); + $tags = $file->tags; + $title = $file->title; + $desc = $file->description; + $owner = $vars['entity']->getOwnerEntity(); + $friendlytime = friendly_time($vars['entity']->time_created); + + $mime = $file->mimetype; + + if (get_context() == "search") { // Start search listing version + + if (get_input('search_viewtype') == "gallery") { + echo "<div class=\"filerepo_gallery_item\">"; + if ($vars['entity']->smallthumb) { + echo "<p class=\"filerepo_title\">" . $file->title . "</p>"; + echo "<p><a href=\"{$file->getURL()}\"><img src=\"{$vars['url']}mod/file/thumbnail.php?size=small&file_guid={$vars['entity']->getGUID()}\" border=\"0\" /></a></p>"; + echo "<p class=\"filerepo_timestamp\"><small><a href=\"{$vars['url']}pg/file/{$owner->username}\">{$owner->username}</a> {$friendlytime}</small></p>"; + + //get the number of comments + $numcomments = elgg_count_comments($vars['entity']); + if ($numcomments) + echo "<p class=\"filerepo_comments\"><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>"; + + + //if the user can edit, display edit and delete links + if ($file->canEdit()) { + echo "<div class=\"filerepo_controls\"><p>"; + echo "<a href=\"{$vars['url']}mod/file/edit.php?file_guid={$file->getGUID()}\">" . elgg_echo('edit') . "</a> "; + echo elgg_view('output/confirmlink',array( + + 'href' => $vars['url'] . "action/file/delete?file=" . $file->getGUID(), + 'text' => elgg_echo("delete"), + 'confirm' => elgg_echo("file:delete:confirm"), + + )); + echo "</p></div>"; + } + + + } else { + echo "<p class=\"filerepo_title\">{$title}</p>"; + echo "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'large')) . "</a>"; + echo "<p class=\"filerepo_timestamp\"><small><a href=\"{$vars['url']}pg/file/{$owner->username}\">{$owner->name}</a> {$friendlytime}</small></p>"; + + //get the number of comments + $numcomments = elgg_count_comments($file); + if ($numcomments) + echo "<p class=\"filerepo_comments\"><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>"; + + + } + echo "</div>"; + // echo elgg_view("search/gallery",array('info' => $info, 'icon' => $icon)); + + } else { + + $info = "<p> <a href=\"{$file->getURL()}\">{$title}</a></p>"; + $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/file/{$owner->username}\">{$owner->name}</a> {$friendlytime}"; + // add extra content, if any + $form = flexfile_get_file_form($file); + if ($form && $form->list_template) { + $info .= form_view_entities(array($file), $form, 'list'); + } + $numcomments = elgg_count_comments($file); + if ($numcomments) + $info .= ", <a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; + $info .= "</p>"; + + // $icon = elgg_view("profile/icon",array('entity' => $owner, 'size' => 'small')); + $icon = "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'small')) . "</a>"; + + echo elgg_view_listing($icon, $info); + + } + + } else { // Start main version + +?> + <div class="filerepo_file"> + <div class="filerepo_icon"> + <a href="<?php echo $vars['url']; ?>action/file/download?file_guid=<?php echo $file_guid; ?>"><?php + + echo elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid)); + + ?></a> + </div> + + <div class="filerepo_title_owner_wrapper"> + <?php + //get the user and a link to their gallery + $user_gallery = $vars['url'] . "mod/file/search.php?md_type=simpletype&subtype=file&tag=image&owner_guid=" . $owner->guid . "&search_viewtype=gallery"; + ?> + <div class="filerepo_user_gallery_link"><a href="<?php echo $user_gallery; ?>"><?php echo sprintf(elgg_echo("file:user:gallery"),$owner->username); ?></a></div> + <div class="filerepo_title"><h2><a href="<?php echo $file->getURL(); ?>"><?php echo $title; ?></a></h2></div> + <div class="filerepo_owner"> + <?php + + echo elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny')); + + ?> + <p class="filerepo_owner_details"><b><a href="<?php echo $vars['url']; ?>pg/file/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b><br /> + <small><?php echo $friendlytime; ?></small></p> + </div> + </div> + + + <div class="filerepo_maincontent"> + + <div class="filerepo_description"><?php echo autop($desc); ?></div> + <?php + $form = flexfile_get_file_form($file); + if ($form && $form->display_template) { + echo form_view_entities(array($file), $form, 'display'); + } else { + ?> + <div class="filerepo_tags"><div class="object_tag_string"><?php + + echo elgg_view('output/tags',array('value' => $tags)); + + ?></div></div> + <?php + } + if (elgg_view_exists('file/specialcontent/' . $mime)) { + echo "<div class=\"filerepo_specialcontent\">".elgg_view('file/specialcontent/' . $mime, $vars)."</div>"; + } else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) { + echo "<div class=\"filerepo_specialcontent\">".elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars)."</div>"; + } + + ?> + + <div class="filerepo_download"><p><a href="<?php echo $vars['url']; ?>action/file/download?file_guid=<?php echo $file_guid; ?>"><?php echo elgg_echo("file:download"); ?></a></p></div> + +<?php + + if ($file->canEdit()) { +?> + + <div class="filerepo_controls"> + <p> + <a href="<?php echo $vars['url']; ?>mod/file/edit.php?file_guid=<?php echo $file->getGUID(); ?>"><?php echo elgg_echo('edit'); ?></a> + <?php + echo elgg_view('output/confirmlink',array( + + 'href' => $vars['url'] . "action/file/delete?file=" . $file->getGUID(), + 'text' => elgg_echo("delete"), + 'confirm' => elgg_echo("file:delete:confirm"), + + )); + ?> + </p> + </div> + +<?php + } + +?> + </div> +</div> + +<?php + + if ($vars['full']) { + + echo elgg_view_comments($file); + + } + +?> + +<?php + + } + +?> \ No newline at end of file diff --git a/plugins/flexgroupprofile/README.txt b/plugins/flexgroupprofile/README.txt new file mode 100755 index 0000000000000000000000000000000000000000..1d20675b823e0ff28407674b23a33875023306a0 --- /dev/null +++ b/plugins/flexgroupprofile/README.txt @@ -0,0 +1,97 @@ +/** + * Use form module to manage group profile questions through the web + * + * @package flexgroupprofile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + +The Elgg 1.x flexgroupprofile plugin requires the form plugin. + +Do not activate the flexgroupprofile plugin without creating a group profile +form first - if you do, your group profiles will be blank and there will be +nothing to edit as no group profile questions will be defined. + +You can use the "Add form" link on the Manage forms page provided by +the form module to manage your group profile questions through the web. Specify +a "group profile" form when creating your form. You can define multiple group +profile categories and have a different set of profile questions for groups +with different categories. + +Field type restrictions + +Currently the invitation box field type does not work for group profile +forms. + +It is also not possible to make group profile fields required. + +Some of these restrictions may be removed eventually. + +For group profile forms, there are a few extra profile field definition options. + +You can specify whether the profile field should be displayed in the profile +summary area on the left, right or bottom area of the profile (or not at all). +By default they are displayed on the right. Even if the field cannot be viewed +in the profile summary area, it can still be viewed in the extended profile +if the user has the correct permissions and you have activated the extended +profile option (see below). + +You can also specify whether a profile field is invisible. This is a value that +can be edited by the user but is never displayed. + +You can specify the profile format. Currently there are four formats. The +default format is similar to the standard Elgg 1.1 summary profile with the +addition of an extended profile (accessed by a link) that shows all the visible +fields (separated by tabs if more than one tab was specified). The default +format (no extended profile) does not include the link to the extended profile. +The tabbed format shows just the tabbed extended profile and no summary +profile. The wide tabbed format shows the same information as the tabbed format, +but places it below the group icon image so there is more romm to display the +information. + +You can also specify different group profiles for different group categories +by entering a category name when creating the group profile. (If the +group category field is left blank, then this used for groups with no +explicit category *or* groups with a category set but no profile form set +for that category.) + +Setting the group category + +The group category is defined by the "group_profile_category" metadata value +for each group. The flexgroupprofile plugin provides two ways to set this +value. + +First, you can pass a value to the group creation page. + +Typically this would be done using the url: + +//link-to-your-elgg/pg/groups/new/?group_profile_category=xxx + +where xxx is the group category. This will cause the group creation page +to display the appropriate questions for that group category and to add the +group_profile_category metadata to the new group. Adding links like this to +your site typically requires a small amount of plugin coding. A through-the-web +feature to add these links may eventually be added to the flexgroupprofile +plugin. + +Second, you can define a field with the name "group_profile_category" in a +group profile form. Create this form with a blank group category field. + +Then users can enter a group category or select it from a list. Once the +group has been created, they can then edit the group profile which will then +show the appropriate questions for that group. + +Activating the flexgroupprofile plugin + +Create a group profile form as described above. More documentation on creating forms +is contained in the form plugin README.txt. + +Then extract the flexgroupprofile plugin into the mod directory and activate it as +usual using the Elgg 1.x tool administration. + +Once activated, the edit details link should show the fields that you have +defined for your group profile form. + diff --git a/plugins/flexgroupprofile/actions/edit.php b/plugins/flexgroupprofile/actions/edit.php new file mode 100755 index 0000000000000000000000000000000000000000..3601f6bfbdcae9a6b7f9d5b9e011a104e9a3cea9 --- /dev/null +++ b/plugins/flexgroupprofile/actions/edit.php @@ -0,0 +1,145 @@ +<?php +/** + * Elgg flex group profile edit action + * Allows user to edit profile + * + * @package Elgg + * @subpackage FlexGroupProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load form profile model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/profile.php"); + +// Load flexgroupprofile model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +$user_guid = get_input('user_guid'); +$user = NULL; +if (!$user_guid) $user = $_SESSION['user']; +else +$user = get_entity($user_guid); + +$group_guid = get_input('group_guid',''); +$group = new ElggGroup($group_guid); // load if present, if not create a new group +if (($group_guid) && (!$group->canEdit())) +{ + register_error(elgg_echo("groups:cantedit")); + + forward($_SERVER['HTTP_REFERER']); + exit; +} + +$group_profile_category = get_input('group_profile_category',null); +if (isset($group_profile_category)) { + $group->group_profile_category = $group_profile_category; +} + +$group->name = get_input('name',''); +$group->description = get_input('description',''); + +// Validate create +if (!$group->name) +{ + register_error(elgg_echo("groups:notitle")); + + forward($_SERVER['HTTP_REFERER']); + exit; +} + +// Group membership +switch (get_input('membership')) +{ + case 2: $group->membership = ACCESS_PUBLIC; break; + default: $group->membership = ACCESS_PRIVATE; +} + +// Get access +$group->access_id = ACCESS_PUBLIC; + +// Set group tool options +if (isset($CONFIG->group_tool_options)) { + foreach($CONFIG->group_tool_options as $group_option) { + $group_option_toggle_name = $group_option->name."_enable"; + if ($group_option->default_on) { + $group_option_default_value = 'yes'; + } else { + $group_option_default_value = 'no'; + } + $group->$group_option_toggle_name = get_input($group_option_toggle_name, $group_option_default_value); + } +} + +$data = form_get_profile_data_from_form_post(); + +form_set_data($group,$data); + +$group->save(); + +if (($group_owner_username = get_input('group_owner_username','')) + && ($user = get_user_by_username($group_owner_username) )) { + $new_group_owner_guid = $user->getGUID(); + $group->owner_guid = $new_group_owner_guid; + $group->container_guid = $new_group_owner_guid; +} + +if (!$group->isMember($user)) + $group->join($user); // Creator always a member + + +// Now see if we have a file icon +if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))) +{ + $prefix = "groups/".$group->guid; + + $filehandler = new ElggFile(); + $filehandler->owner_guid = $group->owner_guid; + $filehandler->setFilename($prefix . ".jpg"); + $filehandler->open("write"); + $filehandler->write(get_uploaded_file('icon')); + $filehandler->close(); + + $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),25,25, true); + $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),40,40, true); + $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),100,100, true); + $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(),200,200, false); + if ($thumbtiny) { + + $thumb = new ElggFile(); + $thumb->setMimeType('image/jpeg'); + + $thumb->setFilename($prefix."tiny.jpg"); + $thumb->open("write"); + $thumb->write($thumbtiny); + $thumb->close(); + + $thumb->setFilename($prefix."small.jpg"); + $thumb->open("write"); + $thumb->write($thumbsmall); + $thumb->close(); + + $thumb->setFilename($prefix."medium.jpg"); + $thumb->open("write"); + $thumb->write($thumbmedium); + $thumb->close(); + + $thumb->setFilename($prefix."large.jpg"); + $thumb->open("write"); + $thumb->write($thumblarge); + $thumb->close(); + + } +} + +trigger_elgg_event('groupprofileupdate','group',$group); + +system_message(elgg_echo("groups:saved")); + +// Forward to the group's profile +forward($group->getUrl()); +exit; + +?> \ No newline at end of file diff --git a/plugins/flexgroupprofile/extended.php b/plugins/flexgroupprofile/extended.php new file mode 100755 index 0000000000000000000000000000000000000000..6a5ce01f692f91c571e38fd64617c3662df9e10c --- /dev/null +++ b/plugins/flexgroupprofile/extended.php @@ -0,0 +1,35 @@ +<?php + +/** + * Elgg flexprofile extended profile + * + * @package FlexProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +global $CONFIG; + +// Define context +set_context('groups'); + +set_page_owner(get_input('group_guid',0)); + +$group = page_owner_entity(); + +$title = friendly_title($group->name); + +add_submenu_item(elgg_echo('form:main_profile_link_text'),$group->getUrl(),'0extendedprofile'); + +$body = elgg_view('flexgroupprofile/extended',array('entity'=>$group)); + +$title = sprintf(elgg_echo('form:extended_profile_title'),$group->name); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/flexgroupprofile/languages/en.php b/plugins/flexgroupprofile/languages/en.php new file mode 100755 index 0000000000000000000000000000000000000000..e391ca95ee086ec7d0b51552707bd3186ab53842 --- /dev/null +++ b/plugins/flexgroupprofile/languages/en.php @@ -0,0 +1,11 @@ +<?php + + $english = array( + + 'flexgroupprofile:owner_label' => "Group owner", + 'flexgroupprofile:owner_description' => "You can transfer group ownership by changing the above username to one for another user.", + ); + + add_translation("en",$english); + +?> \ No newline at end of file diff --git a/plugins/flexgroupprofile/manifest.xml b/plugins/flexgroupprofile/manifest.xml new file mode 100755 index 0000000000000000000000000000000000000000..5392544f5a62d8a18208ec5c47b69570cfbf8139 --- /dev/null +++ b/plugins/flexgroupprofile/manifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest> + <field key="author" value="Kevin Jardine <kevin@radagast.biz>" /> + <field key="version" value="0.8" /> + <field key="description" value="Elgg flexible group profile plugin" /> + <field key="website" value="http://radagast.biz/" /> + <field key="copyright" value="(C) Radagast Solutions 2009" /> + <field key="licence" value="GNU Public License version 2" /> + <field key="elgg_version" value="2009030101" /> +</plugin_manifest> diff --git a/plugins/flexgroupprofile/models/model.php b/plugins/flexgroupprofile/models/model.php new file mode 100755 index 0000000000000000000000000000000000000000..b093978e05382ecd3f3b540b151f532dcaca02e8 --- /dev/null +++ b/plugins/flexgroupprofile/models/model.php @@ -0,0 +1,30 @@ +<?php +/** + * Elgg flex group profile model + * Functions to save and display profile data + * + * @package Elgg + * @subpackage FlexGroupProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load form model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/model.php"); +// Load form profile model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/profile.php"); + +function flexgroupprofile_get_profile_form($entity,$group_profile_category='') { + return form_get_latest_public_profile_form(2,$group_profile_category); +} + +// a stub for future use + +function flexgroupprofile_get_profile_config($group_profile_category) { + $group_config = new stdClass(); + return $group_config; +} + +?> \ No newline at end of file diff --git a/plugins/flexgroupprofile/start.php b/plugins/flexgroupprofile/start.php new file mode 100755 index 0000000000000000000000000000000000000000..d64dbdc94c61ecb25e31d043e0e6f5d8ddbb1810 --- /dev/null +++ b/plugins/flexgroupprofile/start.php @@ -0,0 +1,59 @@ +<?php + +/** + * Elgg flexgroupprofile plugin + * + * @package FlexGroupProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load flexgroupprofile model +require_once(dirname(__FILE__)."/models/model.php"); + +function flexgroupprofile_init() { + register_page_handler('flexgroupprofile','flexgroupprofile_page_handler'); +} + +function flexgroupprofile_pagesetup() { + global $CONFIG; + + $page_owner = page_owner_entity(); + + // Group submenu option + if ($page_owner instanceof ElggGroup && get_context() == 'groups') { + $form = flexgroupprofile_get_profile_form($page_owner,$page_owner->group_profile_category); + if (!$form->profile_format || ($form->profile_format == 'default')) { + $title = friendly_title($page_owner->name); + add_submenu_item(elgg_echo('form:extended_profile_link_text'),$CONFIG->wwwroot.'pg/flexgroupprofile/'.$page_owner->getGUID().'/'.$title.'/','0extendedprofile'); + } + } +} + +/* Flexprofile page handler; allows the use of fancy URLs + * + * @param array $page From the page_handler function + * @return true|false Depending on success + */ +function flexgroupprofile_page_handler($page) { + + // The first component of a flexgroupprofile URL is the group_guid + if (isset($page[0])) { + set_input('group_guid',$page[0]); + } + + @include(dirname(__FILE__) . "/extended.php"); + return true; + +} + register_elgg_event_handler('init','system','flexgroupprofile_init'); + register_elgg_event_handler('pagesetup','system','flexgroupprofile_pagesetup'); + + +// Register actions + global $CONFIG; + register_action("flexgroupprofile/edit",false,$CONFIG->pluginspath . "flexgroupprofile/actions/edit.php"); + +?> \ No newline at end of file diff --git a/plugins/flexgroupprofile/views/default/flexgroupprofile/extended.php b/plugins/flexgroupprofile/views/default/flexgroupprofile/extended.php new file mode 100755 index 0000000000000000000000000000000000000000..09815c66bdde911c2e916e5b3fa62f30007bc127 --- /dev/null +++ b/plugins/flexgroupprofile/views/default/flexgroupprofile/extended.php @@ -0,0 +1,30 @@ +<?php +/** + * Extended profile view + * + * @package Flexprofile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load flexgroupprofile model +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +if (!$vars['embedded']) { + echo '<div class="contentWrapper">'; +} +$group = $vars['entity']; +$form = flexgroupprofile_get_profile_form($group,$group->group_profile_category); +if ($form) { + $tab_data = form_get_data_for_profile_tabbed_display($form, $group); + + echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0)); +} else { + echo elgg_echo('form:error_no_group_profile_form'); +} + +if (!$vars['embedded']) { + echo '</div>'; +} diff --git a/plugins/flexgroupprofile/views/default/forms/groups/edit.php b/plugins/flexgroupprofile/views/default/forms/groups/edit.php new file mode 100755 index 0000000000000000000000000000000000000000..97ab79cbcf08832e4934fd17c6c0db0886ff91e7 --- /dev/null +++ b/plugins/flexgroupprofile/views/default/forms/groups/edit.php @@ -0,0 +1,163 @@ +<?php +/** + * Edit group profile + * + * @package FlexGroupProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load form model + +require_once(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . "/form/models/model.php"); + +// Load form profile model +require_once(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . "/form/models/profile.php"); + +// Load flexgroupprofile model +require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/models/model.php"); + +$group = $vars['entity']; +$group_config = flexgroupprofile_get_profile_config($group->group_profile_category); +if ($group) { + $group_profile_category = get_input('group_profile_category',$group->group_profile_category); +} else { + $group_profile_category = get_input('group_profile_category',''); +} +if ($group_profile_category) { + $fp = form_get_profile_config($group_profile_category,'group'); +} else { + $fp = ''; +} +?> +<div class="contentWrapper"> +<?php if ($fp && $fp->new_group_description) {echo $fp->new_group_description;} else { echo elgg_echo("form:new_group_description"); } ?> +</div> +<div class="contentWrapper"> +<form action="<?php echo $vars['url']; ?>action/flexgroupprofile/edit" enctype="multipart/form-data" method="post"> + + <p> + <label><?php if ($fp && $fp->group_icon) {echo $fp->group_icon;} else {echo elgg_echo("groups:icon");} ?><br /> + <?php + + echo elgg_view("input/file",array('internalname' => 'icon')); + + ?> + </label> + </p> + + <p> + <label> + <?php if ($fp && $fp->group_name) {echo $fp->group_name;} else { echo elgg_echo("groups:name"); } ?><br /> + <?php echo elgg_view("input/text",array( + 'internalname' => 'name', + 'value' => $vars['entity']->name, + )); ?> + </label> + </p> + <p> + <label> + <?php if ($fp && $fp->group_description) {echo $fp->group_description;} else { echo elgg_echo("groups:description"); } ?><br /> + <?php echo elgg_view("input/longtext",array( + 'internalname' => 'description', + 'value' => $vars['entity']->description, + )); ?> + </label> + </p> +<?php + $form = flexgroupprofile_get_profile_form($group,$group_profile_category); + if ($form) { + $tab_data = form_get_data_for_profile_edit_form($form, $group, $group_profile_category); + echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0)); + } else { + echo '<p>'.elgg_echo('form:error_no_group_profile_form').'</p>'; + } + + if (isadminloggedin() || ($group_config->group_owner_can_transfer_ownership && ($group->getOwner() == $_SESSION['user']->getGUID()))) { + // let admins or optionally group owners transfer ownership + if ($group) { + $group_owner_username = get_entity($group->getOwner())->username; + } else { + $group_owner_username = get_loggedin_user()->username; + } +?> +<br /> + <label> + <?php echo elgg_echo('flexgroupprofile:owner_label'); ?><br /> + <?php echo elgg_view('input/text', array('internalname' => 'group_owner_username','value' => $group_owner_username)); ?> + </label> + <p class="description"><?php echo elgg_echo('flexgroupprofile:owner_description');?></p> +<?php +} + ?> + + <p> + <label> + <?php echo elgg_echo('groups:membership'); ?><br /> + <?php echo elgg_view('input/access', array('internalname' => 'membership','value' => $vars['entity']->membership, 'options' => array( ACCESS_PRIVATE => elgg_echo('groups:access:private'), ACCESS_PUBLIC => elgg_echo('groups:access:public')))); ?> + </label> + </p> + + + <?php + if (isset($vars['config']->group_tool_options)) { + foreach($vars['config']->group_tool_options as $group_option) { + $group_option_toggle_name = $group_option->name."_enable"; + if ($group_option->default_on) { + $group_option_default_value = 'yes'; + } else { + $group_option_default_value = 'no'; + } +?> + <p> + <label> + <?php echo $group_option->label; ?><br /> + <?php + + echo elgg_view("input/radio",array( + "internalname" => $group_option_toggle_name, + "value" => $vars['entity']->$group_option_toggle_name ? $vars['entity']->$group_option_toggle_name : $group_option_default_value, + 'options' => array( + elgg_echo('groups:yes') => 'yes', + elgg_echo('groups:no') => 'no', + ), + )); + ?> + </label> + </p> + <?php + } + } + ?> + <p> + <?php + if ($vars['entity']) + { + ?><input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" /><?php + } + ?> + <input type="hidden" name="user_guid" value="<?php echo page_owner_entity()->guid; ?>" /> + <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" /> + + </p> + +</form> +</div> + +<div class="contentWrapper"> +<div id="delete_group_option"> + <form action="<?php echo $vars['url'] . "action/groups/delete"; ?>"> + <?php + if ($vars['entity']) + { + $warning = elgg_echo("groups:deletewarning"); + ?> + <input type="hidden" name="group_guid" value="<?php echo $vars['entity']->getGUID(); ?>" /> + <input type="submit" name="delete" value="<?php echo elgg_echo('groups:delete'); ?>" onclick="javascript:return confirm('<?php echo $warning; ?>')"/><?php + } + ?> + </form> +</div><div class="clearfloat"></div> +</div> diff --git a/plugins/flexgroupprofile/views/default/groups/groupprofile.php b/plugins/flexgroupprofile/views/default/groups/groupprofile.php new file mode 100755 index 0000000000000000000000000000000000000000..cdaca21f516d376f5c568aa30ac500ea8d8e8cb5 --- /dev/null +++ b/plugins/flexgroupprofile/views/default/groups/groupprofile.php @@ -0,0 +1,162 @@ +<?php + /** + * Elgg groups plugin full profile view. + * + * @package ElggGroups + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider + * @copyright Curverider Ltd 2008 + * @link http://elgg.com/ + */ + +// Load form model +require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/form/models/model.php"); + +// Load form profile model +require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/form/models/profile.php"); + +// Load flexgroupprofile model +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + + if ($vars['full'] == true) { + $iconsize = "large"; + } else { + $iconsize = "medium"; + } + +?> + +<div id="groups_info_column_right"><!-- start of groups_info_column_right --> + <div id="groups_icon_wrapper"><!-- start of groups_icon_wrapper --> + + <?php + echo elgg_view( + "groups/icon", array( + 'entity' => $vars['entity'], + //'align' => "left", + 'size' => $iconsize, + ) + ); + ?> + + </div><!-- end of groups_icon_wrapper --> + <div id="group_stats"><!-- start of group_stats --> + <?php + + echo "<p><b>" . elgg_echo("groups:owner") . ": </b><a href=\"" . get_user($vars['entity']->owner_guid)->getURL() . "\">" . get_user($vars['entity']->owner_guid)->name . "</a></p>"; + + ?> + <p><?php echo elgg_echo('groups:members') . ": " . get_entities_from_relationship('member', $vars['entity']->guid, true, 'user', '', 0, '', 9999, 0, true); ?></p> + </div><!-- end of group_stats --> +<?php + if ($vars['full'] == true) { + $body = ''; + $form = flexgroupprofile_get_profile_form($vars['entity'],$vars['entity']->group_profile_category); + if ($form) { + if (!in_array($form->profile_format,array('tabbed','wide_tabbed'))) { + // a little bit weird, but actually in the default design + // this column is displayed on the left (not right) - so show left items + $data = form_get_data_for_profile_summary_display($form, $vars['entity']); + // do left column + if ($data['left']) { + foreach($data['left'] as $item) { + $value = $item->value; + if (!empty($value)) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + $body .= "<p class=\"{$even_odd}\"><b>"; + $body .= $item->title.':</b> '; + $body .= $item->value; + } + } + echo $body; + } + } + } + } +?> +</div><!-- end of groups_info_column_right --> + +<div id="groups_info_column_left"><!-- start of groups_info_column_left --> + <?php + if ($vars['full'] == true) { + $body = ''; + // do right column + // handle description, which is hardcoded to be first + $body .= '<div class="contentWrapper">'; + $body .= $vars['entity']->description; + $body .= '</div>'; + if ($form) { + if (!in_array($form->profile_format,array('tabbed','wide_tabbed'))) { + // a little bit weird, but actually in the default design + // this column is displayed on the right (not left) - so show right items + if ($data['right']) { + foreach($data['right'] as $item) { + $value = $item->value; + if (!empty($value)) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + $body .= "<p class=\"{$even_odd}\"><b>"; + $body .= $item->title.':</b> '; + $body .= $item->value; + + } + } + } + } else if ($form->profile_format == 'tabbed') { + $body .= '<div class="contentWrapper">'; + $body .= elgg_view('flexgroupprofile/extended',array('entity'=>$vars['entity'],'embedded'=>true)); + $body .= '</div>'; + } + } else { + $body .= elgg_echo('form:error_no_group_profile_form'); + } + echo $body; + } + ?> +</div><!-- end of groups_info_column_left --> + +<div id="groups_info_wide"> +<?php +if ($form->profile_format == 'wide_tabbed') { + echo '<br clear="both" /><div class="contentWrapper">'; + echo elgg_view('flexgroupprofile/extended',array('entity'=>$vars['entity'],'embedded'=>true)); + echo '</div>'; +} +?> + + <p class="groups_info_edit_buttons"> + +<?php + if ($vars['entity']->canEdit()) + { + +?> + + <a href="<?php echo $vars['url']; ?>mod/groups/edit.php?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("edit"); ?></a> + + +<?php + + } + + if ($vars['full'] == true) { + if ($form) { + if (!in_array($form->profile_format,array('tabbed','wide_tabbed'))) { + // do bottom + if ($data['bottom']) { + foreach($data['bottom'] as $item) { + echo '<b>'.$item->title.'</b>'; + echo '<br /><br />'; + echo $item->value; + } + } + } + } + } +?> + + </p> +</div> \ No newline at end of file diff --git a/plugins/flexprofile/README.txt b/plugins/flexprofile/README.txt new file mode 100755 index 0000000000000000000000000000000000000000..9a4201909dcba18dbf8aacfb434efceef509c743 --- /dev/null +++ b/plugins/flexprofile/README.txt @@ -0,0 +1,67 @@ +/** + * Use form module to manage profile questions through the web + * + * @package flexprofile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + +The Elgg 1.x flexprofile plugin requires the form plugin. + +Do not activate the flexprofile plugin without creating a profile form first - +if you do, your profiles will be blank and there will be nothing to edit +as no profile questions will be defined. + +You can use the "Add form" link on the Manage forms page provided by +the form module to manage your profile questions through the web. Specify a +"user profile" form when creating your form. + +Field type restrictions + +Currently the invitation box field type does not work for +profile forms. + +It is also not possible to make profile fields required. + +Some of these restrictions may be removed eventually. + +For profile forms, there are a few extra profile field definition options. + +You can specify whether the profile field should be displayed in the profile +summary area on the left, right or bottom area of the profile (or not at all). +By default they are displayed on the right. Even if the field cannot be viewed +in the profile summary area, it can still be viewed in the extended profile +if the user has the correct permissions and you have activated the extended +profile option (see below). + +You can also specify whether a profile field is invisible. This is a value that +can be edited by the user but is never displayed. + +You can specify the profile format. Currently there are three formats. The +default format is similar to the standard Elgg 1.1 summary profile with the +addition of an extended profile (accessed by a link) that shows all the visible +fields (separated by tabs if more than one tab was specified). The default +format (no extended profile) does not include the link to the extended profile. +The tabbed format shows just the tabbed extended profile and no summary +profile. + +You can also specify different user profiles for different user categories. +There is currently no way to set user categories, however, so this feature +is for future use. + +Activating the flexprofile plugin + +Create a profile form as described above. More documentation on creating forms +is contained in the form plugin README.txt. + +Then extract the flexprofile plugin into the mod directory and activate it as +usual using the Elgg 1.x tool administration. + +Once activated, the edit details link should show the fields that you have +defined for your profile form. + +You can have multiple profile forms defined, but the flexprofile plugin will +always use the one most recently created. diff --git a/plugins/flexprofile/actions/edit.php b/plugins/flexprofile/actions/edit.php new file mode 100755 index 0000000000000000000000000000000000000000..6fe49c9c28d4a24b66df13360751ff76b1f0ae1f --- /dev/null +++ b/plugins/flexprofile/actions/edit.php @@ -0,0 +1,44 @@ +<?php +/** + * Elgg flex profile edit action + * Allows user to edit profile + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + // Load flexprofile model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +if ($user = page_owner()) { + $user = page_owner_entity(); +} else { + $user = $_SESSION['user']; + set_page_owner($user->getGUID()); +} + +if ($user && $user->canEdit()) { + $data = form_get_profile_data_from_form_post(); + form_set_data($user,$data); + // Notify of profile update + trigger_elgg_event('profileupdate',$user->type,$user); + //add to river + add_to_river('river/user/default/profileupdate','update',$user->guid,$user->guid); + + system_message(elgg_echo("profile:saved")); + + // Forward to the user's profile + forward($user->getUrl()); + +} else { + // If we can't, display an error + + register_error(elgg_echo("profile:cantedit")); + forward(); +} + +?> \ No newline at end of file diff --git a/plugins/flexprofile/extended.php b/plugins/flexprofile/extended.php new file mode 100755 index 0000000000000000000000000000000000000000..66ca0d16f4fd21089f78251cdb462e70f29c87c2 --- /dev/null +++ b/plugins/flexprofile/extended.php @@ -0,0 +1,32 @@ +<?php + +/** + * Elgg flexprofile extended profile + * + * @package FlexProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +global $CONFIG; + +// Define context +set_context('profile'); + +$user = page_owner_entity(); + +add_submenu_item(elgg_echo('form:extended_profile_link_text'),$CONFIG->wwwroot.'pg/flexprofile/'.$user->username); +add_submenu_item(elgg_echo('form:main_profile_link_text'),$user->getUrl()); + +$body = elgg_view('flexprofile/extended',array('entity'=>$user)); + +$title = sprintf(elgg_echo('form:extended_profile_title'),$user->name); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/flexprofile/manifest.xml b/plugins/flexprofile/manifest.xml new file mode 100755 index 0000000000000000000000000000000000000000..b673ac5c792f5add381495425b17d7ce5245ca92 --- /dev/null +++ b/plugins/flexprofile/manifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest> + <field key="author" value="Kevin Jardine <kevin@radagast.biz>" /> + <field key="version" value="0.8" /> + <field key="description" value="Elgg flexible user profile plugin." /> + <field key="website" value="http://radagast.biz/" /> + <field key="copyright" value="(C) Radagast Solutions 2009" /> + <field key="licence" value="GNU Public License version 2" /> + <field key="elgg_version" value="2009030101" /> +</plugin_manifest> diff --git a/plugins/flexprofile/models/model.php b/plugins/flexprofile/models/model.php new file mode 100755 index 0000000000000000000000000000000000000000..eb2aea18c3acb50f60df2aae05432620a6bb4708 --- /dev/null +++ b/plugins/flexprofile/models/model.php @@ -0,0 +1,129 @@ +<?php +/** + * Elgg flex profile model + * Functions to save and display profile data + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load form model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/model.php"); + +// Load form profile model +require_once(dirname(dirname(dirname(__FILE__))) . "/form/models/profile.php"); + +// Eventually this will be very flexible and return different forms for +// different entities. +// Right now it just returns the first public profile form available. + +function flexprofile_get_profile_form($user=null) { + return form_get_latest_public_profile_form(1); +} + +// use the specified profile form to return the data (indexed by summary area) from the specified user + +function flexprofile_get_data_for_summary_display($form, $user) { + $form_id = $form->getGUID(); + $data = form_get_data_from_profile($form_id,$user); + $area_data = array(); + $maps = form_get_maps($form_id); + if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + //print($field->internal_name.','.$field->field_type.','.$field->choice_type.','.$field->default_value.'<br />'); + $internalname = $field->internal_name; + if (isset($data[$internalname]) && $data[$internalname]->value) { + $area = $field->area; + if ($area) { + if (!isset($area_data[$area])) { + $area_data[$area] = array(); + } + $item = new StdClass(); + $item->internalname = $internalname; + $item->title = form_field_t($form,$field,'title'); + $item->description = form_field_t($form,$field,'description'); + if ($field->field_type == 'choices') { + $item->fieldtype = $field->choice_type; + $choices = form_get_field_choices($field->getGUID()); + $this_choice = ''; + foreach($choices as $choice) { + if ($choice->value == $data[$internalname]->value) { + $this_choice = $choice; + break; + } + } + $item->value = form_choice_t($form,$field,$this_choice); + } else { + $item->fieldtype = $field->field_type; + $item->value = $data[$internalname]->value; + } + + $area_data[$area][] = $item; + } + } + } + } + return $area_data; +} + + +// Return the form fields (indexed by tab), optionally prepopulated with data from the specified user. + +function flexprofile_get_data_for_edit_form($form, $user=null) { + + if ($user) { + $data = form_get_data_from_profile($form->getGUID(),$user); + } else { + $data = array(); + } + + $tab_data = array(); + $tabs = form_display_by_tab($form,$data); + + // add access control pulldowns + if ($tabs) { + foreach ($tabs as $tab => $tab_items) { + $tab_data[$tab] = ''; + foreach ($tab_items as $item) { + $internalname = $item->internalname; + $access_id = $item->default_access; + + $access_bit = '<p class="form-field-access">'; + $access_bit .= elgg_view('input/access', array('internalname' => 'flexprofile_access['.$internalname.']','value'=>$access_id)); + $access_bit .= '</p>'; + $tab_data[$tab] .= $item->html.$access_bit; + } + } + } + return $tab_data; +} + +function flexprofile_set_data($entity,$data) { + global $CONFIG; + + $entity_guid = $entity->getGUID(); + + foreach($data as $name => $item) { + remove_metadata($entity_guid, $name); + $value = $item->value; + if (is_array($value)) { + // currently tags are the only field_type returning multiple values + $i = 0; + foreach($value as $interval) { + $i++; + if ($i == 1) { $multiple = false; } else { $multiple = true; } + create_metadata($entity_guid, $name, $interval, 'text', $entity_guid, $item->access_id, $multiple); + } + } else { + create_metadata($entity_guid, $name, $value, '', $entity_guid, $item->access_id); + } + } +} + + +?> \ No newline at end of file diff --git a/plugins/flexprofile/start.php b/plugins/flexprofile/start.php new file mode 100755 index 0000000000000000000000000000000000000000..b6616d00b451b44d4351eb3c9824cc79216a4fb6 --- /dev/null +++ b/plugins/flexprofile/start.php @@ -0,0 +1,68 @@ +<?php + +/** + * Elgg flexprofile plugin + * + * @package FlexProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + +// Load flexprofile model + require_once(dirname(__FILE__)."/models/model.php"); + +/** + * Profile init function; sets up the profile functions + * + */ + function flexprofile_init() { + + // override profile views + set_view_location("profile/userdetails", dirname(__FILE__).'/views/'); + set_view_location("profile/edit", dirname(__FILE__).'/views/'); + + // Register a page handler, so we can have nice URLs + register_page_handler('flexprofile','flexprofile_page_handler'); + } + + function flexprofile_pagesetup() { + global $CONFIG; + + if (get_context() == 'profile') { + $form = flexprofile_get_profile_form(); + if (!$form->profile_format || ($form->profile_format == 'default')) { + extend_view("profile/menu/actions","flexprofile/menu/actions"); + } + } + } + + /* Flexprofile page handler; allows the use of fancy URLs + * + * @param array $page From the page_handler function + * @return true|false Depending on success + */ + function flexprofile_page_handler($page) { + + // The first component of a flexprofile URL is the username + if (isset($page[0])) { + set_input('username',$page[0]); + } + + @include(dirname(__FILE__) . "/extended.php"); + return true; + + } + + register_elgg_event_handler('pagesetup','system','flexprofile_pagesetup'); + +// Make sure the profile initialisation function is called on initialisation + register_elgg_event_handler('init','system','flexprofile_init',2); + +// Register actions + global $CONFIG; + register_action("flexprofile/edit",false,$CONFIG->pluginspath . "flexprofile/actions/edit.php"); + +?> \ No newline at end of file diff --git a/plugins/flexprofile/views/default/flexprofile/extended.php b/plugins/flexprofile/views/default/flexprofile/extended.php new file mode 100755 index 0000000000000000000000000000000000000000..f40932be638feb45484dfae0503e053b2ac9ae78 --- /dev/null +++ b/plugins/flexprofile/views/default/flexprofile/extended.php @@ -0,0 +1,29 @@ +<?php +/** + * Extended profile view + * + * @package Flexprofile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load flexprofile model +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$user = $vars['entity']; +$form = flexprofile_get_profile_form($user); +if (!$vars['embedded']) { + echo '<div class="contentWrapper">'; +} +if ($form) { + $tab_data = form_get_data_for_profile_tabbed_display($form, $user); + + echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0,'embedded'=>$vars['embedded'])); +} else { + echo elgg_echo('form:error_no_profile_form'); +} +if (!$vars['embedded']) { + echo '</div>'; +} diff --git a/plugins/flexprofile/views/default/flexprofile/menu/actions.php b/plugins/flexprofile/views/default/flexprofile/menu/actions.php new file mode 100755 index 0000000000000000000000000000000000000000..f628c907811424fb30a3197fe4f32aaa42c314c2 --- /dev/null +++ b/plugins/flexprofile/views/default/flexprofile/menu/actions.php @@ -0,0 +1,3 @@ +<?php + echo "<p><a href=\"{$vars['url']}pg/flexprofile/{$vars['entity']->username}\">" . elgg_echo("form:extended_profile_link_text") . "</a></p>"; +?> \ No newline at end of file diff --git a/plugins/flexprofile/views/default/profile/edit.php b/plugins/flexprofile/views/default/profile/edit.php new file mode 100755 index 0000000000000000000000000000000000000000..77ec9ed3645a985d313bc3c3cb8c4dc66e18fd66 --- /dev/null +++ b/plugins/flexprofile/views/default/profile/edit.php @@ -0,0 +1,40 @@ +<?php +/** + * Elgg flex profile edit form + * Allows user to edit profile + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + // Load flexprofile model +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$user = $vars['entity']; +$form = flexprofile_get_profile_form($user); +if ($form) { + $tab_data = flexprofile_get_data_for_edit_form($form, $user); + +echo '<div class="contentWrapper">'; +echo '<form action="'.$vars['url'].'action/flexprofile/edit" method="post" enctype="multipart/form-data">'; +echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0)); + +?> + + <p> + <input type="hidden" name="username" value="<?php echo page_owner_entity()->username; ?>" /> + <input type="submit" class="submit_button" value="<?php echo elgg_echo("save"); ?>" /> + </p> + +</form> +<?php +} else { + echo elgg_echo('form:error_no_profile_form'); +} +echo '</div>'; + +?> \ No newline at end of file diff --git a/plugins/flexprofile/views/default/profile/userdetails.php b/plugins/flexprofile/views/default/profile/userdetails.php new file mode 100755 index 0000000000000000000000000000000000000000..e802191e7e256f14d68e66081dd9f064c56ae8dd --- /dev/null +++ b/plugins/flexprofile/views/default/profile/userdetails.php @@ -0,0 +1,184 @@ +<?php + + /** + * Elgg user display (details) + * + * @package ElggProfile + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008 + * @link http://elgg.com/ + * + * @uses $vars['entity'] The user entity + */ + +// Load flexprofile model +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +// Load form profile model +require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/form/models/profile.php"); + +if ($vars['full'] == true) { + $iconsize = "large"; +} else { + $iconsize = "medium"; +} + +// wrap all profile info +echo "<div id=\"profile_info\">"; + +?> + +<table cellspacing="0"> +<tr> +<td> + +<?php + + // wrap the icon and links in a div + echo "<div id=\"profile_info_column_left\">"; + + echo "<div id=\"profile_icon_wrapper\">"; + // get the user's main profile picture + echo elgg_view( + "profile/icon", array( + 'entity' => $vars['entity'], + //'align' => "left", + 'size' => $iconsize, + 'override' => true, + ) + ); + + + echo "</div>"; + echo "<div class=\"clearfloat\"></div>"; + // display relevant links + echo elgg_view("profile/profilelinks", array("entity" => $vars['entity'])); + + // close profile_info_column_left + + if ($vars['full'] == true) { + + $form = flexprofile_get_profile_form($vars['entity']); + if ($form) { + if ($form->profile_format !== 'tabbed') { + $body = ''; + $data = form_get_data_for_profile_summary_display($form, $vars['entity']); + // do left column + if ($data['left']) { + foreach($data['left'] as $item) { + $value = $item->value; + if (!empty($value)) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + $body .= "<p class=\"{$even_odd}\"><b>"; + $body .= $item->title.':</b> '; + $body .= $item->value; + + } + } + } + print $body; + } + } + } + + echo "</div>"; + +?> +</td> +<td> + + <div id="profile_info_column_middle" > +<?php + $editdetails = elgg_echo("profile:edit"); + $body = ''; + if ($vars['entity']->canEdit()) { + $body .= <<<END + <p class="profile_info_edit_buttons"> + <a href="{$vars['url']}mod/profile/edit.php?username={$vars['entity']->username}"> + $editdetails</a> + </p> +END; + + } + // Simple XFN + $rel = ""; + if (page_owner() == $vars['entity']->guid) + $rel = 'me'; + else if (check_entity_relationship(page_owner(), 'friend', $vars['entity']->guid)) + $rel = 'friend'; + + // display the users name + $body .= "<h2><a href=\"" . $vars['entity']->getUrl() . "\" rel=\"$rel\">" . $vars['entity']->name . "</a></h2>"; + + //insert a view that can be extended + $body .= elgg_view("profile/status", array("entity" => $vars['entity'])); + // display the users name + //$body .= "<h2><a href=\"" . $vars['entity']->getUrl() . "\">" . $vars['entity']->name . "</a></h2>"; + + if ($vars['full'] == true) { + if ($form) { + if ($form->profile_format != 'tabbed') { + // do right column + if ($data['right']) { + foreach($data['right'] as $item) { + $value = $item->value; + if (!empty($value)) { + + //This function controls the alternating class + $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; + $body .= "<p class=\"{$even_odd}\"><b>"; + $body .= $item->title.':</b> '; + $body .= $item->value; + + } + } + } + } else { + $body .= elgg_view('flexprofile/extended',array('entity'=>$vars['entity'],'embedded'=>true)); + } + } else { + $body .= elgg_echo('form:error_no_profile_form'); + } + } + + echo $body; + + + + ?> + </div><!-- /#profile_info_column_middle --> + +</td> +</tr> + +<tr> +<td colspan="2"> + <?php + if ($form) { + if ($form->profile_format != 'tabbed') { + if ($data['bottom']) { + echo '<div id="profile_info_column_right">'; + foreach($data['bottom'] as $item) { + echo '<b>'.$item->title.'</b>'; + echo '<br /><br />'; + echo $item->value; + echo '<br />'; + } + echo '</div><!-- /#profile_info_column_right -->'; + } + } + } + ?> + +</td> +</tr> + + +</table> + + + +</div><!-- /#profile_info --> \ No newline at end of file diff --git a/plugins/form/CHANGES.txt b/plugins/form/CHANGES.txt new file mode 100755 index 0000000000000000000000000000000000000000..f8c5f90f1b3d0bcb520cde869e3fde456eab66f8 --- /dev/null +++ b/plugins/form/CHANGES.txt @@ -0,0 +1,43 @@ +Changes for release 0.8.3 + +Fixed some weirdness in the display of the orientation option +for when editing radio button and checkbox group definitions. +This should now display consistently. + +Removed the is_keyword option as it did not do anything (in Elgg 1.x +metadata is always searchable if you have the right access level). + +Fixed the display of checkbox groups (previously these would only +display properly if only one had been selected). + +Added a ${_friendlytime} template variable. + +Fixed several problems with the group profile display and added a +"wide tabbed" display for groups that need more room for their profile +information. + +Changes for release 0.8.2 + +Required fields for content forms are now working again. + +Added some protection against the metadata case bug: +http://trac.elgg.org/elgg/ticket/639 + +I may have accidentally left a debugging statement in +extended profile views in the last release (not sure, but +this release definitely does not have it.) + +Changes for release 0.8.1 + +Default field access levels should now work properly. + +Moving fields repeatedly up and down now works. + +Skype, MSN and ICQ contact fields now display a text box (and render just as +text as well - some decoration will be added in a future release). + +Flexgroupprofiles now always have a description field and use the one the +group already has if available. + +Custom templates should now show all the values in tag and checkbox fields +(previously they showed only one). \ No newline at end of file diff --git a/plugins/form/README.txt b/plugins/form/README.txt new file mode 100755 index 0000000000000000000000000000000000000000..43298cef23dbdb6edc6dfefcd6eaecf0b3ba68e7 --- /dev/null +++ b/plugins/form/README.txt @@ -0,0 +1,407 @@ +/** + * Manage forms for creating user content + * + * @package form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + +The Elgg 1.x form plugin provides a web-based system that allows site +admins to create forms that they and regular users can use to create +content. So you can allow your users to create, read, recommend, +comment on, and search for any content that you choose to support, from +restaurant reviews to classified ads. + +The form plugin supports a rich and growing set of form elements, including +select and radio boxes, image uploads and Youtube video embeds, search tags +and calendar gadgets. These elements can optionally be split across multiple +tabbed sections to reduce the visual complexity of your forms. + +When used in conjunction with the flexprofile, flexgroupprofile and flexfile +plugins, the form plugin allows you to add some of this functionality to +profile and file upload forms, so that you can manage a rich set of profile +and document data through the web. + +Activating the form plugin + +The zip file contains all four form, flexprofile, flexgroupprofile and flexfile +plugins. + +Extract the form plugin and any other plugins that you want to use into the mod +directory. Activate the form plugin as usual using the Elgg 1.x tool +administration.. Do not activate the flexprofile or flexgroupprofile plugins +until you have created appropriate forms for them to use. + +The form plugin creates a "Manage forms" left submenu link on the Elgg +administration pages. + +You can set a User Content toggle (next to the Forms entry on the tools +administration page) to create a "User content" link in the Tools menu +once you have created data or search forms. The User content page lists all +the accessible forms in your system to create an overview area if you want +that. + +By default the User content link is turned off. As you can see below, you can +also add links to individual forms in the Tool menu. + +Non-admins cannot create their own forms in the current version of the form +plugin but they can submit content using existing forms, comment on and +recommend content, and search for content created by themselves, their friends, +or other site users. + +Within the "Manage forms" page, site admins have a number of options. + +*Add form* + +Allows the admin to create a new form. You can specify when creating the form +whether this is a content, user profile, group profile, or file form. + +*List all fields* + +Lists all the field definitions this admin has created, across all his/her +forms. Notice that even though the "Manage forms" page lists all the forms in +the system, each admin has his or her own set of field definitions. + +*List orphan fields* + +Lists all the field definitions this admin has created that are not part of +any form. + +*Manage group profile categories* + +This provides a simple form to list your categories. + +Most (but not all) forms can also be edited directly through admin-specific +links added to the User content page. These are visible only to admins. + +Adding a form + +After clicking on "Add new form", you are asked for the following information: + +*Form name* + +A short string giving the internal name for this form. It can be any +combination of letters, numbers and underscores. It should not include +spaces. Each form created by a given admin must have a unique name. + +*Title* + +The public name for the form. This is displayed at the top of the +form. + +*Description* + +This is typically used to explain the form for users submitting the form +to provide content. It is displayed below the title. It can contain HTML. + +*Form type* + +Whether this is a content, user profile, group profile, or file form. + +*Access* + +You are probably going to want to keep the access "private" at this stage until +you have finished your form. + +Once you have created your form, you can edit it and set several more options. +The response text and listing and display templates all default to something +reasonable if you do not supply values, so you will not need to change these +until or if you want to customise them. + +For content forms, these are: + +*Response text* + +The text that is displayed to thank the user for submitting the form content. +It can contain HTML. + +*Listing description* + +If you like you can add a paragraph here that describes the form on content +listing pages and on the User content overview page if you have that activated. + +*Email form* + +Tick this box if the information submitted using this form should be emailed +to someone rather than saved to the database. Note that means that this +information will not be searchable, cannot be recommended or commented on, and +should not contain image uploads. + +*Email to* + +Enter the email address to use if the information submitted using this form +should be emailed to someone rather than saved to the database. + +*Allow commenting* + +Tick this box if users are allowed to comment on content created using this +form. + +*Allow recommending* + +Tick this box if users are allowed to recommend content created using this +form. + +*Templates* + +The list and display templates are required for content forms and optionally +can be used for file forms as well. They are explained in the Form templates +section below. + +Adding fields to a form + +Once you have created a form, you must add fields to it if it is to be useful. +When you create a form, you are automatically sent to a page that allows you +to edit the form. You can also get to this page by clicking on an edit link +for this form on the form management or user content pages. + +When editing a form, you can do additional form configuration as well as add, +change or delete field definitions. + +Your field definitions exist independently from your forms once they have been +created and can be added to several of your forms. + +There are three places to add fields on the form edit page. + +*Add new field* + +Enter a new field name here to create a new field definition and add it to this +form. Like form names, a field name should be a combination of letters, numbers +and underscores. It should not include spaces. Each field created by a given +admin must have a unique name. + +*Add existing field* + +Enter an existing field name to add this field to the form. + +*Copy existing field* + +Enter an existing field name to add a copy of this field definition to the +form. You need to rename the field definition and can edit it before adding +it to your form. + +Managing field definitions + +In addition to the field name, you can define several other pieces of +information when creating a field definition. These are: + +*Title* + +Displayed before the field input area. + +*Description* + +Displayed after the field input area to explain what content to enter. + +*Default value* + +Usually left blank, but can be useful for pulldown or radio buttons. + +*Required* + +Users must enter something in this field before they submit this form. + +*Admin only* + +Only admins can view or edit this field. This can be useful if admins want +to add priority information that determines where this content is displayed +in search results. See below for creating content searches. + +*Tab* + +If the fields added to this form appear in two or more tabs, a tab display is +created that divides this form into several sections. + +*Field type* + +There are numerous options here. + +Some comments on some field types: + +The calendar type uses the pop-up calendar that already comes with Elgg 1.x. +I may replace this in future with the jQuery date picker. + +The image upload automatically places the uploaded image in the user's file +upload area where it can be viewed separately from the specific form content. + +The video box accepts Youtube URLs. + +The group category type creates a select (dropdown/pulldown) box to allow users +to specify a group profile category. Currently this will only set a group +profile category if this field is called "group_profile_category". + +The invitation box allows the user to send a link to his or her content to +his friends or colleagues. Note that the invitation box does not work properly +if you have the TinyMCE plugin enabled. + +The access pulldown allows the user to determine who gets to see this content. + +Selecting the contact type allows you to select a number of contact types. +Currently only "url" and "email" have any special functionality. The other + contact types are currently implemented as text fields. + +Selecting the choice type shows an additional set of form elements to add +field choices. Click on "Add option" to add a field option. Typically +a pulldown or radio chocie type will have several options. + +Each option has a value and possibly a label. If the label is not provided, +the value will be used as the label. + +After creating your field definition, click on "Add field" or "Change field" +to save it. + +Managing your fields + +When editing your form definition, you can edit any field attached to that +form in the "Current fields" section. + +You can also remove the field or change the field display order by moving +the field up, down, to the top, or to the bottom. + +Removing a field from a form does not delete the field definition. There is a +separate place to do that. + +Adding your forms to the Tools menu + +There are two options to add the content creation or the content display +pages for each form to the Tools menu so that users can easily access your +forms and the content created using them. + +Form templates + +When editing your form, you can also specify how the form will appear in +search results (list template) and how it will appear when people view the form +content (display template). The form plugin supplies default templates if +you do not enter anything in these fields. + +A current exception is file forms. You need to explicitly provide templates +for this content in order to display it in file listings or when viewing the +file. See the flexfile README.txt for more information. + +In both cases, you describe this using a simple through-the-web templating +language. + +Templates are required in order to view submissions from content forms. They +can optionally be used to show any special fields that you add to file upload +forms. See the flexfile README.txt for more information about file forms. + +In order to display a field value, simply use + +{$my_field_name} + +in the template. + +For image uploads or the video box, + +{$my_field_name} + +will display the image or video clip player. + +You can also use: + +{$my_field_name:thumb} + +to display a thumbnail for the image or video. + +There are a number of special variables: + +$_url is the site url. + +$_full_view_link generates a link to the full content. + +$_full_view_url returns the URL to the full content. + +$_friendlytime returns the creation time of the content in a human readable +format. + +$_annotations displays the bits about comments and recommendations if these +are activated for your form. The list version is just a a line that shows the +number of comments and recommendations. The display version provides the link +and form for creating them and shows any existing comments. + +There are also a number of variables to display information related to the +owner (the person who made this content submission). + +$_owner_message_link allows you to send a message to the user who owns the content. + +$_owner_url is the URL for the owner's profile. +$_owner_name is the full name of the owner +$_owner_username is the username of the owner +$_owner_icon is an img tag for the small icon of the owner + +Here is a full example for classified ads: + +List template + +<h2>{$classified_ad_title}</h2> +<p>{$classified_ad_image:thumb}</p> +<p>{$classified_ad_short_description}</p> +<p>{$_full_view_link}<br /> +{$_user_message_link}</p> + +Display template + +<h2>{$classified_ad_title}</h2> +<p>{$classified_ad_image}</p> +<p>{$classified_ad_full_description}</p> +<p>{$_user_message_link}</p> + +Search definitions + +When editing a form, you can add a search definition. This gives you a way to +specify one or more sophisticated search forms for content created by this +form. + +Search definitions are optional. The user content and search pages provide +links to allow users to find content created by themselves and their friends, +as well as all content sorted in chronological order and (if recommendations +are allowed for that form) in order of recommendations. + +Search definitions allow you to create elaborate search forms and to specify +the order in which search results appear. You can also place a search form in +the Tools menu by providing some text in the Menu field. + +If a search definition is defined, it is displayed in the user content area +for your form. You can create multiple search definitions for each form. + +Form translation + +By default, the text for your form will be taken from the form and field +definitions that you saved to the database. + +This may not be convenient if you want to translate the form into multiple +languages. + +The form trsnlation page lets you export the text from your form and field +definitions into Elgg language files saved in the mod/form/languages/formtrans +directory. + +In this way you can create the form text through the web, test the form until +you are satisfied with it, then export the text and produce multiple language +versions. + +Managing field definitions + +As mentioned above, once created, field definitions are separate from form +definitions. There are two pages that allow you to manage your field +definitions. You can access these pages from links that appear on the left of +the Manage forms or User content pages. + +*List all fields* + +This lets you edit any field definition or delete one +entirely and remove it from all your forms. + +*List orphan fields* + +This lets you edit any orphan field definitions or delete one. An orphan field +is a field that is not currently on any form. + +You can also delete all orphan field definitions with one click if you are +viewing this page. + + + diff --git a/plugins/form/actions/manage_field.php b/plugins/form/actions/manage_field.php new file mode 100755 index 0000000000000000000000000000000000000000..63ec67a40979a7d5253e929ea7ba134473c05123 --- /dev/null +++ b/plugins/form/actions/manage_field.php @@ -0,0 +1,181 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main function for managing fields. + * + */ + + // Load form model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +global $CONFIG; + +$redirect_url = ''; + +admin_gatekeeper(); + +// Define context +set_context('form'); + +$form_action = get_input('form_action',''); +$type = get_input('type',''); +$username = get_input('username',''); +$profile = get_input('profile',''); + +// possible actions: add, change, edit, delete, move, add_existing, copy_existing, add_new + +switch($form_action) { + case "add": + $form_id = get_input('form_id',0); + form_set_field_definition(); + system_message(elgg_echo('form:field_add_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + break; + case "change": + $form_id = get_input('form_id',0); + form_set_field_definition(); + system_message(elgg_echo('form:field_change_response')); + if ($type == 'all' || $type == 'orphan') { + if (!$username) { + $username = get_entity(get_entity($form_id)->owner_guid)->username; + } + $redirect_url = $CONFIG->wwwroot.'mod/form/list_fields.php?type='.$type.'&username='.$username; + } else { + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + } + break; + case "edit": + $field_id = get_input('id',0,PARAM_INT); + $form_id = get_input('form_id',0,PARAM_INT); + $field = form_get_field_definition($field_id); + $choices = form_get_field_choices($field_id); + $title = elgg_echo('form:manage_field_title'); + //$body = form_get_field_form($map->form_id,$field); + $body = elgg_view('form/forms/manage_field', array('form_id'=>$form_id,'field'=>$field,'profile'=>$profile,'choices'=>$choices,'new_field_name'=>'','page_return_type'=>$type,'username'=>$username)); + $redirect_url = ''; + break; + case "edit_with_field_id": + $field_id = get_input('id',0); + $title = elgg_echo('form:manage_field_title'); + $field = form_get_field_definition($field_id); + $choices = form_get_field_choices($field_id); + //$body = form_get_field_form(0,$field); + $body = elgg_view('form/forms/manage_field', array('form_id'=>0,'field'=>$field,'profile'=>$profile,'choices'=>$choices,'new_field_name'=>'','page_return_type'=>$type,'username'=>$username)); + $redirect_url = ''; + break; + case "remove": + // remove this field from a form + $field_id = get_input('id',0); + $form_id = get_input('form_id',0); + form_field_remove($form_id,$field_id); + system_message(elgg_echo('form:field_remove_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + break; + case "delete": + // unlike remove, delete actually deletes the form definition itself + // and the references for all forms + $field_id = get_input('id',0); + //delete_records('form_fields_map','field_id',$field_id); + //delete_records('form_fields','ident',$field_id); + + form_field_delete($field_id); + + $type = get_input('type',''); + if ($type == 'orphan') { + system_message(elgg_echo('form:orphan_field_delete_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/list_fields.php?type=orphan&username='.$username; + } else { + system_message(elgg_echo('form:field_delete_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/list_fields.php?type=all&username='.$username; + } + + break; + case "delete_orphans": + form_delete_orphan_fields(get_user_from_username($username)->getGUID()); + system_message(elgg_echo('form:orphan_delete_all_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/list_fields.php?type=orphan&username='.$username; + break; + case "move": + $form_id = get_input('form_id',0); + $field_id = get_input('id',0); + $direction = get_input('direction',''); + if ($direction == 'up') { + form_field_moveup($form_id,$field_id); + } else if ($direction == 'down') { + form_field_movedown($form_id,$field_id); + } else if ($direction == 'top') { + form_field_movetop($form_id,$field_id); + } else if ($direction == 'bottom') { + form_field_movebottom($form_id,$field_id); + } + //system_message(elgg_echo('form:field_move_response')); + //$redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + break; + case "add_existing": + $existing_field_name = trim(get_input('existing_field_name','')); + $form_id = get_input('form_id',0); + $form = get_entity($form_id); + $field_id = form_get_field_id_from_name($existing_field_name,$form->owner_guid); + if ($field_id) { + if (form_add_existing_field($form_id,$field_id)) { + system_message(sprintf(elgg_echo('form:field_existing_add_response'), $existing_field_name)); + } else { + register_error(elgg_echo('form:field_add_error')); + } + } else { + register_error(elgg_echo('form:error_field_does_not_exist')); + } + + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + break; + case "copy_existing": + $existing_field_name = get_input('existing_field_name',''); + $new_field_name = get_input('new_field_name',''); + $form_id = get_input('form_id',0); + $form = get_entity($form_id); + $field_id = form_get_field_id_from_name($existing_field_name,$form->owner_guid); + + if ($field_id) { + $field = form_get_field_definition($field_id); + system_message(elgg_echo('form:field_add_description')); + $title = elgg_echo('form:add_new_title'); + //$body = form_get_field_form($form_id,$field,$form_name = ''); + $body = elgg_view('form/forms/manage_field', array('form_id'=>$form_id,'field'=>$field,'profile'=>$profile,'new_field_name'=>$new_field_name,'page_return_type'=>$type,'username'=>$username)); + $redirect_url = ''; + } else { + register_error(elgg_echo('form:error_field_does_not_exist')); + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + } + break; + case "add_new": + $new_field_name = get_input('new_field_name',''); + $form_id = get_input('form_id',0); + + // make sure that this field does not already exist + $form = get_entity($form_id); + $field_id = form_get_field_id_from_name($new_field_name,$form->owner_guid); + if ($field_id) { + register_error(elgg_echo('form:error_field_exists')); + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id; + } else { + $title = elgg_echo('form:add_new_title'); + $body = elgg_view('form/forms/manage_field', array('form_id'=>$form_id,'field'=>0,'profile'=>$profile,'new_field_name'=>$new_field_name,'page_return_type'=>$type,'username'=>$username)); + $redirect_url = ''; + } + break; +} + +if ($form_action == 'move') { + $fields = form_get_fields($form_id); + echo elgg_view('form/field_list',array('fields' => $fields,'form_id'=>$form_id)); +} else if ($redirect_url) { + forward($redirect_url); +} else { + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} +?> \ No newline at end of file diff --git a/plugins/form/actions/manage_form.php b/plugins/form/actions/manage_form.php new file mode 100755 index 0000000000000000000000000000000000000000..d566dae8427ce276a9b8fbc3e688f90931992a14 --- /dev/null +++ b/plugins/form/actions/manage_form.php @@ -0,0 +1,85 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main function for creating and changing forms. + * + */ + +// Load form model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +global $CONFIG; + +$redirect_url = ''; + +admin_gatekeeper(); + +$form_action = get_input('form_action',''); +$username = get_input('username',''); + +if ($form_action == 'add' || $form_action == 'change' ) { + // TODO - analyse to see if error checking is required + // Should at least make sure that the user does not try to + // add a form with an empty or existing form name + $form = form_set_form_definition(); + + set_context('form:admin'); + $form_id = $form->getGUID(); + $fields = form_get_fields($form_id); + $title = sprintf(elgg_echo('form:manage_form_title'),$form->title,$form->name); + $vars = array('form' => $form, 'fields' => $fields, 'form_username' => $username); + $body = elgg_view('form/forms/manage_form',$vars); + + if ($form_action == 'add') { + system_message(elgg_echo('form:create_form_response')); + } else { + system_message(elgg_echo('form:manage_form_response')); + } + +} else if ($form_action == 'delete') { + + $form_id = get_input('id',0); + $form = get_entity($form_id); + $username = get_entity($form->owner_guid)->username; + form_delete($form_id); + system_message(elgg_echo('form:delete_response')); + $redirect_url = $CONFIG->wwwroot.'pg/form/'.$username; + +} else if ($form_action == 'translate_status') { + + $form_id = get_input('id',0); + $translate = get_input('translate',0); + form_set_translation_status($form_id,$translate); + if ($translate) { + system_message(elgg_echo('form:translate_on_response')); + } else { + system_message(elgg_echo('form:translate_off_response')); + } + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_form_translation.php?id='.$form_id; +} else if ($form_action == 'user_content_status') { + form_set_user_content_status(get_input('user_content_status',0)); + if (!$username) { + $username = $_SESSION['user']->username; + } + system_message(elgg_echo('form:user_content_status_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_all_forms.php?username='.$username; +} else if ($form_action == 'manage_group_profile_categories') { + form_set_group_profile_categories(get_input('group_profile_categories','')); + system_message(elgg_echo('form:manage_group_profile_categories_response')); + $redirect_url = $CONFIG->wwwroot.'mod/form/manage_group_profile_categories.php'; +} else { + register_error(elgg_echo('form:invalid_action')); + $redirect_url = $CONFIG->wwwroot.'pg/form/'.$username; +} + +if ($redirect_url) { + forward($redirect_url); +} else { + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} +?> \ No newline at end of file diff --git a/plugins/form/actions/manage_form_data.php b/plugins/form/actions/manage_form_data.php new file mode 100755 index 0000000000000000000000000000000000000000..2afeb94446fe4596a3153d4510e45162802eb48f --- /dev/null +++ b/plugins/form/actions/manage_form_data.php @@ -0,0 +1,40 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main function for creating and changing forms. + * + */ + +// Load form model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +global $CONFIG; + +$form_action = get_input('form_action',''); +$form_data_id = get_input('d',0); +$form_data = get_entity($form_data_id); + +if ($form_action == 'delete') { + $form_id = $form_data->form_id; + if (form_delete_data($form_data_id)) { + system_message(elgg_echo('form:delete_data_response')); + } else { + register_error(elgg_echo('form:delete_error')); + } + forward($CONFIG->wwwroot.'mod/form/form.php?id='.$form_id); +} else if ($form_action == 'recommend') { + if (form_recommend($form_data_id)) { + system_message(elgg_echo('form:recommend_response')); + } else { + register_error(elgg_echo('form:recommend_error')); + } + + forward($form_data->getUrl()); +} + +?> \ No newline at end of file diff --git a/plugins/form/actions/manage_search_definition.php b/plugins/form/actions/manage_search_definition.php new file mode 100755 index 0000000000000000000000000000000000000000..9c62d0290efc159cb24fd6eda0ff145291462a4b --- /dev/null +++ b/plugins/form/actions/manage_search_definition.php @@ -0,0 +1,47 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main function for creating and changing forms. + * + */ + +// Load form model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +global $CONFIG; + +$redirect_url = ''; + +admin_gatekeeper(); + +$form_action = get_input('form_action',''); +$search_definition_id = get_input('sid',0); + +if ($form_action == 'add' || $form_action == 'change' ) { + // TODO - analyse to see if error checking is required + // Should at least make sure that the user does not try to + // add a search definition with an empty or existing name + $sd = form_set_search_definition($search_definition_id); + $form_id = $sd->form_id; + + if ($form_action == 'add') { + system_message(elgg_echo('form:create_search_definition_response')); + } else { + system_message(elgg_echo('form:manage_search_definition_response')); + } + +} else if ($form_action == 'delete') { + + $form_id = get_entity($search_definition_id)->form_id; + form_search_definition_delete($search_definition_id); + system_message(elgg_echo('form:delete_search_definition_response')); +} + +forward($CONFIG->wwwroot.'mod/form/list_search_definitions.php?form_id='.$form_id); + +?> \ No newline at end of file diff --git a/plugins/form/actions/submit.php b/plugins/form/actions/submit.php new file mode 100755 index 0000000000000000000000000000000000000000..b1980c7f48e36d3f00a72abe655198bede05def0 --- /dev/null +++ b/plugins/form/actions/submit.php @@ -0,0 +1,60 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Handles form submissions. + * + */ + +// Load form model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +global $CONFIG; + +// Define context +set_context('form:content'); + +$form_data_id = get_input('form_data_id',0); +$form_id = get_input('form_id',0); +$preview = get_input('preview',0); + +$form = get_entity($form_id); +$title = $form->title; + +if ($preview) { + $body = '<p class="form-description">'.elgg_echo('form:preview_results_description').'</p>'; + $form_data = form_get_data_from_form_submit($form_id); + $maps = form_get_maps($form_id); + if ($maps) { + foreach ($maps as $map) { + $field = get_entity($map->field_id); + $value = isset($form_data[$field->internal_name])?$form_data[$field->internal_name]:''; + $body .= '<p><b>'.$field->title.' ('.$field->internal_name.') : '.$value.'</p>'; + } + } + +} else { + $result = form_set_data_from_form($form_data_id); + if ($result->error_status) { + if ($result->error_reason == 'missing') { + register_error(elgg_view('form/missing_error',array('missing'=>$result->missing))); + } else if ($result->error_reason == 'save_failed') { + register_error(elgg_echo('form:err_save_failed')); + } + // redisplay the form + + $tab_data = form_get_data_for_edit_form($form,$result->form_data); + $body = elgg_view('form/forms/display_form', array('form'=>$form,'tab_data'=>$tab_data,'preview'=>$preview)); + } else { + // display response + $body = elgg_view('form/response',array('form'=>$form)); + } +} + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/display_object.php b/plugins/form/display_object.php new file mode 100755 index 0000000000000000000000000000000000000000..3c8a3f573010df8531dbf8ba0df62ee0622c8f01 --- /dev/null +++ b/plugins/form/display_object.php @@ -0,0 +1,37 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:content'); + +global $CONFIG; + +$form_data_id = get_input('d',0); +$form_data = $fd = get_entity($form_data_id); +$form_id = $form_data->form_id; +if($form_data->canEdit()) { + add_submenu_item(elgg_echo('form:edit_content'),$CONFIG->wwwroot.'mod/form/form.php?id='.$form_id.'&d='.$form_data_id,'0formadmin'); + add_submenu_item(elgg_echo('form:delete_content'),$CONFIG->wwwroot.'action/form/manage_form_data?form_action=delete&d='.$form_data_id,'0formadmin'); +} +set_input('form_id',$form_id); +$form = get_entity($form_id); + +$body = elgg_view('form/display_object',array('form_data'=>$form_data, 'form'=>$form)); + +$title = sprintf(elgg_echo('form:display_object_title'),$form->title); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/display_search_object.php b/plugins/form/display_search_object.php new file mode 100755 index 0000000000000000000000000000000000000000..28a4583ff74b0d44493212bb2a931a16bc86890d --- /dev/null +++ b/plugins/form/display_search_object.php @@ -0,0 +1,38 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:content'); + +global $CONFIG; + +$search_definition_id = get_input('sid',0); + +if ($search_definition_id) { + $sd = get_entity($search_definition_id); + $form_id = $sd->form_id; +} else { + $form_id = get_input('form_id',get_input('id',0)); +} + +$form_data_id = get_input('d',0); + +$body = elgg_view('form/display_search_object',array('form_id'=>$form_id, 'form_data_id'=>$form_data_id)); + +$title = elgg_echo('form:search_results_title'); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/form.php b/plugins/form/form.php new file mode 100755 index 0000000000000000000000000000000000000000..3cc673b21ae31cc239227a2d93a0d7107985aa74 --- /dev/null +++ b/plugins/form/form.php @@ -0,0 +1,52 @@ +<?php +/** + * Elgg form display + * Displays the specified Elgg form + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + // Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Load form model +require_once(dirname(__FILE__)."/models/model.php"); + +// Define context +set_context('form:content'); + +$form_id = get_input('id',0); +$form_data_id = get_input('d',0); +$preview = get_input('preview',0); + +$form = get_entity($form_id); + +if ($form && $form->type == 'object' && get_subtype_from_id($form->subtype) == 'form:form') { + set_page_owner($form->owner_guid); + if ($form_data_id && ($form_data = form_get_data($form_data_id))) { + if (get_entity($form_data_id)->canEdit()) { + $tab_data = form_get_data_for_edit_form($form,$form_data); + } else { + register_error(elgg_echo('form:content_not_found')); + forward(); + } + } else { + $tab_data = form_get_data_for_edit_form($form); + } + $title = form_form_t($form,'title'); + $body = elgg_view('form/forms/display_form', array('form'=>$form,'tab_data'=>$tab_data,'preview'=>$preview,'form_data_id'=>$form_data_id)); + + $pg_owner_entity = page_owner_entity(); + $username = $pg_owner_entity->username; + + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} else { + register_error(elgg_echo('form:not_found')); + forward(); +} +?> \ No newline at end of file diff --git a/plugins/form/images/16-arrow-down.png b/plugins/form/images/16-arrow-down.png new file mode 100755 index 0000000000000000000000000000000000000000..7ced90cd251aa0056eff0762c1a6372ba9980d79 Binary files /dev/null and b/plugins/form/images/16-arrow-down.png differ diff --git a/plugins/form/images/16-arrow-up.png b/plugins/form/images/16-arrow-up.png new file mode 100755 index 0000000000000000000000000000000000000000..310c61728814d896fc594912114a8953309199ad Binary files /dev/null and b/plugins/form/images/16-arrow-up.png differ diff --git a/plugins/form/images/16-em-cross.png b/plugins/form/images/16-em-cross.png new file mode 100755 index 0000000000000000000000000000000000000000..84a51140e0b26c042ed917c3f8901f5a1429dd0e Binary files /dev/null and b/plugins/form/images/16-em-cross.png differ diff --git a/plugins/form/images/16-em-down.png b/plugins/form/images/16-em-down.png new file mode 100755 index 0000000000000000000000000000000000000000..d5f2e3469297bdee9bfd77a46eb6263cdb9ea64e Binary files /dev/null and b/plugins/form/images/16-em-down.png differ diff --git a/plugins/form/images/16-em-left.png b/plugins/form/images/16-em-left.png new file mode 100755 index 0000000000000000000000000000000000000000..12b566471e86f5193c7cc3bdfdac6f41e93bb7a8 Binary files /dev/null and b/plugins/form/images/16-em-left.png differ diff --git a/plugins/form/images/16-em-open.png b/plugins/form/images/16-em-open.png new file mode 100755 index 0000000000000000000000000000000000000000..2461d0fadfeffc6a1a92085c52c4dc05d808a96b Binary files /dev/null and b/plugins/form/images/16-em-open.png differ diff --git a/plugins/form/images/16-em-pencil.png b/plugins/form/images/16-em-pencil.png new file mode 100755 index 0000000000000000000000000000000000000000..5ea781e6d026920bd29965066e5e62f175dbf7f6 Binary files /dev/null and b/plugins/form/images/16-em-pencil.png differ diff --git a/plugins/form/images/16-em-right.png b/plugins/form/images/16-em-right.png new file mode 100755 index 0000000000000000000000000000000000000000..3c52e970bac2228dbea8aa485ad7d57f8e7717e1 Binary files /dev/null and b/plugins/form/images/16-em-right.png differ diff --git a/plugins/form/images/16-tag-cross.png b/plugins/form/images/16-tag-cross.png new file mode 100755 index 0000000000000000000000000000000000000000..09230c296c0cf49837dc6b9e737660cc446f9857 Binary files /dev/null and b/plugins/form/images/16-tag-cross.png differ diff --git a/plugins/form/images/16-tag-pencil.png b/plugins/form/images/16-tag-pencil.png new file mode 100755 index 0000000000000000000000000000000000000000..6542ef91b17487b0dccb3b55501c53c43928b5d3 Binary files /dev/null and b/plugins/form/images/16-tag-pencil.png differ diff --git a/plugins/form/images/delete.gif b/plugins/form/images/delete.gif new file mode 100755 index 0000000000000000000000000000000000000000..ce452295d9af89d17a7aad76fe661fc844b7538a Binary files /dev/null and b/plugins/form/images/delete.gif differ diff --git a/plugins/form/images/garbage.png b/plugins/form/images/garbage.png new file mode 100755 index 0000000000000000000000000000000000000000..e8da106f726da8e03ffea10841e5149225ebe8ec Binary files /dev/null and b/plugins/form/images/garbage.png differ diff --git a/plugins/form/index.php b/plugins/form/index.php new file mode 100755 index 0000000000000000000000000000000000000000..23ec2fcb969077348bb3a24915ff6a2b94d8398f --- /dev/null +++ b/plugins/form/index.php @@ -0,0 +1,22 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Lists the current forms + * + */ + +// Define context +set_context('form'); + +set_page_owner(get_loggedin_userid()); + +$title = elgg_echo('form:list_forms_title'); +$body = elgg_view('form/forms/list_forms'); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +?> \ No newline at end of file diff --git a/plugins/form/languages/en.php b/plugins/form/languages/en.php new file mode 100755 index 0000000000000000000000000000000000000000..c5280dbc2d358ab4c46748e6428f17de7fd09001 --- /dev/null +++ b/plugins/form/languages/en.php @@ -0,0 +1,368 @@ +<?php + + $english = array( + + 'item:object:form' => "Forms", + 'item:object:form:form' => "Form definitions", + 'item:object:form:field' => "Form field definitions", + 'item:object:form:field_map' => "Form/field maps", + 'item:object:form:field_choice' => "Form field choice definitions", + 'item:object:form:search_definition' => "Form search definitions", + 'item:object:form_data' => "User content", + 'form:list_forms_title' => "User content", + 'form:manage_form_title' => "Manage form \"%s\" (%s)", + 'form:bad_form_id' => "Error: you have attempted to access a form that does not exist.", + 'form:create_form_title' => "Create form", + 'form:view_all_forms' => "User content", + 'form:edit' => "Edit", + 'form:remove' => "Remove", + 'form:remove_confirm' => "Are you sure that you want to remove this field from this form?", + 'form:move_up' => "Move up", + 'form:move_down' => "Move down", + 'form:move_top' => "Move to top", + 'form:move_bottom' => "Move to bottom", + 'form:form_manage_description' => "You can manage all aspects of this form using the tabs below.", + 'form:form_manage_button' => "Change", + 'form:current_fields' => "Current fields", + 'form:none' => "None", + 'form:preview_link_text' => "Preview this form", + 'form:public_link_text' => "Public link for this form", + 'form:add_existing_button' => "Add existing field", + 'form:add_existing_field_description' => "Enter the name of an existing field to add it to this form.", + 'form:copy_existing_button' => "Copy existing field", + 'form:copy_existing_field_description' => "Enter the name of an existing field and the name of the new " + ."field to create a copy that will be added to this form.", + 'form:add_new_button' => "Add new field", + 'form:add_new_description' => "Enter the name of a new field to add it to this form.", + 'form:existing_label' => "Existing field name", + 'form:new_label' => "New field name", + 'form:add_fields_title' => "Add fields", + 'form:add_existing_title' => "Add existing field", + 'form:copy_existing_title' => "Copy existing field", + 'form:add_new_title' => "Add new field", + 'form:create_form_description' => "Enter the information below and press the Create form button to create this form." + ." Once the form has been created, you will be able to add fields to it and specify other options depending upon the type of form.", + 'form:create_form_button' => "Create", + 'form:name_label' => "Form name", + 'form:name_description' => "Enter an internal name for this form (no blanks, only letters, numbers and/or underscores)", + 'form:title_label' => "Form title", + 'form:form_title_description' => "Enter a brief title. For content forms this will appear as a heading at the top of the form.", + 'form:description_label' => "Description", + 'form:form_description_description' => "Optionally enter a sentence or two of text describing your form. For content forms this will be displayed at the top of your content creation form to explain its purpose.", + 'form:listing_description_label' => "Listing Description", + 'form:form_listing_description' => "For content forms, you can optionally enter a sentence or two of text that will appear at the top of listings of form content.", + 'form:profile_title_label' => "Profile title", + 'form:profile_title_description' => "You can optionally enter a brief title here that will remind you what this profile is for.", + 'form:profile_description_label' => "Profile Description", + 'form:profile_description_description' => "You can optionally enter a sentence or two to remind you what this profile is for.", + 'form:response_text_label' => "Response text", + 'form:response_description' => "Enter the content that will be displayed after the form has been submitted.", + 'form:form_access_label' => "Access", + 'form:form_access_description' => "The access determines who is allowed to see this form.", + 'form:create_form_response' => "This form has been created.", + 'form:manage_form_response' => "Your changes to this form have been saved.", + 'form:delete_response' => "The form has been deleted.", + 'form:invalid_action' => "Error: invalid form action.", + 'form:field_add_response' => "This new field has been added to this form.", + 'form:field_add_error' => "Error: unable to add this field to the form. Perhaps it is already attached to this form?", + 'form:field_change_response' => "Your changes to this field have been saved.", + 'form:manage_field_title' => "Edit field", + 'form:add_field_title' => "Add field", + 'form:field_remove_response' => "This field has been removed from this form.", + 'form:orphan_field_delete_response' => "This field definition has been deleted.", + 'form:field_delete_response' => "This field definition has been deleted and has been removed from all forms.", + 'form:field_move_response' => "This field has been moved.", + 'form:field_existing_add_response' => "Field \"%s\" has been added.", + 'form:field_add_description' => "Review the new field definition below and click on the \"Create field\" button" + ." at the bottom to save it.", + 'form:error_field_does_not_exist' => "Error: This field does not exist.", + 'form:error_field_exists' => "Error: This field already exists.", + 'form:yes' => "yes", + 'form:no' => "no", + 'form:horizontal' => "horizontal", + 'form:vertical' => "vertical", + 'form:manage_field_description' => "Please complete the form below and click on the \"Add field\" at the bottom.", + 'form:add_field_description' => "Please complete the form below and click on the \"Change field\" at the bottom.", + 'form:internal_name_label' => "Internal name", + 'form:internal_name_description' => "The internal name for this field - must be one word (underscores allowed, but no blanks).", + 'form:title_label' => "Title", + 'form:title_description' => "The title (very short description) for this field", + 'form:description_label' => "Description", + 'form:description_description' => "The full description that should be displayed for this field", + 'form:required_label' => "Required", + 'form:required_description' => "Is this field required?", + 'form:admin_only_label' => "Admin only", + 'form:admin_only_description' => "Can this field only be edited by an administrator?", + 'form:profile_label' => "Profile field", + 'form:profile_description' => "Should the user be able to edit this field as part of their profile?", + 'form:field_type_label' => "Field type", + 'form:profile_shorttext_label' => "Short text line (250 px long)", + 'form:profile_text_label' => "Long text line (100% width)", + 'form:profile_smallbox_label' => "Small text box (250 px wide)", + 'form:profile_longtext_label' => "Large text box (100% width)", + 'form:profile_smallbox_no_p_label' => "Small text box (250 px wide), no paragraphing in output", + 'form:profile_longtext_no_p_label' => "Large text box (100% width), no paragraphing in output", + 'form:profile_date_dmy_label' => "Date (day/month/year)", + 'form:profile_date_mdy_label' => "Date (month/day/year)", + 'form:profile_calendar_label' => "Calendar", + 'form:profile_access_label' => "Access pulldown", + 'form:profile_keywords_label' => "Tags box", + 'form:profile_profile_photo_label' => "Profile photo", + 'form:profile_image_label' => "Image upload", + 'form:profile_video_box_label' => "Video box", + 'form:profile_invite_box_label' => "Invitation box", + 'form:profile_contact_label' => "Contact field (Email, Skype, MSN etc.)", + 'form:profile_choices_label' => "Pulldown, radio or checkboxes", + 'form:profile_config_title' => "Profile field configuraton", + 'form:category_label' => "Tab", + 'form:category_description' => "The tab determines the section of the form that this field appears in.", + 'form:subtype_label' => "Subtypes", + 'form:subtype_description' => "This can be a comma-separated list of user or group subtypes. If supplied," + ." this profile question will only appear for users or groups with the given subtypes.", + + 'form:invisible_label' => "Invisible", + 'form:invisible_description' => "Invisible fields can be edited in the profile edit form but never appear on the profile itself.", + 'form:column_label' => "Primary profile column", + 'form:column_description' => "The area in which this field should appear in the primary profile region at the top (if at all).", + 'form:choice_header' => "Choice configuration", + 'form:choice_field_type_label' => "Field type", + 'form:choice_field_type_description' => "Choose the type of field.", + 'form:dropdown' => "Pulldown (select) box", + 'form:radio' => "Radio buttons", + 'form:checkbox' => "Checkbox group", + 'form:default_value_label' => "Default value", + 'form:default_value_description' => "Enter the default value for this field. If the field is a checkbox group, then you can precheck" + ." several checkbox values by entering a comma-separated list of values.", + 'form:is_keyword_tag_label' => "Keyword tag", + 'form:is_keyword_tag_description' => "If yes, then this field will be treated as a searchable keyword tag and will be linked in profiles.", + 'form:orientation_label' => "Orientation", + 'form:orientation_description' => "If this field is made up of radio buttons or a checkbox group, then you can specify the orientation.", + 'form:access_label' => "Default access", + 'form:access_description' => "Set the default access value for this profile field.", + 'form:options_header' => "Options", + 'form:options_value_header' => "Value", + 'form:options_label_header' => "Label (optional)", + 'form:options_description' => "The label is optional. If you specify a label for one option, then you need to specify one for all options.", + 'form:options_add_button' => "Add option", + 'form:add_field_button' => "Add field", + 'form:change_field_button' => "Change field", + 'form:this_form_link_text' => "Return to form page", + 'form:form_link_text' => "List all forms", + 'form:field_link_text' => "List all fields", + 'form:use_system_default_access' => "Use system default access level", + 'form:form_delete_confirm' => "Are you sure that you want to delete this form?", + 'form:export' => "Export", + 'form:preview' => "Preview", + 'form:link' => "Link", + 'form:no_forms' => "There are no forms.", + 'form:add_new_link' => "Add form", + 'form:list_all_fields_link' => "List all fields", + 'form:list_orphan_fields_link' => "List orphan fields", + 'form:import_profile_link' => "Import profile", + 'form:error_no_such_user' => "Error: no such user.", + 'form:url' => "url", + 'form:email' => "email", + 'form:aim' => "aim", + 'form:msn' => "msn", + 'form:skype' => "skype", + 'form:icq' => "icq", + 'form:delete' => "Delete", + 'form:delete_orphans' => "Delete all orphan fields", + 'form:orphan_delete_all_confirm' => "Are you sure that you want to delete all the orphan field definitions?", + 'form:orphan_delete_confirm' => "Are you sure that you want to delete this field definition?", + 'form:content_delete_confirm' => "Are you sure that you want to delete this content?", + 'form:field_delete_confirm' => "Are you sure that you want to delete this field definition and erase it from all forms?", + 'form:orphan_list_description' => "This page lists all the fields not currently associated with a form.", + 'form:field_list_description' => "This page lists all the currently defined fields.", + 'form:no_fields' => "There are no fields.", + 'form:list_fields_title' => "Field listing", + 'form:list_orphan_fields_title' => "Orphan field listing", + 'form:orphan_delete_all_response' => "The orphan field definitions have all been deleted.", + 'form:not_found' => "This form does not exist or you do not have the right to see it.", + 'form:content_not_found' => "This form content does not exist or you do not have the right to edit it.", + 'form:basic_tab_label' => "Basic", + 'form:field_adders_tab_label' => "Add field", + 'form:display_templates_tab_label' => "Templates", + 'form:field_list_tab_label' => "Fields", + 'form:last_bit_tab_label' => "Configuration", + 'form:profile_left' => "left", + 'form:profile_right' => "right", + 'form:profile_bottom' => "bottom", + 'form:search_definition_title' => "Manage search definition for \"%s\"", + 'form:search_field_label' => "Searchable fields", + 'form:search_field_description' => "Supply a comma-separated list of the internal names of the fields you want to be on the search form.", + 'form:list_template_label' => "List template", + 'form:list_template_description' => "Supply an HTML template if you want the search results to be displayable in the list format.", + 'form:gallery_template_label' => "Gallery template", + 'form:gallery_template_description' => "Supply an HTML template if you want the search results to be displayable in the gallery format.", + 'form:display_template_label' => "Display template", + 'form:display_template_description' => "Supply an HTML template for the full content display.", + 'form:search_definition_delete_confirm' => "Are you sure that you want to delete this search definition?", + 'form:no_search_definitions' => "There are no search definitions.", + 'form:list_search_definitions_title' => "Search definitions for form \"%s\"", + 'form:list_search_definitions_link' => "List search definitions", + 'form:add_new_search_definition_link_text' => "Add search definition", + 'form:internalname_label' => "Internal name", + 'form:search_definition_internalname_description' => "The internal name for this search definition - " + ."must be one word (underscores allowed, but no blanks).", + 'form:search_order_label' => "Search order field", + 'form:search_order_description' => "Normally search results are returned with the most recent at the top. If you want to specify another sort " + ."field, enter its internal name here.", + 'form:expiryfield_label' => "Expiry field", + 'form:expiryfield_description' => "If you want content to stop appearing in search results " + ."after a certain date, enter the internal name of the field containing the expiry date.", + 'form:create_search_definition_response' => "The search definition was created.", + 'form:manage_search_definition_response' => "The search definition was changed.", + 'form:delete_search_definition_response' => "The search definition was deleted.", + 'form:add_new_profile_form_link' => "Add profile form", + 'form:add_new_group_profile_form_link' => "Add group profile form", + 'form:search_title' => "Search", + 'form:search_button' => "Search", + 'form:search_title_label' => "Search title", + 'form:search_definition_search_title_description' => "Provide a title that will appear on the search form.", + 'form:search_description_label' => "Search description", + 'form:search_definition_search_description_description' => "Provide instructions that will appear at the top of the search form.", + 'form:search_page_link' => "Search page", + 'form:search_results_title' => "Search results", + 'form:no_search_results_profiles' => "None of our members matched your search request.", + 'form:no_search_results' => "Your search returned no results.", + 'form:gallery_format' => "Gallery format", + 'form:listing_format' => "List format", + 'form:no_profiles' => "No, no profiles", + 'form:show_profiles_label' => "Profile display", + 'form:show_profiles_description' => "If you would like this search to return the profiles of the people who own the content, " + ."select the Gallery or List format. Otherwise you can specify a list and display template for the content below.", + 'form:show_profiles_description_for_profile_forms' => "Select the Gallery or List format for the profile display.", + 'form:submit' => "Submit", + 'form:tab_bit' => "(Tab: %s)", + 'form:error_save_failed' => "Your submission failed. Please try later.", + 'form:save_succeeded' => "Your information has been saved.", + 'form:preview_results_description' => "Here is the information that would have been saved as a result of this form submission.", + 'form:preview_description' => "This is a form preview and will show the form submission results without saving the data.", + 'form:error_missing_fields' => "Error: You must provide the following required information: %s.", + 'form:delete_data_response' => "Your content has been deleted.", + 'form:no_content' => "No content is available.", + 'form:add' => "Add", + 'form:add_content' => "Add content", + 'form:view_mine' => "View mine", + 'form:view_friends' => "View friends", + 'form:view_recommended' => "View recommended", + 'form:recommended' => "Recommended", + 'form:view_all' => "View all", + 'form:admin_title' => "Administrator options", + 'form:submitted' => "Submitted: %s", + 'form:updated' => "last updated: %s", + 'form:manage_forms_title' => "Manage forms", + 'form:main_forms_link' => "User content", + 'form:send_a_message' => "Click here to send a message to this person", + 'form:full_view' => "Full view", + 'form:return_to_search' => "Return to search", + 'form:return_to_search_results' => "Return to search results", + 'form:allow_comments_label' => "Allow commenting on form submissions", + 'form:allow_recommendations_label' => "Allow recommending form submissions", + 'form:recommend_response' => "You have recommended this item.", + 'form:recommendations' => "%s recommendations", + 'form:recommendation' => "%s recommendation", + 'form:recommend_error' => "Either you have already recommended this item or your recommendation could not be saved.", + 'form:recommend_this' => "Recommend this", + 'form:translate_description' => "You can set this form to use the Elgg translation system. Before you do so, " + ."copy the content below with the appropriate translation into a language file in mod/form/languages/formtrans", + 'form:manage_translations_link' => "Form translation", + 'form:manage_translations_title' => "Manage translations for form \"%s\" (%s)", + 'form:translate_on_response' => "This form will use the Elgg translation system.", + 'form:translate_off_response' => "This form will not use the Elgg translation system.", + 'form:text_from_database' => "No, take the text as defined in the form system", + 'form:use_translation_system' => "Yes, use the Elgg translation system", + 'form:tabs_translate_description' => "also, make sure that the tabs below have appropriate translations in the same file:", + 'form:translation_status_title' => "Translation status", + 'form:translation_content_title' => "Translation content", + 'form:translate_content_description' => "Here is the content in your form, ready for translation.", + 'form:usersettings:save:ok' => "Your languages preferences for viewing content were saved.", + 'form:usersettings:save:fail' => "Error: your languages preferences for viewing content could not be saved.", + 'form:usersettings_title' => "Content languages", + 'form:usersettings_description' => "Select any of the languages below to use when searching for content.", + 'form:message' => "Message", + 'form:contacts' => "Contacts", + 'form:invite_message' => "%s has invited you to view this content:\n\n%s", + 'form:user_message' => "\n\nand has added this message:\n\n%s", + 'form:invite_subject' => "%s has sent you an invitation", + 'form:profiles' => "Profiles", + 'form:user_content_status_title' => "Put User content links in Tools and sidebar menus", + 'form:put_user_content_in_menu_for_all_users' => "For all users", + 'form:put_user_content_in_menu_for_admins_only' => "For admins only", + 'form:user_content_status_response' => "The user content status has been changed.", + 'form:email_form_label' => "Email form", + 'form:email_form_description' => "Tick this box if the results from submitting this form should be emailed to someone rather than being saved to the database.", + 'form:email_to_label' => "Email to", + 'form:email_to_description' => "If this is an email form, the person who the results should be emailed to.", + 'form:results_send_header' => "%s (%s) submitted the following information to form \"%s\" (%s) at %s", + 'form:results_send_anonymous_header' => "An anonymous user submitted the following information to form \"%s\" (%s) at %s", + 'form:results_send_subject' => "Submission to %s", + 'form:edit_page_link' => "Edit this form", + 'form:profile_category_label' => "Profile category", + 'form:profile_category_description' => "If the profile category is set, this form will only be used for users or groups in the specified category.", + 'form:profile_format_label' => "Profile format", + 'form:profile_format_description' => "Choose the way this profile will be displayed.", + 'form:profile_format_tabbed_option_label' => "tabbed", + 'form:profile_format_wide_tabbed_option_label' => "wide tabbed", + 'form:profile_format_default_option_label' => "default", + 'form:profile_format_no_extended_option_label' => "default (no extended profile)", + 'form:menu_label' => "Menu", + 'form:search_menu_description' => "Enter a menu label here if you want a link to this search form to appear in the main Tools menu", + 'form:extended_profile_title' => "%s's extended profile", + 'form:main_profile_link_text' => "Main profile", + 'form:extended_profile_link_text' => "Extended profile", + 'form:error_no_profile_form' => "Error: no profile form exists. You must create at least one profile form to use the flexprofile plugin.", + 'form:error_no_group_profile_form' => "Error: no group profile form exists. You must create at least one group profile form for this group category " + ."or a group profile form with a blank category to use the flexgroupprofile plugin.", + 'form:manage_group_profile_categories_title' => "Manage group profile categories", + 'form:manage_group_profile_categories_description' => "Enter the names of your group categories below, one per line.", + 'form:manage_group_profile_categories_response' => "The group profile categories have been saved.", + 'form:new_group_description' => "Please enter the information below to create a new group.", + 'form:content_type' => "Content form", + 'form:user_profile_type' => "User profile form", + 'form:group_profile_type' => "Group profile form", + 'form:file_type' => "File form", + 'form:type_label' => "Form type", + 'form:type_description' => "Specify how this form will be used.", + 'form:form_list' => "Form list", + 'form:yes' => "yes", + 'form:no' => "no", + 'form:group_category_dropdown' => "Group profile category select", + 'form:submission_to' => "Submission to", + 'form:display_object_title' => "Submission to \"%s\"", + 'form:edit_content' => "Edit content", + 'form:delete_content' => "Delete content", + 'form:default_response_text' => "Thank you for your submission.", + 'form:delete_error' => "Unable to delete.", + 'form:comment' => " comment", + 'form:comments' => " comments", + 'form:enable_display_menu_label' => "Put content display in Tools menu", + 'form:enable_display_menu_description' => "Tick this box if you want the content display page for this form to appear in the Tools menu.", + 'form:display_menu_title_label' => "Content display tools menu title", + 'form:display_menu_title_description' => "Title to use if displaying a link to the content display page for this form in the Tools menu.", + 'form:enable_create_menu_label' => "Put content creation in Tools menu", + 'form:enable_create_menu_description' => "Tick if you want the content creation page for this form to appear in the Tools menu.", + 'form:create_menu_title_label' => "Content creation tools menu title", + 'form:create_menu_title_description' => "Title to use if displaying a link to the content creation page for this form in the Tools menu.", + + /** + * Form data (content form) river + **/ + + //generic terms to use + 'form:river:created' => "%s added", + 'form:river:commented' => "%s commented on", + 'form:river:updated' => "%s updated", + + //these get inserted into the river links to take the user to the entity + 'form:river:this_content' => "this content", + 'form:river:destination' => "to \"%s\".", + 'form:river:title' => "this submission to \"%s\".", + 'form_data:river:annotate' => "a comment on", + + ); + + add_translation("en",$english); + +?> \ No newline at end of file diff --git a/plugins/form/languages/formtrans/en.php b/plugins/form/languages/formtrans/en.php new file mode 100755 index 0000000000000000000000000000000000000000..e402a8a385dd14d059b27e4226c4b9529b72d783 --- /dev/null +++ b/plugins/form/languages/formtrans/en.php @@ -0,0 +1,26 @@ +<?php + + $english = array( + +'form:formtrans:kevcontent:title' => "A non-profile form", +'form:formtrans:kevcontent:description' => "This tests a non-profile form, eg. classified ads.", +'form:formtrans:kevcontent:response_text' => "Thanks for providing this useful content!", +'form:fieldtrans:kevput2:title' => "Favourite season", +'form:fieldtrans:kevput2:description' => "What do you think?", +'form:fieldtrans:bio:title' => "About me", +'form:fieldtrans:bio:description' => "Tell everyone a bit about yourself", +'form:fieldtrans:pic:title' => "A picture", +'form:fieldtrans:pic:description' => "Upload a picture", +'form:fieldtrans:kevcal:title' => "Calendar", +'form:fieldtrans:kevcal:description' => "Select a date", +'form:sdtrans:kevcontent:classified_search_general:title' => "Search classified ads", +'form:sdtrans:kevcontent:classified_search_general:description' => "Enter your search criteria below.", +'form:sdtrans:kevcontent:testsearch1:title' => "Test search", +'form:sdtrans:kevcontent:testsearch1:description' => "This is just a way to make sure that the search works.", +'form:sdtrans:kevcontent:search1:title' => "Sample profile search", +'form:sdtrans:kevcontent:search1:description' => "Enter values in the fields below to find people on this site. If you don't enter a value for a given field, then the results will include people who set any value for that field.", +'form:tabtrans:Basic' => "Basic", + ); + + add_translation("en",$english); +?> \ No newline at end of file diff --git a/plugins/form/list_fields.php b/plugins/form/list_fields.php new file mode 100755 index 0000000000000000000000000000000000000000..8d530452abae6544b53d60c6f2f4b77ac5579ebe --- /dev/null +++ b/plugins/form/list_fields.php @@ -0,0 +1,45 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Lists fields owned by the user. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Load form model +require_once(dirname(__FILE__)."/models/model.php"); + +// Define context +set_context('form:admin'); + +admin_gatekeeper(); + +global $CONFIG; + +$username = get_input('username',''); +$user = get_user_by_username($username); +if ($user) { + $type = get_input('type',''); + if ($type == 'orphan') { + $fields = form_get_orphan_fields($user->getGUID()); + $title = elgg_echo('form:list_orphan_fields_title'); + } else { + $fields = form_get_all_fields($user->getGUID()); + $title = elgg_echo('form:list_fields_title'); + } + + $body = elgg_view('form/forms/list_fields', array('user'=>$user, 'fields'=>$fields, 'page_return_type'=>$type)); + + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} else { + register_error(elgg_echo('form:error_no_such_user')); + forward(); +} +?> \ No newline at end of file diff --git a/plugins/form/list_search_definitions.php b/plugins/form/list_search_definitions.php new file mode 100755 index 0000000000000000000000000000000000000000..7bdc2125de3f77780517fa4d2c6f6d8de878356d --- /dev/null +++ b/plugins/form/list_search_definitions.php @@ -0,0 +1,40 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Lists the current forms + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:admin'); + +admin_gatekeeper(); + +global $CONFIG; + +$form_id = get_input('form_id',0); +$user = get_entity(get_entity($form_id)->owner_guid); +if ($user) { + $username = $user->username; + set_page_owner($user->getGUID()); + + $form = get_entity($form_id); + + $title = sprintf(elgg_echo('form:list_search_definitions_title'),$form->title); + $body = elgg_view('form/forms/list_search_definitions', array('form_id'=>$form_id)); + + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} else { + register_error(elgg_echo('form:error_no_such_user')); + forward(); +} + +?> \ No newline at end of file diff --git a/plugins/form/manage_all_forms.php b/plugins/form/manage_all_forms.php new file mode 100755 index 0000000000000000000000000000000000000000..abcb2d8731a06d44c1cc12b54ab9934e74fb64c0 --- /dev/null +++ b/plugins/form/manage_all_forms.php @@ -0,0 +1,43 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Displays a list of user-generated content + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:admin'); + +global $CONFIG; + +admin_gatekeeper(); + +$username = get_input('username'); +if ($username) { + $user = get_user_by_username($username); +} else { + $user = get_loggedin_user(); +} + +if ($user) { + set_page_owner($user->getGUID()); + + $body = elgg_view('form/forms/manage_all_forms',array('username'=>$username)); + + $title = elgg_echo('form:manage_forms_title'); + + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} else { + register_error(elgg_echo('form:error_no_such_user')); + forward(); +} + +?> \ No newline at end of file diff --git a/plugins/form/manage_form.php b/plugins/form/manage_form.php new file mode 100755 index 0000000000000000000000000000000000000000..bd3afbad4ad8984b8f8551fa3d92dcadd9c61d8b --- /dev/null +++ b/plugins/form/manage_form.php @@ -0,0 +1,52 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Load form model +require_once(dirname(__FILE__)."/models/model.php"); + +// Define context +set_context('form:admin'); + +admin_gatekeeper(); + +global $CONFIG; + +$form_id = get_input('id',0); +$username = get_input('username',''); +$profile = get_input('profile',''); + +if ($form_id) { + $form = get_entity($form_id); + if ($form) { + $fields = form_get_fields($form_id); + $owner = get_entity($form->owner_guid); + $username = $owner->username; + $vars = array('form' => $form,'fields'=>$fields,'form_username'=>$username); + $title = sprintf(elgg_echo('form:manage_form_title'),$form->title,$form->name); + + } else { + register_error(elgg_echo('form:bad_form_id')); + forward($CONFIG->wwwroot.'pg/form/'.$username); + } +} else { + $vars = array('form' => '','form_username'=>$username,'profile'=>$profile); + $title = elgg_echo('form:create_form_title'); +} + +$body = elgg_view('form/forms/manage_form',$vars); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/manage_form_translation.php b/plugins/form/manage_form_translation.php new file mode 100755 index 0000000000000000000000000000000000000000..4e8c7377d00519e0271c8aef6ec4fc08f9a70d4d --- /dev/null +++ b/plugins/form/manage_form_translation.php @@ -0,0 +1,49 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Load form model +require_once(dirname(__FILE__)."/models/model.php"); + +// Define context +set_context('form:admin'); + +admin_gatekeeper(); + +global $CONFIG; + +$form_id = get_input('id',0); +$username = get_input('username',''); +$profile = get_input('profile',''); + +$view_all_link_text = elgg_echo('form:view_all_forms'); + +$form = get_entity($form_id); +if ($form) { + $fields = form_get_fields($form_id); + $owner = get_entity($form->owner_guid); + $username = $owner->username; + $vars = array('form' => $form,'fields'=>$fields,'username'=>$username); + $title = sprintf(elgg_echo('form:manage_translations_title'),$form->title,$form->name); + +} else { + register_error(elgg_echo('form:bad_form_id')); + forward($CONFIG->wwwroot.'pg/form/'.$username); +} + +$body = elgg_view('form/forms/manage_form_translation',$vars); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/manage_group_profile_categories.php b/plugins/form/manage_group_profile_categories.php new file mode 100755 index 0000000000000000000000000000000000000000..fb56015b922a893cb9abb1c40e6e110d2597e3eb --- /dev/null +++ b/plugins/form/manage_group_profile_categories.php @@ -0,0 +1,32 @@ +<?php + +/** + * Manage group categories + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Load form model +require_once(dirname(__FILE__)."/models/profile.php"); + +// Define context +set_context('form:admin'); + +admin_gatekeeper(); + +$group_profile_categories = form_get_group_profile_categories(); + +$title = elgg_echo('form:manage_group_profile_categories_title'); +$body = elgg_view('form/forms/manage_group_profile_categories',array('group_profile_categories'=>$group_profile_categories)); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/manage_search_definition.php b/plugins/form/manage_search_definition.php new file mode 100755 index 0000000000000000000000000000000000000000..e96137998faecb8469d0f0a57303ab45c1081b96 --- /dev/null +++ b/plugins/form/manage_search_definition.php @@ -0,0 +1,46 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:admin'); + +admin_gatekeeper(); + +global $CONFIG; + +$search_definition_id = get_input('sid',0); + +if ($search_definition_id) { + $form_id = get_entity($search_definition_id)->form_id; +} else { + $form_id = get_input('form_id',0); +} + +$form = get_entity($form_id); + +if ($form) { + $username = get_entity($form->owner_guid)->username; + $title = sprintf(elgg_echo('form:search_definition_title'),$form->title); + +} else { + register_error(elgg_echo('form:bad_form_id')); + forward(); +} + +$body = elgg_view('form/forms/manage_search_definition',array('form'=>$form,'search_definition_id'=>$search_definition_id)); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/manifest.xml b/plugins/form/manifest.xml new file mode 100755 index 0000000000000000000000000000000000000000..8f869e326f6f553c77bea1f2dce8db833776b042 --- /dev/null +++ b/plugins/form/manifest.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest> + <field key="author" value="Kevin Jardine <kevin@radagast.biz>" /> + <field key="version" value="0.8" /> + <field key="description" value="Elgg form plugin" /> + <field key="website" value="http://radagast.biz/" /> + <field key="copyright" value="(C) Radagast Solutions 2009" /> + <field key="licence" value="GNU Public License version 2" /> + <field key="elgg_version" value="2009030101" /> +</plugin_manifest> diff --git a/plugins/form/models/field_types.php b/plugins/form/models/field_types.php new file mode 100755 index 0000000000000000000000000000000000000000..12190758246622f1ddcadbb630be51a6fc90cfd1 --- /dev/null +++ b/plugins/form/models/field_types.php @@ -0,0 +1,81 @@ +<?php +$form_field_types = array( + 'shorttext' => (object) array( + 'label' => elgg_echo('form:profile_shorttext_label'), + 'input_view' => 'form/input/shorttext', + 'output_view' => 'output/text' + ), + 'text' => (object) array( + 'label' => elgg_echo('form:profile_text_label'), + 'input_view' => 'input/text', + 'output_view' => 'output/text' + ), + 'smallbox' => (object) array( + 'label' => elgg_echo('form:profile_smallbox_label'), + 'input_view' => 'form/input/smallbox', + 'output_view' => 'output/longtext' + ), + 'longtext' => (object) array( + 'label' => elgg_echo('form:profile_longtext_label'), + 'input_view' => 'input/longtext', + 'output_view' => 'output/longtext' + ), + 'smallbox_no_p' => (object) array( + 'label' => elgg_echo('form:profile_smallbox_no_p_label'), + 'input_view' => 'form/input/smallbox', + 'output_view' => 'form/output/longtext_no_p' + ), + 'longtext_no_p' => (object) array( + 'label' => elgg_echo('form:profile_longtext_no_p_label'), + 'input_view' => 'input/longtext', + 'output_view' => 'form/output/longtext_no_p' + ), + 'calendar' => (object) array( + 'label' => elgg_echo('form:profile_calendar_label'), + 'input_view' => 'input/calendar', + 'output_view' => 'output/calendar' + ), + 'tags' => (object) array( + 'label' => elgg_echo('form:profile_keywords_label'), + 'input_view' => 'input/tags', + 'output_view' => 'form/output/tags' + ), + 'image_upload' => (object) array( + 'label' => elgg_echo('form:profile_image_label'), + 'input_view' => 'input/file', + 'output_view' => 'form/output/image' + ), + 'video_box' => (object) array( + 'label' => elgg_echo('form:profile_video_box_label'), + 'input_view' => 'input/text', + 'output_view' => 'form/output/video_box' + ), + 'invite_box' => (object) array( + 'label' => elgg_echo('form:profile_invite_box_label'), + 'input_view' => 'form/input/invite_box', + 'output_view' => '' + ), + 'access' => (object) array( + 'label' => elgg_echo('form:profile_access_label'), + 'input_view' => 'input/access', + 'output_view' => 'output/access' + ), + 'group_category' => (object) array( + 'label' => elgg_echo('form:group_category_dropdown'), + 'input_view' => 'form/input/group_categories', + 'output_view' => 'form/output/choice' + ), + // contacts and choices get special handling + 'contact' => (object) array( + 'label' => elgg_echo('form:profile_contact_label'), + 'input_view' => '', + 'output_view' => '' + ), + 'choices' => (object) array( + 'label' => elgg_echo('form:profile_choices_label'), + 'input_view' => '', + 'output_view' => '' + ), +); + +?> \ No newline at end of file diff --git a/plugins/form/models/model.php b/plugins/form/models/model.php new file mode 100755 index 0000000000000000000000000000000000000000..5716da5e4c8b92964e79896d46fa2c31516d614d --- /dev/null +++ b/plugins/form/models/model.php @@ -0,0 +1,1622 @@ +<?php +require_once(dirname(__FILE__).'/profile.php'); + +function form_get_form_field_types() { + // Load form field types model + include(dirname(dirname(__FILE__))."/models/field_types.php"); + $form_custom_field_types = form_custom_field_type_manager(); + if ($form_custom_field_types) { + return array_merge($form_field_types,$form_custom_field_types); + } else { + return $form_field_types; + } +} + +function form_custom_field_type_manager($type='',$label='',$input_view='',$output_view='') { + static $form_custom_field_types; + + if (!isset($form_custom_field_types)) { + $form_custom_field_types = array(); + } + + if ($type) { + $obj = new stdClass(); + $obj->label = $label; + $obj->input_view = $input_view; + $obj->output_view = $output_view; + $form_custom_field_types[$type] = $obj; + } + return $form_custom_field_types; +} + +function form_delete_file($file_id) { + + $file = get_entity($file_id); + + if ($file->canEdit()) { + $thumbnail = $file->thumbnail; + $smallthumb = $file->smallthumb; + $largethumb = $file->largethumb; + if ($thumbnail) { + + $delfile = new ElggFile(); + $delfile->owner_guid = $file->owner_guid; + $delfile->setFilename($thumbnail); + $delfile->delete(); + + } + if ($smallthumb) { + + $delfile = new ElggFile(); + $delfile->owner_guid = $file->owner_guid; + $delfile->setFilename($smallthumb); + $delfile->delete(); + + } + if ($largethumb) { + + $delfile = new ElggFile(); + $delfile->owner_guid = $file->owner_guid; + $delfile->setFilename($largethumb); + $delfile->delete(); + + } + + return $file->delete(); + } +} + +function form_generate_thumbnail($file,$fieldname) { + // Generate thumbnail (if image) + $prefix = "file/"; + $filestorename = strtolower(time().$_FILES[$fieldname]['name']); + if (substr_count($file->getMimeType(),'image/')) + { + $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),60,60, true); + $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),153,153, true); + $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(),600,600, false); + if ($thumbnail) { + $thumb = new ElggFile(); + $thumb->setMimeType($_FILES[$fieldname]['type']); + + $thumb->setFilename($prefix."thumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumbnail); + $thumb->close(); + + $file->thumbnail = $prefix."thumb".$filestorename; + + $thumb->setFilename($prefix."smallthumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumbsmall); + $thumb->close(); + $file->smallthumb = $prefix."smallthumb".$filestorename; + + $thumb->setFilename($prefix."largethumb".$filestorename); + $thumb->open("write"); + $thumb->write($thumblarge); + $thumb->close(); + $file->largethumb = $prefix."largethumb".$filestorename; + + } + } +} + +function form_handle_file_upload($fieldname,$access_id,$container_guid=0) { + // Extract file from, save to default filestore (for now) + $prefix = "file/"; + $file = new FilePluginFile(); + $filestorename = strtolower(time().$_FILES[$fieldname]['name']); + $file->setFilename($prefix.$filestorename); + $file->setMimeType($_FILES[$fieldname]['type']); + + $file->originalfilename = $_FILES[$fieldname]['name']; + + $file->subtype="file"; + + $file->access_id = $access_id; + + $file->open("write"); + $file->write(get_uploaded_file($fieldname)); + $file->close(); + + if ($container_guid) + $file->container_guid = $container_guid; + + $file->simpletype = get_general_file_type($_FILES[$fieldname]['type']); + + $result = $file->save(); + + if ($result) { + form_generate_thumbnail($file,$fieldname); + } + + return $file->getGUID(); +} + + +function form_vsort($original,$field,$descending = false) { + if (!$original) { + return $original; + } + $sortArr = array(); + + foreach ( $original as $key => $item ) { + $sortArr[ $key ] = $item->$field; + } + + if ( $descending ) { + arsort( $sortArr ); + } else { + asort( $sortArr ); + } + + $resultArr = array(); + foreach ( $sortArr as $key => $value ) { + $resultArr[ $key ] = $original[ $key ]; + } + + return $resultArr; +} + +function form_parse_template($template,$vars,$prefix = '{$',$postfix = '}') { + $tmp = array(); + foreach($vars as $k => $v) + { + $tmp[$prefix . $k . $postfix] = $v; + } + + return str_replace(array_keys($tmp), array_values($tmp), $template); +} + +function form_language_template($template) { + return preg_replace_callback( + '|\{\@([^}]*)\}|', + create_function( + // single quotes are essential here, + // or alternative escape all $ as \$ + '$matches', + 'return elgg_echo($matches[1]);' + ), + $template + ); +} + +function form_get_all_fields($user_id) { + $fields = get_entities('object','form:field',$user_id,"",500); + return form_vsort($fields,'internal_name'); +} + +function form_get_orphan_fields($user_id) { + $maps = get_entities('object','form:field_map',$user_id,"",500); + $field_ids = array(); + if ($maps) { + foreach($maps as $map) { + $field_ids[] = $map->field_id; + } + $field_ids = array_unique($field_ids); + } + $fields = get_entities('object','form:field',$user_id,"",500); + $orphans = array(); + if ($fields) { + foreach ($fields as $field) { + if (!in_array($field->getGUID(),$field_ids)) { + $orphans[] = $field; + } + } + } + return form_vsort($orphans,'internal_name'); +} + +function form_delete_orphan_fields($user_id) { + $fields = form_get_orphan_fields($user_id); + foreach($fields as $field) { + $field->delete(); + } +} + +function form_delete($form_id) { + $form = get_entity($form_id); + // destroy the field map and then the form + $maps = get_entities_from_metadata('form_id',$form_id,'object','form:field_map',$form->owner_guid,500); + if ($maps) { + foreach($maps as $map) { + $map->delete(); + } + } + $form->delete(); +} + +function form_get_field_definition($field_id) { + + // get the field data + + $field = get_entity($field_id); + + // get the choice data, if any + + return $field; +} + +function form_get_field_choices($field_id) { + $field = get_entity($field_id); + return get_entities_from_metadata('field_id',$field_id,'object','form:field_choice',$field->owner_guid,500,0,"e.guid asc"); +} + +function form_set_field_definition() { + $form_action = get_input('form_action',''); + //system_message ('form_action: '.$form_action); + $form_id = get_input('form_id',0); + $form = get_entity($form_id); + if ($form_action == 'change') { + $field_id = get_input('field_id',0); + $field = get_entity($field_id); + } else { + $field = new ElggObject(); + $field->subtype = 'form:field'; + $field->owner_guid = $form->owner_guid; + // field access is always public as real access is controlled at the form level + $field->access_id = ACCESS_PUBLIC; + $field->save(); + } + + $field->title = get_input('title',''); + $field->description = get_input('description',''); + + $field->internal_name = get_input('internal_name',''); + + $field->required = get_input('required',0); + $field->admin_only = get_input('admin_only',0); + $field->profile = get_input('profile',0); + $field->tab = get_input('category',''); + $field->subtype_filter = get_input('subtype_filter',''); + $field->field_type = get_input('field_type',''); + $field->invisible = get_input('invisible',0); + $field->area = get_input('area',''); + $field->default_access = get_input('default_access',''); + $field->choice_type = get_input('choice_type',''); + $field->orientation = get_input('orientation',''); + $field->default_value = get_input('default_value',''); + $field->is_keyword_tag = get_input('is_keyword_tag',0); + + // I use strlower to avoid an Elgg metastrings table issue + + if (strtolower($field->field_type) == 'contact') { + $field->field_type = get_input('contact_type',''); + } + $field->save(); + if ($form_action == 'change') { + // delete the old field choices as they will be recreated with possibly new values below + $field_choices = get_entities_from_metadata('field_id', $field->getGUID(), 'object', 'form:field_choice', $field->owner_guid,500); + if ($field_choices) { + foreach($field_choices as $field_choice) { + $field_choice->delete(); + } + } + } else { + // this is a new field, so add it to the current form + $field_id = $field->getGUID(); + $map = new ElggObject(); + $map->subtype = 'form:field_map'; + $map->owner_guid = $form->owner_guid; + // field map access is always public as real access is controlled at the form level + $map->access_id = ACCESS_PUBLIC; + $map->save(); + $map->field_id = $field_id; + $map->form_id = $form_id; + $map->display_order = 100000; + $map->save(); + form_reorder($field->form_id); + } + + $number_of_options = get_input('number_of_options',0); + + for ($i = 0; $i < $number_of_options; $i++) { + $option = new ElggObject(); + $option->subtype = 'form:field_choice'; + $option->owner_guid = $form->owner_guid; + // field option access is always public as real access is controlled at the form level + $option->access_id = ACCESS_PUBLIC; + $option->field_id = $field->getGUID(); + $option->value = get_input('option_'.$i.'_value',''); + $option->label = get_input('option_'.$i.'_label',''); + if ($option->value) { + $option->save(); + } + } +} + +function form_field_delete($field_id) { + // remove this field from all the forms it is on + + $maps = get_entities_from_metadata('field_id', $field_id, 'object', 'form:field_map',0,500); + if ($maps) { + foreach($maps as $map) { + $map->delete(); + } + } + + // delete the field itself + + $field = get_entity($field_id); + $field->delete(); +} + +function form_field_remove($form_id, $field_id) { + // remove this field from this specific form + + $map = form_get_map($form_id,$field_id); + if ($map) { + $map->delete(); + } +} + +function form_reorder($form_id) { + $maps = form_get_maps($form_id); + $order = array(); + $map_array = array(); + $i = 1; + foreach($maps as $map) { + $map_id = $map->getGUID(); + $order[$map_id] = $i * 10; + $map_array[$map_id] = $map; + $i++; + } + foreach($order as $map_id => $display_order) { + $map = $map_array[$map_id]; + $map->display_order = $display_order; + $map->save(); + } +} + +// TODO: replace maps with the relationship API if possible + +function form_get_maps($form_id) { + $maps = get_entities_from_metadata('form_id',$form_id,'object','form:field_map',0,500); + return form_vsort($maps,'display_order'); +} + +function form_get_map($form_id, $field_id) { + $maps = get_entities_from_metadata_multi(array('form_id'=>$form_id,'field_id'=>$field_id),'object','form:field_map',0,500); + if ($maps) { + return $maps[0]; + } else { + return null; + } +} + +// Move a form/field map up +function form_field_moveup($form_id,$field_id) { + $map = form_get_map($form_id, $field_id); + if ($map) { + $map->display_order = $map->display_order - 11; + $map->save(); + form_reorder($form_id); + } +} + +// Move a form/field map down +function form_field_movedown($form_id,$field_id) { + $map = form_get_map($form_id, $field_id); + if ($map) { + $map->display_order = $map->display_order + 11; + $map->save(); + form_reorder($form_id); + } +} + +// Move a form/field map to the top +function form_field_movetop($form_id,$field_id) { + $map = form_get_map($form_id, $field_id); + if ($map) { + $map->display_order = 0; + $map->save(); + form_reorder($form_id); + } +} + +// Move a form/field map to the bottom +function form_field_movebottom($form_id,$field_id) { + $map = form_get_map($form_id, $field_id); + if ($map) { + $map->display_order = 100000; + $map->save(); + form_reorder($form_id); + } +} + +function form_get_fields($form_id) { + $fields = array(); + $maps = form_get_maps($form_id); + if ($maps) { + foreach($maps as $map) { + $fields[] = get_entity($map->field_id); + } + } + return $fields; +} + +function form_set_form_definition() { + $form_action = get_input('form_action',''); + if ($form_action == 'change') { + $form = get_entity(get_input('form_id',0)); + } else if ($form_action == 'add') { + $form = new ElggObject(); + $form->subtype = 'form:form'; + $username = get_input('username',''); + $user = get_user_by_username($username); + $form->owner_guid = $user->getGUID(); + } + $form->access_id = get_input('access_id',''); + $profile = get_input('profile',0); + $form->profile = $profile; + $form->name = get_input('form_name',''); + $form->title = get_input('form_title',''); + $form->description = get_input('description',''); + $form->listing_description = get_input('form_listing_description',''); + $form->response_text = get_input('response_text',''); + if ($form->profile) { + $form->profile_category = get_input('profile_category',''); + $form->profile_format = get_input('profile_format',''); + } + $form->list_template = get_input('list_template',''); + $form->display_template = get_input('display_template',''); + $form->allow_comments = get_input('allow_comments',0); + $form->email_form = get_input('email_form',0); + $form->email_to = get_input('email_to',''); + $form->enable_create_menu = get_input('enable_create_menu',0); + $form->create_menu_title = get_input('create_menu_title',''); + $form->enable_display_menu = get_input('enable_display_menu',0); + $form->display_menu_title = get_input('display_menu_title',''); + $form->allow_recommendations = get_input('allow_recommendations',0); + + $form->save(); + + return $form; +} + +function form_set_search_definition($search_definition_id) { + $form_action = get_input('form_action',''); + if ($form_action == 'change') { + $sd = get_entity($search_definition_id); + } else if ($form_action == 'add') { + $form_id = get_input('form_id',0); + $sd = new ElggObject(); + $sd->subtype = 'form:search_definition'; + //$sd->owner_guid = get_entity($form_id)->owner_guid; + $sd->access_id = ACCESS_PUBLIC; + } + $sd->title = get_input('search_title',''); + $sd->description = get_input('search_description',''); + $sd->form_id = get_input('form_id',''); + $sd->internalname = get_input('internalname',''); + $sd->search_fields = get_input('search_fields',''); + $sd->search_order = get_input('search_order',''); + //$sd->expiryfield = get_input('expiryfield',''); + $sd->menu = trim(get_input('menu','')); + if ($sd->menu) { + $sd->creates_menu = 1; + } else { + $sd->creates_menu = 0; + } + $sd->show_profiles = get_input('show_profiles',''); + $sd->list_template = get_input('list_template',''); + $sd->gallery_template = get_input('gallery_template',''); + + $sd->save(); + + return $sd; +} + +function form_set_menu_items() { + global $CONFIG; + + // add display links to menu + $entities = get_entities_from_metadata('enable_display_menu',1,'object','form:form'); + if ($entities) { + foreach($entities as $form) { + add_menu(form_form_t($form,'display_menu_title'),$CONFIG->wwwroot.'mod/form/my_forms.php?form_view=all&id='.$form->getGUID()); + } + } + + // add create links to menu + $entities = get_entities_from_metadata('enable_create_menu',1,'object','form:form'); + if ($entities) { + foreach($entities as $form) { + add_menu(form_form_t($form,'create_menu_title'),$CONFIG->wwwroot.'mod/form/form.php?id='.$form->getGUID()); + } + } + + // add search links + $entities = get_entities_from_metadata('creates_menu',1,'object','form:search_definition'); + if ($entities) { + foreach($entities as $sd) { + $form = get_entity($sd->form_id); + add_menu(form_search_definition_t($form,$sd,'menu'),$CONFIG->wwwroot.'mod/form/search.php?sid='.$sd->getGUID()); + } + } +} + +function form_search_definition_delete($search_definition_id) { + $sd = get_entity($search_definition_id); + $sd->delete(); +} + +function form_field_type_to_view($field_type,$mode) { + $form_field_types = form_get_form_field_types(); + // circumvent Elgg metadata bug + $field_type = strtolower($field_type); + + // special handling for choices and contacts + // TODO: remove the need for special handling + + if ($mode == 'output') { + if (in_array($field_type,array('email','url'))) { + $view = 'output/'.$field_type; + } else if (in_array($field_type,array('aim','msn','skype','icq'))) { + $view = 'output/text'; + } else { + $view = $form_field_types[$field_type]->output_view; + } + } else { + if (in_array($field_type,array('radio','checkboxes'))) { + $view = 'form/input/'.$field_type; + } else if ($field_type == 'pulldown') { + $view = 'input/pulldown'; + } else if (in_array($field_type,array('email','url','aim','msn','skype','icq'))) { + $view = 'input/text'; + } else { + $view = $form_field_types[$field_type]->input_view; + } + } + return $view; +} + +function form_get_data_from_form_submit($form_id=0) { + $data = array(); + if (!$form_id) { + $form_id = get_input('form_id',0); + } + if ($form_id) { + $fields = form_get_fields($form_id); + if ($fields) { + foreach($fields as $field) { + $value = get_input('form_data_'.$field->internal_name,''); + if ($value) { + $data[$field->internal_name] = $value; + } + } + } + } + + return $data; +} + +function form_get_data($form_data_id) { + $data = array(); + $md = get_metadata_for_entity($form_data_id); + if ($md) { + foreach ($md as $item) { + if (isset($data[$item->name])) { + // more than one item of the same name, so make this into an array of values + // this can happen for tag fields, for example + if (is_array($data[$item->name]->value)) { + $data[$item->name]->value[] = $item->value; + } else { + $data[$item->name]->value = array($data[$item->name]->value,$item->value); + } + } else { + $data[$item->name] = new StdClass(); + $data[$item->name]->value = $item->value; + } + } + } + + // add the access_id, title and description as these + // could conceivably be changed as well + $fd = get_entity($form_data_id); + $extras = array('access_id'=>$fd->access_id,'title'=>$fd->title,'description'=>$fd->description); + foreach ($extras as $k => $v) { + $data[$k] = new StdClass(); + $data[$k]->value = $v; + } + + return $data; +} + +function form_delete_data($form_data_id) { + + $form_data = get_entity($form_data_id); + + // delete image data, if any + $maps = form_get_maps($form_data->form_id); + if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + if ($field->field_type == 'image_upload') { + $internalname = $field->internal_name; + $file_id = $form_data->$internalname; + if ($file_id) { + form_delete_file($file_id); + } + } + } + } + return $form_data->delete(); +} + +function form_get_input_display_item($form,$field,$data=null,$prepopulate=true,$format_view='form/display_field') { + global $CONFIG; + $internalname = $field->internal_name; + $access_id = ''; + //print($internalname.':'); + if (!isset($field->admin_only) || !$field->admin_only || isadminloggedin()) { + if (!isset($data)) { + $data = array(); + } + if ($prepopulate) { + if (isset($data[$internalname])) { + $value = $data[$internalname]->value; + $access_id = $data[$internalname]->access_id; + } else { + $value = $field->default_value; + // must do this because Elgg has trouble with metadata set to "0" + // in Elgg 1.5 using a simple reference + $m = get_metadata_byname($field->getGUID(),'default_access'); + if ($m && ($m->value || ($m->value === 0) || ($m->value === '0'))) { + $access_id = $m->value; + } else { + $access_id = get_default_access(); + } + } + } else { + $value = ''; + } + // use strtolower to get around the Elgg metadata case problem + $field_type = strtolower($field->field_type); + if ($field_type == 'image_upload') { + if ($value) { + $image_url = $CONFIG->wwwroot.'mod/file/thumbnail.php?size=small&file_guid='.$value; + $view_prefix = '<p><img src="'.$image_url.'"></p>'; + //$view_prefix = $value.print_r($image_entity,true).elgg_view('graphics/icon',array('entity'=>$image_entity,'size'=>'small')); + } else { + $view_prefix = ''; + } + } + $formfieldname = 'form_data_'.$internalname; + $vars = array('internalname'=>$formfieldname,'value'=>$value); + //print($field->internal_name.','.$field->field_type.','.$field->choice_type.','.$field->default_value.'<br />'); + if (strtolower($field->field_type) == 'choices') { + $vars['orientation'] = $field->orientation; + $field_type = $field->choice_type; + $choices = form_get_field_choices($field->getGUID()); + if ($choices) { + if ($choices[0]->label) { + $options_values = array(); + if (!$prepopulate && $field_type == 'pulldown') { + // force an empty default option + $options_values[''] = ''; + } + foreach($choices as $choice) { + $options_values[$choice->value] = form_choice_t($form,$field,$choice); + } + $vars['options_values'] = $options_values; + $vars['options'] = $options_values; + } else { + $options = array(); + if (!$prepopulate && $field_type == 'pulldown') { + // force an empty default option + $options[''] = ''; + } + foreach($choices as $choice) { + $options[$choice->value] = $choice->value; + } + $vars['options'] = $options; + } + } + + } else { + $field_type = $field->field_type; + } + //print $field_type.'#'; + $view = form_field_type_to_view($field_type,"input"); + //print ($field_type.':'.$view.'; '); + + $html = elgg_view($format_view, array('field'=>$view_prefix.elgg_view($view,$vars), + 'title'=>form_field_t($form,$field,'title'),'description'=>form_field_t($form,$field,'description'))); + } else { + if ($prepopulate) { + if (isset($data[$internalname]) && $data[$internalname]->value) { + $value = $data[$internalname]->value; + } else { + $value = $field->default_value; + } + } else { + $value = ''; + } + $html = elgg_view('input/hidden',array('internalname'=>$internalname, 'value'=>$value)); + } + $item = new StdClass(); + $item->default_access = $access_id; + $item->internalname = $field->internal_name; + $item->html = $html; + return $item; +} + +// returns an array of fields keyed and filtered by a name list +// values can be prepopulated if values are present in the $data array +// and hidden if listed in the $hidden array + +function form_display_filtered($form,$namelist,$data=null,$prepopulate=true,$hidden=null) { + $filtered = array(); + $maps = form_get_maps($form->getGUID()); + if ($maps) { + $map_list = array(); + foreach($maps as $map) { + $field = get_entity($map->field_id); + $map_list[$field->internal_name] = $field; + } + + foreach ($namelist as $name) { + if (isset($map_list[$name])) { + if (isset($hidden) && isset($hidden[$name]) && $hidden[$name]) { + // hardcode this as a hidden field + if (isset($data) && isset($data[$name])) { + $value = $data[$name]->value; + } else { + $value = ''; + } + $f = new stdClass; + $f->internalname = $name; + $f->default_access = ACCESS_PUBLIC; + $f->html = elgg_view('input/hidden', array('internalname'=>'form_data_'.$name,'value'=>$value)); + $filtered[$name]= $f; + } else { + $filtered[$name] = form_get_input_display_item($form,$map_list[$name],$data,$prepopulate); + } + } + } + } + return $filtered; +} + +// returns collections of field items keyed by tab + +function form_display_by_tab($form,$data=null,$prepopulate=true,$hidden=null) { + $tabs = array(); + $maps = form_get_maps($form->getGUID()); + if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + if (!$field->admin_only || isadminloggedin() ) { + // don't display admin fields to non-admins + if (isset($hidden) && isset($hidden[$name]) && $hidden[$name]) { + // hardcode this as a hidden field + $name = $field->internal_name; + if (isset($data) && isset($data[$name])) { + $value = $data[$name]->value; + } else { + $value = ''; + } + $f = new stdClass; + $f->internalname = $name; + $f->html = elgg_view('input/hidden', array('internalname'=>'form_data_'.$name,'value'=>$value)); + $item = $f; + } else { + $item = form_get_input_display_item($form,$field,$data,$prepopulate); + } + if (!$field->tab) { + if ($form->translate) { + $tab = form_tab_t($form,elgg_echo('form:basic_tab_label')); + } else { + $tab = elgg_echo('form:basic_tab_label'); + } + } else { + $tab = form_tab_t($form,$field->tab); + } + + if (!isset($tabs[$tab])) { + $tabs[$tab] = array(); + } + $tabs[$tab][] = $item; + } + } + } + return $tabs; +} + +// Return the form fields (indexed by tab), optionally prepopulated with data + +function form_get_data_for_edit_form($form,$data=null) { + + $tab_data = array(); + $tabs = form_display_by_tab($form,$data); + // just flatten the result and return + if ($tabs) { + foreach ($tabs as $tab => $tab_items) { + $tab_data[$tab] = ''; + foreach ($tab_items as $item) { + $tab_data[$tab] .= $item->html; + } + } + } + return $tab_data; +} + +/** + * Returns a view of a list of entities, plus navigation. It is intended that this function + * be called from other wrapper functions. + * + * @see list_entities + * @see list_user_objects + * @see list_user_friends_objects + * @see list_entities_from_metadata + * @see list_entities_from_metadata_multi + * @see list_entities_from_relationships + * @see list_site_members + * + * @param array $entities List of entities + * @param int $count The total number of entities across all pages + * @param int $offset The current indexing offset + * @param int $limit The number of entities to display per page + * @param true|false $fullview Whether or not to display the full view (default: true) + * @param true|false $viewtypetoggle Whether or not to allow users to toggle to gallery view + * @return string The list of entities + */ +function form_view_entity_list($entities, $form, $count, $offset, $limit, $fullview = true, $viewtypetoggle = true) { + + $count = (int) $count; + $offset = (int) $offset; + $limit = (int) $limit; + + $context = get_context(); + + $html = elgg_view('form/entity_list',array( + 'entities' => $entities, + 'form' => $form, + 'count' => $count, + 'offset' => $offset, + 'limit' => $limit, + 'baseurl' => $_SERVER['REQUEST_URI'], + 'fullview' => $fullview, + 'context' => $context, + 'viewtypetoggle' => $viewtypetoggle, + 'viewtype' => get_input('search_viewtype','list'), + )); + + return $html; + +} + +function form_get_field_output($form,$field,$value) { + $form_id = $form->getGUID(); + if ($form->profile) { + $profile = $form->profile; + } else { + $profile = 0; + } + $type_array = array('form_data','user','group'); + if (strtolower($field->field_type) == "choices") { + $choices = form_get_field_choices($field->getGUID()); + if (is_array($value)) { + $value_array = array(); + foreach($value as $value2) { + $this_choice = ''; + foreach($choices as $choice) { + if ($choice->value == $value2) { + $this_choice = $choice; + break; + } + } + if ($this_choice) { + $value_array[$value2] = form_choice_t($form,$field,$this_choice); + } else { + $value_array[$value2] = $value2; + } + } + return elgg_view("form/output/choice",array('form_id'=>$form_id,'type'=>$type_array[$profile],'internalname'=>$field->internal_name,'value'=>$value_array)); + } else { + $this_choice = ''; + foreach($choices as $choice) { + if ($choice->value == $value) { + $this_choice = $choice; + break; + } + } + if ($this_choice) { + return elgg_view("form/output/choice",array('form_id'=>$form_id,'type'=>$type_array[$profile],'internalname'=>$field->internal_name,'value'=>$value,'label'=>form_choice_t($form,$field,$this_choice))); + } else { + return elgg_view("form/output/choice",array('form_id'=>$form_id,'type'=>$type_array[$profile],'internalname'=>$field->internal_name,'value'=>$value)); + } + } + } else { + $view = form_field_type_to_view($field->field_type,"output"); + return elgg_view($view,array('form_id'=>$form_id,'type'=>$type_array[$profile],'internalname'=>$field->internal_name,'value'=>$value)); + } +} + +// assumes that form data is stored as metadata on a form_data object + +function form_view_entities($entities, $form, $viewtype) { + + global $CONFIG; + + $html = ''; + $qs = $_SERVER["QUERY_STRING"]; + + if (is_array($entities) && sizeof($entities) > 0) { + + if (in_array($viewtype,array('list','display'))) { + $commentable = $form->allow_comments; + $recommendable = $form->allow_recommendations; + } else { + $commentable = $false; + $recommendable = $false; + } + + foreach($entities as $entity) { + $form_data_id = $entity->getGUID(); + $entity_url = $entity->getURL(); + $md_get = get_metadata_for_entity($form_data_id); + $md = array(); + foreach ($md_get as $m) { + if (isset($md[$m->name])) { + if (!is_array($md[$m->name]->value)) { + $md[$m->name]->value = array($md[$m->name]->value); + } + $md[$m->name]->value[] = $m->value; + } else { + $md[$m->name] = new StdClass(); + $md[$m->name]->value = $m->value; + $md[$m->name]->name = $m->name; + } + } + + // add title and description + $extras = array('title'=>$entity->title,'description'=>$entity->description); + foreach ($extras as $k => $v) { + $md[$k] = new StdClass(); + $md[$k]->value = $v; + $md[$k]->name = $k; + } + $vars = array(); + $form_id = $form->getGUID(); + $fields = form_get_fields($form_id); + if ($fields) { + foreach ($fields as $field) { + $internalname = $field->internal_name; + if (isset($md[$internalname])) { + $item = $md[$internalname]; + $vars[$item->name] = form_get_field_output($form,$field,$item->value); + if ($field->field_type == 'image_upload') { + $vars[$item->name.':thumb'] = elgg_view($view,array('value'=>$item->value,'size'=>'small')); + } else if ($field->field_type == 'video_box') { + $vars[$item->name.':thumb'] = elgg_view($view,array('value'=>$item->value,'size'=>'thumb')); + } + } else { + // just return empty strings + $vars[$internalname] =''; + if ($field->field_type == 'image_upload') { + $vars[$internalname.':thumb'] = ''; + } else if ($field->field_type == 'video_box') { + $vars[$internalname.':thumb'] = ''; + } + } + } + } + + $comment_bit = ''; + $recommend_bit = ''; + + if ($commentable) { + if ($viewtype == 'display') { + $comment_bit = elgg_view_comments($entity); + } else { + $num_comments = elgg_count_comments($entity); + if ($num_comments == 1) { + $comment_bit = $num_comments.elgg_echo('form:comment'); + } else { + $comment_bit = $num_comments.elgg_echo('form:comments'); + } + } + } + + if ($recommendable) { + $number_of_recommendations = count_annotations($form_data_id, 'object', 'form_data', 'form:recommendation'); + // count_annotations had a bug, but should be fixed now, so comment out this workaround + + //$number_of_recommendations = form_count(get_annotations($form_data_id, 'object', 'form_data', 'form:recommendation', 1, 0, 500)); + if (isloggedin() && ($viewtype == 'display')) { + $number_of_my_recommendations = form_count(get_annotations($form_data_id, 'object', 'form_data', 'form:recommendation', 1,$_SESSION['user']->getGUID())); + $user_guid = $_SESSION['user']->getGUID(); + if ($number_of_my_recommendations == 0){ + $recommendation_template = '<a href="%s">'.elgg_echo("form:recommend_this"). '</a>'; + $my_recommend_bit = ' ['.sprintf($recommendation_template,$CONFIG->wwwroot.'action/form/manage_form_data?form_action=recommend&d='.$form_data_id).']'; + } else { + $my_recommend_bit = ''; + } + } else { + $my_recommend_bit = ''; + } + if ($number_of_recommendations == 1) { + $recommend_bit = sprintf(elgg_echo('form:recommendation'),$number_of_recommendations).$my_recommend_bit; + } else { + $recommend_bit = sprintf(elgg_echo('form:recommendations'),$number_of_recommendations).$my_recommend_bit; + } + } + + if ($viewtype == 'list') { + if ($recommend_bit && $comment_bit) { + $annotation_bit = $recommend_bit.', '.$comment_bit; + } else { + $annotation_bit = $recommend_bit.$comment_bit; + } + } else { + $annotation_bit = $recommend_bit.'<br /><br />'.$comment_bit; + } + + if (trim($form->list_template) || trim($form->display_template)) { + + $vars['_url'] = $CONFIG->wwwroot; + + $vars['_user_message_link'] = '<a href="'.$CONFIG->wwwroot.'mod/messages/send.php?send_to='.$entity->owner_guid + .'">'.elgg_echo('form:send_a_message').'</a>'; + + $vars['_full_view_link'] = '<a href="'.$entity_url.'">'.elgg_echo('form:full_view').'</a>'; + $vars['_full_view_url'] = $entity_url; + $vars['_friendlytime'] = friendly_time($entity->time_created); + $owner_entity = $entity->getOwnerEntity(); + $owner_url = $owner_entity->getUrl(); + $vars['_owner_url'] = $owner_url; + $vars['_owner_name'] = $owner_entity->name; + $vars['_owner_username'] = $owner_entity->username; + $vars['_owner_message_link'] = $vars['_user_message_link']; + $vars['_owner_icon'] = elgg_view( + "profile/icon", array( + 'entity' => $owner_entity, + 'size' => 'small', + ) + ); + $vars['_annotations'] = $annotation_bit; + } + + if ($viewtype == 'display') { + $template = $form->display_template; + if (trim($template)) { + $content = form_parse_template($template,$vars); + $content = form_language_template($content); + } else { + $content = elgg_view('form/default_form_data_display',array('entity'=>$entity,'annotations'=>$annotation_bit)); + } + } else if ($viewtype == 'list') { + $template = $form->list_template; + if (trim($template)) { + $content = form_parse_template($template,$vars); + $content = form_language_template($content); + } else { + $content = elgg_view('form/default_form_data_listing',array('entity'=>$entity,'annotations'=>$annotation_bit)); + } + } else { + $content = sprintf(elgg_echo('form:submitted'),friendly_time($entity->time_created)); + if ($entity->time_updated != $entity->time_created) { + $content .= ", ".sprintf(elgg_echo('form:updated'),friendly_time($entity->time_updated)); + } + } + + $html .= $content; + } + } + return $html; +} + +function form_recommend($form_data_id) { + if (isloggedin()) { + $user_guid = $_SESSION['user']->getGUID(); + $number_of_my_recommendations = form_count(get_annotations($form_data_id, 'object', 'form_data', 'form:recommendation', 1,$user_guid)); + if ($number_of_my_recommendations == 0) { + create_annotation($form_data_id, 'form:recommendation', 1, 'integer', $user_guid, ACCESS_PUBLIC); + return true; + } else { + return false; + } + } + return false; +} + +// TODO - determine if this next function is needed anymore +function form_count($s) { + if (!isset($s) || !is_array($s)) { + return 0; + } else { + return count($s); + } +} + +// sets the form data if valid and returns with an error status +// this is only for form_data objects +// user and group profiles use form_set_data in models/profile.php + +function form_set_data_from_form($form_data_id = 0) { + global $CONFIG; + + $form_id = get_input('form_id'); + $form = get_entity($form_id); + $maps = form_get_maps($form_id); + if ($maps) { + // fields are no longer stored in an array + //$form_data = get_input('form_data',array()); + if ($form_data_id) { + $fd = get_entity($form_data_id); + } else { + $fd = new ElggObject(); + $fd->subtype = 'form_data'; + if (isloggedin()) { + $fd->owner_guid = $_SESSION['user']->getGUID(); + } else { + // no owner + $fd->owner_guid = 0; + } + // Same as form unless this is changed by the form submit + $fd->access_id = $form->access_id; + $fd->form_id = $form_id; + } + $form_data = array(); + $images = array(); + $invite_box_name = ''; + $result = new StdClass(); + $result->error_status = false; + $result->missing = array(); + $result_form_data = array(); + foreach($maps as $map) { + $field = get_entity($map->field_id); + $internalname = $field->internal_name; + $item = new StdClass(); + $item->value = ''; + $form_data[$internalname] = get_input('form_data_'.$internalname,''); + if ($field->field_type == 'tags'){ + // KJ - I reverse the array to fix an annoying Elgg tag order bug + // I will remove this workaround when the bug is fixed + $form_data[$internalname] = array_reverse(string_to_tag_array($form_data[$internalname])); + } + if ($field->field_type == 'image_upload') { + // special handling for images + $images[] = $internalname; + } else if ($field->field_type == 'invite_box') { + // special handling for invite box + $invite_box_name = 'form_data_'.$internalname; + } else if ($field->field_type == 'access') { + // set both values in case the internal name is not "access_id" + $fd->$internalname = $form_data[$internalname]; + $fd->access_id = $form_data[$internalname]; + $item->value = $form_data[$internalname]; + } else if(isset($form_data[$internalname])) { + $fd->$internalname = $form_data[$internalname]; + $item->value = $form_data[$internalname]; + } else { + $fd->$internalname = ''; + } + + if ($field->required && (!isset($form_data[$internalname]) || (trim($form_data[$internalname]) === ''))) { + $result->error_status = true; + $result->error_reason = 'missing'; + $result->missing[] = $field; + } + $result_form_data[$internalname] = $item; + } + $result->form_data = $result_form_data; + if ($result->error_status) { + return $result; + } else { + // looks good + + if ($form->email_form) { + form_send_results($form,$result,$fd->owner_guid); + return $result; + } else { + + // set language and save + if (empty($CONFIG->language)) { + $fd->_language = 'en'; + } else { + $fd->_language = $CONFIG->language; + } + if ($fd->save()) { + // success, so save images + foreach($images as $image) { + $formfieldname = 'form_data_'.$image; + // don't do anything if this field is blank + if (isset($_FILES[$formfieldname]['name']) && trim($_FILES[$formfieldname]['name'])) { + if ($fd->$image) { + // delete the old file + form_delete_file($fd->$image); + } + $fd->$image = form_handle_file_upload($formfieldname,$fd->access_id); + } + } + // added to keep the river happy + if (!trim($fd->title)) { + $fd->title = sprintf(elgg_echo('form:river:title'),$form->title); + } + if (!$form_data_id) + add_to_river('river/object/form_data/create','create',get_loggedin_userid(),$fd->getGUID()); + // TODO: avoid this second save + $fd->save(); + // handle invitations if required + if ($invite_box_name) { + form_send_invitations($invite_box_name,$fd->getGUID()); + } + return $result; + } else { + $result->error_status = true; + $result->error_reason = 'save_failed'; + return result; + } + } + } + } +} + +function form_send_results($form,$result,$submitter) { + global $CONFIG; + + if ($form->email_to) { + if ($submitter) { + $user = get_entity($submitter); + $current_time = date('r'); + $message = sprintf(elgg_echo('form:results_send_header'),$user->name,$user->username,$form->title,$form->name,$current_time); + } else { + $message = sprintf(elgg_echo('form:results_send_anonymous_header'),$form->title,$form->name,$current_time); + } + foreach ($result->form_data as $key => $item) { + $message .= "\n\n*".$key."*\n\n"; + $message .= $item->value; + } + + $site = get_entity($CONFIG->site_guid); + if ($site->email) { + // this should be defined as of Elgg 1.1 + $from = $site->email; + } else { + $from = 'noreply@' . get_site_domain($CONFIG->site_guid); + } + $subject = sprintf(elgg_echo('form:results_send_subject'),$form->title); + form_send_email(array($form->email_to), $from, $subject, $message); + } +} + +function form_send_invitations($invite_box_name,$form_data_id) { + global $CONFIG; + + $contacts = trim(get_input($invite_box_name.'_contacts','')); + if ($contacts) { + $user_message = trim(get_input($invite_box_name.'_message','')); + $url = $CONFIG->wwwroot.'mod/form/display_object.php?d='.$form_data_id; + $message = sprintf(elgg_echo('form:invite_message'),$_SESSION['user']->name,$url); + if ($user_message) { + $message .= sprintf(elgg_echo('form:user_message'),$user_message); + } + $user_list = array(); + $email_address_list = array(); + // handle comma separators + $contacts2 = explode(",",$contacts); + // handle new line separators as well + $contact_list = array(); + foreach($contacts2 as $contact) { + $contact_list = array_merge($contact_list,explode("\n",$contact)); + } + + foreach ($contact_list as $contact) { + $contact = trim($contact); + if (strpos($contact,'@') === false) { + $user = get_user_by_username($contact); + if ($user && $user_id = $user->getGUID()) { + $user_list[] = $user_id; + } + } else { + $email_address_list[] = $contact; + } + } + + $subject = sprintf(elgg_echo('form:invite_subject'),$_SESSION['user']->name); + + if ($user_list) { + $from = $_SESSION['user']->getGUID(); + //print_r($user_list); + //print $subject; + //print $message; + // need to force email for now as Elgg 1 notification does not seem to work without it + notify_user($user_list, $from, $subject, $message, null, array('email')); + } + + if ($email_address_list) { + $site = get_entity($CONFIG->site_guid); + if ($site->email) { + // this should be defined as of Elgg 1.1 + $from = $site->email; + } else { + $from = 'noreply@' . get_site_domain($CONFIG->site_guid); + } + form_send_email($email_address_list, $from, $subject, $message); + } + } +} + +function form_send_email($to_list, $from, $subject, $message) { + $headers = "From: $from"; + foreach($to_list as $to) { + mail($to,$subject,$message,$headers); + } +} + +function form_get_field_id_from_name($existing_field_name,$user_guid) { + $fields = get_entities_from_metadata('internal_name', $existing_field_name, 'object', 'form:form_field', $user_guid,500); + if ($fields) { + $field_id = $fields[0]->getGUID(); + } else { + $field_id = 0; + } + return $field_id; +} + +function form_get_field_from_name($existing_field_name,$user_guid) { + $fields = get_entities_from_metadata('internal_name', $existing_field_name, 'object', 'form:form_field', $user_guid,500); + if ($fields) { + return $fields[0]; + } else { + return null; + } +} + +function form_add_existing_field($form_id,$field_id) { + $form = get_entity($form_id); + + // do nothing if this field is already on the form + $map = form_get_map($form_id,$field_id); + if (!$map) { + // Initialise a new ElggObject + $map = new ElggObject(); + // Tell the system it's a form_fields_map + $map->subtype = "form:field_map"; + // Set its owner to the form user + $map->owner_guid = $form->owner_guid; + // anyone needs to be able to access this to make sure that the Elgg permissions system does not + // cause problems + $map->access_id = ACCESS_PUBLIC; + $map->form_id = $form_id; + $map->field_id = $field_id; + $map->display_order = 100000; + if ($map->save()) { + form_reorder($form_id); + return true; + } else { + return false; + } + } + + return false; +} + +// The next function is inefficient because it may get all the data and then +// throw a lot of it away. +// Will rewrite when the Elgg API gets better or may need a custom SQL select. + +function form_get_data_with_search_conditions($conditions,$sd,$limit,$offset) { + global $CONFIG; + + $search_order_field = trim($sd->search_order); + $form = get_entity($sd->form_id); + // will return at most 500 search results + if ($form->profile == 1) { + // this is a profile form, so get the data from users + $entities = get_entities_from_metadata_multi($conditions, 'user', '',0,500); + } else if ($form->profile == 2) { + // this is a profile form, so get the data from groups + // if a profile category is set for this form, restrict the search + // to groups of that category + if ($form->profile_category) { + $conditions['group_profile_category'] = $form->profile_category; + } + $entities = get_entities_from_metadata_multi($conditions, 'group', '',0,500); + } else if ($conditions) { + $conditions['form_id'] = $sd->form_id; + $entities = get_entities_from_metadata_multi($conditions, 'object', 'form_data',0,500); + } else { + // if no conditions, return everything from the relevant form + $entities = get_entities_from_metadata('form_id', $sd->form_id, 'object', 'form_data',0,500); + } + if ($entities) { + if (!$form->profile) { + // filter by language if appropriate + $new_results2 = array(); + $view_languages = array(); + if (isloggedin()) { + $key = 'form:view_content_languages'; + if (!empty($_SESSION['user']->$key)) { + $view_languages = explode(',',$_SESSION['user']->$key); + } + } + // we can always see content in the current language + $view_languages[] = $CONFIG->language; + + foreach($entities as $entity) { + if (empty($entity->$_language) || in_array($entity->$_language,$view_languages)) { + $new_results2[] = $entity; + } + } + } else { + $new_results2 = $entities; + } + + // sort by search order if required + if($search_order_field) { + $new_results3 = form_vsort($new_results2,$search_order_field); + } else { + $new_results3 = $new_results2; + } + // now slice the results using limit and offset + $count = count($new_results3); + return array($count,array_slice($new_results3,$offset,$limit)); + } else { + return array(0,$entities); + } +// } else { +// // no special handling required +// return get_entities_from_metadata_multi($conditions, 'object', 'form_data', 0, $limit, $offset, "", 0, false); +// } +} + +// this is a simpler version of the function above that does not require a search definition +// TODO: filter for more than the current language + +function form_get_data_with_search_conditions_simple($conditions,$type,$form_id,$limit,$offset) { + global $CONFIG; + + if ($type == 'user') { + // this is a user profile form, so get the data from users + $entities = get_entities_from_metadata_multi($conditions, 'user','',0,$limit,$offset); + $count = get_entities_from_metadata_multi($conditions, 'user','',0,$limit,$offset,"",0,true); + } else if ($type == 'group') { + // this is a user profile form, so get the data from groups + $entities = get_entities_from_metadata_multi($conditions, 'group','',0,$limit,$offset); + $count = get_entities_from_metadata_multi($conditions, 'group','',0,$limit,$offset,"",0,true); + } else { + if (!$conditions) { + $conditions = array(); + } + $conditions['form_id'] = $form_id; + $conditions['_language'] = $CONFIG->language; + $entities = get_entities_from_metadata_multi($conditions, 'object','form_data',0,$limit,$offset); + $count = get_entities_from_metadata_multi($conditions, 'object','form_data',0,$limit,$offset,"",0,true); + } + return array($count,$entities); +} + +// returns a piece of form text + +function form_form_t($form,$t) { + if ($form->translate) { + return elgg_echo('form:formtrans:'.$form->name.':'.$t); + } else { + return $form->$t; + } +} + +// returns a piece of field text + +function form_field_t($form,$field,$t) { + if ($form->translate) { + return elgg_echo('form:fieldtrans:'.$field->internal_name.':'.$t); + } else { + return $field->$t; + } +} + +// returns the choice label + +function form_choice_t($form,$field,$choice) { + if ($form->translate) { + return elgg_echo('form:fieldchoicetrans:'.$field->internal_name.':'.$choice->value); + } else { + return $choice->label; + } +} + +// returns a piece of search definition text + +function form_search_definition_t($form,$sd,$t) { + if ($form->translate) { + return elgg_echo('form:sdtrans:'.$form->name.':'.$sd->internalname.':'.$t); + } else { + return $sd->$t; + } +} + +// returns the tab text + +function form_tab_t($form,$t) { + if ($form->translate) { + return elgg_echo('form:tabtrans:'.$t); + } else { + return $t; + } +} + +function form_set_translation_status($form_id,$translate) { + $form = get_entity($form_id); + $form->translate = $translate; + $form->save(); +} + + +function form_get_user_content_status() { + $form_user_content_area = get_plugin_setting('user_content_area', 'form'); + if ($form_user_content_area) { + return ($form_user_content_area == 'yes')?true:false; + } else { + // use old method + $form_config = get_entities('object','form:config'); + if ($form_config) { + return $form_config[0]->user_content_status; + } + return false; + } +} + +function form_set_user_content_status($status) { + $form_config = get_entities('object','form:config'); + if (!$form_config) { + $form_config = new ElggObject(); + $form_config->subtype = 'form:config'; + $form_config->owner_guid = $_SESSION['user']->getGUID(); + $form_config->access_id = ACCESS_PUBLIC; + } else { + $form_config = $form_config[0]; + } + + $form_config->user_content_status = $status; + $form_config->save(); +} + +function form_type_options() { + + return array ( + 0 => elgg_echo('form:content_type'), + 1 => elgg_echo('form:user_profile_type'), + 2 => elgg_echo('form:group_profile_type'), + 3 => elgg_echo('form:file_type'), + ); +} + +function form_get_tabbed_output_display($form,$data) { + $form_id = $form->getGUID(); + $tab_data = array(); + $maps = form_get_maps($form_id); + if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + if ($field->field_type != 'access') { + $internalname = $field->internal_name; + if (isset($data[$internalname]) && $data[$internalname]->value) { + if (!$field->tab) { + if ($form->translate) { + $tab = form_tab_t($form,elgg_echo('form:basic_tab_label')); + } else { + $tab = elgg_echo('form:basic_tab_label'); + } + } else { + $tab = form_tab_t($form,$field->tab); + } + if (!isset($tab_data[$tab])) { + $tab_data[$tab] = ''; + } + $title = form_field_t($form,$field,'title'); + $value = form_get_field_output($form,$field,$data[$internalname]->value); + $tab_data[$tab] .= elgg_view('form/extended_display_field',array('title'=>$title,'value'=>$value)); + } + } + } + } + return $tab_data; +} + +?> \ No newline at end of file diff --git a/plugins/form/models/profile.php b/plugins/form/models/profile.php new file mode 100755 index 0000000000000000000000000000000000000000..3d1aa220177a2532a76127eff9d7e07f96c9c2a7 --- /dev/null +++ b/plugins/form/models/profile.php @@ -0,0 +1,303 @@ +<?php + +/** + * Elgg form profile model + * Functions to manage user and group profile data + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +require_once(dirname(__FILE__).'/model.php'); +// Profile data is stored as metadata on the user or group entity + +function form_get_latest_public_profile_form($profile_type=1,$profile_category='') { + $conditions = array('profile'=>$profile_type, 'profile_category'=>$profile_category); + $form_array = get_entities_from_metadata_multi($conditions,'object','form:form'); + if (!$form_array) { + if ($profile_category) { + // try again, this time with an empty (default) profile category + $profile_category = ''; + $conditions = array('profile'=>$profile_type, 'profile_category'=>''); + $form_array = get_entities_from_metadata_multi($conditions,'object','form:form'); + } + } + + if ($form_array) { + // return the first public form + // need to check for profile_category because sadly + // get_entities_from_metadata_multi does not work properly for empty strings + foreach($form_array as $form) { + if (((!$profile_category && !$form->profile_category) || ($form->profile_category == $profile_category))) { + return $form; + } + } + } + + return null; +} + +function form_get_group_profile_categories() { + $form_config = get_entities('object','form:config'); + if ($form_config) { + return $form_config[0]->group_profile_categories; + } + + return ''; +} + +function form_set_group_profile_categories($group_profile_categories) { + $form_config = get_entities('object','form:config'); + if (!$form_config) { + $form_config = new ElggObject(); + $form_config->subtype = 'form:config'; + $form_config->owner_guid = $_SESSION['user']->getGUID(); + $form_config->access_id = ACCESS_PUBLIC; + } else { + $form_config = $form_config[0]; + } + + $form_config->group_profile_categories = $group_profile_categories; + $form_config->save(); +} + +function form_get_data_from_profile($form_id,$entity) { + $metadata = get_metadata_for_entity($entity->getGUID()); + + // beginning of workaround + // sadly Elgg 1.1 fails to enforce access controls for get_metadata_for_entity + // see http://trac.elgg.org/elgg/ticket/531 + // so I need to do this dance to workaround this + $good_metadata = array(); + if ($metadata) { + foreach($metadata as $m) { + // get_metadata does enforce the access controls, so use that + $good_m = get_metadata($m->id); + if ($good_m) { + $good_metadata[] = $good_m; + } + } + } + $metadata = $good_metadata; + // end of workaround + + $data = array(); + $fields = form_get_fields($form_id); + if ($fields) { + foreach($fields as $field) { + $internalname = $field->internal_name; + // not too efficient but the metadata doesn't seem to be keyed + foreach($metadata as $m) { + // set an array if there are multiple metadata items with the same name + // otherwise a single value + // currently only the tags and checkbox groups fields return multiple values + if ($m->name == $internalname) { + if (!isset($data[$internalname])) { + $data[$internalname] = new StdClass(); + $data[$internalname]->value = $m->value; + } else if (is_array($data[$internalname]->value)) { + $data[$internalname]->value[] = $m->value; + } else { + $data[$internalname]->value = array($data[$internalname]->value,$m->value); + } + $data[$internalname]->access_id = $m->access_id; + } + } + } + } + return $data; +} + +// use the specified profile form to return the data (indexed by summary area) from the specified user or group entity + +function form_get_data_for_profile_summary_display($form, $entity) { + $form_id = $form->getGUID(); + $data = form_get_data_from_profile($form_id,$entity); + $area_data = array(); + $maps = form_get_maps($form_id); + if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + $internalname = $field->internal_name; + if (isset($data[$internalname]) && $data[$internalname]->value) { + $area = $field->area; + if ($area) { + if (!isset($area_data[$area])) { + $area_data[$area] = array(); + } + $item = new StdClass(); + $item->internalname = $internalname; + $item->title = form_field_t($form,$field,'title'); + $item->description = form_field_t($form,$field,'description'); + $item->value = form_get_field_output($form,$field,$data[$internalname]->value); + $area_data[$area][] = $item; + } + } + } + } + return $area_data; +} + +// use the specified profile form to return the data (indexed by tab) from the specified user or group entity + +function form_get_data_for_profile_tabbed_display($form, $entity) { + $form_id = $form->getGUID(); + $data = form_get_data_from_profile($form_id,$entity); + return form_get_tabbed_output_display($form,$data); +} + + +// Return the form fields (indexed by tab), optionally prepopulated with data from the specified user or group entity. + +function form_get_data_for_profile_edit_form($form, $entity=null, $group_profile_category='') { + + if ($entity) { + $data = form_get_data_from_profile($form->getGUID(),$entity); + } else { + if ($group_profile_category) { + $item = new stdClass; + $item->name = 'group_profile_category'; + $item->value = $group_profile_category; + $data = array('group_profile_category'=>$item); + } + } + + $tab_data = array(); + $tabs = form_display_by_tab($form,$data,true); + if ($tabs) { + foreach ($tabs as $tab => $tab_items) { + $tab_data[$tab] = ''; + foreach ($tab_items as $item) { + if ($entity instanceof ElggUser) { + // add access control pulldowns + $internalname = $item->internalname; + if (isset($data[$internalname])) { + $access_id = $data[$internalname]->access_id; + } else { + if ($item->default_access || $item->default_access === 0) { + $access_id = $item->default_access; + } else { + $access_id = get_default_access(); + } + } + $access_bit = '<p class="form-field-access">'; + $access_bit .= elgg_view('input/access', array('internalname' => 'flexprofile_access['.$internalname.']','value'=>$access_id)); + $access_bit .= '</p>'; + } else { + $access_bit = ''; + } + $tab_data[$tab] .= $item->html.$access_bit; + } + } + } + return $tab_data; +} + +function form_get_profile_data_from_form_post() { + $form_id = get_input('form_id',0); + $flexprofile_data = array(); + + $data = array(); + $images = array(); + $maps = form_get_maps($form_id); + // does not handle image uploads or required data right now, but should + // best to use the function in the form plugin instead? Not sure ... + if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + $flexprofile_data[$field->internal_name] = get_input('form_data_'.$field->internal_name,''); + if ($field->field_type == 'tags'){ + // KJ - I reverse the array to fix an annoying Elgg tag order bug + // I will remove this workaround when the bug is fixed + $flexprofile_data[$field->internal_name] = array_reverse(string_to_tag_array($flexprofile_data[$field->internal_name])); + } else if ($field->field_type == 'image_upload') { + // special handling for images + $images[] = $field->internal_name; + } + } + } + + $profile = get_entity($form_id)->profile; + + if ($profile == 1) { + $flexprofile_access = get_input('flexprofile_access',''); + } + + foreach($flexprofile_data as $name => $value) { + if (!in_array($name,$images)) { + $data[$name] = new StdClass(); + $data[$name]->value = $value; + if ($profile == 1) { + $data[$name]->access_id = $flexprofile_access[$name]; + } else { + $data[$name]->access_id = ACCESS_PUBLIC; + } + } + } + + // not sure if this should go here + foreach($images as $image) { + $formfieldname = 'form_data_'.$image; + // don't do anything if this field is blank + if (isset($_FILES[$formfieldname]['name']) && trim($_FILES[$formfieldname]['name'])) { + // should probably delete the old image data somehow, if it exists + $data[$image] = new StdClass(); + if ($profile == 1) { + $data[$image]->access_id = $flexprofile_access[$image]; + } else { + $data[$image]->access_id = ACCESS_PUBLIC; + } + $data[$image]->value = form_handle_file_upload($formfieldname,$flexprofile_access[$image]); + } + } + return $data; +} + +function form_set_data($entity,$data) { + global $CONFIG; + + $entity_guid = $entity->getGUID(); + + foreach($data as $name => $item) { + // look for magic names first + + remove_metadata($entity_guid, $name); + $value = $item->value; + if (is_array($value)) { + // currently tags and checkbox groups are the only field types returning multiple values + $i = 0; + foreach($value as $interval) { + $i++; + if ($i == 1) { $multiple = false; } else { $multiple = true; } + create_metadata($entity_guid, $name, $interval, 'text', $entity_guid, $item->access_id, $multiple); + } + } else { + create_metadata($entity_guid, $name, $value, '', $entity_guid, $item->access_id); + } + } +} + +function form_get_profile_config($category,$type='group') { + if ($category) { + $profile_config = get_entities_from_metadata('category',$category,'object','form:profile_config'); + if ($profile_config) { + return $profile_config[0]; + } else { + $profile_config = new ElggObject(); + $profile_config->subtype = 'form:profile_config'; + $profile_config->owner_guid = 0; + $profile_config->access_id = ACCESS_PUBLIC; + $profile_config->category = $category; + if ($profile_config->save()) { + return $profile_config; + } + } + } + return null; +} + +?> \ No newline at end of file diff --git a/plugins/form/my_forms.php b/plugins/form/my_forms.php new file mode 100755 index 0000000000000000000000000000000000000000..0550ae7433895e931631d523a573338960a16d32 --- /dev/null +++ b/plugins/form/my_forms.php @@ -0,0 +1,48 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Displays a list of user-generated content + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:content'); + +global $CONFIG; + +$form_id = get_input('id',0); +$form = get_entity($form_id); +$username = get_input('username'); +$form_view = get_input('form_view'); +$callback = get_input('callback'); + +$_SESSION['last_search_qs'] = null; +$_SESSION['last_view_qs'] = $_SERVER["QUERY_STRING"]; + +$nav = elgg_view('form/nav',array('form_id'=>$form_id,'form_view'=>$form_view,'enable_recommendations'=>$form->allow_recommendations)); + +$body = elgg_view('form/my_forms',array('form'=>$form, 'username'=>$username, 'form_view'=>$form_view)); + +if ($callback) { + echo $nav.'<br />'.$body; +} else { + $title = $form->title; + $body = '<div class="contentWrapper"><div id="form_wrapper">'.$nav.'<br />'.$body.'</div></div>'; + if (trim($form->listing_description)) { + $listing_description = '<div class="contentWrapper">'; + $listing_description .= $form->listing_description; + $listing_description .= '</div>'; + $body = $listing_description.$body; + } + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); +} + +?> \ No newline at end of file diff --git a/plugins/form/search.php b/plugins/form/search.php new file mode 100755 index 0000000000000000000000000000000000000000..4e74345162d5aa753fb852253d150b0e4ee9dec4 --- /dev/null +++ b/plugins/form/search.php @@ -0,0 +1,39 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +global $CONFIG; + +$search_definition_id = get_input('sid',0); +$sd = get_entity($search_definition_id); + +// Define context +set_context('form:content'); + +if($sd) { + $form = get_entity($sd->form_id); + if ($form && $form->profile == 2) { + // this is searching group profiles + set_context('groups'); + } +} +$hidden = get_input('form_data',''); + +$body = elgg_view('form/forms/search',array('search_definition'=>$sd,'hidden'=>$hidden)); + +$title = $sd->title; + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/search_results.php b/plugins/form/search_results.php new file mode 100755 index 0000000000000000000000000000000000000000..0de942491ed731a8fc49c9af7c30bcb65e884c6f --- /dev/null +++ b/plugins/form/search_results.php @@ -0,0 +1,48 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Define context +set_context('form:content'); + +global $CONFIG; + +$search_definition_id = get_input('sid',0); +$sd = get_entity($search_definition_id); + +if($sd) { + $form = get_entity($sd->form_id); + if ($form && ($form->profile == 2)) { + // this is searching group profiles + set_context('groups'); + } else if ($form && ($form->profile == 3)) { + // this is searching files + set_context('file'); + } +} + +$_SESSION['last_search_qs'] = $_SERVER["QUERY_STRING"]; + +$body = elgg_view('form/search_results',array('search_definition'=>$sd)); +if ($category = get_input('_hide_category','')) { + $body .= elgg_view('form/forms/search',array('search_definition'=>$sd,'hidden'=>array('group_profile_category'=>$category))); +} else { + $body .= elgg_view('form/forms/search',array('search_definition'=>$sd)); +} + +$title = elgg_echo('form:search_results_title'); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/search_results_simple.php b/plugins/form/search_results_simple.php new file mode 100755 index 0000000000000000000000000000000000000000..5cf61bf200e2186b8f6c8c77900b99c7be39d25b --- /dev/null +++ b/plugins/form/search_results_simple.php @@ -0,0 +1,30 @@ +<?php + +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * The main form for creating and changing forms. + * + */ + +// Load Elgg engine +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +// Load form model +require_once(dirname(__FILE__)."/models/model.php"); + +// Define context +set_context('form'); + +global $CONFIG; + +$body = elgg_view('form/search_results_simple'); + +$title = elgg_echo('form:search_results_title'); + +page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + +?> \ No newline at end of file diff --git a/plugins/form/start.php b/plugins/form/start.php new file mode 100755 index 0000000000000000000000000000000000000000..d3e6b7c6f9b6d5686e864fdcb4fcc5dadb48d1cf --- /dev/null +++ b/plugins/form/start.php @@ -0,0 +1,246 @@ +<?php + + /** + * Elgg form plugin + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + // Load form model + require_once(dirname(__FILE__)."/models/model.php"); + + /** + * Form initialisation + * + * These parameters are required for the event API, but we won't use them: + * + * @param unknown_type $event + * @param unknown_type $object_type + * @param unknown_type $object + */ + + function form_init() { + + // Load system configuration + global $CONFIG; + + // Load the language files + register_translations($CONFIG->pluginspath . "form/languages/"); + register_translations($CONFIG->pluginspath . "form/languages/formtrans/"); + + // Register entity type + register_entity_type('object','form_data'); + + // Register a page handler, so we can have nice URLs + register_page_handler('form','form_page_handler'); + + register_plugin_hook('usersettings:save','user','form_user_settings_save'); + + // Register a URL handler for form data + register_entity_url_handler('form_data_url','object','form_data'); + + extend_view('css','form/css'); + + add_subtype('object', 'form:form'); + add_subtype('object', 'form:config'); + add_subtype('object', 'form:field'); + add_subtype('object', 'form:field_map'); + add_subtype('object', 'form:field_choice'); + add_subtype('object', 'form:search_definition'); + add_subtype('object', 'form_data'); + + } + + function form_pagesetup() { + global $CONFIG; + + // Set up menu and content setting for logged in users + if (isloggedin()) { + form_set_menu_items(); + if (form_get_user_content_status()) { + + add_menu(elgg_echo('item:object:form_data'), $CONFIG->wwwroot . "pg/form/" . $_SESSION['user']->username); + // add a view content option to user settings + extend_elgg_settings_page('form/settings/usersettings', 'usersettings/user'); + } + } + + $context = get_context(); + + $form_id = get_input('form_id',get_input('id',0)); + if (!$form_id && ($sid = get_input('sid',0))) { + $form_id = get_entity($sid)->form_id; + } + if ($form_id) { + $form = get_entity($form_id); + set_page_owner($form->getOwner()); + } + + $username = page_owner_entity()->username; + + if (get_context() == 'admin') { + $admin_url = $CONFIG->wwwroot.'mod/form/manage_all_forms.php'; + if ($username) { + $admin_url .= '?username='.$username; + } + add_submenu_item(elgg_echo('form:manage_forms_title'),$admin_url); + } + + if ($context == 'form:admin' && isadminloggedin()) { + // add_submenu_item(elgg_echo('form:add_new_profile_form_link'),$CONFIG->wwwroot.'mod/form/manage_form.php?username='.$username.'&profile=1', '4formactions'); + // add_submenu_item(elgg_echo('form:add_new_group_profile_form_link'),$CONFIG->wwwroot.'mod/form/manage_form.php?username='.$username.'&profile=2', '4formactions'); + add_submenu_item(elgg_echo('form:manage_group_profile_categories_title'),$CONFIG->wwwroot.'mod/form/manage_group_profile_categories.php?username='.$username, '4formactions'); + } + + if (in_array($context,array('form','form:content','form:admin')) && isadminloggedin()) { + // currently only admins get to manage forms + if ($form_id) { + add_submenu_item(elgg_echo('form:edit_page_link'),$CONFIG->wwwroot.'mod/form/manage_form.php?id='.$form_id,'1formactions'); + if ($context == 'form:admin') { + add_submenu_item(elgg_echo('form:preview_link_text'),$CONFIG->wwwroot.'mod/form/form.php?id='.$form_id.'&preview=true', '1formactions'); + add_submenu_item(elgg_echo('form:public_link_text'),$CONFIG->wwwroot.'mod/form/form.php?id='.$form_id, '1formactions'); + add_submenu_item(elgg_echo('form:list_search_definitions_link'),$CONFIG->wwwroot.'mod/form/list_search_definitions.php?form_id='.$form_id, '1formactions'); + add_submenu_item(elgg_echo('form:add_new_search_definition_link_text'),$CONFIG->wwwroot.'mod/form/manage_search_definition.php?form_id='.$form_id, '1formactions'); + add_submenu_item(elgg_echo('form:manage_translations_link'),$CONFIG->wwwroot.'mod/form/manage_form_translation.php?id='.$form_id, '1formactions'); + } + } + + add_submenu_item(elgg_echo('form:manage_forms_title'),$CONFIG->wwwroot.'mod/form/manage_all_forms.php?username='.$username, '3formactions'); + if ($context == 'form:admin') { + add_submenu_item(elgg_echo('form:add_new_link'),$CONFIG->wwwroot.'mod/form/manage_form.php?username='.$username, '4formactions'); + add_submenu_item(elgg_echo('form:list_all_fields_link'),$CONFIG->wwwroot.'mod/form/list_fields.php?type=all&username='.$username, '3formactions'); + add_submenu_item(elgg_echo('form:list_orphan_fields_link'),$CONFIG->wwwroot.'mod/form/list_fields.php?type=orphan&username='.$username, '3formactions'); + } + } + if (in_array($context,array('form','form:content','form:admin')) && (form_get_user_content_status())) { + add_submenu_item(elgg_echo('form:view_all_forms'),$CONFIG->wwwroot.'pg/form/'.$username, '2formactions'); + } + + if ($context == 'form:content' && $form_id) { + if (isloggedin()) { + set_page_owner($_SESSION['user']->getGUID()); + } + if (!$form->profile) { + if ($sid = get_input('sid',0)) { + $sid_bit = '&sid='.$sid; + } else { + $sid_bit = ''; + } + if (isloggedin()) { + add_submenu_item(elgg_echo('form:add_content'),$CONFIG->wwwroot.'mod/form/form.php?id='.$form_id,'0formactions'); + //add_submenu_item(elgg_echo('form:view_mine'),$CONFIG->wwwroot.'mod/form/my_forms.php?id='.$form_id.'&form_view=mine'.$sid_bit,'4formactions'); + //add_submenu_item(elgg_echo('form:view_friends'),$CONFIG->wwwroot.'mod/form/my_forms.php?id='.$form_id.'&form_view=friends'.$sid_bit,'4formactions'); + } + add_submenu_item(elgg_echo('form:view_all'),$CONFIG->wwwroot.'mod/form/my_forms.php?id='.$form_id.'&form_view=all'.$sid_bit,'0formactions'); + $sd_list = get_entities_from_metadata('form_id',$form_id,'object','form:search_definition'); + if ($sd_list) { + foreach($sd_list as $sd) { + $sd_id = $sd->getGUID(); + add_submenu_item(form_search_definition_t($form,$sd,'title'),$CONFIG->wwwroot.'mod/form/search.php?sid='.$sd_id,'0formactions'); + } + } + } + } + } + + /** + * Form page handler; allows the use of fancy URLs + * + * @param array $page From the page_handler function + * @return true|false Depending on success + */ + function form_page_handler($page) { + + // The first component of a form URL is the username + if (isset($page[0])) { + set_input('username',$page[0]); + } + + @include(dirname(__FILE__) . "/index.php"); + return true; + + } + + function form_data_url($form_data) { + global $CONFIG; + + if (isset($_SESSION['last_search_qs'])) { + $url = $CONFIG->wwwroot.'mod/form/display_search_object.php?d='.$form_data->getGUID(); + $url .= '&'.$_SESSION['last_search_qs']; + //} else if (isset($_SESSION['last_view_qs'])) { + // $url = $CONFIG->wwwroot.'mod/form/my_forms.php?'.$_SESSION['last_view_qs']; + } else { + $url = $CONFIG->wwwroot.'mod/form/display_object.php?d='.$form_data->getGUID(); + } + + return $url; + } + + function form_user_settings_save() { + $form_view_language = get_input('form_view_language',array()); + gatekeeper(); + + $user = page_owner_entity(); + if (!$user) { + $user = $_SESSION['user']; + } + + $result = false; + if (is_array($form_view_language)) { + $languages = implode(',',$form_view_language); + $setting_key = "form:view_content_languages"; + if ($user->$setting_key != $languages) { + $result = form_set_user_setting($user->getGUID(), $languages); + if ($result) { + system_message(elgg_echo('form:usersettings:save:ok')); + } else { + register_error(elgg_echo('form:usersettings:save:fail')); + } + } + } + } + + /** + * Set a form user pref. + * + * @param int $user_guid The user id. + * @param string $value. + * @return bool + */ + function form_set_user_setting($user_guid, $value) + { + $user_guid = (int)$user_guid; + + if ($user_guid == 0) + $user_guid = $_SESSION['user']->guid; + + $user = get_entity($user_guid); + + if (($user) && ($user instanceof ElggUser)) + { + $setting_key = "form:view_content_languages"; + $user->$setting_key = $value; + $user->save(); + + return true; + } + + return false; + } + +// Make sure the blog initialisation function is called on initialisation + register_elgg_event_handler('init','system','form_init'); + register_elgg_event_handler('pagesetup','system','form_pagesetup'); + +// Register actions + global $CONFIG; + register_action("form/manage_form",false,$CONFIG->pluginspath . "form/actions/manage_form.php"); + register_action("form/manage_field",false,$CONFIG->pluginspath . "form/actions/manage_field.php"); + register_action("form/manage_search_definition",false,$CONFIG->pluginspath . "form/actions/manage_search_definition.php"); + register_action("form/submit",true,$CONFIG->pluginspath . "form/actions/submit.php"); + register_action("form/manage_form_data",true,$CONFIG->pluginspath . "form/actions/manage_form_data.php"); +?> \ No newline at end of file diff --git a/plugins/form/tabber/example-ajax-0.html b/plugins/form/tabber/example-ajax-0.html new file mode 100755 index 0000000000000000000000000000000000000000..d536cc35b94040a13ae9b06ea1f3b3c4fd98544e --- /dev/null +++ b/plugins/form/tabber/example-ajax-0.html @@ -0,0 +1 @@ +<p>This is <em>ajax-0.html</em></p> diff --git a/plugins/form/tabber/example-ajax-1.html b/plugins/form/tabber/example-ajax-1.html new file mode 100755 index 0000000000000000000000000000000000000000..791da2bff57b6cbc1e9d3727b6cb9feff0615114 --- /dev/null +++ b/plugins/form/tabber/example-ajax-1.html @@ -0,0 +1 @@ +<p>This is <em>ajax-1.html</em></p> diff --git a/plugins/form/tabber/example-ajax-2.html b/plugins/form/tabber/example-ajax-2.html new file mode 100755 index 0000000000000000000000000000000000000000..aeebdf09b9890426b04e8913a02b3d63406dc0e6 --- /dev/null +++ b/plugins/form/tabber/example-ajax-2.html @@ -0,0 +1 @@ +<p>This is <em>ajax-2.html</em></p> diff --git a/plugins/form/tabber/example-ajax.html b/plugins/form/tabber/example-ajax.html new file mode 100755 index 0000000000000000000000000000000000000000..8210dedba98d7b06ee95c58843885de0458d979a --- /dev/null +++ b/plugins/form/tabber/example-ajax.html @@ -0,0 +1,86 @@ +<!-- $Id: example-ajax.html,v 1.2 2006/04/27 21:00:38 pat Exp $ --> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Ajax Tabber Example</title> + +<link rel="stylesheet" href="example.css" TYPE="text/css" MEDIA="screen"> +<link rel="stylesheet" href="example-print.css" TYPE="text/css" MEDIA="print"> + + +<!-- +Load prototype.js +You can get it at http://prototype.conio.net/ +--> +<script src="http://www.barelyfitz.com/projects/tabber/effects/prototype.js" type="text/javascript"></script> + +<script type="text/javascript"> + +/* Optional: Temporarily hide the "tabber" class so it does not "flash" + on the page as plain HTML. After tabber runs, the class is changed + to "tabberlive" and it will appear. */ + +document.write('<style type="text/css">.tabber{display:none;}<\/style>'); + +var tabberOptions = { + + 'onClick': function(argsObj) { + + var t = argsObj.tabber; /* Tabber object */ + var i = argsObj.index; /* Which tab was clicked (0..n) */ + var div = this.tabs[i].div; /* The tab content div */ + + /* Display a loading message */ + div.innerHTML = "<p>Loading...<\/p>"; + + /* Fetch some html depending on which tab was clicked */ + var url = 'example-ajax-' + i + '.html'; + var pars = 'foo=bar&foo2=bar2'; /* just for example */ + var myAjax = new Ajax.Updater(div, url, {method:'get',parameters:pars}); + }, + + 'onLoad': function(argsObj) { + /* Load the first tab */ + argsObj.index = 0; + this.onClick(argsObj); + }, + + +} +</script> + +<script type="text/javascript" src="tabber.js"></script> + +<style type="text/css"> +.tabberlive .tabbertab { + height:200px; +} +</style> +</head> +<body> + +<h1>Ajax Tabber Example</h1> + +<p>← <a href="http://www.barelyfitz.com/projects/tabber/">Tabber Home</a></p> + +<div class="tabber"> + + <div class="tabbertab"> + <h2>Tab 1</h2> + </div> + + + <div class="tabbertab"> + <h2>Tab 2</h2> + </div> + + + <div class="tabbertab"> + <h2>Tab 3</h2> + </div> + +</div> + +</body> +</html> diff --git a/plugins/form/tabber/example-cookies.html b/plugins/form/tabber/example-cookies.html new file mode 100755 index 0000000000000000000000000000000000000000..292b00f2480923b75299046d19ad0dead3a095b4 --- /dev/null +++ b/plugins/form/tabber/example-cookies.html @@ -0,0 +1,129 @@ +<!-- $Id: example-cookies.html,v 1.2 2006/04/07 05:01:55 pat Exp $ --> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Cookies Tabber Example</title> + +<link rel="stylesheet" href="example.css" TYPE="text/css" MEDIA="screen"> +<link rel="stylesheet" href="example-print.css" TYPE="text/css" MEDIA="print"> + +<script type="text/javascript"> + +/* Optional: Temporarily hide the "tabber" class so it does not "flash" + on the page as plain HTML. After tabber runs, the class is changed + to "tabberlive" and it will appear. */ + +document.write('<style type="text/css">.tabber{display:none;}<\/style>'); + +/*================================================== + Set the tabber options (must do this before including tabber.js) + ==================================================*/ +var tabberOptions = { + + 'cookie':"tabber", /* Name to use for the cookie */ + + 'onLoad': function(argsObj) + { + var t = argsObj.tabber; + var i; + + /* Optional: Add the id of the tabber to the cookie name to allow + for multiple tabber interfaces on the site. If you have + multiple tabber interfaces (even on different pages) I suggest + setting a unique id on each one, to avoid having the cookie set + the wrong tab. + */ + if (t.id) { + t.cookie = t.id + t.cookie; + } + + /* If a cookie was previously set, restore the active tab */ + i = parseInt(getCookie(t.cookie)); + if (isNaN(i)) { return; } + t.tabShow(i); + alert('getCookie(' + t.cookie + ') = ' + i); + }, + + 'onClick':function(argsObj) + { + var c = argsObj.tabber.cookie; + var i = argsObj.index; + alert('setCookie(' + c + ',' + i + ')'); + setCookie(c, i); + } +}; + +/*================================================== + Cookie functions + ==================================================*/ +function setCookie(name, value, expires, path, domain, secure) { + document.cookie= name + "=" + escape(value) + + ((expires) ? "; expires=" + expires.toGMTString() : "") + + ((path) ? "; path=" + path : "") + + ((domain) ? "; domain=" + domain : "") + + ((secure) ? "; secure" : ""); +} + +function getCookie(name) { + var dc = document.cookie; + var prefix = name + "="; + var begin = dc.indexOf("; " + prefix); + if (begin == -1) { + begin = dc.indexOf(prefix); + if (begin != 0) return null; + } else { + begin += 2; + } + var end = document.cookie.indexOf(";", begin); + if (end == -1) { + end = dc.length; + } + return unescape(dc.substring(begin + prefix.length, end)); +} +function deleteCookie(name, path, domain) { + if (getCookie(name)) { + document.cookie = name + "=" + + ((path) ? "; path=" + path : "") + + ((domain) ? "; domain=" + domain : "") + + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; + } +} + +</script> + +<!-- Include the tabber code --> +<script type="text/javascript" src="tabber.js"></script> + +</head> +<body> + +<h1>Tabber Example</h1> + +<p>← <a href="http://www.barelyfitz.com/projects/tabber/">Tabber Home</a></p> + +<p>This example sets a cookie whenever the you click the tab, so if you leave the page and return the same tab remains selected. For purposes of example, this page displays an alert to indicate when a cookie is set or retrieved.</p> + +<div class="tabber" id="mytabber1"> + + <div class="tabbertab"> + <h2>Tab 1</h2> + <p>Tab 1 content.</p> + </div> + + + <div class="tabbertab"> + <h2>Tab 2</h2> + <p>Tab 2 content.</p> + </div> + + + <div class="tabbertab"> + <h2>Tab 3</h2> + <p>Tab 3 content.</p> + </div> + +</div> + +</body> +</html> diff --git a/plugins/form/tabber/example.css b/plugins/form/tabber/example.css new file mode 100755 index 0000000000000000000000000000000000000000..3c3a6ba430cdb845da28eac6d04cb2797ee5bede --- /dev/null +++ b/plugins/form/tabber/example.css @@ -0,0 +1,107 @@ +/* $Id: example.css,v 1.5 2006/03/27 02:44:36 pat Exp $ */ + +/*-------------------------------------------------- + REQUIRED to hide the non-active tab content. + But do not hide them in the print stylesheet! + --------------------------------------------------*/ +.tabberlive .tabbertabhide { + display:none; +} + +/*-------------------------------------------------- + .tabber = before the tabber interface is set up + .tabberlive = after the tabber interface is set up + --------------------------------------------------*/ +.tabber .tabberloading { + width:100%; + height:33px; + background: url(../../../_graphics/ajax_loader.gif) no-repeat top center; +} +.tabber .tabbertab { + display: none; +} +.tabberlive { + margin-top:1em; +} + +/*-------------------------------------------------- + ul.tabbernav = the tab navigation list + li.tabberactive = the active tab + --------------------------------------------------*/ +ul.tabbernav +{ + margin:0; + padding: 3px 0; + border-bottom: 1px solid #778; + font: bold 12px Verdana, sans-serif; +} + +ul.tabbernav li +{ + list-style: none; + margin: 0; + display: inline; +} + +ul.tabbernav li a +{ + padding: 3px 0.5em; + margin-left: 3px; + border: 1px solid #778; + border-bottom: none; + background: #DDE; + text-decoration: none; +} + +ul.tabbernav li a:link { color: #448; } +ul.tabbernav li a:visited { color: #667; } + +ul.tabbernav li a:hover +{ + color: #000; + background: #AAE; + border-color: #227; +} + +ul.tabbernav li.tabberactive a +{ + background-color: #fff; + border-bottom: 1px solid #fff; +} + +ul.tabbernav li.tabberactive a:hover +{ + color: #000; + background: white; + border-bottom: 1px solid white; +} + +/*-------------------------------------------------- + .tabbertab = the tab content + Add style only after the tabber interface is set up (.tabberlive) + --------------------------------------------------*/ +.tabberlive .tabbertab { + padding:5px; + border:1px solid #aaa; + border-top:0; + + /* If you don't want the tab size changing whenever a tab is changed + you can set a fixed height */ + + /* height:200px; */ + + /* If you set a fix height set overflow to auto and you will get a + scrollbar when necessary */ + + /* overflow:auto; */ +} + +/* Example of using an ID to set different styles for the tabs on the page */ +.tabberlive#tab1 { +} +.tabberlive#tab2 { +} +.tabberlive#tab2 .tabbertab { + height:200px; + overflow:auto; +} diff --git a/plugins/form/tabber/example.html b/plugins/form/tabber/example.html new file mode 100755 index 0000000000000000000000000000000000000000..b275828e6482c6ffb3f44643209df31423650764 --- /dev/null +++ b/plugins/form/tabber/example.html @@ -0,0 +1,50 @@ +<!-- $Id: example.html,v 1.4 2006/03/27 02:44:36 pat Exp $ --> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Simple Tabber Example</title> + +<script type="text/javascript" src="tabber.js"></script> +<link rel="stylesheet" href="example.css" TYPE="text/css" MEDIA="screen"> +<link rel="stylesheet" href="example-print.css" TYPE="text/css" MEDIA="print"> + +<script type="text/javascript"> + +/* Optional: Temporarily hide the "tabber" class so it does not "flash" + on the page as plain HTML. After tabber runs, the class is changed + to "tabberlive" and it will appear. */ + +document.write('<style type="text/css">.tabber{display:none;}<\/style>'); +</script> + +</head> +<body> + +<h1>Tabber Example</h1> + +<p>← <a href="http://www.barelyfitz.com/projects/tabber/">Tabber Home</a></p> + +<div class="tabber"> + + <div class="tabbertab"> + <h2>Tab 1</h2> + <p>Tab 1 content.</p> + </div> + + + <div class="tabbertab"> + <h2>Tab 2</h2> + <p>Tab 2 content.</p> + </div> + + + <div class="tabbertab"> + <h2>Tab 3</h2> + <p>Tab 3 content.</p> + </div> + +</div> + +</body> +</html> diff --git a/plugins/form/tabber/example2.html b/plugins/form/tabber/example2.html new file mode 100755 index 0000000000000000000000000000000000000000..a091815c4efba3415d91ce17a738c0eaef361def --- /dev/null +++ b/plugins/form/tabber/example2.html @@ -0,0 +1,153 @@ +<!-- $Id: example2.html,v 1.8 2006/04/10 05:05:28 pat Exp $ --> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Advanced Tabber Example</title> + +<link rel="stylesheet" href="example.css" TYPE="text/css" MEDIA="screen"> +<link rel="stylesheet" href="example-print.css" TYPE="text/css" MEDIA="print"> + +<script type="text/javascript"> + +/* Optional: Temporarily hide the "tabber" class so it does not "flash" + on the page as plain HTML. After tabber runs, the class is changed + to "tabberlive" and it will appear. +*/ +document.write('<style type="text/css">.tabber{display:none;}<\/style>'); + +var tabberOptions = { + + /* Optional: instead of letting tabber run during the onload event, + we'll start it up manually. This can be useful because the onload + even runs after all the images have finished loading, and we can + run tabber at the bottom of our page to start it up faster. See the + bottom of this page for more info. Note: this variable must be set + BEFORE you include tabber.js. + */ + 'manualStartup':true, + + /* Optional: code to run after each tabber object has initialized */ + + 'onLoad': function(argsObj) { + /* Display an alert only after tab2 */ + if (argsObj.tabber.id == 'tab2') { + alert('Finished loading tab2!'); + } + }, + + /* Optional: code to run when the user clicks a tab. If this + function returns boolean false then the tab will not be changed + (the click is canceled). If you do not return a value or return + something that is not boolean false, */ + + 'onClick': function(argsObj) { + + var t = argsObj.tabber; /* Tabber object */ + var id = t.id; /* ID of the main tabber DIV */ + var i = argsObj.index; /* Which tab was clicked (0 is the first tab) */ + var e = argsObj.event; /* Event object */ + + if (id == 'tab2') { + return confirm('Swtich to '+t.tabs[i].headingText+'?\nEvent type: '+e.type); + } + }, + + /* Optional: set an ID for each tab navigation link */ + 'addLinkId': true + +}; + +</script> + +<!-- Load the tabber code --> +<script type="text/javascript" src="tabber.js"></script> + +</head> +<body> + +<h1>Advanced Tabber Example</h1> + +<p>← <a href="http://www.barelyfitz.com/projects/tabber/">Tabber Home</a></p> + +<p>In the following example, the height is not constrained, so the page jumps around when a new tab is selected. "Tab 2" contains a nested tabber.</p> + +<div class="tabber" id="tab1"> + + <div class="tabbertab"> + <h2><a name="tab1">Tab <em>1</em></a></h2> + <p>Tab 1 content.</p> + </div> + + <div class="tabbertab"> + <h2>Tab 2</h2> + <p>Tab 2 content. A nested tabber:</p> + + <div class="tabber" id="tab1-1"> + + <div class="tabbertab"> + <h3>Tab 2-1</h3> + <p>Tab 2-1 content.</p> + </div> + + <div class="tabbertab"> + <h3>Tab 2-2</h3> + <p>Tab 2-2 content.</p> + </div> + + <div class="tabbertab"> + <h3>Tab 2-3</h3> + <p>Tab 2-3 content.</p> + </div> + </div> + </div> + + <div class="tabbertab"> + <h2>Tab 3</h2> + <p>Tab 3 content.</p> + </div> +</div> + +<p>In the following example, "Tab 2" should be selected automatically. In addition, there is an onclick function attached to the tabs so you can confirm each click.</p> + + +<div class="tabber" id="tab2"> + + <div class="tabbertab"> + <h2>Tab 1</h2> + <p>Tab 1 content.</p> + </div> + + <div class="tabbertab tabbertabdefault"> + <h2>Tab 2</h2> + <p>Long content to show the scrollbar to the right.</p> + <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras nonummy lorem quis neque. Etiam molestie auctor ante. Fusce in enim. Suspendisse at ipsum. Praesent eget odio vitae lorem consectetuer euismod. Mauris vel risus eget arcu congue sodales. Mauris adipiscing viverra ante. Cras pharetra augue sit amet enim. Pellentesque ac sem. Nullam pulvinar convallis orci. In tristique accumsan enim. Nam venenatis suscipit lorem. Nam ut dui sit amet libero egestas facilisis. Aliquam elementum lectus sed ipsum tincidunt aliquet. Pellentesque nec nunc at metus malesuada hendrerit. Suspendisse magna. Aliquam odio augue, eleifend non, euismod nec, molestie quis, pede. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;</p> + + <p>In hac habitasse platea dictumst. Aenean suscipit nisl. In mollis consequat purus. Integer scelerisque. Nullam imperdiet sapien nec lectus. Praesent in orci. Donec magna magna, posuere at, auctor in, sagittis nec, mi. Morbi volutpat, magna pharetra scelerisque lacinia, est erat ultricies neque, nec convallis lorem lorem ut dolor. Proin ac nunc eget nibh pulvinar gravida. Sed pretium, sem ac suscipit imperdiet, mauris ligula dictum nulla, pulvinar interdum pede urna vel magna. In lectus. In sed odio. Quisque eros ligula, placerat nec, tincidunt in, ullamcorper sed, lectus. Nam aliquet orci eget ante. Aliquam aliquet mattis pede. Mauris eleifend nibh vel nunc.</p> + + <p>Sed mi lacus, sodales ac, lacinia nec, rutrum sodales, dolor. Morbi convallis molestie enim. Aenean tristique justo. Nullam erat ante, tempor a, suscipit ut, luctus vitae, erat. Proin fermentum. Etiam id erat ut est scelerisque volutpat. Praesent gravida libero vitae sapien. Donec vel elit. In non enim nec quam rutrum sollicitudin. Suspendisse tincidunt adipiscing ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam vel nulla non augue varius pretium. Integer vestibulum enim vel tortor.</p> + + <p>Nulla at massa. Vivamus turpis urna, ultrices eget, auctor ullamcorper, ultricies quis, urna. Proin lobortis tincidunt orci. Duis quam neque, mattis vel, rutrum vitae, porttitor id, libero. Vestibulum sagittis lorem eget pede. Curabitur dignissim, nisi sit amet porttitor dignissim, quam felis condimentum arcu, eget facilisis metus lacus in quam. Nulla semper. In hac habitasse platea dictumst. Aenean luctus diam. Aenean consequat massa quis nisi.</p> + + <p>Curabitur quam odio, ornare vel, hendrerit ac, sagittis mattis, ipsum. Fusce accumsan, dolor ac suscipit gravida, tortor nibh cursus ligula, at posuere orci arcu euismod ipsum. Nunc iaculis, turpis quis mattis imperdiet, nibh sapien venenatis nulla, id ornare tortor nunc in risus. Morbi lacinia mollis nulla. Donec tempus vestibulum diam. Praesent aliquet metus non orci. Nulla dictum pulvinar sem. Proin mi. Maecenas pharetra enim eget elit. Ut interdum libero ac est. Phasellus accumsan. Praesent vulputate vehicula elit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla pretium diam non felis. Aenean at nisl. Proin rutrum tempus mauris. In metus ante, congue eu, vestibulum in, tincidunt sit amet, tortor. Suspendisse non enim eget elit imperdiet fringilla. Pellentesque odio erat, consequat vitae, euismod nec, congue sed, lectus. Praesent tempor urna.</p> + </div> + + <div class="tabbertab" title="Tab 3 Title Override"> + <h2>Tab 3</h2> + <p>The name of this tab is taken from the TITLE attribute instead of from the H2 element, then the TITLE attribute is erased so it does not cause a mouseover tooltip over the content area.</p> + </div> +</div> + +<script type="text/javascript"> + +/* Since we specified manualStartup=true, tabber will not run after + the onload event. Instead let's run it now, to prevent any delay + while images load. +*/ + +tabberAutomatic(tabberOptions); + +</script> + +</body> +</html> diff --git a/plugins/form/tabber/tabber-minimized.js b/plugins/form/tabber/tabber-minimized.js new file mode 100755 index 0000000000000000000000000000000000000000..34dd2e8daff071064123b012e5d07d13fa8f9152 --- /dev/null +++ b/plugins/form/tabber/tabber-minimized.js @@ -0,0 +1,40 @@ +/* Copyright (c) 2006 Patrick Fitzgerald */ + +function tabberObj(argsObj) +{var arg;this.div=null;this.classMain="tabber";this.classMainLive="tabberlive";this.classTab="tabbertab";this.classTabDefault="tabbertabdefault";this.classNav="tabbernav";this.classTabHide="tabbertabhide";this.classNavActive="tabberactive";this.titleElements=['h2','h3','h4','h5','h6'];this.titleElementsStripHTML=true;this.removeTitle=true;this.addLinkId=false;this.linkIdFormat='<tabberid>nav<tabnumberone>';for(arg in argsObj){this[arg]=argsObj[arg];} +this.REclassMain=new RegExp('\\b'+this.classMain+'\\b','gi');this.REclassMainLive=new RegExp('\\b'+this.classMainLive+'\\b','gi');this.REclassTab=new RegExp('\\b'+this.classTab+'\\b','gi');this.REclassTabDefault=new RegExp('\\b'+this.classTabDefault+'\\b','gi');this.REclassTabHide=new RegExp('\\b'+this.classTabHide+'\\b','gi');this.tabs=new Array();if(this.div){this.init(this.div);this.div=null;}} +tabberObj.prototype.init=function(e) +{var +childNodes,i,i2,t,defaultTab=0,DOM_ul,DOM_li,DOM_a,aId,headingElement;if(!document.getElementsByTagName){return false;} +if(e.id){this.id=e.id;} +this.tabs.length=0;childNodes=e.childNodes;for(i=0;i<childNodes.length;i++){if(childNodes[i].className&&childNodes[i].className.match(this.REclassTab)){t=new Object();t.div=childNodes[i];this.tabs[this.tabs.length]=t;if(childNodes[i].className.match(this.REclassTabDefault)){defaultTab=this.tabs.length-1;}}} +DOM_ul=document.createElement("ul");DOM_ul.className=this.classNav;for(i=0;i<this.tabs.length;i++){t=this.tabs[i];t.headingText=t.div.title;if(this.removeTitle){t.div.title='';} +if(!t.headingText){for(i2=0;i2<this.titleElements.length;i2++){headingElement=t.div.getElementsByTagName(this.titleElements[i2])[0];if(headingElement){t.headingText=headingElement.innerHTML;if(this.titleElementsStripHTML){t.headingText.replace(/<br>/gi," ");t.headingText=t.headingText.replace(/<[^>]+>/g,"");} +break;}}} +if(!t.headingText){t.headingText=i+1;} +DOM_li=document.createElement("li");t.li=DOM_li;DOM_a=document.createElement("a");DOM_a.appendChild(document.createTextNode(t.headingText));DOM_a.href="javascript:void(null);";DOM_a.title=t.headingText;DOM_a.onclick=this.navClick;DOM_a.tabber=this;DOM_a.tabberIndex=i;if(this.addLinkId&&this.linkIdFormat){aId=this.linkIdFormat;aId=aId.replace(/<tabberid>/gi,this.id);aId=aId.replace(/<tabnumberzero>/gi,i);aId=aId.replace(/<tabnumberone>/gi,i+1);aId=aId.replace(/<tabtitle>/gi,t.headingText.replace(/[^a-zA-Z0-9\-]/gi,''));DOM_a.id=aId;} +DOM_li.appendChild(DOM_a);DOM_ul.appendChild(DOM_li);} +e.insertBefore(DOM_ul,e.firstChild);e.className=e.className.replace(this.REclassMain,this.classMainLive);this.tabShow(defaultTab);if(typeof this.onLoad=='function'){this.onLoad({tabber:this});} +return this;};tabberObj.prototype.navClick=function(event) +{var +rVal,a,self,tabberIndex,onClickArgs;a=this;if(!a.tabber){return false;} +self=a.tabber;tabberIndex=a.tabberIndex;a.blur();if(typeof self.onClick=='function'){onClickArgs={'tabber':self,'index':tabberIndex,'event':event};if(!event){onClickArgs.event=window.event;} +rVal=self.onClick(onClickArgs);if(rVal===false){return false;}} +self.tabShow(tabberIndex);return false;};tabberObj.prototype.tabHideAll=function() +{var i;for(i=0;i<this.tabs.length;i++){this.tabHide(i);}};tabberObj.prototype.tabHide=function(tabberIndex) +{var div;if(!this.tabs[tabberIndex]){return false;} +div=this.tabs[tabberIndex].div;if(!div.className.match(this.REclassTabHide)){div.className+=' '+this.classTabHide;} +this.navClearActive(tabberIndex);return this;};tabberObj.prototype.tabShow=function(tabberIndex) +{var div;if(!this.tabs[tabberIndex]){return false;} +this.tabHideAll();div=this.tabs[tabberIndex].div;div.className=div.className.replace(this.REclassTabHide,'');this.navSetActive(tabberIndex);if(typeof this.onTabDisplay=='function'){this.onTabDisplay({'tabber':this,'index':tabberIndex});} +return this;};tabberObj.prototype.navSetActive=function(tabberIndex) +{this.tabs[tabberIndex].li.className=this.classNavActive;return this;};tabberObj.prototype.navClearActive=function(tabberIndex) +{this.tabs[tabberIndex].li.className='';return this;};function tabberAutomatic(tabberArgs) +{var +tempObj,divs,i;if(!tabberArgs){tabberArgs={};} +tempObj=new tabberObj(tabberArgs);divs=document.getElementsByTagName("div");for(i=0;i<divs.length;i++){if(divs[i].className&&divs[i].className.match(tempObj.REclassMain)){tabberArgs.div=divs[i];divs[i].tabber=new tabberObj(tabberArgs);}} +return this;} +function tabberAutomaticOnLoad(tabberArgs) +{var oldOnLoad;if(!tabberArgs){tabberArgs={};} +oldOnLoad=window.onload;if(typeof window.onload!='function'){window.onload=function(){tabberAutomatic(tabberArgs);};}else{window.onload=function(){oldOnLoad();tabberAutomatic(tabberArgs);};}} +if(typeof tabberOptions=='undefined'){tabberAutomaticOnLoad();}else{if(!tabberOptions['manualStartup']){tabberAutomaticOnLoad(tabberOptions);}} \ No newline at end of file diff --git a/plugins/form/tabber/tabber.js b/plugins/form/tabber/tabber.js new file mode 100755 index 0000000000000000000000000000000000000000..4fea3145c4c92973efc1fa6f1267328e1d072d4d --- /dev/null +++ b/plugins/form/tabber/tabber.js @@ -0,0 +1,523 @@ +/*================================================== + $Id: tabber.js,v 1.9 2006/04/27 20:51:51 pat Exp $ + tabber.js by Patrick Fitzgerald pat@barelyfitz.com + + Documentation can be found at the following URL: + http://www.barelyfitz.com/projects/tabber/ + + License (http://www.opensource.org/licenses/mit-license.php) + + Copyright (c) 2006 Patrick Fitzgerald + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + ==================================================*/ + +function tabberObj(argsObj) +{ + var arg; /* name of an argument to override */ + + /* Element for the main tabber div. If you supply this in argsObj, + then the init() method will be called. + */ + this.div = null; + + /* Class of the main tabber div */ + this.classMain = "tabber"; + + /* Rename classMain to classMainLive after tabifying + (so a different style can be applied) + */ + this.classMainLive = "tabberlive"; + + /* Class of each DIV that contains a tab */ + this.classTab = "tabbertab"; + + /* Class to indicate which tab should be active on startup */ + this.classTabDefault = "tabbertabdefault"; + + /* Class for the navigation UL */ + this.classNav = "tabbernav"; + + /* When a tab is to be hidden, instead of setting display='none', we + set the class of the div to classTabHide. In your screen + stylesheet you should set classTabHide to display:none. In your + print stylesheet you should set display:block to ensure that all + the information is printed. + */ + this.classTabHide = "tabbertabhide"; + + /* Class to set the navigation LI when the tab is active, so you can + use a different style on the active tab. + */ + this.classNavActive = "tabberactive"; + + /* Elements that might contain the title for the tab, only used if a + title is not specified in the TITLE attribute of DIV classTab. + */ + this.titleElements = ['h2','h3','h4','h5','h6']; + + /* Should we strip out the HTML from the innerHTML of the title elements? + This should usually be true. + */ + this.titleElementsStripHTML = true; + + /* If the user specified the tab names using a TITLE attribute on + the DIV, then the browser will display a tooltip whenever the + mouse is over the DIV. To prevent this tooltip, we can remove the + TITLE attribute after getting the tab name. + */ + this.removeTitle = true; + + /* If you want to add an id to each link set this to true */ + this.addLinkId = false; + + /* If addIds==true, then you can set a format for the ids. + <tabberid> will be replaced with the id of the main tabber div. + <tabnumberzero> will be replaced with the tab number + (tab numbers starting at zero) + <tabnumberone> will be replaced with the tab number + (tab numbers starting at one) + <tabtitle> will be replaced by the tab title + (with all non-alphanumeric characters removed) + */ + this.linkIdFormat = '<tabberid>nav<tabnumberone>'; + + /* You can override the defaults listed above by passing in an object: + var mytab = new tabber({property:value,property:value}); + */ + for (arg in argsObj) { this[arg] = argsObj[arg]; } + + /* Create regular expressions for the class names; Note: if you + change the class names after a new object is created you must + also change these regular expressions. + */ + this.REclassMain = new RegExp('\\b' + this.classMain + '\\b', 'gi'); + this.REclassMainLive = new RegExp('\\b' + this.classMainLive + '\\b', 'gi'); + this.REclassTab = new RegExp('\\b' + this.classTab + '\\b', 'gi'); + this.REclassTabDefault = new RegExp('\\b' + this.classTabDefault + '\\b', 'gi'); + this.REclassTabHide = new RegExp('\\b' + this.classTabHide + '\\b', 'gi'); + + /* Array of objects holding info about each tab */ + this.tabs = new Array(); + + /* If the main tabber div was specified, call init() now */ + if (this.div) { + + this.init(this.div); + + /* We don't need the main div anymore, and to prevent a memory leak + in IE, we must remove the circular reference between the div + and the tabber object. */ + this.div = null; + } +} + + +/*-------------------------------------------------- + Methods for tabberObj + --------------------------------------------------*/ + + +tabberObj.prototype.init = function(e) +{ + /* Set up the tabber interface. + + e = element (the main containing div) + + Example: + init(document.getElementById('mytabberdiv')) + */ + + var + childNodes, /* child nodes of the tabber div */ + i, i2, /* loop indices */ + t, /* object to store info about a single tab */ + defaultTab=0, /* which tab to select by default */ + DOM_ul, /* tabbernav list */ + DOM_li, /* tabbernav list item */ + DOM_a, /* tabbernav link */ + aId, /* A unique id for DOM_a */ + headingElement; /* searching for text to use in the tab */ + + /* Verify that the browser supports DOM scripting */ + if (!document.getElementsByTagName) { return false; } + + /* If the main DIV has an ID then save it. */ + if (e.id) { + this.id = e.id; + } + + /* Clear the tabs array (but it should normally be empty) */ + this.tabs.length = 0; + + /* Loop through an array of all the child nodes within our tabber element. */ + childNodes = e.childNodes; + for(i=0; i < childNodes.length; i++) { + + /* Find the nodes where class="tabbertab" */ + if(childNodes[i].className && + childNodes[i].className.match(this.REclassTab)) { + + /* Create a new object to save info about this tab */ + t = new Object(); + + /* Save a pointer to the div for this tab */ + t.div = childNodes[i]; + + /* Add the new object to the array of tabs */ + this.tabs[this.tabs.length] = t; + + /* If the class name contains classTabDefault, + then select this tab by default. + */ + if (childNodes[i].className.match(this.REclassTabDefault)) { + defaultTab = this.tabs.length-1; + } + } + } + + /* Create a new UL list to hold the tab headings */ + DOM_ul = document.createElement("ul"); + DOM_ul.className = this.classNav; + + /* Loop through each tab we found */ + for (i=0; i < this.tabs.length; i++) { + + t = this.tabs[i]; + + /* Get the label to use for this tab: + From the title attribute on the DIV, + Or from one of the this.titleElements[] elements, + Or use an automatically generated number. + */ + t.headingText = t.div.title; + + /* Remove the title attribute to prevent a tooltip from appearing */ + if (this.removeTitle) { t.div.title = ''; } + + if (!t.headingText) { + + /* Title was not defined in the title of the DIV, + So try to get the title from an element within the DIV. + Go through the list of elements in this.titleElements + (typically heading elements ['h2','h3','h4']) + */ + for (i2=0; i2<this.titleElements.length; i2++) { + headingElement = t.div.getElementsByTagName(this.titleElements[i2])[0]; + if (headingElement) { + t.headingText = headingElement.innerHTML; + if (this.titleElementsStripHTML) { + t.headingText.replace(/<br>/gi," "); + t.headingText = t.headingText.replace(/<[^>]+>/g,""); + } + break; + } + } + } + + if (!t.headingText) { + /* Title was not found (or is blank) so automatically generate a + number for the tab. + */ + t.headingText = i + 1; + } + + /* Create a list element for the tab */ + DOM_li = document.createElement("li"); + + /* Save a reference to this list item so we can later change it to + the "active" class */ + t.li = DOM_li; + + /* Create a link to activate the tab */ + DOM_a = document.createElement("a"); + DOM_a.appendChild(document.createTextNode(t.headingText)); + DOM_a.href = "javascript:void(null);"; + DOM_a.title = t.headingText; + DOM_a.onclick = this.navClick; + + /* Add some properties to the link so we can identify which tab + was clicked. Later the navClick method will need this. + */ + DOM_a.tabber = this; + DOM_a.tabberIndex = i; + + /* Do we need to add an id to DOM_a? */ + if (this.addLinkId && this.linkIdFormat) { + + /* Determine the id name */ + aId = this.linkIdFormat; + aId = aId.replace(/<tabberid>/gi, this.id); + aId = aId.replace(/<tabnumberzero>/gi, i); + aId = aId.replace(/<tabnumberone>/gi, i+1); + aId = aId.replace(/<tabtitle>/gi, t.headingText.replace(/[^a-zA-Z0-9\-]/gi, '')); + + DOM_a.id = aId; + } + + /* Add the link to the list element */ + DOM_li.appendChild(DOM_a); + + /* Add the list element to the list */ + DOM_ul.appendChild(DOM_li); + } + + /* Add the UL list to the beginning of the tabber div */ + e.insertBefore(DOM_ul, e.firstChild); + + /* Make the tabber div "live" so different CSS can be applied */ + e.className = e.className.replace(this.REclassMain, this.classMainLive); + + /* Activate the default tab, and do not call the onclick handler */ + this.tabShow(defaultTab); + + /* If the user specified an onLoad function, call it now. */ + if (typeof this.onLoad == 'function') { + this.onLoad({tabber:this}); + } + + return this; +}; + + +tabberObj.prototype.navClick = function(event) +{ + /* This method should only be called by the onClick event of an <A> + element, in which case we will determine which tab was clicked by + examining a property that we previously attached to the <A> + element. + + Since this was triggered from an onClick event, the variable + "this" refers to the <A> element that triggered the onClick + event (and not to the tabberObj). + + When tabberObj was initialized, we added some extra properties + to the <A> element, for the purpose of retrieving them now. Get + the tabberObj object, plus the tab number that was clicked. + */ + + var + rVal, /* Return value from the user onclick function */ + a, /* element that triggered the onclick event */ + self, /* the tabber object */ + tabberIndex, /* index of the tab that triggered the event */ + onClickArgs; /* args to send the onclick function */ + + a = this; + if (!a.tabber) { return false; } + + self = a.tabber; + tabberIndex = a.tabberIndex; + + /* Remove focus from the link because it looks ugly. + I don't know if this is a good idea... + */ + a.blur(); + + /* If the user specified an onClick function, call it now. + If the function returns false then do not continue. + */ + if (typeof self.onClick == 'function') { + + onClickArgs = {'tabber':self, 'index':tabberIndex, 'event':event}; + + /* IE uses a different way to access the event object */ + if (!event) { onClickArgs.event = window.event; } + + rVal = self.onClick(onClickArgs); + if (rVal === false) { return false; } + } + + self.tabShow(tabberIndex); + + return false; +}; + + +tabberObj.prototype.tabHideAll = function() +{ + var i; /* counter */ + + /* Hide all tabs and make all navigation links inactive */ + for (i = 0; i < this.tabs.length; i++) { + this.tabHide(i); + } +}; + + +tabberObj.prototype.tabHide = function(tabberIndex) +{ + var div; + + if (!this.tabs[tabberIndex]) { return false; } + + /* Hide a single tab and make its navigation link inactive */ + div = this.tabs[tabberIndex].div; + + /* Hide the tab contents by adding classTabHide to the div */ + if (!div.className.match(this.REclassTabHide)) { + div.className += ' ' + this.classTabHide; + } + this.navClearActive(tabberIndex); + + return this; +}; + + +tabberObj.prototype.tabShow = function(tabberIndex) +{ + /* Show the tabberIndex tab and hide all the other tabs */ + + var div; + + if (!this.tabs[tabberIndex]) { return false; } + + /* Hide all the tabs first */ + this.tabHideAll(); + + /* Get the div that holds this tab */ + div = this.tabs[tabberIndex].div; + + /* Remove classTabHide from the div */ + div.className = div.className.replace(this.REclassTabHide, ''); + + /* Mark this tab navigation link as "active" */ + this.navSetActive(tabberIndex); + + /* If the user specified an onTabDisplay function, call it now. */ + if (typeof this.onTabDisplay == 'function') { + this.onTabDisplay({'tabber':this, 'index':tabberIndex}); + } + + return this; +}; + +tabberObj.prototype.navSetActive = function(tabberIndex) +{ + /* Note: this method does *not* enforce the rule + that only one nav item can be active at a time. + */ + + /* Set classNavActive for the navigation list item */ + this.tabs[tabberIndex].li.className = this.classNavActive; + + return this; +}; + + +tabberObj.prototype.navClearActive = function(tabberIndex) +{ + /* Note: this method does *not* enforce the rule + that one nav should always be active. + */ + + /* Remove classNavActive from the navigation list item */ + this.tabs[tabberIndex].li.className = ''; + + return this; +}; + + +/*==================================================*/ + + +function tabberAutomatic(tabberArgs) +{ + /* This function finds all DIV elements in the document where + class=tabber.classMain, then converts them to use the tabber + interface. + + tabberArgs = an object to send to "new tabber()" + */ + var + tempObj, /* Temporary tabber object */ + divs, /* Array of all divs on the page */ + i; /* Loop index */ + + if (!tabberArgs) { tabberArgs = {}; } + + /* Create a tabber object so we can get the value of classMain */ + tempObj = new tabberObj(tabberArgs); + + /* Find all DIV elements in the document that have class=tabber */ + + /* First get an array of all DIV elements and loop through them */ + divs = document.getElementsByTagName("div"); + for (i=0; i < divs.length; i++) { + + /* Is this DIV the correct class? */ + if (divs[i].className && + divs[i].className.match(tempObj.REclassMain)) { + + /* Now tabify the DIV */ + tabberArgs.div = divs[i]; + divs[i].tabber = new tabberObj(tabberArgs); + } + } + + return this; +} + + +/*==================================================*/ + + +function tabberAutomaticOnLoad(tabberArgs) +{ + /* This function adds tabberAutomatic to the window.onload event, + so it will run after the document has finished loading. + */ + var oldOnLoad; + + if (!tabberArgs) { tabberArgs = {}; } + + /* Taken from: http://simon.incutio.com/archive/2004/05/26/addLoadEvent */ + + oldOnLoad = window.onload; + if (typeof window.onload != 'function') { + window.onload = function() { + tabberAutomatic(tabberArgs); + }; + } else { + window.onload = function() { + oldOnLoad(); + tabberAutomatic(tabberArgs); + }; + } +} + + +/*==================================================*/ + + +/* Run tabberAutomaticOnload() unless the "manualStartup" option was specified */ + +if (typeof tabberOptions == 'undefined') { + + tabberAutomaticOnLoad(); + +} else { + + if (!tabberOptions['manualStartup']) { + tabberAutomaticOnLoad(tabberOptions); + } + +} diff --git a/plugins/form/views/default/form/css.php b/plugins/form/views/default/form/css.php new file mode 100755 index 0000000000000000000000000000000000000000..0e646ca110377c0f526f2b08d77c3a36800ec065 --- /dev/null +++ b/plugins/form/views/default/form/css.php @@ -0,0 +1,19 @@ +.river_object_form_data_create { + background: url(<?php echo $vars['url']; ?>_graphics/river_icons/river_icon_blog.gif) no-repeat left -1px; +} +.river_object_form_data_comment { + background: url(<?php echo $vars['url']; ?>_graphics/river_icons/river_icon_comment.gif) no-repeat left -1px; +} + +.form_listing .search_listing { + border:2px solid #cccccc; + margin:0 0 5px 0; +} + +#groups_info_column_left .tabberlive .tabbertab { + background-color: white; +} + +#profile_info_column_middle .tabberlive .tabbertab { + background-color: white; +} \ No newline at end of file diff --git a/plugins/form/views/default/form/default_form_data_display.php b/plugins/form/views/default/form/default_form_data_display.php new file mode 100755 index 0000000000000000000000000000000000000000..c10a920092cc33c40ef5ffd9e8f180b2f2e70716 --- /dev/null +++ b/plugins/form/views/default/form/default_form_data_display.php @@ -0,0 +1,19 @@ +<?php + +/** + * Default form data display + * + * @package form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2009 + * @link http://radagast.biz/ + */ + +$form_data_id = $vars['entity']->getGUID(); +$data = form_get_data($form_data_id); +$form = get_entity($vars['entity']->form_id); +$tab_data = form_get_tabbed_output_display($form,$data); +echo elgg_view('form/forms/display_form_content',array('tab_data'=>$tab_data,'description'=>'','preview'=>0,'form'=>$form,'form_data_id'=>0)); +echo $vars['annotations']; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/default_form_data_listing.php b/plugins/form/views/default/form/default_form_data_listing.php new file mode 100755 index 0000000000000000000000000000000000000000..29beeeb4498ec0f35b97f182fd8640c7ed174c9d --- /dev/null +++ b/plugins/form/views/default/form/default_form_data_listing.php @@ -0,0 +1,25 @@ +<?php + +/** + * Default form data listing + * + * @package form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2009 + * @link http://radagast.biz/ + */ + + $owner = $vars['entity']->getOwnerEntity(); + $friendlytime = friendly_time($vars['entity']->time_created); + $icon = elgg_view( + "profile/icon", array( + 'entity' => $owner, + 'size' => 'small', + ) + ); + $info = '<p><a href="'.$vars['entity']->getURL().'">'.elgg_echo('form:submission_to').'</a> "'.get_entity($vars['entity']->form_id)->title.'"</p>'; + $info .= "<p class=\"owner_timestamp\"><a href=\"{$owner->getURL()}\">{$owner->name}</a> {$friendlytime}</p>"; + echo elgg_view_listing($icon,$info.$vars['annotations']); + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/display_field.php b/plugins/form/views/default/form/display_field.php new file mode 100755 index 0000000000000000000000000000000000000000..8e3085ecc354907d253e44bb5d975e3ea246af63 --- /dev/null +++ b/plugins/form/views/default/form/display_field.php @@ -0,0 +1,26 @@ +<?php + +/** + * Elgg field display + * Displays the specified Elgg title, field and description + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + $field = $vars['field']; + $title = $vars['title']; + $description = $vars['description']; + + $body = <<<END +<label>$title<br /> +$field +</label> +<p class="form-field-description">$description</p> +END; + print $body; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/display_object.php b/plugins/form/views/default/form/display_object.php new file mode 100755 index 0000000000000000000000000000000000000000..518a0782adfdee62b9a0f674c17c83ca2d1a29f9 --- /dev/null +++ b/plugins/form/views/default/form/display_object.php @@ -0,0 +1,21 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +echo '<div class="contentWrapper">'; +echo form_view_entities(array($vars['form_data']), $vars['form'], 'display'); +echo '</div>'; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/display_search_object.php b/plugins/form/views/default/form/display_search_object.php new file mode 100755 index 0000000000000000000000000000000000000000..91e25850fefe7d33ee9d5ca7d1eeb1a9e38bfc41 --- /dev/null +++ b/plugins/form/views/default/form/display_search_object.php @@ -0,0 +1,40 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$form = get_entity($vars['form_id']); +$fd = get_entity($vars['form_data_id']); + +if (isset($_SESSION['last_search_qs'])) { + $qs = $_SERVER["QUERY_STRING"]; + // remove the form data id from the query string first + $qsi = strpos($qs,'&'); + $qs = substr($qs,$qsi+1); + + $return_to_search_results = '<p><a href="'.$CONFIG->wwwroot.'mod/form/search_results.php?'.$qs + .'">'.elgg_echo('form:return_to_search_results').'</a></p>'; +} else { + $return_to_search_results = ''; +} +echo '<div class="contentWrapper">'; +echo $return_to_search_results; + +echo form_view_entities(array($fd), $form, 'display'); + +echo $return_to_search_results; + +echo '</div>'; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/display_templates.php b/plugins/form/views/default/form/display_templates.php new file mode 100755 index 0000000000000000000000000000000000000000..fb6b52614f2357148de92e6e5bf01f34ee240207 --- /dev/null +++ b/plugins/form/views/default/form/display_templates.php @@ -0,0 +1,18 @@ +<?php +$form = $vars['form']; +$display_bit = '<div class="tabbertab" title="'.elgg_echo('form:display_templates_tab_label').'">'; + +$display_bit .= '<label for="list_template">'.elgg_echo('form:list_template_label'); +$display_bit .= elgg_view('input/longtext',array('internalname'=>'list_template','value'=>$form->list_template)); +$display_bit .= '</label>'; +$display_bit .= '<p class="description">'.elgg_echo('form:list_template_description').'</p>'; + +$display_bit .= '<label for="display_template">'.elgg_echo('form:display_template_label'); +$display_bit .= elgg_view('input/longtext',array('internalname'=>'display_template','value'=>$form->display_template)); +$display_bit .= '</label>'; +$display_bit .= '<p class="description">'.elgg_echo('form:display_template_description').'</p>'; +$display_bit .= '<input type="submit" name="submit" value="'.elgg_echo('form:form_manage_button').'">'; +$display_bit .= '</div>'; + +echo $display_bit; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/entity_list.php b/plugins/form/views/default/form/entity_list.php new file mode 100755 index 0000000000000000000000000000000000000000..69cef29aff832869a1eda2fb1ebbb2d205522904 --- /dev/null +++ b/plugins/form/views/default/form/entity_list.php @@ -0,0 +1,61 @@ +<?php + +// load form model +require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$context = $vars['context']; +$offset = $vars['offset']; +$entities = $vars['entities']; +$form = $vars['form']; +$limit = $vars['limit']; +$count = $vars['count']; +$baseurl = $vars['baseurl']; +$context = $vars['context']; +$viewtype = $vars['viewtype']; + +$html = ""; +$nav = ""; + +if (isset($vars['viewtypetoggle'])) { + $viewtypetoggle = $vars['viewtypetoggle']; +} else { + $viewtypetoggle = true; +} + +if ($context == "search" && $count > 0 && $viewtypetoggle) { + $nav .= elgg_view("navigation/viewtype",array( + + 'baseurl' => $baseurl, + 'offset' => $offset, + 'count' => $count, + 'viewtype' => $viewtype, + + )); +} + +$nav .= elgg_view('navigation/pagination',array( + + 'baseurl' => $baseurl, + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + +)); + +$html .= $nav; + +if ($fullview) { + $viewtype = 'display'; +} + +if (is_array($entities) && sizeof($entities) > 0) { + + $html .= form_view_entities($entities, $form, $viewtype); +} + +if ($count) +$html .= $nav; + +echo $html; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/extended_display_field.php b/plugins/form/views/default/form/extended_display_field.php new file mode 100755 index 0000000000000000000000000000000000000000..14b7a8b182292d83029b24194277b5bc3d69e192 --- /dev/null +++ b/plugins/form/views/default/form/extended_display_field.php @@ -0,0 +1,22 @@ +<?php + +/** + * Form extended field display + * + * @package form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + $value = $vars['value']; + $title = $vars['title']; + + $body = <<<END +<label>$title<br /> +<p>$value</p> +</label> +END; + print $body; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/field_list.php b/plugins/form/views/default/form/field_list.php new file mode 100755 index 0000000000000000000000000000000000000000..0198aa4f0d5502ac82724b94b3bfef44d2cc68d4 --- /dev/null +++ b/plugins/form/views/default/form/field_list.php @@ -0,0 +1,55 @@ +<?php +$form_id = $vars['form_id']; +$profile = $vars['profile']; + +$edit_msg = elgg_echo('form:edit'); +$remove_msg = elgg_echo('form:remove'); +$remove_confirm_msg = elgg_echo('form:remove_confirm'); +$moveup_msg = elgg_echo('form:move_up'); +$movedown_msg = elgg_echo('form:move_down'); +$movetop_msg = elgg_echo('form:move_top'); +$movebottom_msg = elgg_echo('form:move_bottom'); + +$img_template = '<img border="0" width="16" height="16" alt="%s" title="%s" src="'.$vars['config']->wwwroot.'mod/form/images/%s" />'; +$edit_img = sprintf($img_template,$edit_msg,$edit_msg,"16-em-pencil.png"); +$remove_img = sprintf($img_template,$remove_msg,$remove_msg,"16-em-cross.png"); +$moveup_img = sprintf($img_template,$moveup_msg,$moveup_msg,"16-em-open.png"); +$movedown_img = sprintf($img_template,$movedown_msg,$movedown_msg,"16-em-down.png"); +$movetop_img = sprintf($img_template,$movetop_msg,$movetop_msg,"16-em-left.png"); +$movebottom_img = sprintf($img_template,$movebottom_msg,$movebottom_msg,"16-em-right.png"); + +$start_url = $vars['config']->wwwroot.'action/form/manage_field?form_action=move&id=%s&form_id=%s&direction='; +$link_template = '<a onclick="javascript:$(\'#field_list\').load(\'%s%s\'); return false;" href="%s%s">%s</a>'; + +$field_template = <<<END +<a href="{$vars['config']->wwwroot}action/form/manage_field?form_action=edit&id=%s&form_id=%s&profile=$profile">$edit_img</a> | +<a onclick="return confirm('$remove_confirm_msg')" href="{$CONFIG->wwwroot}action/form/manage_field?form_action=remove&id=%s&form_id=%s">$remove_img</a> | +%s | +%s | +%s | +%s +%s +<br /> +END; + +$fields = $vars['fields']; + +if ($fields && count($fields) > 0 ) { + foreach ($fields AS $field) { + $ident = $field->getGUID(); + $url = sprintf($start_url,$ident,$form_id); + $up = sprintf($link_template,$url,'up',$url,'up',$moveup_img); + $down = sprintf($link_template,$url,'down',$url,'down',$movedown_img); + $top = sprintf($link_template,$url,'top',$url,'top',$movetop_img); + $bottom = sprintf($link_template,$url,'bottom',$url,'bottom',$movebottom_img); + $field_list .= sprintf( $field_template,$ident,$form_id,$ident,$form_id, + $up,$down,$top,$bottom, + $field->title . ' ('.$field->internal_name.': '.$field->field_type.')'); + } + $field_list .= '<br />'; +} else { + $field_list .= '<p>'.elgg_echo('form:none').'.</p>'; +} + +echo $field_list; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/form_data_admin.php b/plugins/form/views/default/form/form_data_admin.php new file mode 100755 index 0000000000000000000000000000000000000000..19a6e536bd33b6459350693186ce59ca61fab831 --- /dev/null +++ b/plugins/form/views/default/form/form_data_admin.php @@ -0,0 +1,13 @@ +<?php +$manage_bit = '<div class="form-manage">'; +$manage_bit .= '<a href="'.$vars['url'].'mod/form/form.php?id='.$vars['form_id'].'&d='.$vars['form_data_id'].'">'; +$manage_bit .= elgg_echo('form:edit'); +$manage_bit .= '</a> | '; +$manage_bit .= '<a onclick="return confirm(\''.elgg_echo('form:content_delete_confirm').'\')" '; +$manage_bit .= 'href="'.$vars['url'].'action/form/manage_form_data?form_action=delete&d='.$vars['form_data_id'].'">'; +$manage_bit .= elgg_echo('form:delete'); +$manage_bit .= '</a>'; +$manage_bit .= '</div><br />'; + +echo $manage_bit; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/display_form.php b/plugins/form/views/default/form/forms/display_form.php new file mode 100755 index 0000000000000000000000000000000000000000..c8eb0cccc450d812456a91728ccede3d8fc044a5 --- /dev/null +++ b/plugins/form/views/default/form/forms/display_form.php @@ -0,0 +1,69 @@ +<?php + +/** + * Elgg field display + * Displays the specified Elgg title, field and description + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + $tab_data = $vars['tab_data']; + $form = $vars['form']; + $preview = $vars['preview']; + $form_data_id = $vars['form_data_id']; + + if (isset($vars['description'])) { + $description = $vars['description']; + } else { + $description = form_form_t($form,'description'); + } + + if ($preview) { + $body = '<div class="contentWrapper">'.elgg_echo('form:preview_description').'</div>'; + } else { + $body = ''; + } + // TODO - add some intelligent way to determine the form enctype? + $body .= <<<END +<script type="text/javascript" src="{$vars['url']}mod/form/tabber/tabber.js"></script> +<link rel="stylesheet" href="{$vars['url']}mod/form/tabber/example.css" type="text/css" media="screen" /> +<div class="contentWrapper"> +$description +</div> +<div class="contentWrapper"> +<form action="{$vars['url']}action/form/submit" method="post" enctype="multipart/form-data"> +END; + $body .= elgg_view('input/hidden',array('internalname'=>'form_id', 'value'=>$form->getGUID())); + $body .= elgg_view('input/hidden',array('internalname'=>'preview', 'value'=>$preview)); + $body .= elgg_view('input/hidden',array('internalname'=>'form_data_id', 'value'=>$form_data_id)); + + $count = count($tab_data); + + if ($count > 1) { + $body .= '<div class="tabber">'; + $body .= '<div class="tabberloading" ></div>'; + foreach($tab_data as $tab => $html) { + if ($html) { + $body .= "<div class=\"tabbertab\" title=\"$tab\">"; + $body .= $html; + $body .= "</div>\n"; + } + + } + $body .= '</div>'; + } else if ($count == 1) { + // don't show tabs if there is only one + foreach($tab_data as $tab => $html) { + $body .= $html; + } + } + + $body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>elgg_echo('form:submit'))); + $body .= '</form></div>'; + print $body; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/display_form_content.php b/plugins/form/views/default/form/forms/display_form_content.php new file mode 100755 index 0000000000000000000000000000000000000000..1960df387b4a4a81c93fd87b4d81d9f5647b701d --- /dev/null +++ b/plugins/form/views/default/form/forms/display_form_content.php @@ -0,0 +1,57 @@ +<?php + +/** + * Elgg form display + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +$tab_data = $vars['tab_data']; +$form = $vars['form']; +$preview = $vars['preview']; +$form_data_id = $vars['form_data_id']; + +if (isset($vars['description'])) { + $description = $vars['description']; +} else { + $description = form_t($form,'description'); +} + +if ($preview) { + $body = '<p class="form-description">'.elgg_echo('form:preview_description').'</p>'; +} else { + $body = ''; +} + +$body .= elgg_view('input/hidden',array('internalname'=>'form_id', 'value'=>$form->getGUID())); +$body .= elgg_view('input/hidden',array('internalname'=>'preview', 'value'=>$preview)); +$body .= elgg_view('input/hidden',array('internalname'=>'form_data_id', 'value'=>$form_data_id)); +$body .= "<p class=\"form-description\">$description</p>"; + +if (count($tab_data) > 1) { + $body .= <<<END + <script type="text/javascript" src="{$CONFIG->wwwroot}mod/form/tabber/tabber.js"></script> + <link rel="stylesheet" href="{$CONFIG->wwwroot}mod/form/tabber/example.css" type="text/css" media="screen" /> +END; + $body .= '<div class="tabber">'; + $body .= '<div class="tabberloading" ></div>'; + foreach($tab_data as $tab => $html) { + if ($html) { + $body .= "<div class=\"tabbertab\" title=\"$tab\">"; + $body .= $html; + $body .= "</div>\n"; + } + } + $body .= '</div>'; +} else if (count($tab_data) == 1) { + foreach($tab_data as $tab => $html) { + $body .= $html; + } +} +echo $body; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/field_adders.php b/plugins/form/views/default/form/forms/field_adders.php new file mode 100755 index 0000000000000000000000000000000000000000..7774a73f72be0fa64f400c82109f8d8daceb8ba2 --- /dev/null +++ b/plugins/form/views/default/form/forms/field_adders.php @@ -0,0 +1,85 @@ +<?php +/* buttons and links: + * + * preview form (link) + * add existing field (input box for field name) + * copy existing field (copies field definition) (input boxes for field name) + * add new field (input box for field name) + */ + +$form_id = $vars['form_id']; +$profile = $vars['profile']; + +//TODO: clean this up + +$add_existing_button = elgg_echo('form:add_existing_button'); +$add_existing_field_description = elgg_echo('form:add_existing_field_description'); +$copy_existing_button = elgg_echo('form:copy_existing_button'); +$copy_existing_field_description = elgg_echo('form:copy_existing_field_description'); +$add_new_button = elgg_echo('form:add_new_button'); +$add_new_description = elgg_echo('form:add_new_description'); +$existing_label = elgg_echo('form:existing_label'); +$new_label = elgg_echo('form:new_label'); + +$add_fields_title = elgg_echo('form:add_fields_title'); +$add_existing_title = elgg_echo('form:add_existing_title'); +$copy_existing_title = elgg_echo('form:copy_existing_title'); +$add_new_title = elgg_echo('form:add_new_title'); + +$field_adders_tab = elgg_echo('form:field_adders_tab_label'); + +$buttons = <<<END +<div class="tabbertab" title="$field_adders_tab"> +<form action="{$vars['url']}action/form/manage_field" method="post"> +<input type="hidden" name="form_id" value="$form_id"> +<input type="hidden" name="form_action" value="add_new"> +<input type="hidden" name="profile" value="$profile"> +<label class="labelclass" for="new_field_name">$new_label</label> +END; + +$buttons .= elgg_view('input/text',array('internalname'=>'new_field_name')); + +$buttons .= <<<END +<br /> +<span class="description">$add_new_description<br /> +<input type="submit" name="submit" value="$add_new_button"></span> +</form> +<br /> +<form action="{$vars['url']}action/form/manage_field" method="post"> +<input type="hidden" name="form_id" value="$form_id"> +<input type="hidden" name="form_action" value="add_existing"> +<input type="hidden" name="profile" value="$profile"> +<label class="labelclass" for="existing_field_name">$existing_label</label> +END; + +$buttons .= elgg_view('input/text',array('internalname'=>'existing_field_name')); + +$buttons .= <<<END +<br /> +<span class="description">$add_existing_field_description<br /> +<input type="submit" name="submit" value="$add_existing_button"></span> +</form> +<form action="{$vars['url']}action/form/manage_field" method="post"> +<input type="hidden" name="form_id" value="$form_id"> +<input type="hidden" name="form_action" value="copy_existing"> +<input type="hidden" name="profile" value="$profile"> +<label class="labelclass" for="existing_field_name">$existing_label</label> +END; + +$buttons .= elgg_view('input/text',array('internalname'=>'existing_field_name')); + +$buttons .= <<<END +<label class="labelclass" for="new_field_name">$new_label</label> +END; + +$buttons .= elgg_view('input/text',array('internalname'=>'new_field_name')); + +$buttons .= <<<END +<p class="description">$copy_existing_field_description<br /> +<input type="submit" name="submit" value="$copy_existing_button"></p> +</form> +</div> +END; + +echo $buttons; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/list_fields.php b/plugins/form/views/default/form/forms/list_fields.php new file mode 100755 index 0000000000000000000000000000000000000000..10cb297c97a05070f55c43d145f3aaa8db54a8cf --- /dev/null +++ b/plugins/form/views/default/form/forms/list_fields.php @@ -0,0 +1,64 @@ +<?php + + /** + * Elgg list fields view + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form'] Optionally, the form to edit + */ + +$type = $vars['page_return_type']; +$fields = $vars['fields']; +$username = $vars['user']->username; + +$edit_msg = elgg_echo('form:edit');; +$delete_msg = elgg_echo('form:delete'); +$delete_orphans_confirm_msg = elgg_echo('form:orphan_delete_all_confirm'); +if ($type == 'orphan') { + $delete_confirm_msg = elgg_echo('form:orphan_delete_confirm'); +} else { + $delete_confirm_msg = elgg_echo('form:field_delete_confirm'); +} + +$img_template = '<img border="0" width="16" height="16" alt="%s" title="%s" src="'.$CONFIG->wwwroot.'mod/form/images/%s" />'; +$edit_img = sprintf($img_template,$edit_msg,$edit_msg,"16-em-pencil.png"); +$delete_img = sprintf($img_template,$delete_msg,$delete_msg,"16-em-cross.png"); + +$field_template = <<<END +<a href="{$CONFIG->wwwroot}action/form/manage_field?form_action=edit_with_field_id&id=%s&type=%s&username=$username">$edit_img</a> | +<a onclick="return confirm('$delete_confirm_msg')" href="{$CONFIG->wwwroot}action/form/manage_field?form_action=delete&id=%s&type=%s&username=$username">$delete_img</a> + %s +<br /> +END; + +$body .= '<div class="contentWrapper">'; +if ($type == 'orphan') { + $body .= '<p><b><a onclick="return confirm(\''.$delete_orphans_confirm_msg.'\')" href="'.$CONFIG->wwwroot.'action/form/manage_fields?form_action=delete_orphans&username='.$username.'">'.elgg_echo('form:delete_orphans').'</a></b></p> '."\n"; + $body .= '<p>'.elgg_echo('form:orphan_list_description').'</p>'."\n"; +} else { + $body .= '<p>'.elgg_echo('form:field_list_description').'</p>'."\n"; +} + +if ($fields) { + foreach ($fields as $field) { + $field_id = $field->getGUID(); + $body .= sprintf( + $field_template, + $field_id, + $type, + $field_id, + $type, + $field->title . ' ('.$field->internal_name.': '.$field->field_type.')'); + } +} else { + $body .= '<p>'.elgg_echo('form:no_fields').'</p>'; +} +$body .= '</div>'; +print $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/list_forms.php b/plugins/form/views/default/form/forms/list_forms.php new file mode 100755 index 0000000000000000000000000000000000000000..39a13da665fd2a9d4eb60ebabf2afebd24c15960 --- /dev/null +++ b/plugins/form/views/default/form/forms/list_forms.php @@ -0,0 +1,79 @@ +<?php +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Displays existing forms + * + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/models/model.php"); + +//$title = elgg_echo('form:list_forms_title'); + +$view_all_text = elgg_echo('form:view_all'); + +$form_template = <<<END +<div class="contentWrapper"> +<h2>%s</h2> +<p> +%s +</p> +%s +<a href="{$CONFIG->wwwroot}mod/form/my_forms.php?id=%s&form_view=all">$view_all_text</a> +%s +</div> +END; + +//$pg_owner_entity = page_owner_entity(); +//$username = $pg_owner_entity->username; + +$body = ''; + +$profile_form = form_get_latest_public_profile_form(); + +if ($profile_form) { + $sd_list = get_entities_from_metadata('form_id',$profile_form->getGUID(),'object','form:search_definition'); + if ($sd_list) { + $body .= '<div class="contentWrapper">'; + $body .= '<h2>'.elgg_echo('form:profiles').'</h2><br />'; + foreach($sd_list as $sd) { + $sd_id = $sd->getGUID(); + $body .= "<a href=\"{$vars['url']}mod/form/search.php?sid=$sd_id\">".form_search_definition_t($form,$sd,'title')."</a><br />"; + } + $body .= '</div>'; + } +} + +$forms = get_entities_from_metadata('profile','0','object','form:form'); +if ($forms) { + foreach ($forms as $form) { + $form_id = $form->getGUID(); + if (isloggedin()) { + $add_bit = '<a href="'.$vars['url'].'mod/form/form.php?id='.$form_id.'">'.elgg_echo('form:add_content').'</a> | '; + } else { + $add_bit = ''; + } + $sd_bit = ''; + $sd_list = get_entities_from_metadata('form_id',$form_id,'object','form:search_definition'); + if ($sd_list) { + foreach($sd_list as $sd) { + $sd_id = $sd->getGUID(); + $sd_bit .= "| <a href=\"{$vars['url']}mod/form/search.php?sid=$sd_id\">".form_search_definition_t($form,$sd,'title')."</a>"; + } + } + $body .= sprintf($form_template,form_form_t($form,'title'),form_form_t($form,'listing_description'),$add_bit,$form_id,$sd_bit); + } +} else { + if (!$profile_form) { + $body .= '<p>'.elgg_echo('form:no_content').'</p>'; + } +} + +print $body; + + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/list_search_definitions.php b/plugins/form/views/default/form/forms/list_search_definitions.php new file mode 100755 index 0000000000000000000000000000000000000000..5e79cf40c3c06cf5a4a31d522e5b463f75495883 --- /dev/null +++ b/plugins/form/views/default/form/forms/list_search_definitions.php @@ -0,0 +1,45 @@ +<?php +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Displays existing search definitions + * + */ + +$edit_msg = elgg_echo('form:edit'); +$delete_msg = elgg_echo('form:delete'); +$delete_confirm_msg = elgg_echo('form:search_definition_delete_confirm'); +$search_page = elgg_echo('form:search_page_link'); + +$img_template = '<img border="0" width="16" height="16" alt="%s" title="%s" src="'.$CONFIG->wwwroot.'mod/form/images/%s" />'; +$edit_img = sprintf($img_template,$edit_msg,$edit_msg,"16-em-pencil.png"); +$delete_img = sprintf($img_template,$delete_msg,$delete_msg,"16-em-cross.png"); + +$sd_template = <<<END +<a href="{$CONFIG->wwwroot}mod/form/manage_search_definition.php?sid=%s">$edit_img</a> | +<a onclick="return confirm('$delete_confirm_msg')" href="{$CONFIG->wwwroot}action/form/manage_search_definition?form_action=delete&sid=%s">$delete_img</a> | +<a href="{$CONFIG->wwwroot}mod/form/search.php?sid=%s">$search_page</a> %s (%s) +<br /> +END; + +$body = '<div class="contentWrapper">'; + +$form_id = get_input('form_id',0); +$sds = get_entities_from_metadata('form_id',$form_id,'object','form:search_definition'); +if ($sds) { + foreach ($sds as $sd) { + $ident = $sd->getGUID(); + $body .= sprintf($sd_template,$ident,$ident,$ident,$sd->title,$sd->internalname); + } +} else { + $body .= '<p>'.elgg_echo('form:no_search_definitions').'</p>'; +} + +$body .= '</div>'; + +print $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/manage_all_forms.php b/plugins/form/views/default/form/forms/manage_all_forms.php new file mode 100755 index 0000000000000000000000000000000000000000..6231a512ae19e34a66a9205977653854f4837f9b --- /dev/null +++ b/plugins/form/views/default/form/forms/manage_all_forms.php @@ -0,0 +1,67 @@ +<?php +/* + * Elgg Forms + * Kevin Jardine + * Radagast Solutions + * http://radagast.biz + * + * Displays existing forms + * + */ + +$title = elgg_echo('form:list_forms_title'); + +$edit_msg = elgg_echo('form:edit'); +$delete_msg = elgg_echo('form:delete'); +$delete_confirm_msg = elgg_echo('form:form_delete_confirm'); + +$img_template = '<img border="0" width="16" height="16" alt="%s" title="%s" src="'.$CONFIG->wwwroot.'mod/form/images/%s" />'; +$edit_img = sprintf($img_template,$edit_msg,$edit_msg,"16-em-pencil.png"); +$delete_img = sprintf($img_template,$delete_msg,$delete_msg,"16-em-cross.png"); +$export_text = elgg_echo('form:export'); +$preview_text = elgg_echo('form:preview'); +$link_text = elgg_echo('form:link'); + +$form_template = <<<END +<a href="{$CONFIG->wwwroot}mod/form/manage_form.php?id=%s">$edit_img</a> | +<a onclick="return confirm('$delete_confirm_msg')" href="{$CONFIG->wwwroot}action/form/manage_form?form_action=delete&id=%s">$delete_img</a> | +<a href="{$CONFIG->wwwroot}mod/form/form.php?id=%s&preview=true">$preview_text</a> | +<a href="{$CONFIG->wwwroot}mod/form/form.php?id=%s">$link_text</a> + %s +<br /> +END; + +$body = '<div class="contentWrapper">'; + +/*$user_content_status = form_get_user_content_status(); +$body .= '<h2>'.elgg_echo('form:user_content_status_title').'</h2><br />'; + +$options = array( 1=>elgg_echo('form:yes'), +0=>elgg_echo('form:no') ); + +$body .= '<form action="'.$CONFIG->wwwroot.'action/form/manage_form" method ="post" >'; +$body .= elgg_view('input/hidden',array('internalname'=>'form_action', 'value'=>'user_content_status')); + +$body .= elgg_view('form/input/radio',array('internalname'=>'user_content_status','options'=>$options,'value'=>$user_content_status)); + +$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>elgg_echo('form:submit'))); +$body .= '</form>';*/ + +$body .= '<h2>'.elgg_echo('form:form_list').'</h2><br />'; + +$forms = get_entities('object','form:form'); +if ($forms) { + foreach ($forms as $form) { + $ident = $form->getGUID(); + $body .= sprintf($form_template,$ident,$ident,$ident,$ident,$form->title.' ('.$form->name.')'); + } +} else { + $body .= '<p>'.elgg_echo('form:no_forms').'</p>'; +} + +$body .= '</div>'; + +echo $body; + + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/manage_field.php b/plugins/form/views/default/form/forms/manage_field.php new file mode 100755 index 0000000000000000000000000000000000000000..ed7522c82b6289dd2c50d7d908af11c52b7dc17e --- /dev/null +++ b/plugins/form/views/default/form/forms/manage_field.php @@ -0,0 +1,696 @@ +<?php + +/** + * Elgg manage field page + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['field'] The field to edit + * $vars['form_id'] The form to add a new field to + * $vars['new_field_name'] Optionally, an internal name for this field + */ + +$form_field_types = form_get_form_field_types(); + +$i = 0; + +foreach ($form_field_types as $type => $ft) { + if ($type == 'contact') { + $contact_index = $i; + } else if ($type == 'choices') { + $choices_index = $i; + } + $i += 1; +} + +$form_id = $vars['form_id']; +$field = $vars['field']; +$choices = $vars['choices']; +$page_return_type = $vars['page_return_type']; +$new_field_name = $vars['new_field_name']; +$username = $vars['username']; + +$profile_label = elgg_echo('form:profile_label'); +$profile_description = elgg_echo('form:profile_description'); +$yes = elgg_echo('form:yes'); +$no = elgg_echo('form:no'); + +$profile_bit = <<<END +<label class="labelclass" for="profile">$profile_label</label> +<input type="radio" name="profile" value="0" onChange="vis();" %s> $no +<input type="radio" name="profile" value="1" onChange="vis();" %s> $yes +<p class="description">$profile_description</p> +END; + +if (!isset($vars['profile'])) { + if ($form_id) { + $profile = get_entity($form_id)->profile; + } else { + $profile = 0; + } +} else { + $profile = $vars['profile']; +} + +if (!$profile) { + $profile = 0; +} + +// set up the field values + +if ($field) { + if ($new_field_name) { + // this is duplicating an existing field + $form_action = 'add'; + $field_id = 0; + $internal_name = $new_field_name; + } else { + $form_action = 'change'; + $field_id = $field->getGUID(); + $internal_name = $field->internal_name; + } + + $form_title = $field->title; + $description = $field->description; + $field_type = $field->field_type; + + // must do this because Elgg has trouble with metadata set to "0" + // in Elgg 1.5 + $m = get_metadata_byname($field->getGUID(),'default_access'); + if ($m) { + $default_access = $m->value; + if ($default_access !== '') { + $field_access = (int) $default_access; + } else { + $field_access = ''; + } + } else { + $field_access = ''; + } + $default_value = $field->default_value; + $is_keyword_tag = $field->is_keyword_tag; + if (in_array($field_type,array('url','email','aim','msn','skype','icq'))) { + $contact_type = $field_type; + $field_type = 'contact'; + $contact_class = 'visible'; + } else { + $contact_class = 'invisible'; + $contact_type = ''; + } + + if (isset($choices)) { + $number_of_options = count($choices); + } else { + $number_of_options = 0; + } + + if ($field_type == 'choices') { + $choices_class = 'visible'; + if (($profile == 1) | ($profile == 2)) { + $is_keyword_tag_class = 'visible'; + } else { + $is_keyword_tag_class = 'invisible'; + } + + } else { + $choices_class = 'invisible'; + $is_keyword_tag_class = 'invisible'; + } + + $required_no_checked = ''; + $required_yes_checked = ''; + if ($field->required) { + $required_yes_checked = 'checked'; + } else { + $required_no_checked = 'checked'; + } + + $admin_only_no_checked = ''; + $admin_only_yes_checked = ''; + if ($field->admin_only) { + $admin_only_yes_checked = 'checked'; + } else { + $admin_only_no_checked = 'checked'; + } + + $profile_no_checked = ''; + $profile_yes_checked = ''; + + if (($profile == 1) || ($profile==2)) { + $profile_yes_checked = 'checked'; + $profile_class = 'visible'; + } else { + $profile_no_checked = 'checked'; + $profile_class = 'invisible'; + } + + // remove this for now + + /*if ($profile_bit) { + $profile_bit = sprintf($profile_bit, $profile_no_checked, $profile_yes_checked); + }*/ + $profile_bit = ''; + + $category = $field->tab; + $subtype_filter = $field->subtype_filter; + + $invisible_no_checked = ''; + $invisible_yes_checked = ''; + if ($field->invisible) { + $invisible_yes_checked = 'checked'; + } else { + $invisible_no_checked = 'checked'; + } + + $is_keyword_tag_no_checked = ''; + $is_keyword_tag_yes_checked = ''; + if ($is_keyword_tag) { + $is_keyword_tag_yes_checked = 'checked'; + } else { + $is_keyword_tag_no_checked = 'checked'; + } + + // make this always invisible as it is not currently used + $is_keyword_tag_class = 'invisible'; + + $area_left_checked = ''; + $area_right_checked = ''; + $area_bottom_checked = ''; + $area_no_checked = ''; + if ($field->area == 'left') { + $area_left_checked = 'checked'; + } else if ($field->area == 'right') { + $area_right_checked = 'checked'; + } else if ($field->area == 'bottom') { + $area_bottom_checked = 'checked'; + } else { + $area_no_checked = 'checked'; + } + + $choice_type_select_checked = ''; + $choice_type_radio_checked = ''; + $choice_type_checkbox_checked = ''; + if ($field->choice_type == 'pulldown') { + $choice_type_select_checked = 'checked'; + $orientation_class = 'invisible'; + } else if ($field->choice_type == 'radio') { + $choice_type_radio_checked = 'checked'; + $orientation_class = 'visible'; + } else { + $choice_type_checkbox_checked = 'checked'; + $orientation_class = 'visible'; + } + + $orientation_horizontal_checked = ''; + $orientation_vertical_checked = ''; + if ($field->orientation == 'horizontal') { + $orientation_horizontal_checked = 'checked'; + } else { + $orientation_vertical_checked = 'checked'; + } + +} else { + $form_action = 'add'; + + $number_of_options = 0; + //$profile = $vars['profile']; + + $orientation_class = 'invisible'; + $profile_class = 'invisible'; + $choices_class = 'invisible'; + $contact_class = 'invisible'; + $is_keyword_tag_class = 'invisible'; + + $field_id = 0; + + $internal_name = $new_field_name; + $form_title = ''; + $description = ''; + $field_type = 'profile_shorttext'; + $field_access = ''; + $contact_type = 'web'; + + $default_value = ''; + $is_keyword_tag_no_checked = 'checked'; + $is_keyword_tag_yes_checked = ''; + // make this always invisible as it is not currently used + $is_keyword_tag_class = 'invisible'; + + $required_no_checked = 'checked'; + $required_yes_checked = ''; + + $admin_only_no_checked = 'checked'; + $admin_only_yes_checked = ''; + + $profile_no_checked = ''; + $profile_yes_checked = ''; + if (($profile == 1) || ($profile == 2)) { + $profile_yes_checked = 'checked'; + $profile_class = 'visible'; + $profile_bit = '<input type="hidden" name="profile" value="'.$profile.'1">'; + } else { + $profile_no_checked = 'checked'; + $profile_class = 'invisible'; + // for now lock this in + // will have a toggle when I introduce mixed forms + //$profile_bit = sprintf($profile_bit, $profile_no_checked, $profile_yes_checked); + $profile_bit = '<input type="hidden" name="profile" value="'.$profile.'">'; + } + + $category = ''; + $subtype_filter = ''; + + $invisible_no_checked = 'checked'; + $invisible_yes_checked = ''; + + $registration_no_checked = 'checked'; + $registration_yes_checked = ''; + + $area_right_checked = 'checked'; + $area_left_checked = ''; + $area_bottom_checked = ''; + $area_no_checked = ''; + + $choice_type_select_checked = 'checked'; + $choice_type_radio_checked = ''; + $choice_type_checkbox_checked = ''; + + $orientation_horizontal_checked = 'checked'; + $orientation_vertical_checked = ''; +} + +// define the Javascript and CSS + +$body = <<<END +<script> +number_of_options = $number_of_options; + +function vis() { + var x,v; + // show profile config if relevant + v = document.field_form.profile; + x = document.getElementById('profile_config'); + /*if (v && v[1] && v[1].checked) { + x.className = 'visible'; + } else { + x.className = 'invisible'; + }*/ + + // hack to make this always visible for now + profile = $profile; + if ((profile == 1) || (profile == 2)) { + x.className = 'visible'; + } else { + x.className = 'invisible'; + } + + // show choice config if relevant + //u = document.field_form.profile; + v = document.field_form.field_type; + x = document.getElementById('choices_config'); + y = document.getElementById('contact_config'); + z = document.getElementById('is_keyword_tag_config'); + z.className = 'invisible'; + if (v.options[$choices_index].selected) { + x.className = 'visible'; + y.className = 'invisible'; + //if (u[1].checked) { + // z.className = 'visible'; + //} + } else if (v.options[$contact_index].selected) { + x.className = 'invisible'; + y.className = 'visible'; + } else { + x.className = 'invisible'; + y.className = 'invisible'; + } + + // show orientation config if relevant + v = document.field_form.choice_type; + x = document.getElementById('orientation_config'); + if (v[1].checked || v[2].checked) { + x.className = 'visible'; + } else { + x.className = 'invisible'; + } +} + +function add_option() { + var o,el; + o = document.getElementById('option_container'); + el = document.createElement('input'); + el.type = 'text'; + el.className = "option_value_input"; + el.name = "option_"+number_of_options+"_value"; + el.value = ""; + o.appendChild(el); + el = document.createElement('input'); + el.type = 'text'; + el.className = "option_label_input"; + el.name = "option_"+number_of_options+"_label"; + el.value = ""; + o.appendChild(el); + el = document.createElement('br'); + o.appendChild(el); + number_of_options++; + document.field_form.number_of_options.value = number_of_options; + + x = document.getElementById('option_outer_container'); + x.className = 'visible'; +} +</script> +<style> +div.invisible { + display: none; +} +div.visibleright { + float:right; + width: 100px; +} + +label.labelclass { + display:block; + font-weight:bold; +} + +p.description { + font-size: 0.9em; + margin-top: 0px; +} + +span.option_value_header { + font-weight: bold; + width: 150px; + display: block; + float: left; +} + +span.option_label_header { + font-weight: bold; + width: 300px; + margin-left: 10px; +} + +input.option_value_input { + width:150px; +} + +input.option_label_input { + margin-left:10px; + width:300px; +} + +input.standard { + width: 100%; +} + +input.longer { + width:100%; +} +</style> +END; + +print $body; + +// define a whole lot of text + +$horizontal = elgg_echo('form:horizontal'); +$vertical = elgg_echo('form:vertical'); + +if ($form_action == 'add') { + $title = elgg_echo('form:add_field_title'); + $form_description = elgg_echo('form:add_field_description'); +} else { + $title = elgg_echo('form:manage_field_title'); + $form_description = elgg_echo('form:manage_field_description'); +} + +$internal_name_label = elgg_echo('form:internal_name_label'); +$internal_name_description = elgg_echo('form:internal_name_description'); + +$title_label = elgg_echo('form:title_label'); +$title_description = elgg_echo('form:title_description'); + +$description_label = elgg_echo('form:description_label'); +$description_description = elgg_echo('form:description_description'); + +$required_label = elgg_echo('form:required_label'); +$required_description = elgg_echo('form:required_description'); + +$admin_only_label = elgg_echo('form:admin_only_label'); +$admin_only_description = elgg_echo('form:admin_only_description'); + +$field_type_label = elgg_echo('form:field_type_label'); + +$profile_config_title = elgg_echo('form:profile_config_title'); + +$category_label = elgg_echo('form:category_label'); +$category_description = elgg_echo('form:category_description'); + +$subtype_label = elgg_echo('form:subtype_label'); +$subtype_description = elgg_echo('form:subtype_description'); + +$invisible_label = elgg_echo('form:invisible_label'); + +$invisible_description = elgg_echo('form:invisible_description'); + +$registration_label = elgg_echo('form:registration_label'); + +$registration_description = elgg_echo('form:registration_description'); + +$column_label = elgg_echo('form:column_label'); + +$column_description = elgg_echo('form:column_description'); + +$choice_header = elgg_echo('form:choice_header'); + +$choice_field_type_label = elgg_echo('form:choice_field_type_label'); +$choice_field_type_description = elgg_echo('form:choice_field_type_description'); + +$dropdown = elgg_echo('form:dropdown'); +$radio = elgg_echo('form:radio'); +$checkbox = elgg_echo('form:checkbox'); + +$default_value_label = elgg_echo('form:default_value_label'); +$default_value_description = elgg_echo('form:default_value_description'); + +$is_keyword_tag_label = elgg_echo('form:is_keyword_tag_label'); +$is_keyword_tag_description = elgg_echo('form:is_keyword_tag_description'); + +$orientation_label = elgg_echo('form:orientation_label'); +$orientation_description = elgg_echo('form:orientation_description'); + +$access_label = elgg_echo('form:access_label'); +$access_description = elgg_echo('form:access_description'); + +$options_header = elgg_echo('form:options_header'); +$options_value_header = elgg_echo('form:options_value_header'); +$options_label_header = elgg_echo('form:options_label_header'); +$options_description = elgg_echo('form:options_description'); +$options_add_button = elgg_echo('form:options_add_button'); + +$profile_left = elgg_echo('form:profile_left'); +$profile_right = elgg_echo('form:profile_right'); +$profile_bottom = elgg_echo('form:profile_bottom'); + +// set up some form components + +if ($form_action == "add") { + $manage_field_button = elgg_echo('form:add_field_button'); +} else { + $manage_field_button = elgg_echo('form:change_field_button'); +} + +$this_form_link_text = elgg_echo('form:this_form_link_text'); +$form_link_text = elgg_echo('form:form_link_text'); +$field_link_text = elgg_echo('form:field_link_text'); + +// TODO: the following code shows the admin's access list. +// Try to find something more generic. + +$access_options = get_write_access_array(); +$access_options[''] = elgg_echo('form:use_system_default_access'); + +/*$access_options = array( + '' => elgg_echo('form:use_system_default_access'), + 'PRIVATE' => elgg_echo('ACCESS_PRIVATE'), + 'PUBLIC' => elgg_echo('ACCESS_PUBLIC'), + 'LOGGED_IN' => elgg_echo('ACCESS_LOGGED_IN'), +);*/ + +$access = '<select name="default_access">'."\n"; +foreach ($access_options AS $value => $label) { + if ($value === $field_access) { + $selected = 'selected'; + } else { + $selected = ''; + } + $access .= sprintf('<option value="%s" %s>%s</option>'."\n", $value, $selected, $label); +} + +$access .= '</select>'."\n"; + +$field_type_select = '<select name="field_type" onChange="vis();">'."\n"; + +foreach ($form_field_types AS $value => $ft) { + if ($value == $field_type) { + $selected = 'selected'; + } else { + $selected = ''; + } + $field_type_select .= sprintf('<option value="%s" %s>%s</option>'."\n", $value, $selected, $ft->label); +} + +$field_type_select .= '</select>'."\n"; + +$contact_options = array( + 'url' => elgg_echo("form:url"), + 'email' => elgg_echo("form:email"), + 'aim' => elgg_echo("form:aim"), + 'msn' => elgg_echo("form:msn"), + 'skype' => elgg_echo("form:skype"), + 'icq' => elgg_echo("form:icq"), +); + +$contact_radio = ''; + +foreach ($contact_options AS $value => $label) { + if ($value == $contact_type) { + $checked = 'checked'; + } else { + $checked = ''; + } + $contact_radio .= sprintf('<input type="radio" name="contact_type" value="%s" %s /> %s'."\n", $value, $checked, $label); +} + +$option_template = '<input class="option_value_input" type="text" name="option_%s_value" value="%s">'; +$option_template .= '<input class="option_label_input" type="text" name="option_%s_label" value="%s">'; +$option_template .= "<br />\n"; + +$options_bit = ''; + +if ($number_of_options > 0) { + $count = 0; + foreach($choices AS $option) { + $options_bit .= sprintf($option_template,$count,$option->value,$count,$option->label); + $count ++; + } +} + +if (!$profile) { + // currently only content forms support required fields + $required_bit = <<<END + <label class="labelclass" for="required">$required_label</label> +<input type="radio" name="required" value="0" $required_no_checked> $no +<input type="radio" name="required" value="1" $required_yes_checked> $yes +<p class="description">$required_description</p> +END; +} else { + $required_bit = ''; +} + +// define the form + +$body = <<< END +<div class="contentWrapper"> +<p>$form_description</p> +<form name="field_form" action="{$CONFIG->wwwroot}action/form/manage_field" method="post"> +<input type="hidden" name="form_action" value="$form_action"> +<input type="hidden" name="form_id" value="$form_id"> +<input type="hidden" name="field_id" value="$field_id"> +<input type="hidden" name="number_of_options" value="$number_of_options"> +<input type="hidden" name="type" value="$page_return_type"> +<input type="hidden" name="username" value="$username"> + +<label class="labelclass" for="internal_name">$internal_name_label</label> +<input type="text" class="standard" name="internal_name" value="$internal_name"> +<p class="description">$internal_name_description</p> +<label class="labelclass" for="title">$title_label</label> +<input type="text" class="standard" name="title" value="$form_title"> +<p class="description">$title_description</p> +<label class="labelclass" for="description">$description_label</label> +<input type="text" class="longer" name="description" value="$description"> +<p class="description">$description_description</p> +<label class="labelclass" for="default_value">$default_value_label</label> +<input type="text" class="standard" name="default_value" value="$default_value"> +<p class="description">$default_value_description</p> +$required_bit +<label class="labelclass" for="admin_only">$admin_only_label</label> +<input type="radio" name="admin_only" value="0" $admin_only_no_checked> $no +<input type="radio" name="admin_only" value="1" $admin_only_yes_checked> $yes +<p class="description">$admin_only_description</p> +<label class="labelclass" for="category">$category_label</label> +<input type="text" class="standard" name="category" value="$category"> +<p class="description">$category_description</p> +$profile_bit +<label class="labelclass" for="field_type">$field_type_label</label> +$field_type_select +<div id="contact_config" class="$contact_class"> + $contact_radio +</div> +<div id="choices_config" class="$choices_class"> + <br /> + <h1>$choice_header</h1> + <label class="labelclass" for="choice_type">$choice_field_type_label</label> + <input type="radio" name="choice_type" onChange="javascript:vis();" value="pulldown" $choice_type_select_checked> $dropdown + <input type="radio" name="choice_type" onChange="javascript:vis();" value="radio" $choice_type_radio_checked> $radio + <input type="radio" name="choice_type" onChange="javascript:vis();" value="checkboxes" $choice_type_checkbox_checked> $checkbox + <p class="description">$choice_field_type_description</p> + <div id="is_keyword_tag_config" class="$is_keyword_tag_class"> + <label class="labelclass" for="is_keyword_tag">$is_keyword_tag_label</label> + <input type="radio" name="is_keyword_tag" value="0" $is_keyword_tag_no_checked> $no + <input type="radio" name="is_keyword_tag" value="1" $is_keyword_tag_yes_checked> $yes + <p class="description">$is_keyword_tag_description</p> + </div> + <div id="orientation_config" class="$orientation_class"> + <label class="labelclass" for="orientation">$orientation_label</label> + <input type="radio" name="orientation" value="horizontal" $orientation_horizontal_checked> $horizontal + <input type="radio" name="orientation" value="vertical" $orientation_vertical_checked> $vertical + <p class="description">$orientation_description</p> + </div> + <div id="option_outer_container" class="$choices_class"> + <div id="option_container"> + <h1>$options_header</h1> + <span class="option_value_header">$options_value_header</span> + <span class="option_label_header">$options_label_header</span> + <br /> + $options_bit + <br /> + </div> + <p class="description">$options_description</p> + </div> + + <br /> + <input type="button" name="option_button" value="$options_add_button" onClick="add_option();"> +</div> +<div id="profile_config" class="$profile_class"> + <br /> + <h1>$profile_config_title</h1> + <br /> + <label class="labelclass" for="invisible">$invisible_label</label> + <input type="radio" name="invisible" value="0" $invisible_no_checked> $no + <input type="radio" name="invisible" value="1" $invisible_yes_checked> $yes + <p class="description">$invisible_description</p> + <label class="labelclass" for="area">$column_label</label> + <input type="radio" name="area" value="left" $area_left_checked> $profile_left + <input type="radio" name="area" value="right" $area_right_checked> $profile_right + <input type="radio" name="area" value="bottom" $area_bottom_checked> $profile_bottom + <input type="radio" name="area" value="" $area_no_checked> $no + <p class="description">$column_description</p> + <label class="labelclass" for="default_access">$access_label</label> + $access + <p class="description">$access_description</p> +</div> +<br /> +<input type="submit" value="$manage_field_button" /> +</form> +</div> +END; + +echo $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/manage_form.php b/plugins/form/views/default/form/forms/manage_form.php new file mode 100755 index 0000000000000000000000000000000000000000..f30c46db47df4fb3647f2d89be3af411f05d1527 --- /dev/null +++ b/plugins/form/views/default/form/forms/manage_form.php @@ -0,0 +1,147 @@ +<?php + + /** + * Elgg manage form view + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form'] Optionally, the form to edit + */ + +$form = $vars['form']; +$username = $vars['form_username']; + +$profile = $vars['profile']; + +if ($form) { + if ($form->profile) { + $profile = $form->profile; + } else { + $profile = 0; + } +} + +$type_options = form_type_options(); + +if ($form) { + $form_action = 'change'; + $explanation = elgg_echo('form:form_manage_description'); + $form_manage_button = elgg_echo('form:form_manage_button'); + $form_id = $form->getGUID(); + $form_name = $form->name; + $form_title = $form->title; + $description = $form->description; + $access_id = $form->access_id; + $field_list = elgg_view('form/field_list',array('fields' => $vars['fields'],'form_id' => $form_id, 'profile' => $profile)); + + if (($profile == 0) || ($profile == 3)) { + // this bit is just for data or file forms + $display_bit = elgg_view('form/display_templates',array('form'=>$form)); + } else { + $display_bit = ''; + } + + $buttons = elgg_view('form/forms/field_adders',array('form_id'=>$form_id,'profile'=>$profile)); + $basic_tab = elgg_echo('form:basic_tab_label'); + $tab_bit= <<<END +<script type="text/javascript" src="{$vars['url']}mod/form/tabber/tabber.js"></script> +<link rel="stylesheet" href="{$vars['url']}mod/form/tabber/example.css" type="text/css" media="screen" /> +<div class="tabber"> +<div class="tabberloading" ></div> +<div class="tabbertab" title="$basic_tab"> +END; +} else { + $form_action = 'add'; + $manage_form_title = ''; + $explanation = elgg_echo('form:create_form_description'); + $form_manage_button = elgg_echo('form:create_form_button'); + $form_id = 0; + $form_name = ''; + $form_title = ''; + $description = ''; + $access_id = ACCESS_PRIVATE; + $display_bit = ''; + $field_list = ''; + $buttons = ''; + $tab_bit = ''; +} + +// top of form + +$body = <<<END +<div class="contentWrapper"> +<p>$explanation</p> +$tab_bit +<form action="{$vars['config']->wwwroot}action/form/manage_form" method="post"> +<h1>$manage_form_title</h1> +<input type="hidden" name="form_id" value="$form_id"> +<input type="hidden" name="form_action" value="$form_action"> +<input type="hidden" name="username" value="$username"> +END; + +// form name +$body .= '<label class="labelclass" for="form_name">'.elgg_echo('form:name_label').'</label>'; +$body .= elgg_view('input/text',array('internalname'=>'form_name','value'=>$form_name)); +$body .= '<p class="description">'.elgg_echo('form:name_description').'</p>'; + +// form title +$body .= '<label class="labelclass" for="form_title">'.elgg_echo('form:title_label').'</label>'; +$body .= elgg_view('input/text',array('internalname'=>'form_title','value'=>$form_title)); +$body .= '<p class="description">'.elgg_echo('form:form_title_description').'</p>'; + +// form content creation description +$body .= '<label class="labelclass" for="description">'.elgg_echo('form:description_label').'</label>'; +$body .= elgg_view('input/longtext',array('internalname'=>'description','value'=>$description)); +$body .= '<p class="description">'.elgg_echo('form:form_description_description').'</p>'; + +// form type +$body .= '<label class="labelclass" for="form_type">'.elgg_echo('form:type_label').'</label>'; +$body .= elgg_view('input/pulldown',array('internalname'=>'profile','options_values'=>$type_options,'value'=>$profile)); +$body .= '<p class="description">'.elgg_echo('form:type_description').'</p>'; + +// access levels + +$body .= '<label class="labelclass" for="access">'.elgg_echo('form:form_access_label').'</label>'; +$body .= elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); +$body .= '<p class="description">'.elgg_echo('form:form_access_description').'</p>'; + + +if ($form) { + $body .= '<input type="submit" name="submit" value="'.$form_manage_button.'">'; + $body .= '</div>'; +} +if ($profile != 3) { + // file forms don't use this + $body .= elgg_view('form/manage_form_last_bit',array('form'=>$form)); +} +$body .= $display_bit; + +if ($form) { + $body .= '</form>'; + $body .= $buttons; + $body .= '<div class="tabbertab" title="'.elgg_echo('form:field_list_tab_label').'">'; + $body .= '<h2>'.elgg_echo('form:current_fields').'</h2><br />'; + $body .= '<div id="field_list">'; + $body .= $field_list; + $body .= '</div>'; + $body .= '</div>'; +} else { + $body .= '<input type="submit" name="submit" value="'.$form_manage_button.'">'; + $body .= '</form>'; +} +// bottom of form +$body .= <<<END +</div> +END; + +if ($form) { + $body .= '</div>'; +} + +print $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/manage_form_translation.php b/plugins/form/views/default/form/forms/manage_form_translation.php new file mode 100755 index 0000000000000000000000000000000000000000..9655668e786b6468328a132f9efd142fd1fb826d --- /dev/null +++ b/plugins/form/views/default/form/forms/manage_form_translation.php @@ -0,0 +1,111 @@ +<?php + + /** + * Elgg manage form view + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form'] Optionally, the form to edit + */ + +$form = $vars['form']; +$form_id = $form->getGUID(); + +if ($form->translate) { + $translate = 1; +} else { + $translate = 0; +} + +echo '<div class="contentWrapper">'; + +echo '<p class="form-description">'.elgg_echo('form:translate_description').'</p>'; + +echo '</div>'; + +echo '<div class="contentWrapper">'; + +echo '<h2>'.elgg_echo('form:translation_status_title').'</h2><br />'; + +$options = array( 0=>elgg_echo('form:text_from_database'), + 1=>elgg_echo('form:use_translation_system') ); + +$body = '<form action="'.$CONFIG->wwwroot.'action/form/manage_form" method ="post" >'; +$body .= elgg_view('input/hidden',array('internalname'=>'id', 'value'=>$form->getGUID())); +$body .= elgg_view('input/hidden',array('internalname'=>'form_action', 'value'=>'translate_status')); + +$body .= elgg_view('form/input/radio',array('internalname'=>'translate','options'=>$options,'value'=>$translate)); + +$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>elgg_echo('form:submit'))); +$body .= '</form>'; + +$body .= '</div>'; + +echo $body; + +echo '<div class="contentWrapper">'; + +echo '<h2>'.elgg_echo('form:translation_content_title').'</h2><br />'; + +echo '<p class="form-description">'.elgg_echo('form:translate_content_description').'</p>'; + +echo '<textarea style="width:100%; height:250px;">'; + +if ($form) { + echo '\'form:formtrans:'.$form->name.':title\' => "'.htmlspecialchars($form->title).'",'."\n"; + if ($form->description) + echo '\'form:formtrans:'.$form->name.':description\' => "'.htmlspecialchars($form->description).'",'."\n"; + if ($form->listing_description) + echo '\'form:formtrans:'.$form->name.':listing_description\' => "'.htmlspecialchars($form->listing_description).'",'."\n"; + if ($form->response_text) + echo '\'form:formtrans:'.$form->name.':response_text\' => "'.htmlspecialchars($form->response_text).'",'."\n"; + $tabs = array(); + $fields = $vars['fields']; + if ($fields && count($fields) > 0 ) { + foreach ($fields AS $field) { + $field_id = $field->getGUID(); + echo '\'form:fieldtrans:'.$field->internal_name.':title\' => "'.htmlspecialchars($field->title).'",'."\n"; + if ($field->description) + echo '\'form:fieldtrans:'.$field->internal_name.':description\' => "'.htmlspecialchars($field->description).'",'."\n"; + if ($field->field_type == 'choices') { + $choices = form_get_field_choices($field_id); + if ($choices) { + foreach($choices as $choice) { + echo '\'form:fieldchoicetrans:'.$field->internal_name.':'.$choice->value.'\' => "'.htmlspecialchars($choice->label).'",'."\n"; + } + } + } + + if ($field->tab && !in_array($field->tab,$tabs)) { + $tabs[] = $field->tab; + } + + } + } + $sd_list = get_entities_from_metadata('form_id',$form_id,'object','form:search_definition'); + if ($sd_list) { + foreach($sd_list as $sd) { + echo '\'form:sdtrans:'.$form->name.':'.$sd->internalname.':title\' => "'.htmlspecialchars($sd->title).'",'."\n"; + echo '\'form:sdtrans:'.$form->name.':'.$sd->internalname.':description\' => "'.htmlspecialchars($sd->description).'",'."\n"; + } + } +} + +echo '</textarea>'; + +if (count($tabs) > 0) { + echo '<br /><br /><p class="form-description">'.elgg_echo('form:tabs_translate_description').'</p>'; + echo '<textarea style="width:100%; height:100px;">'; + foreach ($tabs as $tab) { + echo '\'form:tabtrans:'.$tab.'\' => "'.$tab.'",'."\n"; + } + echo '</textarea>'; +} + +echo '</div>'; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/manage_group_profile_categories.php b/plugins/form/views/default/form/forms/manage_group_profile_categories.php new file mode 100755 index 0000000000000000000000000000000000000000..6b7ac6db1b316f579f0a21de3f48095a3db57485 --- /dev/null +++ b/plugins/form/views/default/form/forms/manage_group_profile_categories.php @@ -0,0 +1,32 @@ +<?php + +/** + * Manage group categories + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + +$group_profile_categories = $vars['group_profile_categories']; + +$body .= '<div class="contentWrapper">'; + +$body .= '<p class="form-description">'.elgg_echo('form:manage_group_profile_categories_description').'</p>'; + +$body .= '<form action="'.$CONFIG->wwwroot.'action/form/manage_form" method ="post" >'; +$body .= elgg_view('input/hidden',array('internalname'=>'form_action', 'value'=>'manage_group_profile_categories')); + +$body .= elgg_view('input/longtext',array('internalname'=>'group_profile_categories','value'=>$group_profile_categories)); + +$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>elgg_echo('form:submit'))); +$body .= '</form>'; + +$body .= '</div>'; + +echo $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/manage_search_definition.php b/plugins/form/views/default/form/forms/manage_search_definition.php new file mode 100755 index 0000000000000000000000000000000000000000..e7fd6226290cd7d879329a3d19b3f0b6c9943a21 --- /dev/null +++ b/plugins/form/views/default/form/forms/manage_search_definition.php @@ -0,0 +1,93 @@ +<?php + + /** + * Elgg add search definition + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form_id'] Optionally, the form to add a search definition for + */ + +$form = $vars['form']; +$form_id = $form->getGUID(); +if (isset($vars['search_definition_id']) && $vars['search_definition_id']) { + $form_action = 'change'; + $search_definition_id = $vars['search_definition_id']; + $sd = get_entity($search_definition_id); + $internalname = $sd->internalname; + $search_title = $sd->title; + $search_description = $sd->description; + $search_fields = $sd->search_fields; + $search_order = $sd->search_order; + //$expiryfield = $sd->expiryfield; + $menu = $sd->menu; + $button = elgg_echo('form:form_manage_button'); +} else { + $form_action = 'add'; + $search_definition_id = 0; + $internalname = ''; + $search_title = ''; + $search_description = ''; + $search_fields = ''; + $search_order = ''; + //$expiryfield = ''; + $menu = ''; + $button = elgg_echo('form:create_form_button'); +} + +$body = '<div class="contentWrapper">'; + +$body .= '<form action="'.$vars['url'].'action/form/manage_search_definition" method="post">'; + +$body .= elgg_view('input/hidden',array('internalname'=>'form_id', 'value'=>$form_id)); +$body .= elgg_view('input/hidden',array('internalname'=>'form_action', 'value'=>$form_action)); +$body .= elgg_view('input/hidden',array('internalname'=>'sid', 'value'=>$search_definition_id)); + +$body .= '<label for="internalname">'.elgg_echo('form:internalname_label'); +$body .= elgg_view('input/text',array('internalname'=>'internalname','value'=>$internalname)); +$body .= '</label>'; +$body .= '<p class="description">'.elgg_echo('form:search_definition_internalname_description').'</p>'; + +$body .= '<label for="search_title">'.elgg_echo('form:search_title_label'); +$body .= elgg_view('input/text',array('internalname'=>'search_title','value'=>$search_title)); +$body .= '</label>'; +$body .= '<p class="description">'.elgg_echo('form:search_definition_search_title_description').'</p>'; + +$body .= '<label for="search_description">'.elgg_echo('form:search_description_label'); +$body .= elgg_view('input/longtext',array('internalname'=>'search_description','value'=>$search_description)); +$body .= '</label>'; +$body .= '<p class="description">'.elgg_echo('form:search_definition_search_description_description').'</p>'; + +$body .= '<label for="search_fields">'.elgg_echo('form:search_field_label'); +$body .= elgg_view('input/text',array('internalname'=>'search_fields','value'=>$search_fields)); +$body .= '</label>'; +$body .= '<p class="description">'.elgg_echo('form:search_field_description').'</p>'; + +$body .= '<label for="search_order">'.elgg_echo('form:search_order_label'); +$body .= elgg_view('input/text',array('internalname'=>'search_order','value'=>$search_order)); +$body .= '</label>'; +$body .= '<p class="description">'.elgg_echo('form:search_order_description').'</p>'; +// TODO: replace expiryfield with the new dated entities when they become available +/*$body .= '<p><label for="expiryfield">'.elgg_echo('form:expiryfield_label'); +$body .= elgg_view('input/text',array('internalname'=>'expiryfield','value'=>$expiryfield)); +$body .= '</label></p>'; +$body .= '<p class="form-field-description">'.elgg_echo('form:expiryfield_description').'</p>';*/ + +$body .= '<label for="menu">'.elgg_echo('form:menu_label'); +$body .= elgg_view('input/text',array('internalname'=>'menu','value'=>$menu)); +$body .= '</label>'; +$body .= '<p class="description">'.elgg_echo('form:search_menu_description').'</p>'; + +$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>$button)); + +$body .= '</form>'; + +$body .= '</div>'; + +print $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/forms/search.php b/plugins/form/views/default/form/forms/search.php new file mode 100755 index 0000000000000000000000000000000000000000..951a83b68b4b79f03e1bd83e625e6fc93c98aa30 --- /dev/null +++ b/plugins/form/views/default/form/forms/search.php @@ -0,0 +1,79 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form_id'] Optionally, the form to add a search definition for + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/models/model.php"); +$sd = $vars['search_definition']; +$search_definition_id = $sd->getGUID(); +$form_id = $sd->form_id; +$form = get_entity($form_id); + +$hide_category = ''; + +$hidden_fields = $vars['hidden']; +if ($hidden_fields) { + $data = array(); + $hidden = array(); + foreach ($hidden_fields as $key => $value) { + $f = new stdClass; + $f->value = $value; + $f->name = $key; + $data[$key] = $f; + $hidden[$key] = true; + if ($key == 'group_profile_category') { + // special handling + $hide_category = $value; + } + } +} + +$button = elgg_echo('form:search_button'); + +$body = '<div class="contentWrapper">'.$sd->description.'</div>'; +$body .= '<div class="contentWrapper">'; + +$body .= '<form action="'.$vars['url'].'mod/form/search_results.php" method="get">'; +$body .= elgg_view('input/hidden',array('internalname'=>'sid', 'value'=>$search_definition_id)); + +$namelist = array(); +$names = trim($sd->search_fields); +if ($names) { + foreach(explode(',',$names) as $name) { + $namelist[] = trim($name); + } + if ($hidden_fields) { + $results = form_display_filtered($form,$namelist,$data,false,$hidden); + } else { + $results = form_display_filtered($form,$namelist,null,false); + } + + if ($results) { + foreach($results as $item) { + $body .= $item->html; + } + } +} + +if ($hide_category) { + $body .= elgg_view('input/hidden',array('internalname'=>'_hide_category', 'value'=>$hide_category)); +} + +$body .= elgg_view('input/submit', array('internalname'=>'submit','value'=>$button)); + +$body .= '</form>'; +$body .= '</div>'; + +print $body; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/input/checkboxes.php b/plugins/form/views/default/form/input/checkboxes.php new file mode 100755 index 0000000000000000000000000000000000000000..322eea2ed3daed72dcae3d314b4c36ec5afbcb83 --- /dev/null +++ b/plugins/form/views/default/form/input/checkboxes.php @@ -0,0 +1,58 @@ +<?php + + /** + * Elgg checkbox input + * Displays a checkbox input field + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + * + * Form module version reverses $options array and adds orientation option + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['options'] An array of strings representing the options for the checkbox field + * + */ + + $class = $vars['class']; + if (!$class) $class = "input-checkboxes"; + + $orientation = $vars['orientation']; + if ($orientation == 'horizontal') { + $ending = ' '; + } else { + $ending = '<br />'; + } + + foreach($vars['options'] as $option => $label) { + //if (!in_array($option,$vars['value'])) { + if (is_array($vars['value'])) { + if (!in_array($option,$vars['value'])) { + $selected = ""; + } else { + $selected = "checked = \"checked\""; + } + } else { + if ($option != $vars['value']) { + $selected = ""; + } else { + $selected = "checked = \"checked\""; + } + } + $labelint = (int) $label; + if ("{$label}" == "{$labelint}") { + $label = $option; + } + + $disabled = ""; + if ($vars['disabled']) $disabled = ' disabled="yes" '; + echo "<label><input type=\"checkbox\" $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option, null, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label>".$ending; + } + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/input/group_categories.php b/plugins/form/views/default/form/input/group_categories.php new file mode 100755 index 0000000000000000000000000000000000000000..8c0564b12dbcca188b8e61764de0d09b6676f7ba --- /dev/null +++ b/plugins/form/views/default/form/input/group_categories.php @@ -0,0 +1,13 @@ +<?php +$categories = form_get_group_profile_categories(); +$options = array(); +if ($categories) { + foreach(explode("\n",$categories) as $category) { + // not sure why this trim is necessary + $category = trim($category); + $options[$category] = $category; + } +} +$vars['options'] = $options; +echo elgg_view('input/pulldown',$vars); +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/input/invite_box.php b/plugins/form/views/default/form/input/invite_box.php new file mode 100755 index 0000000000000000000000000000000000000000..3b2660a1b2319d423b9b9e8c559c687502e33798 --- /dev/null +++ b/plugins/form/views/default/form/input/invite_box.php @@ -0,0 +1,20 @@ +<?php + + /** + * Elgg invite box view + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['internalname'] The internal name of the field + */ + + echo '<br /><b>'.elgg_echo('form:contacts').'</b><br />'; + echo elgg_view('form/input/smallbox',array('internalname'=>$vars['internalname'].'_contacts','value'=>'')); + echo '<br /><b>'.elgg_echo('form:message').'</b><br />'; + echo elgg_view('form/input/smallbox',array('internalname'=>$vars['internalname'].'_message','value'=>'')); + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/input/radio.php b/plugins/form/views/default/form/input/radio.php new file mode 100755 index 0000000000000000000000000000000000000000..e609cacca462b02e9627d22d019dc82222fdad69 --- /dev/null +++ b/plugins/form/views/default/form/input/radio.php @@ -0,0 +1,42 @@ +<?php + + /** + * Elgg radio input + * Displays a radio input field + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['options'] An array of strings representing the options for the radio field + * + */ + + $class = $vars['class']; + if (!$class) $class = "input-radio"; + + $orientation = $vars['orientation']; + if ($orientation == 'horizontal') { + $ending = ' '; + } else { + $ending = '<br />'; + } + + foreach($vars['options'] as $option => $label) { + if ($option != $vars['value']) { + $selected = ""; + } else { + $selected = "checked = \"checked\""; + } + + if ($vars['disabled']) $disabled = ' disabled="yes" '; + echo "<label><input type=\"radio\" $disabled {$vars['js']} name=\"{$vars['internalname']}\" value=\"".htmlentities($option, null, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label>".$ending; + } + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/input/shorttext.php b/plugins/form/views/default/form/input/shorttext.php new file mode 100755 index 0000000000000000000000000000000000000000..d26f89aba2a7f9be8a8657083bccabe7d8cae3ea --- /dev/null +++ b/plugins/form/views/default/form/input/shorttext.php @@ -0,0 +1,27 @@ +<?php + + /** + * Elgg text input + * Displays a text input field + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * @uses $vars['disabled'] If true then control is read-only + * @uses $vars['class'] Class override + */ + + + $class = $vars['class']; + if (!$class) $class = "input-text"; + +?> + +<input style="width:250px;" type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], null, 'UTF-8'); ?>" class="<?php echo $class ?>"/> \ No newline at end of file diff --git a/plugins/form/views/default/form/input/smallbox.php b/plugins/form/views/default/form/input/smallbox.php new file mode 100755 index 0000000000000000000000000000000000000000..568b69754d1f4194994619142ed9b5a38e896c69 --- /dev/null +++ b/plugins/form/views/default/form/input/smallbox.php @@ -0,0 +1,25 @@ +<?php + + /** + * Elgg long text input + * Displays a long text input field + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + * + * @uses $vars['value'] The current value, if any + * @uses $vars['js'] Any Javascript to enter into the input tag + * @uses $vars['internalname'] The name of the input field + * + */ + + $class = $vars['class']; + if (!$class) $class = "input-textarea"; + +?> + +<textarea style="width:250px;" class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo $vars['value']; ?></textarea> \ No newline at end of file diff --git a/plugins/form/views/default/form/manage_form_last_bit.php b/plugins/form/views/default/form/manage_form_last_bit.php new file mode 100755 index 0000000000000000000000000000000000000000..a9df20493f295c1de6a53a2cf0208eb27a7cd79a --- /dev/null +++ b/plugins/form/views/default/form/manage_form_last_bit.php @@ -0,0 +1,154 @@ +<?php +$form = $vars['form']; +$type_options = form_type_options(); + +if ($form) { + $listing_description = $form->listing_description; + $response_text = $form->response_text; + if ($form->allow_comments) { + $allow_comments = 1; + } else { + $allow_comments = 0; + } + if ($form->allow_recommendations) { + $allow_recommendations = 1; + } else { + $allow_recommendations = 0; + } + if ($form->email_form) { + $email_form = 1; + } else { + $email_form = 0; + } + $email_to = $form->email_to; + + if ($form->enable_display_menu) { + $enable_display_menu = 1; + } else { + $enable_display_menu = 0; + } + $display_menu_title = $form->display_menu_title; + + if ($form->enable_create_menu) { + $enable_create_menu = 1; + } else { + $enable_create_menu = 0; + } + $create_menu_title = $form->create_menu_title; + + $profile = $form->profile; + if ($form->profile_format) { + $profile_format = $form->profile_format; + } else { + $profile_format = 'default'; + } + +} else { + $listing_description = ''; + $response_text = ''; + $allow_comments = 0; + $email_form = 0; + $email_to = ''; + $enable_display_menu = 0; + $display_menu_title = ''; + $enable_create_menu = 0; + $create_menu_title = ''; + $allow_recommendations = 0; + $profile_format = 'default'; +} + +$last_bit = ''; +if ($form) { + $last_bit .= '<div class="tabbertab" title="'.elgg_echo('form:last_bit_tab_label').'">'; +} + +if (($profile == 1) || ($profile == 2)) { + $format_options = array( + elgg_echo('form:profile_format_default_option_label') => 'default', + elgg_echo('form:profile_format_no_extended_option_label') => 'no_extended', + elgg_echo('form:profile_format_tabbed_option_label') => 'tabbed', + ); + + if ($profile == 2) { + $format_options[elgg_echo('form:profile_format_wide_tabbed_option_label')] = 'wide_tabbed'; + } + + if ($form) { + $last_bit .= '<input type="hidden" name="response_text" value="">'; + + $last_bit .= '<label class="labelclass" for="profile_format">'.elgg_echo('form:profile_format_label').'</label><br />'; + $last_bit .= elgg_view('input/radio', array('internalname'=>'profile_format','value'=>$profile_format,'options'=>$format_options)); + $last_bit .= '<p class="description">'.elgg_echo('form:profile_format_description').'</p>'; + + $last_bit .= '<label class="labelclass" for="profile_category">'.elgg_echo('form:profile_category_label').'</label>'; + $last_bit .= elgg_view('input/text',array('internalname'=>'profile_category','value'=>trim($form->profile_category))); + $last_bit .= '<p class="description">'.elgg_echo('form:profile_category_description').'</p>'; + + } +} else if ($profile == 0) { + // content form stuff + if ($form) { + + // form listing description + $last_bit .= '<label class="labelclass" for="form_listing_description">'.elgg_echo('form:listing_description_label').'</label>'; + $last_bit .= elgg_view('input/longtext',array('internalname'=>'form_listing_description','value'=>$listing_description)); + $last_bit .= '<p class="description">'.elgg_echo('form:form_listing_description').'</p>'; + + // response text + + $last_bit .= '<label class="labelclass" for="response_text">'.elgg_echo('form:response_text_label').'</label>'; + $last_bit .= elgg_view('input/longtext',array('internalname'=>'response_text','value'=>$response_text)); + $last_bit .= '<p class="description">'.elgg_echo('form:response_description').'</p>'; + + // email form option + + $last_bit .= '<br /><br />'; + + $last_bit .= elgg_view('input/checkboxes',array('internalname'=>'email_form','value'=>$email_form, 'options'=>array(elgg_echo('form:email_form_label')=>1))); + $last_bit .= '<p>'.elgg_echo('form:email_form_description').'</p>'; + + $last_bit .= '<label class="labelclass" for="email_to">'.elgg_echo('form:email_to_label').'</label>'; + $last_bit .= elgg_view('input/text', array('internalname'=>'email_to','value'=>$email_to)); + $last_bit .= '<p class="description">'.elgg_echo('form:email_to_description').'</p>'; + + $last_bit .= '<br /><br />'; + + // display menu option + + $last_bit .= elgg_view('input/checkboxes',array('internalname'=>'enable_display_menu','value'=>$enable_display_menu, 'options'=>array(elgg_echo('form:enable_display_menu_label')=>1))); + $last_bit .= '<p>'.elgg_echo('form:enable_display_menu_description').'</p>'; + + $last_bit .= '<label class="labelclass" for="display_menu_title">'.elgg_echo('form:display_menu_title_label').'</label>'; + $last_bit .= elgg_view('input/text', array('internalname'=>'display_menu_title','value'=>$display_menu_title)); + $last_bit .= '<p class="description">'.elgg_echo('form:display_menu_title_description').'</p>'; + + $last_bit .= '<br /><br />'; + + // create menu option + + $last_bit .= elgg_view('input/checkboxes',array('internalname'=>'enable_create_menu','value'=>$enable_create_menu, 'options'=>array(elgg_echo('form:enable_create_menu_label')=>1))); + $last_bit .= '<p>'.elgg_echo('form:enable_create_menu_description').'</p>'; + + $last_bit .= '<label class="labelclass" for="create_menu_title">'.elgg_echo('form:create_menu_title_label').'</label>'; + $last_bit .= elgg_view('input/text', array('internalname'=>'create_menu_title','value'=>$create_menu_title)); + $last_bit .= '<p class="description">'.elgg_echo('form:create_menu_title_description').'</p>'; + + $last_bit .= '<br /><br />'; + + // comment and recommendation options + + $last_bit .= '<p>'; + $last_bit .= elgg_view('input/checkboxes',array('internalname'=>'allow_comments','value'=>$allow_comments, 'options'=>array(elgg_echo('form:allow_comments_label')=>1))); + $last_bit .= elgg_view('input/checkboxes',array('internalname'=>'allow_recommendations','value'=>$allow_recommendations, 'options'=>array(elgg_echo('form:allow_recommendations_label')=>1))); + $last_bit .= '</p>'; + } + +} + +if ($form) { + $last_bit .= '<input type="submit" name="submit" value="'.elgg_echo('form:form_manage_button').'">'; + $last_bit .= '</div>'; +} + +echo $last_bit; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/missing_error.php b/plugins/form/views/default/form/missing_error.php new file mode 100755 index 0000000000000000000000000000000000000000..dd9b9117e6981e15868715d8b1e5c97f9787ac9a --- /dev/null +++ b/plugins/form/views/default/form/missing_error.php @@ -0,0 +1,34 @@ +<?php + +/** + * Elgg display missing error + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + $missing = $vars['missing']; + $tabs = array(); + foreach($missing as $field) { + // order within tab + if (!isset($tabs[$field->tab])) { + $tabs[$field->tab] = array(); + } + $tabs[$field->tab][] = $field->title; + } + + $field_list = array(); + + foreach ($tabs as $tab => $fields) { + if (!$tab) { + $tab = elgg_echo('form:basic_tab_label'); + } + $field_list[] = implode(', ',$fields).' '.sprintf(elgg_echo('form:tab_bit'),$tab); + } + + print sprintf(elgg_echo('form:error_missing_fields'),implode('; ',$field_list)); +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/my_forms.php b/plugins/form/views/default/form/my_forms.php new file mode 100755 index 0000000000000000000000000000000000000000..20705bf3764a27f484115391d6b8e121d9681d16 --- /dev/null +++ b/plugins/form/views/default/form/my_forms.php @@ -0,0 +1,88 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form_id'] Optionally, the form to add a search definition for + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$form = $vars['form']; +$form_view = $vars['form_view']; +$username = $vars['username']; +if ($username) { + $user = get_user_by_username($username); +} else { + $user = get_loggedin_user(); +} + +$form_id = $form->getGUID(); + +$offset = (int) get_input('offset',0); +$limit = 10; + +$entities = array(); + +if ($form_view == 'recommendations') { + // get all the form data with recommendations, sorted with the most recommended at the top + // TODO: replace with more efficient SQL + $all_entities = get_entities_from_annotations("object", "form_data", "form:recommendation", "", 0, 0, 5000); + if ($all_entities) { + $entity_list = array(); + foreach($all_entities as $entity) { + if ($entity->form_id == $form_id) { + $count = count_annotations($entity->getGUID(), "object", "form_data", "form:recommendation"); + $item = new StdClass(); + $item->entity = $entity; + $item->count = $count; + $entity_list[] = $item; + } + } + + $sorted = form_vsort($entity_list,'count',true); + foreach($sorted as $item) { + $entities[] = $item->entity; + } + $entities = array_slice($entities,$offset,$limit); + } +} else { + + if ($form_view == 'mine') { + $user_guid = $user->getGUID(); + } else if ($form_view == 'friends') { + // handles up to 5000 friends + $friends = $user->getFriends("", 5000); + $user_guid = array(); + if ($friends) { + foreach ($friends as $friend) { + $user_guid[] = $friend->getGUID(); + } + } + } else if ($form_view == 'all') { + $user_guid = 0; + } + + if (!is_array($user_guid) || count($user_guid) > 0) { + + $count = get_entities_from_metadata('form_id', $form_id, 'object', 'form_data', $user_guid, $limit, $offset, "", 0, true); + $entities = get_entities_from_metadata('form_id', $form_id, 'object', 'form_data', $user_guid, $limit, $offset, "", 0, false); + } +} + +if ($entities) { + echo '<div class="form_listing">'; + echo form_view_entity_list($entities, $form, $count, $offset, $limit, false, true); + echo '</div>'; +} else { + echo elgg_echo('form:no_search_results'); +} + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/nav.php b/plugins/form/views/default/form/nav.php new file mode 100755 index 0000000000000000000000000000000000000000..dfcefbc830d0886071b00a5528aa706594d90918 --- /dev/null +++ b/plugins/form/views/default/form/nav.php @@ -0,0 +1,26 @@ +<?php +$allselect = ''; $friendsselect = ''; $mineselect = ''; +switch($vars['form_view']) { + case 'all': $allselect = 'class="selected"'; + break; + case 'friends': $friendsselect = 'class="selected"'; + break; + case 'recommendations': $recommendedselect = 'class="selected"'; + break; + case 'mine': $mineselect = 'class="selected"'; + break; +} + +$url_start = $vars['url'].'mod/form/my_forms.php?id='.$vars['form_id'].'&mode='.$vars['mode']; + +?> +<div id="elgg_horizontal_tabbed_nav"> + <ul> + <li <?php echo $allselect; ?> ><a onclick="javascript:$('#form_wrapper').load('<?php echo $url_start; ?>&form_view=all&callback=true'); return false;" href="<?php echo $url_start; ?>&form_view=all&callback=true"><?php echo elgg_echo('all'); ?></a></li> + <?php if ($vars['enable_recommendations']) {?> + <li <?php echo $recommendedselect; ?> ><a onclick="javascript:$('#form_wrapper').load('<?php echo $url_start; ?>&form_view=recommendations&callback=true'); return false;" href="<?php echo $url_start; ?>&form_view=recommendations&callback=true"><?php echo elgg_echo('form:recommended'); ?></a></li> + <? } ?> + <li <?php echo $friendsselect; ?> ><a onclick="javascript:$('#form_wrapper').load('<?php echo $url_start; ?>&form_view=friends&callback=true'); return false;" href="<?php echo $url_start; ?>&form_view=friends&callback=true"><?php echo elgg_echo('friends'); ?></a></li> + <li <?php echo $mineselect; ?> ><a onclick="javascript:$('#form_wrapper').load('<?php echo $url_start; ?>&form_view=mine&callback=true'); return false;" href="<?php echo $url_start; ?>&form_view=mine&callback=true"><?php echo elgg_echo('mine'); ?></a></li> + </ul> +</div> \ No newline at end of file diff --git a/plugins/form/views/default/form/output/choice.php b/plugins/form/views/default/form/output/choice.php new file mode 100755 index 0000000000000000000000000000000000000000..e0168d434e308dada6e5d7db69ecde6072af8e24 --- /dev/null +++ b/plugins/form/views/default/form/output/choice.php @@ -0,0 +1,55 @@ +<?php + +/** + * Elgg choice + * Displays a choice option linked to a search + * + * Tags can be a single string (for one tag) or an array of strings + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['option'] The choice option + * @uses $vars['label'] The label + * @uses $vars['internalname'] The internal name of the field + * @uses $vars['form_id'] The form_id + */ + +$type = $vars['type']; +$value = $vars['value']; +$internalname = $vars['internalname']; +$form_id = $vars['form_id']; + +if ($type == 'form_data') { + $qs = "type=form_data&form_id=$form_id"; +} else { + $qs = "type=$type"; +} + +if (is_array($value)) { + $value_array = array(); + foreach($value as $key => $label) { + if (!$label) { + $label = $key; + } + $value_bit = "&form_data[$internalname]=".urlencode($key); + $value_array[] = '<a href="'.$vars['url'].'mod/form/search_results_simple.php?'.$qs.$value_bit.'">'.$label.'</a>'; + } + echo implode(', ',$value_array); +} else { + + if (empty($vars['label'])) { + $label = $value; + } else { + $label = $vars['label']; + } + + $qs .= "&form_data[$internalname]=".urlencode($value); + + echo '<a href="'.$vars['url'].'mod/form/search_results_simple.php?'.$qs.'">'.$label.'</a>'; +} + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/output/image.php b/plugins/form/views/default/form/output/image.php new file mode 100755 index 0000000000000000000000000000000000000000..7db638b86ea4f6decaf8d3a811d66b56586f7cc5 --- /dev/null +++ b/plugins/form/views/default/form/output/image.php @@ -0,0 +1,11 @@ +<?php + +$value = trim($vars['value']); +$size = trim($vars['size']); +if (!$size) { + $size = 'large'; +} + +print '<img src="'.$vars['url'].'/mod/file/thumbnail.php?size='.$size.'&file_guid='.$value.'">'; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/output/longtext_no_p.php b/plugins/form/views/default/form/output/longtext_no_p.php new file mode 100755 index 0000000000000000000000000000000000000000..3ce4c6dcdbb00c90dbb8842290743c232c419113 --- /dev/null +++ b/plugins/form/views/default/form/output/longtext_no_p.php @@ -0,0 +1,36 @@ +<?php + + /** + * Elgg display long text, no_p + * Displays a large amount of text, with new lines converted to line breaks + * + * This version modified to remove paragraph wrapper and replace internal + * paragraph tags with <br /><br /> + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2009 + * @link http://elgg.org/ + * + * @uses $vars['text'] The text to display + * + */ + + global $CONFIG; + + $value = trim(autop(parse_urls(filter_tags($vars['value'])))); + + // strip off last </p> if any + if (substr($value,strlen($value)-4,4) == '</p>') { + $value = substr($value,0,strlen($value)-4); + } + // eliminate <p> tags + $value = str_replace('<p>','',$value); + // replace </p> tags with <br /><br /> + $value = str_replace('</p>','<br /><br />',$value); + + echo $value; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/output/tags.php b/plugins/form/views/default/form/output/tags.php new file mode 100755 index 0000000000000000000000000000000000000000..c73ba9cc1e0911a9fd0854f9be6266c33c675cf7 --- /dev/null +++ b/plugins/form/views/default/form/output/tags.php @@ -0,0 +1,44 @@ +<?php + +/** + * Elgg tags + * Displays a list of tags, separated by commas + */ + +if (!empty($vars['subtype'])) { + $subtype = "&subtype=" . urlencode($vars['subtype']); +} else { + $subtype = ""; +} +if (!empty($vars['object'])) { + $object = "&object=" . urlencode($vars['object']); +} else { + $object = ""; +} + +if (empty($vars['tags']) && !empty($vars['value'])) +$vars['tags'] = $vars['value']; +if (!empty($vars['tags'])) { + + $tagstr = ""; + if (!is_array($vars['tags'])) + $vars['tags'] = array($vars['tags']); + + foreach($vars['tags'] as $tag) { + if (!empty($tagstr)) { + $tagstr .= ", "; + } + if (!empty($vars['type'])) { + $type = "&type={$vars['type']}"; + } else { + $type = ""; + } + if (is_string($tag)) { + $vars['value'] = $tag; + $tagstr .= elgg_view('form/output/choice',$vars); + } + } + echo $tagstr; + +} +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/output/video_box.php b/plugins/form/views/default/form/output/video_box.php new file mode 100755 index 0000000000000000000000000000000000000000..9b4127b3774ebf04b2b15f2fb7872adb3c2c42e0 --- /dev/null +++ b/plugins/form/views/default/form/output/video_box.php @@ -0,0 +1,36 @@ +<?php + +$value = trim($vars['value']); +$pos1 = strpos($value, "="); +if ($pos1 !== false) { + $pos2 = strpos($value,"&",$pos1+1); + if ($pos2 !== false) { + $value=substr($value,$pos1+1,$pos2-$pos1-1); + } else { + $value = substr($value, $pos1+1); + } + + $size = $vars['size']; + if (!$size) { + $size = 'full'; + } + if ($size == 'thumb') { + print '<img src="http://img.youtube.com/vi/'.$value.'/2.jpg" />'; + } else { + + +?> + +<object width="425" height="344"> +<param name="movie" value="http://www.youtube.com/v/<?php echo $value; ?>&hl=en&fs=1"></param> +<param name="allowFullScreen" value="true"></param> +<embed src="http://www.youtube.com/v/<?php echo $value; ?>&hl=en&fs=1" +type="application/x-shockwave-flash" allowfullscreen="true" +width="425" height="344"> +</embed> +</object> + +<?php + } +} +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/response.php b/plugins/form/views/default/form/response.php new file mode 100755 index 0000000000000000000000000000000000000000..86ebc4c65b9ea386de2df7653e50e7e10b41befc --- /dev/null +++ b/plugins/form/views/default/form/response.php @@ -0,0 +1,11 @@ +<?php +$form = $vars['form']; +$body = '<div class="contentWrapper">'; +if (trim($form->response_text)) { + $body .= '<p class="form-response">'.$form->response_text.'</p>'; +} else { + $body .= '<p class="form-response">'.elgg_echo('form:default_response_text').'</p>'; +} +$body .= '</div>'; +echo $body; +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/search/listing.php b/plugins/form/views/default/form/search/listing.php new file mode 100755 index 0000000000000000000000000000000000000000..34f89e055d710d4f386393fab91b85ecd568ce9c --- /dev/null +++ b/plugins/form/views/default/form/search/listing.php @@ -0,0 +1,38 @@ +<?php + + /** + * Elgg search listing + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + if (isset($vars['search_viewtype']) && $vars['search_viewtype'] == "gallery") { + + echo elgg_view("search/gallery_listing",$vars); + + } else { + +?> + + <div class="search_listing"> + + <!--div class="search_listing_info"--> + <?php + + echo $vars['info']; + + ?> + <!--/div --> + + </div> + +<?php + + } + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/search_results.php b/plugins/form/views/default/form/search_results.php new file mode 100755 index 0000000000000000000000000000000000000000..d7bbb028def1a1921cfcf8a33aacd3f75bff1275 --- /dev/null +++ b/plugins/form/views/default/form/search_results.php @@ -0,0 +1,52 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form_id'] Optionally, the form to add a search definition for + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$sd = $vars['search_definition']; +$fd = form_get_data_from_form_submit($sd->form_id); + +$form = get_entity($sd->form_id); + +$offset = (int) get_input('offset',0); +$limit = 5; + +$search_page_link = '<p><a href="'.$vars['url'].'mod/form/search.php?sid='.$sd->getGUID().'" >'.elgg_echo('form:return_to_search').'</a></p>'; + +//echo $search_page_link; +echo '<div class="contentWrapper">'; +echo '<div class="form_listing">'; + +$result = form_get_data_with_search_conditions($fd,$sd,$limit,$offset); + +$count = $result[0]; +$entities = $result[1]; + +if ($entities) { + if (($form->profile == 1) || ($form->profile == 2)) { + echo elgg_view_entity_list($entities, $count, $offset, $limit, false, false); + } else { + echo form_view_entity_list($entities, $form, $count, $offset, $limit, false, false); + } +} else { + echo '<p>'.elgg_echo('form:no_search_results').'</p>'; +} + +echo '</div>'; +echo '</div>'; + +//echo $search_page_link; + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/search_results_simple.php b/plugins/form/views/default/form/search_results_simple.php new file mode 100755 index 0000000000000000000000000000000000000000..fe32bc4b219939ed8680d9c0023a0b35beb61327 --- /dev/null +++ b/plugins/form/views/default/form/search_results_simple.php @@ -0,0 +1,60 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + * @uses $vars['form_id'] Optionally, the form to add a search definition for + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + // load form profile model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/profile.php"); + +$type = get_input('type',''); + +$fd = get_input('form_data',array()); + +if ($type == 'user') { + // load flexprofile model + require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/flexprofile/models/model.php"); + $form = flexprofile_get_profile_form(); +} else if ($type == 'group') { + // load flexgroupprofile model + require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/flexgroupprofile/models/model.php"); + $form = flexgroupprofile_get_profile_form(); + set_context('groups'); +} else if ($type == 'file') { + // load flexgroupprofile model + require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/flexfile/models/model.php"); + $form = flexfile_get_file_form(); + set_context('file'); +} else { + $form_id = (int) get_input('form_id',0); + $form = get_entity($form_id); +} + +$offset = (int) get_input('offset',0); +$limit = 5; + +$result = form_get_data_with_search_conditions_simple($fd,$type,$form->getGUID(),$limit,$offset); +$count = $result[0]; +$entities = $result[1]; + +if ($entities) { + if (($form->profile == 1) || ($form->profile == 2)) { + echo elgg_view_entity_list($entities, $count, $offset, $limit, false, false); + } else { + echo form_view_entity_list($entities, $form, $count, $offset, $limit, false, false); + } +} else { + echo '<p>'.elgg_echo('form:no_search_results').'</p>'; +} + +?> \ No newline at end of file diff --git a/plugins/form/views/default/form/settings/usersettings.php b/plugins/form/views/default/form/settings/usersettings.php new file mode 100755 index 0000000000000000000000000000000000000000..7dbb7864da198b648a940624d7d7b2a7ea6e6012 --- /dev/null +++ b/plugins/form/views/default/form/settings/usersettings.php @@ -0,0 +1,27 @@ +<?php + /** + * User settings for forms. + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + $key = 'form:view_content_languages'; + $form_view_languages = $_SESSION['user']->$key; + if ($form_view_languages) { + $form_view_languages = explode(",",$form_view_languages); + } else { + $form_view_languages = array(); + } + $languages = get_installed_translations(); +?> + <h3><?php echo elgg_echo('form:usersettings_title'); ?></h3> + + <p><?php echo elgg_echo('form:usersettings_description'); ?></p> + +<?php + echo elgg_view('form/input/checkboxes',array('internalname' => "form_view_language", 'options' => $languages, 'value' => $form_view_languages)); + +?> \ No newline at end of file diff --git a/plugins/form/views/default/object/form.php b/plugins/form/views/default/object/form.php new file mode 100755 index 0000000000000000000000000000000000000000..d072431d39eef942bcade41ab275ecb41a28942d --- /dev/null +++ b/plugins/form/views/default/object/form.php @@ -0,0 +1,74 @@ +<?php +/** + * Elgg form display + * Displays the specified Elgg form + * + * @package Elgg + * @subpackage Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + */ + + +// Load form model +require_once(dirname(dirname(dirname(dirname(__FILE__))))."/models/model.php"); + +$form = $vars['entity']; + +$tab_data = array(); +$title = $form->title; +$maps = form_get_maps($form_id); +if ($maps) { + foreach($maps as $map) { + $field = get_entity($map->field_id); + $vars = array('internalname'=>$field->internal_name,'value'=>$field->default_value); + //print($field->internal_name.','.$field->field_type.','.$field->choice_type.','.$field->default_value.'<br />'); + if ($field->field_type == 'choices') { + $vars['orientation'] = $field->orientation; + $field_type = $field->choice_type; + $choices = form_get_field_choices($field->getGUID()); + if ($choices) { + if ($choices[0]->label) { + $options_values = array(); + foreach($choices as $choice) { + $options_values[$choice->value] = $choice->label; + } + $vars['options_values'] = $options_values; + } else { + $options = array(); + foreach($choices as $choice) { + $options[$choice->value] = $choice->value; + } + $vars['options'] = $options; + } + } + + } else { + $field_type = $field->field_type; + } + $view = 'input/'.$field_type; + if (in_array($field_type, array('radio','checkboxes'))) { + // use the local view + $view = 'form/'.$view; + } + //print($view.'<br />'); + if (!$field->tab) { + $tab = elgg_echo('form:basic_tab_label'); + } else { + // TODO - allow forms to get this data from the translation file rather than directly + $tab = $field->tab; + } + + if (!isset($tab_data[$tab])) { + $tab_data[$tab] = ''; + } + $tab_data[$tab] .= elgg_view('form/display_field', array('field'=>elgg_view($view,$vars), + 'title'=>$field->title,'description'=>$field->description)); + } +} + +echo elgg_view('form/display_form', array('description'=>$form->description,'tab_data'=>$tab_data)); + +?> \ No newline at end of file diff --git a/plugins/form/views/default/object/form_data.php b/plugins/form/views/default/object/form_data.php new file mode 100755 index 0000000000000000000000000000000000000000..6d990e7d2b100f0b2cbfd0418dc9d4bcce394050 --- /dev/null +++ b/plugins/form/views/default/object/form_data.php @@ -0,0 +1,23 @@ +<?php + + /** + * Elgg display search form + * + * @package Form + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + + // load form model + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/models/model.php"); + +$form_data = $vars['entity']; +$form = get_entity($form_data->form_id); +if ($form) { + echo form_view_entities(array($form_data), $form, 'list'); +} + +?> \ No newline at end of file diff --git a/plugins/form/views/default/river/object/form_data/annotate.php b/plugins/form/views/default/river/object/form_data/annotate.php new file mode 100755 index 0000000000000000000000000000000000000000..f8409ef5c39e5671b9a38b03d83eb97b8052b737 --- /dev/null +++ b/plugins/form/views/default/river/object/form_data/annotate.php @@ -0,0 +1,13 @@ +<?php + $performed_by = get_entity($vars['item']->subject_guid); + $object = get_entity($vars['item']->object_guid); + $form_title = get_entity($object->form_id)->title; + + $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; + $string = ''; + $string .= sprintf(elgg_echo("form:river:commented"),$url) . " "; + $string .= "<a href=\"" . $object->getURL() . "\">" . elgg_echo("form:river:this_content") . "</a> ".sprintf(elgg_echo("form:river:destination"),$form_title); + +?> + +<?php echo $string; ?> \ No newline at end of file diff --git a/plugins/form/views/default/river/object/form_data/create.php b/plugins/form/views/default/river/object/form_data/create.php new file mode 100755 index 0000000000000000000000000000000000000000..a477dd617e94c35c5b5f49885667ad6a3164bde0 --- /dev/null +++ b/plugins/form/views/default/river/object/form_data/create.php @@ -0,0 +1,13 @@ +<?php + $performed_by = get_entity($vars['item']->subject_guid); + $object = get_entity($vars['item']->object_guid); + $form_title = get_entity($object->form_id)->title; + + $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; + $string = ''; + $string .= sprintf(elgg_echo("form:river:created"),$url) . " "; + $string .= "<a href=\"" . $object->getURL() . "\">" . elgg_echo("form:river:this_content") . "</a> ".sprintf(elgg_echo("form:river:destination"),$form_title); + +?> + +<?php echo $string; ?> \ No newline at end of file diff --git a/plugins/form/views/default/settings/form/edit.php b/plugins/form/views/default/settings/form/edit.php new file mode 100755 index 0000000000000000000000000000000000000000..01798eeee0560fe09f570a916e9744820ab173fa --- /dev/null +++ b/plugins/form/views/default/settings/form/edit.php @@ -0,0 +1,20 @@ +<?php +$options = array(elgg_echo('form:yes')=>'yes', + elgg_echo('form:no')=>'no', +); + +if (form_get_user_content_status()) { + $form_user_content_area = 'yes'; +} else { + $form_user_content_area = 'no'; +} + +$body = ''; + +$body .= elgg_echo('form:user_content_status_title'); +$body .= '<br />'; +$body .= elgg_view('input/radio',array('internalname'=>'params[user_content_area]','value'=>$form_user_content_area,'options'=>$options)); + +echo $body; + +?> \ No newline at end of file