diff --git a/advanced_custom_data.php b/advanced_custom_data.php
index da0ce52..7eb8005 100644
--- a/advanced_custom_data.php
+++ b/advanced_custom_data.php
@@ -1,17 +1,19 @@
getCustomData("all"));
$acds = advanced_custom_data::getAllAcds("images");
$checked = 'checked="checked"';
-
-
+
+
$answer = "\n
- \n".gettext('Custom Settings:')."
+ \n" . gettext('Custom Settings:') . "
\n";
-
- foreach($acds as $id=>$row) {
+
+ foreach ($acds as $id => $row) {
$title = trim(strtolower($row['acd_title']));
$answer.= "";
-
- $answer.= "\n
".$row['acd_title']."
";
-
- switch($row['acd_type']) {
-
+
+ $answer.= "\n
" . $row['acd_title'] . "
";
+
+ switch ($row['acd_type']) {
+
case "checkbox" :
$val = (is_array($current) && isset($current[$id])) ? $current[$id] : false;
- $answer .= "\n
";
+ $answer .= "\n
";
break;
-
+
case "input" :
$val = (is_array($current) && isset($current[$id])) ? $current[$id] : false;
$size = $row['acd_opt_input_length'] ? $row['acd_opt_input_length'] : 32;
- $answer.= "\n
";
+ $answer.= "\n
";
break;
-
+
case "textarea" :
$val = (is_array($current) && isset($current[$id])) ? $current[$id] : false;
$rows = $row['acd_opt_textarea_rows'] ? $row['acd_opt_textarea_rows'] : 32;
$cols = $row['acd_opt_textarea_cols'] ? $row['acd_opt_textarea_cols'] : 5;
- $answer.= "\n
";
+ $answer.= "\n
";
break;
}
-
- if($row['acd_desc']) {
- $answer.= "\n
".$row['acd_desc']."
";
+
+ if ($row['acd_desc']) {
+ $answer.= "\n
" . $row['acd_desc'] . "
";
}
$answer.= "\n
";
}
@@ -97,74 +102,73 @@ function custom_data_edit_image($discard, $image, $currentimage) {
}
/**
-* Returns a processed album custom data item
-* called when an album is saved on the backend
-*
-* @param string $discard always empty
-* @param int $prefix the prefix for the album being saved
-* @return string
-*/
+ * Returns a processed album custom data item
+ * called when an album is saved on the backend
+ *
+ * @param string $discard always empty
+ * @param int $prefix the prefix for the album being saved
+ * @return string
+ */
function custom_data_save_album($discard, $prefix) {
- $result = $_POST[$prefix.'x_album_custom_data'];
- if(is_array($result)) {
+ $result = $_POST[$prefix . 'x_album_custom_data'];
+ if (is_array($result)) {
foreach ($result as &$row) {
- $row=sanitize($row,1);
+ $row = sanitize($row, 1);
}
}
-return serialize($result);
+ return serialize($result);
}
-
/**
-* Returns table row(s) for the edit of an album custom data field
-*
-* @param string $discard always empty
-* @param int $prefix prefix of the album being edited
-* @param object $album the album object
-* @return string
-*/
+ * Returns table row(s) for the edit of an album custom data field
+ *
+ * @param string $discard always empty
+ * @param int $prefix prefix of the album being edited
+ * @param object $album the album object
+ * @return string
+ */
function custom_data_edit_album($discard, $album, $prefix) {
$answer;
$acds = advanced_custom_data::getAllAcds("albums");
- $current = unserialize($album->getCustomData("all"));
+ $current = unserialize($album->getCustomData("all"));
$checked = 'checked="checked"';
-
-
+
+
$answer = "\n
- \n".gettext('Custom Settings:')."
+ \n" . gettext('Custom Settings:') . "
\n";
-
- foreach($acds as $id=>$row) {
+
+ foreach ($acds as $id => $row) {
$title = trim(strtolower($row['acd_title']));
$answer.= "";
-
- $answer.= "\n
".$row['acd_title']."
";
- switch($row['acd_type']) {
-
+ $answer.= "\n
" . $row['acd_title'] . "
";
+
+ switch ($row['acd_type']) {
+
case "checkbox" :
$val = (is_array($current) && isset($current[$id])) ? $current[$id] : false;
- $answer .= "\n
";
+ $answer .= "\n
";
break;
-
+
case "input" :
$val = (is_array($current) && isset($current[$id])) ? $current[$id] : false;
$size = $row['acd_opt_input_length'] ? $row['acd_opt_input_length'] : 32;
- $answer.= "\n
";
+ $answer.= "\n
";
break;
-
+
case "textarea" :
$val = (is_array($current) && isset($current[$id])) ? $current[$id] : false;
$rows = $row['acd_opt_textarea_rows'] ? $row['acd_opt_textarea_rows'] : 32;
$cols = $row['acd_opt_textarea_cols'] ? $row['acd_opt_textarea_cols'] : 5;
- $answer.= "\n
";
+ $answer.= "\n
";
break;
}
-
- if($row['acd_desc']) {
- $answer.= "\n
".$row['acd_desc']."
";
+
+ if ($row['acd_desc']) {
+ $answer.= "\n
" . $row['acd_desc'] . "
";
}
$answer.= "\n
";
}
@@ -173,31 +177,33 @@ function custom_data_edit_album($discard, $album, $prefix) {
}
function custom_admin_head($discard) {
- echo ' ';
+ echo ' ';
}
function getAcd($type, $field = FALSE) {
$allAcds = advanced_custom_data::getAllAcds();
- if($type == "album") {
+ if ($type == "album") {
global $_zp_current_album;
$curAcd = unserialize($_zp_current_album->getCustomData("all"));
} elseif ($type == "image") {
global $_zp_current_image;
$curAcd = unserialize($_zp_current_image->getCustomData("all"));
- } else return false;
-
- if (!is_array($curAcd)) return NULL;
-
+ } else
+ return false;
+
+ if (!is_array($curAcd))
+ return NULL;
+
$answer = array();
- foreach($curAcd as $id=>$value) {
- if(isset($allAcds[$id])) {
+ foreach ($curAcd as $id => $value) {
+ if (isset($allAcds[$id])) {
$answer[$allAcds[$id]['aux']] = $value;
}
}
-
+
if ($field && isset($answer[$field])) {
return $answer[$field];
} else if ($field) {
@@ -206,10 +212,11 @@ function getAcd($type, $field = FALSE) {
return $answer;
}
-
// OPTION INTERFACE CLASS
class advanced_custom_data {
+
var $ratingstate;
+
/**
* class instantiation function
*
@@ -218,62 +225,64 @@ function advanced_custom_data() {
setOptionDefault('show_button', 1);
}
-
/**
* Reports the supported options
*
* @return array
*/
function getOptionsSupported() {
- return array(gettext('new_field') => array('key' => 'show_button', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
- 'checkboxes' => array(gettext("Show Button") => "1"),
- 'order' =>1,
- 'desc' => gettext('Whether to show the button')),
- );
+ return array(gettext('new_field') => array('key' => 'show_button', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
+ 'checkboxes' => array(gettext("Show Button") => "1"),
+ 'order' => 1,
+ 'desc' => gettext('Whether to show the button')),
+ );
}
function handleOption($option, $currentValue) {
+
}
static function overviewbutton($buttons) {
+ if (zp_loggedin(ADMIN_RIGHTS)) {
- $buttons[] = array(
- 'category'=>gettext('Advanced Custom Data'),
- 'enable'=>'true',
- 'button_text'=>gettext('Create ACD entries'),
- 'formname'=>'advanced_custom_data_button',
- 'action'=>WEBPATH.'/plugins/advanced_custom_data/acd_create.php?page=overview&tab=create_fields',
- 'icon'=>'images/arrow_up.png',
- 'alt'=>'',
- 'hidden'=>' ',
- 'rights'=>ADMIN_RIGHTS,
- 'title'=>'Create new custom data fields'
- );
- $buttons[] = array(
- 'category'=>gettext('Advanced Custom Data'),
- 'enable'=>'true',
- 'button_text'=>gettext('Edit exisiting ACD entries'),
- 'formname'=>'advanced_custom_data_button',
- 'action'=>WEBPATH.'/plugins/advanced_custom_data/acd_edit.php?page=overview&tab=manage_fields',
- 'icon'=>'images/arrow_up.png',
- 'alt'=>'',
- 'hidden'=>' ',
- 'rights'=>ADMIN_RIGHTS,
- 'title'=>'Manage your custom data fields'
- );
+ $buttons[] = array(
+ 'category' => gettext('Advanced Custom Data'),
+ 'enable' => 'true',
+ 'button_text' => gettext('Create ACD entries'),
+ 'formname' => 'advanced_custom_data_button',
+ 'action' => WEBPATH . '/plugins/advanced_custom_data/acd_create.php?page=overview&tab=create_fields',
+ 'icon' => 'images/arrow_up.png',
+ 'alt' => '',
+ 'hidden' => ' ',
+ 'rights' => ADMIN_RIGHTS,
+ 'title' => 'Create new custom data fields'
+ );
+ $buttons[] = array(
+ 'category' => gettext('Advanced Custom Data'),
+ 'enable' => 'true',
+ 'button_text' => gettext('Edit exisiting ACD entries'),
+ 'formname' => 'advanced_custom_data_button',
+ 'action' => WEBPATH . '/plugins/advanced_custom_data/acd_edit.php?page=overview&tab=manage_fields',
+ 'icon' => 'images/arrow_up.png',
+ 'alt' => '',
+ 'hidden' => ' ',
+ 'rights' => ADMIN_RIGHTS,
+ 'title' => 'Manage your custom data fields'
+ );
+ }
return $buttons;
}
-
+
static function getAllAcds($category = FALSE) {
$acd = array();
$count = 0;
- $result = query('SELECT * FROM'.prefix('plugin_storage').' WHERE `type`="advanced_custom_data" ');
+ $result = query('SELECT * FROM' . prefix('plugin_storage') . ' WHERE `type`="advanced_custom_data" ');
while ($row = db_fetch_assoc($result)) {
$id = $row['id'];
$data = unserialize($row['data']);
if (!$category || ($data['acd_category'] == $category) || ($data['acd_category'] == 'both')) {
$acd[$id]['aux'] = $row['aux'];
- foreach($data as $key=>$value) {
+ foreach ($data as $key => $value) {
$acd[$id][$key] = $value;
$acd[$id][$key] = $value;
}
@@ -283,4 +292,5 @@ static function getAllAcds($category = FALSE) {
}
}
+
?>
diff --git a/advanced_custom_data/acd_create.php b/advanced_custom_data/acd_create.php
index d2d403c..79454c0 100644
--- a/advanced_custom_data/acd_create.php
+++ b/advanced_custom_data/acd_create.php
@@ -1,57 +1,56 @@
'../plugins/advanced_custom_data/acd_create.php?page=overview&tab=create_fields',
- gettext('Manage exisiting ACD entries') => '../plugins/advanced_custom_data/acd_edit.php?page=overview&tab=manage_fields');
+ gettext('Create new ACD entry') => '../plugins/advanced_custom_data/acd_create.php?page=overview&tab=create_fields',
+ gettext('Manage exisiting ACD entries') => '../plugins/advanced_custom_data/acd_edit.php?page=overview&tab=manage_fields');
if (isset($_GET['update'])) {
XSRFdefender('advanced_custom_data');
$acd_type = $_POST['acd_type'];
-
+
if ($acd_type) {
$msg = saveAcds();
}
}
-printAdminHeader('overview',gettext('Advanced Custom Data'));
+printAdminHeader('overview', gettext('Advanced Custom Data'));
?>
-';
-printTabs();
-echo "\n" . '';
-?>
-
-
+ ';
+ printTabs();
+ echo "\n" . '
';
+ ?>
+
+
-".$clear."";
-if($msg) {
- echo "\n
".$msg."
";
-} elseif ($msg === FALSE) {
- echo "\n
Entry created.
";
-}
-?>
+ " . $clear . "";
+ if ($msg) {
+ echo "\n
" . $msg . "
";
+ } elseif ($msg === FALSE) {
+ echo "\n
Entry created.
";
+ }
+ ?>
-
';
-echo "\n" . '
';
+
+
+
+
+
+
+ " >
+
+
+
+
+
+
-printAdminFooter();
-echo "\n";
-echo "\n";
-?>
+ ';
+ echo "\n" . '
';
+ echo "\n" . '
';
+
+ printAdminFooter();
+
+ echo "\n ";
@@ -48,82 +48,85 @@