示例#1
0
 public function buildIndex()
 {
     $options = XenForo_Application::get('options');
     $paths = array();
     if ($options->EWRutiles_Sitemap_sources['forums']) {
         $paths = array_merge($paths, $this->buildForums());
     }
     if ($options->EWRutiles_Sitemap_sources['threads']) {
         $paths = array_merge($paths, $this->buildThreads());
     }
     if ($options->EWRutiles_Sitemap_sources['members']) {
         $paths = array_merge($paths, $this->buildMembers());
     }
     if ($options->EWRutiles_Sitemap_sources['media'] && XenForo_Application::autoload('EWRmedio_Model_Media')) {
         $paths = array_merge($paths, $this->buildMedia());
     }
     if ($options->EWRutiles_Sitemap_sources['wiki'] && XenForo_Application::autoload('EWRcarta_Model_Pages')) {
         $paths = array_merge($paths, $this->buildWiki());
     }
     list($document, $sub_node) = $this->addDocument('sitemapindex');
     foreach ($paths as $path) {
         $this->addUrl($document, $sub_node, 'sitemap', $path, XenForo_Application::$time);
     }
     $path = XenForo_Helper_File::getExternalDataPath() . '/sitemaps/index.xml';
     $file = fopen($path, 'w');
     fwrite($file, $document->saveXML());
     fclose($file);
     if ($options->EWRutiles_Sitemap_pings['bing']) {
         $this->pingUrl('http://www.bing.com/webmaster/ping.aspx?sitemap=');
     }
     if ($options->EWRutiles_Sitemap_pings['google']) {
         $this->pingUrl('http://www.google.com/webmasters/tools/ping?sitemap=');
     }
     return true;
 }
示例#2
0
 public function getPromoteIcons($input)
 {
     $post = $this->getModelFromCache('XenForo_Model_Post')->getPostById($input['first_post_id']);
     $icons = array('attachments' => array(), 'imageEmbeds' => array(), 'medioEmbeds' => array());
     if ($post['attachments'] = $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentsByContentId('post', $input['first_post_id'])) {
         $post['attachments'] = $this->getModelFromCache('XenForo_Model_Attachment')->prepareAttachments($post['attachments']);
         foreach ($post['attachments'] as $attach) {
             if (!empty($attach['thumbnailUrl'])) {
                 $icons['attachments'][] = $attach;
             }
         }
     }
     if (preg_match_all('#\\[img\\](.+?)\\[/img\\]#i', $post['message'], $matches)) {
         foreach ($matches[1] as $match) {
             $url = str_ireplace('http://', '', $match);
             $url = explode('/', $url);
             $icons['imageEmbeds'][] = array('server' => reset($url), 'filename' => end($url), 'imageurl' => $match);
         }
     }
     if (XenForo_Application::autoload('EWRmedio_Model_Media')) {
         if (preg_match_all('#\\[medio\\](\\d+)\\[/medio\\]#i', $post['message'], $matches)) {
             $icons['medioEmbeds'] = $this->getModelFromCache('EWRmedio_Model_Media')->getMediasByIDs($matches[1]);
         }
     }
     return $icons;
 }
示例#3
0
文件: Export.php 项目: Sywooch/forums
 public function renderXml()
 {
     $nameSuffix = str_replace(' ', '-', utf8_romanize(utf8_deaccent(ucfirst($this->_params['name']))));
     XenForo_Application::autoload('Zend_Debug');
     $this->setDownloadFileName('BBM_BbCode_' . $nameSuffix . '.xml');
     return $this->_params['xml']->saveXml();
 }
示例#4
0
 protected function _validateValidationClassAndMethod($class, $method)
 {
     if ($class && !XenForo_Application::autoload($class)) {
         $this->error(new XenForo_Phrase('callback_class_x_for_option_y_is_not_valid', array('option' => $this->get('option_id'), 'class' => $class)), 'validation');
         return false;
     }
     return true;
 }
