示例#1
1
 /**
  * Manage User's Tags
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ManageTags()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     $this->AjaxMe();
     $post = jaws()->request->fetch(array('gadgets_filter', 'term', 'page', 'page_item'));
     $page = $post['page'];
     $filters = array();
     $selected_gadget = "";
     if (!empty($post['gadgets_filter'])) {
         $filters['gadget'] = $post['gadgets_filter'];
         $selected_gadget = $post['gadgets_filter'];
     }
     if (!empty($post['term'])) {
         $filters['name'] = $post['term'];
     }
     $tpl = $this->gadget->template->load('ManageTags.html');
     $tpl->SetBlock('tags');
     if ($response = $GLOBALS['app']->Session->PopResponse('Tags.ManageTags')) {
         $tpl->SetVariable('type', $response['type']);
         $tpl->SetVariable('text', $response['text']);
     }
     // Menubar
     $tpl->SetVariable('menubar', $this->MenuBar('ManageTags', array('ManageTags')));
     $tpl->SetVariable('title', _t('TAGS_MANAGE_TAGS'));
     $page = empty($page) ? 1 : (int) $page;
     if (empty($post['page_item'])) {
         $limit = 10;
     } else {
         $limit = $post['page_item'];
     }
     $tpl->SetVariable('opt_page_item_' . $limit, 'selected="selected"');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $model = $this->gadget->model->loadAdmin('Tags');
     $tags = $model->GetTags($filters, $limit, ($page - 1) * $limit, 0, $user);
     $tagsTotal = $model->GetTagsCount($filters, $user);
     $tpl->SetVariable('txt_term', $post['term']);
     $tpl->SetVariable('lbl_gadgets', _t('GLOBAL_GADGETS'));
     $tpl->SetVariable('lbl_all', _t('GLOBAL_ALL'));
     $tpl->SetVariable('icon_filter', STOCK_SEARCH);
     $tpl->SetVariable('icon_ok', STOCK_OK);
     $tpl->SetVariable('lbl_tag_name', _t('TAGS_TAG_NAME'));
     $tpl->SetVariable('lbl_tag_title', _t('TAGS_TAG_TITLE'));
     $tpl->SetVariable('lbl_tag_usage_count', _t('TAGS_TAG_USAGE_COUNT'));
     $tpl->SetVariable('filter', _t('GLOBAL_SEARCH'));
     $tpl->SetVariable('lbl_page_item', _t('TAGS_ITEMS_PER_PAGE'));
     $tpl->SetVariable('lbl_actions', _t('GLOBAL_ACTIONS'));
     $tpl->SetVariable('lbl_no_action', _t('GLOBAL_NO_ACTION'));
     $tpl->SetVariable('lbl_delete', _t('GLOBAL_DELETE'));
     $tpl->SetVariable('lbl_merge', _t('TAGS_MERGE'));
     $tpl->SetVariable('selectMoreThanOneTags', _t('TAGS_SELECT_MORE_THAN_ONE_TAG_FOR_MERGE'));
     $tpl->SetVariable('enterNewTagName', _t('TAGS_ENTER_NEW_TAG_NAME'));
     //load other gadget translations
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     $tpl->SetBlock('tags/gadgets_filter');
     //Gadgets filter
     $model = $this->gadget->model->load('Tags');
     $gadgets = $model->GetTagableGadgets();
     $tagGadgets = array();
     $tagGadgets[''] = _t('GLOBAL_ALL');
     $objTranslate = Jaws_Translate::getInstance();
     foreach ($gadgets as $gadget => $title) {
         $tpl->SetBlock('tags/gadget');
         $tpl->SetVariable('selected', '');
         if ($gadget == $selected_gadget) {
             $tpl->SetVariable('selected', 'selected="selected"');
         }
         $tpl->SetVariable('name', $gadget);
         $tpl->SetVariable('title', $title);
         $tpl->ParseBlock('tags/gadget');
     }
     foreach ($tags as $tag) {
         $tpl->SetBlock('tags/tag');
         $tpl->SetVariable('id', $tag['id']);
         $tpl->SetVariable('name', $tag['name']);
         $tpl->SetVariable('title', $tag['title']);
         $tpl->SetVariable('usage_count', $tag['usage_count']);
         $tpl->SetVariable('tag_url', $this->gadget->urlMap('EditTagUI', array('tag' => $tag['id'])));
         $tpl->ParseBlock('tags/tag');
     }
     $params = array();
     if (!empty($post['gadgets_filter'])) {
         $params['gadgets_filter'] = $post['gadgets_filter'];
     }
     if (!empty($post['term'])) {
         $params['term'] = $post['term'];
     }
     // page navigation
     $this->GetPagesNavigation($tpl, 'tags', $page, $limit, $tagsTotal, _t('TAGS_TAG_COUNT', $tagsTotal), 'ManageTags', $params);
     $tpl->ParseBlock('tags');
     return $tpl->Get();
 }
示例#2
1
文件: index.php 项目: Dulciane/jaws
require_once JAWS_PATH . 'include/Jaws/Utils.php';
require_once JAWS_PATH . 'include/Jaws/Gadget.php';
if (!isset($_SESSION['install'])) {
    $_SESSION['install'] = array('stage' => 0, 'lastStage' => array());
}
// Lets handle our requests
require JAWS_PATH . 'include/Jaws/Request.php';
$request = Jaws_Request::getInstance();
$lang = $request->fetch('language', 'post');
if (isset($lang)) {
    $_SESSION['install']['language'] = urlencode($lang);
} elseif (!isset($_SESSION['install']['language'])) {
    $_SESSION['install']['language'] = 'en';
}
include_once JAWS_PATH . 'include/Jaws/Translate.php';
$objTranslate = Jaws_Translate::getInstance(false);
if (isset($_SESSION['install']['language'])) {
    $objTranslate->SetLanguage($_SESSION['install']['language']);
}
$objTranslate->LoadTranslation('Global');
$objTranslate->LoadTranslation('Install', JAWS_COMPONENT_INSTALL);
require_once 'stagelist.php';
require_once 'JawsInstaller.php';
require_once 'JawsInstallerStage.php';
$installer = new JawsInstaller();
$installer->loadStages($stages);
$stages = $installer->getStages();
$stage = $stages[$_SESSION['install']['stage']];
$stageobj = $installer->loadStage($stage);
$stages_count = count($stages);
$_SESSION['install']['predefined'] = $predefined = $installer->hasPredefined();
示例#3
0
文件: Mail.php 项目: juniortux/jaws
 /**
  * constructor
  *
  * @access  public
  * @param   array   $options    Associated options array
  * @return  void
  */
 public function __construct($options)
 {
     $this->object = Jaws_Mail::getInstance('notification');
     // fetch all registry keys related to site attributes
     $this->attributes = $GLOBALS['app']->Registry->fetchAll('Settings', false);
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $this->attributes['site_language']);
     $this->attributes['site_url'] = $GLOBALS['app']->GetSiteURL('/');
     $this->attributes['site_direction'] = _t_lang($this->attributes['site_language'], 'GLOBAL_LANG_DIRECTION');
 }
