本文整理汇总了PHP中JObject类的典型用法代码示例。如果您正苦于以下问题:PHP JObject类的具体用法?PHP JObject怎么用?PHP JObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActions
/**
* Returns a list of the actions that can be performed
*
* @param string $type The type of the content to check
* @param int $id The ID of the content (category or image)
* @return JObject An object holding the results of the check
* @since 2.0
*/
public static function getActions($type = 'component', $id = 0)
{
static $cache = array();
// Create a unique key for the this pair of parameters
$key = $type . ':' . $id;
if (isset($cache[$key])) {
return $cache[$key];
}
$user = JFactory::getUser();
$result = new JObject();
$actions = array('core.admin', 'core.manage', 'joom.upload', 'joom.upload.inown', 'core.create', 'joom.create.inown', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete');
switch ($type) {
case 'category':
$assetName = _JOOM_OPTION . '.category.' . $id;
break;
case 'image':
$assetName = _JOOM_OPTION . '.image.' . $id;
break;
default:
$assetName = _JOOM_OPTION;
break;
}
foreach ($actions as $action) {
$result->set($action, $user->authorise($action, $assetName));
}
// Store the result for better performance
$cache[$key] = $result;
return $result;
}
示例2: display
function display($tpl = null)
{
global $mainframe;
$id = JRequest::getVar('id', 0, '', 'int');
$chemOptions = new JObject();
$chemOptions->set('carbonLabelVisible', JRequest::getVar('carbonLabelVisible', 0, '', 'int'));
$chemOptions->set('cpkColoring', JRequest::getVar('cpkColoring', 1, '', 'int'));
$chemOptions->set('implicitHydrogen', JRequest::getVar('implicitHydrogen', 'TERMINAL_AND_HETERO', '', 'string'));
$chemOptions->set('displayMode', JREquest::getVar('displayMode', 'WIREFRAME', '', 'string'));
$chemOptions->set('bgrcolor', JRequest::getVar('bgrcolor', '#ffffff', '', 'string'));
$chemOptions->set('zoomMode', JRequest::getVar('zoomMode', 'fit', '', 'string'));
$chemOptions->set('width', JRequest::getVar('width', 300, '', 'int'));
$chemOptions->set('height', JRequest::getVar('height', 300, '', 'int'));
$this->setLayout('jsme');
$db =& JFactory::getDBO();
$document =& JFactory::getDocument();
$pathway =& $mainframe->getPathway();
// Adds parameter handling
$params = $mainframe->getParams();
//Set page title information
$menus =& JSite::getMenu();
$menu = $menus->getActive();
// $params->set('page_title','Chem');
$document->setTitle($params->get('page_title'));
$params->def('show_page_title', 1);
//$params->def( 'page_title', 'Chem Title' );
$where = $id !== 0 ? ' where id=' . $id : '';
$query = 'SELECT * ' . ' FROM #__chem a' . $where;
$db->setQuery($query);
$chem = $db->loadObjectList();
$this->assignRef('request', $chem);
$this->assignRef('params', $params);
$this->assignRef('chemoptions', $chemOptions);
parent::display($tpl);
}
示例3: addTag
function addTag()
{
$mainframe =& JFactory::getApplication();
$tag = JRequest::getString('tag');
$tag = str_replace('-', '', $tag);
$response = new JObject();
$response->set('name', $tag);
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'JSON.php';
$json = new Services_JSON();
if (empty($tag)) {
$response->set('msg', JText::_('You need to enter a tag!', true));
echo $json->encode($response);
$mainframe->close();
}
$db =& JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__k2_tags WHERE name=" . $db->Quote($tag);
$db->setQuery($query);
$result = $db->loadResult();
if ($result > 0) {
$response->set('msg', JText::_('Tag already exists!', true));
echo $json->encode($response);
$mainframe->close();
}
$row =& JTable::getInstance('K2Tag', 'Table');
$row->name = $tag;
$row->published = 1;
$row->store();
$cache =& JFactory::getCache('com_k2');
$cache->clean();
$response->set('id', $row->id);
$response->set('status', 'success');
$response->set('msg', JText::_('Tag added to available tags list!', true));
echo $json->encode($response);
$mainframe->close();
}
示例4: getActions
/**
* Gets a list of the actions that can be performed.
*
* @param integer The category ID.
*
* @return JObject
* @since 1.6
*/
public static function getActions($categoryId = 0)
{
$user = JFactory::getUser();
$result = new JObject;
if (empty($categoryId))
{
$assetName = 'com_mvceditor';
$level = 'component';
}
else
{
$assetName = 'com_mvceditor.category.'.(int) $categoryId;
$level = 'category';
}
$actions = JAccess::getActions('com_mvceditor', $level);
foreach ($actions as $action)
{
$result->set($action->name, $user->authorise($action->name, $assetName));
}
return $result;
}
示例5: test__construct
/**
* @todo Implement test__toString().
*/
public function test__construct() {
$this->object = new JObject(array('property1' => 'value1', 'property2' => 5));
$this->assertThat(
$this->object->get('property1'),
$this->equalTo('value1')
);
}
示例6: _loadSettings
/**
* Returns a singleton with all settings
*
* @return JObject - loads a singleton object with all settings
*/
private static function _loadSettings()
{
$db = JFactory::getDBO();
$settings = new JObject();
$query = ' SELECT st.title, st.value' . ' FROM #__matukio_settings AS st' . ' ORDER BY st.id';
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ($data as $value) {
$settings->set($value->title, $value->value);
}
// Grab the settings from the menu and merge them in the object
$app = JFactory::getApplication();
$menu = $app->getMenu();
if (is_object($menu)) {
if ($item = $menu->getActive()) {
$menuParams = $menu->getParams($item->id);
foreach ($menuParams->toArray() as $key => $value) {
if ($key == 'show_page_heading') {
$key = 'show_page_title';
}
$settings->set($key, $value);
}
}
}
return $settings;
}
示例7: _loadData
function _loadData()
{
global $mainframe;
// Lets load the content if it doesn't already exist
if (empty($this->_data)) {
// Lets load the content if it doesn't already exist
if (empty($this->_data)) {
$query = 'SELECT p.filename as filename' . ' FROM #__phocagallery AS p' . ' WHERE p.id = ' . (int) $this->_id;
$this->_db->setQuery($query);
$filename_object = $this->_db->loadObject();
//Get Folder settings and File resize settings
$path = PhocaGalleryHelper::getPathSet();
$file = new JObject();
//Create thumbnail if it doesn't exists but originalfile must exist
$orig_path = $path['orig_abs_ds'];
$refresh_url = 'index.php?option=com_phocagallery&view=phocagalleryd&tmpl=component&cid[]=' . $this->_id;
//Creata thumbnails if not exist
PhocaGalleryHelper::getOrCreateThumbnail($orig_path, $filename_object->filename, $refresh_url, 1, 1, 1);
jimport('joomla.filesystem.file');
if (!isset($filename_object->filename)) {
$file->set('linkthumbnailpath', '');
} else {
$thumbnail_file = PhocaGalleryHelper::getThumbnailName($filename_object->filename, 'large');
$file->set('linkthumbnailpath', $thumbnail_file['rel']);
}
}
if (isset($file)) {
$this->_data = $file;
} else {
$this->_data = '';
}
return (bool) $this->_data;
}
return true;
}
示例8: getActions
/**
* Gets a list of the actions that can be performed.
*
* @param int The category ID.
*
* @return JObject
*/
public static function getActions()
{
$user = JFactory::getUser();
$result = new JObject();
$result->set('core.admin', $user->authorise('core.admin', 'com_favicon'));
return $result;
}
示例9: getActions
/**
* Получаем доступы для действий.
*
* @param int $categoryId Id категории.
* @param int $messageId Id сообщения.
*
* @return object
*/
public static function getActions($categoryId = 0, $messageId = 0)
{
// Определяем имя ассета (ресурса).
if (empty($messageId) && empty($categoryId)) {
$assetName = 'com_helloworld';
$section = 'component';
} elseif (empty($messageId)) {
$assetName = 'com_helloworld.category.' . (int) $categoryId;
$section = 'category';
} else {
$assetName = 'com_helloworld.message.' . (int) $messageId;
$section = 'message';
}
if (empty(self::$actions)) {
// Получаем список доступных действий для компонента.
$accessFile = JPATH_ADMINISTRATOR . '/components/com_helloworld/access.xml';
$actions = JAccess::getActionsFromFile($accessFile, "/access/section[@name='" . $section . "']/");
// Для сообщения и категорий добавляем действие core.admin.
if ($section == 'category' || $section == 'message') {
$adminAction = new stdClass();
$adminAction->name = 'core.admin';
array_push($actions, $adminAction);
}
self::$actions = new JObject();
foreach ($actions as $action) {
// Устанавливаем доступы пользователя для действий.
self::$actions->set($action->name, JFactory::getUser()->authorise($action->name, $assetName));
}
}
return self::$actions;
}
示例10: onDisplay
function onDisplay($name)
{
$application = JFactory::getApplication();
$my_first_daughters_name = "Anna";
$user =& JFactory::getUser();
$prefix = '';
if ($application->isAdmin()) {
$prefix = '../';
}
// needed because of user friendly urls!! Relative urls for the css does not work then.
$relative_dir = parse_url(JURI::base());
$relative_dir = $relative_dir['path'];
$relative_dir = rtrim($relative_dir,"\\/.") . '/'; // we replace to get a consistent output with different php versions!
$css = ".button2-left .jfuButton {
background: transparent url(".$relative_dir.$prefix."plugins/editors-xtd/jfuploader_editor/jfuploader_editor.png) no-repeat 100% 0px;
}";
// we need to use the right part to get the right user!!
if ($application->isAdmin()) {
// front and admin do not have the sames session. I have to create a secret token to check that the request is not modified
$jConfig = new JConfig();
$secret = $jConfig->secret;
$ts =time();
$token = md5($user->username . $my_first_daughters_name . $secret . $ts);
$stub = $prefix. "index.php";
$link = $stub . '?option=com_jfuploader&tmpl=component&type=jfuploader_editor&e_name='.$name .'&ts='.$ts.'&myid=' . $user->username . '&mytoken=' . $token;
} else {
$stub = "index.php";
$link = $prefix.$stub . '?option=com_jfuploader&tmpl=component&type=jfuploader_editor&e_name='.$name;
}
$popup_width = 680;
$popup_height = 520;
if(@$this->params){
if(@$this->params->get('popup_width') > 0){
$popup_width = (int)@$this->params->get('popup_width');
}
if(@$this->params->get('popup_height') > 0){
$popup_height = (int)@$this->params->get('popup_height');
}
}
$doc = & JFactory::getDocument();
if ($application->isAdmin()) {
$doc->addStyleDeclaration($css);
}
$button = new JObject();
$button->set('modal', true);
$button->set('text', JText::_('JFUploader'));
$button->set('name', 'jfuButton');
$button->set('options', "{handler: 'iframe',size: {x: $popup_width, y: $popup_height}}");
$button->set('link', $link);
return $button;
}
示例11: getTitle
/**
* Get the alternate title for the module
*
* @param JObject $params The module parameters.
* @param JObject $module The module.
*
* @return string The alternate title for the module.
*/
public static function getTitle($params, $module)
{
$key = $params->get('context', 'mod_quickicon') . '_title';
if (JFactory::getLanguage()->hasKey($key)) {
return JText::_($key);
} else {
return $module->title;
}
}
示例12: readXML
public static function readXML($params)
{
$temppath = JPATH_BASE . DS . "cache/mod_bps_kiyoh/";
if (!is_dir($temppath)) {
mkdir($temppath);
}
$xmlUrl = $params->get('xmlUrl', '');
$cacheTime = (int) $params->get('cacheTime', 480) * 60;
$filename = md5($xmlUrl . $params->toString());
$tempfile = $temppath . $filename;
if (file_exists($tempfile)) {
$mtime = filemtime($tempfile);
if (time() - $mtime < $cacheTime) {
$aXmlData = unserialize(file_get_contents($tempfile));
return $aXmlData;
}
}
if (!($oXml = simplexml_load_file($xmlUrl))) {
echo 'Geen xml geladen';
return false;
}
$oXmlInfo = new JObject();
$oXmlInfo->set('naam', (string) $oXml->company->name);
$oXmlInfo->set('kiyohLink', (string) $oXml->company->url);
$oXmlInfo->set('total_score', (double) $oXml->company->total_score);
$oXmlInfo->set('total_reviews', (int) $oXml->company->total_reviews);
$oXmlInfo->set('total_views', (int) $oXml->company->total_views);
$aReviews = array();
$iReviewCount = 0;
foreach ($oXml->review_list->review as $oReview) {
$oReviewInfo = new JObject();
$oReviewInfo->set('naam', (string) $oReview->customer->name);
$oReviewInfo->set('place', (string) $oReview->customer->place);
$oReviewInfo->set('date', JHtml::_('date', (string) $oReview->customer->date, '%d %b'));
$oReviewInfo->set('dateRaw', JHtml::_('date', (string) $oReview->customer->date, '%Y-%m-%d'));
$oReviewInfo->set('total_score', (int) $oReview->total_score);
$oReviewInfo->set('recommendation', (string) $oReview->recommendation);
$oReviewInfo->set('positive', (string) $oReview->positive);
$oReviewInfo->set('negative', (string) $oReview->negative);
$iReviewCount++;
if ($params->get('reviewOnly', false) && ($oReviewInfo->positive == '' && $oReviewInfo->negative == '')) {
continue;
}
$aReviews[] = $oReviewInfo->getProperties();
}
$oXmlInfo->set('reviewCount', $iReviewCount);
$oXmlInfo->set('aReviews', $aReviews);
$aXmlData = $oXmlInfo->getProperties();
//in file zetten
$file = fopen($tempfile, 'w');
fwrite($file, serialize($aXmlData));
fclose($file);
// print_r_pre($aXmlData);
// print_r_pre($oXml->review_list);
return $aXmlData;
}
示例13: onDisplay
/**
* Add Attachment button
*
* @return a button
*/
function onDisplay($name, $asset, $author)
{
// Avoid displaying the button for anything except content articles
$option = JRequest::getVar('option');
if ($option != 'com_content') {
return new JObject();
}
// Get the article ID
$cid = JRequest::getVar('cid', array(0), '', 'array');
$id = 0;
if (count($cid) > 0) {
$id = intval($cid[0]);
}
if ($id == 0) {
$nid = JRequest::getVar('id', null);
if (!is_null($nid)) {
$id = intval($nid);
}
}
JHtml::_('behavior.modal');
// Create the button object
$button = new JObject();
// Figure out where we are and construct the right link and set
// up the style sheet (to get the visual for the button working)
$document =& JFactory::getDocument();
$app = JFactory::getApplication();
if ($app->isAdmin()) {
$document->addStyleSheet(JURI::root() . '/media/com_cedtag/css/admintag.css');
if ($id == 0) {
$button->set('options', "{handler: 'iframe', size: {x: 400, y: 300}}");
$link = "index.php?option=com_cedtag&controller=tag&task=warning&tmpl=component&tagsWarning=FIRST_SAVE_WARNING";
} else {
$button->set('options', "{handler: 'iframe', size: {x: 600, y: 300}}");
$link = "index.php?option=com_cedtag&controller=tag&task=add&article_id=" . $id . "&tmpl=component";
}
} else {
$CedTagThemes = new CedTagThemes();
$CedTagThemes->addCss();
//return $button;
if ($id == 0) {
$button->set('options', "{handler: 'iframe', size: {x: 400, y: 300}}");
$msg = JText::_('SAVE ARTICLE BEFORE ADD TAGS');
$link = "index.php?option=com_cedtag&task=warning&tmpl=component&tagsWarning=FIRST_SAVE_WARNING";
} else {
$button->set('options', "{handler: 'iframe', size: {x: 500, y: 300}}");
$link = "index.php?option=com_cedtag&tmpl=component&task=add&article_id=" . $id;
}
}
$button->set('modal', true);
$button->set('class', 'modal');
$button->set('text', JText::_('Add Tags'));
$button->set('name', 'add_Tags');
$button->set('link', $link);
//$button->set('image', '');
return $button;
}
示例14: display
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$user = JFactory::getUser();
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->modules = $this->get('Modules');
$this->levels = $this->get('ViewLevels');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));
// Check if we're allowed to edit this item
// No need to check for create, because then the moduletype select is empty
if (!empty($this->item->id) && !$this->canDo->get('core.edit')) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
parent::display($tpl);
$this->addToolbar();
}
示例15: getState
/**
* Get property state value escaped.
*
* @param string $name property name
* @return mized
*/
public function getState($name)
{
if (isset($this->state)) {
return $this->escape($this->state->get($this->getStateName($name)));
}
return null;
}