本文整理汇总了PHP中DSC::getApp方法的典型用法代码示例。如果您正苦于以下问题:PHP DSC::getApp方法的具体用法?PHP DSC::getApp怎么用?PHP DSC::getApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DSC
的用法示例。
在下文中一共展示了DSC::getApp方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItems
/**
*
*/
public static function getItems($option = '')
{
static $items;
if (empty($option)) {
$com = DSC::getApp();
$option = 'com_' . $com->getName();
}
$app = JApplication::getInstance('site');
$menus = $app->getMenu();
if (empty($menus)) {
return array();
}
if (empty($items)) {
$items = array();
}
if (empty($items[$option])) {
$component = JComponentHelper::getComponent($option);
foreach ($menus->getItems('component', $option) as $item) {
if (!is_object($item)) {
continue;
}
if ($item->component_id == $component->id || $item->componentid == $component->id || !empty($item->query['option']) && $item->query['option'] == $option) {
$items[$option][] = $item;
}
}
}
if (empty($items[$option])) {
return array();
}
return $items[$option];
}
示例2: footer
/**
* Displays the footer
*
* @return unknown_type
*/
function footer()
{
// show a generous linkback, TIA
$app = DSC::getApp();
$input = JFactory::getApplication()->input;
$show_linkback = $app->get('show_linkback', '1');
$name = $app->getName();
$model_name = $name . "ModelDashboard";
$app->load($model_name, "models.dashboard");
$model = new $model_name();
$format = $input->getString('format');
if ($show_linkback == '1' && $format != 'raw') {
$view = $this->getView('dashboard', 'html');
$view->hidemenu = true;
$view->setTask('footer');
$view->setModel($model, true);
$view->setLayout('footer');
$view->assign('style', '');
$view->display();
} elseif ($format != 'raw') {
$view = $this->getView('dashboard', 'html');
$view->hidemenu = true;
$view->setTask('footer');
$view->setModel($model, true);
$view->setLayout('footer');
$view->assign('style', 'style="display: none;"');
$view->display();
}
return;
}
示例3: __construct
function __construct($config = array())
{
$input = JFactory::getApplication()->input;
$app = DSC::getApp();
$this->_option = !empty($app) ? 'com_' . $app->getName() : $input->get('option');
parent::__construct($config);
}
示例4: displayTitle
/**
* Displays text as the title of the page
*
* @param $text
* @return unknown_type
*/
public function displayTitle($text = '')
{
$input = JFactory::getApplication()->input;
$layout = $this->getLayout();
switch (strtolower($layout)) {
case "footer":
break;
case "default":
default:
$app = DSC::getApp();
$title = $text ? JText::_($text) : JText::_(ucfirst($input->getString('view')));
JToolBarHelper::title($title, $app->getName());
break;
}
}
示例5: display
/**
* First displays the submenu, then displays the output
* but only if a valid _doTask is set in the view object
*
* @param $tpl
* @return unknown_type
*/
public function display($tpl = null)
{
// display() will return null if 'doTask' is not set by the controller
// This prevents unauthorized access by bypassing the controllers
if (empty($this->_doTask)) {
return null;
}
$this->getLayoutVars($tpl);
if (!JRequest::getInt('hidemainmenu') && empty($this->hidemenu)) {
$this->displaySubmenu();
}
$app = DSC::getApp();
$config = $app::getInstance();
if ($config->get('include_site_css', '1')) {
JHTML::_('stylesheet', 'site.css', 'media/' . $this->_option . '/css/');
}
parent::display($tpl);
}
示例6: __construct
/**
* constructor
*/
function __construct($config = array())
{
parent::__construct($config);
$input = JFactory::getApplication()->input;
$com = $input->get('option');
//$com = JRequest::get('option');
if (!empty($config['com'])) {
$com = $config['com'];
}
//do we really need to get the whole app to get the name or should we strip it from the option??
$app = DSC::getApp();
$this->_name = $app->getName();
$this->_Pluginname = ucfirst($this->_name);
$this->set('com', $com);
$this->set('suffix', $this->get('default_view'));
$this->list_url = "index.php?option=" . $this->get('com') . "&view=" . $this->get('suffix');
// Register Extra tasks
$this->registerTask('list', 'display');
$this->registerTask('close', 'cancel');
}
示例7: getAvatar
/**
*
* Get Avatar based on the installed community component
* @param int $id - userid
* @return object
*/
function getAvatar($id)
{
$avatar = '';
$found = false;
Citruscart::load('CitruscartHelperAmbra', 'helpers.ambra');
$helper_ambra = CitruscartHelperBase::getInstance('Ambra');
//check if ambra installed
if ($helper_ambra->isInstalled() && !$found) {
if (!class_exists('Ambra')) {
JLoader::register("Ambra", JPATH_ADMINISTRATOR . "/components/com_ambra/defines.php");
}
//Get Ambra Avatar
if ($image = Ambra::getClass("AmbraHelperUser", 'helpers.user')->getAvatar($id)) {
$link = JRoute::_(JURI::root() . 'index.php?option=com_ambra&view=users&id=' . $id, false);
$avatar .= "<a href='{$link}' target='_blank'>";
$avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />";
$avatar .= "</a>";
}
$found = true;
}
//check if jomsocial installed
if (DSC::getApp()->isComponentInstalled('com_community') && !$found) {
//Get JomSocial Avatar
$database = JFactory::getDBO();
$query = "\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\t#__community_users\r\n\t\t\tWHERE\r\n\t\t\t\t`userid` = '" . $id . "'\r\n\t\t\t";
$database->setQuery($query);
$result = $database->loadObject();
if (isset($result->thumb)) {
$image = JURI::root() . $result->thumb;
}
$link = JRoute::_(JURI::root() . 'index.php?option=com_community&view=profile&userid=' . $id, false);
$avatar .= "<a href='{$link}' target='_blank'>";
$avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />";
$avatar .= "</a>";
$found = true;
}
//check if community builder is installed
if (DSC::getApp()->isComponentInstalled('com_comprofiler') && !$found) {
//Get JomSocial Avatar
$database = JFactory::getDBO();
$query = "\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\t#__comprofiler\r\n\t\t\tWHERE\r\n\t\t\t\t`id` = '" . $id . "'\r\n\t\t\t";
$database->setQuery($query);
$result = $database->loadObject();
if (isset($result->avatar)) {
$image = JURI::root() . 'images/comprofiler/' . $result->avatar;
} else {
$image = JRoute::_(JURI::root() . 'components/com_comprofiler/plugin/templates/default/images/avatar/nophoto_n.png');
}
$link = JRoute::_(JURI::root() . 'index.php?option=com_comprofiler&userid=' . $id, false);
$avatar .= "<a href='{$link}' target='_blank'>";
$avatar .= "<img src='{$image}' style='max-width:80px; border:1px solid #ccccce;' />";
$avatar .= "</a>";
$found = true;
}
return $avatar;
}
示例8: _
/**
* Format and convert a number according to currency rules
*
* @param unknown_type $amount
* @param unknown_type $currency
* @return unknown_type
*/
public static function _($amount, $currency = '', $options = '')
{
// default to whatever is in config
$config = DSC::getApp();
$options = (array) $options;
$default_currencyid = $config->get('default_currencyid', '1');
$num_decimals = isset($options['num_decimals']) ? $options['num_decimals'] : $config->get('currency_num_decimals', '2');
$thousands = isset($options['thousands']) ? $options['thousands'] : $config->get('currency_thousands', ',');
$decimal = isset($options['decimal']) ? $options['decimal'] : $config->get('currency_decimal', '.');
$pre = isset($options['pre']) ? $options['pre'] : $config->get('currency_symbol_pre', '$');
$post = isset($options['post']) ? $options['post'] : $config->get('currency_symbol_post', '');
// Now check the session variable to see if there is a currency setting there
$session_currency = DSCHelper::getSessionVariable('currency_id', 0);
if ($session_currency) {
// Let the code below deal with currency loading
$currency = $session_currency;
}
// if currency is an object, use it's properties
if (is_object($currency)) {
$table = $currency;
$num_decimals = $table->currency_decimals;
$thousands = $table->thousands_separator;
$decimal = $table->decimal_separator;
$pre = $table->symbol_left;
$post = $table->symbol_right;
if ($default_currencyid != $table->currency_id) {
$convertTo = $table->currency_code;
}
} elseif (!empty($currency) && is_numeric($currency)) {
// TODO if currency is an integer, load the object for its id
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sample' . DS . 'tables');
$table = JTable::getInstance('Currencies', 'DSCTable');
$table->load((int) $currency);
if (!empty($table->currency_id)) {
$num_decimals = $table->currency_decimals;
$thousands = $table->thousands_separator;
$decimal = $table->decimal_separator;
$pre = $table->symbol_left;
$post = $table->symbol_right;
if ($default_currencyid != $currency) {
$convertTo = $table->currency_code;
}
}
} elseif (!empty($currency)) {
// TODO if currency is a string (currency_code) load the object for its code
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sample' . DS . 'tables');
$table = JTable::getInstance('Currencies', 'DSCTable');
$keynames = array();
$keynames['currency_code'] = (string) $currency;
$table->load($keynames);
if (!empty($table->currency_id)) {
$num_decimals = $table->currency_decimals;
$thousands = $table->thousands_separator;
$decimal = $table->decimal_separator;
$pre = $table->symbol_left;
$post = $table->symbol_right;
if ($default_currencyid != $table->currency_id) {
$convertTo = $table->currency_code;
}
}
}
// if the currency code we're using is diff from the store-wide currency, then we need to convert the amount
if (!empty($convertTo)) {
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sample' . DS . 'tables');
$table = JTable::getInstance('Currencies', 'DSCTable');
$table->load((int) $default_currencyid);
DSC::load('DSCHelperCurrency', 'helpers.currency');
$amount = DSCHelperCurrency::convert($table->currency_code, $convertTo, $amount);
}
$return = $pre . number_format($amount, $num_decimals, $decimal, $thousands) . $post;
return $return;
}
示例9: pagetooltip
public static function pagetooltip($key, $title = 'Tip', $id = 'page_tooltip', $app = null)
{
$input = JFactory::getApplication()->input;
$href = '';
$constant = 'page_tooltip_' . $key;
$app = $input->get('option');
$defines = DSC::getApp($app);
$disabled = $defines->get($constant . "_disabled", '0');
$full_constant = strtoupper($app . "_" . $constant);
$lang = JFactory::getLanguage();
if ($lang->hasKey($full_constant) && !$disabled) {
$option = strtolower($app);
$view = strtolower($input->getString('view'));
$task = "page_tooltip_disable";
$url = JRoute::_("index.php?option={$option}&controller={$view}&view={$view}&task={$task}&key={$key}");
$link = "<a href='{$url}'>" . JText::_("Hide This") . "</a>";
$href = '
<fieldset class="' . $id . '">
<legend class="' . $id . '">' . JText::_($title) . '</legend>
' . JText::_($full_constant) . '
<span class="' . $id . '" style="float: right;">' . $link . '</span>
</fieldset>
';
}
return $href;
}
示例10: _getLayout
/**
* Gets the parsed layout file
*
* @param string $layout The name of the layout file
* @param object $vars Variables to assign to
* @param string $plugin The name of the plugin
* @param string $group The plugin's group
* @return string
* @access protected
*/
protected function _getLayout($layout, $vars = false, $plugin = '', $group = '')
{
if (empty($group)) {
$app = DSC::getApp();
$com_name = $app->getName();
$group = str_replace('com_', '', $com_name);
if (empty($group)) {
// TODO Try to get it some other way, such as from the name of the plugin?
return null;
}
}
if (empty($plugin)) {
$plugin = $this->_element;
}
ob_start();
$layout = $this->_getLayoutPath($plugin, $group, $layout);
include $layout;
$html = ob_get_contents();
ob_end_clean();
return $html;
}
示例11: display
/**
* Displays the menu according to view.
*
* @return unknown_type
*/
public function display($layout = 'submenu', $hidemainmenu = '', $type = '')
{
$input = JFactory::getApplication()->input;
jimport('joomla.application.component.view');
// TODO This should be passed as an argument
$hide = $input->getInt('hidemainmenu');
if (version_compare(JVERSION, '1.6.0', 'ge')) {
// Joomla! 1.6+ code here
$items = $this->_menu->getItems();
$name = $this->_name;
} else {
// Joomla! 1.5 code here
$items = $this->_menu->_bar;
$name = $this->_name;
}
// Load the named template, if there are links to display.
if (!empty($items)) {
$base = JFactory::getApplication()->isAdmin() ? JPATH_ADMINISTRATOR : JPATH_SITE;
$app = DSC::getApp();
$template = JFactory::getApplication()->getTemplate();
$lib_path = JPATH_SITE . '/libraries/dioscouri/component/view/dashboard';
$com_template_path = $base . '/components/com_' . $app->getName() . '/views/dashboard/tmpl';
$template_path = $base . '/templates/' . $template . '/html/com_' . $app->getName() . '/dashboard';
$view = new DSCViewBase(array('name' => 'dashboard', 'template_path' => $lib_path));
$view->set('items', $items);
$view->set('name', $name);
$view->set('layout', $layout);
$view->set('hide', $hide);
$view->setLayout($layout);
$view->addTemplatePath($com_template_path);
$view->addTemplatePath($template_path);
$view->display();
}
}
示例12: number
/**
* Nicely format a number
*
* @param $number
* @return unknown_type
*/
public static function number($number, $options = '')
{
$config = DSC::getApp();
$options = (array) $options;
$thousands = isset($options['thousands']) ? $options['thousands'] : $config->get('number_thousands', ',');
$decimal = isset($options['decimal']) ? $options['decimal'] : $config->get('number_decimal', '.');
$num_decimals = isset($options['num_decimals']) ? $options['num_decimals'] : $config->get('number_num_decimals', '0');
$return = number_format($number, $num_decimals, $decimal, $thousands);
return $return;
}
示例13: sendMail
/**
* Returns yes/no
* @param object
* @param mixed Boolean
* @return array
*/
private static function sendMail(&$user, $details, $useractivation, $guest = false)
{
$com = DSC::getApp();
$com_name = strtoupper('com_' . $com->getName());
$lang = JFactory::getLanguage();
$lang->load('lib_dioscouri', JPATH_ADMINISTRATOR);
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$name = $user->get('name');
$email = $user->get('email');
$username = $user->get('username');
$activation = $user->get('activation');
$password = $details['password2'];
// using the original generated pword for the email
$usersConfig = JComponentHelper::getParams('com_users');
// $useractivation = $usersConfig->get( 'useractivation' );
$sitename = $mainframe->getCfg('sitename');
$mailfrom = $mainframe->getCfg('mailfrom');
$fromname = $mainframe->getCfg('fromname');
$siteURL = JURI::base();
$subject = sprintf(JText::_($com_name . '_ACCOUNT_DETAILS_FOR'), $name, $sitename);
$subject = html_entity_decode($subject, ENT_QUOTES);
if ($useractivation == 1) {
$message = sprintf(JText::_($com_name . '_EMAIL_MESSAGE_ACTIVATION'), $sitename, $siteURL, $username, $password, $activation);
} else {
$message = sprintf(JText::_($com_name . '_EMAIL_MESSAGE'), $sitename, $siteURL, $username, $password);
}
if ($guest) {
$message = sprintf(JText::_($com_name . '_EMAIL_MESSAGE_GUEST'), $sitename, $siteURL, $username, $password);
}
$message = html_entity_decode($message, ENT_QUOTES);
//get all super administrator
$query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"';
$db->setQuery($query);
$rows = $db->loadObjectList();
// Send email to user
if (!$mailfrom || !$fromname) {
$fromname = $rows[0]->name;
$mailfrom = $rows[0]->email;
}
$success = self::doMail($mailfrom, $fromname, $email, $subject, $message);
return $success;
}
示例14: handleMultipleUpload
/**
* Returns
* @param mixed Boolean
* @param mixed Boolean
* @return object
*/
function handleMultipleUpload($fieldname = 'userfile', $num = 0)
{
$input = JFactory::getApplication()->input;
$success = false;
$config = DSC::getApp();
// Check if file uploads are enabled
if (!(bool) ini_get('file_uploads')) {
$this->setError(JText::_('Uploads Disabled'));
return $success;
}
// Check that the zlib is available
if (!extension_loaded('zlib')) {
$this->setError(JText::_('ZLib Unavailable'));
return $success;
}
// check that upload exists
$userfile = $input->file->getArray($fieldname, '', 'files', 'array');
if (!$userfile) {
$this->setError(JText::_('No File'));
return $success;
}
//$this->proper_name = basename($userfile['name'][$num]);
$userFileName = basename($userfile['name'][$num]);
$this->proper_name = $this->getProperName($userFileName);
if ($userfile['size'][$num] == 0) {
$this->setError(JText::_('Invalid File'));
return $success;
}
$this->size = $userfile['size'][$num] / 1024;
// check size of upload against max set in config
if ($this->size > $config->get('files_maxsize', '10000')) {
$this->setError(JText::_('Invalid File Size'));
return $success;
}
$this->size = number_format($this->size, 2) . ' Kb';
if (!is_uploaded_file($userfile['tmp_name'][$num])) {
$this->setError(JText::_('Invalid File'));
return $success;
} else {
$this->file_path = $userfile['tmp_name'][$num];
}
$this->getExtension();
$this->uploaded = true;
$success = true;
return $success;
}