remove() public method

remove the path
Since: 3.0.0
public remove ( string $path = null )
$path string name of the $path
Ejemplo n.º 1
0
 /**
  * render
  *
  * @since 2.6.0
  *
  * @param string $directory
  * @param array $options
  *
  * @return string
  */
 public static function render($directory = null, $options = null)
 {
     $output = null;
     $outputItem = null;
     /* html elements */
     $imageElement = new Html\Element();
     $imageElement->init('img', array('class' => self::$_config['className']['image']));
     $linkElement = new Html\Element();
     $linkElement->init('a');
     $listElement = new Html\Element();
     $listElement->init('ul', array('class' => self::$_config['className']['list']));
     /* gallery directory */
     $galleryDirectory = new Directory();
     $galleryDirectory->init($directory, self::$_config['thumbDirectory']);
     $galleryDirectoryArray = $galleryDirectory->getArray();
     /* adjust order */
     if ($options['order'] === 'desc') {
         $galleryDirectoryArray = array_reverse($galleryDirectoryArray);
     }
     /* gallery data */
     $galleryCounter = 0;
     $galleryTotal = count($galleryDirectoryArray);
     $galleryId = uniqid('gallery-');
     /* remove thumbs */
     if ($options['command'] === 'remove' || !$galleryTotal) {
         $galleryDirectory->remove(self::$_config['thumbDirectory']);
     } else {
         /* process directory */
         foreach ($galleryDirectoryArray as $key => $value) {
             $imagePath = $directory . '/' . $value;
             $thumbPath = $directory . '/' . self::$_config['thumbDirectory'] . '/' . $value;
             /* create thumbs */
             if ($options['command'] === 'create' || !is_file($thumbPath)) {
                 self::_createThumb($value, $directory, $options);
             }
             /* image data */
             $imageData = self::_getImageData($imagePath);
             /* collect item output */
             $outputItem .= '<li>';
             $outputItem .= $linkElement->copy()->attr(array('href' => $imagePath, 'data-counter' => ++$galleryCounter, 'data-total' => $galleryTotal, 'data-id' => $galleryId, 'data-artist' => array_key_exists('artist', $imageData) ? $imageData['artist'] : null, 'data-date' => array_key_exists('date', $imageData) ? $imageData['date'] : null, 'data-description' => array_key_exists('description', $imageData) ? $imageData['description'] : null))->html($imageElement->copy()->attr(array('src' => $thumbPath, 'alt' => array_key_exists('description', $imageData) ? $imageData['description'] : null)));
             $outputItem .= '</li>';
         }
         $output = $listElement->attr('id', $galleryId)->html($outputItem);
     }
     return $output;
 }
 /**
  * testRemove
  *
  * @since 2.1.0
  *
  * @param array $path
  * @param array $expect
  *
  * @dataProvider providerRemove
  */
 public function testRemove($path = array(), $expect = array())
 {
     /* setup */
     $directory = new Directory();
     $directory->init(Stream::url($path[1]));
     $directory->remove($path[0]);
     /* actual */
     $actual = scandir(Stream::url($path[2]));
     /* compare */
     $this->assertEquals($expect, $actual);
 }
Ejemplo n.º 3
0
 /**
  * testRemove
  *
  * @since 3.0.0
  *
  * @param string $path
  * @param string $remove
  * @param array $expectArray
  *
  * @dataProvider providerRemove
  */
 public function testRemove($path = null, $remove = null, $expectArray = [])
 {
     /* setup */
     $directory = new Directory();
     $directory->init(Stream::url($path));
     $directory->remove($remove);
     /* actual */
     $actualArray = scandir(Stream::url($path));
     /* compare */
     $this->assertEquals($expectArray, $actualArray);
 }
Ejemplo n.º 4
0
 /**
  * tearDownAfterClass
  *
  * @since 3.0.0
  */
 public static function tearDownAfterClass()
 {
     $rootDirectory = new Directory();
     $rootDirectory->init('.');
     $rootDirectory->remove('.restore');
 }
Ejemplo n.º 5
0
 /**
  * removeThumb
  *
  * @since 3.0.0
  *
  * @param string $directory
  */
 protected static function _removeThumb($directory = null)
 {
     $galleryDirectory = new Directory();
     $galleryDirectory->init($directory);
     $galleryDirectory->remove(self::$_configArray['thumbDirectory']);
 }