| 1 | <?php |
|---|
| 2 | class RCCWP_WritePostPage |
|---|
| 3 | { |
|---|
| 4 | function ApplyCustomWritePanelAssignedCategories($content) |
|---|
| 5 | { |
|---|
| 6 | global $CUSTOM_WRITE_PANEL; |
|---|
| 7 | |
|---|
| 8 | $assignedCategoryIds = RCCWP_CustomWritePanel::GetAssignedCategoryIds($CUSTOM_WRITE_PANEL->id); |
|---|
| 9 | foreach ($assignedCategoryIds as $categoryId) |
|---|
| 10 | { |
|---|
| 11 | $toReplace = 'id="in-category-' . $categoryId . '"'; |
|---|
| 12 | $replacement = $toReplace . ' checked="checked"'; |
|---|
| 13 | $content = str_replace($toReplace, $replacement, $content); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | return $content; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | function FormError(){ |
|---|
| 20 | if (RCCWP_Application::InWritePostPanel()){ |
|---|
| 21 | echo "<div id='flutter-publish-error-message' class='error' style='display:none;'><p><strong>".__("Post was not published - ")."</strong> ".__("You have errors in some fields, please check the fields below.")."</p></div>"; |
|---|
| 22 | } |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | function ApplyCustomWritePanelHeader() |
|---|
| 26 | { |
|---|
| 27 | global $CUSTOM_WRITE_PANEL; |
|---|
| 28 | |
|---|
| 29 | // Validate capability |
|---|
| 30 | require_once ('RCCWP_Options.php'); |
|---|
| 31 | $assignToRole = RCCWP_Options::Get('assign-to-role'); |
|---|
| 32 | $requiredPostsCap = 'edit_posts'; |
|---|
| 33 | $requiredPagesCap = 'edit_pages'; |
|---|
| 34 | |
|---|
| 35 | if ($assignToRole == 1){ |
|---|
| 36 | $requiredPostsCap = $CUSTOM_WRITE_PANEL->capability_name; |
|---|
| 37 | $requiredPagesCap = $CUSTOM_WRITE_PANEL->capability_name; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | if ($CUSTOM_WRITE_PANEL->type == "post") |
|---|
| 41 | $requiredCap = $requiredPostsCap; |
|---|
| 42 | else |
|---|
| 43 | $requiredCap = $requiredPagesCap; |
|---|
| 44 | |
|---|
| 45 | if (!current_user_can($requiredCap)) wp_die( __('You do not have sufficient permissions to access this custom write panel.') ); |
|---|
| 46 | |
|---|
| 47 | // --- Apply Flutter CSS and javascript |
|---|
| 48 | ?> |
|---|
| 49 | |
|---|
| 50 | <link rel='stylesheet' href='<?php echo CANVASURI?>css/epoch_styles.css' type='text/css' /> |
|---|
| 51 | |
|---|
| 52 | <style type="text/css"> |
|---|
| 53 | |
|---|
| 54 | .tr_inside{ |
|---|
| 55 | background-color:transparent !important; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | .freshout{ |
|---|
| 59 | display: block; |
|---|
| 60 | margin-left: auto; |
|---|
| 61 | margin-right: auto ; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | .photo_edit_link{ |
|---|
| 65 | clear:both; |
|---|
| 66 | margin: 0px 0px 0px 0px; |
|---|
| 67 | width:150px; |
|---|
| 68 | text-align:center; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | .error_msg_txt{ |
|---|
| 72 | font-weight: bold; |
|---|
| 73 | overflow: auto; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | .duplicate_button{ |
|---|
| 77 | text-decoration:none; |
|---|
| 78 | font-weight:bold; |
|---|
| 79 | float:right |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | .duplicate_image{ |
|---|
| 83 | vertical-align:middle; |
|---|
| 84 | padding-right:3px; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | </style> |
|---|
| 88 | |
|---|
| 89 | <link href="<?php echo CANVASURI?>js/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" /> |
|---|
| 90 | |
|---|
| 91 | <!--<script type="text/javascript"> |
|---|
| 92 | |
|---|
| 93 | tinyMCE.init({ |
|---|
| 94 | theme : "advanced", |
|---|
| 95 | theme_advanced_toolbar_location : "top", |
|---|
| 96 | theme_advanced_toolbar_align : "left", |
|---|
| 97 | theme_advanced_buttons1 : "bold, italic, |, underline, |, bullist, numlist, outdent, indent, |, justifyleft, justifycenter, justifyright, justifyfull, |, link, unlink, spellchecker", |
|---|
| 98 | theme_advanced_buttons2 : "", |
|---|
| 99 | theme_advanced_buttons3 : "", |
|---|
| 100 | mode : "textareas", |
|---|
| 101 | skin : "wp_theme", |
|---|
| 102 | tab_focus : "next", |
|---|
| 103 | spellchecker_languages : "english", |
|---|
| 104 | convert_urls : false, |
|---|
| 105 | gecko_spellcheck : true, |
|---|
| 106 | convert_newlines_to_brs : false, |
|---|
| 107 | force_br_newlines : true, |
|---|
| 108 | force_p_newlines : false, |
|---|
| 109 | //mode : "exact", |
|---|
| 110 | //elements : "editorContent", |
|---|
| 111 | editor_selector : "mceEditor", |
|---|
| 112 | width : "100%", |
|---|
| 113 | height : "200" |
|---|
| 114 | }); |
|---|
| 115 | |
|---|
| 116 | </script>--> |
|---|
| 117 | |
|---|
| 118 | <script language="JavaScript" type="text/javascript" src="<?php echo CANVASURI; ?>js/prototype.js"></script> |
|---|
| 119 | |
|---|
| 120 | <!-- Calendar Control --> |
|---|
| 121 | <script type="text/javascript" src="<?php echo CANVASURI?>js/epoch_classes.js"></script> <!--Epoch's Code--> |
|---|
| 122 | <!-- Calendar Control --> |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | <script type="text/javascript"> |
|---|
| 126 | var GB_ROOT_DIR = "<?php echo CANVASURI?>js/greybox/"; |
|---|
| 127 | var flutter_path = "<?php echo FLUTTER_URI ?>" ; |
|---|
| 128 | var swf_authentication = "<?php if ( function_exists('is_ssl') && is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>" ; |
|---|
| 129 | var swf_nonce = "<?php echo wp_create_nonce('media-form'); ?>" ; |
|---|
| 130 | </script> |
|---|
| 131 | <script type="text/javascript" src="<?php echo CANVASURI?>js/greybox/AJS.js"></script> |
|---|
| 132 | <script type="text/javascript" src="<?php echo CANVASURI?>js/greybox/AJS_fx.js"></script> |
|---|
| 133 | <script type="text/javascript" src="<?php echo CANVASURI?>js/greybox/gb_scripts.js"></script> |
|---|
| 134 | <script type="text/javascript" src="<?php echo FLUTTER_URI; ?>js/swfupload/swfcallbacks.js" ></script> |
|---|
| 135 | <script type="text/javascript" src="<?php echo FLUTTER_URI; ?>js/swfupload/swfupload.js"></script> |
|---|
| 136 | |
|---|
| 137 | <script type="text/javascript"> |
|---|
| 138 | function isset( ) { |
|---|
| 139 | // http://kevin.vanzonneveld.net |
|---|
| 140 | // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) |
|---|
| 141 | // + improved by: FremyCompany |
|---|
| 142 | // * example 1: isset( undefined, true); |
|---|
| 143 | // * returns 1: false |
|---|
| 144 | // * example 2: isset( 'Kevin van Zonneveld' ); |
|---|
| 145 | // * returns 2: true |
|---|
| 146 | |
|---|
| 147 | var a=arguments; var l=a.length; var i=0; |
|---|
| 148 | |
|---|
| 149 | while ( i!=l ) { |
|---|
| 150 | if (typeof(a[i])=='undefined') { |
|---|
| 151 | return false; |
|---|
| 152 | } else { |
|---|
| 153 | i++; |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | return true; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | function checkForm(event){ |
|---|
| 161 | var stopPublish = false; |
|---|
| 162 | $$('input.field_required','textarea.field_required').each( |
|---|
| 163 | function(inputField){ |
|---|
| 164 | if ($F(inputField) == "" && |
|---|
| 165 | !(Object.isElement($(inputField.id+"_last")) && $F(inputField.id+"_last") != "") ){ |
|---|
| 166 | stopPublish = true; |
|---|
| 167 | |
|---|
| 168 | // Update row color |
|---|
| 169 | if (isset($("row_"+inputField.id).style)) |
|---|
| 170 | $("row_"+inputField.id).style.backgroundColor = "#FFEBE8"; |
|---|
| 171 | |
|---|
| 172 | // Update iframe color if it exists |
|---|
| 173 | if (Object.isElement($("upload_internal_iframe_"+inputField.id))){ |
|---|
| 174 | if ($("upload_internal_iframe_"+inputField.id).contentDocument) { |
|---|
| 175 | // For FF |
|---|
| 176 | $("upload_internal_iframe_"+inputField.id).contentDocument.body.style.backgroundColor = "#FFEBE8"; |
|---|
| 177 | } else if ($("upload_internal_iframe_"+inputField.id).contentWindow) { |
|---|
| 178 | // For IE5.5 and IE6 |
|---|
| 179 | $("upload_internal_iframe_"+inputField.id).contentWindow.document.body.style.backgroundColor = "#FFEBE8"; |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | $("fieldcellerror_"+inputField.id).style.display = ""; |
|---|
| 184 | $("fieldcellerror_"+inputField.id).innerHTML = "ERROR: Field can not be empty"; |
|---|
| 185 | } |
|---|
| 186 | else{ |
|---|
| 187 | $("fieldcellerror_"+inputField.id).style.display = "none"; |
|---|
| 188 | if (isset($("row_"+inputField.id).style)) |
|---|
| 189 | $("row_"+inputField.id).style.backgroundColor = ""; |
|---|
| 190 | |
|---|
| 191 | // Update iframe color if it exists |
|---|
| 192 | if (Object.isElement($("upload_internal_iframe_"+inputField.id))){ |
|---|
| 193 | if ($("upload_internal_iframe_"+inputField.id).contentDocument) { |
|---|
| 194 | // For FF |
|---|
| 195 | $("upload_internal_iframe_"+inputField.id).contentDocument.body.style.backgroundColor = "#EAF3FA"; |
|---|
| 196 | } else if ($("upload_internal_iframe_"+inputField.id).contentWindow) { |
|---|
| 197 | // For IE5.5 and IE6 |
|---|
| 198 | $("upload_internal_iframe_"+inputField.id).contentWindow.document.body.style.backgroundColor = "#EAF3FA"; |
|---|
| 199 | } |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | } |
|---|
| 203 | } |
|---|
| 204 | ); |
|---|
| 205 | if (stopPublish){ |
|---|
| 206 | $("flutter-publish-error-message").style.display = ""; |
|---|
| 207 | Event.stop(event); |
|---|
| 208 | return false; |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | return true; |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | Event.observe(window, 'load', function() { |
|---|
| 215 | Event.observe('post', 'submit', checkForm); |
|---|
| 216 | }); |
|---|
| 217 | |
|---|
| 218 | // ------------- |
|---|
| 219 | // Edit Photo functions |
|---|
| 220 | |
|---|
| 221 | function setCookie(c_name,value,expiredays) |
|---|
| 222 | { |
|---|
| 223 | var exdate=new Date(); |
|---|
| 224 | exdate.setDate(exdate.getDate()+expiredays); |
|---|
| 225 | document.cookie=c_name+ "=" +escape(value)+ |
|---|
| 226 | ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); |
|---|
| 227 | } |
|---|
| 228 | function prepareUpdatePhoto(inputName){ |
|---|
| 229 | document.getElementById(inputName+'_dorename').value = '1'; |
|---|
| 230 | return true; |
|---|
| 231 | } |
|---|
| 232 | function exchangeValues(e, id) |
|---|
| 233 | { |
|---|
| 234 | //document.getElementById(document.getElementById('parent_text_'+id.substring(10)).value).value = e; |
|---|
| 235 | //document.getElementById(document.getElementById('hidImgValue'+id.substring(10)).value).value = e; |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | // ------------- |
|---|
| 239 | // Date Functions |
|---|
| 240 | |
|---|
| 241 | var dp_cal = new Array(); // declare the calendars as global variables |
|---|
| 242 | |
|---|
| 243 | function pickDate(inputName){ |
|---|
| 244 | if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]) document.getElementById('date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d'); |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 247 | function InitializeDateObject(inputName, dateFormat, currentValue){ |
|---|
| 248 | if (!Object.isElement($('display_date_field_' + inputName))) return; |
|---|
| 249 | |
|---|
| 250 | dp_cal[inputName] = new Epoch('dp_cal_'+inputName,'popup',document.getElementById('display_date_field_'+inputName), false, 'pickDate', inputName, dateFormat); |
|---|
| 251 | |
|---|
| 252 | var d = new Date(); |
|---|
| 253 | |
|---|
| 254 | if (currentValue.length > 0){ |
|---|
| 255 | d.setYear(parseInt(currentValue.substr(0,4),10)); |
|---|
| 256 | d.setMonth(parseInt(currentValue.substr(5,2),10)-1); |
|---|
| 257 | d.setDate(parseInt(currentValue.substr(8,2),10)); |
|---|
| 258 | } |
|---|
| 259 | d.selected = true; |
|---|
| 260 | d.canSelect = true; |
|---|
| 261 | var tmpDatesArray = new Array(d); |
|---|
| 262 | dp_cal[inputName].selectDates(tmpDatesArray, true, true, true); |
|---|
| 263 | if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]) |
|---|
| 264 | document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat); |
|---|
| 265 | } |
|---|
| 266 | |
|---|
| 267 | function today_date(inputName, dateFormat){ |
|---|
| 268 | var d = new Date(); |
|---|
| 269 | var tmpDatesArray = new Array(d); |
|---|
| 270 | dp_cal[inputName].selectDates(tmpDatesArray, true, true, true); |
|---|
| 271 | if (dp_cal[inputName] && dp_cal[inputName].selectedDates[0]){ |
|---|
| 272 | document.getElementById('display_date_field_'+inputName).value = dp_cal[inputName].selectedDates[0].dateFormat(dateFormat); |
|---|
| 273 | document.getElementById('date_field_' + inputName).value = dp_cal[inputName].selectedDates[0].dateFormat('Y-m-d'); |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | |
|---|
| 277 | // ------------- |
|---|
| 278 | // Duplicates functions |
|---|
| 279 | |
|---|
| 280 | function getDuplicate(fId,fcounter,div,gcounter) |
|---|
| 281 | { |
|---|
| 282 | $(div).setStyle({display: ""}); |
|---|
| 283 | new Ajax.Request('<?php echo FLUTTER_URI; ?>RCCWP_GetDuplicate.php', |
|---|
| 284 | { |
|---|
| 285 | method:'post', |
|---|
| 286 | onSuccess: function(transport){ |
|---|
| 287 | $(div).insert( {before: transport.responseText} ); |
|---|
| 288 | $(div).setStyle({display: "none"}); |
|---|
| 289 | }, |
|---|
| 290 | parameters: "customFieldId="+fId+"&fieldCounter="+fcounter+"&groupCounter="+gcounter |
|---|
| 291 | }); |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | function deleteDuplicate(fieldinputName) |
|---|
| 295 | { |
|---|
| 296 | var field = document.getElementById( fieldinputName ) ; |
|---|
| 297 | field.parentNode.removeChild(field) ; |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | function GetGroupDuplicate(div, customGroupID) |
|---|
| 301 | { |
|---|
| 302 | customGroupCounter = $F('g'+customGroupID+'counter'); |
|---|
| 303 | customGroupCounter ++; |
|---|
| 304 | $('g'+customGroupID+'counter').value = customGroupCounter; |
|---|
| 305 | $(div).setStyle({display: ""}); |
|---|
| 306 | new Ajax.Request('<?php echo FLUTTER_URI; ?>RCCWP_GetDuplicate.php', |
|---|
| 307 | { |
|---|
| 308 | method:'post', |
|---|
| 309 | onSuccess: function(transport){ |
|---|
| 310 | $(div).insert( {before: transport.responseText} ); |
|---|
| 311 | $(div).setStyle({display: "none"}); |
|---|
| 312 | }, |
|---|
| 313 | parameters: "flag=group&groupId="+customGroupID+"&groupCounter="+customGroupCounter |
|---|
| 314 | }); |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | function deleteGroupDuplicate(groupDiv) |
|---|
| 318 | { |
|---|
| 319 | var group = document.getElementById( groupDiv ) ; |
|---|
| 320 | group.parentNode.removeChild( group ) ; |
|---|
| 321 | } |
|---|
| 322 | function typeHandler(inputName,customFieldId,groupCounter) |
|---|
| 323 | { |
|---|
| 324 | oldval = $F("c"+inputName+"Counter"); |
|---|
| 325 | newval = parseInt(oldval) + 1; |
|---|
| 326 | $("c"+inputName+"Counter").value = newval ; |
|---|
| 327 | getDuplicate(customFieldId, $F("c"+inputName+"Counter"), "c"+inputName+"Duplicate",$(groupCounter)) ; |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | </script> |
|---|
| 331 | |
|---|
| 332 | <?php |
|---|
| 333 | |
|---|
| 334 | // Show/Hide Panel fields |
|---|
| 335 | |
|---|
| 336 | global $STANDARD_FIELDS; |
|---|
| 337 | |
|---|
| 338 | $standardFields = RCCWP_CustomWritePanel::GetStandardFields($CUSTOM_WRITE_PANEL->id); |
|---|
| 339 | $hideCssIds = array(); |
|---|
| 340 | |
|---|
| 341 | foreach($STANDARD_FIELDS as $standardField){ |
|---|
| 342 | if (!in_array($standardField->id, $standardFields)){ |
|---|
| 343 | foreach($standardField->cssId as $cssID) |
|---|
| 344 | array_push($hideCssIds, $cssID); |
|---|
| 345 | } |
|---|
| 346 | } |
|---|
| 347 | |
|---|
| 348 | if (empty($hideCssIds)) |
|---|
| 349 | return; |
|---|
| 350 | |
|---|
| 351 | array_walk($hideCssIds, create_function('&$item1, $key', '$item1 = "#" . $item1;')); |
|---|
| 352 | $hideCssIdString = implode(', ', $hideCssIds); |
|---|
| 353 | ?> |
|---|
| 354 | |
|---|
| 355 | <style type="text/css"> |
|---|
| 356 | <?php echo $hideCssIdString?> {display: none !important;} |
|---|
| 357 | </style> |
|---|
| 358 | |
|---|
| 359 | <?php |
|---|
| 360 | |
|---|
| 361 | /*<script type="text/javascript"> |
|---|
| 362 | Event.observe(window, 'load', function() { |
|---|
| 363 | $$('h2').each( |
|---|
| 364 | function(element) { |
|---|
| 365 | if ($(element).innerHTML= "Advanced Options") |
|---|
| 366 | $(element).style.display="none"; |
|---|
| 367 | }); |
|---|
| 368 | }); |
|---|
| 369 | </script>*/ |
|---|
| 370 | |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | function CustomFieldCollectionInterfaceRight(){ |
|---|
| 375 | RCCWP_WritePostPage::CustomFieldCollectionInterface(true); |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | function CustomFieldCollectionInterface($rightOnly = false) |
|---|
| 379 | { |
|---|
| 380 | global $CUSTOM_WRITE_PANEL; |
|---|
| 381 | |
|---|
| 382 | if (!isset($CUSTOM_WRITE_PANEL)) |
|---|
| 383 | return; |
|---|
| 384 | |
|---|
| 385 | $customGroups = RCCWP_CustomWritePanel::GetCustomGroups($CUSTOM_WRITE_PANEL->id); |
|---|
| 386 | |
|---|
| 387 | foreach ($customGroups as $customGroup) |
|---|
| 388 | { |
|---|
| 389 | if (($rightOnly && !$customGroup->at_right) || |
|---|
| 390 | (!$rightOnly && $customGroup->at_right)) |
|---|
| 391 | { |
|---|
| 392 | continue; |
|---|
| 393 | } |
|---|
| 394 | |
|---|
| 395 | // Render a block for each group in the module |
|---|
| 396 | ?> |
|---|
| 397 | |
|---|
| 398 | <?php |
|---|
| 399 | $customFields = RCCWP_CustomGroup::GetCustomFields($customGroup->id); |
|---|
| 400 | if( isset( $_REQUEST['post'] ) && count($customFields) > 0) |
|---|
| 401 | { |
|---|
| 402 | $firstFieldName = $customFields[0]->name; |
|---|
| 403 | $gc = RCCWP_CustomField::GetFieldGroupDuplicates($_REQUEST['post'], $firstFieldName) ; |
|---|
| 404 | if ($gc < 1) $gc = 1;//for backward compatability |
|---|
| 405 | for($i=1;$i<=$gc;$i++) |
|---|
| 406 | { |
|---|
| 407 | RCCWP_WritePostPage::GroupDuplicate($customGroup,$i,false) ; |
|---|
| 408 | } |
|---|
| 409 | } |
|---|
| 410 | else |
|---|
| 411 | { |
|---|
| 412 | RCCWP_WritePostPage::GroupDuplicate($customGroup,1,false) ; |
|---|
| 413 | $gc = 1 ; |
|---|
| 414 | } |
|---|
| 415 | ?> |
|---|
| 416 | <div id="<?php echo $customGroup->id."Duplicate";?>" style="display:none"> |
|---|
| 417 | <img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/spinner.gif" alt=""/> Loading ... |
|---|
| 418 | </div> |
|---|
| 419 | <input type='hidden' name='g<?php echo $customGroup->id?>counter' id='g<?php echo $customGroup->id?>counter' value='<?php echo $gc?>' /> |
|---|
| 420 | <?php |
|---|
| 421 | } |
|---|
| 422 | ?> |
|---|
| 423 | |
|---|
| 424 | <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')?>" /> |
|---|
| 425 | <input type="hidden" name="rc-cwp-custom-write-panel-id" value="<?php echo $CUSTOM_WRITE_PANEL->id?>" /> |
|---|
| 426 | |
|---|
| 427 | <!-- rc_cwp_submit_buttons --> |
|---|
| 428 | <?php |
|---|
| 429 | } |
|---|
| 430 | |
|---|
| 431 | function GroupDuplicate($customGroup, $groupCounter, $fromAjax=true) |
|---|
| 432 | { |
|---|
| 433 | $customFields = RCCWP_CustomGroup::GetCustomFields($customGroup->id); |
|---|
| 434 | if (count($customFields) == 0) return; |
|---|
| 435 | if( $customGroup->duplicate == 0 & $groupCounter != 1 ) return ; |
|---|
| 436 | require_once("RC_Format.php"); |
|---|
| 437 | |
|---|
| 438 | if ( $customGroup->name == "__default"){ |
|---|
| 439 | // $customGroup->name = "Module general fields"; |
|---|
| 440 | $customGroup->name = "" ; |
|---|
| 441 | } |
|---|
| 442 | ?> |
|---|
| 443 | |
|---|
| 444 | <?php if ($groupCounter==1){ ?> |
|---|
| 445 | <div id="freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter;?>" class="<?php if ($customGroup->name != "") echo "postbox ".postbox_classes('freshpostdiv_group_'.$customGroup->id, 'post');?>"> |
|---|
| 446 | |
|---|
| 447 | <?php if ($customGroup->name != ""){ ?> |
|---|
| 448 | <h3> |
|---|
| 449 | <?php echo $customGroup->name ?> |
|---|
| 450 | </h3> |
|---|
| 451 | <?php } ?> |
|---|
| 452 | <?php } else { ?> |
|---|
| 453 | <div id="freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter;?>" class="postbox"> |
|---|
| 454 | <?php if ($fromAjax){ ?> |
|---|
| 455 | <h3 onclick="jQuery(jQuery(this).parent().get(0)).toggleClass('closed');"> <a class="togbox">+</a> |
|---|
| 456 | <?php }else{ ?> |
|---|
| 457 | <h3> |
|---|
| 458 | <?php } ?> |
|---|
| 459 | <?php echo $customGroup->name." ($groupCounter)" ?> |
|---|
| 460 | </h3> |
|---|
| 461 | <?php }?> |
|---|
| 462 | <div class="inside"> |
|---|
| 463 | <table class="form-table" style="width: 100%;" cellspacing="2" cellpadding="5"> |
|---|
| 464 | <?php |
|---|
| 465 | foreach ($customFields as $field) |
|---|
| 466 | { |
|---|
| 467 | // Render a row for each field in the group |
|---|
| 468 | $customField = RCCWP_CustomField::Get($field->id); |
|---|
| 469 | $customFieldName = RC_Format::GetInputName(attribute_escape($field->name)); |
|---|
| 470 | $customFieldTitle = attribute_escape($customField->description); |
|---|
| 471 | $inputName = $field->id."_".$groupCounter."_1_".$customFieldName |
|---|
| 472 | |
|---|
| 473 | ?> |
|---|
| 474 | |
|---|
| 475 | <?php |
|---|
| 476 | if( isset( $_REQUEST['post'] ) ) |
|---|
| 477 | { |
|---|
| 478 | $fc = RCCWP_CustomField::GetFieldDuplicates($_REQUEST['post'],$field->name,$groupCounter) ; |
|---|
| 479 | if ($fc < 1) $fc = 1;//for backward compatability |
|---|
| 480 | for($i=1;$i<=$fc;$i++) |
|---|
| 481 | { |
|---|
| 482 | //if ($i>1) echo "<div id='field".$field->id."_$i"."_$groupCounter'>" ; |
|---|
| 483 | RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,$i) ; |
|---|
| 484 | //if ($i>1) echo "</div>" ; |
|---|
| 485 | } |
|---|
| 486 | } |
|---|
| 487 | else |
|---|
| 488 | { |
|---|
| 489 | RCCWP_WritePostPage::CustomFieldInterface($field->id,$groupCounter,1); |
|---|
| 490 | $fc = 1 ; |
|---|
| 491 | } |
|---|
| 492 | |
|---|
| 493 | |
|---|
| 494 | ?> |
|---|
| 495 | |
|---|
| 496 | <tr style="display:none" id="<?php echo "c".$inputName."Duplicate"?>"> |
|---|
| 497 | <th valign="top" scope="row"> |
|---|
| 498 | </th> |
|---|
| 499 | <td> |
|---|
| 500 | <img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/spinner.gif" alt=""/> Loading ... |
|---|
| 501 | <input type="hidden" name="c<?php echo $inputName ?>Counter" id="c<?php echo $inputName ?>Counter" value='<?php echo $fc ?>' /> |
|---|
| 502 | </td> |
|---|
| 503 | </tr> |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | <?php } |
|---|
| 507 | ?> |
|---|
| 508 | |
|---|
| 509 | </table> |
|---|
| 510 | </div> |
|---|
| 511 | <br /> |
|---|
| 512 | <?php |
|---|
| 513 | if( $customGroup->duplicate != 0 ){ |
|---|
| 514 | if( $groupCounter == 1 ){ |
|---|
| 515 | ?> |
|---|
| 516 | <a class ="duplicate_button" href="javascript:GetGroupDuplicate('<?php echo $customGroup->id."Duplicate";?>', <?php echo $customGroup->id ?>)"> |
|---|
| 517 | <img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/duplicate.png" alt="Add group duplicate"/> Duplicate Group |
|---|
| 518 | </a> |
|---|
| 519 | <br style="height:2px"/> |
|---|
| 520 | <?php |
|---|
| 521 | } |
|---|
| 522 | else { |
|---|
| 523 | ?> |
|---|
| 524 | <a class ="duplicate_button" href="javascript:deleteGroupDuplicate('freshpostdiv_group_<?php echo $customGroup->id.'_'.$groupCounter ?>')" > |
|---|
| 525 | <img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/delete.png" alt="Remove field duplicate"/>Remove Group |
|---|
| 526 | </a> |
|---|
| 527 | <br style="height:2px"/> |
|---|
| 528 | <?php } |
|---|
| 529 | } |
|---|
| 530 | ?> |
|---|
| 531 | </div> |
|---|
| 532 | |
|---|
| 533 | <?php |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | function CustomFieldInterface($customFieldId, $groupCounter=1, $fieldCounter=1) |
|---|
| 537 | { |
|---|
| 538 | require_once("RC_Format.php"); |
|---|
| 539 | $customField = RCCWP_CustomField::Get($customFieldId); |
|---|
| 540 | $customFieldName = RC_Format::GetInputName(attribute_escape($customField->name)); |
|---|
| 541 | $customFieldTitle = attribute_escape($customField->description); |
|---|
| 542 | $inputName = $customFieldId."_".$groupCounter."_".$fieldCounter."_".$customFieldName; // Create input tag name |
|---|
| 543 | if( $fieldCounter > 1 && $customField->duplicate == 0 ) return ; |
|---|
| 544 | if( $fieldCounter > 1) $titleCounter = " ($fieldCounter)"; |
|---|
| 545 | |
|---|
| 546 | $field_group = RCCWP_CustomGroup::Get($customField->group_id); |
|---|
| 547 | |
|---|
| 548 | ?> |
|---|
| 549 | <tr class="form-field" id="row_<?php echo $inputName?>"> |
|---|
| 550 | <?php |
|---|
| 551 | // If the field is at right, put the header over the field |
|---|
| 552 | if ($field_group->at_right){ |
|---|
| 553 | ?> |
|---|
| 554 | <td> |
|---|
| 555 | <label style="font-weight:bold" for="<?php echo $inputName?>"><?php echo $customFieldTitle.$titleCounter?></label> |
|---|
| 556 | <br /> |
|---|
| 557 | <?php |
|---|
| 558 | } else { |
|---|
| 559 | ?> |
|---|
| 560 | <th valign="top" scope="row"> |
|---|
| 561 | <label for="<?php echo $inputName?>"><?php echo $customFieldTitle.$titleCounter?></label> |
|---|
| 562 | </th> |
|---|
| 563 | <td> |
|---|
| 564 | <?php |
|---|
| 565 | } |
|---|
| 566 | ?> |
|---|
| 567 | |
|---|
| 568 | <p class="error_msg_txt" id="fieldcellerror_<?php echo $inputName?>" style="display:none"></p> |
|---|
| 569 | <?php |
|---|
| 570 | switch ($customField->type) |
|---|
| 571 | { |
|---|
| 572 | case 'Textbox' : |
|---|
| 573 | RCCWP_WritePostPage::TextboxInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 574 | break; |
|---|
| 575 | case 'Multiline Textbox' : |
|---|
| 576 | RCCWP_WritePostPage::MultilineTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 577 | break; |
|---|
| 578 | case 'Checkbox' : |
|---|
| 579 | RCCWP_WritePostPage::CheckboxInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 580 | break; |
|---|
| 581 | case 'Checkbox List' : |
|---|
| 582 | RCCWP_WritePostPage::CheckboxListInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 583 | break; |
|---|
| 584 | case 'Radiobutton List' : |
|---|
| 585 | RCCWP_WritePostPage::RadiobuttonListInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 586 | break; |
|---|
| 587 | case 'Dropdown List' : |
|---|
| 588 | RCCWP_WritePostPage::DropdownListInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 589 | break; |
|---|
| 590 | case 'Listbox' : |
|---|
| 591 | RCCWP_WritePostPage::ListboxInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 592 | break; |
|---|
| 593 | case 'File' : |
|---|
| 594 | RCCWP_WritePostPage::FileInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 595 | break; |
|---|
| 596 | case 'Image' : |
|---|
| 597 | RCCWP_WritePostPage::PhotoInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 598 | break; |
|---|
| 599 | case 'Date' : |
|---|
| 600 | RCCWP_WritePostPage::DateInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 601 | break; |
|---|
| 602 | case 'Audio' : |
|---|
| 603 | RCCWP_WritePostPage::AudioInterface($customField, $inputName, $groupCounter, $fieldCounter); |
|---|
| 604 | break; |
|---|
| 605 | default: |
|---|
| 606 | ; |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | |
|---|
| 610 | if($fieldCounter == 1) |
|---|
| 611 | { |
|---|
| 612 | ?> |
|---|
| 613 | <?php if($customField->duplicate != 0 ){ ?> |
|---|
| 614 | <br /> |
|---|
| 615 | |
|---|
| 616 | <a class ="duplicate_button" href="javascript:typeHandler('<?php echo $inputName ?>',<?php echo $customFieldId ?>,<?php echo $groupCounter ?>)" > |
|---|
| 617 | <img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/duplicate.png" alt="Add field duplicate"/> Duplicate |
|---|
| 618 | </a> |
|---|
| 619 | <?php } ?> |
|---|
| 620 | |
|---|
| 621 | <?php |
|---|
| 622 | } |
|---|
| 623 | else |
|---|
| 624 | { |
|---|
| 625 | ?> |
|---|
| 626 | <br /> |
|---|
| 627 | |
|---|
| 628 | <a class ="duplicate_button" href="javascript:deleteDuplicate('row_<?php echo $inputName?>')" > |
|---|
| 629 | <img class="duplicate_image" src="<?php echo FLUTTER_URI; ?>images/delete.png" alt="Remove field duplicate"/> Remove |
|---|
| 630 | </a> |
|---|
| 631 | <?php |
|---|
| 632 | } |
|---|
| 633 | ?> |
|---|
| 634 | <input type="hidden" name="rc_cwp_meta_keys[]" value="<?php echo $inputName?>" /> |
|---|
| 635 | </td> |
|---|
| 636 | </tr> |
|---|
| 637 | <?php |
|---|
| 638 | } |
|---|
| 639 | |
|---|
| 640 | function CheckboxInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 641 | { |
|---|
| 642 | $customFieldId = ''; |
|---|
| 643 | if (isset($_REQUEST['post'])) |
|---|
| 644 | { |
|---|
| 645 | $customFieldId = $customField->id; |
|---|
| 646 | $value = RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter); |
|---|
| 647 | $checked = $value == 'true' ? 'checked="checked"' : ''; |
|---|
| 648 | } |
|---|
| 649 | ?> |
|---|
| 650 | |
|---|
| 651 | <input type="hidden" name="<?php echo $inputName?>" value="false" /> |
|---|
| 652 | <input tabindex="3" class="checkbox" name="<?php echo $inputName?>" value="true" id="<?php echo $inputName?>" type="checkbox" <?php echo $checked?> /> |
|---|
| 653 | |
|---|
| 654 | <?php |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | function CheckboxListInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 658 | { |
|---|
| 659 | $customFieldId = ''; |
|---|
| 660 | $values = array(); |
|---|
| 661 | if (isset($_REQUEST['post'])) |
|---|
| 662 | { |
|---|
| 663 | $customFieldId = $customField->id; |
|---|
| 664 | $values = (array) RCCWP_CustomField::GetCustomFieldValues(false, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter); |
|---|
| 665 | } |
|---|
| 666 | else |
|---|
| 667 | { |
|---|
| 668 | $values = $customField->default_value; |
|---|
| 669 | } |
|---|
| 670 | ?> |
|---|
| 671 | |
|---|
| 672 | |
|---|
| 673 | <?php |
|---|
| 674 | foreach ($customField->options as $option) : |
|---|
| 675 | $checked = in_array($option, (array)$values) ? 'checked="checked"' : ''; |
|---|
| 676 | $option = attribute_escape(trim($option)); |
|---|
| 677 | ?> |
|---|
| 678 | |
|---|
| 679 | <label for="" class="selectit"> |
|---|
| 680 | <input tabindex="3" id="<?php echo $option?>" name="<?php echo $inputName?>[]" value="<?php echo $option?>" type="checkbox" <?php echo $checked?>/> |
|---|
| 681 | <?php echo attribute_escape($option)?> |
|---|
| 682 | </label><br /> |
|---|
| 683 | |
|---|
| 684 | <?php |
|---|
| 685 | endforeach; |
|---|
| 686 | ?> |
|---|
| 687 | |
|---|
| 688 | |
|---|
| 689 | <?php |
|---|
| 690 | } |
|---|
| 691 | |
|---|
| 692 | function DropdownListInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 693 | { |
|---|
| 694 | $customFieldId = ''; |
|---|
| 695 | if (isset($_REQUEST['post'])) |
|---|
| 696 | { |
|---|
| 697 | $customFieldId = $customField->id; |
|---|
| 698 | $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); |
|---|
| 699 | } |
|---|
| 700 | else |
|---|
| 701 | { |
|---|
| 702 | $value = $customField->default_value[0]; |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 706 | ?> |
|---|
| 707 | |
|---|
| 708 | <select tabindex="3" class="<?php echo $requiredClass;?>" name="<?php echo $inputName?>"> |
|---|
| 709 | <option value="">--Select--</option> |
|---|
| 710 | |
|---|
| 711 | <?php |
|---|
| 712 | foreach ($customField->options as $option) : |
|---|
| 713 | $selected = $option == $value ? 'selected="selected"' : ''; |
|---|
| 714 | $option = attribute_escape(trim($option)); |
|---|
| 715 | ?> |
|---|
| 716 | |
|---|
| 717 | <option value="<?php echo $option?>" <?php echo $selected?>><?php echo $option?></option> |
|---|
| 718 | |
|---|
| 719 | <?php |
|---|
| 720 | endforeach; |
|---|
| 721 | ?> |
|---|
| 722 | |
|---|
| 723 | </select> |
|---|
| 724 | |
|---|
| 725 | |
|---|
| 726 | <?php |
|---|
| 727 | } |
|---|
| 728 | |
|---|
| 729 | function ListboxInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 730 | { |
|---|
| 731 | $customFieldId = ''; |
|---|
| 732 | if (isset($_REQUEST['post'])) |
|---|
| 733 | { |
|---|
| 734 | $customFieldId = $customField->id; |
|---|
| 735 | $values = (array) RCCWP_CustomField::GetCustomFieldValues(false, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter); |
|---|
| 736 | } |
|---|
| 737 | else |
|---|
| 738 | { |
|---|
| 739 | $values = $customField->default_value; |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | $inputSize = (int)$customField->properties['size']; |
|---|
| 743 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 744 | ?> |
|---|
| 745 | |
|---|
| 746 | <select class="<?php echo $requiredClass;?>" tabindex="3" id="<?php echo $inputName?>" name="<?php echo $inputName?>[]" multiple size="<?php echo $inputSize?>"> |
|---|
| 747 | |
|---|
| 748 | <?php |
|---|
| 749 | foreach ($customField->options as $option) : |
|---|
| 750 | $selected = in_array($option, (array)$values) ? 'selected="selected"' : ''; |
|---|
| 751 | $option = attribute_escape(trim($option)); |
|---|
| 752 | ?> |
|---|
| 753 | |
|---|
| 754 | <option value="<?php echo $option?>" <?php echo $selected?>><?php echo $option?></option> |
|---|
| 755 | |
|---|
| 756 | <?php |
|---|
| 757 | endforeach; |
|---|
| 758 | ?> |
|---|
| 759 | |
|---|
| 760 | </select> |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | <?php |
|---|
| 764 | } |
|---|
| 765 | |
|---|
| 766 | function MultilineTextboxInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 767 | { |
|---|
| 768 | $customFieldId = ''; |
|---|
| 769 | |
|---|
| 770 | if (isset($_REQUEST['post'])) |
|---|
| 771 | { |
|---|
| 772 | $customFieldId = $customField->id; |
|---|
| 773 | $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); |
|---|
| 774 | } |
|---|
| 775 | |
|---|
| 776 | $inputHeight = (int)$customField->properties['height']; |
|---|
| 777 | $inputWidth = (int)$customField->properties['width']; |
|---|
| 778 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 779 | |
|---|
| 780 | ?> |
|---|
| 781 | <script type="text/javascript"> |
|---|
| 782 | //Event.observe(window, 'load', function() { |
|---|
| 783 | tinyMCE.execCommand('mceAddControl', false, "<?php echo $inputName?>"); |
|---|
| 784 | //}); |
|---|
| 785 | </script> |
|---|
| 786 | |
|---|
| 787 | <textarea class="<?php echo $requiredClass;?>" tabindex="3" id="<?php echo $inputName?>" name="<?php echo $inputName?>" rows="<?php echo $inputHeight?>" cols="<?php echo $inputWidth?>"><?php echo $value?></textarea> |
|---|
| 788 | |
|---|
| 789 | |
|---|
| 790 | <?php |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | function TextboxInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 794 | { |
|---|
| 795 | $customFieldId = ''; |
|---|
| 796 | |
|---|
| 797 | if (isset($_REQUEST['post'])) |
|---|
| 798 | { |
|---|
| 799 | $customFieldId = $customField->id; |
|---|
| 800 | $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); |
|---|
| 801 | } |
|---|
| 802 | |
|---|
| 803 | |
|---|
| 804 | $inputSize = (int)$customField->properties['size']; |
|---|
| 805 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 806 | |
|---|
| 807 | // If the field is at right, set a constant width to the text box |
|---|
| 808 | $field_group = RCCWP_CustomGroup::Get($customField->group_id); |
|---|
| 809 | if ($field_group->at_right){ |
|---|
| 810 | if ($inputSize>14) $inputSize = 14; |
|---|
| 811 | } |
|---|
| 812 | ?> |
|---|
| 813 | |
|---|
| 814 | <input class="<?php echo $requiredClass;?>" tabindex="3" id="<?php echo $inputName?>" name="<?php echo $inputName?>" value="<?php echo $value?>" type="text" size="<?php echo $inputSize?>" /> |
|---|
| 815 | |
|---|
| 816 | <?php |
|---|
| 817 | } |
|---|
| 818 | |
|---|
| 819 | |
|---|
| 820 | function FileInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 821 | { |
|---|
| 822 | $customFieldId = ''; |
|---|
| 823 | $freshPageFolderName = (dirname(plugin_basename(__FILE__))); |
|---|
| 824 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 825 | |
|---|
| 826 | if (isset($_REQUEST['post'])) |
|---|
| 827 | { |
|---|
| 828 | $customFieldId = $customField->id; |
|---|
| 829 | $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); |
|---|
| 830 | $path = CANVASURI.'files_flutter/'; |
|---|
| 831 | $valueRelative = $value; |
|---|
| 832 | $value = $path.$value; |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | // If the field is at right, set a constant width to the text box |
|---|
| 836 | $field_group = RCCWP_CustomGroup::Get($customField->group_id); |
|---|
| 837 | $urlInputSize = false; |
|---|
| 838 | $is_canvas = 0; |
|---|
| 839 | if ($field_group->at_right){ |
|---|
| 840 | $urlInputSize = 5; |
|---|
| 841 | $is_canvas = 1; |
|---|
| 842 | } |
|---|
| 843 | |
|---|
| 844 | ?> |
|---|
| 845 | |
|---|
| 846 | <p class="error_msg_txt" id="upload_progress_<?php echo $inputName?>" style="visibility:hidden;height:0px"></p> |
|---|
| 847 | |
|---|
| 848 | <?php if( $valueRelative ){ echo '(<a href="' . $value . '" target="_blank">View Current</a>)'; } ?> |
|---|
| 849 | |
|---|
| 850 | <input tabindex="3" |
|---|
| 851 | id="<?php echo $inputName?>" |
|---|
| 852 | name="<?php echo $inputName?>" |
|---|
| 853 | type="hidden" |
|---|
| 854 | class="<?php echo $requiredClass;?>" |
|---|
| 855 | size="46" |
|---|
| 856 | value="<?php echo $valueRelative?>" |
|---|
| 857 | /> |
|---|
| 858 | |
|---|
| 859 | <?php |
|---|
| 860 | include_once( "RCCWP_SWFUpload.php" ) ; |
|---|
| 861 | RCCWP_SWFUpload::Body($inputName, 0, $is_canvas, $urlInputSize) ; |
|---|
| 862 | } |
|---|
| 863 | |
|---|
| 864 | |
|---|
| 865 | function PhotoInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 866 | { |
|---|
| 867 | $customFieldId = ''; |
|---|
| 868 | $filepath = $inputName . '_filepath'; |
|---|
| 869 | $noimage = ""; |
|---|
| 870 | $freshPageFolderName = (dirname(plugin_basename(__FILE__))); |
|---|
| 871 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 872 | |
|---|
| 873 | //global $countImageThumbID; |
|---|
| 874 | $imageThumbID = ""; |
|---|
| 875 | $imageThumbID = "img_thumb_".$inputName; //.++$countImageThumbID; |
|---|
| 876 | |
|---|
| 877 | if (isset($_REQUEST['post'])) |
|---|
| 878 | { |
|---|
| 879 | $customFieldId = $customField->id; |
|---|
| 880 | $value = RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter); |
|---|
| 881 | |
|---|
| 882 | $path = CANVASURI.'phpThumb.php?src='.CANVASURI.'files_flutter/'; |
|---|
| 883 | $valueRelative = $value; |
|---|
| 884 | $value = $path.$value; |
|---|
| 885 | if(!(strpos($value, 'http') === FALSE)) |
|---|
| 886 | $hidValue = str_replace('"', "'", $valueRelative); |
|---|
| 887 | $value = stripslashes(trim("\<img src=\'".$value."\' class=\"freshout\" \/\>")); |
|---|
| 888 | } |
|---|
| 889 | else |
|---|
| 890 | { |
|---|
| 891 | $noimage = "<img src='".CANVASURI."images/noimage.jpg' id='".$imageThumbID."'/>"; |
|---|
| 892 | } |
|---|
| 893 | if($valueRelative == '') |
|---|
| 894 | { |
|---|
| 895 | $noimage = "<img src='".CANVASURI."images/noimage.jpg' id='".$imageThumbID."'/>"; |
|---|
| 896 | } |
|---|
| 897 | |
|---|
| 898 | include_once('RCCWP_Options.php'); |
|---|
| 899 | $useSnipshot = RCCWP_Options::Get('use-snipshot'); |
|---|
| 900 | |
|---|
| 901 | // If the field is at right, set a constant width to the text box |
|---|
| 902 | $field_group = RCCWP_CustomGroup::Get($customField->group_id); |
|---|
| 903 | $urlInputSize = false; |
|---|
| 904 | $is_canvas = 0; |
|---|
| 905 | if ($field_group->at_right){ |
|---|
| 906 | $urlInputSize = 5; |
|---|
| 907 | $is_canvas = 1; |
|---|
| 908 | } |
|---|
| 909 | |
|---|
| 910 | ?> |
|---|
| 911 | |
|---|
| 912 | <p class="error_msg_txt" id="upload_progress_<?php echo $inputName?>" style="visibility:hidden;height:0px"></p> |
|---|
| 913 | |
|---|
| 914 | <div id="image_photo" style="width:150px;"> |
|---|
| 915 | |
|---|
| 916 | <?php |
|---|
| 917 | if($valueRelative != "") |
|---|
| 918 | { |
|---|
| 919 | if(!(strpos($value, '<img src') === FALSE)) |
|---|
| 920 | { |
|---|
| 921 | $valueLinkArr = explode("'", $value); |
|---|
| 922 | $valueLink = $valueLinkArr[1]; |
|---|
| 923 | //$valueLink = $value; |
|---|
| 924 | |
|---|
| 925 | if(!(strpos($value, '&sw') === FALSE)) |
|---|
| 926 | { |
|---|
| 927 | // Calculating Image Width/Height |
|---|
| 928 | $arrSize = explode("=",$value); |
|---|
| 929 | $arrSize1 = explode("&",$arrSize[3]); |
|---|
| 930 | $arrSize2 = explode("&",$arrSize[4]); |
|---|
| 931 | |
|---|
| 932 | $imageWidth = $arrSize1[0]; |
|---|
| 933 | $imageHeight = $arrSize2[0]; |
|---|
| 934 | // END |
|---|
| 935 | |
|---|
| 936 | $valueArr = explode("&sw", $value); |
|---|
| 937 | $valueArr = explode("'", $valueArr[1]); |
|---|
| 938 | $value = str_replace("&sw".$valueArr[0]."'", "&sw".$valueArr[0]."&w=150&h=120' align='center' id='".$imageThumbID."'", $value); |
|---|
| 939 | } |
|---|
| 940 | else if(!(strpos($value, '&w') === FALSE)) |
|---|
| 941 | { |
|---|
| 942 | // Calculating Image Width/Height |
|---|
| 943 | $arrSize = explode("=",$value); |
|---|
| 944 | $arrSize1 = explode("&",$arrSize[3]); |
|---|
| 945 | $arrSize2 = explode("'",$arrSize[4]); |
|---|
| 946 | |
|---|
| 947 | $imageWidth = $arrSize1[0]; |
|---|
| 948 | $imageHeight = $arrSize2[0]; |
|---|
| 949 | // END |
|---|
| 950 | |
|---|
| 951 | $valueArr = explode("&", $value); |
|---|
| 952 | $valueArr = explode("'", $valueArr[2]); |
|---|
| 953 | $value = str_replace($valueArr[0], "&w=150&h=120' align='left' id='".$imageThumbID."'", $value); |
|---|
| 954 | } |
|---|
| 955 | else |
|---|
| 956 | { |
|---|
| 957 | // Calculating Image Width/Height |
|---|
| 958 | $arrSize = explode("&",$params); |
|---|
| 959 | $arrSize1 = explode("=",$arrSize[1]); |
|---|
| 960 | $arrSize2 = explode("=",$arrSize[2]); |
|---|
| 961 | |
|---|
| 962 | $imageWidth = $arrSize1[1]; |
|---|
| 963 | $imageHeight = $arrSize2[1]; |
|---|
| 964 | // END |
|---|
| 965 | |
|---|
| 966 | $valueArr = explode("'", $value); |
|---|
| 967 | $value = str_replace($valueArr[1], $valueArr[1]."&w=150' id='".$imageThumbID."' align='", $value); |
|---|
| 968 | } |
|---|
| 969 | if(!empty($imageWidth)) |
|---|
| 970 | { |
|---|
| 971 | ?> |
|---|
| 972 | <script language="javascript"> |
|---|
| 973 | //document.getElementById('spanImageSize').innerHTML = " (<?php echo $imageWidth; echo ' x '; echo $imageHeight; ?>)"; |
|---|
| 974 | </script> |
|---|
| 975 | |
|---|
| 976 | <?php |
|---|
| 977 | } |
|---|
| 978 | echo '<a style="display: block;margin-left: auto;margin-right: auto " href="' . $valueLink . '" target="_blank">' . $value .'</a>'; |
|---|
| 979 | } |
|---|
| 980 | } |
|---|
| 981 | echo $noimage; |
|---|
| 982 | $arrSize = explode("phpThumb.php?src=",$valueLink); |
|---|
| 983 | $fileLink = $arrSize[1]; |
|---|
| 984 | $andPos = strpos($arrSize[1],"?"); |
|---|
| 985 | if ($andPos === FALSE) $andPos = strpos($arrSize[1],"&"); |
|---|
| 986 | |
|---|
| 987 | // Remove & parameters from file path |
|---|
| 988 | if ($andPos>0) $fileLink = substr($arrSize[1], 0, $andPos); |
|---|
| 989 | |
|---|
| 990 | $ext = substr($fileLink, -3, 3); |
|---|
| 991 | |
|---|
| 992 | |
|---|
| 993 | /*$arrSizeext = explode("&",$arrSize[1]); |
|---|
| 994 | if (sizeof($arrSizeext) > 1){ |
|---|
| 995 | $ext = substr($arrSizeext[0],-4, -1); |
|---|
| 996 | $fileLink = substr($arrSizeext[0],0, -1); |
|---|
| 997 | } |
|---|
| 998 | else { |
|---|
| 999 | $ext = substr($arrSizeext[0],-3); |
|---|
| 1000 | $fileLink = $arrSizeext[0]; |
|---|
| 1001 | }*/ |
|---|
| 1002 | ?> |
|---|
| 1003 | |
|---|
| 1004 | <div id="photo_edit_link_<?php echo $inputName ?>" class="photo_edit_link"> |
|---|
| 1005 | |
|---|
| 1006 | <?php |
|---|
| 1007 | if(isset($_REQUEST['post']) && $hidValue != '') |
|---|
| 1008 | { |
|---|
| 1009 | if ($useSnipshot){ |
|---|
| 1010 | echo "<a href='".RCCWP_WritePostPage::snipshot_anchor($fileLink)."' class='thickbox' tittle='Flutter'<strong onclick=prepareUpdatePhoto('$inputName')>Edit</strong> </a>" ; |
|---|
| 1011 | }else{ |
|---|
| 1012 | $cropperLink = CANVASURI."cropper.php?input_name=".urlencode($inputName)."&id=".urlencode($hidValue)."&url=".urlencode($_SERVER['REQUEST_URI'])."&imageThumbId=$imageThumbID"; |
|---|
| 1013 | ?> |
|---|
| 1014 | <a rel="gb_page_fs[]" href="<?php echo $cropperLink ?>" title="Flutter" class="greybox" id="lnkCropper"> <strong>Crop</strong> </a> |
|---|
| 1015 | <?php |
|---|
| 1016 | } |
|---|
| 1017 | } |
|---|
| 1018 | ?> |
|---|
| 1019 | |
|---|
| 1020 | </div> |
|---|
| 1021 | </div> |
|---|
| 1022 | <br /> |
|---|
| 1023 | <div id="image_input"> |
|---|
| 1024 | |
|---|
| 1025 | <input tabindex="3" |
|---|
| 1026 | id="<?php echo $inputName?>" |
|---|
| 1027 | name="<?php echo $inputName?>" |
|---|
| 1028 | type="hidden" |
|---|
| 1029 | class="<?php echo $requiredClass;?>" |
|---|
| 1030 | size="46" |
|---|
| 1031 | value="<?php echo $hidValue?>" |
|---|
| 1032 | /> |
|---|
| 1033 | |
|---|
| 1034 | <?php |
|---|
| 1035 | include_once( "RCCWP_SWFUpload.php" ) ; |
|---|
| 1036 | RCCWP_SWFUpload::Body($inputName, 1, $is_canvas, $urlInputSize) ; |
|---|
| 1037 | ?> |
|---|
| 1038 | |
|---|
| 1039 | </div> |
|---|
| 1040 | |
|---|
| 1041 | <input type="hidden" name="rc_cwp_meta_photos[]" value="<?php echo $inputName?>" /> |
|---|
| 1042 | <input type="hidden" name="<?php echo $inputName?>_dorename" id="<?php echo $inputName?>_dorename" value="0" /> |
|---|
| 1043 | |
|---|
| 1044 | |
|---|
| 1045 | <!-- Used to store name of URL Field --> |
|---|
| 1046 | <!--<input type="hidden" name="parent_text_<?php echo $countImageThumbID; ?>" id="parent_text_<?php echo $countImageThumbID; ?>" value="<?php echo $filepath; ?>"/> |
|---|
| 1047 | <input type="hidden" name="hidImgValue<?php echo $countImageThumbID; ?>" id="hidImgValue<?php echo $countImageThumbID; ?>" value="<?php echo $inputName; ?>_last" />--> |
|---|
| 1048 | |
|---|
| 1049 | <?php |
|---|
| 1050 | } |
|---|
| 1051 | |
|---|
| 1052 | function snipshot_anchor($fileLink) |
|---|
| 1053 | { |
|---|
| 1054 | /* |
|---|
| 1055 | return '<a rel="gb_page_fs[]" href="http://services.snipshot.com/?snipshot_input='. urlencode($fileLink).'&snipshot_callback='.urlencode(CANVASURI."RCCWP_SnipshotCallback.php").'&snipshot_output=file&snipshot_callback_agent=user&test=hello&snipshot_output_options='.urlencode("{\"filetype\":\"$ext\"}").' title="Flutter" class="greybox1" id="lnkCropper">' ; |
|---|
| 1056 | |
|---|
| 1057 | return '<a href="http://services.snipshot.com/?snipshot_input='. urlencode($fileLink).'&snipshot_callback='.urlencode(CANVASURI."RCCWP_SnipshotCallback.php").'&snipshot_output=file&snipshot_callback_agent=user&test=hello&snipshot_output_options='.urlencode("{\"filetype\":\"$ext\"}").'&KeepThis=true&TB_iframe=true&height=400&width=600" class="thickbox" title="flutter" >' ; |
|---|
| 1058 | */ |
|---|
| 1059 | return 'http://services.snipshot.com/?snipshot_input='. urlencode($fileLink).'&snipshot_callback='.urlencode(CANVASURI."RCCWP_SnipshotCallback.php").'&snipshot_output=file&snipshot_callback_agent=user&test=hello&snipshot_output_options='.urlencode("{\"filetype\":\"$ext\"}").'&KeepThis=true&TB_iframe=true&height=400&width=600' ; |
|---|
| 1060 | } |
|---|
| 1061 | |
|---|
| 1062 | function RadiobuttonListInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 1063 | { |
|---|
| 1064 | $customFieldId = ''; |
|---|
| 1065 | |
|---|
| 1066 | if (isset($_REQUEST['post'])) |
|---|
| 1067 | { |
|---|
| 1068 | $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); |
|---|
| 1069 | } |
|---|
| 1070 | else |
|---|
| 1071 | { |
|---|
| 1072 | $value = $customField->default_value[0]; |
|---|
| 1073 | } |
|---|
| 1074 | ?> |
|---|
| 1075 | |
|---|
| 1076 | <?php |
|---|
| 1077 | foreach ($customField->options as $option) : |
|---|
| 1078 | $checked = $option == $value ? 'checked="checked"' : ''; |
|---|
| 1079 | $option = attribute_escape(trim($option)); |
|---|
| 1080 | ?> |
|---|
| 1081 | <label for="" class="selectit"> |
|---|
| 1082 | <input tabindex="3" id="<?php echo $option?>" name="<?php echo $inputName?>" value="<?php echo $option?>" type="radio" <?php echo $checked?>/> |
|---|
| 1083 | <?php echo $option?> |
|---|
| 1084 | </label><br /> |
|---|
| 1085 | <?php |
|---|
| 1086 | endforeach; |
|---|
| 1087 | ?> |
|---|
| 1088 | |
|---|
| 1089 | <?php |
|---|
| 1090 | } |
|---|
| 1091 | |
|---|
| 1092 | function DateInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 1093 | { |
|---|
| 1094 | global $wpdb; |
|---|
| 1095 | $customFieldId = ''; |
|---|
| 1096 | |
|---|
| 1097 | if (isset($_REQUEST['post'])) |
|---|
| 1098 | { |
|---|
| 1099 | $customFieldId = $customField->id; |
|---|
| 1100 | $value = attribute_escape(RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter)); |
|---|
| 1101 | } |
|---|
| 1102 | else |
|---|
| 1103 | $value = strftime("%Y-%m-%d"); |
|---|
| 1104 | |
|---|
| 1105 | |
|---|
| 1106 | |
|---|
| 1107 | $sQuery = "SELECT * FROM " . RC_CWP_TABLE_CUSTOM_FIELD_PROPERTIES . " WHERE custom_field_id='".$customField->id."'"; |
|---|
| 1108 | $result = $wpdb->get_results($sQuery); |
|---|
| 1109 | |
|---|
| 1110 | $arrDateFormat = explode('"', $result[0]->properties); |
|---|
| 1111 | $dateFormat = $arrDateFormat[3]; |
|---|
| 1112 | |
|---|
| 1113 | // If the field is at right, set a constant width to the text box |
|---|
| 1114 | $field_group = RCCWP_CustomGroup::Get($customField->group_id); |
|---|
| 1115 | $inputSize = 25; |
|---|
| 1116 | if ($field_group->at_right){ |
|---|
| 1117 | $inputSize = 15; |
|---|
| 1118 | } |
|---|
| 1119 | |
|---|
| 1120 | |
|---|
| 1121 | ?> |
|---|
| 1122 | <script type="text/javascript"> |
|---|
| 1123 | |
|---|
| 1124 | addEventHandler(window, 'load',function () { |
|---|
| 1125 | InitializeDateObject('<?php echo $inputName?>', '<?php echo $dateFormat?>', '<?php echo $value?>'); |
|---|
| 1126 | }); |
|---|
| 1127 | |
|---|
| 1128 | InitializeDateObject('<?php echo $inputName?>', '<?php echo $dateFormat?>', '<?php echo $value?>'); |
|---|
| 1129 | |
|---|
| 1130 | |
|---|
| 1131 | </script> |
|---|
| 1132 | |
|---|
| 1133 | |
|---|
| 1134 | <input tabindex="3" id="display_date_field_<?php echo $inputName?>" value="<?php echo $value?>" type="text" size="<?php echo $inputSize?>" READONLY /> |
|---|
| 1135 | <input tabindex="3" id="date_field_<?php echo $inputName?>" name="<?php echo $inputName?>" value="<?php echo $value?>" type="hidden" /> |
|---|
| 1136 | <input type="button" value="Pick..." onclick="dp_cal['<?php echo $inputName?>'].toggle();" /> |
|---|
| 1137 | <input type="button" value="Today" onclick="today_date('<?php echo $inputName?>', '<?php echo $dateFormat?>');" /> |
|---|
| 1138 | |
|---|
| 1139 | <input type="hidden" name="rc_cwp_meta_date[]" value="<?php echo $inputName?>" /> |
|---|
| 1140 | |
|---|
| 1141 | |
|---|
| 1142 | <?php |
|---|
| 1143 | } |
|---|
| 1144 | |
|---|
| 1145 | function AudioInterface($customField, $inputName, $groupCounter, $fieldCounter) |
|---|
| 1146 | { |
|---|
| 1147 | $customFieldId = ''; |
|---|
| 1148 | $freshPageFolderName = (dirname(plugin_basename(__FILE__))); |
|---|
| 1149 | if ($customField->required_field) $requiredClass = "field_required"; |
|---|
| 1150 | |
|---|
| 1151 | |
|---|
| 1152 | if (isset($_REQUEST['post'])) |
|---|
| 1153 | { |
|---|
| 1154 | $customFieldId = $customField->id; |
|---|
| 1155 | $valueOriginal = RCCWP_CustomField::GetCustomFieldValues(true, $_REQUEST['post'], $customField->name, $groupCounter, $fieldCounter); |
|---|
| 1156 | $path = CANVASURI . 'files_flutter/'; |
|---|
| 1157 | $$valueOriginalRelative = $valueOriginal; |
|---|
| 1158 | $valueOriginal = $path.$valueOriginal; |
|---|
| 1159 | if (!empty($valueOriginal)) |
|---|
| 1160 | $value = stripslashes(trim("\<div style=\'width:260px;padding-top:3px;\'\>\<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase='\http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\' width=\'95%\' height=\'20\' wmode=\'transparent\' \>\<param name=\'movie\' value=\'".CANVASURI."js/singlemp3player.swf?file=".urlencode($valueOriginal)."\' wmode=\'transparent\' /\>\<param name=\'quality\' value=\'high\' wmode=\'transparent\' /\>\<embed src=\'".CANVASURI."js/singlemp3player.swf?file=".urlencode($valueOriginal)."' width=\'100\%\' height=\'20\' quality=\'high\' pluginspage=\'http://www.macromedia.com/go/getflashplayer\' type=\'application/x-shockwave-flash\' wmode=\'transparent\' \>\</embed\>\</object\>\</div\><br />")); |
|---|
| 1161 | } |
|---|
| 1162 | |
|---|
| 1163 | // If the field is at right, set a constant width to the text box |
|---|
| 1164 | $field_group = RCCWP_CustomGroup::Get($customField->group_id); |
|---|
| 1165 | $urlInputSize = false; |
|---|
| 1166 | $is_canvas = 0; |
|---|
| 1167 | if ($field_group->at_right){ |
|---|
| 1168 | $urlInputSize = 5; |
|---|
| 1169 | $is_canvas = 1; |
|---|
| 1170 | } |
|---|
| 1171 | |
|---|
| 1172 | ?> |
|---|
| 1173 | <p class="error_msg_txt" id="upload_progress_<?php echo $inputName?>" style="visibility:hidden;height:0px"></p> |
|---|
| 1174 | |
|---|
| 1175 | |
|---|
| 1176 | <?php if( $$valueOriginalRelative ){ echo $value; } ?> |
|---|
| 1177 | |
|---|
| 1178 | |
|---|
| 1179 | <input tabindex="3" |
|---|
| 1180 | id="<?php echo $inputName?>" |
|---|
| 1181 | name="<?php echo $inputName?>" |
|---|
| 1182 | type="hidden" |
|---|
| 1183 | class="<?php echo $requiredClass;?>" |
|---|
| 1184 | size="46" |
|---|
| 1185 | value="<?php echo $$valueOriginalRelative?>" |
|---|
| 1186 | /> |
|---|
| 1187 | |
|---|
| 1188 | |
|---|
| 1189 | <?php |
|---|
| 1190 | include_once( "RCCWP_SWFUpload.php" ) ; |
|---|
| 1191 | RCCWP_SWFUpload::Body($inputName, 2, $is_canvas, $urlInputSize) ; |
|---|
| 1192 | |
|---|
| 1193 | } |
|---|
| 1194 | |
|---|
| 1195 | } |
|---|
| 1196 | ?> |
|---|