示例#4
0
文件: Feeds.php 项目: uda/jaws
 /**
  * Get then FeedsLink action params
  *
  * @access  public
  * @return  array list of the Banners action params
  */
 function FeedsLinkLayoutParams()
 {
     $result = array();
     $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);
     $result[] = array('title' => _t('COMMENTS_GADGETS'), 'value' => array('Blog' => _t('BLOG_TITLE'), 'Phoo' => _t('PHOO_TITLE'), 'Shoutbox' => _t('SHOUTBOX_TITLE'), 'Comments' => _t('COMMENTS_TITLE')));
     $result[] = array('title' => _t('COMMENTS_FEEDS_TYPE'), 'value' => array('RSS' => _t('COMMENTS_FEEDS_RSS'), 'Atom' => _t('COMMENTS_FEEDS_ATOM')));
     return $result;
 }
示例#5
0
 /**
  * Constructor
  *
  * @access public
  */
 function Installer_Settings()
 {
     $this->_Fields = array('site_name' => 'Jaws ' . JAWS_VERSION, 'site_slogan' => JAWS_VERSION_CODENAME, 'site_language' => $_SESSION['install']['language'], 'site_sample' => false);
     if (!isset($GLOBALS['app'])) {
         // Connect to the database and setup registry and similar.
         require_once JAWS_PATH . 'include/Jaws/DB.php';
         $objDatabase = Jaws_DB::getInstance('default', $_SESSION['install']['Database']);
         // Create application
         include_once JAWS_PATH . 'include/Jaws.php';
         $GLOBALS['app'] = jaws();
         $GLOBALS['app']->Registry->Init();
         $GLOBALS['app']->loadPreferences(array('language' => $_SESSION['install']['language']), false);
         Jaws_Translate::getInstance()->LoadTranslation('Install', JAWS_COMPONENT_INSTALL);
     }
 }
