//do nothing } else { //var names are first (before values) array_push($vars, $val); } $i++; } } else { array_push($vars, $name); } if ($type == 'textfield') { //include file include_once $path . 'textfield.php'; //save remaining vars $size = $temp[3]; wk_submit_textfield($name, $translation, $size); } elseif ($type == 'textarea') { //include file include_once 'textarea.php'; //save remaining vars $cols = $temp[3]; $rows = $temp[4]; wk_submit_textarea($name, $translation, $cols, $rows); } elseif ($type == 'category') { //include file include_once 'category.php'; wk_submit_category($name, $translation); } elseif ($type == 'date') { //include file include_once 'date.php'; wk_submit_date($name, $translation, $language);
//do nothing } else { //var names are first (before values) array_push($vars, $val); } $i++; } } else { array_push($vars, $name); } if ($type == 'textfield') { //include file include_once $path . 'textfield.php'; //save remaining vars $size = $temp[3]; wk_submit_textfield($name, $translation, $size, $object_id, $object_type); } elseif ($type == 'textarea') { //include file include_once 'textarea.php'; //save remaining vars $cols = $temp[3]; $rows = $temp[4]; wk_submit_textarea($name, $translation, $cols, $rows, $object_id, $object_type); } elseif ($type == 'category') { //include file include_once 'category.php'; wk_submit_category($name, $translation, $object_id, $object_type); } elseif ($type == 'date') { //include file include_once 'date.php'; wk_submit_date($name, $translation, $language, $object_id, $object_type);
array_push($vars, $val); } $i++; } } else { array_push($vars, $name); } } if ($type == 'textfield') { //check if user can edit this if (check_user_level($level)) { //include file include_once 'textfield.php'; //save remaining vars $size = $temp[5]; wk_submit_textfield($level, $name, $translation, $default, $size, $object_id, $object_type); } else { echo '<input type="hidden" name="' . $name . '" value="' . $default . '" />'; } } elseif ($type == 'textarea') { //check if user can edit this if (check_user_level($level)) { //include file include_once 'textarea.php'; //save remaining vars $cols = $temp[5]; $rows = $temp[6]; wk_submit_textarea($level, $name, $translation, $default, $cols, $rows, $object_id, $object_type); } else { echo '<input type="hidden" name="' . $name . '" value="' . $default . '" />'; }
/** * Edit a post * * Only post_status = publish is supported for now * When someone edits the picture, it saves it when he uploads it, not on submit * * @return * @param string $language * @param int $post_id * @param string $post_status [publish] * @param array $fields */ function wk_submit_edit($language, $post_id, $post_status, $fields) { include 'languages/' . $language . '.php'; global $current_user; get_currentuserinfo(); //stores the names of vars sent to submit.php $vars = array(); //fetch the post we are trying to edit $post = query_posts('p=' . $post_id); ?> <div class="wk_submit"> <form id="editform" action="/wp-content/plugins/wk_submit/edit.php" method="post"> <?php foreach ($fields as $val) { //seperate type and name $temp = explode('|', $val); $type = $temp[0]; $name = $temp[1]; $translation = $temp[2]; //save names to send to form to be able to know how many vars to expect //if date, add 3 values if ($type == 'date') { array_push($vars, $name . '_day', $name . '_month', $name . '_year'); } elseif ($type == 'time') { array_push($vars, $name . '_hour', $name . '_minute'); } elseif ($type == 'checkbox') { //save and seperate checkbox values $allvalues = explode('~', $temp[3]); //find var_names to add to vars $i = 0; foreach ($allvalues as $val) { if ($i % 2 == 0) { //do nothing } else { //var names are first (before values) array_push($vars, $val); } $i++; } } else { //dont add photos if ($type != 'photo') { array_push($vars, $name); } } if ($type == 'textfield') { //include file include_once 'textfield.php'; //save remaining vars $size = $temp[3]; wk_submit_textfield($name, $translation, $size, $post[0]); } elseif ($type == 'textarea') { //include file include_once 'textarea.php'; //save remaining vars $cols = $temp[3]; $rows = $temp[4]; wk_submit_textarea($name, $translation, $cols, $rows, $post[0]); } elseif ($type == 'category') { //find the category id to send it to category.php $postcat = get_the_category($post[0]->ID); $category = $postcat[0]->cat_ID; //include file include_once 'category.php'; wk_submit_category($name, $translation, $category); } elseif ($type == 'date') { //include file include_once 'date.php'; wk_submit_date($name, $translation, $language, $post[0]); } elseif ($type == 'time') { //include file include_once 'time.php'; //save remaining vars $precision = $temp[3]; wk_submit_time($name, $translation, $precision, $language, $post[0]); } elseif ($type == 'dropdown') { //include file include_once 'dropdown.php'; //save remaining vars //save and seperate dropdown values $allvalues = explode('~', $temp[3]); //format allvalues in couples to send to function $i = 0; foreach ($allvalues as $val) { if ($i % 2 == 0) { $temp2 = $val; } else { $myvalues[$i / 2] = $temp2 . '|' . $val; } $i++; } wk_submit_dropdown($name, $translation, $myvalues, $post[0]); } elseif ($type == 'checkbox') { //include file include_once 'checkbox.php'; //save remaining vars //save and seperate checkbox values $allvalues = explode('~', $temp[3]); //format allvalues in couples to send to function //example :Array ( [0] => Parking|Parking [1] => Μετρό|Metro [2] => Καλοκαιρινό|Summer ) $i = 0; foreach ($allvalues as $val) { if ($i % 2 == 0) { $temp2 = $val; } else { $myvalues[$i / 2] = $temp2 . '|' . $val; } $i++; } wk_submit_checkbox($name, $translation, $myvalues, $post[0]); } elseif ($type == 'photo') { //save remaining vars $width = $temp[3]; $height = $temp[4]; $size = $temp[5]; //add stylesheet url $stylesheet = get_bloginfo('stylesheet_url'); //display the iframe //add the id param to it for the edit and status to display the previous photo $post_id = $post[0]->ID; $params = "post_id={$post_id}&name={$name}&translation={$translation}&width={$width}&height={$height}&size={$size}&stylesheet={$stylesheet}&status=editing"; ?> <iframe name="<?php echo $name; ?> " frameborder="0" marginwidth="0px" marginheight="0px" scrolling="no" src ="/wp-content/plugins/wk_submit/photo.php?<?php echo $params; ?> " width="100%" height="50px"></iframe> <?php } } //transform the vars to send to update_profile.php $vars_send = ''; foreach ($vars as $val) { $vars_send .= $val . '|'; } //remove the last char which is | $vars_send = substr($vars_send, 0, strlen($vars_send) - 1); ?> <input type="hidden" name="vars_send" value="<?php echo $vars_send; ?> " /> <input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?> " /> <input type="hidden" name="post_status" value="<?php echo $post_status; ?> " /> <input type="hidden" name="post_id" value="<?php echo $post_id; ?> " /> <input name="submit" type="submit" id="submit" value="<?php echo $submit_txt; ?> " /> </form> </div> <?php }