Skip to content

Commit

Permalink
just cleanup nothing to see here. move along.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmj committed Jan 14, 2016
1 parent 066deaa commit 4bee8d0
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 95 deletions.
39 changes: 14 additions & 25 deletions VraCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class VraCorePlugin extends Omeka_Plugin_AbstractPlugin
);

protected $searchTexts = '';

protected $elementsData = array(
'Title' => array('attrs' => array('type')),
'Agent' => array(
Expand Down Expand Up @@ -199,7 +199,7 @@ public function hookAdminHead($args)
queue_js_string($js);
queue_js_file('vra-core');
}

public function hookPublicHead($args)
{
queue_css_file('vra-core');
Expand Down Expand Up @@ -235,7 +235,6 @@ public function hookElementsShow($args)
}
$groupedElements = array();
foreach($elements as $element) {
debug($element->name);
$groupedElements[$element->name][] = $element;
}
$view = get_view();
Expand All @@ -246,7 +245,7 @@ public function hookElementsShow($args)
);
}
}

public function hookAfterSaveItem($args)
{
$this->afterSaveRecord($args);
Expand All @@ -261,7 +260,7 @@ public function hookAfterSaveFile($args)
{
$this->afterSaveRecord($args);
}

public function filterVraIdInput($components, $args)
{
$components['html_checkbox'] = false;
Expand Down Expand Up @@ -345,17 +344,17 @@ public function getGlobalAttrs()
{
return $this->globalAttrs;
}

public function getElementsData()
{
return $this->elementsData;
}

public function getSubelementsData()
{
return $this->subelementsData;
}

protected function storeAttributes($attributesData, $omekaRecord, $omekaElementId, $vraElementId = null)
{
if(empty($attributesData)) {
Expand Down Expand Up @@ -386,8 +385,7 @@ protected function storeAttributes($attributesData, $omekaRecord, $omekaElementI
}
}

/*
*
/**
* $vraElementId the id of the VraCoreElement record, not the optional vra_element_id column value
*/
protected function storeElement($elementData, $omekaRecord, $omekaElementId, $vraElementId = null)
Expand All @@ -402,8 +400,6 @@ protected function storeElement($elementData, $omekaRecord, $omekaElementId, $vr
$vraElement->vra_element_id = isset($elementData['vra_element_id']) ? $elementData['vra_element_id'] : null;
$vraElement->name = $elementData['name'];
}


$vraElement->content = isset($elementData['content']) ? $elementData['content'] : null;
$this->searchTexts .= ' ' . $vraElement->content . ' ';
$vraElement->save();
Expand All @@ -427,21 +423,18 @@ protected function processNewElement($omekaRecord, $omekaElementId, $elementData
'name' => 'dates',
'attrs' => $datesSubelements['attrs'],
);

$datesSubelementObject = $this->processNewSubelement($omekaRecord,
$omekaElementId,
$newVraElement,
$datesSubelementData);

$earliestDateData = $datesSubelements['earliestDate'];
$earliestDateData['name'] = 'earliestDate';
$latestDateData = $datesSubelements['latestDate'];
$latestDateData['name'] = 'latestDate';



if(!empty($earliestDateData['content'])) {


$this->processNewSubelement($omekaRecord,
$omekaElementId,
$datesSubelementObject,
Expand All @@ -464,8 +457,6 @@ protected function processNewElement($omekaRecord, $omekaElementId, $elementData
$this->processNewSubelement($omekaRecord, $omekaElementId, $newVraElement, $subelementData);
}
}


}
} else {
if (empty($elementData['content'])) {
Expand All @@ -477,10 +468,9 @@ protected function processNewElement($omekaRecord, $omekaElementId, $elementData
}
return $newVraElement;
}

protected function processExistingElement($omekaRecord, $omekaElementId, $vraElementId, $elementData)
{

$hasSubelements = !empty($elementData['hasSubElements']);
$vraElementObject = $this->_db->getTable('VraCoreElement')->find($vraElementId);
if ($hasSubelements) {
Expand All @@ -494,14 +484,13 @@ protected function processExistingElement($omekaRecord, $omekaElementId, $vraEle
}
$vraElementObject->content = $elementData['content'];
//@TODO: reuse the storeElement function if possible, or rename it for clarity

$vraElementObject->save();
$this->searchTexts .= ' ' . $vraElementObject->content;
$this->storeAttributes($elementData['attrs'], $omekaRecord, $omekaElementId, $vraElementId);
}
}
}

protected function processNewSubelement($omekaRecord, $omekaElementId, $parentVraElement, $elementData)
{
//this is the id of the element in Omeka's Elements table
Expand Down Expand Up @@ -540,7 +529,7 @@ protected function hasNewSubelements($elementData)
}
return false;
}

public function afterSaveRecord($args)
{
$insert = $args['insert'];
Expand Down
10 changes: 3 additions & 7 deletions controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ class VraCore_AjaxController extends Omeka_Controller_AbstractActionController
{
public function elementAction()
{

//@todo there has to be a cleaner way to pass the data around with statics
// or at least know that it already exists someplace
$plugin = new VraCorePlugin();
$globalAttrs = $plugin->getGlobalAttrs();
$elementsData = $plugin->getElementsData();

$nameBase = $this->getParam('nameBase');
$omekaElementName = $this->getParam('omekaElementName');
$newElementCount = $this->getParam('newElementCount');
Expand All @@ -33,7 +31,7 @@ public function subelementAction()
$nameBase = $this->getParam('nameBase');
$subelementName = $this->getParam('subelementName');
$newSubelementCount = $this->getParam('newSubelementCount');

if (isset($subelementsData[$subelementName])) {
$attributeNames = array_merge($subelementsData[$subelementName]['attrs'], $globalAttrs);
} else {
Expand All @@ -44,9 +42,8 @@ public function subelementAction()
$this->view->nameBase = $nameBase;
$this->view->subelementName = $subelementName;
$this->view->newSubelementCount = $newSubelementCount;

}

public function parentElementAction()
{
$plugin = new VraCorePlugin();
Expand All @@ -56,7 +53,6 @@ public function parentElementAction()
$omekaElementName = $this->getParam('omekaElementName');
$nameBase = $this->getParam('nameBase');
$newElementCount = $this->getParam('newElementCount');

$attributeNames = array_merge($elementsData[$omekaElementName]['attrs'], $globalAttrs);

$this->view->attributeNames = $attributeNames;
Expand All @@ -67,4 +63,4 @@ public function parentElementAction()
$this->view->subelementsData = $subelementsData;
$this->view->globalAttrs = $globalAttrs;
}
}
}
4 changes: 2 additions & 2 deletions models/Table/VraCoreAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getSelectForFindBy($params)
}
return $select;
}

