public static function tchsp_shortcode_int($arr) { if (!is_array($arr)) { return ''; } $imageli = ""; $tch = ""; $id = isset($arr['id']) ? $arr['id'] : '0'; $data = array(); $data = tchsp_cls_dbquery::tchsp_gallery_details_select($id); if (count($data) > 0) { $form_gallery = array('gal_id' => $data[0]['gal_id'], 'gal_title' => $data[0]['gal_title'], 'gal_width' => $data[0]['gal_width'], 'gal_height' => $data[0]['gal_height'], 'gal_controls' => $data[0]['gal_controls'], 'gal_autointerval' => $data[0]['gal_autointerval'], 'gal_intervaltime' => $data[0]['gal_intervaltime'], 'gal_animation' => $data[0]['gal_animation'], 'gal_random' => $data[0]['gal_random']); $gal_width = $form_gallery["gal_width"]; $gal_height = $form_gallery["gal_height"]; $gal_controls = $form_gallery["gal_controls"]; $gal_autointerval = $form_gallery["gal_autointerval"]; $gal_intervaltime = $form_gallery["gal_intervaltime"]; $gal_animation = $form_gallery["gal_animation"]; $gal_width1 = $gal_width + 4; $gal_height1 = $gal_height + 4; $image = tchsp_cls_dbquery::tchsp_image_details_load($form_gallery["gal_id"], $form_gallery["gal_random"]); if (count($image) > 0) { foreach ($image as $img) { $imageli = $imageli . '<li>'; $imageli = $imageli . '<a href="' . $img['img_link'] . '" target="_target">'; $imageli = $imageli . '<img alt="' . $img['img_title'] . '" src="' . $img['img_imageurl'] . '" />'; $imageli = $imageli . '</a>'; $imageli = $imageli . '</li>'; } if ($imageli != "") { $tch = $tch . "<style type='text/css' media='screen'>\r\r\n\t\t\t\t\t#tchsp { height: 1%; margin: 30px 0 0; overflow:hidden; position: relative; padding: 0 50px 10px; }\r\r\n\t\t\t\t\t#tchsp .viewport { height: " . $gal_height1 . "px; overflow: hidden; position: relative; }\r\r\n\t\t\t\t\t#tchsp .buttons { background: #C01313; border-radius: 35px; display: block; position: absolute;\r\r\n\t\t\t\t\ttop: 40%; left: 0; width: 35px; height: 35px; color: #fff; font-weight: bold; text-align: center; line-height: 35px; text-decoration: none;\r\r\n\t\t\t\t\tfont-size: 22px; }\r\r\n\t\t\t\t\t#tchsp .next { right: 0; left: auto;top: 40%; }\r\r\n\t\t\t\t\t#tchsp .buttons:hover{ color: #C01313;background: #fff; }\r\r\n\t\t\t\t\t#tchsp .disable { visibility: hidden; }\r\r\n\t\t\t\t\t#tchsp .overview { list-style: none; position: absolute; padding: 0; margin: 0; width: " . $gal_width1 . "px; left: 0 top: 0; }\r\r\n\t\t\t\t\t#tchsp .overview li{ float: left; margin: 0 20px 0 0; padding: 1px; height: " . $gal_height . "px; border: 1px solid #dcdcdc; width: " . $gal_width . "px;}\r\r\n\t\t\t\t\t</style>"; $tch = $tch . '<div id="tchsp">'; $tch = $tch . '<a class="buttons prev" href="#"><</a>'; $tch = $tch . '<div class="viewport">'; $tch = $tch . '<ul class="overview">'; $tch = $tch . $imageli; $tch = $tch . '</ul>'; $tch = $tch . '</div>'; $tch = $tch . '<a class="buttons next" href="#">></a>'; $tch = $tch . '</div>'; $tch = $tch . '<script type="text/javascript">'; $tch = $tch . 'jQuery(document).ready(function(){'; $tch = $tch . "jQuery('#tchsp').tinycarousel({ buttons: " . $gal_controls . ", interval: " . $gal_autointerval . ", intervalTime: " . $gal_intervaltime . ", animationTime: " . $gal_animation . " });"; $tch = $tch . '});'; $tch = $tch . '</script>'; } } } else { $tch = __('Please check your short code. Gallery does not exists for this Id.', TCHSP_TDOMAIN); } return $tch; }
public static function tchsp_activation() { global $wpdb; $prefix = $wpdb->prefix; $tchsp_plugin_ver = "1.2"; $tchsp_plugin_installed = ""; $tchsp_plugin_installed = get_option("tchsp_plugin_installed"); if ($tchsp_plugin_installed == "") { add_option('tchsp_plugin_installed', "1.2"); } else { update_option("tchsp_plugin_installed", $tchsp_plugin_ver); } // Plugin tables $array_tables_to_plugin = array('tinycarousel_gallery', 'tinycarousel_image'); $errors = array(); // loading the sql file, load it and separate the queries $sql_file = TCHSP_DIR . 'sql' . DS . 'tiny-carousel-tbl.sql'; $prefix = $wpdb->prefix; $handle = fopen($sql_file, 'r'); $query = fread($handle, filesize($sql_file)); fclose($handle); $query = str_replace('CREATE TABLE IF NOT EXISTS `', 'CREATE TABLE IF NOT EXISTS `' . $prefix, $query); $queries = explode('-- SQLQUERY ---', $query); // run the queries one by one $has_errors = false; foreach ($queries as $qry) { $wpdb->query($qry); } // list the tables that haven't been created $missingtables = array(); foreach ($array_tables_to_plugin as $table_name) { if (strtoupper($wpdb->get_var("SHOW TABLES like '" . $prefix . $table_name . "'")) != strtoupper($prefix . $table_name)) { $missingtables[] = $prefix . $table_name; } } // add error in to array variable if ($missingtables) { $errors[] = __('These tables could not be created on installation ' . implode(', ', $missingtables), TCHSP_TDOMAIN); $has_errors = true; } // if error call wp_die() if ($has_errors) { wp_die(__($errors[0], TCHSP_TDOMAIN)); return false; } else { tchsp_cls_dbquery::tchsp_image_details_default(); } return true; }
public static function tchsp_image_details_default() { global $wpdb; $prefix = $wpdb->prefix; $result = tchsp_cls_dbquery::tchsp_gallery_details_count(0); if ($result == 0) { $sql = $wpdb->prepare("INSERT INTO `" . $prefix . "tinycarousel_gallery` (`gal_title`, `gal_width`,`gal_height`) \r\r\n\t\t\tVALUES (%s, %d, %d)", array("Default Gallery", 100, 75)); $wpdb->query($sql); } $result = tchsp_cls_dbquery::tchsp_image_details_count(0); if ($result == 0) { $img_title1 = "Tiny Carousel Horizontal Slider Plus Image 1"; $img_title2 = "Tiny Carousel Horizontal Slider Plus Image 2"; $img_title3 = "Tiny Carousel Horizontal Slider Plus Image 3"; $img_title4 = "Tiny Carousel Horizontal Slider Plus Image 4"; $img_imageurl1 = TCHSP_URL . "images/Sing_1.jpg"; $img_imageurl2 = TCHSP_URL . "images/Sing_2.jpg"; $img_imageurl3 = TCHSP_URL . "images/Sing_3.jpg"; $img_imageurl4 = TCHSP_URL . "images/Sing_4.jpg"; //$img_imageurl5 = TCHSP_URL . "images/Sing_5.jpg"; //$img_imageurl6 = TCHSP_URL . "images/Sing_6.jpg"; $sql = $wpdb->prepare("INSERT INTO `" . $prefix . "tinycarousel_image` (`img_title`, `img_imageurl`,`img_gal_id`) \r\r\n\t\t\tVALUES (%s, %s, %d)", array($img_title1, $img_imageurl1, "1")); $wpdb->query($sql); $sql = $wpdb->prepare("INSERT INTO `" . $prefix . "tinycarousel_image` (`img_title`, `img_imageurl`,`img_gal_id`) \r\r\n\t\t\tVALUES (%s, %s, %d)", array($img_title2, $img_imageurl2, "1")); $wpdb->query($sql); $sql = $wpdb->prepare("INSERT INTO `" . $prefix . "tinycarousel_image` (`img_title`, `img_imageurl`,`img_gal_id`) \r\r\n\t\t\tVALUES (%s, %s, %d)", array($img_title3, $img_imageurl3, "1")); $wpdb->query($sql); $sql = $wpdb->prepare("INSERT INTO `" . $prefix . "tinycarousel_image` (`img_title`, `img_imageurl`,`img_gal_id`) \r\r\n\t\t\tVALUES (%s, %s, %d)", array($img_title4, $img_imageurl4, "1")); $wpdb->query($sql); //$sql = $wpdb->prepare("INSERT INTO `".$prefix."tinycarousel_image` (`img_title`, `img_imageurl`,`img_gal_id`) //VALUES (%s, %s, %d)", array($img_title, $img_imageurl5, "1")); //$wpdb->query($sql); //$sql = $wpdb->prepare("INSERT INTO `".$prefix."tinycarousel_image` (`img_title`, `img_imageurl`,`img_gal_id`) //VALUES (%s, %s, %d)", array($img_title, $img_imageurl6, "1")); //$wpdb->query($sql); } return true; }
<option value='NO'>NO</option> </select> <p><?php _e('Do you want the picture to show in your galler?', TCHSP_TDOMAIN); ?> </p> <label for="tag-a"><?php _e('Gallery title', TCHSP_TDOMAIN); ?> </label> <select name="img_gal_id" id="img_gal_id"> <option value=''>Select</option> <?php $galleryData = array(); $galleryData = tchsp_cls_dbquery::tchsp_gallery_details_select(0); if (count($galleryData) > 0) { foreach ($galleryData as $data) { ?> <option value='<?php echo $data['gal_id']; ?> '><?php echo $data['gal_title']; ?> </option><?php } } ?> </select>
$form['gal_controls'] = isset($_POST['gal_controls']) ? $_POST['gal_controls'] : ''; $form['gal_autointerval'] = isset($_POST['gal_autointerval']) ? $_POST['gal_autointerval'] : ''; $form['gal_intervaltime'] = isset($_POST['gal_intervaltime']) ? $_POST['gal_intervaltime'] : ''; if ($form['gal_intervaltime'] == '') { $tchsp_errors[] = __('Enter auto interval time in millisecond. (Ex: 1500)', TCHSP_TDOMAIN); $tchsp_error_found = TRUE; } $form['gal_animation'] = isset($_POST['gal_animation']) ? $_POST['gal_animation'] : ''; if ($form['gal_animation'] == '') { $tchsp_errors[] = __('Enter animation duration in millisecond. (Ex: 1000)', TCHSP_TDOMAIN); $tchsp_error_found = TRUE; } $form['gal_random'] = isset($_POST['gal_random']) ? $_POST['gal_random'] : ''; // No errors found, we can add this Group to the table if ($tchsp_error_found == FALSE) { $action = tchsp_cls_dbquery::tchsp_gallery_details_act($form, "ins"); if ($action == "sus") { $tchsp_success = __('New details was successfully added.', TCHSP_TDOMAIN); } elseif ($action == "err") { $tchsp_success = __('Oops unexpected error occurred.', TCHSP_TDOMAIN); $tchsp_error_found = TRUE; } // Reset the form fields $form = array('gal_id' => '', 'gal_title' => '', 'gal_width' => '', 'gal_height' => '', 'gal_controls' => '', 'gal_autointerval' => '', 'gal_intervaltime' => '', 'gal_animation' => '', 'gal_random' => ''); } } if ($tchsp_error_found == TRUE && isset($tchsp_errors[0]) == TRUE) { ?> <div class="error fade"> <p><strong><?php
if ($data['img_linktarget'] == "_blank") { echo "Open New Window"; } else { echo "Open Same Window"; } ?> </td> <td><?php echo $data['img_display']; ?> </td> <td> <?php $galleryData = array(); $galleryData = tchsp_cls_dbquery::tchsp_gallery_details_select($data['img_gal_id']); if (count($galleryData) > 0) { foreach ($galleryData as $data) { echo $data['gal_title']; } } ?> </td> </tr> <?php $i = $i + 1; } } else { ?> <tr><td colspan="7" align="center"><?php