Ejemplo n.º 1
0
 /**
  * Adds theme data (GUID, icon, preview image) to a style if in debug mode. (used by update & insert)
  *
  * @param	string	$guid Theme GUID
  * @param	binary	$icon Theme icon
  * @param	boolean	$iconRemove Whether to remove the current icon (if there is one, and we're not uploading a new one)
  * @param	binary	$previewImage Theme preview image
  * @param	boolean	$previewImageRemove Whether to remove the current preview image (if there is one, and we're not uploading a new one)
  */
 protected function addThemeData($dostyleid, $guid, $icon, $iconRemove, $previewImage, $previewImageRemove)
 {
     $config = vB::getConfig();
     if (empty($config['Misc']['debug'])) {
         // only modify theme information in debug mode.
         return;
     }
     $style = $this->library->fetchStyleByID($dostyleid);
     $themeImporter = new vB_Xml_Import_Theme();
     $updateValues = array();
     // ----- GUID -----
     if (!empty($guid)) {
         $updateValues['guid'] = $guid;
     } else {
         $updateValues['guid'] = vB_dB_Query::VALUE_ISNULL;
     }
     // ----- Icon -----
     if (!empty($icon)) {
         // upload it & get a filedataid
         $filedataid = $themeImporter->uploadThemeImageData($icon);
         if ($filedataid > 0 and $filedataid != $style['filedataid']) {
             $updateValues['filedataid'] = $filedataid;
         }
     }
     if ($style['filedataid'] > 0 and ($iconRemove or !empty($updateValues['filedataid']))) {
         // remove previous icon (if there was one and they checked 'remove' or if there was one and we just uploaded a new one)
         vB::getDbAssertor()->assertQuery('decrementFiledataRefcount', array('filedataid' => $style['filedataid']));
         // set icon to blank if we don't have a new one
         if (empty($updateValues['filedataid'])) {
             $updateValues['filedataid'] = 0;
         }
     }
     // ----- Preview Image -----
     if (!empty($previewImage)) {
         // upload it & get a previewfiledataid
         $previewfiledataid = $themeImporter->uploadThemeImageData($previewImage);
         if ($previewfiledataid > 0 and $previewfiledataid != $style['previewfiledataid']) {
             $updateValues['previewfiledataid'] = $previewfiledataid;
         }
     }
     if ($style['previewfiledataid'] > 0 and ($previewImageRemove or !empty($updateValues['previewfiledataid']))) {
         // remove previous preview image (if there was one and they checked 'remove' or if there was one and we just uploaded a new one)
         vB::getDbAssertor()->assertQuery('decrementFiledataRefcount', array('filedataid' => $style['previewfiledataid']));
         // set preview image to blank if we don't have a new one
         if (empty($updateValues['previewfiledataid'])) {
             $updateValues['previewfiledataid'] = 0;
         }
     }
     // save
     if (!empty($updateValues)) {
         vB::getDbAssertor()->update('style', $updateValues, array('styleid' => $dostyleid));
     }
 }
Ejemplo n.º 2
0
             if ($type == vB_Cleaner::TYPE_STR) {
                 $args[$name] = $vbulletin->GPC[$name];
             } else {
                 if ($type == vB_Cleaner::TYPE_INT or $type = vB_Cleaner::TYPE_BOOL) {
                     $args[$name] = intval($vbulletin->GPC[$name]);
                 }
             }
         }
         if (is_uploaded_file($vbulletin->GPC['stylefile']['tmp_name'])) {
             // need to keep this file uploaded at the second pageload...
             $args['require_reupload'] = true;
         }
         print_cp_redirect2('template', $args);
     }
 }
 $xml_importer = new vB_Xml_Import_Theme();
 // importAdminCP($parsedXML, $startat = 0, $perpage = 1, $overwrite = false, $styleid = -1)
 try {
     // Note, title & parentid will be ignored for overwrite.
     $extras = array('title' => $vbulletin->GPC['title'], 'parentid' => $vbulletin->GPC['parentid'], 'displayorder' => $vbulletin->GPC['displayorder'], 'userselect' => $vbulletin->GPC['userselect']);
     $imported = $xml_importer->importAdminCP($parsedXML, $startat, $perpage, $vbulletin->GPC['overwrite'], $vbulletin->GPC['overwritestyleid'], $vbulletin->GPC['anyversion'], $extras);
 } catch (vB_Exception_AdminStopMessage $e) {
     $args = $e->getParams();
     $errorMsg = construct_phrase($vbphrase['theme_import_failed_x'], $vbphrase[$args[0]]);
     print_cp_message($errorMsg);
 }
 // need to pass in some data to the next POST
 if (!$imported['done'] and isset($imported['overwritestyleid'])) {
     // See a few lines below where $args are set from the existing GPC values before they're passed into print_cp_redirect2();
     $vbulletin->GPC['overwritestyleid'] = $imported['overwritestyleid'];
 }
Ejemplo n.º 3
0
 protected function getDefaultParentTheme()
 {
     // If the default parent theme exists, return it. Else, create it & return it.
     self::$themeParent = $this->db->getRow('style', array('guid' => self::DEFAULT_PARENT_GUID));
     if (!empty(self::$themeParent['guid'])) {
         return self::$themeParent;
     } else {
         /*
         				VBV-12430 Automatically install packaged themes :
         					If there are themes to install, create an empty style call themes.
         					Make all installed themes children of this new style.
         					This style should itself be a theme (so it is not editable, etc) but should not be displayed or selected
         */
         $parentTitle = vB_Api::instanceInternal('phrase')->fetch('theme_parent_name');
         $parentTitle = $parentTitle['theme_parent_name'];
         $defaultData = array('guid' => self::DEFAULT_PARENT_GUID, 'title' => $parentTitle, 'parentid' => -1, 'displayorder' => 0, 'userselect' => 0);
         // we need to add the blank style
         $styleid = $this->db->insert('style', $defaultData);
         if (empty($styleid) or !is_numeric($styleid)) {
             // if we can't create the default parent, we don't want to recurse forever.
             throw new vB_Exception_AdminStopMessage('theme_failed_to_create_parent');
         }
         // no reason to copy code. The DB Fetch at the beginning of this function will handle retrieving
         // the newly created style.
         return $this->getDefaultParentTheme();
     }
 }