public function onAdminInit()
 {
     if ($this->_pm->isPremium() && IfwPsn_Wp_Proxy_Blog::isPluginActive('post-status-notifier-lite/post-status-notifier-lite.php')) {
         // Lite version still activated
         $this->getAdminNotices()->addError(sprintf(__('The Lite version of this plugin is still activated. Please deactivate it! Refer to the <a href="%s">Upgrade Howto</a>.', 'psn'), 'http://docs.ifeelweb.de/post-status-notifier/upgrade_howto.html'));
     }
 }
Example #2
0
 /**
  * @param $tablename
  * @param bool $networkwide
  */
 public function createTable($tablename, $networkwide = false)
 {
     global $wpdb;
     $query = '
     CREATE TABLE IF NOT EXISTS `%s` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
       `priority` int(11) NOT NULL,
       `message` varchar(255) CHARACTER SET utf8 NOT NULL,
       `type` smallint(4) NOT NULL,
       `timestamp` datetime NOT NULL,
       `extra` longtext COLLATE utf8_unicode_ci NOT NULL,
       PRIMARY KEY (`id`)
     );
     ';
     if (!$networkwide) {
         // single blog installation
         $wpdb->query(sprintf($query, $wpdb->prefix . $tablename));
     } else {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $wpdb->query(sprintf($query, $wpdb->prefix . $tablename));
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     }
 }
Example #3
0
 /**
  * Alias for get_current_screen()
  * @return WP_Screen
  */
 public static function getCurrent()
 {
     if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.1') && function_exists('get_current_screen')) {
         return get_current_screen();
     }
     return null;
 }
Example #4
0
    /**
     * @param $action
     * @param null $submitText
     */
    public function displayForm($action, $submitText = null)
    {
        $bytes = wp_max_upload_size();
        $size = size_format($bytes);
        $upload_dir = IfwPsn_Wp_Proxy_Blog::getUploadDir();
        if ($submitText == null) {
            $submitText = __('Upload', 'ifw');
        }
        if (!empty($upload_dir['error'])) {
            ?>
<div class="error"><p><?php 
            _e('Before you can upload your import file, you will need to fix the following error:');
            ?>
</p>
            <p><strong><?php 
            echo $upload_dir['error'];
            ?>
</strong></p></div><?php 
        } else {
            $allowedExtensions = $this->getMimeTypes() != null ? implode(',', array_unique(array_keys($this->getMimeTypes()))) : null;
            $label = sprintf('Choose a file from your computer (Maximum size: %s%s)', $size, $allowedExtensions !== null ? ', ' . __('allowed extensions: ') . $allowedExtensions : '');
            ?>
            <form enctype="multipart/form-data" id="<?php 
            echo $this->_id;
            ?>
-upload-form" method="post" class="wp-upload-form" action="<?php 
            echo esc_url($action);
            ?>
">
                <?php 
            echo wp_nonce_field($this->_getNonceName());
            ?>
                <p>
                    <label for="upload-<?php 
            echo $this->_id;
            ?>
"><?php 
            echo $label;
            ?>
</label>
                    <input type="file" id="upload-<?php 
            echo $this->_id;
            ?>
" name="<?php 
            echo $this->_id;
            ?>
" size="25" />
                    <input type="hidden" name="action" value="upload" />
                    <input type="hidden" name="max_file_size" value="<?php 
            echo $bytes;
            ?>
" />
                </p>
                <?php 
            submit_button($submitText, 'button');
            ?>
            </form>
        <?php 
        }
    }
Example #5
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  */
 public function __construct(IfwPsn_Wp_Plugin_Manager $pm)
 {
     $this->_pm = $pm;
     if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.1')) {
         // screen functionality supported since WP 3.1
         $this->_init();
     }
 }
