/**
  * Imports a set XMLArchive
  *
  * @access	public
  * @param	string		XMLArchive content to import
  * @param	string		Images directory name to use.
  * @param	int			[ Set ID to apply to (if desired) ]
  * @return	mixed		Number of items added, or bool
  */
 public function importImagesXMLArchive($content, $imageSetName, $setID = 0)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $addedCount = 0;
     //-----------------------------------------
     // Got anything?
     //-----------------------------------------
     if (!strstr($content, "<xmlarchive")) {
         $this->_addErrorMessage("The content was not a valid XMLArchive");
         return FALSE;
     }
     //-----------------------------------------
     // Grab the XMLArchive class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
     $xmlArchive = new classXMLArchive();
     $xmlArchive->readXML($content);
     if (!$xmlArchive->countFileArray()) {
         $this->_addErrorMessage("The XMLArchive is empty");
         return FALSE;
     }
     $added = $xmlArchive->countFileArray();
     //-----------------------------------------
     // Checks...
     //-----------------------------------------
     if ($this->checkImageDirectoryExists($imageSetName) === TRUE) {
         /* Already exists... */
         $this->_addErrorMessage("The directory public/style_images/{$imageSetName} already exists");
         return FALSE;
     }
     if ($this->createNewImageDirectory($imageSetName) !== TRUE) {
         $this->_addErrorMessage("Could not create public/style_images/{$imageSetName}. Please check file permissions and try again.");
         return FALSE;
     }
     //-----------------------------------------
     // OK, write it...
     //-----------------------------------------
     /* Find the name of the folder */
     //preg_match( "#<path>([^/]+?)</path>#", $content, $match );
     //$_strip = $match[1];
     /* Strip the path */
     //$xmlArchive->setStripPath( $_strip );
     /* Write it */
     if ($xmlArchive->write($content, $this->fetchImageDirectoryPath($imageSetName)) === FALSE) {
         $this->_addErrorMessage("Could not write the image set to disk");
         return FALSE;
     }
     //-----------------------------------------
     // Update set?
     //-----------------------------------------
     if ($setID) {
         $this->DB->update('skin_collections', array('set_image_dir' => $imageSetName), 'set_id=' . $setID);
         /* Rebuild trees */
         $this->rebuildTreeInformation($setID);
         /* Now re-load to fetch the tree information */
         $newSet = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => 'set_id=' . $setID));
         /* Add to allSkins array for caching functions below */
         $newSet['_parentTree'] = unserialize($newSet['set_parent_array']);
         $newSet['_childTree'] = unserialize($newSet['set_child_array']);
         $newSet['_userAgents'] = unserialize($newSet['set_locked_uagent']);
         $newSet['_cssGroupsArray'] = unserialize($newSet['set_css_groups']);
         $this->registry->output->allSkins[$setID] = $newSet;
         $this->rebuildSkinSetsCache($setID);
         $this->rebuildCSS($setID);
         $this->rebuildReplacementsCache($setID);
     }
     return $added;
 }
Пример #2
0
 /**
  * Imports a set XMLArchive
  *
  * @access	public
  * @param	string		XMLArchive content to import
  * @return	mixed		Number of items added, or bool
  */
 public function importXmlArchive($content)
 {
     /* Correct file type ? */
     if (!strstr($content, "<xmlarchive")) {
         return false;
     }
     /* Get XML class */
     require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
     /*noLibHook*/
     $xmlArchive = new classXMLArchive();
     $xmlArchive->readXML($content);
     /* Got stuff? */
     if (!$xmlArchive->countFileArray()) {
         return false;
     }
     /* Write it */
     if ($xmlArchive->write($content, $this->getImageDir()) === FALSE) {
         return false;
     }
     /* Check images */
     $errors = $this->checkImages();
     if ($errors['missing'] !== false or $errors['dimensions'] !== false or $errors['writeable'] !== false) {
         return false;
     }
     /* Push changes to the app */
     $this->setStyleLastUpdated(time());
     return true;
 }