本文整理汇总了PHP中JObject::def方法的典型用法代码示例。如果您正苦于以下问题:PHP JObject::def方法的具体用法?PHP JObject::def怎么用?PHP JObject::def使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JObject
的用法示例。
在下文中一共展示了JObject::def方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSpamCheck
/**
* Does the CleanTalk Magic and Throws error message if message is not allowed
* @param string $context The context of the content being passed to the plugin. Usually component.view (example: com_contactenhanced.contact)
* @param array $data Containing all required data ($sender_email, $sender_nickname,$message)
* @return boolean True if passes validation OR false if it fails
*/
private function onSpamCheck($context = '', $data)
{
// Converts $data Array into an Object
$obj = new JObject($data);
$ver = new JVersion();
if (strcmp($ver->RELEASE, '1.5') <= 0) {
foreach ($data as $k => $v) {
$obj->set($k, $v);
}
} else {
// sets 'sender_email' ONLY if not already set. Also checks to see if 'email' was not provided instead
$obj->def('sender_email', $obj->get('email', null));
// sets 'sender_nickname' ONLY if not already set. Also checks to see if 'name' was not provided instead
$obj->def('sender_nickname', $obj->get('name', null));
// sets 'message' ONLY if not already set. Also checks to see if 'comment' was not provided instead
$obj->def('message', $obj->get('comment', null));
}
$session = JFactory::getSession();
$submit_time = $this->submit_time_test();
$checkjs = $this->get_ct_checkjs(true);
$sender_info = $this->get_sender_info();
$sender_info = json_encode($sender_info);
if ($sender_info === false) {
$sender_info = '';
}
// gets 'comment_type' from $data. If not se it will use 'event_message'
$post_info['comment_type'] = $obj->get('comment_type', 'event_message');
$post_info['post_url'] = $session->get($this->current_page);
$post_info = json_encode($post_info);
if ($post_info === false) {
$post_info = '';
}
self::getCleantalk();
$ctResponse = self::ctSendRequest('check_message', array('message' => $obj->get('message'), 'sender_email' => $obj->get('sender_email'), 'sender_ip' => self::$CT->ct_session_ip($_SERVER['REMOTE_ADDR']), 'sender_nickname' => $obj->get('sender_nickname'), 'js_on' => $checkjs, 'post_info' => $post_info, 'submit_time' => $submit_time, 'sender_info' => $sender_info));
if (!empty($ctResponse['allow']) and $ctResponse['allow'] == 1) {
return true;
} else {
// records error message in dispatcher (and let the event caller handle)
$this->_subject->setError($ctResponse['comment']);
return false;
}
}
示例2: die
<?php
/**
* Zo2 (http://www.zootemplate.com/zo2)
* A powerful Joomla template framework
*
* @link http://www.zootemplate.com/zo2
* @link https://github.com/cleversoft/zo2
* @author ZooTemplate <http://zootemplate.com>
* @copyright Copyright (c) 2014 CleverSoft (http://cleversoft.co/)
* @license GPL v2
*/
defined('_JEXEC') or die('Restricted access');
$name = $this->data['name'];
$dataValue = new JObject($this->data['value']);
$dataValue->def('type', 'none');
$dataValue->def('size', 14);
$dataValue->def('font_line_height', 30);
$fontFamily = new JObject($dataValue->get('family'));
$fontType = $dataValue->get('type');
$noneFont = $fontFamily->get('none');
$standardFont = $fontFamily->get('standard');
$googleFont = $fontFamily->get('googlefonts');
$fontdeckFont = $fontFamily->get('fontdeck');
/**
* List Standard font
*/
$standardFonts = array('Arial' => 'Arial', 'Courier New' => 'Courier New', 'Georgia' => 'Georgia', 'Helvetica' => 'Helvetica', 'Lucida Sans' => 'Lucida Sans', 'Lucida Sans Unicode' => 'Lucida Sans Unicode', 'Myriad Pro' => 'Myriad Pro', 'Palatino Linotype' => 'Palatino Linotype', 'Tahoma' => 'Tahoma', 'Times New Roman' => 'Times New Roman', 'Trebuchet MS' => 'Trebuchet MS', 'Verdana' => 'Verdana');
?>
<div class="zo2-font-container">
<h3><?php
示例3: genMenuItem
function genMenuItem($item, $level = 0, $pos = '')
{
$data = '';
$title = '';
$menu_title = '';
// Print a link if it exists
$active = $this->genClass($item, $level, $pos);
$iParams = new JObject(json_decode($item->params));
if ($iParams->get('showmenutitle', 1)) {
$menu_title .= '<span class="menu-title">' . $item->name . '</span>';
} else {
$menu_title .= '<span class="menu-title"> </span>';
}
if ($iParams->get('desc')) {
$menu_title .= '<span class="menu-desc">' . $iParams->get('desc') . '</span>';
}
//Menu image
if ($this->helix->Param('show_menu_image') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
if ($this->helix->Param('menu_image_position', 1) == '1') {
$txt = '<span class="menu"><img class="menu-image" src="' . JURI::base() . $iParams->get('menu_image') . '" alt=" " />' . $menu_title . '</span>';
} else {
$txt = '<span class="menu"><span class="has-image" style="background-image:url(' . JURI::base() . $iParams->get('menu_image') . ')">' . $menu_title . '</span></span>';
}
} else {
$txt = '<span class="menu">' . $menu_title . '</span>';
}
if ($item->type == 'menulink') {
$menu =& JSite::getMenu();
$alias_item = clone $menu->getItem($item->query['Itemid']);
if (!$alias_item) {
return false;
} else {
$item->url = $alias_item->link;
}
}
//Handle Links
switch ($item->type) {
case 'separator':
$item->url = '#';
break;
case 'url':
if (strpos($item->link, 'index.php?') !== false && strpos($item->link, 'Itemid=') === false) {
$item->url = $item->link . '&Itemid=' . $item->id;
} else {
$item->url = $item->link;
}
break;
case 'alias':
$item->url = 'index.php?Itemid=' . $item->params->get('aliasoptions');
break;
default:
$router = JSite::getRouter();
$item->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $item->id : $item->link . '&Itemid=' . $item->id;
break;
}
if ($item->name) {
if ($item->type == 'separator') {
$data = '<a href="#" ' . $active . '>' . $txt . '</a>';
} else {
if ($item->url != null) {
// Handle SSL links
$iParams = new JObject(json_decode($item->params));
$iSecure = $iParams->def('secure', 0);
if ($item->home == 1) {
$item->url = JURI::base();
} elseif (strcasecmp(substr($item->url, 0, 4), 'http') && strpos($item->link, 'index.php?') !== false) {
$item->url = JRoute::_($item->url, true, $iSecure);
} else {
$item->url = str_replace('&', '&', $item->url);
}
switch ($item->browserNav) {
default:
case 0:
// _top
$data = '<a href="' . $item->url . '" ' . $active . ' ' . $title . '>' . $txt . '</a>';
break;
case 1:
// _blank
$data = '<a href="' . $item->url . '" target="_blank" ' . $active . ' ' . $title . '>' . $txt . '</a>';
break;
case 2:
// window.open
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->helix->Param('window_open');
// hrm...this is a bit dickey
$link = str_replace('index.php', 'index2.php', $item->url);
$data = '<a href="' . $link . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;" ' . $active . ' ' . $title . '>' . $txt . '</a>';
break;
}
} else {
$data = '<a ' . $active . ' ' . $title . '>' . $txt . '</a>';
}
}
}
//Load module or module positions
if ($this->_menu == 'mega') {
//For group
$subcont = $item->megaparams->get('subcontent');
if ($item->megaparams->get('group') && $data) {
$data = "<div class=\"sp-menu-group-title\">{$data}</div>";
if ($subcont == 'modules' || $subcont == 'positions') {
//.........这里部分代码省略.........