/** * 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(); }
/** * 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; }
/** * 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; }
/** * * @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(); }
/** * 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; }
/** * 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')); }
/** * 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; }
/** * 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; }
/** * 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(); }
/** * 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; }
/** * 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('Glossary', 'RandomTerms', 'RandomTerms', 'Term'); $layoutModel->EditGadgetLayoutAction('Glossary', 'ListOfTerms', 'ListOfTerms', 'Term'); } return true; }
/** * 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; }
/** * 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); }
/** * 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'))); }
/** * 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, Jaws_Error otherwise */ function Upgrade($old, $new) { if (version_compare($old, '1.0.0', '<')) { // Update layout actions $layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout'); if (!Jaws_Error::isError($layoutModel)) { $layoutModel->EditGadgetLayoutAction('Launcher', 'Execute', 'Script', 'Script'); } } return true; }
/** * 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]; }
/** * 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('Contact', 'Display', 'Contact', 'Contact'); $layoutModel->EditGadgetLayoutAction('Contact', 'DisplayMini', 'ContactMini', 'Contact'); $layoutModel->EditGadgetLayoutAction('Contact', 'DisplaySimple', 'ContactSimple', 'Contact'); $layoutModel->EditGadgetLayoutAction('Contact', 'DisplayFull', 'ContactFull', 'Contact'); } return true; }
/** * 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, Jaws_Error otherwise */ function Upgrade($old, $new) { // Update layout actions $layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout'); if (!Jaws_Error::isError($layoutModel)) { $layoutModel->EditGadgetLayoutAction('SysInfo', 'SysInfo', 'SysInfo', 'SysInfo'); $layoutModel->EditGadgetLayoutAction('SysInfo', 'PHPInfo', 'PHPInfo', 'PHPInfo'); $layoutModel->EditGadgetLayoutAction('SysInfo', 'JawsInfo', 'JawsInfo', 'JawsInfo'); $layoutModel->EditGadgetLayoutAction('SysInfo', 'DirInfo', 'DirInfo', 'DirInfo'); } return true; }
/** * The preg_replace call back function * * @access private * @param string $data Matched strings from preg_replace_callback * @return string Block content or blank text */ function Prepare($data) { $blockID = isset($data[1]) ? $data[1] : ''; if (Jaws_Gadget::IsGadgetInstalled('Blocks') && !empty($blockID)) { $objBlocks = Jaws_Gadget::getInstance('Blocks')->action->load('Block'); $result = $objBlocks->Block($blockID); if (!Jaws_Error::isError($result)) { return $result; } } return ''; }
/** * 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; }
/** * 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, Jaws_Error otherwise */ function Upgrade($old, $new) { if (version_compare($old, '0.9.0', '<')) { // Update layout actions $layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout'); if (!Jaws_Error::isError($layoutModel)) { $layoutModel->EditGadgetLayoutAction('Search', 'Box', 'Box', 'Search'); $layoutModel->EditGadgetLayoutAction('Search', 'SimpleBox', 'SimpleBox', 'Search'); $layoutModel->EditGadgetLayoutAction('Search', 'AdvancedBox', 'AdvancedBox', 'Search'); } } return true; }
/** * Displays a list of blog entries ordered by date * * @access public * @return string XHTML template content */ function Archive() { $tpl = $this->gadget->template->load('Archive.html'); $model = $this->gadget->model->load('Posts'); $archiveEntries = $model->GetEntriesAsArchive(); $auxMonth = ''; $this->SetTitle(_t('BLOG_ARCHIVE')); $tpl->SetBlock('archive'); $tpl->SetVariable('title', _t('BLOG_ARCHIVE')); if (!Jaws_Error::IsError($archiveEntries)) { $date = Jaws_Date::getInstance(); foreach ($archiveEntries as $entry) { $currentMonth = $date->Format($entry['publishtime'], 'MN'); if ($currentMonth != $auxMonth) { if ($auxMonth != '') { $tpl->ParseBlock('archive/month'); } $tpl->SetBlock('archive/month'); $year = $date->Format($entry['publishtime'], 'Y'); $tpl->SetVariable('month', $currentMonth); $tpl->SetVariable('year', $year); $auxMonth = $currentMonth; } $tpl->SetBlock('archive/month/record'); $tpl->SetVariable('id', $entry['id']); $tpl->SetVariable('date', $date->Format($entry['publishtime'])); $tpl->SetVariable('date-monthname', $currentMonth); $tpl->SetVariable('date-month', $date->Format($entry['publishtime'], 'm')); $tpl->SetVariable('date-day', $date->Format($entry['publishtime'], 'd')); $tpl->SetVariable('date-year', $year); $tpl->SetVariable('date-time', $date->Format($entry['publishtime'], 'g:ia')); $tpl->SetVariable('title', $entry['title']); $comments = _t('BLOG_NO_COMMENT'); if (Jaws_Gadget::IsGadgetInstalled('Comments')) { $cModel = Jaws_Gadget::getInstance('Comments')->model->load('Comments'); $commentsCount = $cModel->GetCommentsCount('Blog', 'Post', $entry['id'], '', Comments_Info::COMMENTS_STATUS_APPROVED); if (!empty($commentsCount)) { $comments = _t('BLOG_HAS_N_COMMENTS', $entry['comments']); } } $tpl->SetVariable('comments', $comments); $id = !empty($entry['fast_url']) ? $entry['fast_url'] : $entry['id']; $url = $this->gadget->urlMap('SingleView', array('id' => $id)); $tpl->SetVariable('view-link', $url); $tpl->ParseBlock('archive/month/record'); } $tpl->ParseBlock('archive/month'); } $tpl->ParseBlock('archive'); return $tpl->Get('archive'); }
/** * Displays user comments * * @access public * @return string XHTML content */ function UserComments() { $user = (int) jaws()->request->fetch('user', 'get'); if (empty($user)) { return ''; } $userModel = new Jaws_User(); $userInfo = $userModel->GetUser($user); $tpl = $this->gadget->template->load('RecentComments.html'); $tpl->SetBlock('recent_comments'); $tpl->SetVariable('title', _t('COMMENTS_USER_COMMENTS', $userInfo['nickname'])); $cHTML = Jaws_Gadget::getInstance('Comments')->action->load('Comments'); $tpl->SetVariable('comments', $cHTML->ShowComments('', '', 0, array('action' => 'RecentComments', 'params' => array('user' => $user)), $user, 0, 0)); $tpl->ParseBlock('recent_comments'); return $tpl->Get(); }
/** * Gets list of gadgets that have Sitemap * * @access public * @return array List of gadgets */ function GetAvailableSitemapGadgets() { $cmpModel = Jaws_Gadget::getInstance('Components')->model->load('Gadgets'); $gadgetList = $cmpModel->GetGadgetsList(false, true, true); $gadgets = array(); foreach ($gadgetList as $key => $gadget) { if (is_file(JAWS_PATH . 'gadgets/' . $gadget['name'] . '/Hooks/Sitemap.php')) { $gadget['name'] = trim($gadget['name']); if ($gadget['name'] == 'Sitemap' || empty($gadget['name'])) { continue; } $gadgets[$key] = $gadget; } } return $gadgets; }
/** * 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, Jaws_Error otherwise */ function Upgrade($old, $new) { if (version_compare($old, '0.9.0', '<')) { // Registry keys $this->gadget->registry->insert('api_key', ''); // Update layout actions $layoutModel = Jaws_Gadget::getInstance('Layout')->model->loadAdmin('Layout'); if (!Jaws_Error::isError($layoutModel)) { $layoutModel->EditGadgetLayoutAction('Weather', 'RegionWeather', 'RegionWeather', 'RegionWeather'); $layoutModel->EditGadgetLayoutAction('Weather', 'AllRegionsWeather', 'AllRegionsWeather', 'RegionWeather'); } } if (version_compare($old, '1.0.0', '<')) { $this->gadget->registry->update('unit', null, true); $this->gadget->registry->update('date_format', null, true); } return true; }
/** * Get information about a link * * @access public * @param int $id The links id * @return mixed An array contains link information and Jaws_Error on error */ function GetLink($id) { $objORM = Jaws_ORM::getInstance()->table('linkdump_links'); $objORM->select('id:integer', 'gid:integer', 'title', 'description', 'url', 'fast_url', 'createtime', 'updatetime', 'clicks:integer', 'rank:integer'); $objORM->where(is_numeric($id) ? 'id' : 'fast_url', $id); $link = $objORM->fetchRow(); if (Jaws_Error::IsError($link)) { return $link; } if (Jaws_Gadget::IsGadgetInstalled('Tags')) { if (!empty($link)) { $model = Jaws_Gadget::getInstance('Tags')->model->loadAdmin('Tags'); $tags = $model->GetReferenceTags('LinkDump', 'link', $id); $link['tags'] = array_filter($tags); } } return $link; }
/** * Get user's preferences of this gadget * * @access public * @return array Formatted array for using in Users Preferences action */ function Execute() { $result = array(); $languages = Jaws_Utils::GetLanguagesList(); $objSettings = $this->gadget->model->loadAdmin('Settings'); $objComponents = Jaws_Gadget::getInstance('Components')->model->load('Gadgets'); $gadgets = $objComponents->GetGadgetsList(null, true, true, null, true); $gadgets = array_column(array_values($gadgets), 'title', 'name'); array_unshift($gadgets, _t('GLOBAL_NOGADGET')); $result['admin_language'] = array('title' => _t('SETTINGS_ADMIN_LANGUAGE'), 'values' => $languages, 'ltr' => true); $result['site_language'] = array('title' => _t('SETTINGS_DEFAULT_SITE_LANGUAGE'), 'values' => $languages, 'ltr' => true); $result['calendar'] = array('title' => _t('SETTINGS_CALENDAR'), 'values' => $objSettings->GetCalendarList()); $result['date_format'] = array('title' => _t('SETTINGS_DATE_FORMAT'), 'values' => $objSettings->GetDateFormatList()); $result['main_gadget'] = array('title' => _t('SETTINGS_MAIN_GADGET'), 'values' => $gadgets); $result['editor'] = array('title' => _t('SETTINGS_EDITOR'), 'values' => $objSettings->GetEditorList()); $result['timezone'] = array('title' => _t('GLOBAL_TIMEZONE'), 'values' => $objSettings->GetTimeZonesList(), 'ltr' => true); return $result; }
/** * Get summary of the blog * * @access public * @return array An array that has the summary of blog entries */ function GetSummary() { $model = $this->gadget->model->load('DatePosts'); $summary = $model->GetPostsDateLimitation(); // Avg. entries per week if (isset($summary['min_date'])) { $dfirst = strtotime($summary['min_date']); $dlast = strtotime($summary['max_date']); $weekfirst = date('W', $dfirst); $yearfirst = date('Y', $dfirst); $weeklast = date('W', $dlast); $yearlast = date('Y', $dlast); if ($yearlast > $yearfirst) { // Ok ok, we assume 53 weeks per year... $nweeks = 54 - $weekfirst + 53 * ($yearlast - 1 - $yearfirst) + $weeklast; } else { $nweeks = $weeklast - $weekfirst; } if ($nweeks != 0) { $avg = round($summary['qty_posts'] / $nweeks); } else { $avg = $summary['qty_posts']; } $summary['AvgEntriesPerWeek'] = $avg; } else { $summary['min_date'] = null; $summary['max_date'] = null; $summary['AvgEntriesPerWeek'] = null; } if (Jaws_Gadget::IsGadgetInstalled('Comments')) { $cModel = Jaws_Gadget::getInstance('Comments')->model->load('Comments'); // total comments $summary['CommentsQty'] = $cModel->GetCommentsCount($this->gadget->name); // recent comments $comments = $cModel->GetComments($this->gadget->name, '', '', '', array(), 10); if (Jaws_Error::IsError($comments)) { return $comments; } foreach ($comments as $r) { $summary['Comments'][] = array('id' => $r['id'], 'name' => $r['name'], 'insert_time' => $r['insert_time']); } } return $summary; }
/** * Displays recent comments * * @access public * @param string $gadget * @param int $orderBy * @param mixed $limit limit recent comments (int) * @return string XHTML content */ function RecentComments($gadget = '', $orderBy = 0, $limit = 0) { $site_language = $this->gadget->registry->fetch('site_language', 'Settings'); $objTranslate = Jaws_Translate::getInstance(); $objTranslate->LoadTranslation('Blog', JAWS_COMPONENT_GADGET, $site_language); $objTranslate->LoadTranslation('Phoo', JAWS_COMPONENT_GADGET, $site_language); $objTranslate->LoadTranslation('Shoutbox', JAWS_COMPONENT_GADGET, $site_language); $gadget_name = empty($gadget) ? _t('GLOBAL_ALL') : _t(strtoupper($gadget) . '_TITLE'); $tpl = $this->gadget->template->load('RecentComments.html'); $tpl->SetBlock('recent_comments'); $tpl->SetVariable('title', _t('COMMENTS_RECENT_COMMENTS', $gadget_name)); if (!empty($gadget)) { $tpl->SetVariable('gadget', $gadget); } $cHTML = Jaws_Gadget::getInstance('Comments')->action->load('Comments'); $tpl->SetVariable('comments', $cHTML->ShowComments($gadget, '', 0, array('action' => 'RecentComments'), null, $limit, $orderBy)); $tpl->ParseBlock('recent_comments'); return $tpl->Get(); }
/** * Saves an incoming pingback as a Comment * * @access public * @param int $postID Post ID * @param string $sourceURI Who's pinging? * @param string $permalink Target URI (of post) * @param string $title Title of who's pinging (<title>..) * @param string $content has the context, from exact target link position (optional) */ function SavePingback($postID, $sourceURI, $permalink, $title, $content) { $sourceURI = strip_tags($sourceURI); $permalink = strip_tags($permalink); if (empty($title)) { $title = _t('BLOG_PINGBACK_DEFAULT_TITLE', $sourceURI); } if (empty($content)) { $content = _t('BLOG_PINGBACK_DEFAULT_CONTENT', $sourceURI); } /** * TODO: Find some other default values for pingbacks/trackbacks */ $email = $this->gadget->registry->fetch('gate_email', 'Settings'); $name = $this->gadget->registry->fetch('site_author', 'Settings'); $ip = $_SERVER['REMOTE_ADDR']; $status = $this->gadget->registry->fetch('comment_status'); $cModel = Jaws_Gadget::getInstance('Comments')->model->loadAdmin('Comments'); $res = $cModel->insertComment($this->gadget->name, $postID, 'Pingback', $name, $email, $sourceURI, $content, $ip, $permalink, $status); }