Example #6
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  */
 protected static function _dropTable($pm)
 {
     global $wpdb;
     if ($pm->isPremium() || !$pm->isPremium() && !IfwPsn_Wp_Proxy_Blog::isPluginActive('post-status-notifier/post-status-notifier.php')) {
         // only delete rules table if it's the Premium version
         // or it's the Lite version and the Premium version is not activated
         $wpdb->query('DROP TABLE IF EXISTS `' . $wpdb->prefix . 'psn_rules`');
     }
 }
Example #7
0
 /**
  * Checks whether a given date string is older than the given seconds
  *
  * @param $time expects date format YYYY-MM-DD HH:MM:SS
  * @param $seconds
  * @return bool
  */
 public static function isOlderThanSeconds($time, $seconds)
 {
     $dt = new DateTime($time, new DateTimeZone('UTC'));
     $offset = IfwPsn_Wp_Proxy_Blog::getGmtOffset();
     if (empty($offset)) {
         $offset = 0;
     }
     $timeTs = (int) $dt->format('U');
     return $timeTs + $seconds < time();
 }
Example #8
0
 /**
  * Loads the appropriate action for adding contextual help
  */
 public function load()
 {
     if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.3')) {
         // since 3.3 use the add_help_method on the screen object
         IfwPsn_Wp_Proxy_Action::addAdminHead(array($this, 'addHelpTab'));
     } else {
         // before 3.3 use the contextual_help action
         IfwPsn_Wp_Proxy_Action::add('contextual_help', array($this, 'getContextualHelp'), 10, 3);
     }
 }
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @param $networkwide
  * @return mixed
  */
 public function execute(IfwPsn_Wp_Plugin_Manager $pm, $networkwide = false)
 {
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $this->_refreshPresentVersion($pm);
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         $this->_refreshPresentVersion($pm);
     }
 }
Example #10
0
 public function execute()
 {
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Translate/Adapter/Array.php';
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Locale.php';
     try {
         // check if the WP locale is valid otherwise set it to default
         $locale = IfwPsn_Wp_Proxy_Blog::getLanguage();
         if (!in_array($locale, $this->_supportedLanguages)) {
             $locale = 'en_US';
         }
         $translator = new IfwPsn_Vendor_Zend_Translate('IfwPsn_Vendor_Zend_Translate_Adapter_Array', $this->_adapter->getPluginManager()->getPathinfo()->getRootLib() . 'IfwPsn/Zend/Form/resources/languages', $locale, array('scan' => IfwPsn_Vendor_Zend_Translate::LOCALE_DIRECTORY));
         // set the validation translator
         IfwPsn_Vendor_Zend_Validate_Abstract::setDefaultTranslator($translator);
     } catch (Exception $e) {
         // do nothing. if something failed, we just have no translation for Zend_Validate
     }
 }
Example #11
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager|null $pm
  * @return mixed|void
  */
 public static function execute($pm)
 {
     if (!$pm instanceof IfwPsn_Wp_Plugin_Manager) {
         return;
     }
     if (IfwPsn_Wp_Proxy_Blog::isMultisite()) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $pm->getOptions()->reset();
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         $pm->getOptions()->reset();
     }
 }
Example #12
0
 /**
  * @return mixed
  */
 protected function _init()
 {
     if ($this->_module->isCustomModule()) {
         $uploadDir = IfwPsn_Wp_Proxy_Blog::getUploadDir();
         $this->_url = $uploadDir['baseurl'] . '/' . $this->_customLocationName . '/' . $this->_pathinfo->getDirname() . '/';
     } else {
         // built-in module
         $dirnamePathParts = array_reverse(explode(DIRECTORY_SEPARATOR, $this->_pathinfo->getDirnamePath()));
         $this->_url = plugins_url($dirnamePathParts[3]) . '/modules/' . $this->_pathinfo->getDirname() . '/';
     }
     $this->_urlFiles = $this->_url . 'files/';
     $this->_urlCss = $this->_urlFiles . 'css/';
     $this->_urlJs = $this->_urlFiles . 'js/';
     $this->_urlImg = $this->_urlFiles . 'img/';
     $this->_version = $this->_module->getVersion();
     $this->_name = $this->_module->getName();
     $this->_description = $this->_module->getDescription();
     $this->_textDomain = $this->_module->getTextDomain();
     $this->_homepage = $this->_module->getHomepage();
 }