示例#6
0
 /**
  * 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();
 }
示例#7
0
 /**
  * Send contact reply
  *
  * @access  public
  * @param   int     $cid    Contact ID
  * @return  mixed   True on Success or Jaws_Error on Failure
  */
 function SendReply($cid)
 {
     $model = $this->gadget->model->loadAdmin('Contacts');
     $contact = $model->GetReply($cid);
     if (Jaws_Error::IsError($contact)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('GLOBAL_ERROR_QUERY_FAILED'));
     }
     if (!isset($contact['id'])) {
         $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'), RESPONSE_ERROR);
         return new Jaws_Error(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'));
     }
     $from_name = '';
     $from_email = '';
     $to = $contact['email'];
     $rid = $contact['recipient'];
     if ($rid != 0) {
         $rModel = $this->gadget->model->load('Recipients');
         $recipient = $rModel->GetRecipient($rid);
         if (Jaws_Error::IsError($recipient)) {
             $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_QUERY_FAILED'), RESPONSE_ERROR);
             return new Jaws_Error(_t('GLOBAL_ERROR_QUERY_FAILED'));
         }
         if (!isset($recipient['id'])) {
             $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS'), RESPONSE_ERROR);
             return new Jaws_Error(_t('CONTACT_ERROR_RECIPIENT_DOES_NOT_EXISTS'));
         }
         $from_name = $recipient['name'];
         $from_email = $recipient['email'];
     }
     $format = $this->gadget->registry->fetch('email_format');
     if ($format == 'html') {
         $reply = $this->gadget->ParseText($contact['reply']);
     } else {
         $reply = $contact['reply'];
     }
     $jDate = Jaws_Date::getInstance();
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     $profile_url = $GLOBALS['app']->getSiteURL('/') . $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $GLOBALS['app']->Session->GetAttribute('username')));
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
     Jaws_Translate::getInstance()->LoadTranslation('Contact', JAWS_COMPONENT_GADGET, $site_language);
     $tpl = $this->gadget->template->load('SendReplyTo.html', array('loadFromTheme' => true, 'loadRTLDirection' => _t_lang($site_language, 'GLOBAL_LANG_DIRECTION') == 'rtl'));
     $tpl->SetBlock($format);
     $tpl->SetVariable('lbl_name', _t_lang($site_language, 'GLOBAL_NAME'));
     $tpl->SetVariable('lbl_email', _t_lang($site_language, 'GLOBAL_EMAIL'));
     $tpl->SetVariable('lbl_message', _t_lang($site_language, 'CONTACT_MESSAGE'));
     $tpl->SetVariable('lbl_reply', _t_lang($site_language, 'CONTACT_REPLY'));
     $tpl->SetVariable('name', $contact['name']);
     $tpl->SetVariable('email', $contact['email']);
     $tpl->SetVariable('subject', $contact['subject']);
     $tpl->SetVariable('message', $contact['msg_txt']);
     $tpl->SetVariable('reply', $reply);
     $tpl->SetVariable('createtime', $jDate->Format($contact['createtime']));
     $tpl->SetVariable('nickname', $GLOBALS['app']->Session->GetAttribute('nickname'));
     $tpl->SetVariable('profile_url', $profile_url);
     $tpl->SetVariable('site-name', $site_name);
     $tpl->SetVariable('site-url', $site_url);
     $tpl->ParseBlock($format);
     $template = $tpl->Get();
     $subject = _t_lang($site_language, 'CONTACT_REPLY_TO', Jaws_XSS::defilter($contact['subject']));
     $mail = Jaws_Mail::getInstance();
     $mail->SetFrom($from_email, $from_name);
     $mail->AddRecipient($to);
     $mail->AddRecipient('', 'cc');
     $mail->SetSubject($subject);
     $mail->SetBody($template, $format);
     $result = $mail->send();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_ERROR_REPLY_NOT_SENT'), RESPONSE_ERROR);
         return false;
     }
     $model->UpdateReplySent($cid, true);
     $GLOBALS['app']->Session->PushLastResponse(_t('CONTACT_REPLY_SENT'), RESPONSE_NOTICE);
     return true;
 }
