Skip to content

Commit

Permalink
- Properly fires the backend events: _EntryPreCreate_ and _EntryPostC…
Browse files Browse the repository at this point in the history
…reate_

- Backend stuff, no longer uses event, uses the built in actionNew function of contentPublish
  • Loading branch information
scottkf committed May 18, 2011
1 parent fa53caa commit 73465a8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 137 deletions.
15 changes: 7 additions & 8 deletions assets/massuploadutility.js
Expand Up @@ -107,14 +107,13 @@
id = idSafeFilename(name);
p = "<p id='"+id+"'>";
if (json != null) {
css = (json.response["_result"] == 'error') ? "failure" : "success";
css = (json.status == 'error') ? "failure" : "success";
p += "<img src='"+urlAssets + "/images/"+css+".png' />&nbsp;" + name + "&nbsp;<small id='MUU-list' class="+css+">";
if (json.response["_result"] == "error") {
$.each(json.response, function(k,v) {
if (k != "_result" && k != "message" && k != "post-values") {
field = $("form *[name='fields["+k+"]']");
if (json.status == "error") {
$.each(json.errors, function(k,v) {
field = $("form div[id='field-"+k+"'] input");
if (errorsInQueue || field.attr('type') == 'file') {
p += v._message + "&nbsp;";
p += v + "&nbsp;";
}
else {
// highlight the fields that have errors
Expand All @@ -124,11 +123,11 @@
if (field.parent().attr('id') != 'error') {
// field.children(":first").attr("name") + " " + v;
field.wrap("<div id=\"error\" class=\"invalid\"></div>");
field.parent().append("<p>" + v._message + "</p>");
field.parent().append("<p>" + v + "</p>");
}
}
}
});
);
}
p += "</small></p>";
}
Expand Down
24 changes: 16 additions & 8 deletions content/content.index.php
Expand Up @@ -34,23 +34,31 @@ public function getSectionId() {
* ---------------------------------------------------------
*/
public function view() {

if (!isset($_REQUEST['MUUsource']) or $_REQUEST['MUUsource'] == '')
{ exit; }

if (($section_id = $this->getSectionId()) === NULL)
{ exit; }

$_POST['fields'] = $_REQUEST['fields'];
$_POST['action'] = $_REQUEST['action'];
$_POST = $_REQUEST;
$_POST['action']['save'] = true;

$event = new Event_Mass_Upload_Utility_Entry(Frontend::instance(), array());

// Borrowed from Nick Dunn
$xml = $event->load();
if(is_array($xml)) $xml = reset($xml);
if($xml instanceOf XMLElement) $xml = $xml->generate(TRUE);
require_once(CONTENT . '/content.publish.php');
$content = new contentPublish($this->_Parent);
// this is used by contentPublish to see the source section
$content->_context = array();
$content->_context['section_handle'] = General::sanitize($_REQUEST['MUUsource']);

// this function takes care of all the entry adding
$content->__actionNew();

$response['errors'] = $content->_errors;
$response['status'] = (count($content->_errors) ? 'error' : 'success');
$response['message'] = ($content->Alert instanceof Alert ? $content->Alert->__get('message') : '');

echo(json_encode(XMLToArray::convert($xml)));
echo(json_encode($response));

exit;
}
Expand Down
45 changes: 0 additions & 45 deletions events/event.mass_upload_utility_entry.php

This file was deleted.

4 changes: 2 additions & 2 deletions extension.driver.php
Expand Up @@ -10,8 +10,8 @@ class Extension_MassUploadUtility extends Extension {
public function about() {
return array(
'name' => 'Mass Upload Utility',
'version' => '0.9.5',
'release-date' => '2011-05-12',
'version' => '0.9.6',
'release-date' => '2011-05-18',
'author' => array(
'name' => 'Scott Tesoriere',
'website' => 'http://tesoriere.com',
Expand Down
72 changes: 0 additions & 72 deletions lib/class.xmltoarray.php

This file was deleted.

9 changes: 7 additions & 2 deletions readme.md
@@ -1,7 +1,7 @@
# Mass Upload Utility

- Version: 0.9.5
- Date: 12 May 2011
- Version: 0.9.6
- Date: 18 May 2011
- Requirements: Symphony 2.2
- Author: Scott Tesoriere <scott@tesoriere.com>
- Github Repository: http://github.com/scottkf/massuploadutility
Expand All @@ -18,6 +18,11 @@ has an upload field, it *should* work with all upload fields. Testing is needed.

## Changelog

**v0.9.6.**

- Properly fires the backend events: _EntryPreCreate_ and _EntryPostCreate_
- Backend stuff, no longer uses event, uses the built in actionNew function of contentPublish

**v0.9.5**

- No longer clears files from the input[file] box if failed
Expand Down

0 comments on commit 73465a8

Please sign in to comment.