Example #13
0
 /**
  * @param bool $networkwide
  */
 public function execute($networkwide = false)
 {
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         // get the current blog id
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         // loop through all blogs
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             // execute networkwide task
             $this->_execute();
         }
         // switch back to current blog
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // no network found or no networkwide execution requested
         // execute single blog task
         $this->_execute();
     }
 }
Example #14
0
 /**
  * Initializes the controller
  * Will be called on bootstrap before admin-menu/admin-init/load-[page]
  * Use onAdminMenu/onAdminInit etc otherwise
  */
 public function init()
 {
     // set config
     $this->_config = $this->getInvokeArg('bootstrap')->getOptions();
     $this->_pm = $this->_config['pluginmanager'];
     $this->view->pm = $this->_pm;
     $this->_pm->getLogger()->logPrefixed('Init default controller.');
     $this->_adminNotices = new IfwPsn_Wp_Admin_Notices($this->_pm->getAbbrLower());
     //        $this->_adminNotices->setAutoShow(true);
     $this->view->adminNotices = $this->_adminNotices;
     $this->_redirector = $this->_helper->getHelper('Redirector');
     $this->_request = $this->getRequest();
     $this->_helper->layout()->setLayout('layout');
     $this->_pageHook = 'page-' . $this->_pm->getPathinfo()->getDirname() . '-' . $this->getRequest()->getControllerName() . '-' . $this->getRequest()->getActionName();
     $this->view->pageHook = $this->_pageHook;
     $this->initNavigation();
     $this->view->isSupportedWpVersion = IfwPsn_Wp_Proxy_Blog::isMinimumVersion($this->_pm->getConfig()->plugin->wpMinVersion);
     $this->view->notSupportedWpVersionMessage = sprintf(__('This plugin requires WordPress version %s for full functionality. Your version is %s. <a href="%s">Please upgrade</a>.', 'ifw'), $this->_pm->getConfig()->plugin->wpMinVersion, IfwPsn_Wp_Proxy_Blog::getVersion(), 'http://wordpress.org/download/');
     // Do action on controller init
     IfwPsn_Wp_Proxy_Action::doAction(get_class($this) . '_init', $this);
 }
Example #15
0
 /**
  *
  */
 public function sendTestMailAction()
 {
     if (!$this->_verifyNonce('psn-form-test-mail')) {
         $this->getAdminNotices()->persistError(__('Invalid access.', 'psn'));
         $this->_gotoIndex();
     }
     $this->_email = new IfwPsn_Wp_Email();
     $subject = sprintf(__('Test Email from %s', 'psn'), $this->_pm->getEnv()->getName());
     $body = IfwPsn_Wp_Proxy_Filter::apply('psn_send_test_mail_body', sprintf(__('This is a test email generated by %s on %s (%s)', 'psn'), $this->_pm->getEnv()->getName(), IfwPsn_Wp_Proxy_Blog::getName(), IfwPsn_Wp_Proxy_Blog::getUrl()), $this->_email);
     switch (trim($this->_request->get('recipient'))) {
         case 'custom':
             $recipient = esc_attr($_POST['custom_recipient']);
             break;
         case 'admin':
         default:
             $recipient = IfwPsn_Wp_Proxy_Blog::getAdminEmail();
             break;
     }
     $recipient = IfwPsn_Wp_Proxy_Filter::apply('psn_send_test_mail_recipient', $recipient);
     if (empty($recipient)) {
         $resultMsg = __('Invalid recipient.', 'psn') . ' ' . __('Test email could not be sent.', 'psn');
         $this->getAdminNotices()->persistError($resultMsg);
     } else {
         $this->_email->setTo($recipient)->setSubject($subject)->setMessage($body);
         IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail', $this->_email);
         if ($this->_email->send()) {
             // mail sent successfully
             $resultMsg = __('Test email has been sent successfully.', 'psn');
             $this->getAdminNotices()->persistUpdated($resultMsg);
             IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail_success', $this);
         } else {
             // email could not be sent
             $resultMsg = __('Test email could not be sent.', 'psn');
             $this->getAdminNotices()->persistError($resultMsg);
             IfwPsn_Wp_Proxy_Action::doAction('psn_send_test_mail_failure', $this);
         }
         IfwPsn_Wp_Proxy_Action::doAction('psn_after_test_email_send', $this->_email);
     }
     $this->_gotoIndex();
 }
