本文整理汇总了PHP中MagebridgeModelConfig类的典型用法代码示例。如果您正苦于以下问题:PHP MagebridgeModelConfig类的具体用法?PHP MagebridgeModelConfig怎么用?PHP MagebridgeModelConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MagebridgeModelConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setMessages
/**
* Method to set the messages
*/
public function setMessages()
{
if (MagebridgeModelConfig::load('enable_messages') == 0) {
return false;
}
$messages = $this->getResponseData();
if (!empty($messages) && is_array($messages)) {
$application = JFactory::getApplication();
foreach ($messages as $message) {
if (!is_array($message)) {
continue;
}
switch ($message['type']) {
case 'warning':
$type = 'warning';
break;
case 'error':
$type = 'error';
break;
default:
$type = 'message';
break;
}
$application->enqueueMessage($message['message'], $type);
}
}
return true;
}
示例2: getInput
protected function getInput()
{
$name = $this->name;
$fieldName = $name;
$value = $this->value;
if (MagebridgeModelConfig::load('api_widgets') == true) {
$cache = JFactory::getCache('com_magebridge_admin');
$cache->setCaching(0);
$options = $cache->call(array('JElementStoreview', 'getResult'));
// Parse the result into an HTML form-field
if (!empty($options) && is_array($options)) {
foreach ($options as $index => $option) {
if (!isset($option[$return])) {
$return = 'value';
}
$option['label'] = $option['label'] . ' (' . $option[$return] . ') ';
$option['value'] = $option[$return];
$options[$index] = $option;
}
array_unshift($options, array('value' => '', 'label' => ''));
return JHTML::_('select.genericlist', $options, $fieldName, null, 'value', 'label', $value);
} else {
MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "storeview": ' . var_export($options, true));
}
}
return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />';
}
示例3: getInput
protected function getInput()
{
$name = $this->name;
$fieldName = $name;
$value = $this->value;
// Are the API widgets enabled?
if (MagebridgeModelConfig::load('api_widgets') == true) {
// Load the javascript
JHTML::script('media/com_magebridge/js/backend-elements.js');
JHTML::_('behavior.modal', 'a.modal');
$returnType = (string) $this->element['return'];
$title = $value;
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
$link = 'index.php?option=com_magebridge&view=element&tmpl=component&type=customer&object=' . $name . '&return=' . $returnType . '&current=' . $value;
$html = '<div style="float: left;">';
$html .= '<input type="text" id="' . $name . '_name" value="' . $title . '" disabled="disabled" />';
$html .= '</div>';
$html .= '<div class="button2-left"><div class="blank">';
$html .= '<a class="modal" title="' . JText::_('Select a Customer') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x:800, y:450}}">' . JText::_('Select') . '</a>';
$html .= '</div></div>' . "\n";
$html .= '<input type="hidden" id="' . $name . '_id" name="' . $fieldName . '" value="' . $value . '" />';
return $html;
}
return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />';
}
示例4: getInput
/**
* Method to get the HTML of this element
*
* @param null
* @return string
*/
protected function getInput()
{
$name = $this->name;
$value = $this->value;
$id = preg_replace('/([^0-9a-zA-Z]+)/', '_', $name);
// Are the API widgets enabled?
if (MagebridgeModelConfig::load('api_widgets') == true) {
// Load the javascript
JHTML::script('media/com_magebridge/js/backend-elements.js');
JHTML::_('behavior.modal', 'a.modal');
$returnType = (string) $this->element['return'];
if (empty($returnType)) {
$returnType = 'sku';
}
$title = $value;
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
$link = 'index.php?option=com_magebridge&view=element&tmpl=component&ajax=1';
$link .= '&type=product&object=' . $id . '&return=' . $returnType . '&current=' . $value;
$html = array();
$html[] = '<span class="input-append">';
$html[] = '<input type="text" class="input-medium" id="' . $id . '" name="' . $name . '" value="' . $title . '" size="35" />';
$html[] = '<a class="modal btn" role="button" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>';
$html[] = '</span>';
$html = implode("\n", $html);
return $html;
}
return '<input type="text" name="' . $name . '" value="' . $value . '" />';
}
示例5: export
/**
* Method to export users to CSV
*
* @param null
* @return null
*/
public function export()
{
// Gather the variables
$users = $this->getUserList();
$website_id = MagebridgeModelConfig::load('users_website_id');
$group_id = MagebridgeModelConfig::load('users_group_id');
// Perform preliminary checks
if (empty($users)) {
$this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('No users found'), 'error');
return false;
}
if (empty($website_id)) {
$this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('Website not configured in export parameters'), 'error');
return false;
}
if (empty($group_id)) {
$this->setRedirect('index.php?option=com_magebridge&view=users', JText::_('Customer Group not configured in export parameters'), 'error');
return false;
}
$date = date('Ymd');
$filename = 'magebridge-export-joomla-users_' . $date . '.csv';
$output = $this->getOutput($users, $website_id, $group_id);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . YireoHelper::strlen($output));
header('Content-type: text/x-csv');
header('Content-Disposition: attachment; filename=' . $filename);
print $output;
// Close the application
$application = JFactory::getApplication();
$application->close();
}
示例6: load
public static function load()
{
if (MagebridgeModelConfig::load('preload_all_modules') == 0 && JRequest::getInt('Itemid') != 0) {
static $modules = null;
if (is_array($modules) == false) {
$modules = JModuleHelper::_load();
foreach ($modules as $index => $module) {
if (strstr($module->module, 'mod_magebridge') == false) {
unset($modules[$index]);
}
}
}
return $modules;
}
$application = JFactory::getApplication();
$db = JFactory::getDBO();
$where = array();
$where[] = 'm.published = 1';
$where[] = 'm.module LIKE "mod_magebridge%"';
$where[] = 'm.client_id = ' . (int) $application->getClientId();
$query = 'SELECT m.*' . ' FROM #__modules AS m' . ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id' . ' WHERE ' . implode(' AND ', $where) . ' ORDER BY m.position, m.ordering';
$db->setQuery($query);
$modules = $db->loadObjectList();
return $modules;
}
示例7: fetchElement
public function fetchElement($name, $value, $node = null, $control_name = null)
{
if (!empty($control_name)) {
$fieldName = $control_name . '[' . $name . ']';
} else {
$fieldName = $name;
}
// Are the API widgets enabled?
if (MagebridgeModelConfig::load('api_widgets') == true) {
// Load the javascript
JHTML::script('backend-elements.js', 'media/com_magebridge/js/');
JHTML::_('behavior.modal', 'a.modal');
if (!empty($node) && is_object($node)) {
$returnType = $node->attributes('return');
} else {
if (!empty($node) && is_array($node) && !empty($node['return'])) {
$returnType = $node['return'];
} else {
$returnType = 'sku';
}
}
$title = $value;
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
$link = 'index.php?option=com_magebridge&view=element&tmpl=component&ajax=1&type=widget&object=' . $name . '&return=' . $returnType . '&current=' . $value;
$html = '<div style="float: left;">';
$html .= '<input type="text" id="' . $name . '" name="' . $fieldName . '" value="' . $title . '" />';
$html .= '</div>';
$html .= '<div class="button2-left"><div class="blank">';
$html .= '<a class="modal" title="' . JText::_('Select a widget') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x:800, y:450}}">' . JText::_('Select') . '</a>';
$html .= '</div></div>' . "\n";
return $html;
}
return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />';
}
示例8: getStore
public function getStore()
{
// If the database configuration specified no stores, skip this step
if (MagebridgeModelConfig::load('load_stores') == 0) {
return null;
}
// Get the conditions
$db = JFactory::getDBO();
$db->setQuery("SELECT * FROM #__magebridge_stores WHERE `published`=1 ORDER BY `ordering`");
$conditions = $db->loadObjectList();
if (empty($conditions)) {
return null;
}
// Get the connectors
$connectors = $this->getConnectors();
// Try to match a condition with one of the connectors
foreach ($conditions as $condition) {
foreach ($connectors as $connector) {
if ($condition->connector == $connector->name) {
if ($connector->checkCondition($condition->connector_value) == TRUE) {
$type = $condition->type == 'storeview' ? 'store' : 'group';
return array('type' => $type, 'name' => $condition->name);
}
}
}
}
return null;
}
示例9: getInput
protected function getInput()
{
$name = $this->name;
$fieldName = $name;
$value = $this->value;
// Only build a dropdown when the API-widgets are enabled
if (MagebridgeModelConfig::load('api_widgets') == true) {
// Fetch the widget data from the API
$options = MageBridgeWidgetHelper::getWidgetData('website');
// Parse the result into an HTML form-field
if (!empty($options) && is_array($options)) {
foreach ($options as $index => $option) {
// Customize the return-value when the attribute "output" is defined
$output = (string) $this->element['output'];
if (!empty($output) && array_key_exists($output, $option)) {
$option['value'] = $option[$output];
}
// Customize the label
$option['label'] = $option['label'] . ' (' . $option['value'] . ') ';
// Add the option back to the list of options
$options[$index] = $option;
}
// Return a dropdown list
array_unshift($options, array('value' => '', 'label' => ''));
return JHTML::_('select.genericlist', $options, $fieldName, null, 'value', 'label', $value);
// Fetching data from the bridge failed, so report a warning
} else {
MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "website": ' . var_export($options, true));
}
}
// Return a simple input-field by default
return '<input type="text" name="' . $fieldName . '" value="' . $value . '" />';
}
示例10: getRequestData
/**
* Method to get the meta-data
*
* @return array
*/
public function getRequestData()
{
// Compile the meta-data
if (empty($this->_meta_data) || !is_array($this->_meta_data)) {
$application = JFactory::getApplication();
$input = $application->input;
$user = JFactory::getUser();
$uri = JURI::getInstance();
$session = JFactory::getSession();
$config = JFactory::getConfig();
$storeHelper = MageBridgeStoreHelper::getInstance();
$bridge = MageBridgeModelBridge::getInstance();
$app_type = $storeHelper->getAppType();
$app_value = $storeHelper->getAppValue();
$arguments = array('api_session' => $bridge->getApiSession(), 'api_user' => MageBridgeEncryptionHelper::encrypt(MagebridgeModelConfig::load('api_user')), 'api_key' => MageBridgeEncryptionHelper::encrypt(MagebridgeModelConfig::load('api_key')), 'api_url' => JURI::root() . 'component/magebridge/?controller=jsonrpc&task=call', 'app' => $application->getClientId(), 'app_type' => $app_type, 'app_value' => $app_value, 'storeview' => MagebridgeModelConfig::load('storeview'), 'storegroup' => MagebridgeModelConfig::load('storegroup'), 'website' => MagebridgeModelConfig::load('website'), 'customer_group' => MagebridgeModelConfig::load('customer_group'), 'joomla_url' => $bridge->getJoomlaBridgeUrl(), 'joomla_sef_url' => $bridge->getJoomlaBridgeSefUrl(), 'joomla_sef_suffix' => (int) MageBridgeUrlHelper::hasUrlSuffix(), 'joomla_user_email' => $application->isSite() && !empty($user->email) ? $user->email : null, 'joomla_current_url' => $uri->current(), 'modify_url' => MagebridgeModelConfig::load('modify_url'), 'enforce_ssl' => MagebridgeModelConfig::load('enforce_ssl'), 'has_ssl' => (int) $uri->isSSL(), 'payment_urls' => MagebridgeModelConfig::load('payment_urls'), 'enable_messages' => MagebridgeModelConfig::load('enable_messages'), 'joomla_session' => session_id(), 'joomla_conf_caching' => $config->get('caching', 60), 'joomla_conf_lifetime' => $config->get('lifetime', 60) * 60, 'magento_session' => $bridge->getMageSession(), 'magento_persistent_session' => $bridge->getMagentoPersistentSession(), 'magento_user_allowed_save_cookie' => isset($_COOKIE['user_allowed_save_cookie']) ? $_COOKIE['user_allowed_save_cookie'] : null, 'request_uri' => MageBridgeUrlHelper::getRequest(), 'request_id' => md5(JURI::current() . serialize($input->get->getArray())), 'post' => !empty($_POST) ? $_POST : null, 'http_referer' => $bridge->getHttpReferer(), 'http_host' => $uri->toString(array('host')), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'remote_addr' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'supportkey' => MagebridgeModelConfig::load('supportkey'), 'debug' => (int) MageBridgeModelDebug::isDebug(), 'debug_level' => MagebridgeModelConfig::load('debug_level'), 'debug_display_errors' => MagebridgeModelConfig::load('debug_display_errors'), 'protocol' => MagebridgeModelConfig::load('protocol'), 'state' => 'initializing', 'ajax' => (int) $bridge->isAjax(), 'disable_css' => MageBridgeHelper::getDisableCss(), 'disable_js' => MageBridgeHelper::getDisableJs());
if (MageBridgeTemplateHelper::isMobile()) {
$arguments['theme'] = MagebridgeModelConfig::load('mobile_magento_theme');
} else {
$arguments['theme'] = MagebridgeModelConfig::load('magento_theme');
}
foreach ($arguments as $name => $value) {
if (is_string($value)) {
$arguments[$name] = MageBridgeEncryptionHelper::base64_encode($value);
}
}
$this->_meta_data = $arguments;
}
return $this->_meta_data;
}
示例11: encrypt
/**
* Encrypt data for security
*
* @param mixed $data
* @return string
*/
public static function encrypt($data)
{
// Don't do anything with empty data
$data = trim($data);
if (empty($data)) {
return null;
}
// Check if encryption was turned off
if (MagebridgeModelConfig::load('encryption') == 0) {
return $data;
}
// Check if SSL is already in use, so encryption is not needed
if (MagebridgeModelConfig::load('protocol') == 'https') {
return $data;
}
// Check for mcrypt
if (!function_exists('mcrypt_get_iv_size') || !function_exists('mcrypt_cfb')) {
return $data;
}
// Generate a random key
$random = str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
$key = MageBridgeEncryptionHelper::getSaltedKey($random);
try {
$td = mcrypt_module_open(MCRYPT_CAST_256, '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$encrypted = mcrypt_generic($td, $data);
$encoded = MageBridgeEncryptionHelper::base64_encode($encrypted);
} catch (Exception $e) {
Mage::getSingleton('magebridge/debug')->error("Error while decrypting: " . $e->getMessage());
return null;
}
return $encoded . '|=|' . $random;
}
示例12: call
public function call($call = '', $options = array())
{
if (empty($this->session_id)) {
$api_user = MagebridgeModelConfig::load('api_user');
$api_key = MagebridgeModelConfig::load('api_key');
$msg = new xmlrpcmsg('login', array($this->encode($api_user), $this->encode($api_key)));
$doc = $this->client->send($msg, $this->timeout);
if (!is_object($doc)) {
return JText::_('XML-RPC non-object document: ' . $doc);
}
$value = $doc->value();
if (!is_object($value)) {
return JText::_('XML-RPC non-object value: ' . $value);
}
$this->session_id = $doc->value()->getval();
if (!$this->session_id > 0) {
return JText::_('Empty session ID: ' . $doc->faultString());
}
}
$msg = new xmlrpcmsg('call', array($this->encode($this->session_id), $this->encode($call)));
$doc = $this->client->send($msg, $this->timeout);
if ($doc->faultCode() == 0) {
return $this->decode($doc->value());
} else {
return $doc->faultString();
}
}
示例13: store
/**
* Method to store the item
*
* @package MageBridge
* @access public
* @param array $data
* @return bool
*/
public function store($data)
{
// Store the item
$rt = parent::store($data);
// Change the setting "load_urls" in the MageBridge configuration
if ($data['published'] == 1) {
MagebridgeModelConfig::saveValue('load_urls', 1);
}
return $rt;
}
示例14: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
if (MagebridgeModelConfig::load('api_widgets') == true) {
$options = MageBridgeWidgetHelper::getWidgetData('theme');
if (!empty($options) && is_array($options)) {
array_unshift($options, array('value' => '', 'label' => '-- Select --'));
return JHTML::_('select.genericlist', $options, $name, null, 'value', 'label', $value);
} else {
MageBridgeModelDebug::getInstance()->warning('Unable to obtain MageBridge API Widget "theme": ' . var_export($options, true));
}
}
return '<input type="text" name="' . $name . '" value="' . $value . '" />';
}
示例15: getInput
/**
* Method to get the output of this element
*
* @param null
* @return string
*/
protected function getInput()
{
$name = $this->name;
$fieldName = $this->fieldname;
$value = $this->value;
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
$options = TemplatesHelper::getTemplateOptions(0);
if (!empty($options) && is_array($options)) {
array_unshift($options, array('value' => '', 'text' => ''));
return JHTML::_('select.genericlist', $options, $fieldName, null, 'value', 'text', MagebridgeModelConfig::load($fieldName));
}
return '<input type="text" name="' . $name . '" value="' . $value . '" />';
}