예제 #1
0
 /**
  * Function to get data from imported XML file
  *
  * @return file xml
  * @added 2.2
  */
 static function getData($file)
 {
     if (!is_admin()) {
         exit;
     }
     if (!$file['tmp_name']) {
         return RM_Status::set('error', __('No Import File Attached', 'responsive-menu'));
     }
     if ($file['type'] != 'text/xml') {
         return RM_Status::set('error', __('Incorrect Import File Format', 'responsive-menu'));
     }
     if ($file['size'] > 500000) {
         return RM_Status::set('error', __('Import File Too Large', 'responsive-menu'));
     }
     if (!is_uploaded_file($file['tmp_name'])) {
         return RM_Status::set('error', __('Import File Not Valid', 'responsive-menu'));
     }
     $data = file_get_contents($file['tmp_name']);
     $xml = simplexml_load_string($data);
     $json = json_encode($xml);
     $array = json_decode($json, TRUE);
     $decoded = array();
     foreach ($array as $key => $val) {
         /* Need to JSON Decode HTML Shapes */
         if ($key == 'RMArShpA' || $key == 'RMArShpI') {
             $decoded[$key] = is_array($val) ? null : json_decode(base64_decode($val));
         } else {
             $decoded[$key] = is_array($val) ? null : base64_decode($val);
         }
     }
     return $decoded;
 }
예제 #2
0
 /**
  * Function to create the file to hold the JS file
  *
  * @param string $js
  * @return file
  * @added 1.6
  */
 static function createJSFile($js)
 {
     $file = fopen(RM_Registry::get('config', 'plugin_data_dir') . '/js/responsive-menu-' . get_current_blog_id() . '.js', 'w');
     $jsFile = fwrite($file, $js);
     fclose($file);
     if (!$file) {
         RM_Status::set('error', __('Unable to create JS file', 'responsive-menu'));
     }
     return $jsFile;
 }
예제 #3
0
 /**
  * Function to create export XML file
  *
  * @return file xml
  * @added 2.2
  */
 static function export()
 {
     if (!is_admin()) {
         exit;
     }
     $fileName = RM_Registry::get('config', 'plugin_base_dir') . '/public/export/export.xml';
     $file = fopen($fileName, 'w+');
     if (!$file) {
         return RM_Status::set('error', __('Could not create export file, please check plugin folder permissions', 'responsive-menu'));
     }
     $xml = '<?xml version="1.0" encoding="UTF-8"?>';
     $xml .= '<RMOptions>';
     foreach (ResponsiveMenu::getOptions() as $option_key => $option_val) {
         $xml .= '<' . $option_key . '>' . $option_val . '</' . $option_key . '>';
     }
     $xml .= '</RMOptions>';
     fwrite($file, $xml);
     fclose($file);
     $link = RM_Registry::get('config', 'plugin_base_uri') . 'public/export/export.xml';
     RM_Status::set('updated', '<a href="' . $link . '">' . __('You can download your exported file by clicking here', 'responsive-menu') . '</a>');
 }
예제 #4
0
파일: Import.php 프로젝트: jekv/devia
 /**
  * Function to get data from imported XML file
  *
  * @return file xml
  * @added 2.2
  */
 static function getData($file)
 {
     if (!is_admin()) {
         exit;
     }
     if (!$file['tmp_name']) {
         return RM_Status::set('error', __('No Import File Attached', 'responsive-menu'));
     }
     if ($file['type'] != 'text/xml') {
         return RM_Status::set('error', __('Incorrect Import File Format', 'responsive-menu'));
     }
     if ($file['size'] > 500000) {
         return RM_Status::set('error', __('Import File Too Large', 'responsive-menu'));
     }
     if (!is_uploaded_file($file['tmp_name'])) {
         return RM_Status::set('error', __('Import File Not Valid', 'responsive-menu'));
     }
     $data = file_get_contents($file['tmp_name']);
     $xml = simplexml_load_string($data);
     $json = json_encode($xml);
     $array = json_decode($json, TRUE);
     return $array;
 }