Example #16
0
 /**
  * (non-PHPdoc)
  * @see IfwPsn_Wp_Plugin_Installer_ActivationInterface::execute()
  */
 public function execute(IfwPsn_Wp_Plugin_Manager $pm, $networkwide = false)
 {
     if ($pm->isPremium() && IfwPsn_Wp_Proxy_Blog::isPluginActive('post-status-notifier-lite/post-status-notifier-lite.php')) {
         trigger_error(sprintf(__('The Lite version of this plugin is still activated. Please deactivate it! Refer to the <a href=\\"%s\\">Upgrade Howto</a>.', 'psn'), 'http://docs.ifeelweb.de/post-status-notifier/upgrade_howto.html'));
     }
     $this->_dbPatcher = new Psn_Patch_Database();
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             // give every site in the network the default time limit of 30 seconds
             set_time_limit(30);
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $this->_createTable();
             $this->_presetOptions($pm);
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         $this->_createTable();
         $this->_presetOptions($pm);
     }
 }
Example #17
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @return string
  */
 public static function getServerEnvironment(IfwPsn_Wp_Plugin_Manager $pm)
 {
     $tpl = IfwPsn_Wp_Tpl::getFilesytemInstance($pm);
     $count_users = count_users();
     $mysql_server_info = @mysql_get_server_info();
     $mysql_client_info = @mysql_get_client_info();
     $phpAutoloadFunctions = array();
     foreach (IfwPsn_Wp_Autoloader::getAllRegisteredAutoloadFunctions() as $function) {
         try {
             if (is_string($function)) {
                 array_push($phpAutoloadFunctions, $function);
             } elseif (is_array($function) && count($function) == 2) {
                 $autoloadObject = $function[0];
                 if (is_object($autoloadObject)) {
                     $autoloadObject = get_class($autoloadObject);
                 }
                 $autoloadMethod = $function[1];
                 if (!is_scalar($autoloadMethod)) {
                     $autoloadMethod = var_export($autoloadMethod, true);
                 }
                 array_push($phpAutoloadFunctions, $autoloadObject . '::' . $autoloadMethod);
             } elseif (is_object($function)) {
                 array_push($phpAutoloadFunctions, get_class($function));
             }
         } catch (Exception $e) {
             // no action
         }
     }
     $context = array('plugin_name' => $pm->getEnv()->getName(), 'plugin_version' => $pm->getEnv()->getVersion(), 'plugin_build_number' => $pm->getEnv()->getBuildNumber(), 'plugin_modules' => $pm->getBootstrap()->getModuleManager()->getModules(), 'plugin_modules_initialized' => $pm->getBootstrap()->getModuleManager()->getInitializedModules(), 'plugin_modules_custom_dir' => $pm->getBootstrap()->getModuleManager()->getCustomModulesLocation(), 'OS' => PHP_OS, 'uname' => php_uname(), 'wp_version' => IfwPsn_Wp_Proxy_Blog::getVersion(), 'wp_charset' => IfwPsn_Wp_Proxy_Blog::getCharset(), 'wp_count_users' => $count_users['total_users'], 'wp_debug' => WP_DEBUG == true ? 'true' : 'false', 'wp_debug_log' => WP_DEBUG_LOG == true ? 'true' : 'false', 'wp_debug_display' => WP_DEBUG_DISPLAY == true ? 'true' : 'false', 'plugins' => IfwPsn_Wp_Proxy_Blog::getPlugins(), 'theme_name' => IfwPsn_Wp_Proxy_Blog::getThemeName(), 'theme_version' => IfwPsn_Wp_Proxy_Blog::getThemeVersion(), 'theme_author' => IfwPsn_Wp_Proxy_Blog::getThemeAuthor(), 'theme_uri' => IfwPsn_Wp_Proxy_Blog::getThemeURI(), 'php_version' => phpversion(), 'php_memory_limit' => ini_get('memory_limit'), 'php_extensions' => IfwPsn_Wp_Server_Php::getExtensions(), 'php_include_path' => get_include_path(), 'php_open_basedir' => ini_get('open_basedir'), 'php_autoload_functions' => $phpAutoloadFunctions, 'mysql_version' => !empty($mysql_server_info) ? $mysql_server_info : '', 'mysql_client' => !empty($mysql_client_info) ? $mysql_client_info : '', 'server_software' => $_SERVER['SERVER_SOFTWARE']);
     if (function_exists('apache_get_version')) {
         $context['apache_version'] = apache_get_version();
     }
     if (function_exists('apache_get_modules')) {
         $context['apache_modules'] = apache_get_modules();
     }
     return $tpl->render('server_env.html.twig', $context);
 }
