本文整理汇总了PHP中CParameter::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP CParameter::bind方法的具体用法?PHP CParameter::bind怎么用?PHP CParameter::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CParameter
的用法示例。
在下文中一共展示了CParameter::bind方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplateParams
public function getTemplateParams()
{
$template = new CTemplateHelper();
$defaultParam = $template->getTemplatePath('params.ini', 'default');
$templateParam = $template->getTemplatePath('params.ini');
$overrideParam = $template->getOverrideTemplatePath('params.ini');
$params = new CParameter('');
if (JFile::exists($defaultParam)) {
$params->bind(JFile::read($defaultParam));
}
if (JFile::exists($templateParam)) {
$params->bind(JFile::read($templateParam));
}
if (JFile::exists($overrideParam)) {
$params->bind(JFile::read($overrideParam));
}
return $params;
}
示例2: ajaxSaveSettings
/**
*
*/
public function ajaxSaveSettings($postvars)
{
// Check permissions
$my =& JFactory::getUser();
$filter = JFilterInput::getInstance();
$postvars = $filter->clean($postvars, 'array');
if ($my->id == 0) {
return $this->ajaxBlockUnregister();
}
$objResponse = new JAXResponse();
$appsModel = CFactory::getModel('apps');
$appName = $postvars['appname'];
$id = $postvars['appid'];
// @rule: Test if app is core app as we need to add into the db
$pluginId = $appsModel->getPluginId($appName);
$appParam = new CParameter($appsModel->getPluginParams($pluginId));
if ($pluginId && $my->id != 0 && $appParam->get('coreapp')) {
// Add new app in the community plugins table
$appsModel->addApp($my->id, $appName);
// @rule: For core applications, the ID might be referring to Joomla's id. Get the correct id if needed.
$id = $appsModel->getUserApplicationId($appName, $my->id);
}
// Make sure this is valid for current user
if (!$appsModel->isOwned($my->id, $id)) {
// It could be that the app is a core app.
$objResponse->addAlert('COM_COMMUNITY_PERMISSION_ERROR');
return $objResponse->sendResponse();
}
$post = array();
// convert $postvars to normal post
$pattern = "'params\\[(.*?)\\]'s";
for ($i = 0; $i < count($postvars); $i++) {
if (!empty($postvars[$i]) && is_array($postvars[$i])) {
$key = $postvars[$i][0];
// Blogger view
preg_match($pattern, $key, $matches);
if ($matches) {
$key = $matches[1];
}
$post[$key] = $postvars[$i][1];
}
}
$xmlPath = JPATH_COMPONENT . DS . 'applications' . DS . $appName . DS . $appName . '.xml';
$params = new CParameter($appsModel->getUserAppParams($id), $xmlPath);
$params->bind($post);
//echo $params->toString();
$appsModel->storeParams($id, $params->toString());
$objResponse->addScriptCall('cWindowHide');
return $objResponse->sendResponse();
}
示例3: ajaxSaveField
/**
* AJAX method to save a field
*
* @param int id Current field id
* @param Array data The fields data
*
* @return JAXResponse object Azrul's AJAX Response object
**/
public function ajaxSaveField($id, $data)
{
$user =& JFactory::getUser();
if ($user->get('guest')) {
JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
return;
}
$response = new JAXResponse();
// Load the JTable Object.
$row =& JTable::getInstance('profiles', 'CommunityTable');
$row->load($id);
$isValid = true;
$row->bindAjaxPost($data);
// override the option visiable, registration and required for label type.
if ($row->type == 'label') {
$row->visible = 0;
$row->required = 0;
}
// Do some validation before blindly saving the profile.
if (empty($row->name)) {
$error = JText::_('COM_COMMUNITY_PROFILE_NAME_EMPTY_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if (empty($row->fieldcode)) {
$error = JText::_('COM_COMMUNITY_PROFILE_FIELD_CODE_EMPTY_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if (($row->type == 'select' || $row->type == 'singleselect' || $row->type == 'list' || $row->type == 'radio' || $row->type == 'checkbox') && empty($row->options)) {
$error = JText::_('COM_COMMUNITY_PROFILE_FIELD_OPTIONS_EMPTY_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if ($row->required && !$row->registration) {
$error = JText::_('COM_COMMUNITY_PROFILE_FIELD_REQUIRED_CHECK_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if ($isValid) {
$groupOrdering = isset($data['group']) ? $data['group'] : '';
/* Now, save optional params items */
$xmlPath = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'fields' . DS . $row->type . '.xml';
if (JFile::exists($xmlPath)) {
$postvars = $data;
$post = array();
// convert $postvars to normal post
$pattern = "'params\\[(.*?)\\]'s";
for ($i = 0; $i < count($postvars); $i++) {
if (!empty($postvars[$i]) && is_array($postvars[$i])) {
$key = $postvars[$i][0];
// @TODO: support 'usergroup' param type
preg_match($pattern, $key, $matches);
if ($matches) {
$key = $matches[1];
$post[$key] = $postvars[$i][1];
}
}
}
$params = new CParameter('', $xmlPath);
$params->bind($post);
$row->params = $params->toString();
}
$row->store($groupOrdering);
$parent = '';
// Get the view
$view =& $this->getView('profiles', 'html');
if ($id != 0) {
$name = '<a href="javascript:void(0);" onclick="azcommunity.editField(\'' . $row->id . '\');">' . $row->name . '</a>';
$type = '<span id="type' . $row->id . '" onclick="$(\'typeOption\').style.display = \'block\';$(this).style.display = \'none\';">' . JString::ucfirst($row->type) . '</span>';
$publish = $view->getPublish($row, 'published', 'profiles,ajaxTogglePublish');
if ($row->type == 'label') {
$required = $view->showPublish($row, 'required');
$visible = $view->showPublish($row, 'visible');
} else {
$required = $view->getPublish($row, 'required', 'profiles,ajaxTogglePublish');
$visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish');
}
$registration = $view->getPublish($row, 'registration', 'profiles,ajaxTogglePublish');
// Set the parent id
$parent = $row->id;
// Update the rows in the table at the page.
//@todo: need to update the title in a way looks like Joomla initialize the tooltip on document ready
$response->addAssign('name' . $row->id, 'innerHTML', $name);
$response->addAssign('type' . $row->id, 'innerHTML', $type);
$response->addAssign('published' . $row->id, 'innerHTML', $publish);
$response->addAssign('required' . $row->id, 'innerHTML', $required);
$response->addAssign('visible' . $row->id, 'innerHTML', $visible);
$response->addAssign('registration' . $row->id, 'innerHTML', $registration);
$response->addAssign('min' . $row->id, 'value', $row->min);
$response->addAssign('max' . $row->id, 'value', $row->max);
} else {
//.........这里部分代码省略.........
示例4: ajaxSaveField
/**
* AJAX method to save a field
*
* @param int id Current field id
* @param Array data The fields data
*
* @return JAXResponse object Azrul's AJAX Response object
**/
public function ajaxSaveField($id, $data)
{
$user = JFactory::getUser();
if ($user->get('guest')) {
JError::raiseError(403, JText::_('COM_COMMUNITY_ACCESS_FORBIDDEN'));
return;
}
$response = new JAXResponse();
// Load the JTable Object.
$row = JTable::getInstance('profiles', 'CommunityTable');
$row->load($id);
$isValid = true;
$row->bindAjaxPost($data);
// override the option visiable, registration and required for label type.
if ($row->type == 'label') {
//$row->visible = 0;
$row->required = 0;
}
// Do some validation before blindly saving the profile.
if (empty($row->name)) {
$error = JText::_('COM_COMMUNITY_PROFILE_NAME_EMPTY_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if (empty($row->fieldcode)) {
$error = JText::_('COM_COMMUNITY_PROFILE_FIELD_CODE_EMPTY_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if (($row->type == 'select' || $row->type == 'singleselect' || $row->type == 'list' || $row->type == 'radio' || $row->type == 'checkbox') && empty($row->options)) {
$error = JText::_('COM_COMMUNITY_PROFILE_FIELD_OPTIONS_EMPTY_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if ($row->required && !$row->registration) {
$error = JText::_('COM_COMMUNITY_PROFILE_FIELD_REQUIRED_CHECK_WARN');
$response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
$isValid = false;
}
if ($isValid) {
$groupOrdering = isset($data['group']) ? $data['group'] : '';
/* Now, save optional params items */
$xmlPath = JPATH_ROOT . '/components/com_community/libraries/fields/' . $row->type . '.xml';
if (JFile::exists($xmlPath)) {
$postvars = $data;
$post = array();
// convert $postvars to normal post
$pattern = "'params\\[(.*?)\\]'s";
for ($i = 0; $i < count($postvars); $i++) {
if (!empty($postvars[$i]) && is_array($postvars[$i])) {
$key = $postvars[$i][0];
// @TODO: support 'usergroup' param type
preg_match($pattern, $key, $matches);
if ($matches) {
$key = $matches[1];
$post[$key] = $postvars[$i][1];
}
}
}
$params = new CParameter('', $xmlPath);
$params->bind($post);
$row->params = $params->toString();
}
if ($row->type == 'gender') {
$row->options = "COM_COMMUNITY_MALE\nCOM_COMMUNITY_FEMALE";
} elseif ($row->type == 'country') {
$row->options = 'Afghanistan' . "\n" . 'Albania' . "\n" . 'Algeria' . "\n" . 'American Samoa' . "\n" . 'Andorra' . "\n" . 'Angola' . "\n" . 'Anguilla' . "\n" . 'Antarctica' . "\n" . 'Antigua and Barbuda' . "\n" . 'Argentina' . "\n" . 'Armenia' . "\n" . 'Aruba' . "\n" . 'Australia' . "\n" . 'Austria' . "\n" . 'Azerbaijan' . "\n" . 'Bahamas' . "\n" . 'Bahrain' . "\n" . 'Bangladesh' . "\n" . 'Barbados' . "\n" . 'Belarus' . "\n" . 'Belgium' . "\n" . 'Belize' . "\n" . 'Benin' . "\n" . 'Bermuda' . "\n" . 'Bhutan' . "\n" . 'Bolivia' . "\n" . 'Bosnia and Herzegovina' . "\n" . 'Botswana' . "\n" . 'Bouvet Island' . "\n" . 'Brazil' . "\n" . 'British Indian Ocean Territory' . "\n" . 'Brunei Darussalam' . "\n" . 'Bulgaria' . "\n" . 'Burkina Faso' . "\n" . 'Burundi' . "\n" . 'Cambodia' . "\n" . 'Cameroon' . "\n" . 'Canada' . "\n" . 'Cape Verde' . "\n" . 'Cayman Islands' . "\n" . 'Central African Republic' . "\n" . 'Chad' . "\n" . 'Chile' . "\n" . 'China' . "\n" . 'Christmas Island' . "\n" . 'Cocos (Keeling) Islands' . "\n" . 'Colombia' . "\n" . 'Comoros' . "\n" . 'Congo' . "\n" . 'Cook Islands' . "\n" . 'Costa Rica' . "\n" . 'Cote D\'Ivoire (Ivory Coast)' . "\n" . 'Croatia (Hrvatska)' . "\n" . 'Cuba' . "\n" . 'Cyprus' . "\n" . 'Czechoslovakia (former)' . "\n" . 'Czech Republic' . "\n" . 'Denmark' . "\n" . 'Djibouti' . "\n" . 'Dominica' . "\n" . 'Dominican Republic' . "\n" . 'East Timor' . "\n" . 'Ecuador' . "\n" . 'Egypt' . "\n" . 'El Salvador' . "\n" . 'Equatorial Guinea' . "\n" . 'Eritrea' . "\n" . 'Estonia' . "\n" . 'Ethiopia' . "\n" . 'Falkland Islands (Malvinas)' . "\n" . 'Faroe Islands' . "\n" . 'Fiji' . "\n" . 'Finland' . "\n" . 'France' . "\n" . 'France, Metropolitan' . "\n" . 'French Guiana' . "\n" . 'French Polynesia' . "\n" . 'French Southern Territories' . "\n" . 'Gabon' . "\n" . 'Gambia' . "\n" . 'Georgia' . "\n" . 'Germany' . "\n" . 'Ghana' . "\n" . 'Gibraltar' . "\n" . 'Great Britain (UK)' . "\n" . 'Greece' . "\n" . 'Greenland' . "\n" . 'Grenada' . "\n" . 'Guadeloupe' . "\n" . 'Guam' . "\n" . 'Guatemala' . "\n" . 'Guinea' . "\n" . 'Guinea-Bissau' . "\n" . 'Guyana' . "\n" . 'Haiti' . "\n" . 'Heard and McDonald Islands' . "\n" . 'Honduras' . "\n" . 'Hong Kong' . "\n" . 'Hungary' . "\n" . 'Iceland' . "\n" . 'India' . "\n" . 'Indonesia' . "\n" . 'Iran' . "\n" . 'Iraq' . "\n" . 'Ireland' . "\n" . 'Israel' . "\n" . 'Italy' . "\n" . 'Jamaica' . "\n" . 'Japan' . "\n" . 'Jordan' . "\n" . 'Kazakhstan' . "\n" . 'Kenya' . "\n" . 'Kiribati' . "\n" . 'Korea, North' . "\n" . 'South Korea' . "\n" . 'Kuwait' . "\n" . 'Kyrgyzstan' . "\n" . 'Laos' . "\n" . 'Latvia' . "\n" . 'Lebanon' . "\n" . 'Lesotho' . "\n" . 'Liberia' . "\n" . 'Libya' . "\n" . 'Liechtenstein' . "\n" . 'Lithuania' . "\n" . 'Luxembourg' . "\n" . 'Macau' . "\n" . 'Macedonia' . "\n" . 'Madagascar' . "\n" . 'Malawi' . "\n" . 'Malaysia' . "\n" . 'Maldives' . "\n" . 'Mali' . "\n" . 'Malta' . "\n" . 'Marshall Islands' . "\n" . 'Martinique' . "\n" . 'Mauritania' . "\n" . 'Mauritius' . "\n" . 'Mayotte' . "\n" . 'Mexico' . "\n" . 'Micronesia' . "\n" . 'Moldova' . "\n" . 'Monaco' . "\n" . 'Mongolia' . "\n" . 'Montserrat' . "\n" . 'Morocco' . "\n" . 'Mozambique' . "\n" . 'Myanmar' . "\n" . 'Namibia' . "\n" . 'Nauru' . "\n" . 'Nepal' . "\n" . 'Netherlands' . "\n" . 'Netherlands Antilles' . "\n" . 'Neutral Zone' . "\n" . 'New Caledonia' . "\n" . 'New Zealand' . "\n" . 'Nicaragua' . "\n" . 'Niger' . "\n" . 'Nigeria' . "\n" . 'Niue' . "\n" . 'Norfolk Island' . "\n" . 'Northern Mariana Islands' . "\n" . 'Norway' . "\n" . 'Oman' . "\n" . 'Pakistan' . "\n" . 'Palau' . "\n" . 'Panama' . "\n" . 'Papua New Guinea' . "\n" . 'Paraguay' . "\n" . 'Peru' . "\n" . 'Philippines' . "\n" . 'Pitcairn' . "\n" . 'Poland' . "\n" . 'Portugal' . "\n" . 'Puerto Rico' . "\n" . 'Qatar' . "\n" . 'Reunion' . "\n" . 'Romania' . "\n" . 'Russian Federation' . "\n" . 'Rwanda' . "\n" . 'Saint Kitts and Nevis' . "\n" . 'Saint Lucia' . "\n" . 'Saint Vincent and the Grenadines' . "\n" . 'Samoa' . "\n" . 'San Marino' . "\n" . 'Sao Tome and Principe' . "\n" . 'Saudi Arabia' . "\n" . 'Senegal' . "\n" . 'Seychelles' . "\n" . 'S. Georgia and S. Sandwich Isls.' . "\n" . 'Sierra Leone' . "\n" . 'Singapore' . "\n" . 'Slovak Republic' . "\n" . 'Slovenia' . "\n" . 'Solomon Islands' . "\n" . 'Somalia' . "\n" . 'South Africa' . "\n" . 'Spain' . "\n" . 'Sri Lanka' . "\n" . 'St. Helena' . "\n" . 'St. Pierre and Miquelon' . "\n" . 'Sudan' . "\n" . 'Suriname' . "\n" . 'Svalbard and Jan Mayen Islands' . "\n" . 'Swaziland' . "\n" . 'Sweden' . "\n" . 'Switzerland' . "\n" . 'Syria' . "\n" . 'Taiwan' . "\n" . 'Tajikistan' . "\n" . 'Tanzania' . "\n" . 'Thailand' . "\n" . 'Togo' . "\n" . 'Tokelau' . "\n" . 'Tonga' . "\n" . 'Trinidad and Tobago' . "\n" . 'Tunisia' . "\n" . 'Turkey' . "\n" . 'Turkmenistan' . "\n" . 'Turks and Caicos Islands' . "\n" . 'Tuvalu' . "\n" . 'Uganda' . "\n" . 'Ukraine' . "\n" . 'United Arab Emirates' . "\n" . 'United Kingdom' . "\n" . 'United States' . "\n" . 'Uruguay' . "\n" . 'US Minor Outlying Islands' . "\n" . 'USSR (former)' . "\n" . 'Uzbekistan' . "\n" . 'Vanuatu' . "\n" . 'Vatican City State (Holy Sea)' . "\n" . 'Venezuela' . "\n" . 'Viet Nam' . "\n" . 'Virgin Islands (British)' . "\n" . 'Virgin Islands (U.S.)' . "\n" . 'Wallis and Futuna Islands' . "\n" . 'Western Sahara' . "\n" . 'Yemen' . "\n" . 'Yugoslavia' . "\n" . 'Zaire' . "\n" . 'Zambia' . "\n" . 'Zimbabwe';
}
$row->store($groupOrdering);
$parent = '';
// Get the view
$view = $this->getView('profiles', 'html');
if ($id != 0) {
$name = '<a href="javascript:void(0);" onclick="azcommunity.editField(\'' . $row->id . '\');">' . $row->name . '</a>';
$type = '<span id="type' . $row->id . '" onclick="$(\'typeOption\').style.display = \'block\';$(this).style.display = \'none\';">' . JString::ucfirst($row->type) . '</span>';
$publish = $view->getPublish($row, 'published', 'profiles,ajaxTogglePublish');
if ($row->type == 'label') {
$required = $view->showPublish($row, 'required');
//$visible = $view->showPublish( $row , 'visible');
$visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish');
} else {
$required = $view->getPublish($row, 'required', 'profiles,ajaxTogglePublish');
$visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish');
}
$registration = $view->getPublish($row, 'registration', 'profiles,ajaxTogglePublish');
// Set the parent id
$parent = $row->id;
$response->addScriptCall('location.reload();');
} else {
$response->addScriptCall('location.reload();');
}
$response->addScriptCall('cWindowHide();');
//.........这里部分代码省略.........
示例5: ajaxSaveSettings
/**
*
*/
public function ajaxSaveSettings($postvars)
{
// Check permissions
$my = CFactory::getUser();
$filter = JFilterInput::getInstance();
$postvars = $filter->clean($postvars, 'array');
if ($my->id == 0) {
return $this->ajaxBlockUnregister();
}
$json = array();
$appsModel = CFactory::getModel('apps');
$appName = $postvars['appname'];
$id = $postvars['appid'];
// @rule: Test if app is core app as we need to add into the db
$pluginId = $appsModel->getPluginId($appName);
$appParam = new CParameter($appsModel->getPluginParams($pluginId));
if ($pluginId && $my->id != 0 && $appParam->get('coreapp')) {
// Add new app in the community plugins table
$appsModel->addApp($my->id, $appName);
// @rule: For core applications, the ID might be referring to Joomla's id. Get the correct id if needed.
$id = $appsModel->getUserApplicationId($appName, $my->id);
}
// Make sure this is valid for current user.
if (!$appsModel->isOwned($my->id, $id)) {
$json['error'] = JText::_('COM_COMMUNITY_PERMISSION_ERROR');
die(json_encode($json));
}
$post = array();
// convert $postvars to normal post
$pattern = "'params\\[(.*?)\\]'s";
for ($i = 0; $i < count($postvars); $i++) {
if (!empty($postvars[$i]) && is_array($postvars[$i])) {
$key = $postvars[$i][0];
// Blogger view
preg_match($pattern, $key, $matches);
if ($matches) {
$key = $matches[1];
}
$post[$key] = $postvars[$i][1];
}
}
//$xmlPath = JPATH_COMPONENT.'/applications/'.$appName.'/'.$appName.'.xml';
$xmlPath = CPluginHelper::getPluginPath('community', $appName) . '/config.xml';
$params = new CParameter($appsModel->getUserAppParams($id), $xmlPath);
$params->bind($post);
//echo $params->toString();
$appsModel->storeParams($id, $params->toString());
$json['success'] = true;
die(json_encode($json));
}
示例6: removeWallActivities
/**
* Remove activities by the given apps and wall id
*
* @param type $option array search criteria.
* @param type $wallId int Wall post id.
* @since 2.4
*
*/
public function removeWallActivities($option, $wallId)
{
// Return all activities by the given apps and specific criteria.
$activitiesModel = CFactory::getModel('activities');
$activities = $activitiesModel->getAppActivities($option);
// Generate target activity id from param's wall id
$activityID = 0;
$params = new CParameter();
foreach ($activities as $objAct) {
$params->bind($objAct->params);
if ($params->get('wallid') == $wallId) {
$activityID = $objAct->id;
break;
}
}
// Remove activity.
if ($activityID > 0) {
$activity = JTable::getInstance('Activity', 'CTable');
$activity->load($activityID);
$activity->delete($option['app']);
}
}