예제 #5
0
 /**
  * Function to create the data folders
  *
  * @return null
  * @added 1.6
  */
 static function create()
 {
     $mainFolder = RM_Registry::get('config', 'plugin_data_dir');
     $cssFolder = RM_Registry::get('config', 'plugin_data_dir') . '/css';
     $jsFolder = RM_Registry::get('config', 'plugin_data_dir') . '/js';
     if (!file_exists($mainFolder)) {
         mkdir($mainFolder, 0777);
     }
     if (!file_exists($cssFolder)) {
         mkdir($cssFolder, 0777);
     }
     if (!file_exists($jsFolder)) {
         mkdir($jsFolder, 0777);
     }
     if (!file_exists($mainFolder)) {
         RM_Status::set('error', __('Unable to create data folders', 'responsive-menu'));
     }
     if (!file_exists($cssFolder)) {
         RM_Status::set('error', __('Unable to create CSS folders', 'responsive-menu'));
     }
     if (!file_exists($cssFolder)) {
         RM_Status::set('error', __('Unable to create JS folders', 'responsive-menu'));
     }
 }
예제 #6
0
 /**
  * Saves all the data from the admin page to the database
  *
  * @param  array  $data
  * @return null
  * @added 1.0
  */
 public static function save($data)
 {
     // Initialise Variables Correctly
     $RM = isset($data['RM']) ? $data['RM'] : RM_Registry::get('defaults', 'RM');
     $RMTitle = isset($data['RMTitle']) ? $data['RMTitle'] : RM_Registry::get('defaults', 'RMTitle');
     $RMBreak = $data['RMBreak'] ? $data['RMBreak'] : RM_Registry::get('defaults', 'RMBreak');
     $RMDepth = isset($data['RMDepth']) ? $data['RMDepth'] : RM_Registry::get('defaults', 'RMDepth');
     $RMTop = isset($data['RMTop']) ? $data['RMTop'] : RM_Registry::get('defaults', 'RMTop');
     $RMRight = isset($data['RMRight']) ? $data['RMRight'] : RM_Registry::get('defaults', 'RMRight');
     $RMCss = isset($data['RMCss']) ? $data['RMCss'] : RM_Registry::get('defaults', 'RMCss');
     $RMLineCol = !empty($data['RMLineCol']) ? $data['RMLineCol'] : RM_Registry::get('defaults', 'RMLineCol');
     $RMClickBkg = !empty($data['RMClickBkg']) ? $data['RMClickBkg'] : RM_Registry::get('defaults', 'RMClickBkg');
     $RMClickTitle = isset($data['RMClickTitle']) ? $data['RMClickTitle'] : RM_Registry::get('defaults', 'RMClickTitle');
     $RMBkgTran = isset($data['RMBkgTran']) ? $data['RMBkgTran'] : false;
     $RMPos = isset($data['RMPos']) ? $data['RMPos'] : RM_Registry::get('defaults', 'RMPos');
     $RMImage = isset($data['RMImage']) ? $data['RMImage'] : RM_Registry::get('defaults', 'RMImage');
     $RMWidth = $data['RMWidth'] ? $data['RMWidth'] : RM_Registry::get('defaults', 'RMWidth');
     $RMBkg = !empty($data['RMBkg']) ? $data['RMBkg'] : RM_Registry::get('defaults', 'RMBkg');
     $RMBkgHov = !empty($data['RMBkgHov']) ? $data['RMBkgHov'] : RM_Registry::get('defaults', 'RMBkgHov');
     $RMTitleCol = !empty($data['RMTitleCol']) ? $data['RMTitleCol'] : RM_Registry::get('defaults', 'RMTitleCol');
     $RMTextCol = !empty($data['RMTextCol']) ? $data['RMTextCol'] : RM_Registry::get('defaults', 'RMTextCol');
     $RMBorCol = !empty($data['RMBorCol']) ? $data['RMBorCol'] : RM_Registry::get('defaults', 'RMBorCol');
     $RMTextColHov = !empty($data['RMTextColHov']) ? $data['RMTextColHov'] : RM_Registry::get('defaults', 'RMTextColHov');
     $RMTitleColHov = !empty($data['RMTitleColHov']) ? $data['RMTitleColHov'] : RM_Registry::get('defaults', 'RMTitleColHov');
     /* Added in 1.6 */
     $RMAnim = isset($data['RMAnim']) ? $data['RMAnim'] : RM_Registry::get('defaults', 'RMAnim');
     $RMPushCSS = isset($data['RMPushCSS']) ? $data['RMPushCSS'] : RM_Registry::get('defaults', 'RMPushCSS');
     $RMTitleBkg = !empty($data['RMTitleBkg']) ? $data['RMTitleBkg'] : RM_Registry::get('defaults', 'RMTitleBkg');
     $RMFont = isset($data['RMFont']) ? $data['RMFont'] : RM_Registry::get('defaults', 'RMFont');
     $RMFontSize = $data['RMFontSize'] ? $data['RMFontSize'] : RM_Registry::get('defaults', 'RMFontSize');
     $RMTitleSize = $data['RMTitleSize'] ? $data['RMTitleSize'] : RM_Registry::get('defaults', 'RMTitleSize');
     $RMBtnSize = $data['RMBtnSize'] ? $data['RMBtnSize'] : RM_Registry::get('defaults', 'RMBtnSize');
     $RMCurBkg = !empty($data['RMCurBkg']) ? $data['RMCurBkg'] : RM_Registry::get('defaults', 'RMCurBkg');
     $RMCurCol = !empty($data['RMCurCol']) ? $data['RMCurCol'] : RM_Registry::get('defaults', 'RMCurCol');
     $RMAnimSpd = $data['RMAnimSpd'] !== false ? $data['RMAnimSpd'] : RM_Registry::get('defaults', 'RMAnimSpd');
     /* Added in 1.7 */
     $RMTranSpd = $data['RMTranSpd'] ? $data['RMTranSpd'] : RM_Registry::get('defaults', 'RMTranSpd');
     $RMTxtAlign = isset($data['RMTxtAlign']) ? $data['RMTxtAlign'] : RM_Registry::get('defaults', 'RMTxtAlign');
     $RMSearch = isset($data['RMSearch']) ? $data['RMSearch'] : RM_Registry::get('defaults', 'RMSearch');
     $RMExpand = isset($data['RMExpand']) ? $data['RMExpand'] : RM_Registry::get('defaults', 'RMExpand');
     $RMLinkHeight = $data['RMLinkHeight'] ? $data['RMLinkHeight'] : RM_Registry::get('defaults', 'RMLinkHeight');
     /* Added in 1.8 */
     $RMExternal = isset($data['RMExternal']) ? $data['RMExternal'] : RM_Registry::get('defaults', 'RMExternal');
     $RMSide = isset($data['RMSide']) ? $data['RMSide'] : RM_Registry::get('defaults', 'RMSide');
     /* Added in 1.9 */
     $RMFooter = isset($data['RMFooter']) ? $data['RMFooter'] : RM_Registry::get('defaults', 'RMFooter');
     $RMClickImg = isset($data['RMClickImg']) ? $data['RMClickImg'] : RM_Registry::get('defaults', 'RMClickImg');
     $RMMinify = isset($data['RMMinify']) ? $data['RMMinify'] : RM_Registry::get('defaults', 'RMMinify');
     $RMClickClose = isset($data['RMClickClose']) ? $data['RMClickClose'] : RM_Registry::get('defaults', 'RMClickClose');
     $RMRemImp = isset($data['RMRemImp']) ? $data['RMRemImp'] : RM_Registry::get('defaults', 'RMRemImp');
     $RMX = isset($data['RMX']) ? $data['RMX'] : RM_Registry::get('defaults', 'RMX');
     $RMMinWidth = isset($data['RMMinWidth']) ? $data['RMMinWidth'] : RM_Registry::get('defaults', 'RMMinWidth');
     /* Added in 2.0 */
     $RMMaxWidth = isset($data['RMMaxWidth']) ? $data['RMMaxWidth'] : RM_Registry::get('defaults', 'RMMaxWidth');
     $RMExpandPar = isset($data['RMExpandPar']) ? $data['RMExpandPar'] : false;
     $RMIgnParCli = isset($data['RMIgnParCli']) ? $data['RMIgnParCli'] : RM_Registry::get('defaults', 'RMIgnParCli');
     $RMCliToClo = isset($data['RMCliToClo']) ? $data['RMCliToClo'] : RM_Registry::get('defaults', 'RMCliToClo');
     $RMSearchPos = isset($data['RMSearchPos']) ? $data['RMSearchPos'] : RM_Registry::get('defaults', 'RMSearchPos');
     $RMTitleLink = isset($data['RMTitleLink']) ? $data['RMTitleLink'] : RM_Registry::get('defaults', 'RMTitleLink');
     $RMTitleLoc = isset($data['RMTitleLoc']) ? $data['RMTitleLoc'] : RM_Registry::get('defaults', 'RMTitleLoc');
     $RMHtml = isset($data['RMHtml']) ? $data['RMHtml'] : RM_Registry::get('defaults', 'RMHtml');
     $RMHtmlLoc = isset($data['RMHtmlLoc']) ? $data['RMHtmlLoc'] : RM_Registry::get('defaults', 'RMHtmlLoc');
     /* Added in 2.1 */
     $RMShortcode = isset($data['RMShortcode']) ? $data['RMShortcode'] : RM_Registry::get('defaults', 'RMShortcode');
     /* Added in 2.2 */
     $RMLineHeight = isset($data['RMLineHeight']) ? $data['RMLineHeight'] : RM_Registry::get('defaults', 'RMLineHeight');
     $RMLineWidth = isset($data['RMLineWidth']) ? $data['RMLineWidth'] : RM_Registry::get('defaults', 'RMLineWidth');
     $RMLineMargin = isset($data['RMLineMargin']) ? $data['RMLineMargin'] : RM_Registry::get('defaults', 'RMLineMargin');
     $RMClickImgClicked = isset($data['RMClickImgClicked']) ? $data['RMClickImgClicked'] : RM_Registry::get('defaults', 'RMClickImgClicked');
     $RMAccordion = isset($data['RMAccordion']) ? $data['RMAccordion'] : RM_Registry::get('defaults', 'RMAccordion');
     $RMArShpA = isset($data['RMArShpA']) ? $data['RMArShpA'] : RM_Registry::get('defaults', 'RMArShpA');
     $RMArShpI = isset($data['RMArShpI']) ? $data['RMArShpI'] : RM_Registry::get('defaults', 'RMArShpI');
     $RMArImgA = isset($data['RMArImgA']) ? $data['RMArImgA'] : RM_Registry::get('defaults', 'RMArImgA');
     $RMArImgI = isset($data['RMArImgI']) ? $data['RMArImgI'] : RM_Registry::get('defaults', 'RMArImgI');
     /* Added in 2.3 */
     $RMTrigger = isset($data['RMTrigger']) && !empty($data['RMTrigger']) ? $data['RMTrigger'] : RM_Registry::get('defaults', 'RMTrigger');
     $RMPushBtn = isset($data['RMPushBtn']) ? $data['RMPushBtn'] : RM_Registry::get('defaults', 'RMPushBtn');
     $RMCurBkgHov = !empty($data['RMCurBkgHov']) ? $data['RMCurBkgHov'] : RM_Registry::get('defaults', 'RMCurBkgHov');
     $RMCurColHov = !empty($data['RMCurColHov']) ? $data['RMCurColHov'] : RM_Registry::get('defaults', 'RMCurColHov');
     /* Add by MKDGS */
     $RMWalker = isset($data['RMWalker']) ? $data['RMWalker'] : RM_Registry::get('defaults', 'RMWalker');
     /* Added in 2.4 */
     $RMUseTran = isset($data['RMUseTran']) ? $data['RMUseTran'] : RM_Registry::get('defaults', 'RMUseTran');
     $RMLoc = isset($data['RMLoc']) ? $data['RMLoc'] : RM_Registry::get('defaults', 'RMLoc');
     /* Added in 2.6 Mkdgs */
     $RMThemeLocation = isset($data['RMThemeLocation']) ? $data['RMThemeLocation'] : RM_Registry::get('defaults', 'RMThemeLocation');
     $optionsArray = array('RM' => self::Filter($RM), 'RMBreak' => intval($RMBreak), 'RMDepth' => intval($RMDepth), 'RMTop' => intval($RMTop), 'RMRight' => intval($RMRight), 'RMCss' => self::Filter($RMCss), 'RMTitle' => self::Filter($RMTitle), 'RMLineCol' => self::Filter($RMLineCol), 'RMClickBkg' => self::Filter($RMClickBkg), 'RMClickTitle' => self::Filter($RMClickTitle), 'RMBkgTran' => self::Filter($RMBkgTran), 'RMFont' => self::Filter($RMFont), 'RMPos' => self::Filter($RMPos), 'RMImage' => self::Filter($RMImage), 'RMWidth' => intval($RMWidth), 'RMBkg' => self::Filter($RMBkg), 'RMBkgHov' => self::Filter($RMBkgHov), 'RMTitleCol' => self::Filter($RMTitleCol), 'RMTextCol' => self::Filter($RMTextCol), 'RMBorCol' => self::Filter($RMBorCol), 'RMTextColHov' => self::Filter($RMTextColHov), 'RMTitleColHov' => self::Filter($RMTitleColHov), 'RMAnim' => self::Filter($RMAnim), 'RMPushCSS' => self::Filter($RMPushCSS), 'RMTitleBkg' => self::Filter($RMTitleBkg), 'RMFontSize' => intval($RMFontSize), 'RMTitleSize' => intval($RMTitleSize), 'RMBtnSize' => intval($RMBtnSize), 'RMCurBkg' => self::Filter($RMCurBkg), 'RMCurCol' => self::Filter($RMCurCol), 'RMAnimSpd' => floatval($RMAnimSpd), 'RMTranSpd' => floatval($RMTranSpd), 'RMTxtAlign' => self::Filter($RMTxtAlign), 'RMSearch' => self::Filter($RMSearch), 'RMExpand' => self::Filter($RMExpand), 'RMLinkHeight' => intval($RMLinkHeight), 'RMExternal' => self::Filter($RMExternal), 'RMSide' => self::Filter($RMSide), 'RMFooter' => self::Filter($RMFooter), 'RMClickImg' => self::Filter($RMClickImg), 'RMMinify' => self::Filter($RMMinify), 'RMClickClose' => self::Filter($RMClickClose), 'RMRemImp' => self::Filter($RMRemImp), 'RMX' => self::Filter($RMX), 'RMMinWidth' => intval($RMMinWidth), 'RMMaxWidth' => intval($RMMaxWidth), 'RMExpandPar' => self::Filter($RMExpandPar), 'RMIgnParCli' => self::Filter($RMIgnParCli), 'RMCliToClo' => self::Filter($RMCliToClo), 'RMSearchPos' => self::Filter($RMSearchPos), 'RMTitleLink' => self::Filter($RMTitleLink), 'RMTitleLoc' => self::Filter($RMTitleLoc), 'RMHtml' => self::FilterHtml($RMHtml), 'RMHtmlLoc' => self::Filter($RMHtmlLoc), 'RMShortcode' => self::Filter($RMShortcode), 'RMLineHeight' => intval($RMLineHeight), 'RMLineWidth' => intval($RMLineWidth), 'RMLineMargin' => intval($RMLineMargin), 'RMClickImgClicked' => self::Filter($RMClickImgClicked), 'RMAccordion' => self::Filter($RMAccordion), 'RMArShpA' => json_encode($RMArShpA), 'RMArShpI' => json_encode($RMArShpI), 'RMArImgA' => self::Filter($RMArImgA), 'RMArImgI' => self::Filter($RMArImgI), 'RMTrigger' => self::Filter($RMTrigger), 'RMPushBtn' => self::Filter($RMPushBtn), 'RMCurBkgHov' => self::Filter($RMCurBkgHov), 'RMCurColHov' => self::Filter($RMCurColHov), 'RMWalker' => class_exists($RMWalker) ? $RMWalker : '', 'RMUseTran' => self::Filter($RMUseTran), 'RMLoc' => self::Filter($RMLoc), 'RMThemeLocation' => self::Filter($RMThemeLocation));
     // Update Submitted Options
     update_option('RMOptions', $optionsArray);
     // Clear Transient Menus
     RM_Transient::clearTransientMenus();
     // And save the status
     RM_Status::set('updated', __('You have successfully updated the Responsive Menu options', 'responsive-menu'));
 }