예제 #1
0
 /**
  * Add a new Pageimage item, or create one from it's filename and add it.
  *
  * @param Pageimage|string $item If item is a string (filename) then the Pageimage instance will be created automatically.
  * @return $this
  *
  */
 public function add($item)
 {
     if (is_string($item)) {
         $item = new Pageimage($this, $item);
     }
     return parent::add($item);
 }
예제 #2
0
 /**
  * Does this field have the given file name? If so, return it, if not return null.
  *
  * @param string $name Basename is assumed
  * @return null|Pagefile Returns Pagefile object if found, null if not
  *
  */
 public function getFile($name)
 {
     $hasFile = parent::getFile($name);
     if ($hasFile) {
         return $hasFile;
     }
     $name = basename($name);
     $pos = strpos($name, '.');
     $base = substr($name, 0, $pos);
     foreach ($this as $pagefile) {
         if (strpos($pagefile->basename, $base) !== 0) {
             continue;
         }
         // they start the same, is it a variation?
         if (!$pagefile->isVariation($name)) {
             continue;
         }
         // if we are here we found a variation
         $hasFile = $pagefile;
         break;
     }
     return $hasFile;
 }