Ejemplo n.º 1
0
 /**
  * Writes the skins and templates to the database
  *
  * @param $allowOverwrite
  *		set to 1 when allowed to overwrite existing skins with the same name
  *		(default = 0)
  */
 function writeToDatabase($allowOverwrite = 0)
 {
     $existingSkins = $this->checkSkinNameClashes();
     $existingTemplates = $this->checkTemplateNameClashes();
     // if not allowed to overwrite, check if any nameclashes exists
     if (!$allowOverwrite) {
         if (sizeof($existingSkins) > 0 || sizeof($existingTemplates) > 0) {
             return _SKINIE_NAME_CLASHES_DETECTED;
         }
     }
     foreach ($this->skins as $skinName => $data) {
         // 1. if exists: delete all part data, update desc data
         //    if not exists: create desc
         if (in_array($skinName, $existingSkins)) {
             $skinObj = SKIN::createFromName($skinName);
             // delete all parts of the skin
             $skinObj->deleteAllParts();
             // update general info
             $skinObj->updateGeneralInfo($skinName, $data['description'], $data['type'], $data['includeMode'], $data['includePrefix']);
         } else {
             $skinid = SKIN::createNew($skinName, $data['description'], $data['type'], $data['includeMode'], $data['includePrefix']);
             $skinObj = new SKIN($skinid);
         }
         // 2. add parts
         foreach ($data['parts'] as $partName => $partContent) {
             $skinObj->update($partName, $partContent);
         }
     }
     foreach ($this->templates as $templateName => $data) {
         // 1. if exists: delete all part data, update desc data
         //    if not exists: create desc
         if (in_array($templateName, $existingTemplates)) {
             $templateObj = TEMPLATE::createFromName($templateName);
             // delete all parts of the template
             $templateObj->deleteAllParts();
             // update general info
             $templateObj->updateGeneralInfo($templateName, $data['description']);
         } else {
             $templateid = TEMPLATE::createNew($templateName, $data['description']);
             $templateObj = new TEMPLATE($templateid);
         }
         // 2. add parts
         foreach ($data['parts'] as $partName => $partContent) {
             $templateObj->update($partName, $partContent);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @todo document this
  */
 function action_skinclone()
 {
     global $member;
     $skinid = intRequestVar('skinid');
     $member->isAdmin() or $this->disallow();
     // 1. read skin to clone
     $skin =& new SKIN($skinid);
     $name = "clone_" . $skin->getName();
     // if a skin with that name already exists:
     if (SKIN::exists($name)) {
         $i = 1;
         while (SKIN::exists($name . $i)) {
             $i++;
         }
         $name .= $i;
     }
     // 2. create skin desc
     $newid = SKIN::createNew($name, $skin->getDescription(), $skin->getContentType(), $skin->getIncludeMode(), $skin->getIncludePrefix());
     // 3. clone
     /*
     $this->skinclonetype($skin, $newid, 'index');
     $this->skinclonetype($skin, $newid, 'item');
     $this->skinclonetype($skin, $newid, 'archivelist');
     $this->skinclonetype($skin, $newid, 'archive');
     $this->skinclonetype($skin, $newid, 'search');
     $this->skinclonetype($skin, $newid, 'error');
     $this->skinclonetype($skin, $newid, 'member');
     $this->skinclonetype($skin, $newid, 'imagepopup');
     */
     $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
     $res = sql_query($query);
     while ($row = sql_fetch_assoc($res)) {
         $this->skinclonetype($skin, $newid, $row['stype']);
     }
     $this->action_skinoverview();
 }