示例#5
0
 /**
  * Factory method to get the named alert handler. The class must exist and be autoloadable
  * or an exception will be thrown.
  *
  * @param string Class to load
  *
  * @return XenForo_AlertHandler_Abstract
  */
 public static function create($class)
 {
     if (XenForo_Application::autoload($class)) {
         $obj = new $class();
         if ($obj instanceof XenForo_AlertHandler_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid user alert handler '{$class}' specified");
 }
 /**
  * Pre-save handling.
  */
 protected function _preSave()
 {
     if ($this->isChanged('callback_class') || $this->isChanged('callback_method')) {
         $class = $this->get('callback_class');
         $method = $this->get('callback_method');
         if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
             $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
         }
     }
 }
示例#7
0
 /**
  * Verifies and prepares the censor option to the correct format.
  *
  * @param array $words List of words to censor (from input). Keys: word, exact, replace
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$options, XenForo_DataWriter $dw, $fieldName)
 {
     if (!XenForo_Application::autoload('EWRmedio_ControllerPublic_Media')) {
         $options['media'] = 0;
     }
     if (!XenForo_Application::autoload('EWRcarta_ControllerPublic_Wiki')) {
         $options['wiki'] = 0;
     }
     return true;
 }
示例#8
0
文件: Blocks.php 项目: Sywooch/forums
 protected function _preDelete()
 {
     if ($this->get('uninstall_callback_class') && $this->get('uninstall_callback_method')) {
         $class = $this->get('uninstall_callback_class');
         $method = $this->get('uninstall_callback_method');
         if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
             $this->error(new XenForo_Phrase('files_necessary_uninstallation_addon_not_found'));
         }
     }
 }
示例#9
0
文件: Prefix.php 项目: Sywooch/forums
 /**
  * Loads the specified sub-rule and then tries to match it.
  *
  * @param string Route class name
  * @param string Route path to pass to match
  * @param Zend_Controller_Request_Http
  * @param XenForo_Router
  *
  * @return XenForo_RouteMatch|false
  */
 protected function _loadAndRunSubRule($routeClass, $newRoutePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     if (XenForo_Application::autoload($routeClass)) {
         $routeClass = XenForo_Application::resolveDynamicClass($routeClass, 'route_prefix');
         $route = new $routeClass();
         return $route->match($newRoutePath, $request, $router);
     } else {
         return false;
     }
 }
示例#10
0
文件: Admin.php 项目: Sywooch/forums
 public function actionRebuild()
 {
     if (!$this->perms['admin']) {
         return $this->responseNoPermission();
     }
     if (XenForo_Application::autoload('EWRmedio_XML_Premium')) {
         XenForo_Model::create('EWRmedio_XML_Premium')->rebuildServices();
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('media/admin/services'));
 }
示例#11
0
 /**
  * Factory method to get the named news feed handler. The class must exist and be autoloadable
  * or an exception will be thrown.
  *
  * @param string Class to load
  *
  * @return XenForo_NewsFeedHandler_Abstract
  */
 public static function create($class)
 {
     if (XenForo_Application::autoload($class)) {
         $class = XenForo_Application::resolveDynamicClass($class);
         $obj = new $class();
         if ($obj instanceof XenForo_NewsFeedHandler_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid news feed handler '{$class}' specified");
 }
示例#12
0
文件: Media.php 项目: Sywooch/forums
 protected function _getMediaKeyFromCallback($url, $matchedId, array $site, $siteId)
 {
     if (!empty($site['match_callback_class']) && !empty($site['match_callback_method'])) {
         $class = $site['match_callback_class'];
         $method = $site['match_callback_method'];
         if (XenForo_Application::autoload($class) && method_exists($class, $method)) {
             return call_user_func_array(array($class, $method), array($url, $matchedId, $site, $siteId));
         }
     }
     return null;
 }
示例#13
0
 /**
  * factory method to get the content itemhandler
  * @param $class
  * @return SimplePortal_ItemHandler_Abstract
  * @throws XenForo_Exception
  */
 public static function create($class)
 {
     $classResolved = XenForo_Application::resolveDynamicClass($class);
     if (XenForo_Application::autoload($classResolved)) {
         $obj = new $classResolved();
         if ($obj instanceof SimplePortal_ItemHandler_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid extraportal_handler '{$class}' specified");
 }
示例#14
0
 /**
  * Factory method to get the named authentication module. The class must exist or be autoloadable
  * or an exception will be thrown.
  *
  * @param string Class to load
  *
  * @return XenForo_Authentication_Abstract
  */
 public static function create($class)
 {
     if (!$class) {
         return self::createDefault();
     }
     if (XenForo_Application::autoload($class)) {
         $obj = new $class();
         if ($obj instanceof XenForo_Authentication_Abstract) {
             return $obj;
         }
     }
     throw new XenForo_Exception("Invalid authentication module '{$class}' specified");
 }
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     if (empty($widget['options']['callback_class']) or empty($widget['options']['callback_method'])) {
         return '';
     }
     $class = $widget['options']['callback_class'];
     $method = $widget['options']['callback_method'];
     if (XenForo_Application::autoload($class) && method_exists($class, $method)) {
         return call_user_func(array($class, $method), $widget, $positionCode, $params, $renderTemplateObject);
     } else {
         return '';
     }
 }
示例#16
0
 public function actionTest()
 {
     $method = $this->_input->filterSingle('method', XenForo_Input::STRING);
     $url = $this->_input->filterSingle('url', XenForo_Input::STRING);
     if (empty($url) || empty($method)) {
         return $this->responseError('Both Method and URL needs to be supplied!');
     }
     XenForo_Application::autoload('Shorten_URL');
     $Details = array();
     $Details['name'] = $method;
     $Details['url'] = Shorten_URL::shorten($url, $method);
     if (!$Details['url']) {
         $Details['url'] = 'ERROR';
     }
     return $this->responseView('XenForo_ViewAdmin_Sutest_Method_Test', 'sutest_method_test', array('details' => $Details));
 }
示例#17
0
 public function actionExport()
 {
     if (!$this->perms['admin']) {
         return $this->responseNoPermission();
     }
     if (XenForo_Application::autoload('EWRmedio_XML_Premium')) {
         $serviceSlug = $this->_input->filterSingle('service_slug', XenForo_Input::STRING);
         if (!($service = $this->getModelFromCache('EWRmedio_Model_Services')->getServiceBySlug($serviceSlug))) {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, XenForo_Link::buildPublicLink('media/admin/services'));
         }
         $this->_routeMatch->setResponseType('xml');
         $viewParams = array('service' => $service, 'xml' => $this->getModelFromCache('EWRmedio_XML_Premium')->exportService($service));
         return $this->responseView('EWRmedio_ViewPublic_ServiceExport', '', $viewParams);
     }
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('media/admin/services'));
 }
 /**
  * Pre-save behaviors.
  */
 protected function _preSave()
 {
     if ($this->isChanged('handler_class')) {
         $class = $this->get('handler_class');
         if (!$class) {
             $this->set('handler_class', '');
         } else {
             if (!XenForo_Application::autoload($class)) {
                 $this->error(new XenForo_Phrase('please_enter_valid_handler_class'), 'handler_class');
             }
         }
     }
     $namePhrase = $this->getExtraData(self::DATA_NAME);
     if ($namePhrase !== null && strlen($namePhrase) == 0) {
         $this->error(new XenForo_Phrase('please_enter_valid_name'), 'name');
     }
 }
示例#19
0
 public static function installCode($existingAddOn, $addOnData)
 {
     $endVersion = $addOnData['version_id'];
     $strVersion = $existingAddOn ? $existingAddOn['version_id'] + 1 : 1;
     $install = self::getInstance();
     for ($i = $strVersion; $i <= $endVersion; $i++) {
         $method = '_install_' . $i;
         if (method_exists($install, $method)) {
             $install->{$method}();
         }
     }
     if (XenForo_Application::autoload('EWRmedio_XML_Premium')) {
         XenForo_Model::create('EWRmedio_XML_Premium')->rebuildServices();
     } else {
         $targetXml = XenForo_Application::getInstance()->getRootDir() . '/library/EWRmedio/XML';
         XenForo_Model::create('EWRmedio_Model_Services')->importService($targetXml . '/youtube.xml');
     }
 }
示例#20
0
 /**
  *
  * @param XenForo_Visitor $visitor
  * @param string $dynamicClass
  */
 public static function extend(XenForo_Visitor &$visitor, $dynamicClass)
 {
     if ($visitor instanceof $dynamicClass) {
         return;
     }
     $visitor = serialize($visitor);
     $pattern = '#O:[0-9]*:"([^"]*)"#';
     preg_match($pattern, $visitor, $matches);
     if (isset($matches[1])) {
         $proxyClass = 'XFCP_' . $dynamicClass;
         if (!class_exists($proxyClass, false)) {
             eval('class ' . $proxyClass . ' extends ' . $matches[1] . ' {}');
             XenForo_Application::autoload($dynamicClass);
         }
         $replacement = 'O:' . strlen($dynamicClass) . ':"' . $dynamicClass . '"';
         $visitor = preg_replace($pattern, $replacement, $visitor);
     }
     $visitor = unserialize($visitor);
 }
示例#21
0
文件: Blocks.php 项目: Sywooch/forums
 public function getBlockParams($block, $page = 1, $params = array())
 {
     $template = 'EWRporta_Block_' . $block['block_id'];
     if ($block['category'] || $page > 1) {
         $params['option'] = $block['options'];
         $params['page'] = $page;
         $params['category'] = $block['category'];
         $params['position'] = $block['position'];
         switch ($block['block_id']) {
             case 'RecentNews':
                 $model = new $template();
                 $params[$block['block_id']] = $model->getModule($params['option'], $page, $params['category']);
                 return $params;
         }
     }
     if (XenForo_Application::autoload($template)) {
         $model = new $template();
     }
     if (strtotime($block['cache'], $block['caches']['date']) < XenForo_Application::$time) {
         $params['option'] = $block['options'];
         if (isset($model)) {
             if (method_exists($model, 'getModule')) {
                 $params[$block['block_id']] = $model->getModule($params['option'], $page);
             }
         }
         if ($block['cache'] != 'now') {
             $this->getModelFromCache('EWRporta_Model_Caches')->buildBlockCache($block, serialize($params));
         }
     } else {
         $params = unserialize($block['caches']['results']);
     }
     if (isset($model)) {
         if (method_exists($model, 'getBypass')) {
             $params['layout'] = $block['layout'];
             $params[$block['block_id']] = $model->getBypass($params);
         }
     }
     $params['position'] = $block['position'];
     return $params;
 }
示例#22
0
 protected function _preSave()
 {
     $class = $this->get('route_class');
     if (!XenForo_Application::autoload($class)) {
         $options = array('title_plural' => str_replace('-', ' ', $this->get('original_prefix')));
         if ($this->getOption(self::OPTION_PRIMARY_KEY_ID)) {
             $options['primary_key_id'] = $this->getOption(self::OPTION_PRIMARY_KEY_ID);
         }
         $phpFile = null;
         switch ($this->get('route_type')) {
             case 'public':
                 $phpFile = new ThemeHouse_Controllers_PhpFile_Route_Prefix($class, $options);
                 break;
             case 'admin':
                 $phpFile = new ThemeHouse_Controllers_PhpFile_Route_PrefixAdmin($class, $options);
                 break;
         }
         if (!is_null($phpFile)) {
             $phpFile->export(true);
         }
     }
     return parent::_preSave();
 }
示例#23
0
 protected function _preSave()
 {
     $class = $this->get('route_class');
     if (!XenForo_Application::autoload($class)) {
         $filename = XenForo_Autoloader::getInstance()->getRootDir() . DIRECTORY_SEPARATOR . str_replace("_", DIRECTORY_SEPARATOR, $class) . ".php";
         if (!file_exists(dirname($filename))) {
             XenForo_Helper_File::createDirectory(dirname($filename));
         }
         $options = array('title_plural' => str_replace('-', ' ', $this->get('original_prefix')));
         $phpFile = null;
         switch ($this->get('route_type')) {
             case 'public':
                 $phpFile = new ThemeHouse_RoutePrefixes_PhpFile_Route_Prefix($class, $options);
                 break;
             case 'admin':
                 $phpFile = new ThemeHouse_RoutePrefixes_PhpFile_Route_PrefixAdmin($class, $options);
                 break;
         }
         if (!is_null($phpFile)) {
             $phpFile->export(true);
         }
     }
     return parent::_preSave();
 }
示例#24
0
文件: api.php 项目: pritcham/XenAPI
 public function hasModel($model)
 {
     if (XenForo_Application::autoload($model)) {
         $model = @XenForo_Model::create($model);
         return is_a($model, 'XenForo_Model');
     }
     return FALSE;
 }
示例#25
0
 /**
  * Pre-save behaviors.
  */
 protected function _preSave()
 {
     if ($this->isChanged('match_callback_class') || $this->isChanged('match_callback_method')) {
         $class = $this->get('match_callback_class');
         $method = $this->get('match_callback_method');
         if (!$class || !$method) {
             $this->set('match_callback_class', '');
             $this->set('match_callback_method', '');
         } else {
             if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
                 $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
             }
         }
     }
     if ($this->isChanged('field_choices_callback_class') || $this->isChanged('field_choices_callback_method')) {
         $class = $this->get('field_choices_callback_class');
         $method = $this->get('field_choices_callback_method');
         if (!$class || !$method) {
             $this->set('field_choices_callback_class', '');
             $this->set('field_choices_callback_method', '');
         } else {
             if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
                 $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
             }
         }
     }
     if ($this->isChanged('display_callback_class') || $this->isChanged('display_callback_method')) {
         $class = $this->get('display_callback_class');
         $method = $this->get('display_callback_method');
         if (!$class || !$method) {
             $this->set('display_callback_class', '');
             $this->set('display_callback_method', '');
         } else {
             if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
                 $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
             }
         }
     }
     if ($this->isChanged('field_callback_class') || $this->isChanged('field_callback_method')) {
         $class = $this->get('field_callback_class');
         $method = $this->get('field_callback_method');
         if (!$class || !$method) {
             $this->set('field_callback_class', '');
             $this->set('field_callback_method', '');
         } else {
             if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
                 $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
             }
         }
     }
     if ($this->isChanged('export_callback_class') || $this->isChanged('export_callback_method')) {
         $class = $this->get('export_callback_class');
         $method = $this->get('export_callback_method');
         if (!$class || !$method) {
             $this->set('export_callback_class', '');
             $this->set('export_callback_method', '');
         } else {
             if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
                 $this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
             }
         }
     }
     if ($this->isUpdate() && $this->isChanged('field_type')) {
         $typeMap = $this->_getFieldModel()->getThreadFieldTypeMap();
         if ($typeMap[$this->get('field_type')] != $typeMap[$this->getExisting('field_type')]) {
             $this->error(new XenForo_Phrase('you_may_not_change_field_to_different_type_after_it_has_been_created'), 'field_type');
         }
     }
     if (!$this->get('field_choices_callback_class') && !$this->get('field_choices_callback_method') && in_array($this->get('field_type'), array('select', 'radio', 'checkbox', 'multiselect'))) {
         if ($this->isInsert() && !$this->_fieldChoices || is_array($this->_fieldChoices) && !$this->_fieldChoices) {
             $this->error(new XenForo_Phrase('please_enter_at_least_one_choice'), 'field_choices', false);
         }
     } else {
         $this->setFieldChoices(array());
     }
     if (!$this->getOption(self::OPTION_MASS_UPDATE)) {
         $titlePhrase = $this->getExtraData(self::DATA_TITLE);
         if ($titlePhrase !== null && strlen($titlePhrase) == 0) {
             $this->error(new XenForo_Phrase('please_enter_valid_title'), 'title');
         }
     }
 }
