Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ContributionPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function setUp()
$this->_hooks[] = 'user_profiles_user_page';
}

if (! is_admin_theme()) {
if (!is_admin_theme()) {
//dig up all the elements being used, and add their ElementForm hook
$elementsTable = $this->_db->getTable('Element');
$select = $elementsTable->getSelect();
Expand Down Expand Up @@ -112,6 +112,7 @@ public function hookInstall()
`item_type_id` INT UNSIGNED NOT NULL,
`display_name` VARCHAR(255) NOT NULL,
`file_permissions` ENUM('Disallowed', 'Allowed', 'Required') NOT NULL DEFAULT 'Disallowed',
`add_tags` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `item_type_id` (`item_type_id`)
) ENGINE=MyISAM;";
Expand Down Expand Up @@ -259,6 +260,12 @@ public function hookUpgrade($args)
set_option('contribution_open', get_option('contribution_simple'));
delete_option('contribution_simple');
}

if (version_compare($oldVersion, '3.1.2', '<')) {
$db = $this->_db;
$sql = "ALTER TABLE `$db->ContributionType` ADD COLUMN `add_tags` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'";
$db->query($sql);
}
}

public function hookUninstallMessage()
Expand Down Expand Up @@ -634,8 +641,8 @@ public function hookUserProfilesUserPage($args)
{
$user = $args['user'];
$contributionCount = $this->_db->getTable('ContributionContributedItem')->count(array('contributor' => $user->id));
if ($contributionCount !=0) {
echo "<a href='" . url('contribution/contributors/show/id/' . $user->id) . "'>Contributed Items ($contributionCount)";
if ($contributionCount != 0) {
echo "<a href='" . url('contribution/contributors/show/id/' . $user->id) . "'>" . __('Contributed Items (%d)', $contributionCount) . '</a>';
}
}

Expand Down
4 changes: 3 additions & 1 deletion controllers/ContributionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ protected function _setupCaptcha()
protected function _processForm($post)
{
if (!empty($post)) {

//for the "Simple" configuration, look for the user if exists by email. Log them in.
//If not, create the user and log them in.
$user = current_user();
Expand Down Expand Up @@ -274,6 +273,9 @@ protected function _processForm($post)
return false;
}
$this->_addElementTextsToItem($item, $post['Elements']);
if ($contributionType->add_tags && isset($post['tags'])) {
$item->addTags($post['tags']);
}
// Allow plugins to deal with the inputs they may have added to the form.
fire_plugin_hook('contribution_save_form', array('contributionType'=>$contributionType,'record'=>$item, 'post'=>$post));
$item->save();
Expand Down
1 change: 1 addition & 0 deletions models/ContributionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ContributionType extends Omeka_Record_AbstractRecord
public $item_type_id;
public $display_name;
public $file_permissions = 'Disallowed';
public $add_tags = 0;

protected $_related = array('ContributionTypeElements' => 'getTypeElements',
'ItemType' => 'getItemType');
Expand Down
2 changes: 1 addition & 1 deletion plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ link="http://omeka.org/codex/Plugins/Contribution_2.0"
support_link="http://omeka.org/forums/forum/plugins"
omeka_minimum_version="2.3"
omeka_target_version="2.3"
version="3.1.0"
version="3.1.2"
tags="social, items"
license="GPLv3"
required_plugins="GuestUser"
Expand Down
14 changes: 12 additions & 2 deletions views/admin/types/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,19 @@
</div>
</div>
</div>



<div class="field">
<div class="two columns alpha">
<label><?php echo __("Add Tags"); ?></label>
</div>
<div class="inputs five columns omega">
<p class="explanation"><?php echo __("Allow to add tags."); ?></p>
<div class="input-block">
<?php echo $this->formCheckbox('add_tags', null, array('checked' => $contribution_type->add_tags)); ?>
</div>
</div>
</div>

<div id="element-list" class="seven columns alpha">
<ul id="contribution-type-elements" class="sortable">
<?php
Expand Down
12 changes: 12 additions & 0 deletions views/public/contribution/type-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
}
?>

<?php if ($type->add_tags) : ?>
<div id="tag-form" class="field">
<div class="two columns alpha">
<?php echo $this->formLabel('tags', __('Add Tags')); ?>
</div>
<div class="inputs five columns omega">
<p id="add-tags-explanation" class="explanation"><?php echo __('Separate tags with %s', option('tag_delimiter')); ?></p>
<?php echo $this->formText('tags'); ?>
</div>
</div>
<?php endif; ?>

<?php
if (!isset($required) && $type->isFileAllowed()):
?>
Expand Down