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

Updates #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions fields/field.selectbox_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function groupRecords($records){
foreach($records as $r){
$data = $r->getData($this->get('id'));
$value = $data['relation_id'];
$primary_field = $this->__findPrimaryFieldValueFromRelationID($data['relation_id']);
$primary_field = $this->findPrimaryFieldValueFromRelationID($data['relation_id']);

if(!isset($groups[$this->get('element_name')][$value])){
$groups[$this->get('element_name')][$value] = array(
Expand Down Expand Up @@ -104,7 +104,7 @@ public function prepareTableValue($data, XMLElement $link=NULL){
foreach($data['relation_id'] as $relation_id){
if((int)$relation_id <= 0) continue;

$primary_field = $this->__findPrimaryFieldValueFromRelationID($relation_id);
$primary_field = $this->findPrimaryFieldValueFromRelationID($relation_id);

if(!is_array($primary_field) || empty($primary_field)) continue;

Expand All @@ -130,11 +130,11 @@ public function prepareTableValue($data, XMLElement $link=NULL){
return trim($output);
}

private function __findPrimaryFieldValueFromRelationID($entry_id){
protected function findPrimaryFieldValueFromRelationID($entry_id){
$field_id = $this->findFieldIDFromRelationID($entry_id);

if (!isset(self::$cacheFields[$field_id])) {
self::$cacheFields[$field_id] = $this->_engine->Database->fetchRow(0, "
self::$cacheFields[$field_id] = Symphony::Database()->fetchRow(0, "
SELECT
f.id,
s.name AS `section_name`,
Expand All @@ -160,7 +160,7 @@ private function __findPrimaryFieldValueFromRelationID($entry_id){
$field = $fm->fetch($field_id);

if (!isset(self::$cacheValues[$entry_id])) {
self::$cacheValues[$entry_id] = $this->_engine->Database->fetchRow(0, sprintf("
self::$cacheValues[$entry_id] = Symphony::Database()->fetchRow(0, sprintf("
SELECT *
FROM `tbl_entries_data_%d`
WHERE `entry_id` = %d
Expand Down Expand Up @@ -210,7 +210,7 @@ public function fetchAssociatedEntrySearchValue($data, $field_id=NULL, $parent_e

if(!is_array($data)) return $data;

$searchvalue = $this->_engine->Database->fetchRow(0,
$searchvalue = Symphony::Database()->fetchRow(0,
sprintf("
SELECT `entry_id` FROM `tbl_entries_data_%d`
WHERE `handle` = '%s'
Expand All @@ -221,11 +221,11 @@ public function fetchAssociatedEntrySearchValue($data, $field_id=NULL, $parent_e
}

public function fetchAssociatedEntryCount($value){
return $this->_engine->Database->fetchVar('count', 0, "SELECT count(*) AS `count` FROM `tbl_entries_data_".$this->get('id')."` WHERE `relation_id` = '$value'");
return Symphony::Database()->fetchVar('count', 0, "SELECT count(*) AS `count` FROM `tbl_entries_data_".$this->get('id')."` WHERE `relation_id` = '$value'");
}

public function fetchAssociatedEntryIDs($value){
return $this->_engine->Database->fetchCol('entry_id', "SELECT `entry_id` FROM `tbl_entries_data_".$this->get('id')."` WHERE `relation_id` = '$value'");
return Symphony::Database()->fetchCol('entry_id', "SELECT `entry_id` FROM `tbl_entries_data_".$this->get('id')."` WHERE `relation_id` = '$value'");
}

public function appendFormattedElement(&$wrapper, $data, $encode=false){
Expand All @@ -236,7 +236,7 @@ public function appendFormattedElement(&$wrapper, $data, $encode=false){
if(!is_array($data['relation_id'])) $data['relation_id'] = array($data['relation_id']);

foreach($data['relation_id'] as $relation_id){
$primary_field = $this->__findPrimaryFieldValueFromRelationID($relation_id);
$primary_field = $this->findPrimaryFieldValueFromRelationID($relation_id);

$value = $primary_field['value'];

Expand All @@ -262,10 +262,10 @@ public function findFieldIDFromRelationID($id){

try{
## Figure out the section
$section_id = $this->_engine->Database->fetchVar('section_id', 0, "SELECT `section_id` FROM `tbl_entries` WHERE `id` = {$id} LIMIT 1");
$section_id = Symphony::Database()->fetchVar('section_id', 0, "SELECT `section_id` FROM `tbl_entries` WHERE `id` = {$id} LIMIT 1");

## Figure out which related_field_id is from that section
$field_id = $this->_engine->Database->fetchVar('field_id', 0, "SELECT f.`id` AS `field_id`
$field_id = Symphony::Database()->fetchVar('field_id', 0, "SELECT f.`id` AS `field_id`
FROM `tbl_fields` AS `f`
LEFT JOIN `tbl_sections` AS `s` ON f.parent_section = s.id
WHERE `s`.id = {$section_id} AND f.id IN ('".@implode("', '", $this->get('related_field_id'))."') LIMIT 1");
Expand All @@ -284,7 +284,7 @@ public function findOptions(array $existing_selection=NULL){
$limit = $this->get('limit');

// find the sections of the related fields
$sections = $this->_engine->Database->fetch("SELECT DISTINCT (s.id), s.name, f.id as `field_id`
$sections = Symphony::Database()->fetch("SELECT DISTINCT (s.id), s.name, f.id as `field_id`
FROM `tbl_sections` AS `s`
LEFT JOIN `tbl_fields` AS `f` ON `s`.id = `f`.parent_section
WHERE `f`.id IN ('" . implode("','", $this->get('related_field_id')) . "')
Expand Down Expand Up @@ -312,7 +312,7 @@ public function findOptions(array $existing_selection=NULL){

if(is_array($results) && !empty($results)){
foreach($results as $entry_id){
$value = $this->__findPrimaryFieldValueFromRelationID($entry_id);
$value = $this->findPrimaryFieldValueFromRelationID($entry_id);
$group['values'][$entry_id] = $value['value'];
}
}
Expand Down Expand Up @@ -377,15 +377,15 @@ public function commit(){
$fields['limit'] = max(1, (int)$this->get('limit'));
$fields['related_field_id'] = implode(',', $this->get('related_field_id'));

$this->_engine->Database->query("DELETE FROM `tbl_fields_".$this->handle()."` WHERE `field_id` = '$id'");
Symphony::Database()->query("DELETE FROM `tbl_fields_".$this->handle()."` WHERE `field_id` = '$id'");

if(!$this->_engine->Database->insert($fields, 'tbl_fields_' . $this->handle())) return false;
if(!Symphony::Database()->insert($fields, 'tbl_fields_' . $this->handle())) return false;

//$sections = $this->get('related_field_id');

$this->removeSectionAssociation($id);

//$section_id = $this->_engine->Database->fetchVar('parent_section', 0, "SELECT `parent_section` FROM `tbl_fields` WHERE `id` = '".$fields['related_field_id']."' LIMIT 1");
//$section_id = Symphony::Database()->fetchVar('parent_section', 0, "SELECT `parent_section` FROM `tbl_fields` WHERE `id` = '".$fields['related_field_id']."' LIMIT 1");

foreach($this->get('related_field_id') as $field_id){
$this->createSectionAssociation(NULL, $id, $field_id, $this->get('show_association') == 'yes' ? true : false);
Expand Down Expand Up @@ -541,7 +541,7 @@ public function displaySettingsPanel(&$wrapper, $errors=NULL){
}

public function createTable(){
return $this->_engine->Database->query(
return Symphony::Database()->query(
"CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . $this->get('id') . "` (
`id` int(11) unsigned NOT NULL auto_increment,
`entry_id` int(11) unsigned NOT NULL,
Expand Down
29 changes: 29 additions & 0 deletions lang/lang.ro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

$about = array(
'name' => '',
'author' => array(
'name' => 'Vlad Ghita',
'email' => 'vlad_micutul@yahoo.com',
),
'release-date' => '2011-05-23'
);

/**
* Field: Select Box Link
*/
$dictionary = array(

'Select Box Link' =>
'Select Box Link',

'Values' =>
'Valori',

'Limit to the %s most recent entries' =>
'Limitează la %s cele mai recente înregistrări',

'Allow selection of multiple options' =>
'Permite selectarea de opţiuni multiple',

);