Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * 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();
 }
Esempio n. 3
0
 /**
  * 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);
 }
Esempio n. 4
0
 /**
  * Hook called upon deactivation of plugin.
  *
  */
 function deactivatePlugin()
 {
     PhotoQHelper::debug('plugin deactivated');
 }
Esempio n. 5
0
 function createThumb($inFile, $outFile, $width = 0, $height = 0)
 {
     PhotoQHelper::debug('enter createThumb() ' . $this->getName());
     require_once PHOTOQ_PATH . 'lib/phpThumb_1.7.9/phpthumb.class.php';
     // create phpThumb object
     $phpThumb = new phpThumb();
     //set imagemagick path here
     $phpThumb->config_imagemagick_path = $this->_oc->getValue('imagemagickPath') ? $this->_oc->getValue('imagemagickPath') : null;
     // set data source -- do this first, any settings must be made AFTER this call
     $phpThumb->setSourceFilename($inFile);
     // PLEASE NOTE:
     // You must set any relevant config settings here. The phpThumb
     // object mode does NOT pull any settings from phpThumb.config.php
     //$phpThumb->setParameter('config_document_root', '/home/groups/p/ph/phpthumb/htdocs/');
     $phpThumb->setParameter('config_temp_directory', $this->_oc->getCacheDir());
     // set parameters (see "URL Parameters" in phpthumb.readme.txt)
     if ($height) {
         $phpThumb->setParameter('h', $height);
     }
     if ($width) {
         $phpThumb->setParameter('w', $width);
     }
     $phpThumb->setParameter('q', $this->_quality);
     //rect images may be cropped to the exact size
     if ($this->_crop) {
         $phpThumb->setParameter('zc', 'C');
     }
     //$phpThumb->setParameter('fltr', 'gam|1.2');
     if ($this->_watermark && ($wmPath = get_option('wimpq_watermark'))) {
         $phpThumb->setParameter('fltr', 'wmi|' . $wmPath . '|' . $this->_oc->getValue('watermarkPosition') . '|' . $this->_oc->getValue('watermarkOpacity') . '|' . $this->_oc->getValue('watermarkXMargin') . '|' . $this->_oc->getValue('watermarkYMargin'));
     }
     PhotoQHelper::debug('generating thumb...');
     // generate & output thumbnail
     //$output_filename = './thumbnails/'.basename($name.'_'.$largestSide.'.'.$phpThumb->config_output_format;
     if ($phpThumb->GenerateThumbnail()) {
         // this line is VERY important, do not remove it!
         PhotoQHelper::debug('generation ok');
         if ($phpThumb->RenderToFile($outFile)) {
             PhotoQHelper::debug('rendering ok');
             // do something on success
             return new PhotoQStatusMessage(__('Thumb created successfully', 'PhotoQ'));
         } else {
             PhotoQHelper::debug('rendering failed');
             // do something with debug/error messages
             return new PhotoQErrorMessage(__('Failed:', 'PhotoQ') . '<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>');
         }
     } else {
         // do something with debug/error messages
         return new PhotoQErrorMessage(__('Failed:', 'PhotoQ') . '<pre>' . $phpThumb->fatalerror . "\n\n" . implode("\n\n", $phpThumb->debugmessages) . '</pre>');
     }
 }
Esempio n. 6
0
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');
?>
 &raquo;" />
		</div>
Esempio n. 7
0
     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'])) {
Esempio n. 8
0
		
				<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;
}
Esempio n. 9
0
 /**
  * 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&amp;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'));
     }
 }