Beispiel #1
0
 /**
  *
  * @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();
 }
Beispiel #2
0
 /**
  * Displays admin menu bar according to selected action
  *
  * @access  public
  * @param   string  $action_selected    selected action
  * @return  string XHTML template content
  */
 function MenuBar($action_selected)
 {
     $actions = array('Summary', 'NewEntry', 'ListEntries', 'ManageComments', 'ManageTrackbacks', 'ManageCategories', 'AdditionalSettings');
     if (!in_array($action_selected, $actions)) {
         $action_selected = 'ListEntries';
     }
     $menubar = new Jaws_Widgets_Menubar();
     $menubar->AddOption('Summary', _t('BLOG_SUMMARY'), BASE_SCRIPT . '?gadget=Blog&action=Summary', 'images/stock/new.png');
     if ($this->gadget->GetPermission('AddEntries')) {
         $menubar->AddOption('NewEntry', _t('BLOG_NEW_ENTRY'), BASE_SCRIPT . '?gadget=Blog&action=NewEntry', 'images/stock/new.png');
     }
     $menubar->AddOption('ListEntries', _t('BLOG_LIST_ENTRIES'), BASE_SCRIPT . '?gadget=Blog&action=ListEntries', 'images/stock/edit.png');
     if (Jaws_Gadget::IsGadgetInstalled('Comments') && $this->gadget->GetPermission('ManageComments')) {
         $menubar->AddOption('ManageComments', _t('BLOG_MANAGE_COMMENTS'), BASE_SCRIPT . '?gadget=Blog&action=ManageComments', 'images/stock/stock-comments.png');
     }
     if ($this->gadget->GetPermission('ManageTrackbacks')) {
         $menubar->AddOption('ManageTrackbacks', _t('BLOG_MANAGE_TRACKBACKS'), BASE_SCRIPT . '?gadget=Blog&action=ManageTrackbacks', 'images/stock/stock-comments.png');
     }
     if ($this->gadget->GetPermission('ManageCategories')) {
         $menubar->AddOption('ManageCategories', _t('BLOG_CATEGORIES'), BASE_SCRIPT . '?gadget=Blog&action=ManageCategories', 'images/stock/edit.png');
     }
     if ($this->gadget->GetPermission('Settings')) {
         $menubar->AddOption('AdditionalSettings', _t('BLOG_SETTINGS'), BASE_SCRIPT . '?gadget=Blog&action=AdditionalSettings', 'images/stock/properties.png');
     }
     $menubar->Activate($action_selected);
     return $menubar->Get();
 }
Beispiel #3
0
 /**
  * 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();
 }
Beispiel #4
0
 /**
  * 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;
 }
Beispiel #5
0
 /**
  * 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;
 }
Beispiel #6
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('Faq', 'ListCategories', 'ListCategories', 'Category');
     }
     return true;
 }
Beispiel #7
0
 /**
  * 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;
 }
Beispiel #8
0
 /**
  * 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;
 }
Beispiel #9
0
 /**
  * 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'));
 }
Beispiel #10
0
 /**
  * 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();
 }
Beispiel #11
0
 /**
  * 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;
 }
Beispiel #12
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('Glossary', 'RandomTerms', 'RandomTerms', 'Term');
         $layoutModel->EditGadgetLayoutAction('Glossary', 'ListOfTerms', 'ListOfTerms', 'Term');
     }
     return true;
 }
Beispiel #13
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('Poll', 'Display', 'Poll', 'Poll');
         $layoutModel->EditGadgetLayoutAction('Poll', 'LastPoll', 'Poll', 'Poll');
         $layoutModel->EditGadgetLayoutAction('Poll', 'ListOfPolls', 'Polls', 'Polls');
     }
     return true;
 }
Beispiel #14
0
 /**
  * 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);
 }
Beispiel #15
0
 /**
  * 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')));
 }
Beispiel #16
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, 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;
 }
Beispiel #17
0
 /**
  * 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 '';
 }
Beispiel #18
0
 /**
  * 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];
 }
Beispiel #19
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, 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;
 }
Beispiel #20
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;
 }
Beispiel #21
0
 /**
  * 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;
 }
Beispiel #22
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, 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;
 }
Beispiel #23
0
 /**
  * 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');
 }
Beispiel #24
0
Datei: Info.php Projekt: uda/jaws
 /**
  * Constructor
  *
  * @access  protected
  * @param   string  $gadget Gadget's name(filesystem name)
  * @return  void
  */
 protected function __construct($gadget)
 {
     parent::__construct($gadget);
     if (isset($GLOBALS['app']) && isset($GLOBALS['app']->Session)) {
         $this->user = (int) $GLOBALS['app']->Session->GetAttribute('user');
         $default_theme = unserialize($GLOBALS['app']->Registry->fetch('theme', 'Settings'));
         $this->theme = $default_theme['name'];
         $this->locality = (int) $default_theme['locality'];
     } else {
         $this->user = 0;
         $this->theme = 'jaws';
         $this->locality = 0;
     }
 }
Beispiel #25
0
 /**
  * Displays admin menu bar according to selected action
  *
  * @access  public
  * @param   string  $action    selected action
  * @return  string XHTML template content
  */
 function MenuBar($action)
 {
     $actions = array('Directory', 'Comments');
     if (!in_array($action, $actions)) {
         $action = 'Directory';
     }
     $menubar = new Jaws_Widgets_Menubar();
     $menubar->AddOption('Directory', _t('DIRECTORY_TITLE'), BASE_SCRIPT . '?gadget=Directory&amp;action=Directory', 'images/stock/folder.png');
     if (Jaws_Gadget::IsGadgetInstalled('Comments') && $this->gadget->GetPermission('ManageComments')) {
         $menubar->AddOption('Comments', _t('DIRECTORY_FILE_COMMENTS'), BASE_SCRIPT . '?gadget=Directory&amp;action=ManageComments', 'images/stock/stock-comments.png');
     }
     $menubar->Activate($action);
     return $menubar->Get();
 }
Beispiel #26
0
 /**
  * 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();
 }
Beispiel #27
0
 /**
  * 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;
 }
Beispiel #28
0
 /**
  * Sitemap XML content
  *
  * @access  public
  * @return  string  XML content
  */
 function SitemapXML()
 {
     header('Content-Type: text/xml; charset=utf-8');
     $model = $this->gadget->model->load('Sitemap');
     $gadget = jaws()->request->fetch('gname', 'get');
     $gadget = Jaws_Gadget::filter($gadget);
     if (empty($gadget)) {
         return $model->GetSitemapXML();
     } else {
         $xml = $model->GetGadgetSitemapXML($gadget);
         if (empty($xml)) {
             return Jaws_HTTPError::Get(404);
         }
         return $xml;
     }
 }
Beispiel #29
0
 /**
  * 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;
 }
Beispiel #30
0
 /**
  * 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;
 }