示例#8
0
文件: Mailer.php 项目: Dulciane/jaws
 /**
  * Prepares the message body of the Email
  *
  * @access  public
  * @param   string  $message  Body part of the Email
  * @return  string  XHTML template content
  */
 function PrepareMessage($message)
 {
     $this->gadget->CheckPermission('AccessToMailer');
     $format = $this->gadget->registry->fetch('email_format');
     if ($format == 'html') {
         $message = $this->gadget->ParseText($message);
     } else {
         $message = strip_tags($message);
     }
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
     Jaws_Translate::getInstance()->LoadTranslation('Contact', JAWS_COMPONENT_GADGET, $site_language);
     $tpl = $this->gadget->template->load('SendEmail.html', array('loadFromTheme' => true, 'loadRTLDirection' => _t_lang($site_language, 'GLOBAL_LANG_DIRECTION') == 'rtl'));
     $tpl->SetBlock($format);
     $tpl->SetVariable('message', $message);
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $tpl->SetVariable('site-name', $site_name);
     $tpl->SetVariable('site-url', $site_url);
     $tpl->ParseBlock($format);
     return $tpl->Get();
 }
示例#9
0
文件: PHPFunctions.php 项目: uda/jaws
/**
 * Convenience function to translate strings.
 *
 * Passes it's arguments to Jaws_Translate::Translate to do the actual translation.
 *
 * @access  public
 * @param   string  lang The language.
 * @param   string  string The string to translate.
 * @return  string
 */
function _t_lang($lang, $string)
{
    $args = array();
    if (func_num_args() > 2) {
        $args = func_get_args();
        // Argument 1th for lang and argument 2th is the string to be translated.
        array_shift($args);
        array_shift($args);
    }
    return Jaws_Translate::getInstance()->Translate($lang, $string, $args);
}
示例#10
0
 /**
  * Insert a new translation statement
  *
  * @access  public
  * @param   string  $key_name   Key name
  * @param   string  $key_value  Key value
  * @param   string  $gadget     (Optional) Gadget name
  * @return  bool    Returns True or False
  */
 function insert($key_name, $key_value, $gadget = '')
 {
     $gadget = empty($gadget) ? $this->gadget->name : $gadget;
     return Jaws_Translate::getInstance()->AddTranslation($gadget, strtoupper($gadget . '_' . $key_name), $key_value, JAWS_COMPONENT_GADGET);
 }
示例#11
0
 /**
  * Mails reply to the sender
  *
  * @access  public
  * @param   string  $email      Comment sender's email
  * @param   string  $message    Message
  * @param   string  $reply      Reply message
  * @param   int     $replier    Replier Id
  * @return  mixed   True on successfully or Jaws_Error on failure
  */
 function EmailReply($email, $message, $reply, $replier)
 {
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $site_language = $this->gadget->registry->fetch('site_language', 'Settings');
     Jaws_Translate::getInstance()->LoadTranslation('Global', JAWS_COMPONENT_OTHERS, $site_language);
     Jaws_Translate::getInstance()->LoadTranslation('Comments', JAWS_COMPONENT_GADGET, $site_language);
     $tpl = $this->gadget->template->load('EmailReply.html');
     $tpl->SetBlock('notification');
     $tpl->SetVariable('lbl_message', _t_lang($site_language, 'COMMENTS_MESSAGE'));
     $tpl->SetVariable('message', $message);
     $tpl->SetVariable('replier', _t_lang($site_language, 'COMMENTS_REPLY_BY', $replier));
     $tpl->SetVariable('lbl_reply', _t_lang($site_language, 'COMMENTS_REPLY'));
     $tpl->SetVariable('reply', $reply);
     $tpl->SetVariable('site_name', $site_name);
     $tpl->SetVariable('site_url', $site_url);
     $tpl->ParseBlock('notification');
     $template = $tpl->Get();
     $ObjMail = Jaws_Mail::getInstance();
     $ObjMail->SetFrom();
     if (empty($email)) {
         $ObjMail->AddRecipient('', 'to');
     } else {
         $ObjMail->AddRecipient($email);
         $ObjMail->AddRecipient('', 'cc');
     }
     $ObjMail->SetSubject(_t_lang('COMMENTS_YOU_GET_REPLY'));
     $ObjMail->SetBody($template, 'html');
     return $ObjMail->send();
 }