示例#26
0
 public function getMedio(&$post)
 {
     if (XenForo_Application::autoload('EWRmedio_Model_Media')) {
         if ($medio = $this->getModelFromCache('EWRmedio_Model_Media')->getMediaByID($post['promote_data'])) {
             $post['message'] = str_ireplace('[medio]' . $post['promote_data'] . '[/medio]', '', $post['message']);
             $post['message'] = str_ireplace('[medio=full]' . $post['promote_data'] . '[/medio]', '', $post['message']);
             return $medio;
         }
     }
     return false;
 }
示例#27
0
 /**
  * Verifies that the model class is valid.
  *
  * @param string $modelClass
  *
  * @return boolean
  */
 protected function _verifyModelClass($modelClass)
 {
     if (!XenForo_Application::autoload($modelClass)) {
         $this->error(new XenForo_Phrase('please_specify_valid_class_that_extends_xenforo_model'), 'model_class');
         return false;
     }
     return true;
 }
示例#28
0
 /**
  * Resolves dynamic, run time inheritance for the specified class.
  * The classes to be loaded for this base class are grabbed via the event.
  * These classes must inherit from from XFCP_x, which is a non-existant
  * class that is dynamically created, inheriting from the correct class
  * as needed.
  *
  * If a fake base is needed when the base class doesn't exist, and there
  * are no classes extending it, false will still be returned! This prevents
  * an unnecessary eval.
  *
  * @param string $class Name of class
  * @param string $type Type of class (for determining event to fire)
  * @param string|false $fakeBase If the specified class doesn't exist, an alternative base can be specified
  *
  * @return false|string False or name of class to instantiate
  */
 public static function resolveDynamicClass($class, $type, $fakeBase = false)
 {
     if (!XenForo_Application::autoload($class)) {
         if ($fakeBase) {
             $fakeNeeded = true;
         } else {
             return false;
         }
     } else {
         $fakeNeeded = false;
     }
     if (!empty(self::$_classCache[$class])) {
         return self::$_classCache[$class];
     }
     $createClass = $class;
     $extend = array();
     XenForo_CodeEvent::fire('load_class_' . $type, array($class, &$extend));
     if ($fakeNeeded) {
         if (!$extend) {
             return false;
         }
         eval('class ' . $class . ' extends ' . $fakeBase . ' {}');
     }
     if ($extend) {
         try {
             foreach ($extend as $dynamicClass) {
                 // XenForo Class Proxy, in case you're wondering
                 $proxyClass = 'XFCP_' . $dynamicClass;
                 eval('class ' . $proxyClass . ' extends ' . $createClass . ' {}');
                 XenForo_Application::autoload($dynamicClass);
                 $createClass = $dynamicClass;
             }
         } catch (Exception $e) {
             self::$_classCache[$class] = $class;
             throw $e;
         }
     }
     self::$_classCache[$class] = $createClass;
     return $createClass;
 }
