本文整理汇总了PHP中Jaws_Gadget::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Gadget::getInstance方法的具体用法?PHP Jaws_Gadget::getInstance怎么用?PHP Jaws_Gadget::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Gadget
的用法示例。
在下文中一共展示了Jaws_Gadget::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SiteActivity
/**
* Send data to parent site
*
* @access public
* @return boolean
*/
function SiteActivity()
{
// Load the template
$tpl = $this->gadget->template->load('SiteActivity.html');
$tpl->SetBlock('SiteActivity');
$tpl->SetVariable('title', _t('SITEACTIVITY_ACTIONS_SITEACTIVITY'));
$this->SetTitle(_t('SITEACTIVITY_ACTIONS_SITEACTIVITY'));
$model = $this->gadget->model->load('SiteActivity');
$filters = array();
$today = getdate();
$todayTime = mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);
$filters['domain'] = '-1';
// fetch just own domain data
$filters['from_date'] = $todayTime;
// fetch today data
$activities = $model->GetSiteActivities($filters);
if (!Jaws_Error::isError($activities) && !empty($activities)) {
$gadgetsActivities = array();
$gadget = '';
foreach ($activities as $activity) {
if ($activity['gadget'] != $gadget) {
$gadget = $activity['gadget'];
}
$gadgetsActivities[$gadget][$activity['action']] = $activity['hits'];
}
}
$saGadgets = $model->GetSiteActivityGadgets();
if (count($saGadgets) > 0) {
foreach ($saGadgets as $gadget => $gTitle) {
// load gadget
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
continue;
}
// load hook
$objHook = $objGadget->hook->load('SiteActivity');
if (Jaws_Error::IsError($objHook)) {
continue;
}
// fetch gadget activity's action items
$actions = $objHook->Execute();
$tpl->SetBlock('SiteActivity/gadget');
$tpl->SetVariable('gadget_title', $objGadget->title);
foreach ($actions as $actionName => $actionTitle) {
$tpl->SetBlock('SiteActivity/gadget/action');
$tpl->SetVariable('action', $actionTitle);
$hits = isset($gadgetsActivities[$gadget][$actionName]) ? $gadgetsActivities[$gadget][$actionName] : 0;
$tpl->SetVariable('hits', $hits);
$tpl->ParseBlock('SiteActivity/gadget/action');
}
$tpl->ParseBlock('SiteActivity/gadget');
}
} else {
$tpl->SetBlock('SiteActivity/no_activity');
$tpl->SetVariable('no_activity', _t('SITEACTIVITY_ACTIONS_NOT_FIND_ACTIVITY'));
$tpl->ParseBlock('SiteActivity/no_activity');
}
$tpl->ParseBlock('SiteActivity');
return $tpl->Get();
}
示例2: GetPage
/**
* Gets a single page
*
* @access public
* @param mixed $id ID or fast_url of the page (int/string)
* @param string $language Page language
* @return mixed Array of the page information or Jaws_Error on failure
*/
function GetPage($id, $language = '')
{
$spTable = Jaws_ORM::getInstance()->table('static_pages as sp');
$spTable->select('sp.page_id:integer', 'sp.group_id:integer', 'spt.translation_id:integer', 'spt.language', 'spt.title', 'sp.fast_url', 'spt.published:boolean', 'sp.show_title:boolean', 'spt.content', 'spt.user:integer', 'spt.meta_keywords', 'spt.meta_description', 'spt.updated');
$spTable->join('static_pages_translation as spt', 'sp.page_id', 'spt.base_id');
if (empty($language)) {
$spTable->where('spt.language', array('sp.base_language', 'expr'));
} else {
$spTable->where('spt.language', $language);
}
if (is_numeric($id)) {
$spTable->and()->where('sp.page_id', $id);
} else {
$spTable->and()->where('sp.fast_url', $id);
}
$page = $spTable->fetchRow();
if (!empty($page)) {
$page['tags'] = '';
if (Jaws_Gadget::IsGadgetInstalled('Tags')) {
$model = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags');
$tags = $model->GetReferenceTags('StaticPage', 'page', $page['translation_id']);
$page['tags'] = implode(',', array_filter($tags));
}
}
return $page;
}
示例3: Shout
/**
* Shouts a call to the listener object that will act immediately.
*
* @access public
* @param string $shouter Shouter class|gadget name
* @param string $event Event name
* @param mixed $params Event param(s)
* @param string $gadget If set, returns listener result of this gadget
* @param bool $broadcast Broadcast event to all listeners
* @return mixed True if successfully, otherwise returns Jaws_Error
*/
function Shout($shouter, $event, $params = array(), $gadget = '', $broadcast = true)
{
$listeners = $this->GetEventListeners($event);
if (Jaws_Error::IsError($listeners)) {
return $listeners;
}
$result = null;
foreach ($listeners as $listener) {
// check event broadcasting
if (!$broadcast && $listener['gadget'] !== $gadget) {
continue;
}
if (Jaws_Gadget::IsGadgetInstalled($listener['gadget'])) {
$objGadget = Jaws_Gadget::getInstance($listener['gadget']);
if (Jaws_Error::IsError($objGadget)) {
continue;
}
$objEvent = $objGadget->event->load($event);
if (Jaws_Error::IsError($objEvent)) {
continue;
}
$response = $objEvent->Execute($shouter, $params);
// return listener result
if ($gadget == $listener['gadget']) {
$result = $response;
}
}
}
return $result;
}
示例4: LoginHistory
/**
*
* @access public
* @return string HTML content with menu and menu items
*/
function LoginHistory($limit = 5)
{
if (!$GLOBALS['app']->Session->Logged()) {
return false;
}
$logModel = Jaws_Gadget::getInstance('Logs')->model->load('Logs');
$logs = $logModel->GetLogs(array('gadget' => 'Users', 'action' => 'Login', 'user' => $GLOBALS['app']->Session->GetAttribute('user')), $limit);
if (Jaws_Error::IsError($logs) || empty($logs)) {
return false;
}
$tpl = $this->gadget->template->load('LoginHistory.html');
$tpl->SetBlock('history');
$date = Jaws_Date::getInstance();
$tpl->SetVariable('title', _t('LOGS_LOGIN_HISTORY'));
foreach ($logs as $log) {
$tpl->SetBlock('history/' . $log['status']);
$tpl->SetVariable('ip', long2ip($log['ip']));
$tpl->SetVariable('agent', $log['agent']);
$tpl->SetVariable('status_title', _t('GLOBAL_HTTP_ERROR_TITLE_' . $log['status']));
$tpl->SetVariable('date', $date->Format($log['insert_time'], 'd MN Y H:i'));
$tpl->ParseBlock('history/' . $log['status']);
}
$tpl->ParseBlock('history');
return $tpl->Get();
}
示例5: Upgrade
/**
* Upgrades the gadget
*
* @access public
* @param string $old Current version (in registry)
* @param string $new New version (in the $gadgetInfo file)
* @return mixed True on Success or Jaws_Error on Failure
*/
function Upgrade($old, $new)
{
// Update layout actions
$layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout');
if (!Jaws_Error::isError($layoutModel)) {
$layoutModel->EditGadgetLayoutAction('Faq', 'ListCategories', 'ListCategories', 'Category');
}
return true;
}
示例6: ManageComments
/**
* Displays blog comments manager
*
* @access public
* @return string XHTML template content
*/
function ManageComments()
{
$this->gadget->CheckPermission('ManageComments');
if (!Jaws_Gadget::IsGadgetInstalled('Comments')) {
Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog');
}
$cHTML = Jaws_Gadget::getInstance('Comments')->action->loadAdmin('Comments');
return $cHTML->Comments($this->gadget->name, $this->MenuBar('ManageComments'));
}
示例7: Upgrade
/**
* Upgrades the gadget
*
* @access public
* @param string $old Current version (in registry)
* @param string $new New version (in the $gadgetInfo file)
* @return bool True
*/
function Upgrade($old, $new)
{
// Update layout actions
$layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout');
if (!Jaws_Error::isError($layoutModel)) {
$layoutModel->EditGadgetLayoutAction('Shoutbox', 'Display', 'Comments', 'Comments');
}
return true;
}
示例8: GetGadgetsList
/**
* Fetches list of gadgets, installed/not installed, core/none core, has layout/has not, ...
*
* @access public
* @param bool $core_gadget accepts true/false/null
* @param bool $installed accepts true/false/null
* @param bool $updated accepts true/false/null
* @param bool $has_html accepts true/false/null
* @return array List of gadgets
*/
function GetGadgetsList($core_gadget = null, $installed = null, $updated = null, $has_html = null)
{
//TODO: implementing cache for this method
static $gadgetsList;
if (!isset($gadgetsList)) {
$gadgetsList = array();
$gDir = JAWS_PATH . 'gadgets' . DIRECTORY_SEPARATOR;
if (!is_dir($gDir)) {
Jaws_Error::Fatal('The gadgets directory does not exists!', __FILE__, __LINE__);
}
$installed_gadgets = $GLOBALS['app']->Registry->fetch('gadgets_installed_items');
$installed_gadgets = array_filter(explode(',', $installed_gadgets));
$disabled_gadgets = $GLOBALS['app']->Registry->fetch('gadgets_disabled_items');
$gadgets = scandir($gDir);
foreach ($gadgets as $gadget) {
if ($gadget[0] == '.' || !is_dir($gDir . $gadget)) {
continue;
}
if (!$this->gadget->GetPermission(JAWS_SCRIPT == 'index' ? 'default' : 'default_admin', '', false, $gadget)) {
continue;
}
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
continue;
}
$gInstalled = Jaws_Gadget::IsGadgetInstalled($gadget);
if ($gInstalled) {
$gUpdated = Jaws_Gadget::IsGadgetUpdated($gadget);
} else {
$gUpdated = true;
}
$index = urlencode($objGadget->title) . $gadget;
$section = strtolower($objGadget->GetSection());
switch ($section) {
case 'general':
$order = str_pad(array_search($gadget, $installed_gadgets), 2, '0', STR_PAD_LEFT);
$index = '0' . $section . $order . $index;
break;
case 'gadgets':
$index = '2' . $section . $index;
break;
default:
$index = '1' . $section . $index;
break;
}
$gadgetsList[$index] = array('section' => $section, 'name' => $gadget, 'title' => $objGadget->title, 'core_gadget' => $objGadget->_IsCore, 'description' => $objGadget->description, 'version' => $objGadget->version, 'installed' => (bool) $gInstalled, 'updated' => (bool) $gUpdated, 'disabled' => strpos($disabled_gadgets, ",{$gadget},") !== false, 'has_html' => $objGadget->default_action ? true : false);
}
ksort($gadgetsList);
}
$resList = array();
foreach ($gadgetsList as $gadget) {
if ((is_null($core_gadget) || $gadget['core_gadget'] == $core_gadget) && (is_null($installed) || $gadget['installed'] == $installed) && (is_null($updated) || $gadget['updated'] == $updated) && (is_null($has_html) || $gadget['has_html'] == $has_html)) {
$resList[$gadget['name']] = $gadget;
}
}
return $resList;
}
示例9: DisplayWhen
/**
* Changes when to display a given gadget
*
* @access public
* @return XHTML template content
*/
function DisplayWhen()
{
$rqst = jaws()->request->fetch(array('id', 'layout'), 'get');
$layout = empty($rqst['layout']) ? 'Layout' : $rqst['layout'];
// check permissions
if ($layout == 'Index.Dashboard') {
$GLOBALS['app']->Session->CheckPermission('Users', 'ManageDashboard');
} else {
$GLOBALS['app']->Session->CheckPermission('Users', 'ManageLayout');
}
$model = $this->gadget->model->loadAdmin('Elements');
$tpl = $this->gadget->template->load('DisplayWhen.html');
$tpl->SetBlock('template');
$direction = _t('GLOBAL_LANG_DIRECTION');
$dir = $direction == 'rtl' ? '.' . $direction : '';
$brow = $GLOBALS['app']->GetBrowserFlag();
$brow = empty($brow) ? '' : '.' . $brow;
$base_url = $GLOBALS['app']->GetSiteURL('/');
$tpl->SetVariable('BASE_URL', $base_url);
$tpl->SetVariable('.dir', $dir);
$tpl->SetVariable('.browser', $brow);
$tpl->SetVariable('base_script', BASE_SCRIPT);
$tpl->SetVariable('lbl_when', _t('LAYOUT_DISPLAY'));
$layoutElement = $model->GetElement($rqst['id']);
if (is_array($layoutElement) && !empty($layoutElement)) {
$dw_value = $layoutElement['when'];
}
$displayCombo =& Piwi::CreateWidget('Combo', 'display_in');
$displayCombo->AddOption(_t('LAYOUT_ALWAYS'), 'always');
$displayCombo->AddOption(_t('LAYOUT_ONLY_IN_GADGET'), 'selected');
if ($dw_value == '*') {
$displayCombo->SetDefault('always');
$tpl->SetVariable('selected_display', 'none');
} else {
$displayCombo->SetDefault('selected');
$tpl->SetVariable('selected_display', 'block');
}
$displayCombo->AddEvent(ON_CHANGE, "showGadgets();");
$tpl->SetVariable('display_in_combo', $displayCombo->Get());
// Display in list
$selectedGadgets = explode(',', $dw_value);
// for index...
$gadget_field =& Piwi::CreateWidget('CheckButtons', 'checkbox_index', 'vertical');
$gadget_field->AddOption(_t('LAYOUT_INDEX'), 'index', null, in_array('index', $selectedGadgets));
$cmpModel = Jaws_Gadget::getInstance('Components')->model->load('Gadgets');
$gadget_list = $cmpModel->GetGadgetsList(null, true, true, true);
foreach ($gadget_list as $g) {
$gadget_field->AddOption($g['title'], $g['name'], null, in_array($g['name'], $selectedGadgets));
}
$tpl->SetVariable('selected_gadgets', $gadget_field->Get());
$saveButton =& Piwi::CreateWidget('Button', 'ok', _t('GLOBAL_SAVE'), STOCK_SAVE);
$saveButton->AddEvent(ON_CLICK, "parent.parent.saveChangeDW(" . $layoutElement['id'] . ", getSelectedGadgets());");
$tpl->SetVariable('save', $saveButton->Get());
$tpl->ParseBlock('template');
return $tpl->Get();
}
示例10: Run
/**
* Does any actions required to finish the stage, such as DB queries.
*
* @access public
* @return bool|Jaws_Error Either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function Run()
{
// Connect to database
require_once JAWS_PATH . 'include/Jaws/DB.php';
$objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
if (Jaws_Error::IsError($objDatabase)) {
_log(JAWS_LOG_DEBUG, "There was a problem connecting to the database, please check the details and try again");
return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
}
// upgrade core database schema
$old_schema = JAWS_PATH . 'upgrade/Resources/schema/0.9.0.xml';
$new_schema = JAWS_PATH . 'upgrade/Resources/schema/schema.xml';
if (!file_exists($old_schema)) {
return new Jaws_Error(_t('GLOBAL_ERROR_SQLFILE_NOT_EXISTS', '0.9.0.xml'), 0, JAWS_ERROR_ERROR);
}
if (!file_exists($new_schema)) {
return new Jaws_Error(_t('GLOBAL_ERROR_SQLFILE_NOT_EXISTS', 'schema.xml'), 0, JAWS_ERROR_ERROR);
}
_log(JAWS_LOG_DEBUG, "Upgrading core schema");
$result = Jaws_DB::getInstance()->installSchema($new_schema, '', $old_schema);
if (Jaws_Error::isError($result)) {
_log(JAWS_LOG_ERROR, $result->getMessage());
if ($result->getCode() !== MDB2_ERROR_ALREADY_EXISTS) {
return new Jaws_Error($result->getMessage(), 0, JAWS_ERROR_ERROR);
}
}
// Create application
include_once JAWS_PATH . 'include/Jaws.php';
$GLOBALS['app'] = jaws();
$GLOBALS['app']->Registry->Init();
// Upgrading core gadgets
$gadgets = array('UrlMapper', 'Settings', 'ControlPanel', 'Policy', 'Layout', 'Users', 'Comments');
foreach ($gadgets as $gadget) {
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading core gadget: " . $gadget);
return $objGadget;
}
$installer = $objGadget->installer->load();
if (Jaws_Error::IsError($installer)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading installer of core gadget: {$gadget}");
return $installer;
}
if (Jaws_Gadget::IsGadgetInstalled($gadget)) {
$result = $installer->UpgradeGadget();
} else {
continue;
//$result = $installer->InstallGadget();
}
if (Jaws_Error::IsError($result)) {
_log(JAWS_LOG_DEBUG, "There was a problem installing/upgrading core gadget: {$gadget}");
return $result;
}
}
return true;
}
示例11: Upgrade
/**
* Upgrades the gadget
*
* @access public
* @param string $old Current version (in registry)
* @param string $new New version (in the $gadgetInfo file)
* @return mixed True on Success or Jaws_Error on Failure
*/
function Upgrade($old, $new)
{
// Update layout actions
$layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout');
if (!Jaws_Error::isError($layoutModel)) {
$layoutModel->EditGadgetLayoutAction('Poll', 'Display', 'Poll', 'Poll');
$layoutModel->EditGadgetLayoutAction('Poll', 'LastPoll', 'Poll', 'Poll');
$layoutModel->EditGadgetLayoutAction('Poll', 'ListOfPolls', 'Polls', 'Polls');
}
return true;
}
示例12: Execute
/**
* Event execute method
*
*/
function Execute($shouter, $params)
{
@(list($gadget, $action, $reference) = $params);
if ($gadget != 'Phoo') {
return;
}
$cModel = Jaws_Gadget::getInstance('Comments')->model->load('Comments');
$howManyComment = $cModel->GetCommentsCount($this->gadget->name, $action, $reference, '', Comments_Info::COMMENTS_STATUS_APPROVED);
$pModel = $this->gadget->model->loadAdmin('Comments');
return $pModel->UpdateImageCommentsCount($reference, $howManyComment);
}
示例13: GetJawsInfo
/**
* Gets some info around your Jaws
*
* @access public
* @return array Jaws information
*/
function GetJawsInfo()
{
$cmpGModel = Jaws_Gadget::getInstance('Components')->model->load('Gadgets');
$cmpPModel = Jaws_Gadget::getInstance('Components')->model->load('Plugins');
$theme = $GLOBALS['app']->GetTheme();
$coreGadgets = $cmpGModel->GetGadgetsList(true, true, true);
$gadgets = $cmpGModel->GetGadgetsList(false, true, true);
$outdateGadgets = $cmpGModel->GetGadgetsList(null, true, false);
$plugins = $cmpPModel->GetPluginsList(true);
return array(array('title' => "Core gadgets", 'value' => implode(", ", array_keys($coreGadgets))), array('title' => "Gadgets", 'value' => implode(", ", array_keys($gadgets))), array('title' => "Outdated gadgets", 'value' => implode(", ", array_keys($outdateGadgets))), array('title' => "Plugins", 'value' => implode(", ", array_keys($plugins))), array('title' => "Default gadget", 'value' => $this->gadget->registry->fetch('main_gadget', 'Settings')), array('title' => "Authentication method", 'value' => $this->gadget->registry->fetch('auth_method', 'Users')), array('title' => "Mailer", 'value' => $this->gadget->registry->fetch('mailer', 'Settings')), array('title' => "FTP", 'value' => $this->gadget->registry->fetch('ftp_enabled', 'Settings')), array('title' => "Proxy", 'value' => $this->gadget->registry->fetch('proxy_enabled', 'Settings')), array('title' => "Default theme", 'value' => $theme['name']), array('title' => "Encryption", 'value' => $this->gadget->registry->fetch('crypt_enabled', 'Policy')), array('title' => "GZip compression", 'value' => $this->gadget->registry->fetch('gzip_compression', 'Settings')), array('title' => "WWW-Authentication", 'value' => $this->gadget->registry->fetch('http_auth', 'Settings')), array('title' => "URL mapping", 'value' => $GLOBALS['app']->Registry->fetch('map_enabled', 'UrlMapper')), array('title' => "Use rewrite", 'value' => $GLOBALS['app']->Registry->fetch('map_use_rewrite', 'UrlMapper')));
}
示例14: Prepare
/**
* The preg_replace call back function
*
* @access private
* @param string $matches Matched strings from preg_replace_callback
* @return string Gadget action output or plain text on errors
*/
function Prepare($data)
{
$gadget = $data[2];
$action = $data[3];
$params = @$data[5];
$actions = Jaws_Gadget::getInstance($gadget)->action->fetchAll('index');
if (in_array($action, array_keys($actions)) && isset($actions[$action]['normal']) && $actions[$action]['normal']) {
$objAction = Jaws_Gadget::getInstance($gadget)->action->load($actions[$action]['file']);
return isset($params) ? $objAction->{$action}($params) : $objAction->{$action}();
}
return $data[0];
}
示例15: GetSubscriptionGadgets
/**
* Gets list of subscription support gadgets
*
* @access public
* @return array List of subscription supportgadgets
*/
function GetSubscriptionGadgets()
{
$cmpModel = Jaws_Gadget::getInstance('Components')->model->load('Gadgets');
$gadgets = $cmpModel->GetGadgetsList(null, true, true);
foreach ($gadgets as $gadget => $info) {
if (is_file(JAWS_PATH . "gadgets/{$gadget}/Hooks/Subscription.php")) {
$gadgets[$gadget] = $info['title'];
continue;
}
unset($gadgets[$gadget]);
}
return $gadgets;
}