示例#12
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()
 {
     $keys = array_keys($this->_Defaults);
     $keys[] = 'dbpass';
     $request = Jaws_Request::getInstance();
     $post = $request->fetch($keys, 'post');
     $post['dbpass'] = $request->fetch('dbpass', 'post', false);
     $request->reset();
     if (isset($_SESSION['install']['data']['Database'])) {
         $post = $_SESSION['install']['data']['Database'] + $post;
     }
     if ($_SESSION['secure']) {
         require_once JAWS_PATH . 'include/Jaws/Crypt.php';
         $JCrypt = Jaws_Crypt::getInstance(array('pvt_key' => $_SESSION['pvt_key'], 'pub_key' => $_SESSION['pub_key']));
         if (!Jaws_Error::isError($JCrypt)) {
             $post['dbpass'] = $JCrypt->decrypt($post['dbpass']);
         } else {
             return $JCrypt;
         }
     }
     if (substr($post['prefix'], -1) == '_') {
         $prefix = $post['prefix'];
     } elseif (strlen($post['prefix']) > 0) {
         $prefix = $post['prefix'] . '_';
     } else {
         $prefix = $post['prefix'];
     }
     if (!empty($post['path'])) {
         if (DIRECTORY_SEPARATOR != '/') {
             $post['path'] = str_replace('/', '\\', $post['path']);
         }
         if (substr($post['path'], -1) != DIRECTORY_SEPARATOR) {
             $post['path'] .= DIRECTORY_SEPARATOR;
         }
     }
     $_SESSION['install']['Database'] = array('user' => trim($post['user']), 'password' => $post['dbpass'], 'isdba' => !empty($post['isdba']) ? 'true' : 'false', 'name' => trim($post['name']), 'path' => trim($post['path']), 'host' => trim($post['host']), 'port' => trim($post['port']), 'prefix' => $prefix, 'driver' => $post['driver']);
     // Connect to database
     require_once JAWS_PATH . 'include/Jaws/DB.php';
     $objDatabase = Jaws_DB::getInstance('default', $_SESSION['install']['Database']);
     if (Jaws_Error::IsError($objDatabase)) {
         _log(JAWS_LOG_DEBUG, "There was a problem connecting to the database.");
         return new Jaws_Error(_t('INSTALL_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
     }
     $variables = array();
     $variables['timestamp'] = Jaws_DB::getInstance()->date();
     $result = Jaws_DB::getInstance()->installSchema('Resources/schema/schema.xml', $variables);
     _log(JAWS_LOG_DEBUG, "Installing core schema");
     if (Jaws_Error::isError($result)) {
         _log(JAWS_LOG_DEBUG, $result->getMessage());
         return $result;
     }
     // Create application
     require_once JAWS_PATH . 'include/Jaws.php';
     $GLOBALS['app'] = jaws();
     $GLOBALS['app']->Registry->Init();
     $GLOBALS['app']->loadPreferences(array('language' => $_SESSION['install']['language']), false);
     Jaws_Translate::getInstance()->LoadTranslation('Install', JAWS_COMPONENT_INSTALL);
     // registry keys
     $result = $GLOBALS['app']->Registry->insertAll(array(array('version', JAWS_VERSION), array('gadgets_installed_items', ','), array('gadgets_disabled_items', ','), array('gadgets_autoload_items', ','), array('plugins_installed_items', ',')));
     if (Jaws_Error::isError($result)) {
         _log(JAWS_LOG_DEBUG, $result->getMessage());
     }
     $gadgets = array('Settings', 'ControlPanel', 'Components', 'UrlMapper', 'Layout', 'Users', 'Policy');
     foreach ($gadgets as $gadget) {
         $objGadget = Jaws_Gadget::getInstance($gadget);
         if (Jaws_Error::IsError($objGadget)) {
             _log(JAWS_LOG_DEBUG, "There was a problem installing core gadget: " . $gadget);
             return $objGadget;
         }
         $installer = $objGadget->installer->load();
         $result = $installer->InstallGadget();
         if (Jaws_Error::IsError($result)) {
             _log(JAWS_LOG_DEBUG, "There was a problem installing core gadget: " . $gadget);
             return $result;
         }
     }
     return true;
 }
示例#13
0
文件: Jaws.php 项目: juniortux/jaws
 /**
  * Load the default application preferences(language, theme, ...)
  *
  * @access  public
  * @param   array   $preferences        Default preferences
  * @param   bool    $loadFromDatabase   Load preferences from database
  * @return  void
  */
 function loadPreferences($preferences = array(), $loadFromDatabase = true)
 {
     if ($loadFromDatabase) {
         $user = $this->Session->GetAttribute('user');
         $layout = $this->Session->GetAttribute('layout');
         $this->_Preferences = array('theme' => unserialize($this->Registry->fetchByUser($layout, 'theme', 'Settings')), 'editor' => $this->Registry->fetchByUser($user, 'editor', 'Settings'), 'timezone' => $this->Registry->fetchByUser($user, 'timezone', 'Settings'), 'calendar' => $this->Registry->fetchByUser($layout, 'calendar', 'Settings'));
         if (JAWS_SCRIPT == 'index') {
             $this->_Preferences['language'] = $this->Registry->fetchByUser($layout, 'site_language', 'Settings');
         } else {
             $this->_Preferences['language'] = $this->Registry->fetchByUser($user, 'admin_language', 'Settings');
         }
     }
     // merge default with passed preferences
     $this->_Preferences = array_merge($this->_Preferences, $preferences);
     // filter non validate character
     $this->theme['name'] = preg_replace('/[^[:alnum:]_\\-]/', '', $this->_Preferences['theme']['name']);
     $this->theme['locality'] = (int) $this->_Preferences['theme']['locality'];
     $this->_Language = preg_replace('/[^[:alnum:]_\\-]/', '', $this->_Preferences['language']);
     $this->_Editor = preg_replace('/[^[:alnum:]_\\-]/', '', $this->_Preferences['editor']);
     $this->_Timezone = $this->_Preferences['timezone'];
     $this->_Calendar = preg_replace('/[^[:alnum:]_]/', '', $this->_Preferences['calendar']);
     // load the language translates
     Jaws_Translate::getInstance()->Init($this->_Language);
 }
示例#14
0
 /**
  * Displays blog settings administration panel
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function AdditionalSettings()
 {
     $this->gadget->CheckPermission('Settings');
     $this->AjaxMe('script.js');
     $tpl = $this->gadget->template->loadAdmin('Settings.html');
     $tpl->SetBlock('additional');
     // Header
     $tpl->SetVariable('menubar', $this->MenuBar('AdditionalSettings'));
     $form =& Piwi::CreateWidget('Form', BASE_SCRIPT, 'POST');
     $form->Add(Piwi::CreateWidget('HiddenEntry', 'gadget', 'Blog'));
     $form->Add(Piwi::CreateWidget('HiddenEntry', 'action', 'SaveAdditionalSettings'));
     include_once JAWS_PATH . 'include/Jaws/Widgets/FieldSet.php';
     $fieldset = new Jaws_Widgets_FieldSet(_t('BLOG_ADDITIONAL_SETTINGS'));
     // $fieldset =& Piwi::CreateWidget('FieldSet', _t('BLOG_ADDITIONAL_SETTINGS'));
     // Save Button
     $save =& Piwi::CreateWidget('Button', 'save', _t('GLOBAL_SAVE'), STOCK_SAVE);
     $save->AddEvent(ON_CLICK, 'javascript: saveSettings(this.form);');
     $sModel = $this->gadget->model->loadAdmin('Settings');
     $cModel = $this->gadget->model->load('Categories');
     $settings = $sModel->GetSettings();
     if (Jaws_Error::IsError($settings)) {
         $settings = array();
     }
     // Default View
     $tpl->SetVariable('label', _t('BLOG_DEFAULT_VIEW'));
     $viewCombo =& Piwi::CreateWidget('Combo', 'default_view');
     $viewCombo->setContainerClass('oneline');
     $viewCombo->SetTitle(_t('BLOG_DEFAULT_VIEW'));
     $viewCombo->AddOption(_t('BLOG_MONTHLY'), 'monthly');
     $viewCombo->AddOption(_t('BLOG_LATEST_ENTRY'), 'latest_entry');
     $viewCombo->AddOption(_t('BLOG_LAST_ENTRIES'), 'last_entries');
     $viewCombo->AddOption(_t('BLOG_DEFAULT_CATEGORY'), 'default_category');
     $viewCombo->SetDefault(isset($settings['default_view']) ? $settings['default_view'] : '');
     // Last entries limit
     $limitCombo =& Piwi::CreateWidget('Combo', 'last_entries_limit');
     $limitCombo->setContainerClass('oneline');
     $limitCombo->SetTitle(_t('BLOG_LAST_ENTRIES_LIMIT'));
     for ($i = 5; $i <= 30; $i += 5) {
         $limitCombo->AddOption($i, $i);
     }
     $limitCombo->SetDefault(isset($settings['last_entries_limit']) ? $settings['last_entries_limit'] : '');
     // Popular limit
     $popCombo =& Piwi::CreateWidget('Combo', 'popular_limit');
     $popCombo->setContainerClass('oneline');
     $popCombo->SetTitle(_t('BLOG_POPULAR_ENTRIES_LIMIT'));
     for ($i = 5; $i <= 30; $i += 5) {
         $popCombo->AddOption($i, $i);
     }
     $popCombo->SetDefault(isset($settings['popular_limit']) ? $settings['popular_limit'] : '');
     // Last comments limit
     $commentslimitCombo =& Piwi::CreateWidget('Combo', 'last_comments_limit');
     $commentslimitCombo->setContainerClass('oneline');
     $commentslimitCombo->SetTitle(_t('BLOG_LAST_COMMENTS_LIMIT'));
     for ($i = 5; $i <= 30; $i += 5) {
         $commentslimitCombo->AddOption($i, $i);
     }
     $commentslimitCombo->SetDefault(isset($settings['last_comments_limit']) ? $settings['last_comments_limit'] : '');
     // Last recent comments
     $recentcommentsLimitCombo =& Piwi::CreateWidget('Combo', 'last_recentcomments_limit');
     $recentcommentsLimitCombo->setContainerClass('oneline');
     $recentcommentsLimitCombo->SetTitle(_t('BLOG_LAST_RECENTCOMMENTS_LIMIT'));
     for ($i = 5; $i <= 30; $i += 5) {
         $recentcommentsLimitCombo->AddOption($i, $i);
     }
     $recentcommentsLimitCombo->SetDefault(isset($settings['last_recentcomments_limit']) ? $settings['last_recentcomments_limit'] : '');
     $categories = $cModel->GetCategories();
     if (!Jaws_Error::IsError($categories)) {
         // Default category
         $catCombo =& Piwi::CreateWidget('Combo', 'default_category');
         $catCombo->setContainerClass('oneline');
         $catCombo->SetTitle(_t('BLOG_DEFAULT_CATEGORY'));
         foreach ($categories as $cat) {
             $catCombo->AddOption($cat['name'], $cat['id']);
         }
         $catCombo->SetDefault(isset($settings['default_category']) ? $settings['default_category'] : '');
     }
     // RSS/Atom limit
     $xmlCombo =& Piwi::CreateWidget('Combo', 'xml_limit');
     $xmlCombo->setContainerClass('oneline');
     $xmlCombo->SetTitle(_t('BLOG_RSS_ENTRIES_LIMIT'));
     for ($i = 5; $i <= 50; $i += 5) {
         $xmlCombo->AddOption($i, $i);
     }
     $xmlCombo->SetDefault(isset($settings['xml_limit']) ? $settings['xml_limit'] : '');
     Jaws_Translate::getInstance()->LoadTranslation('Comments', JAWS_COMPONENT_GADGET);
     // Comments
     $commCombo =& Piwi::CreateWidget('Combo', 'comments');
     $commCombo->setContainerClass('oneline');
     $commCombo->SetTitle(_t('BLOG_COMMENTS'));
     $commCombo->AddOption(_t('GLOBAL_ENABLED'), 'true');
     $commCombo->AddOption(_t('GLOBAL_DISABLED'), 'false');
     $commCombo->SetDefault(isset($settings['comments']) ? $settings['comments'] : '');
     // Trackback
     $tbCombo =& Piwi::CreateWidget('Combo', 'trackback');
     $tbCombo->setContainerClass('oneline');
     $tbCombo->SetTitle(_t('BLOG_TRACKBACK'));
     $tbCombo->AddOption(_t('GLOBAL_ENABLED'), 'true');
     $tbCombo->AddOption(_t('GLOBAL_DISABLED'), 'false');
     $tbCombo->SetDefault($settings['trackback']);
     // Trackback status
     $tbStatusCombo =& Piwi::CreateWidget('Combo', 'trackback_status');
     $tbStatusCombo->setContainerClass('oneline');
     $tbStatusCombo->SetTitle(_t('BLOG_DEFAULT_STATUS', _t('BLOG_TRACKBACK')));
     $tbStatusCombo->AddOption(_t('COMMENTS_STATUS_APPROVED'), 'approved');
     $tbStatusCombo->AddOption(_t('COMMENTS_STATUS_WAITING'), 'waiting');
     $tbStatusCombo->SetDefault($settings['trackback_status']);
     // Pingback
     $pbCombo =& Piwi::CreateWidget('Combo', 'pingback');
     $pbCombo->setContainerClass('oneline');
     $pbCombo->SetTitle(_t('BLOG_PINGBACK'));
     $pbCombo->AddOption(_t('GLOBAL_ENABLED'), 'true');
     $pbCombo->AddOption(_t('GLOBAL_DISABLED'), 'false');
     $pbCombo->SetDefault($settings['pingback']);
     $fieldset->Add($viewCombo);
     $fieldset->Add($limitCombo);
     $fieldset->Add($popCombo);
     $fieldset->Add($commentslimitCombo);
     $fieldset->Add($recentcommentsLimitCombo);
     if (!Jaws_Error::IsError($categories)) {
         $fieldset->Add($catCombo);
     }
     $fieldset->Add($xmlCombo);
     $fieldset->Add($commCombo);
     $fieldset->Add($tbCombo);
     $fieldset->Add($tbStatusCombo);
     $fieldset->Add($pbCombo);
     $fieldset->SetDirection('vertical');
     $form->Add($fieldset);
     $buttonbox =& Piwi::CreateWidget('HBox');
     $buttonbox->SetStyle(_t('GLOBAL_LANG_DIRECTION') == 'rtl' ? 'float: left;' : 'float: right;');
     $buttonbox->PackStart($save);
     $form->Add($buttonbox);
     $tpl->SetVariable('form', $form->Get());
     $tpl->ParseBlock('additional');
     return $tpl->Get();
 }
示例#15
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()
 {
     $request = Jaws_Request::getInstance();
     $post = $request->fetch(array('username', 'email', 'nickname', 'password'), 'post');
     if (isset($_SESSION['install']['data']['CreateUser'])) {
         $post = $_SESSION['install']['data']['CreateUser'] + $post;
     }
     if ($_SESSION['secure']) {
         require_once JAWS_PATH . 'include/Jaws/Crypt.php';
         $JCrypt = Jaws_Crypt::getInstance(array('pvt_key' => $_SESSION['pvt_key'], 'pub_key' => $_SESSION['pub_key']));
         if (!Jaws_Error::isError($JCrypt)) {
             $post['password'] = $JCrypt->decrypt($post['password']);
         } else {
             return $JCrypt;
         }
     }
     $_SESSION['install']['CreateUser'] = array('username' => $post['username'], 'email' => $post['email'], 'nickname' => $post['nickname']);
     require_once JAWS_PATH . 'include/Jaws/DB.php';
     $objDatabase = Jaws_DB::getInstance('default', $_SESSION['install']['Database']);
     #if (Jaws_Error::IsError($objDatabase)) {
     #   return new Jaws_Error("There was a problem connecting to the database, please check the details and try again.", 0, JAWS_ERROR_WARNING);
     #}
     require_once JAWS_PATH . 'include/Jaws.php';
     $GLOBALS['app'] = jaws();
     $GLOBALS['app']->Registry->Init();
     $GLOBALS['app']->loadPreferences(array('language' => $_SESSION['install']['language']), false);
     Jaws_Translate::getInstance()->LoadTranslation('Install', JAWS_COMPONENT_INSTALL);
     require_once JAWS_PATH . 'include/Jaws/User.php';
     $userModel = new Jaws_User();
     $userInfo = $userModel->GetUser($post['username']);
     if (!Jaws_Error::IsError($userInfo)) {
         //username exists
         if (isset($userInfo['username'])) {
             _log(JAWS_LOG_DEBUG, "Update existing user");
             $res = $userModel->UpdateUser($userInfo['id'], array('username' => $post['username'], 'nickname' => $post['nickname'], 'email' => $post['email'], 'password' => $post['password']));
         } else {
             _log(JAWS_LOG_DEBUG, "Adding first/new admin user to Jaws");
             $res = $userModel->AddUser(array('username' => $post['username'], 'nickname' => $post['nickname'], 'email' => $post['email'], 'password' => $post['password'], 'superadmin' => true));
         }
     } else {
         $res = $userInfo;
     }
     if (Jaws_Error::IsError($res)) {
         _log(JAWS_LOG_DEBUG, "There was a problem while creating your user:");
         _log(JAWS_LOG_DEBUG, $res->GetMessage());
         return new Jaws_Error(_t('INSTALL_USER_RESPONSE_CREATE_FAILED'), 0, JAWS_ERROR_ERROR);
     }
     return true;
 }