Example #18
0
 /**
  * Retrieves dir to search for custom modules
  * @return null|string
  */
 public function getCustomModulesLocation()
 {
     $uploadDir = IfwPsn_Wp_Proxy_Blog::getUploadDir();
     $dirName = $this->getCustomModulesLocationName();
     if (is_array($uploadDir) && (isset($uploadDir['error']) && empty($uploadDir['error'])) && (isset($uploadDir['basedir']) && !empty($uploadDir['basedir']))) {
         return $uploadDir['basedir'] . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR;
     }
     return null;
 }
Example #19
0
 /**
  * @see IfwPsn_Wp_Plugin_Admin_Menu_Metabox_Abstract::render()
  */
 public function render()
 {
     printf('<textarea id="ifw_server_env">%s</textarea>', IfwPsn_Wp_Proxy_Blog::getServerEnvironment($this->_pm));
 }
Example #20
0
 public static function getAdminPageBaseUrl()
 {
     return IfwPsn_Wp_Proxy_Blog::getSiteUrl() . '/wp-admin/admin.php';
 }
Example #21
0
 /**
  * Fires at the end of the update message container in each row of the plugins list table.
  *
  * @param array $plugin_data An array of plugin data.
  * @param $meta_data
  */
 public function onPluginUpdateMessage($plugin_data, $meta_data)
 {
     $plugin_slug = $this->_pm->getPathinfo()->getDirname();
     $request = new IfwPsn_Wp_Plugin_Update_Request($this->_pm);
     $request->setAction('plugin_update_message')->addData('slug', $plugin_slug)->addData('version', $plugin_data['Version'])->addData('lang', IfwPsn_Wp_Proxy_Blog::getLanguage());
     if ($this->_pm->isPremium()) {
         $license = $this->_pm->getOptionsManager()->getOption('license_code');
         $request->addData('license', $license);
     }
     $response = $request->send();
     if ($response->isSuccess()) {
         if ($this->_pm->isPremium() && empty($license)) {
             printf('<div style="padding: 5px 10px; border: 1px dashed red; margin-top: 10px;">%s</div>', sprintf(__('You have to enter your plugin <b>license code</b> in the <a href="%s">plugin options</a> to be able to download this update!', 'ifw'), $this->_pm->getConfig()->plugin->optionsPage));
         }
         echo $response->getBody();
     }
 }
