本文整理汇总了PHP中JInput::get方法的典型用法代码示例。如果您正苦于以下问题:PHP JInput::get方法的具体用法?PHP JInput::get怎么用?PHP JInput::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInput
的用法示例。
在下文中一共展示了JInput::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkData
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*/
public function checkData($isNew, $auto_added = false)
{
global $jlistConfig;
jimport('joomla.filesystem.file ');
jimport('joomla.filesystem.folder');
jimport('joomla.html.html');
$user = JFactory::getUser();
$db = JFactory::getDBO();
$app = JFactory::getApplication();
// we neeed the jform data
$jinput = JFactory::getApplication()->input;
$formdata = $jinput->get('jform', array(), 'array');
// we neeed also the jform files data
$jFileInput = new JInput($_FILES);
$files = $jFileInput->get('jform', array(), 'array');
$default_access_value_used = false;
// doing the next part only when we have a new download creation or an editing in frontend
if ($app->isSite() && !$auto_added) {
$user_rules = JDHelper::getUserRules();
// we must check some from the required fields manually, which are not checked with javascript
if ($this->cat_id == 0) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CATEGORY'));
}
if ($user_rules->form_changelog && $user_rules->form_changelog_x && $this->changelog == '') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CHANGELOG'));
}
if ($user_rules->form_short_desc && $user_rules->form_short_desc_x && $this->description == '') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_SHORT_DESC'));
}
if ($user_rules->form_long_desc && $user_rules->form_long_desc_x && $this->description_long == '') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_LONG_DESC'));
}
if ($user_rules->form_extra_large_input_1 && $user_rules->form_extra_large_input_1_x && $this->custom_field_13 == '') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_TEXT'));
}
if ($user_rules->form_extra_large_input_2 && $user_rules->form_extra_large_input_2_x && $this->custom_field_14 == '') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_TEXT'));
}
if ($user_rules->form_license && $user_rules->form_license_x && !$this->license) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_LICENSE'));
}
if ($user_rules->form_creation_date && $user_rules->form_creation_date_x && $this->date_added == '0000-00-00 00:00:00') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_DATE_ADDED'));
}
if ($user_rules->form_file_date && $user_rules->form_file_date_x && $this->file_date == '0000-00-00 00:00:00') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_DATE_FILE'));
}
if ($user_rules->form_file_language && $user_rules->form_file_language_x && !$this->file_language) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_LANGUAGE_FILE'));
}
if ($user_rules->form_file_system && $user_rules->form_file_system_x && !$this->system) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_SYSTEM_FILE'));
}
if ($user_rules->form_file_pic && $user_rules->form_file_pic_x && !$this->file_pic) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_PIC_FILE'));
}
// we need the total amount of selected image files
$thumb_image_files = $jFileInput->get('file_upload_thumb', array(), 'array');
$amount_selected_thumbs_files = count($thumb_image_files['name']);
foreach ($thumb_image_files['name'] as $name) {
if (!$name) {
$amount_selected_thumbs_files--;
}
}
if ($user_rules->form_images && $user_rules->form_images_x && !$amount_selected_thumbs_files) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_IMAGES'));
}
if ($user_rules->form_extra_select_box_1 && $user_rules->form_extra_select_box_1_x && !$this->custom_field_1) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_SELECT'));
}
if ($user_rules->form_extra_select_box_2 && $user_rules->form_extra_select_box_2_x && !$this->custom_field_2) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_SELECT'));
}
if ($user_rules->form_extra_select_box_3 && $user_rules->form_extra_select_box_3_x && !$this->custom_field_3) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_SELECT'));
}
if ($user_rules->form_extra_select_box_4 && $user_rules->form_extra_select_box_4_x && !$this->custom_field_4) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_SELECT'));
}
if ($user_rules->form_extra_select_box_5 && $user_rules->form_extra_select_box_5_x && !$this->custom_field_5) {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_SELECT'));
}
if ($user_rules->form_extra_date_1 && $user_rules->form_extra_extra_date_1_x && $this->custom_field_11 == '0000-00-00 00:00:00') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_DATE'));
}
if ($user_rules->form_extra_date_2 && $user_rules->form_extra_extra_date_2_x && $this->custom_field_12 == '0000-00-00 00:00:00') {
$this->setError(JText::_('COM_JDOWNLOADS_REQUIRED_CUSTOM_DATE'));
}
// break when we have before found a invalid data field
if ($this->getErrors()) {
return false;
}
// check the file extension when frontend upload
if ($files['tmp_name']['file_upload'] != '' || $files['name']['file_upload'] != '') {
$file_extension = JFile::getExt($files['name']['file_upload']);
//.........这里部分代码省略.........
示例2: build
function build()
{
$jinput = new JInput();
//Initialize default form
$keys = array('option' => $this->getExtension(), 'view' => $this->getView(), 'layout' => $jinput->get('layout', null, 'CMD'), 'task' => "");
//For item layout
if (isset($this->dataObject)) {
$keys['id'] = isset($this->dataObject->id) ? $this->dataObject->id : 0;
//Deprecated
$keys['cid[]'] = isset($this->dataObject->id) ? $this->dataObject->id : 0;
}
//Specifics values or overrides
if (isset($this->values)) {
foreach ($this->values as $key => $value) {
$keys[$key] = $value;
}
}
//Reproduce current query in the form
$followers = array('lang', 'Itemid', 'tmpl');
//Cmd types only for the moment
foreach ($followers as $follower) {
$val = $jinput->get($follower, null, 'CMD');
if ($val) {
$keys[$follower] = $val;
}
}
$html = "";
foreach ($keys as $key => $value) {
$html .= JDom::_('html.form.input.hidden', array('dataKey' => $key, 'dataValue' => $value));
}
//Token
$html .= JHTML::_('form.token');
return $html;
}
示例3: onContentBeforeSave
/**
* Example before save content method
*
* Method is called right before content is saved into the database.
* Article object is passed by reference, so any changes will be saved!
* NOTE: Returning false will abort the save with an error.
*You can set the error by calling $article->setError($message)
*
* @param string The context of the content passed to the plugin.
* @param object A JTableContent object
* @param bool If the content is just about to be created
* @return bool If false, abort the save
* @since 1.6
*/
public function onContentBeforeSave($context, $article, $isNew)
{
//error_log("plgContentArticlesubmit::onContentBeforeSave") ;
$app = JFactory::getApplication();
// run this plugin only for com_content
$parts = explode(".", $context);
if ($parts[0] != 'com_content') {
return true;
}
// dont do anything is it is not frontend
if (!$app->isSite()) {
return true;
}
$jinput = $app->input;
$formData = new JInput($jinput->get('jform', '', 'array'));
//error_log("jinput == " . print_r($jinput,true));
$introtext = $formData->get('article_introtext', '', 'html');
//error_log("introtext == " . $introtext);
$fulltext = $formData->get('article_fulltext', '', 'raw');
//error_log("fulltext == " . $fulltext);
$article->introtext = $introtext;
$article->fulltext = $fulltext;
$savedImage = $this->saveImage($article);
if ($savedImage) {
$images = array();
$images['image_fulltext'] = $savedImage;
$images['image_intro'] = $savedImage;
$article->images = json_encode($images);
return true;
} else {
$article->setError("Could not process the uploaded image. Please try again with a different (smaller) image.");
return false;
}
return true;
}
示例4: _get
/**
* {@inheritdoc}
*/
protected function _get($name, $default = null, $isArray = false)
{
if ($isArray) {
return $this->_input->get($name, $default, 'array');
}
// Yeap, HTML is not RAW, but it safes your website
return $this->_input->get($name, $default, 'html');
}
示例5: upload
/**
* upload
*
* @param \JInput $input
*/
public static function upload(\JInput $input)
{
try {
$editorPlugin = \JPluginHelper::getPlugin('editors', 'akmarkdown');
if (!$editorPlugin) {
throw new \Exception('Editor Akmarkdown not exists');
}
$params = new Registry($editorPlugin->params);
$files = $input->files;
$field = $input->get('field', 'file');
$type = $input->get('type', 'post');
$allows = $params->get('Upload_AllowExtension', '');
$allows = array_map('strtolower', array_map('trim', explode(',', $allows)));
$file = $files->getVar($field);
$src = $file['tmp_name'];
$name = $file['name'];
$tmp = new \SplFileInfo(JPATH_ROOT . '/tmp/ak-upload/' . $name);
if (empty($file['tmp_name'])) {
throw new \Exception('File not upload');
}
$ext = pathinfo($name, PATHINFO_EXTENSION);
if (!in_array($ext, $allows)) {
throw new \Exception('File extension now allowed.');
}
// Move file to tmp
if (!is_dir($tmp->getPath())) {
\JFolder::create($tmp->getPath());
}
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
\JFile::upload($src, $tmp->getPathname());
$src = $tmp;
$dest = static::getDest($name, $params->get('Upload_S3_Subfolder', 'ak-upload'));
$s3 = new \S3($params->get('Upload_S3_Key'), $params->get('Upload_S3_SecretKey'));
$bucket = $params->get('Upload_S3_Bucket');
$result = $s3::putObject(\S3::inputFile($src->getPathname(), false), $bucket, $dest, \S3::ACL_PUBLIC_READ);
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
if (!$result) {
throw new \Exception('Upload fail.');
}
} catch (\Exception $e) {
$response = new Response();
$response->setBody(json_encode(['error' => $e->getMessage()]));
$response->setMimeType('text/json');
$response->respond();
exit;
}
$return = new \JRegistry();
$return['filename'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$return['file'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$response = new Response();
$response->setBody((string) $return);
$response->setMimeType('text/json');
$response->respond();
}
示例6: testGet
/**
* Test the JInput::get method.
*
* @return void
*
* @since 11.1
*/
public function testGet()
{
$_REQUEST['foo'] = 'bar';
// Test the get method.
$this->assertThat($this->class->get('foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.');
$_GET['foo'] = 'bar2';
// Test the get method.
$this->assertThat($this->class->get->get('foo'), $this->equalTo('bar2'), 'Line: ' . __LINE__ . '.');
// Test the get method.
$this->assertThat($this->class->get('default_value', 'default'), $this->equalTo('default'), 'Line: ' . __LINE__ . '.');
}
示例7: parseUserTask
/**
* parseTask
*
* @param string $controller
* @param \JInput $input
*
* @return void
*/
public static function parseUserTask($controller, $input)
{
$task = $input->get('task');
if (is_numeric($task)) {
$id = $task;
$input->set('id', $id);
$input->set('task', null);
} else {
$input->set('task', 'user.' . $input->get('task'));
}
}
示例8: createView
/**
* @param array $data
* @return Renderer
*/
public function createView(array $data = array())
{
$renderer = new Renderer($data);
$name = $this->getName();
// Add the default view path
$renderer->addIncludePath(COMPONENT_ROOT . '/src/views/' . $this->getName());
$template = $this->app->getTemplate();
$option = $this->input->get('option');
// Prepend the template path
$renderer->addIncludePath(JPATH_ROOT . '/templates/' . $template . '/html/' . $option . '/' . $this->getName(), true);
return $renderer;
}
示例9: start
/**
* Starts the session
*
* @return boolean True if started
*
* @since 3.5
* @throws RuntimeException If something goes wrong starting the session.
*/
public function start()
{
$session_name = $this->getName();
// Get the JInputCookie object
$cookie = $this->input->cookie;
if (is_null($cookie->get($session_name))) {
$session_clean = $this->input->get($session_name, false, 'string');
if ($session_clean) {
$this->setId($session_clean);
$cookie->set($session_name, '', time() - 3600);
}
}
return parent::start();
}
示例10: _start
/**
* Start a session.
*
* Creates a session (or resumes the current one based on the state of the session)
*
* @return boolean true on success
*
* @since 11.1
*/
protected function _start()
{
// Start session if not started
if ($this->_state === 'restart') {
session_regenerate_id(true);
} else {
$session_name = session_name();
// Get the JInputCookie object
$cookie = $this->_input->cookie;
if (is_null($cookie->get($session_name))) {
$session_clean = $this->_input->get($session_name, false, 'string');
if ($session_clean) {
session_id($session_clean);
$cookie->set($session_name, '', time() - 3600);
}
}
}
/**
* Write and Close handlers are called after destructing objects since PHP 5.0.5.
* Thus destructors can use sessions but session handler can't use objects.
* So we are moving session closure before destructing objects.
*
* Replace with session_register_shutdown() when dropping compatibility with PHP 5.3
*/
register_shutdown_function('session_write_close');
session_cache_limiter('none');
session_start();
return true;
}
示例11: build
/**
* Build route.
*
* @param string $name Route resource name.
* @param array &$queries Http queries.
*
* @return array
*/
public function build($name, &$queries)
{
if (empty($this->resources[$name])) {
return array();
}
if (is_callable($this->buildHandler[$name])) {
call_user_func_array($this->buildHandler[$name], array($queries));
}
$replace = array();
$pattern = $this->resources[$name];
foreach ($this->maps[$name]['vars'] as $key) {
$var = isset($queries[$key]) ? $queries[$key] : $this->input->get($key, 'null');
if (is_array($var) || is_object($var)) {
$var = implode('/', (array) $var);
$key2 = '*' . $key;
$replace[$key2] = $var;
} else {
$key2 = ':' . $key;
$replace[$key2] = $var;
}
if (strpos($pattern, $key2) !== false) {
unset($queries[$key]);
}
}
$pattern = strtr($pattern, $replace);
return explode('/', $pattern);
}
示例12: getContext
/**
* getContext
*
* @return string
*/
public function getContext()
{
$option = $this->input->get('option');
$view = $this->input->get('view');
$context = "{$option}.{$view}";
return $context;
}
示例13: init
/**
* Init this component.
*
* @return void
*/
public function init()
{
$dispatcher = $this->container->get('event.dispatcher');
// Event
$dispatcher->trigger('onComponentBeforeInit', array($this->name, $this, $this->input));
// We build component path constant, helpe us get path easily.
$this->path['self'] = JPATH_BASE . '/components/' . strtolower($this->option);
$this->path['site'] = JPATH_ROOT . '/components/' . strtolower($this->option);
$this->path['administrator'] = JPATH_ROOT . '/administrator/components/' . strtolower($this->option);
define(strtoupper($this->name) . '_SELF', $this->path['self']);
define(strtoupper($this->name) . '_SITE', $this->path['site']);
define(strtoupper($this->name) . '_ADMIN', $this->path['administrator']);
// Register some useful object for this component.
$this->container->registerServiceProvider(new ComponentProvider($this->name, $this));
$task = $this->input->getWord('task');
$controller = $this->input->getWord('controller');
// Prepare default controller
if (!$task && !$controller) {
// If we got view, set it to display controller.
$view = $this->input->get('view');
$task = $view ? $view . '.display' : $this->defaultController;
$this->input->set('task', $task);
$this->input->set('controller', $task);
}
// Register form and fields
\JForm::addFieldPath(WINDWALKER_SOURCE . '/Form/Fields');
\JForm::addFormPath(WINDWALKER_SOURCE . '/Form/Forms');
$this->registerEventListener();
// Register elFinder controllers
// @TODO: Should use event listener
$this->registerTask('finder.elfinder.display', '\\Windwalker\\Elfinder\\Controller\\DisplayController');
$this->registerTask('finder.elfinder.connect', '\\Windwalker\\Elfinder\\Controller\\ConnectController');
// Event
$dispatcher->trigger('onComponentAfterInit', array($this->name, $this, $this->input));
}
示例14: detectRemoteUser
/**
* This method checks if a value for remote user is present inside
* the $_SERVER array. If so then replace any domain related stuff
* to get the username and return it.
*
* @return mixed Username of detected user or False.
*
* @since 1.0
*/
public function detectRemoteUser()
{
/*
* When legacy flag is true, it ensures compatibility with JSSOMySite 1.x by
* only returning a string username or false can be returned. This also means
* keeping compatibility with Joomla 1.6.
* When it is set to False, it can return an array and compatible with Joomla 2.5.
*/
$legacy = $this->params->get('use_legacy', false);
// Get the array key of $_SERVER where the user can be located
$serverKey = strtoupper($this->params->get('userkey', 'REMOTE_USER'));
// Get the $_SERVER key and ensure its lowercase and doesn't filter
if ($legacy) {
// Get the $_SERVER value which should contain the SSO username
$remoteUser = JRequest::getVar($serverKey, null, 'server', 'string', JREQUEST_ALLOWRAW);
} else {
// Get the $_SERVER value which should contain the SSO username
$input = new JInput($_SERVER);
$remoteUser = $input->get($serverKey, null, 'USERNAME');
unset($input);
}
// Ensures the returned user is lowercased
$remoteUser = strtolower($remoteUser);
// Get a username replacement parameter in lowercase and split by semi-colons
$replace_set = explode(';', strtolower($this->params->get('username_replacement', '')));
foreach ($replace_set as $replacement) {
$remoteUser = str_replace(trim($replacement), '', $remoteUser);
}
// Returns the username
return $remoteUser;
}
示例15: detectRemoteUser
/**
* Gets the IP address of the client machine, translates it to a compatiable
* eDirectory netadress and queries it against the LDAP server using a filter.
*
* @return mixed Username of detected user or False.
*
* @since 1.0
*/
public function detectRemoteUser()
{
// Import languages for frontend errors
$this->loadLanguage();
/*
* When legacy flag is true, it ensures compatibility with JSSOMySite 1.x by
* only returning a string username or false can be returned. This also means
* keeping compatibility with Joomla 1.6.
* When it is set to False, it can return an array and compatible with Joomla 2.5.
*/
$legacy = $this->params->get('use_legacy', false);
if ($legacy) {
// Use legacy way of getting paramters
$authParams = new JRegistry();
$authName = $this->params->get('auth_plugin', 'jmapmyldap');
$authPlugin = JPluginHelper::getPlugin('authentication', $authName);
$authParams->loadString($authPlugin->params);
$ldapUid = $authParams->get('ldap_uid', 'uid');
// Attempt to load up a LDAP instance using the legacy method
jimport('shmanic.jldap2');
$ldap = new JLDAP2($authParams);
// Lets try to bind using proxy user
if (!$ldap->connect() || !$ldap->bind($ldap->connect_username, $ldap->connect_password)) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('PLG_EDIR_ERROR_LDAP_BIND'));
return;
}
// Get IP of client machine
$myip = JRequest::getVar('REMOTE_ADDR', 0, 'server');
// Convert this to some net address thing that edir likes
$na = JLDAPHelper::ipToNetAddress($myip);
// Find the network address and return the uid for it
$filter = "(networkAddress={$na})";
$dn = $authParams->get('base_dn');
// Do the LDAP filter search now
$result = new JLDAPResult($ldap->search($dn, $filter, array($ldapUid)));
$ldap->close();
} else {
try {
// We will only check the first LDAP config
$ldap = SHLdap::getInstance();
$ldap->proxyBind();
$ldapUid = $ldap->getUid;
// Get the IP address of this client and convert to netaddress for LDAP searching
$input = new JInput($_SERVER);
$myIp = $input->get('REMOTE_ADDR', false, 'string');
$na = SHLdapHelper::ipToNetAddress($myIp);
$result = $ldap->search(null, "(networkAddress={$na})", array($ldapUid));
} catch (Exception $e) {
SHLog::add($e, 16010, JLog::ERROR, 'sso');
return;
}
}
if ($value = $result->getValue(0, $ldapuid, 0)) {
// Username was found logged in on this client machine
return $value;
}
}