Esempio n. 1
0
 /**
  * Remove directory and all its content recursively.
  *
  * @param string $filepath
  * @return boolean
  */
 function recursiveRemoveDir($filepath)
 {
     if (is_dir($filepath) && !is_link($filepath)) {
         if ($dh = opendir($filepath)) {
             while (($sf = readdir($dh)) !== false) {
                 if ($sf == '.' || $sf == '..') {
                     continue;
                 }
                 if (!PhotoQHelper::recursiveRemoveDir($filepath . '/' . $sf)) {
                     $rmError = new PhotoQErrorMessage($filepath . '/' . $sf . ' could not be deleted.');
                     $rmError->show();
                 }
             }
             closedir($dh);
         }
         return rmdir($filepath);
     }
     if (file_exists($filepath)) {
         return unlink($filepath);
     } else {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Runs any automatic upgrading things when changing between versions.
  *
  */
 function _autoUpgrade()
 {
     if ($this->_version != get_option("wimpq_version")) {
         // upgrade to 1.8. the structure of views changed, we don't want to force a rebuild on our users
         // so we deal with it here, adjusting the old views to the new ones
         $oldOptionArray = get_option('wimpq_options');
         if (!isset($oldOptionArray['views'])) {
             $views = array();
             $views['views'] = array('content' => 0, 'excerpt' => 0);
             //copy the old settings over
             $views['content'] = $oldOptionArray['contentView'];
             $views['excerpt'] = $oldOptionArray['excerptView'];
             //store the new views setting
             $oldOptionArray['views'] = $views;
             //remove the old guys
             unset($oldOptionArray['contentView']);
             unset($oldOptionArray['excerptView']);
             update_option('wimpq_options', $oldOptionArray);
             //reload to make the changes active
             $this->_oc->load();
         }
         // upgrade to 1.5.2 requires removing content of old photoq cache directory
         // if upgrading from 1.5 ...
         $oldPhotoQPath = str_replace('photoq-photoblog-plugin', 'whoismanu-photoq', PHOTOQ_PATH);
         $oldCachePath = $oldPhotoQPath . 'cache';
         if (file_exists($oldCachePath)) {
             PhotoQHelper::recursiveRemoveDir($oldCachePath);
         }
         // ...or removing content of cache directory in other location if upgrading from 1.5.1
         $oldCachePath = PHOTOQ_PATH . 'cache';
         if (file_exists($oldCachePath)) {
             PhotoQHelper::recursiveRemoveDir($oldCachePath);
         }
         // upgrade to 1.5.2 requires content rebuild because p tags changed to divs
         if ($this->_version == '1.5.2' && $this->_oc->getValue('inlineDescr')) {
             //get all photo posts, foreach size, rebuild the content
             foreach ($this->_db->getAllPublishedPhotos() as $photo) {
                 @$photo->rebuild(array(), false, true, false, '', '');
             }
         }
         // upgrade the database tables
         $this->_db->upgrade($this->_version);
     }
 }
 /**
  * Callback function that is called whenever a image size is deleted in the PhotoQ Settings.
  * @param $name	String	the name of the image size to be deleted
  * @return true on success, false on failure
  */
 function delImageSizeCallback($name)
 {
     $imageSizeDir = $this->getImgDir() . $name;
     //remove corresponding dirs from server
     if (!file_exists($imageSizeDir) || PhotoQHelper::recursiveRemoveDir($imageSizeDir)) {
         return true;
     } else {
         $this->_errStack->push(PHOTOQ_IMGSIZE_DEL_FAILED, 'error', array('imgDir' => $imageSizeDir));
         return false;
     }
 }
Esempio n. 4
0
 /**
  * Runs any automatic upgrading things when changing between versions.
  *
  */
 function autoUpgrade()
 {
     if ($this->_version != get_option("wimpq_version")) {
         // upgrade to 1.5.2 requires removing content of old photoq cache directory
         // if upgrading from 1.5 ...
         $oldPhotoQPath = str_replace('photoq-photoblog-plugin', 'whoismanu-photoq', PHOTOQ_PATH);
         $oldCachePath = $oldPhotoQPath . 'cache';
         if (file_exists($oldCachePath)) {
             PhotoQHelper::recursiveRemoveDir($oldCachePath);
         }
         // ...or removing content of cache directory in other location if upgrading from 1.5.1
         $oldCachePath = PHOTOQ_PATH . 'cache';
         if (file_exists($oldCachePath)) {
             PhotoQHelper::recursiveRemoveDir($oldCachePath);
         }
         // upgrade to 1.5.2 requires content rebuild because p tags changed to divs
         if ($this->_version == '1.5.2' && $this->_oc->getValue('inlineDescr')) {
             //get all photo posts, foreach size, rebuild the content
             foreach ($this->_db->getAllPublishedPhotos() as $photo) {
                 @$photo->rebuild(array(), false, true, false, '', '');
             }
         }
         // upgrade the database tables
         $this->_db->upgrade($this->_version);
     }
 }
Esempio n. 5
0
 function removeImageSize($name)
 {
     $imageSizeDir = $this->getImgDir() . $name;
     //remove corresponding dirs from server
     if (!file_exists($imageSizeDir) || PhotoQHelper::recursiveRemoveDir($imageSizeDir)) {
         $imageSizes =& $this->_options['imageSizes'];
         //remove from database
         $imageSizes->removeChild($name);
         $this->_store();
     } else {
         return new PhotoQErrorMessage(sprintf(__('Could not remove image size. The required directories in %s could not be removed. Please check your settings.', 'PhotoQ'), $imageSizeDir));
     }
     return new PhotoQStatusMessage(__("Image size successfully removed.", 'PhotoQ'));
 }