/** * Creates the formatted exif list. Only tags selected in PhotoQ * and that are present in the current photo are displayed. * TagsFromExif are shown as links to the corresponding tag pages. * @param $exif the full exif data array of this post * @param $tags the exif tags that are selected in photoq * @param $tagsFromExif the exif tags that were chosen as post_tags via tagFromExif * @return string formatted exif outpout in form of unordered html list */ function getFormattedExif($exif, $tags, $tagsFromExif, $displayNames, $displayOptions) { if (!empty($tags) && !is_array($tags)) { //is it a comma separated list? $tags = array_unique(explode(',', $tags)); } if (!is_array($tags) || count($tags) < 1) { //still nothing? $result = ''; } else { $result = $displayOptions['before']; //'<ul class="photoQExifInfo">'; $foundOne = false; //we don't want to print <ul> if there is no exif in the photo foreach ($tags as $tag) { if (array_key_exists($tag, $exif)) { $foundOne = true; if (empty($displayOptions['elementFormatting'])) { //go with default $displayOptions['elementFormatting'] = '<li class="photoQExifInfoItem"><span class="photoQExifTag">[key]:</span> <span class="photoQExifValue">[value]</span></li>'; } $displayName = $tag; //do we need to display a special name if (!empty($displayNames[$tag])) { $displayName = $displayNames[$tag]; } $value = $exif[$tag]; //do we need a tag link? if (in_array($tag, $tagsFromExif)) { //yes, so try to get an id and then the link $term = get_term_by('name', $value, 'post_tag'); if ($term) { $value = '<a href="' . get_tag_link($term->term_id) . '">' . $value . '</a>'; } } $result .= PhotoQHelper::formatShorttags($displayOptions['elementFormatting'], array('key' => $displayName, 'value' => $value)); $result .= $displayOptions['elementBetween']; } } //remove last occurrence of elementBetween $result = preg_replace('/' . preg_quote($displayOptions['elementBetween']) . '$/', '', $result); $result .= $displayOptions['after']; //'</ul>'; if (!$foundOne) { $result = ''; } } return $result; }
?> </div> <div class="qHCol qEdit"></div> <div class="qHCol qDelete"></div> <div class="clr"> </div> </div> <ul id="photoq"> <?php for ($i = 0; $i < $qLength; $i++) { //get the i-th photo from the queue $currentPhoto =& $this->_queue->getQueuedPhoto($i); //construct the url to the fullsize image $imgUrl = PhotoQHelper::getRelUrlFromPath($currentPhoto->getPath()); $path = $currentPhoto->getAdminThumbURL(); $deleteLink = 'edit.php?page=whoismanu-photoq.php&action=delete&entry=' . $currentPhoto->getId(); $deleteLink = function_exists('wp_nonce_url') ? wp_nonce_url($deleteLink, 'photoq-deleteQueueEntry' . $currentPhoto->getId()) : $deleteLink; ?> <li id="photoq-<?php echo $currentPhoto->getId(); ?> " class='photoqEntry'> <div class="qCol qPosition"><?php echo $i + 1; ?> </div> <div class="qCol qThumb"> <a class="img_link" href="<?php
/** * Process previously stored BatchSets * @param $id integer The id of the batch to be executed * @return PhotoQBatchResult the result of the operation */ function executeBatch($id) { PhotoQHelper::debug('enter executeBatch()'); $timer =& PhotoQSingleton::getInstance('PhotoQTimers'); $timer->start('batchProcessing'); $bp =& new PhotoQBatchProcessor($this, $id); PhotoQHelper::debug('calling process()'); return $bp->process(); }
/** * Our own little parser as there doesn't seem to be a reasonable one that works * with both PHP4 and PHP5. A bit cumbersome and certainly not nice but it seems * to work. * * @param string $content * @return string */ function getInlineDescription($content, $className = 'photoQDescr') { $descr = ''; $photoQDescrTagsInnerHTML = array(); $pTags = PhotoQHelper::getHTMLTags('div', $content); PhotoQHelper::debug('pTags: ' . print_r($pTags, true)); foreach ($pTags as $pTag) { $matches = array(); $found = preg_match('#^(<div.*?class="' . $className . '".*?>)#', $pTag, $matches); if ($found) { //remove the p start and end tag, the rest is the description. array_push($photoQDescrTagsInnerHTML, str_replace($matches[1], '', substr($pTag, 0, strlen($pTag) - 6))); } } PhotoQHelper::debug('photoQDescrTagsInnerHTML: ' . print_r($photoQDescrTagsInnerHTML, true)); //if we have more than one p.photoQDescr tag, it means that there were several //lines created in the editor -> wrap each one with a p tag. $numDescrTags = count($photoQDescrTagsInnerHTML); if ($numDescrTags == 1) { $descr = $photoQDescrTagsInnerHTML[0]; } else { for ($i = 0; $i < $numDescrTags; $i++) { if ($photoQDescrTagsInnerHTML[$i] !== '') { $descr .= "<p>{$photoQDescrTagsInnerHTML[$i]}</p>"; } } } PhotoQHelper::debug('descr:' . $descr); return $descr; }
/** * Hook called upon deactivation of plugin. * */ function deactivatePlugin() { PhotoQHelper::debug('plugin deactivated'); }
/** * Given array of shorttags, checks whether the format string contains least one of them. * @param $format * @param $tags * @return unknown_type */ function containsAnyOfTheseShorttags($format, $tags) { foreach ($tags as $tag) { if (PhotoQHelper::containsShorttag($format, $tag)) { return true; } } return false; }
/** * Populate the lists of image sizes with the names of registered image sizes as key, value pair. * * @param array $imgSizeNames * @access public */ function populate($imgSizeNames, $addOriginal = true) { //add the original as an option if ($addOriginal) { array_push($imgSizeNames, 'original'); } $singleSize =& $this->getOptionByName($this->_name . 'View-singleSize'); $singleSize->populate(PhotoQHelper::arrayCombine($imgSizeNames, $imgSizeNames)); $imgLinkSize =& $this->getOptionByName($this->_name . 'View-imgLinkSize'); $imgLinkSize->populate(PhotoQHelper::arrayCombine($imgSizeNames, $imgSizeNames)); $imgLinkTargetSize =& $this->getOptionByName($this->_name . 'View-imgLinkTargetSize'); $imgLinkTargetSize->populate(PhotoQHelper::arrayCombine($imgSizeNames, $imgSizeNames)); }
<div class="submit"> <input type="submit" class="button-primary submit-btn" name="save_batch" value="<?php _e('Save Changes', 'PhotoQ'); ?> " /> <input type="submit" class="button-secondary submit-btn" onclick="window.location = window.location.href;" value="<?php _e('Cancel', 'PhotoQ'); ?> " /> </div> </div> </form> <?php PhotoQHelper::debug('form over'); break; case 'batchProcessing': check_ajax_referer("photoq-batchProcess"); PhotoQHelper::debug('starting batch with id: ' . $_POST['id']); $photoqBatchResult = $photoq->executeBatch($_POST['id']); PhotoQHelper::debug('executed'); $photoqErrMsg = PhotoQErrorHandler::showAllErrorsExcept($photoqErrStack, array(PHOTOQ_QUEUED_PHOTO_NOT_FOUND), false); echo '{ "percentage": "' . $photoqBatchResult->getPercentage() * 100 . '", "message": "' . $photoqBatchResult->getMessage() . '", "errorMessage": "' . addslashes($photoqErrMsg) . '" }'; break; }
/** * Returns the batch sets associated with batch of given id. * @param $id * @return unknown_type */ function getBatchSets($id) { $setObj = $this->_wpdb->get_row("SELECT batch FROM {$this->QBATCH_TABLE} WHERE bid='{$id}'"); PhotoQHelper::debug('db getBatchSets: ' . print_r($setObj->batch, true)); PhotoQHelper::debug('db getBatchSets unser: ' . print_r(unserialize($setObj->batch), true)); return unserialize($setObj->batch); }
<input type="file" class="button-secondary" name="Filedata" id="Filedata" /> <input type="submit" class="button-secondary action" value="Upload"/> <input type="hidden" name="batch_upload" value="0"> <?php } ?> </div> <div class="alignleft actions"> <input type="button" id="cancelbtn" class="button-secondary action" onclick="cancelUpload()" value="<?php _e('Cancel', 'PhotoQ'); ?> " /> </div> <div class="alignright actions"> <?php if (!PhotoQHelper::isWPMU() && $this->_oc->getValue('enableFtpUploads')) { ?> <input type="submit" id="ftpUploadBtn" name="ftp_upload" class="button-secondary action" value="<?php _e('Import from FTP directory...', 'PhotoQ'); ?> " /> <?php } ?> </div> </div> </form> <div id="SWFUploadFileListingFiles"></div> <br class="clr" />
/** * Overwrites default behavior. No call to phpThumb needed for original photo. * Just move it to the imgdir. * * @param unknown_type $oldOriginalPath * @return unknown */ function createPhoto($oldOriginalPath, $moveOriginal = true) { //create directory if (!PhotoQHelper::createDir($this->_yearMonthDirPath)) { return new PhotoQErrorMessage(sprintf(_c('Error when creating directory: %s| dirname', 'PhotoQ'), $this->_yearMonthDirPath)); } //move the image file if (!file_exists($this->_path)) { if ($moveOriginal) { if (!PhotoQHelper::moveFile($oldOriginalPath, $this->_path)) { return new PhotoQErrorMessage(sprintf(_c('Unable to move %s, posting aborted.| imgname', 'PhotoQ'), $this->_imgName)); } } else { //we don't move we only copy if (!copy($oldOriginalPath, $this->_path)) { return new PhotoQErrorMessage(sprintf(_c('Unable to copy %s, posting aborted.| imgname', 'PhotoQ'), $this->_imgName)); } } } else { return new PhotoQErrorMessage(sprintf(_c('Image %s already exists, posting aborted.| imgname', 'PhotoQ'), $this->_imgName)); } return new PhotoQStatusMessage(__('Original photo moved successfully')); }
PhotoQHelper::debug('manage_page: reached edit-batch panel'); ?> <div class="wrap"> <h2><?php _e('Manage PhotoQ - Enter Info', 'PhotoQ'); ?> </h2> <form method="post" enctype="multipart/form-data" action="edit.php?page=whoismanu-photoq.php"> <div id="poststuff"> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('photoq-saveBatch', 'saveBatchNonce'); } PhotoQHelper::debug('manage_page: passed nonce in edit-batch panel'); $photosToEdit = $this->_queue->getQueuedUneditedPhotos(); foreach ($photosToEdit as $currentToEdit) { echo '<div class="photo_info">'; $currentToEdit->showPhotoEditForm(); echo '</div>'; } ?> </div> <div> <input type="submit" class="button-primary action" name="save_batch" value="<?php _e('Save Batch Info', 'PhotoQ'); ?> »" /> </div>
require_once PHOTOQ_PATH . 'classes/PhotoQ.php'; // import ReusableOptions Library, same here add safety check if (!class_exists("OptionController")) { require_once PHOTOQ_PATH . 'lib/ReusableOptions/OptionController.php'; } //import remaining PhotoQ classes require_once PHOTOQ_PATH . 'classes/PhotoQOptionController.php'; require_once PHOTOQ_PATH . 'classes/PhotoQDB.php'; require_once PHOTOQ_PATH . 'classes/PhotoQQueue.php'; require_once PHOTOQ_PATH . 'classes/PhotoQBatch.php'; require_once PHOTOQ_PATH . 'classes/PhotoQPhoto.php'; require_once PHOTOQ_PATH . 'classes/PhotoQExif.php'; require_once PHOTOQ_PATH . 'classes/PhotoQImageSize.php'; } if (class_exists("PhotoQ")) { PhotoQHelper::debug('enter photoq exists()'); //$timer =& PhotoQSingleton::getInstance('PhotoQTimers'); //$timer->start('photoQInit'); $photoq = new PhotoQ(); //print_r($timer->stop('photoQInit')); /*in the case where batch upload is enabled, we have to override the pluggable functions responsible for reading auth cookie, so that they allow login info to be submitted via post or get request. The reason is that the upload request comes from the flash script which doesn't have access to the user, password cookie. Try to minimize this, so only do it when something is uploaded. */ if (!function_exists('wp_validate_auth_cookie') && $photoq->_oc->getValue('enableBatchUploads') && isset($_POST['batch_upload'])) { function wp_validate_auth_cookie($cookie = '', $scheme = 'auth') { //here starts the part that is new -- get cookie value from request, model taken from media.php global $photoq; if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
?> <div class="info_unit"><label><?php _e('Post Author', 'PhotoQ'); ?> :</label><?php wp_dropdown_users(array('include' => $authors, 'name' => 'img_author', 'selected' => $user_ID)); ?> </div> </div> <?php PhotoQHelper::showMetaFieldList(); ?> <div class="wimpq_cats info_group"> <?php PhotoQHelper::showCategoryCheckboxList(); ?> </div> <br class="clr" /> <?php $submitLabel = isset($_POST['ftp_upload']) ? __('Import/Enter Info »', 'PhotoQ') : __('Enter Info »', 'PhotoQ'); ?> <p style="float: right" class="infobutton"> <input type="submit" class="button-primary action" name="edit_batch" value="<?php echo $submitLabel; ?> " /> </p> </div> <?php
/** * Reduces multidimensional array to single dimension. * * @param array $in * @return array */ function flatten($in) { $out = array(); if (is_array($in)) { foreach ($in as $key => $value) { if (is_array($value)) { unset($in[$key]); $out = array_merge($out, PhotoQHelper::flatten($value)); } else { $out[$key] = $value; } } } return $out; }
?> </table> </div> </div> <div class="postbox closed"> <h3 class="postbox-handle"><span><?php _e('Maintenance', 'PhotoQ'); ?> </span></h3> <div class="inside"> <table width="100%" cellspacing="2" cellpadding="5" class="form-table"> <?php if (!PhotoQHelper::isWPMU()) { ?> <tr valign="top"> <th scope="row"><?php _e('Upgrade:', 'PhotoQ'); ?> </th> <td><input style="vertical-align: top;" type="submit" class="button-secondary" name="showUpgradePanel" value="<?php _e('Upgrade from PhotoQ < 1.5', 'PhotoQ'); ?> »" /></td> </tr> <tr valign="top"> <th scope="row"><?php
/** * Publish the top of the queue. * * @return object PhotoQStatusMessage */ function publishTop() { PhotoQHelper::debug('enterPublishTop()'); if ($this->getLength() == 0) { return new PhotoQErrorMessage(__('Queue is empty, nothing to post.', 'PhotoQ')); } $topPhoto = $this->_queuedPhotos[0]; if ($postID = $topPhoto->publish()) { PhotoQHelper::debug('publishing ok'); $this->_postPublishingActions($topPhoto->id, $postID); $statusMsg = '<strong>' . __('Your post has been saved.', 'PhotoQ') . '</strong> <a href="' . get_permalink($postID) . '">' . __('View post', 'PhotoQ') . '</a> | <a href="post.php?action=edit&post=' . $postID . '">' . __('Edit post', 'PhotoQ') . '</a>'; PhotoQHelper::debug('leave PublishTop() returning ok message'); return new PhotoQStatusMessage($statusMsg); } else { return new PhotoQErrorMessage(__('Publishing Photo did not succeed.', 'PhotoQ')); } }