public function fetchElementDataDate($vraElement)
{
$select = $this->getSelectForFindBy(array(
Expand All @@ -26,4 +26,4 @@ public function fetchElementDataDate($vraElement)
);
return $this->fetchObject($select);
}
}
}
6 changes: 3 additions & 3 deletions models/Table/VraCoreElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getSelectForFindBy($params)
}
return $select;
}

public function findNotesForRecordElement($omekaRecord, $omekaElementId)
{
$params = array(
Expand All @@ -25,7 +25,7 @@ public function findNotesForRecordElement($omekaRecord, $omekaElementId)
$select = $this->getSelectForFindBy($params);
return $this->fetchObject($select);
}

public function omekaElementHasVraElements($omekaElement, $omekaRecord)
{
$count = $this->count(array('element_id' => $omekaElement->id,
Expand All @@ -37,4 +37,4 @@ public function omekaElementHasVraElements($omekaElement, $omekaRecord)
}
return false;
}
}
}
10 changes: 5 additions & 5 deletions models/VraCoreAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
class VraCoreAttribute extends Omeka_Record_AbstractRecord
{
public $record_id;

public $record_type;

public $element_id;

public $vra_element_id;

public $name;

public $content;
}
17 changes: 8 additions & 9 deletions models/VraCoreElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ class VraCoreElement extends Omeka_Record_AbstractRecord
{

public $record_id;

public $record_type;

public $element_id;

public $vra_element_id;

public $name;

public $content;

protected $attributes;

protected $subelements;



public function getAttributes()
{
if(! $this->attributes) {
Expand Down
3 changes: 0 additions & 3 deletions views/admin/ajax/element.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

<div class='vra-element-inputs new added'>

<textarea name='<?php echo $nameBase; ?>[newElements][<?php echo $newElementCount; ?>][content]' value=''></textarea>
<input type='hidden' name='<?php echo $nameBase; ?>[newElements][<?php echo $newElementCount; ?>][name]' value='<?php echo $omekaElementName; ?>'></input>
<?php echo $this->partial('element-attribute-form.php',
Expand All @@ -15,4 +13,3 @@
);
?>
</div>

17 changes: 1 addition & 16 deletions views/admin/ajax/parent-element.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
<input type='hidden' name='<?php echo $nameBase; ?>[newElements][<?php echo $newElementCount; ?>][hasSubelements]' value='1'></input>
<div class='vra-subelements'>
<?php foreach($elementsData[$omekaElementName]['subelements'] as $subelementName): ?>
<?php debug($subelementName); ?>

<?php if($subelementName == 'dates'): ?>

<div class='vra-subelement-container'>
<div class='vra-element-header'>
<div class='drawer closed'></div><label class='vra-subelement-label'><?php echo $subelementName; ?></label>
</div>

<fieldset style='display:none'>
<input class='subelement-add' type='submit' value='Add Dates Element' data-namebase='<?php echo $nameBase; ?>' data-subelement-name='<?php echo $subelementName; ?>' data-omeka-element-name='<?php echo $omekaElement->name; ?>'></input>
<?php echo $this->partial('element-attribute-form.php',
Expand Down Expand Up @@ -44,15 +40,6 @@
?>
</fieldset>
</div>









<?php else: ?>
<div class='vra-subelement-container'>
<div class='vra-element-header'>
Expand All @@ -61,15 +48,13 @@
<fieldset style='display: none'>
<input class='subelement-add' type='submit' value='Add Input' data-namebase='<?php echo $nameBase; ?>' data-subelement-name='<?php echo $subelementName; ?>' data-omeka-element-name='<?php echo $omekaElementName; ?>'></input>
<div class='vra-subelement vra-element-inputs new'>

<?php
if (isset($subelementsData[$subelementName])) {
$attributeNames = array_merge($subelementsData[$subelementName]['attrs'], $globalAttrs);
} else {
$attributeNames = $globalAttrs;
}
?>

<textarea name='<?php echo $nameBase; ?>[newElements][<?php echo $newElementCount; ?>][newSubelements][<?php echo $subelementName; ?>][0][content]' value=''></textarea>
<?php echo $this->partial('element-attribute-form.php',
array(
Expand All @@ -89,4 +74,4 @@
<?php endforeach; ?>
</div>
</fieldset>
</div>
</div>
5 changes: 0 additions & 5 deletions views/admin/ajax/subelement.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php if ($subelementName == 'dates'): ?>

<?php echo $this->partial('dates-form.php',
array(

'elementsData' => $this->elementsData,
'subelementsData' => $this->subelementsData,
'subelementName' => $subelementName,
Expand All @@ -11,12 +9,9 @@
//@todo : how many of these are still actually used?
'globalAttributes' => $this->globalAttrs,
'attributeNames' => $attributeNames,

'attributeObjects' => array()

)
);

?>

<?php else: ?>
Expand Down
Loading

0 comments on commit 4bee8d0

Please sign in to comment.