Advertisement
Viruthagiri

cv-edit.php

Mar 20th, 2012
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $lang = get_bloginfo('language'); // 'en-US';
  3. ?>
  4.     <script src="<?php bloginfo('template_url'); ?>/profile/jquery.js" type="text/javascript"></script>
  5.     <script src="<?php bloginfo('template_url'); ?>/profile/ajaxupload.js" type="text/javascript"></script>
  6.     <?php if($_SERVER["HTTP_HOST"] == 'localhost') : ?>
  7.     <link href="style.css" rel="stylesheet" type="text/css" />
  8.     <link rel="stylesheet" href="profile/style.css" type="text/css" />
  9.     <?php endif ?>
  10.     <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/profile/style.css" type="text/css" />
  11.  
  12.     <script>        
  13.     $(document).ready(function(){
  14.         $('#p_picture').hide(); //, 'label[for=#p_picture]'
  15.         $("label.p_picture").hide();
  16.         var thumb = $('img#thumb');
  17.         new AjaxUpload('imageUpload', {
  18.             action: '<?php bloginfo('template_url'); ?>/profile/upload.php', //$('form#picture').attr('action'),
  19.             name: 'qqfile',
  20.             onSubmit: function(file, extension) {
  21.             $('div.preview').addClass('loading');
  22.         },
  23.         onComplete: function(file, response) {
  24.             var response_ajax = '<?php bloginfo('wpurl'); ?>/wp-content/uploads/'+response;
  25.         $("#p_picture").val(response);
  26.         thumb.load(function(){
  27.             $('div.preview').removeClass('loading');
  28.             thumb.unbind();
  29.         });
  30.         thumb.attr('src', response_ajax);
  31.           //alert(response_ajax);
  32.         }
  33.         });
  34.  
  35.         $("#profileDeleteForm").click(function() {
  36.           $(this).remove();
  37.         });
  38.          
  39.         $("#profileDeleteForm").confirm({
  40.           msg:'Do you really want to delete this button?',
  41.           timeout:3000
  42.         });
  43.  
  44.  
  45.  
  46.     });
  47.    
  48.     function deletechecked(message)
  49.     {
  50.         var answer = confirm(message)
  51.         if (answer){
  52.             document.messages.submit();
  53.         }
  54.        
  55.         return false;  
  56.     }  
  57.     </script>  
  58.     <style>
  59.         div.preview { float: left; width: 200px; height: 150px; margin:5px; border: 1px solid #CCCCCC; }
  60.         div.preview.loading { background: url(<?php bloginfo('template_url'); ?>/profile/images/loading.gif) no-repeat 90px 65px; }
  61.         div.preview.loading img {display: none; }
  62.     </style>
  63. <?php do_shortcode('[theme-my-login login_template="login-templates/login-form.php" register_template="login-templates/register-form.php" lostpassword_template="login-templates/lostpassword-form.php" resetpass_template="login-templates/resetpass-form.php" user_template="login-templates/user-panel.php" profile_template="login-templates/profile-form.php" before_widget="" after_widget="" before_title="" after_title="" show_reg_link="false"]'); ?>
  64. <?php edit_post_link('Edit', ' | ', ' | '); ?>
  65. <div class="main-subject">
  66.     <?php if($lang == 'en-US'): ?>
  67.         Welcome to resume creation wizard,..
  68.     <?php else: ?>
  69.         &Ouml;zge&ccedil;mi&#351; olu&#351;turma sihirbaz&#305;na ho&#351;geldiniz,..
  70.     <?php endif; ?>
  71. </div>
  72. <?php if(!is_user_logged_in()) : ?>
  73.     <?php if($lang == 'en-US'): ?>
  74.     <div class="main-text">
  75.         To continue, please <a href="<?php echo home_url(); ?>/login?action=register"><strong>register</strong></a>, to our website,<br />
  76.         if you are already registered, please<b> <a href="<?php echo home_url(); ?>/login">login</a></b> to your account.
  77.     </div>
  78.     <?php else: ?>
  79.     <div class="main-text">
  80.         &Ouml;zge&ccedil;mi&#351; bilgilerini olu&#351;turman&#305;z i&ccedil;in,
  81.         Sitemize <a href="<?php echo home_url(); ?>/login?action=register"><strong>&uuml;ye olmal&#305;</strong></a>,<br />
  82.         &uuml;ye iseniz<b> <a href="<?php echo home_url(); ?>/login">kullan&#305;c&#305; giri&#351;i</a></b> yapman&#305;z gerekmektedir.
  83.     </div>
  84.     <?php endif; ?>
  85. <?php else : ?>
  86. <div class="main-text">
  87. <?php
  88. //Save Function
  89. require_once( dirname(__FILE__) . '/../../plugins/magic-fields/RCCWP_Post.php' );
  90. //Picture Upload Function
  91. require_once( dirname(__FILE__) . '/../../plugins/magic-fields/RCCWP_WritePostPage.php' );
  92.  
  93. global $metaData;
  94.  
  95. function check_profile(){
  96.     global $post, $current_user, $post_category, $post_title, $post_content, $post_id, $profileData, $metaData, $lang;
  97.     if($lang == 'en-US'){ $text = 'Profile'; } else{ $text = 'Profil'; }
  98.     $post_category = get_cat_ID($text);
  99.     $profileData = query_posts('author='.$current_user->ID.
  100.         '&post_type=post&post_status=publish&posts_per_page=1&orderby=date&order=DESC&cat='.$post_category.'');
  101.  
  102.     if ( have_posts() ) : while ( have_posts() ) : the_post(); //echo $post->ID;
  103.         $post_title = get_the_title();
  104.         $post_content = get_the_content();
  105.         $post_id = $post->ID;
  106.  
  107.     endwhile; else:
  108.         //echo "Lutfen once profilinizi olusturun";
  109.     endif;
  110. }
  111.  
  112. function get_form_data(){
  113.     //Get post verileri varsa burada topluyoruz
  114.     global $_SERVER, $_POST, $_GET;
  115.     if(empty($_POST)){ $data = $_GET; }else{ $data = $_POST; }
  116.     foreach ($data as $k=>$v){
  117.         $vars[$k] = $v; //echo $k.': '; echo $v.'<br />';
  118.     }
  119.     //var_dump($vars);
  120.     return $vars;
  121. }
  122.  
  123. //Form verilerini alalim.
  124. $formData = get_form_data();
  125. //Veritabanina yazmak icin butun verileri alalim.
  126. check_profile();
  127.  
  128. // Check if the form was submitted
  129. if( $_SERVER['REQUEST_METHOD'] == 'POST' && !empty( $formData['post_action'] )) {
  130.  
  131.         if($formData['post_action'] == 'delete'){ //wp_delete_post( $post_id, $force_delete = 1 )
  132.         if(wp_delete_post( $post_id, $force_delete = 1 ))
  133.             { echo $post_id.' id\'li profiliniz silinmistir.'; }
  134.         else { echo "Bir hata olustu islem tamamlanamadi."; }
  135.     }
  136.    
  137.     // Add the content of the form to $post as an array
  138.     $post = array(
  139.         'post_title'    => $formData['post_title'],
  140.         'post_content'  => $formData['post_content'],
  141.         'post_category' => array($formData['post_category']),  // Usable for custom taxonomies too
  142.         'tags_input'    => $formData['post_tags'],
  143.         'post_status'   => 'publish',           // Choose: publish, preview, future, etc.
  144.         'post_type'     => $formData['post_type'],  // Use a custom post type if you want to,
  145.         'post_name'     => $post_id.'-'.$formData['post_title']  // Sluq
  146.     );
  147.  
  148.     if(empty($profileData)){
  149.         if($lang == 'en-US'){ echo "<h2>Your resume has been created.</h1>"; }
  150.         else{ echo "<h2>Profiliniz olu&#351;turuldu.</h1>"; }      
  151.         $new_id = wp_insert_post($post);  // Pass  the value of $post to WordPress the insert function
  152.         RCCWP_Post::SaveCustomFields($new_id);
  153.     }
  154.     else{
  155.         if($lang == 'en-US'){ echo "<h2>Your profile has been updated.</h2>"; }
  156.         else{ echo "<h2>Profiliniz g&uuml;ncellendi.</h2>"; }  
  157.         $post['edit_date'] = true;
  158.         $post['ID'] = $post_id;
  159.         //$post['post_content'] = 'This is the updated content.';
  160.         //print_r( $post );
  161.         wp_update_post($post);
  162.         RCCWP_Post::SaveCustomFields($post_id);
  163.         //wp_publish_post($post['ID']);
  164.     }
  165. }
  166.  
  167. //Yeni eklenen verileri alalimki asagidaki formu yeni verilerle sunalim.
  168. check_profile();
  169.     if($lang == 'en-US'){ echo "Welcome, <b>".$current_user->user_login."</b><br \>"; }
  170.     else{ echo "Ho&#351;geldin, <b>".$current_user->user_login."</b><br \>"; }
  171.     if(empty($profileData)){
  172.         if($lang == 'en-US'){ echo 'Currently there are no resume, please create your resume.'; }
  173.         else{ echo 'Hen&uuml;z &ouml;zge&ccedil;mi&#351;ini olu&#351;turmam&#305;&#351;s&#305;n,
  174.         <br />L&uuml;tfen &ouml;zge&ccedil;mi&#351;inizi olu&#351;turunuz.';  }
  175.     }
  176.    
  177.     $bUrl = get_bloginfo('wpurl');
  178.     if($bUrl == "http://localhost/atol2"){ $mf_panel_id = 3; $mf_group_id = 13; }
  179.     else{ $mf_panel_id = 1; $mf_group_id = 2; }
  180.  
  181. ?>
  182. </div>
  183. <!-- New Post Form -->
  184. <div class="main-subject">
  185.     <?php if($lang == 'en-US'): ?>
  186.     Resume details,...
  187.     <?php else: ?>
  188.     &Ouml;zge&ccedil;mi&#351; detaylar&#305;,...
  189.     <?php endif; ?>
  190. </div>
  191.     <div class="main-text">
  192.     <form action="?" id="profileForm" name="profileForm" method="POST">
  193.     <input type='hidden' name='rc-custom-write-panel-verify-key' id='rc-custom-write-panel-verify-key' value='<?php echo wp_create_nonce('rc-custom-write-panel'); ?>'/>
  194.     <input type='hidden' name='rc-cwp-change-custom-write-panel-id' id='rc-cwp-change-custom-write-panel-id' value='<?php echo $mf_panel_id; ?>' />
  195.     <input type='hidden' name='rc-cwp-custom-write-panel-id' id='rc-cwp-custom-write-panel-id' value='<?php echo $mf_panel_id; ?>' />
  196.     <input type='hidden' name='magicfields_remove_files' id='magicfields_remove_files' value=''/>
  197.     <input type="hidden" name="post_action" value="post" />
  198.     <input type="hidden" name="post_category" id="post_category" value="<?php echo $post_category; ?>" />
  199.     <!--<input type="hidden" name="npost_type" id="npost_type" value="post" /> -->
  200.    
  201.        
  202.     <label for="post_title">
  203.     <?php if($lang == 'en-US'): ?>
  204.         Your profession followed by your name and surname
  205.         <br /><small>example: Captain Yavuz Porsuk</small>
  206.     <?php else: ?>
  207.         Varsa &Uuml;nvan&#305;n&#305;z, Ad&#305;n&#305;z Soyad&#305;n&#305;z
  208.         <small>&Ouml;rn: Kaptan Yavuz Porsuk</small>
  209.     <?php endif; ?>
  210.     </label>
  211.     <br />
  212.     <input type="text" id="post_title" name="post_title" value="<?php echo $post_title; ?>" tabindex="1" size="22" />
  213.     <br clear="all" />
  214.    
  215.     <label for="post_content">
  216.         <?php
  217.             if($lang == 'en-US'){ echo 'A short description about yourself and your references'; }
  218.             else{ echo 'Kendiniz hakk&#305;nda k&#305;sa &ouml;zge&ccedil;mi&#351; (Referanslar&#305;n&#305;z),'; }
  219.         ?>
  220.     </label>
  221.     <br />
  222.     <textarea id="post_content" name="post_content" tabindex="3" cols="50" rows="6"><?php echo $post_content; ?></textarea>
  223.     <br clear="all" />
  224.     <div id="picture" class="container">
  225.         <div class="preview">
  226.         <?php if(get('p_picture')): ?>
  227.         <img id="thumb" width="200px" height="150px" src="<?php echo bloginfo('template_url').'/wp-t/?w=200&h=150&src='.get('p_picture'); ?>" />
  228.         <?php else: ?>
  229.         <img id="thumb" width="200px" height="150px" src="<?php bloginfo('template_url'); ?>/profile/images/captain-icon.png" />
  230.         <?php endif ?>
  231.         </div>
  232.        
  233.       <label>
  234.         <?php if($lang == 'en-US'): ?>
  235.             Photo uploader,<br />
  236.             <font color="#FF0000"><b>Please upload a decent photo with uniform </b></font>
  237.             <br />Please choose a photo from your computer
  238.         <?php else: ?>
  239.             Resim y&uuml;kleme sihirbaz&#305;,<br />
  240.             <font color="#FF0000"><b>&Uuml;niformal&#305; resmi olmayanlar&#305;n cv'si yay&#305;nlanmayacakt&#305;r.</b></font>
  241.             <br />L&uuml;tfen bilgisayar&#305;n&#305;zdan bir resim se&ccedil;iniz.
  242.         <?php endif; ?>  
  243.       </label>
  244.       <br />
  245.         <input type="file" id="imageUpload" size="20" value="" />
  246.         <button type="submit" class="button">Save</button>
  247.         <noscript>
  248.             <?php
  249.                 if($lang == 'en-US'){ echo 'To upload a picture please enable javascript in your browser'; }
  250.                 else{ echo '<p>Resim y&uuml;klemek i&ccedil;in Browser\'inizin JavaScript &ouml;zelli&#287;inin aktif olmas&#305; gerekir.</p>'; }
  251.              ?>
  252.             <!-- or put a simple form for upload here -->
  253.         </noscript>
  254.     </div>
  255.     <br clear="all" />
  256.  
  257.     <?php
  258.  
  259. $customFields = RCCWP_CustomGroup::GetCustomFields($mf_group_id);
  260.  
  261. foreach($customFields as $customField) {
  262.        
  263.    $customFieldValue = get($customField->name);
  264.    $customFieldLabel = get($customField->description);
  265.    if(empty($customFieldValue)){ $customFieldValue = $customField->default_value; }
  266.        
  267.    if($customField->type == 'Textbox'){
  268.       echo '<label for="'.$customField->name.'">'.$customField->description.'</label><br />';
  269.       echo '<input type="text" name="magicfields['.$customField->name.'][1][1]" id="'.$customField->name.'" value="'.$customFieldValue.'" />';
  270.       echo '<br clear="all" />';
  271.    }
  272.       elseif($customField->type == 'Multiline Textbox'){
  273.       echo '<label for="'.$customField->name.'">'.$customField->description.'</label><br />';
  274.       echo '<textarea name="magicfields['.$customField->name.'][1][1]" id="'.$customField->name.'">'.$customFieldValue.'</textarea>';
  275.       echo '<br clear="all" />';
  276.    }
  277.    elseif($customField->type == 'Dropdown List'){
  278.       echo '<label for="'.$customField->name.'">'.$customField->description.'</label><br />';
  279.       echo '<select name="magicfields['.$customField->name.'][1][1]" style="width:250px;">'."\n";
  280.       $dropDownListDefaultValues = $customField->options;
  281.          
  282.          foreach($dropDownListDefaultValues as $defaultValue){
  283.         $selected = ' ';
  284.         if($defaultValue == $customFieldValue)
  285.            { $selected = ' selected="selected "'; }
  286.            
  287.         echo '<option value="'.$defaultValue.'"'.$selected.'>'.$defaultValue.'</option>';
  288.      }
  289.       echo '</select>';
  290.       echo '<br clear="all" />';
  291.    }
  292.    elseif($customField->type == 'Checkbox List'){
  293.       echo '<label for="'.$customField->name.'">'.$customField->description.'</label><br />';
  294.       $dropDownListDefaultValues = $customField->options;
  295.          
  296.          foreach($dropDownListDefaultValues as $defaultValue){
  297.         $selected = ' ';
  298.         if(in_array($defaultValue, $customFieldValue))
  299.            { $selected = ' checked="checked" '; }
  300.         echo '<label for="magicfields['.$customField->name.'][1][1]_'.$defaultValue.'">'.$defaultValue;
  301.         echo '<input name="magicfields['.$customField->name.'][1][1][]" id="magicfields['.$customField->name.'][1][1]_'.$defaultValue.'" type="checkbox" value="'.$defaultValue.'"'.$selected.'/></label>';
  302.      }
  303.       echo '<br clear="all" />';
  304.    }
  305.    elseif($customField->type == 'Listbox'){
  306.       echo '<label for="'.$customField->name.'">'.$customField->description.'</label><br />';
  307.       $dropDownListDefaultValues = $customField->options;
  308.       echo '<select id="magicfields_'.$customField->name.'_1_1" name="magicfields['.$customField->name.'][1][1][]" multiple="multiple" size="3" style="width:250px; height: auto;">';
  309.          
  310.          foreach($dropDownListDefaultValues as $defaultValue){
  311.         $selected = ' ';
  312.         if(in_array($defaultValue, $customFieldValue))
  313.            { $selected = ' selected="selected" '; }
  314.         echo '<option value="'.$defaultValue.'"'.$selected .'>'.$defaultValue.'</option>';
  315.      }
  316.       echo '</select>';
  317.       echo '<br clear="all" />';
  318.    }
  319.    elseif($customField->type == 'Radiobutton List'){
  320.       echo '<label for="'.$customField->name.'">'.$customField->description.'</label><br />';
  321.       $dropDownListDefaultValues = $customField->options;
  322.          
  323.          foreach($dropDownListDefaultValues as $defaultValue){
  324.         $selected = ' ';
  325.         if($defaultValue == $customFieldValue)
  326.            { $selected = ' checked="checked" '; }
  327.         echo '<label for="magicfields['.$customField->name.'][1][1]_'.$defaultValue.'">'.$defaultValue;
  328.         echo '<input id="magicfields['.$customField->name.'][1][1]_'.$defaultValue.'" name="magicfields['.$customField->name.'][1][1]" value="'.$defaultValue.'" '.$selected.' type="radio"></label>';
  329.      }
  330.       echo '<br clear="all" />';
  331.    }
  332.    else { "Boyle bir input hazirlamamisim, buyuk ihtimalle sacma sapan gereksiz bir input sectin."; }
  333.  
  334. }
  335.  
  336. echo "<pre>";
  337. //pr($customFields);
  338. echo "</pre>";
  339.  
  340. //  print_r( get_group('profil'));
  341. //
  342. //  //$customField = RCCWP_CustomField::Get(184);
  343. //
  344. //  //print_r($customField);
  345. //
  346. //  $customFields = RCCWP_CustomGroup::GetCustomFields(13);
  347. //  $mf_post_id = $post_id;
  348. //  $groupCounter = 1;
  349. //  $customGroup->id = 13;
  350. //
  351. //      foreach($customFields as $field){
  352. //              //RCCWP_WritePostPage::CustomFieldInterface($field->id,1,1,1);
  353. //          if(isset($mf_post_id)){
  354. //              $fc = RCCWP_CustomField::GetFieldDuplicates($mf_post_id,$field->name,$groupCounter);
  355. //              $fields_order =  RCCWP_CustomField::GetFieldsOrder($mf_post_id,$field->name,$groupCounter);
  356. //              foreach($fields_order as $element){
  357. //                  RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,$element,$customGroup->id);
  358. //              }  
  359. //          }else{
  360. //              RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,1,$customGroup->id);
  361. //              $fc = 1;
  362. //          }
  363. //      }
  364.     ?>
  365.  
  366.     <?php wp_nonce_field('profileForm'); ?>
  367.     <?php if($lang == 'en-US'){ $text = 'Save Profile'; } else{ $text = 'Profilimi Kaydet'; } ?>   
  368.     <input type="submit" id="submit" name="submit" value="<?php echo $text; ?>" tabindex="6" />
  369.     </form>
  370. </div>
  371. <!--// New Post Form -->
  372.  
  373. <form id="profileForm" name="profileForm" method="POST" action="?">
  374.     <input type="hidden" name="post_action" value="delete" />
  375.     <?php wp_nonce_field('delete-post'); ?>
  376.     <?php if($lang == 'en-US'){ $text = 'Delete My Profile'; } else{ $text = 'Profilimi Sil'; } ?>
  377.     <?php if($lang == 'en-US'){ $text2 = 'Are you sure?'; } else{ $text2 = 'Devam Etmek istiyormusunuz?'; } ?>
  378.     <p align="right"><input type="submit" id="submit" name="submit" onclick="return deletechecked('<?php echo $text2; ?>');" value="<?php echo $text; ?>" tabindex="6" /></p>
  379. </form>
  380.  
  381. <?php endif ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement