Пример #1
0
 public function get($d = array())
 {
     parent::get($d);
     if (empty($this->_allTemplates)) {
         $directories = utilsBup::getDirList(BUP_TEMPLATES_DIR);
         if (!empty($directories)) {
             foreach ($directories as $code => $dir) {
                 if ($xml = utilsBup::getXml($dir['path'] . 'settings.xml')) {
                     $this->_allTemplates[$code] = $xml;
                     $this->_allTemplates[$code]->prevImg = BUP_TEMPLATES_PATH . $code . '/screenshot.png';
                 }
             }
         }
         if (is_dir(utilsBup::getCurrentWPThemeDir() . 'csp' . DS)) {
             if ($xml = utilsBup::getXml(utilsBup::getCurrentWPThemeDir() . 'csp' . DS . 'settings.xml')) {
                 $code = utilsBup::getCurrentWPThemeCode();
                 if (strpos($code, '/') !== false) {
                     // If theme is in sub-folder
                     $code = explode('/', $code);
                     $code = trim($code[count($code) - 1]);
                 }
                 $this->_allTemplates[$code] = $xml;
                 if (is_file(utilsBup::getCurrentWPThemeDir() . 'screenshot.jpg')) {
                     $this->_allTemplates[$code]->prevImg = utilsBup::getCurrentWPThemePath() . '/screenshot.jpg';
                 } else {
                     $this->_allTemplates[$code]->prevImg = utilsBup::getCurrentWPThemePath() . '/screenshot.png';
                 }
             }
         }
     }
     if (isset($d['code']) && isset($this->_allTemplates[$d['code']])) {
         return $this->_allTemplates[$d['code']];
     }
     return $this->_allTemplates;
 }
Пример #2
0
 public function getPath($tpl)
 {
     $path = '';
     $code = $this->_code;
     $parentModule = frameBup::_()->getModule($this->_code);
     $plTemplate = frameBup::_()->getModule('options')->get('template');
     // Current plugin template
     if (empty($plTemplate) || !frameBup::_()->getModule($plTemplate)) {
         $plTemplate = '';
     }
     if (file_exists(utilsBup::getCurrentWPThemeDir() . 'bup' . DS . $code . DS . $tpl . '.php')) {
         $path = utilsBup::getCurrentWPThemeDir() . 'bup' . DS . $code . DS . $tpl . '.php';
     } elseif ($plTemplate && file_exists(frameBup::_()->getModule($plTemplate)->getModDir() . 'templates' . DS . $code . DS . $tpl . '.php')) {
         $path = frameBup::_()->getModule($plTemplate)->getModDir() . 'templates' . DS . $code . DS . $tpl . '.php';
     } elseif (file_exists($parentModule->getModDir() . 'views' . DS . 'tpl' . DS . $tpl . '.php')) {
         //Then try to find it in module directory
         $path = $parentModule->getModDir() . DS . 'views' . DS . 'tpl' . DS . $tpl . '.php';
     }
     return $path;
 }
Пример #3
0
 public function init()
 {
     if (is_admin() && frameBup::_()->isPluginAdminPage()) {
         $this->_styles = array('styleBup' => array('path' => BUP_CSS_PATH . 'style.css'), 'adminStylesBup' => array('path' => BUP_CSS_PATH . 'adminStyles.css'), 'jquery-tabs' => array('path' => BUP_CSS_PATH . 'jquery-tabs.css'), 'jquery-buttons' => array('path' => BUP_CSS_PATH . 'jquery-buttons.css'), 'wp-jquery-ui-dialog' => array(), 'farbtastic' => array(), 'jquery-dialog' => array('path' => BUP_CSS_PATH . 'jquery-dialog.css'), 'jquery-progress' => array('path' => BUP_CSS_PATH . 'jquery-progress.css'));
         $defaultPlugTheme = frameBup::_()->getModule('options')->get('default_theme');
         $ajaxurl = admin_url('admin-ajax.php');
         if (frameBup::_()->getModule('options')->get('ssl_on_ajax')) {
             $ajaxurl = uriBup::makeHttps($ajaxurl);
         }
         $jsData = array('siteUrl' => BUP_SITE_URL, 'imgPath' => BUP_IMG_PATH, 'loader' => BUP_LOADER_IMG, 'close' => BUP_IMG_PATH . 'cross.gif', 'ajaxurl' => $ajaxurl, 'animationSpeed' => frameBup::_()->getModule('options')->get('js_animation_speed'), 'siteLang' => langBup::getData(), 'options' => frameBup::_()->getModule('options')->getByCode(), 'BUP_CODE' => BUP_CODE);
         $jsData = dispatcherBup::applyFilters('jsInitVariables', $jsData);
         frameBup::_()->addScript('jquery');
         frameBup::_()->addScript('jquery-ui-tabs', '', array('jquery'));
         frameBup::_()->addScript('jquery-ui-dialog', '', array('jquery'));
         frameBup::_()->addScript('jquery-ui-button', '', array('jquery'));
         frameBup::_()->addScript('farbtastic');
         frameBup::_()->addScript('commonBup', BUP_JS_PATH . 'common.js');
         frameBup::_()->addScript('coreBup', BUP_JS_PATH . 'core.js');
         //installerBup::isUsed() ? frameBup::_()->addScript('adminOptionsBup', BUP_JS_PATH. 'admin.options.js') : false;
         frameBup::_()->addScript('adminOptionsBup', BUP_JS_PATH . 'admin.options.js');
         frameBup::_()->addScript('ajaxupload', BUP_JS_PATH . 'ajaxupload.js');
         frameBup::_()->addScript('postbox', get_bloginfo('wpurl') . '/wp-admin/js/postbox.js');
         frameBup::_()->addJSVar('coreBup', 'BUP_DATA', $jsData);
         /*$desktop = true;
         		if(utilsBup::isTablet()) {
         			$this->_styles['style-tablet'] = array();
         			$desktop = false;
         		} elseif(utilsBup::isMobile()) {
         			$this->_styles['style-mobile'] = array();
         			$desktop = false;
         		}
         		if($desktop) {
         			$this->_styles['style-desctop'] = array();
         		}*/
         foreach ($this->_styles as $s => $sInfo) {
             if (isset($sInfo['for'])) {
                 if ($sInfo['for'] == 'frontend' && is_admin() || $sInfo['for'] == 'admin' && !is_admin()) {
                     continue;
                 }
             }
             $canBeSubstituted = true;
             if (isset($sInfo['substituteFor'])) {
                 switch ($sInfo['substituteFor']) {
                     case 'frontend':
                         $canBeSubstituted = !is_admin();
                         break;
                     case 'admin':
                         $canBeSubstituted = is_admin();
                         break;
                 }
             }
             if ($canBeSubstituted && file_exists(BUP_TEMPLATES_DIR . $defaultPlugTheme . DS . $s . '.css')) {
                 frameBup::_()->addStyle($s, BUP_TEMPLATES_PATH . $defaultPlugTheme . '/' . $s . '.css');
             } elseif ($canBeSubstituted && file_exists(utilsBup::getCurrentWPThemeDir() . 'csp' . DS . $s . '.css')) {
                 frameBup::_()->addStyle($s, utilsBup::getCurrentWPThemePath() . '/toe/' . $s . '.css');
             } elseif (!empty($sInfo['path'])) {
                 frameBup::_()->addStyle($s, $sInfo['path']);
             } else {
                 frameBup::_()->addStyle($s);
             }
         }
         add_action('wp_head', array($this, 'addInitJsVars'));
     }
     parent::init();
 }