Example #22
0
 /**
  * Retrieves the prepared notification body text
  *
  * @return string
  */
 public function getNotificationBody()
 {
     if ($this->_notificationBody === null) {
         // see: http://stackoverflow.com/questions/6275380/does-html-entity-decode-replaces-nbsp-also-if-not-how-to-replace-it
         if (IfwPsn_Wp_Proxy_Blog::getCharset() == 'UTF-8') {
             $body = str_replace(" ", ' ', html_entity_decode($this->get('notification_body'), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset()));
         } else {
             $body = str_replace(" ", ' ', html_entity_decode($this->get('notification_body'), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset()));
         }
         $body = IfwPsn_Wp_Proxy_Filter::apply('psn_rule_notification_body', $this->_replacer->replace($body), $this);
         $this->_notificationBody = $body;
     }
     return $this->_notificationBody;
 }
Example #23
0
 /**
  * @return WP_Post|object
  */
 protected function _getPostMockup()
 {
     $this->_isMockUpPost = true;
     if (IfwPsn_Wp_Proxy_Blog::isMinimumVersion('3.5')) {
         // WP_Post since 3.5
         return new WP_Post(new stdClass());
     } else {
         // before 3.5
         global $wpdb;
         return $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} LIMIT 1"));
     }
 }
Example #24
0
 /**
  * @return bool
  */
 protected function _isValidBlogVersion()
 {
     return IfwPsn_Wp_Proxy_Blog::getVersion() >= '3.3';
 }
Example #25
0
 /**
  *
  */
 protected function _init()
 {
     parent::_init();
     $this->setUrl($this->_pm->getConfig()->plugin->updateServer);
     $this->addData('api-key', md5(IfwPsn_Wp_Proxy_Blog::getUrl()));
 }
Example #26
0
 /**
  * Runs the test
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @return mixed
  */
 public function execute(IfwPsn_Wp_Plugin_Manager $pm)
 {
     $this->_pm = $pm;
     $this->_result = IfwPsn_Wp_Proxy_Blog::isMinimumVersion($pm->getConfig()->plugin->wpMinVersion);
 }