示例#29
0
 /**
  * Attempts to fetch media tag embed HTML using the callback method defined for a media site, if one is specified.
  *
  * @param string $mediaKey
  * @param array $site Information about the site to render this media
  * @param string $siteId
  *
  * @return string|boolean Returns false if callback is invalid
  */
 protected function _getMediaSiteHtmlFromCallback($mediaKey, array $site, $siteId)
 {
     if (!empty($site['callback']) && is_array($site['callback'])) {
         $class = $site['callback'][0];
         $method = $site['callback'][1];
         if (XenForo_Application::autoload($class) && method_exists($class, $method)) {
             return call_user_func_array($site['callback'], array($mediaKey, $site, $siteId));
         }
     }
     return false;
 }
示例#30
0
 /**
  * Verifies that the add-on given is installable (or upgradeable).
  *
  * @param array $addOnData Information about the add-on, from the root XML node
  * @param string|false $upgradeAddOnId Add-on we're trying to upgrade, if applicable
  *
  * @return array If doing an upgrade, returns information about the existing version
  */
 public function verifyAddOnIsInstallable($addOnData, $upgradeAddOnId = false)
 {
     $addOnId = $addOnData['addon_id'];
     if ($addOnId === '') {
         throw new XenForo_Exception(new XenForo_Phrase('add_on_xml_does_not_specify_valid_add_on_id_and_cannot_be_installed'), true);
     }
     $existingAddOn = $this->getAddOnById($addOnId);
     if ($existingAddOn) {
         if ($upgradeAddOnId === false) {
             throw new XenForo_Exception(new XenForo_Phrase('specified_add_on_is_already_installed'), true);
         } else {
             if ($existingAddOn['addon_id'] != $upgradeAddOnId) {
                 throw new XenForo_Exception(new XenForo_Phrase('specified_add_on_does_not_match_add_on_you_chose_to_upgrade'), true);
             }
         }
         if ($addOnData['version_id'] < $existingAddOn['version_id']) {
             throw new XenForo_Exception(new XenForo_Phrase('specified_add_on_is_older_than_install_version'), true);
         }
     }
     if ($upgradeAddOnId !== false && !$existingAddOn) {
         throw new XenForo_Exception(new XenForo_Phrase('specified_add_on_does_not_match_add_on_you_chose_to_upgrade'), true);
     }
     if ($addOnData['install_callback_class'] && $addOnData['install_callback_method']) {
         if (!XenForo_Application::autoload($addOnData['install_callback_class']) || !method_exists($addOnData['install_callback_class'], $addOnData['install_callback_method'])) {
             throw new XenForo_Exception(new XenForo_Phrase('files_associated_with_addon_not_found'), true);
         }
     }
     if ($addOnData['uninstall_callback_class'] && $addOnData['uninstall_callback_method']) {
         if (!XenForo_Application::autoload($addOnData['uninstall_callback_class']) || !method_exists($addOnData['uninstall_callback_class'], $addOnData['uninstall_callback_method'])) {
             throw new XenForo_Exception(new XenForo_Phrase('files_associated_with_addon_not_found'), true);
         }
     }
     return $existingAddOn;
 }