Example #27
0
 public function render($content)
 {
     $element = $this->getElement();
     $name = htmlentities($element->getFullyQualifiedName());
     $label = $element->getLabel();
     $id = htmlentities($element->getId());
     $value = $element->getValue();
     if (is_string($value)) {
         $value = htmlentities($element->getValue(), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset());
     }
     switch ($element->getType()) {
         case 'IfwPsn_Vendor_Zend_Form_Element_Textarea':
             $html_entity_decode = $element->getAttrib('html_entity_decode');
             if (!isset($html_entity_decode) || empty($html_entity_decode) || $html_entity_decode === true) {
                 $value = html_entity_decode($element->getValue(), ENT_COMPAT, IfwPsn_Wp_Proxy_Blog::getCharset());
             }
             if ($element->getAttrib('ace_editor') == true) {
                 $value = $element->getValue();
                 $format = $this->_formatAceEditor;
                 $markup = sprintf($format, $name, $label, $name, $value, $id);
             } else {
                 $format = $this->_formatTextarea;
                 $cols = $element->getAttrib('cols');
                 $rows = $element->getAttrib('rows');
                 $markup = sprintf($format, $name, $label, $id, $name, $cols, $rows, $value);
             }
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Select':
             $options = '';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $options .= sprintf('<option value="%s"%s>%s</option>', $k, $k == $value ? ' selected="selected"' : '', $v);
             }
             $markup = sprintf($this->_formatSelect, $id, $label, $id, $name, $options);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Multiselect':
             $defaults = $element->getValue();
             if (!is_array($defaults)) {
                 if (empty($defaults)) {
                     $defaults = array();
                 } else {
                     $defaults = array($defaults);
                 }
             }
             $options = '';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $options .= sprintf('<option value="%s"%s>%s</option>', $k, in_array($k, $defaults) ? ' selected="selected"' : '', $v);
             }
             $markup = sprintf($this->_formatMultiselect, $id, $label, $id, $name, $element->getAttrib('size'), $options);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_MultiCheckbox':
             $options = '';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $options .= sprintf('<label><input type="checkbox" name="%s" value="%s">%s</label>', $name, $k, $v);
             }
             $markup = sprintf($this->_formatMulticheckbox, $label, $options);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Checkbox':
             $value = $element->getCheckedValue();
             $checked = $element->isChecked() ? 'checked="checked"' : '';
             $markup = sprintf($this->_formatCheckbox, $id, $label, $id, $name, $value, $checked);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Radio':
             $markup = '<label>' . $label . '</label>';
             foreach ($element->getAttrib('options') as $k => $v) {
                 $optid = $id . '-' . $k;
                 $checked = $k == $value ? 'checked="checked"' : '';
                 $markup .= sprintf($this->_formatRadio, $optid, $optid, $name, $k, $checked, $v['label']);
             }
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Password':
             $additionalParams = '';
             if ($element->getAttrib('maxlength') != null) {
                 $additionalParams .= sprintf('maxlength="%s"', $element->getAttrib('maxlength'));
             }
             if ($element->getAttrib('class') != null) {
                 $additionalParams .= sprintf('class="%s"', htmlspecialchars($element->getAttrib('class')));
             }
             $markup = sprintf($this->_formatPassword, $id, $label, $id, $name, $value, $additionalParams);
             break;
         case 'IfwPsn_Vendor_Zend_Form_Element_Text':
         default:
             $additionalParams = '';
             if ($element->getAttrib('maxlength') != null) {
                 $additionalParams .= sprintf('maxlength="%s"', $element->getAttrib('maxlength'));
             }
             if ($element->getAttrib('placeholder') != null) {
                 $additionalParams .= sprintf('placeholder="%s"', htmlspecialchars($element->getAttrib('placeholder')));
             }
             if ($element->getAttrib('class') != null) {
                 $additionalParams .= sprintf('class="%s"', htmlspecialchars($element->getAttrib('class')));
             }
             $markup = sprintf($this->_formatText, $id, $label, $id, $name, $value, $additionalParams);
             break;
     }
     return $markup;
 }
Example #28
0
 /**
  * @return IfwPsn_Wp_Http_Request
  */
 protected function _getRequest()
 {
     if ($this->_request === null) {
         $this->_request = new IfwPsn_Wp_Http_Request();
         $this->_request->setUrl($this->_pm->getConfig()->plugin->updateServer);
         $this->_request->addData('api-key', md5(IfwPsn_Wp_Proxy_Blog::getUrl()));
         $this->_request->addData('referrer', IfwPsn_Wp_Proxy_Blog::getUrl());
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             $this->_request->addData('browser_user_agent', $_SERVER['HTTP_USER_AGENT']);
         }
     }
     return $this->_request;
 }
Example #29
0
 /**
  * @return string|void
  */
 protected function _getPlatform()
 {
     return IfwPsn_Wp_Proxy_Blog::getUrl();
 }
Example #30
0
 /**
  * Get the blog admins display_name (if there is a user matching the blog admin email)
  * @return WP_User|null
  */
 public static function getAdminDisplayName()
 {
     $adminDisplayName = null;
     if (function_exists('get_user_by')) {
         $user = self::getByEmail(IfwPsn_Wp_Proxy_Blog::getAdminEmail());
         if ($user instanceof WP_User) {
             $adminDisplayName = $user->display_name;
         }
     } else {
         $u = IfwPsn_Wp_ORM_Model::factory('IfwPsn_Wp_Model_User')->where_equal('user_email', IfwPsn_Wp_Proxy_Blog::getAdminEmail())->find_one();
         if ($u instanceof IfwPsn_Wp_Model_User) {
             $adminDisplayName = $u->get('display_name');
         }
     }
     return $adminDisplayName;
 }