示例#1
0
文件: Posts.php 项目: juniortux/jaws
 /**
  * Generates XHTML template
  *
  * @access  public
  * @param   int     $cat
  * @return  string  XHTML template content
  */
 function ViewPage($cat = null)
 {
     $page = jaws()->request->fetch('page', 'get');
     if (is_null($page) || $page <= 0) {
         $page = 1;
     }
     $GLOBALS['app']->Layout->AddHeadLink($this->gadget->urlMap('Atom'), 'alternate', 'application/atom+xml', 'Atom - All');
     $GLOBALS['app']->Layout->AddHeadLink($this->gadget->urlMap('RSS'), 'alternate', 'application/rss+xml', 'RSS 2.0 - All');
     /**
      * This will be supported in next Blog version - Bookmarks for each categorie
     $categories = $model->GetCategories();
     if (!Jaws_Error::IsError($categories)) {
     $GLOBALS['app']->Layout->AddHeadLink(
             $base_url.'blog.atom',
             'alternate',
             'application/atom+xml',
             'Atom - All'
         );
         foreach ($categories as $cat) {
             $name = $cat['name'];
         }
     }
     */
     $this->setTitle(_t('BLOG_RECENT_POSTS'));
     $tpl = $this->gadget->template->load('Posts.html');
     $tpl->SetBlock('view');
     $model = $this->gadget->model->load('Posts');
     $entries = $model->GetEntriesAsPage($cat, $page);
     if (!Jaws_Error::IsError($entries) && count($entries) > 0) {
         $row = 0;
         $col = 0;
         $index = 0;
         $tpl->SetVariable('title', _t('BLOG_RECENT_POSTS'));
         $columns = (int) $this->gadget->registry->fetch('columns');
         $columns = $columns <= 0 ? 1 : $columns;
         foreach ($entries as $entry) {
             if ($col == 0) {
                 $tpl->SetBlock('view/entryrow');
                 $tpl->SetVariable('row', $row);
             }
             $tpl->SetBlock('view/entryrow/column');
             $tpl->SetVariable('col', $col);
             $this->ShowEntry($tpl, 'view/entryrow/column', $entry);
             $tpl->ParseBlock('view/entryrow/column');
             $index++;
             $col = $index % $columns;
             if ($col == 0 || $index == count($entries)) {
                 $row++;
                 $tpl->ParseBlock('view/entryrow');
             }
         }
     }
     if ($tpl->VariableExists('navigation')) {
         $total = $model->GetNumberOfPages($cat);
         $limit = $this->gadget->registry->fetch('last_entries_limit');
         $tpl->SetVariable('navigation', $this->GetNumberedPageNavigation($page, $limit, $total, 'ViewPage'));
     }
     $tpl->ParseBlock('view');
     return $tpl->Get();
 }
示例#2
0
文件: Terms.php 项目: Dulciane/jaws
 /**
  * Look for a term and prints it
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewTerm()
 {
     $term = jaws()->request->fetch('term', 'get');
     $term = Jaws_XSS::defilter($term);
     $model = $this->gadget->model->load('Term');
     $term = $model->GetTerm($term);
     if (!Jaws_Error::IsError($term) && isset($term['term'])) {
         $this->SetTitle($term['term']);
         $tpl = $this->gadget->template->load('ViewTerm.html');
         $tpl->SetBlock('definition');
         $tpl->SetVariable('title', $this->gadget->title);
         $date = Jaws_Date::getInstance();
         $tpl->SetBlock('definition/term');
         $tpl->SetVariable('term', $term['term']);
         $tid = empty($term['fast_url']) ? $term['id'] : $term['fast_url'];
         $tpl->SetVariable('url', $this->gadget->urlMap('ViewTerm', array('term' => $tid)));
         $tpl->SetVariable('description', $this->gadget->ParseText($term['description']));
         $tpl->SetVariable('created_in', _t('GLOBAL_CREATETIME'));
         $tpl->SetVariable('updated_in', _t('GLOBAL_UPDATETIME'));
         $tpl->SetVariable('createtime', $date->Format($term['createtime']));
         $tpl->SetVariable('updatetime', $date->Format($term['updatetime']));
         $tpl->ParseBlock('definition/term');
         $tpl->ParseBlock('definition');
     } else {
         return Jaws_HTTPError::Get(404);
     }
     return $tpl->Get();
 }
示例#3
0
文件: Open.php 项目: Dulciane/jaws
 /**
  * Builds UI to display a single note
  *
  * @access  public
  * @return  string  XHTML UI
  */
 function OpenNote()
 {
     $id = (int) jaws()->request->fetch('id', 'get');
     $model = $this->gadget->model->load('Notepad');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $note = $model->GetNote($id, $user);
     if (Jaws_Error::IsError($note) || empty($note)) {
         return;
     }
     $this->AjaxMe('site_script.js');
     $tpl = $this->gadget->template->load('Open.html');
     $tpl->SetBlock('note');
     $tpl->SetVariable('id', $id);
     $tpl->SetVariable('note_title', $note['title']);
     $tpl->SetVariable('note_content', $this->gadget->ParseText($note['content'], 'Notepad'));
     // Actions
     if ($note['user'] == $user) {
         $tpl->SetBlock('note/actions');
         $tpl->SetVariable('lbl_edit', _t('GLOBAL_EDIT'));
         $tpl->SetVariable('lbl_share', _t('NOTEPAD_SHARE'));
         $tpl->SetVariable('lbl_delete', _t('GLOBAL_DELETE'));
         $tpl->SetVariable('confirmDelete', _t('NOTEPAD_WARNING_DELETE_NOTE'));
         $tpl->SetVariable('notepad_url', $this->gadget->urlMap('Notepad'));
         $tpl->SetVariable('url_edit', $this->gadget->urlMap('EditNote', array('id' => $id)));
         $tpl->SetVariable('url_share', $this->gadget->urlMap('ShareNote', array('id' => $id)));
         $tpl->ParseBlock('note/actions');
     }
     $tpl->ParseBlock('note');
     return $tpl->Get();
 }
示例#4
0
 /**
  * Download post attachment
  *
  * @access  public
  * @return  string   Requested file content or HTML error page
  */
 function Attachment()
 {
     $rqst = jaws()->request->fetch(array('fid', 'tid', 'pid', 'attach'), 'get');
     $pModel = $this->gadget->model->load('Posts');
     $post = $pModel->GetPost($rqst['pid'], $rqst['tid'], $rqst['fid']);
     if (Jaws_Error::IsError($post)) {
         $this->SetActionMode('Attachment', 'normal', 'standalone');
         return Jaws_HTTPError::Get(500);
     }
     $aModel = $this->gadget->model->load('Attachments');
     $attachment = $aModel->GetAttachmentInfo($rqst['attach']);
     if (Jaws_Error::IsError($attachment)) {
         $this->SetActionMode('Attachment', 'normal', 'standalone');
         return Jaws_HTTPError::Get(500);
     }
     if (!empty($attachment)) {
         $filepath = JAWS_DATA . 'forums/' . $attachment['filename'];
         if (file_exists($filepath)) {
             // increase download hits
             $result = $aModel->HitAttachmentDownload($rqst['attach']);
             if (Jaws_Error::IsError($result)) {
                 // do nothing
             }
             if (Jaws_Utils::Download($filepath, $attachment['title'])) {
                 return;
             }
             $this->SetActionMode('Attachment', 'normal', 'standalone');
             return Jaws_HTTPError::Get(500);
         }
     }
     $this->SetActionMode('Attachment', 'normal', 'standalone');
     return Jaws_HTTPError::Get(404);
 }
示例#5
0
文件: Ajax.php 项目: juniortux/jaws
 /**
  * Updates properties
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function UpdateProperties()
 {
     @(list($format) = jaws()->request->fetchAll('post'));
     $modelServerTime = $this->gadget->model->loadAdmin('Properties');
     $modelServerTime->UpdateProperties($format);
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#6
0
文件: Delete.php 项目: Dulciane/jaws
 /**
  * Deletes passed note(s)
  *
  * @access  public
  * @return  mixed   Response array
  */
 function DeleteNote()
 {
     $id_set = jaws()->request->fetch('id_set');
     $id_set = explode(',', $id_set);
     if (empty($id_set)) {
         return $GLOBALS['app']->Session->GetResponse(_t('NOTEPAD_ERROR_NOTE_DELETE'), RESPONSE_ERROR);
     }
     // Verify notes & user
     $model = $this->gadget->model->load('Notepad');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $verified_nodes = $model->CheckNotes($id_set, $user);
     if (Jaws_Error::IsError($verified_nodes)) {
         return $GLOBALS['app']->Session->GetResponse(_t('NOTEPAD_ERROR_NOTE_DELETE'), RESPONSE_ERROR);
     }
     // No notes was verified
     if (empty($verified_nodes)) {
         return $GLOBALS['app']->Session->GetResponse(_t('NOTEPAD_ERROR_NO_PERMISSION'), RESPONSE_ERROR);
     }
     // Delete notes
     $res = $model->Delete($verified_nodes);
     if (Jaws_Error::IsError($res)) {
         return $GLOBALS['app']->Session->GetResponse(_t('NOTEPAD_ERROR_NOTE_DELETE'), RESPONSE_ERROR);
     }
     if (count($id_set) !== count($verified_nodes)) {
         $msg = _t('NOTEPAD_WARNING_DELETE_NOTES_FAILED');
         // FIXME: we are creating response twice
         $GLOBALS['app']->Session->PushResponse($msg, 'Notepad.Response', RESPONSE_WARNING);
         return $GLOBALS['app']->Session->GetResponse($msg, RESPONSE_WARNING);
     }
     $msg = count($id_set) === 1 ? _t('NOTEPAD_NOTICE_NOTE_DELETED') : _t('NOTEPAD_NOTICE_NOTES_DELETED');
     $GLOBALS['app']->Session->PushResponse($msg, 'Notepad.Response');
     return $GLOBALS['app']->Session->GetResponse($msg);
 }
示例#7
0
文件: Ajax.php 项目: Dulciane/jaws
 /**
  * Updates searchable gadgets
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function SaveChanges()
 {
     $gadgets = jaws()->request->fetchAll('post');
     $model = $this->gadget->model->loadAdmin('Settings');
     $model->SetSearchableGadgets($gadgets);
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#8
0
文件: Update.php 项目: Dulciane/jaws
 /**
  * Updates note
  *
  * @access  public
  * @return  array   Response array
  */
 function UpdateNote()
 {
     $data = jaws()->request->fetch(array('id', 'title', 'content'), 'post');
     if (empty($data['id']) || empty($data['title']) || empty($data['content'])) {
         $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_INCOMPLETE_DATA'), 'Notepad.Response', RESPONSE_ERROR, $data);
         Jaws_Header::Referrer();
     }
     // Validate note
     $model = $this->gadget->model->load('Notepad');
     $id = (int) $data['id'];
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $note = $model->GetNote($id, $user);
     if (Jaws_Error::IsError($note)) {
         $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_RETRIEVING_DATA'), 'Notepad.Response', RESPONSE_ERROR);
         Jaws_Header::Referrer();
     }
     // Verify owner
     if ($note['user'] != $user) {
         $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NO_PERMISSION'), 'Notepad.Response', RESPONSE_ERROR);
         Jaws_Header::Referrer();
     }
     $data['title'] = Jaws_XSS::defilter($data['title']);
     $data['content'] = Jaws_XSS::defilter($data['content']);
     $result = $model->Update($id, $data);
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NOTE_UPDATE'), 'Notepad.Response', RESPONSE_ERROR, $data);
         Jaws_Header::Referrer();
     }
     $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_NOTICE_NOTE_UPDATED'), 'Notepad.Response');
     Jaws_Header::Location($this->gadget->urlMap('Notepad'));
 }
示例#9
0
 /**
  * Pingback function
  *
  * @access  public
  */
 function Pingback()
 {
     if ($this->gadget->registry->fetch('pingback') == 'true') {
         $pback = Jaws_Pingback::getInstance();
         $response = $pback->listen();
         if (is_array($response)) {
             //Load model
             $model = $this->gadget->model->load('Posts');
             //We need to parse the target URI to get the post ID
             $GLOBALS['app']->Map->Parse($response['targetURI']);
             //pingbacks come from POST but JawsURL maps everything on get (that how Maps work)
             $postID = jaws()->request->fetch('id', 'get');
             if (empty($postID)) {
                 return;
             }
             $entry = $model->GetEntry($postID, true);
             if (!Jaws_Error::IsError($entry)) {
                 $title = '';
                 $content = '';
                 $response['title'] = strip_tags($response['title']);
                 if (empty($response['title'])) {
                     if (empty($entry['title'])) {
                         $title = _t('GLOBAL_RE') . _t('BLOG_PINGBACK_TITLE', $entry['title']);
                         $content = _t('BLOG_PINGBACK_DEFAULT_COMMENT', $entry['sourceURI']);
                     }
                 } else {
                     $comesFrom = '<a href="' . $response['sourceURI'] . '">' . $response['title'] . '</a>';
                     $content = _t('BLOG_PINGBACK_COMMENT', $comesFrom);
                     $title = _t('GLOBAL_RE') . _t('BLOG_PINGBACK_TITLE', $response['title']);
                 }
                 $model->SavePingback($postID, $response['sourceURI'], $response['targetURI'], $title, $content);
             }
         }
     }
 }
示例#10
0
文件: Ajax.php 项目: juniortux/jaws
 /**
  * Update the properties
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function UpdateProperties()
 {
     $this->gadget->CheckPermission('UpdateProperties');
     @(list($limit, $max_strlen, $authority) = jaws()->request->fetchAll('post'));
     $model = $this->gadget->model->loadAdmin('Settings');
     $model->UpdateProperties($limit, $max_strlen, $authority == 'true');
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#11
0
文件: Ajax.php 项目: juniortux/jaws
 /**
  * Gets all entries/records for datagrid
  *
  * @access  public
  * @return  array   List of visits
  */
 function getData()
 {
     @(list($offset) = jaws()->request->fetchAll('post'));
     if (!is_numeric($offset)) {
         $offset = 0;
     }
     $gadget = $this->gadget->action->loadAdmin('VisitCounter');
     return $gadget->GetVisits($offset);
 }
示例#12
0
文件: 09To100.php 项目: Dulciane/jaws
 /**
  * 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;
 }
示例#13
0
文件: Ajax.php 项目: juniortux/jaws
 /**
  * Sets language data
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function SetLangData()
 {
     @(list($component, $langTo, $data) = jaws()->request->fetchAll('post'));
     $data = jaws()->request->fetch('2:array', 'post', false);
     $component = explode('|', $component);
     $component[1] = preg_replace("/[^A-Za-z0-9]/", '', $component[1]);
     $model = $this->gadget->model->loadAdmin('Languages');
     $model->SetLangData($component[1], (int) $component[0], $langTo, $data);
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#14
0
 /**
  * Build and export data with VCard format
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function VCardBuild()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     require_once JAWS_PATH . 'gadgets/Addressbook/vCard.php';
     $model = $this->gadget->model->load('AddressBook');
     $agModel = $this->gadget->model->load('AddressBookGroup');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $ids = jaws()->request->fetch('adr:array');
     $link = $this->gadget->urlMap('AddressBook', array(), true);
     if (empty($ids)) {
         Jaws_Header::Location($link);
         return false;
     }
     $addressItems = $model->GetAddresses($ids, $user);
     if (Jaws_Error::IsError($addressItems) || empty($addressItems)) {
         return Jaws_HTTPError::Get(404);
     }
     $result = '';
     $nVCard = array('LastName', 'FirstName', 'AdditionalNames', 'Prefixes', 'Suffixes');
     foreach ($addressItems as $addressItem) {
         $vCard = new vCard();
         $names = explode(';', $addressItem['name']);
         foreach ($names as $key => $name) {
             $vCard->n($name, $nVCard[$key]);
         }
         $vCard->fn($names[3] . (trim($names[3]) == '' ? '' : ' ') . $names[1] . (trim($names[1]) == '' ? '' : ' ') . $names[0]);
         $vCard->nickname($addressItem['nickname']);
         $vCard->title($addressItem['title']);
         $adrGroups = $agModel->GetGroupNames($addressItem['address_id'], $user);
         $vCard->categories(implode(',', $adrGroups));
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_home'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_work'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_other'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_home'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_work'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_other'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_home'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_work'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_other'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'url', $addressItem['url'], null, '\\n');
         $vCard->note($addressItem['notes']);
         $result = $result . $vCard;
     }
     header("Content-Disposition: attachment; filename=\"" . 'address.vcf' . "\"");
     header("Content-type: application/csv");
     header("Content-Length: " . strlen($result));
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Connection: close");
     echo $result;
     exit;
 }
示例#15
0
 /**
  * Check if a captcha value is valid
  *
  * @access  public
  * @return  bool    return validity of captcha value
  */
 function check()
 {
     $recaptcha = jaws()->request->fetch(array('recaptcha_challenge_field', 'recaptcha_response_field'), 'post');
     if ($recaptcha['recaptcha_response_field']) {
         $privatekey = $GLOBALS['app']->Registry->fetch('reCAPTCHA_private_key', 'Policy');
         $objReCaptcha = new ReCaptcha();
         $objReCaptcha->recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha['recaptcha_challenge_field'], $recaptcha['recaptcha_response_field']);
         return $objReCaptcha->is_valid;
     }
     return false;
 }
示例#16
0
文件: Robots.php 项目: juniortux/jaws
 /**
  * Update Robots content
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function UpdateRobots()
 {
     $robots = jaws()->request->fetch('robots', 'post');
     $result = $this->gadget->registry->update('robots.txt', $robots);
     if (!$result || Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('SITEMAP_ERROR_ROBOTS_NOT_SAVED'), RESPONSE_ERROR);
     } else {
         $GLOBALS['app']->Session->PushLastResponse(_t('SITEMAP_ROBOTS_SAVED'), RESPONSE_NOTICE);
     }
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#17
0
 /**
  * Update Settings
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function SaveSettings()
 {
     $this->gadget->CheckPermission('Settings');
     $configuration = jaws()->request->fetch('gadgets_drivers:array', 'post');
     $res = $this->gadget->registry->update('configuration', serialize($configuration));
     if (Jaws_Error::isError($res)) {
         return $GLOBALS['app']->Session->GetResponse($res->getMessage(), RESPONSE_ERROR);
     } else {
         return $GLOBALS['app']->Session->GetResponse(_t('NOTIFICATION_SETTINGS_UPDATED'), RESPONSE_NOTICE);
     }
 }
示例#18
0
 /**
  * Uploads attachment file
  *
  * @access  public
  * @return  string  javascript script segment
  */
 function UploadFile()
 {
     $file_num = jaws()->request->fetch('attachment_number', 'post');
     $file = Jaws_Utils::UploadFiles($_FILES, Jaws_Utils::upload_tmp_dir(), '', null);
     if (Jaws_Error::IsError($file)) {
         $response = array('type' => 'error', 'message' => $file->getMessage());
     } else {
         $response = array('type' => 'notice', 'file_info' => array('title' => $file['attachment' . $file_num][0]['user_filename'], 'filename' => $file['attachment' . $file_num][0]['host_filename'], 'filesize_format' => Jaws_Utils::FormatSize($file['attachment' . $file_num][0]['host_filesize']), 'filesize' => $file['attachment' . $file_num][0]['host_filesize'], 'filetype' => $file['attachment' . $file_num][0]['host_filetype']));
     }
     $response = Jaws_UTF8::json_encode($response);
     return "<script type='text/javascript'>parent.onUpload({$response});</script>";
 }
示例#19
0
文件: Feeds.php 项目: Dulciane/jaws
 /**
  * Displays an Atom feed for a given blog category
  *
  * @access  public
  * @return  string  xml with Atom feed
  */
 function ShowAtomCategory()
 {
     header('Content-type: application/atom+xml; charset=utf-8');
     $id = jaws()->request->fetch('id', 'get');
     $id = Jaws_XSS::defilter($id);
     $model = $this->gadget->model->load('Feeds');
     $xml = $model->MakeCategoryAtom($id);
     if (Jaws_Error::IsError($xml)) {
         return '';
     }
     return $xml;
 }
示例#20
0
文件: Report.php 项目: Dulciane/jaws
 /**
  * Builds the upgrader page.
  *
  * @access  public
  * @return  string A block of valid XHTML to display the status of old/current jaws versions
  */
 function Display()
 {
     include_once JAWS_PATH . 'include/Jaws/DB.php';
     $objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
     require_once JAWS_PATH . 'include/Jaws.php';
     $GLOBALS['app'] = jaws();
     if (!isset($_SESSION['upgrade']['InstalledVersion'])) {
         $_SESSION['upgrade']['InstalledVersion'] = $GLOBALS['app']->Registry->Init();
     }
     $GLOBALS['app']->loadPreferences(array('language' => $_SESSION['upgrade']['language']), false);
     $supportedversions = array(array('version' => '1.2.0', 'stage' => '9'), array('version' => '1.1.1', 'stage' => '8'), array('version' => '1.1.0', 'stage' => '7'), array('version' => '1.0.0', 'stage' => '6'), array('version' => '0.9.3', 'stage' => null), array('version' => '0.9.2', 'stage' => null), array('version' => '0.9.1', 'stage' => null), array('version' => '0.9.0', 'stage' => null));
     _log(JAWS_LOG_DEBUG, "Checking/Reporting previous missed installations");
     $tpl = new Jaws_Template(false, false);
     $tpl->Load('display.html', 'stages/Report/templates');
     $tpl->SetBlock('Report');
     $tpl->setVariable('lbl_info', _t('UPGRADE_REPORT_INFO', JAWS_VERSION));
     $tpl->setVariable('lbl_message', _t('UPGRADE_REPORT_MESSAGE'));
     $tpl->SetVariable('next', _t('GLOBAL_NEXT'));
     $versions_to_upgrade = 0;
     $_SESSION['upgrade']['stagedVersions'] = array();
     foreach ($supportedversions as $supported) {
         $tpl->SetBlock('Report/versions');
         $tpl->SetBlock('Report/versions/version');
         $tpl->SetVariable('description', $supported['version']);
         $_SESSION['upgrade']['versions'][$supported['version']] = array('version' => $supported['version'], 'stage' => $supported['stage'], 'file' => isset($supported['file']) ? $supported['file'] : '', 'script' => isset($supported['script']) ? $supported['script'] : '');
         if (version_compare($supported['version'], $_SESSION['upgrade']['InstalledVersion'], '<=')) {
             if ($supported['version'] == JAWS_VERSION) {
                 $tpl->SetVariable('status', _t('UPGRADE_REPORT_NO_NEED_CURRENT'));
                 _log(JAWS_LOG_DEBUG, $supported['version'] . " does not requires upgrade(is current)");
             } else {
                 $tpl->SetVariable('status', _t('UPGRADE_REPORT_NO_NEED'));
                 _log(JAWS_LOG_DEBUG, $supported['version'] . " does not requires upgrade");
             }
             $_SESSION['upgrade']['versions'][$supported['version']]['status'] = true;
         } else {
             $tpl->SetVariable('status', _t('UPGRADE_REPORT_NEED'));
             $_SESSION['upgrade']['versions'][$supported['version']]['status'] = false;
             $versions_to_upgrade++;
             _log(JAWS_LOG_DEBUG, $supported['version'] . " requires upgrade");
             $_SESSION['upgrade']['versions'][$supported['version']]['status'] = false;
         }
         if (!is_null($supported['stage'])) {
             $_SESSION['upgrade']['stagedVersions'][] = $supported['version'];
         }
         $tpl->ParseBlock('Report/versions/version');
         $tpl->ParseBlock('Report/versions');
     }
     $_SESSION['upgrade']['versions_to_upgrade'] = $versions_to_upgrade;
     arsort($_SESSION['upgrade']['versions']);
     krsort($_SESSION['upgrade']['stagedVersions']);
     $tpl->ParseBlock('Report');
     return $tpl->Get();
 }
示例#21
0
文件: Ajax.php 项目: juniortux/jaws
 /**
  * Delete a theme
  *
  * @access   public
  * @internal param  string  $theme  Name of the theme
  * @return   array  Response array (notice or error)
  */
 function DeleteTheme()
 {
     @(list($theme) = jaws()->request->fetchAll('post'));
     $gadget = $this->gadget->action->loadAdmin('Themes');
     $res = $gadget->DeleteTheme($theme);
     if (Jaws_Error::IsError($res) || !$res) {
         $GLOBALS['app']->Session->PushLastResponse(_t('TMS_ERROR_CANT_DELETE_THEME'), RESPONSE_ERROR);
     } else {
         $GLOBALS['app']->Session->PushLastResponse(_t('TMS_RESPONSE_THEME_DELETED'), RESPONSE_NOTICE);
     }
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#22
0
 /**
  * Update Settings
  *
  * @access  public
  * @return  array   Response array (notice or error)
  */
 function SaveSettings()
 {
     $this->gadget->CheckPermission('ManageSettings');
     $settings = jaws()->request->fetchAll('post');
     $model = $this->gadget->model->loadAdmin('Settings');
     $res = $model->SaveSettings($settings);
     if (Jaws_Error::IsError($res)) {
         $GLOBALS['app']->Session->PushLastResponse($res->GetMessage(), RESPONSE_ERROR);
     } else {
         $GLOBALS['app']->Session->PushLastResponse(_t('LOGS_SETTINGS_UPDATED'), RESPONSE_NOTICE);
     }
     return $GLOBALS['app']->Session->PopLastResponse();
 }
示例#23
0
文件: Ajax.php 项目: Dulciane/jaws
 /**
  * Add gadget to layout 
  *
  * @access  public
  * @return  array   Details of the added gadget/action
  */
 function AddGadget()
 {
     $res = array();
     $id = false;
     @(list($gadget, $action, $params, $index_layout, $user) = jaws()->request->fetchAll('post'));
     $params = jaws()->request->fetch('2:array', 'post');
     $model = $this->gadget->model->loadAdmin('Elements');
     $actions = $model->GetGadgetLayoutActions($gadget, true);
     if (isset($actions[$action])) {
         $user = (int) $user;
         $loggedUser = (int) $GLOBALS['app']->Session->GetAttribute('user');
         if ($user == 0 && $this->gadget->GetPermission('ManageLayout') || $user == $loggedUser && $GLOBALS['app']->Session->GetPermission('Users', 'ManageDashboard')) {
             $id = $model->NewElement($index_layout, 'main', $gadget, $action, $params, $actions[$action]['file'], '', $user);
             $id = Jaws_Error::IsError($id) ? false : $id;
         }
     }
     if ($id === false) {
         $GLOBALS['app']->Session->PushLastResponse(_t('LAYOUT_ERROR_ELEMENT_ADDED'), RESPONSE_ERROR);
         $res['success'] = false;
     } else {
         $el = $model->GetElement($id, $user);
         $GLOBALS['app']->Session->PushLastResponse(_t('LAYOUT_ELEMENT_ADDED'), RESPONSE_NOTICE);
         $info = Jaws_Gadget::getInstance($gadget);
         $el['tname'] = $info->title;
         if (isset($actions[$action])) {
             $el['taction'] = $actions[$action]['name'];
             $el['tactiondesc'] = $actions[$action]['desc'];
         } else {
             $el['taction'] = _t('LAYOUT_ACTION');
             $el['tactiondesc'] = '';
         }
         $el['eaid'] = 'ea' . $id;
         $url_ea = BASE_SCRIPT . '?gadget=Layout&action=ElementAction&id=' . $id . '&user='******'eaonclick'] = "elementAction('{$url_ea}');";
         unset($info);
         $el['icon'] = 'gadgets/' . $gadget . '/Resources/images/logo.png';
         $el['delete'] = "deleteElement('{$id}');";
         $el['deleteimg'] = 'gadgets/Layout/Resources/images/delete-item.gif';
         $el['dwalways'] = _t('GLOBAL_ALWAYS');
         $el['dwtitle'] = _t('LAYOUT_CHANGE_DW');
         $el['dwdisplay'] = _t('LAYOUT_DISPLAY_IN') . ': ';
         $el['dwid'] = 'dw' . $id;
         $url_dw = BASE_SCRIPT . '?gadget=Layout&action=DisplayWhen&id=' . $id . '&user='******'dwonclick'] = "displayWhen('{$url_dw}');";
         $res = $el;
         $res['success'] = true;
     }
     $res['message'] = $GLOBALS['app']->Session->PopLastResponse();
     return $res;
 }
示例#24
0
 /**
  * Displays list of user's posts ordered by date
  *
  * @access  public
  * @return  string  XHTML content
  */
 function UserPosts()
 {
     $rqst = jaws()->request->fetch(array('user', 'page'), 'get');
     $user = $rqst['user'];
     if (empty($user)) {
         return false;
     }
     $userModel = new Jaws_User();
     $user = $userModel->GetUser($user);
     $page = empty($rqst['page']) ? 1 : (int) $rqst['page'];
     // posts per page
     $posts_limit = $this->gadget->registry->fetch('posts_limit');
     $posts_limit = empty($posts_limit) ? 10 : (int) $posts_limit;
     $tpl = $this->gadget->template->load('UserPosts.html');
     $pModel = $this->gadget->model->load('Posts');
     $posts = $pModel->GetUserPosts($user['id'], $posts_limit, ($page - 1) * $posts_limit);
     if (!Jaws_Error::IsError($posts)) {
         // date format
         $date_format = $this->gadget->registry->fetch('date_format');
         $date_format = empty($date_format) ? 'DN d MN Y' : $date_format;
         $max_size = 128;
         $objDate = Jaws_Date::getInstance();
         $tpl->SetBlock('userposts');
         // title
         $tpl->SetVariable('action_title', _t('FORUMS_USER_POSTS', $user['nickname']));
         foreach ($posts as $post) {
             $tpl->SetBlock('userposts/post');
             // topic subject/link
             $tpl->SetVariable('lbl_topic', $post['subject']);
             $tpl->SetVariable('url_topic', $this->gadget->urlMap('Posts', array('fid' => $post['fid'], 'tid' => $post['tid'])));
             // post author
             $tpl->SetVariable('insert_time', $objDate->Format($post['insert_time'], $date_format));
             $tpl->SetVariable('insert_time_iso', $objDate->ToISO((int) $post['insert_time']));
             $tpl->SetVariable('message', Jaws_UTF8::substr(strip_tags($this->gadget->ParseText($post['message'], 'Forums', 'index')), 0, $max_size) . ' ...');
             // post url
             $url_params = array('fid' => $post['fid'], 'tid' => $post['tid']);
             $last_post_page = floor(($post['topic_replies'] - 1) / $posts_limit) + 1;
             if ($last_post_page > 1) {
                 $url_params['page'] = $last_post_page;
             }
             $tpl->SetVariable('url_post', $this->gadget->urlMap('Posts', $url_params));
             $tpl->ParseBlock('userposts/post');
         }
         $post_counts = $pModel->GetUserPostsCount($user['id']);
         // page navigation
         $this->GetPagesNavigation($tpl, 'userposts', $page, $posts_limit, $post_counts, _t('FORUMS_POSTS_COUNT', $post_counts), 'UserPosts', array('user' => $user['username']));
         $tpl->ParseBlock('userposts');
     }
     return $tpl->Get();
 }
示例#25
0
 /**
  * Displays a concrete category
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewCategory()
 {
     $model = $this->gadget->model->load('Question');
     $cat_id = jaws()->request->fetch('id', 'get');
     $cat_id = Jaws_XSS::defilter($cat_id);
     $this->SetTitle($this->gadget->title . ' - ' . _t('FAQ_CATEGORIES'));
     $questions = $model->GetQuestions($cat_id, true);
     if (is_array($questions) && count($questions) > 0) {
         $tpl = $this->gadget->template->load('Category.html');
         foreach ($questions as $cat) {
             $tpl->SetBlock('faq_category');
             $tpl->SetVariable('title', _t('FAQ_TITLE'));
             $tpl->SetVariable('category', $cat['category']);
             $tpl->SetVariable('description', $this->gadget->ParseText($cat['description']));
             if (isset($cat['questions']) && is_array($cat['questions'])) {
                 $qPos = 0;
             }
             foreach ($cat['questions'] as $q) {
                 $qPos++;
                 $tpl->SetBlock('faq_category/question');
                 $tpl->SetVariable('id', $q['id']);
                 $tpl->SetVariable('pos', $qPos);
                 $tpl->SetVariable('question', $q['question'], 'Faq', false);
                 $tpl->SetVariable('url', $this->gadget->urlMap('ViewCategory', array('id' => $cat_id)));
                 $tpl->ParseBlock('faq_category/question');
             }
             if (isset($cat['questions']) && is_array($cat['questions'])) {
                 $qPos = 0;
             }
             foreach ($cat['questions'] as $q) {
                 $qPos++;
                 $tpl->SetBlock('faq_category/item');
                 $tpl->SetVariable('top_label', _t('FAQ_GO_TO_TOP'));
                 $tpl->SetVariable('top_link', $this->gadget->urlMap('ViewCategory', array('id' => $cat_id)) . '#topfaq');
                 $tpl->SetVariable('id', $q['id']);
                 $tpl->SetVariable('pos', $qPos);
                 $qid = empty($q['fast_url']) ? $q['id'] : $q['fast_url'];
                 $tpl->SetVariable('url', $this->gadget->urlMap('ViewQuestion', array('id' => $qid)));
                 $tpl->SetVariable('question', $q['question']);
                 $tpl->SetVariable('answer', $this->gadget->ParseText($q['answer']));
                 $tpl->ParseBlock('faq_category/item');
             }
             $tpl->ParseBlock('faq_category');
         }
         return $tpl->Get();
     }
     // FIXME: We should return something like "No questions found"
     return '';
 }
示例#26
0
文件: Search.php 项目: uda/jaws
 /**
  * Builds the advanced search box
  *
  * @access  public
  * @return  string  XHTML search box
  */
 function AdvancedBox()
 {
     $post = jaws()->request->fetch(array('all', 'exact', 'least', 'exclude', 'gadgets', 'date'), 'get');
     $post['all'] = Jaws_XSS::defilter($post['all']);
     $tpl = $this->gadget->template->load('Search.html');
     $tpl->SetBlock('AdvancedBox');
     $tpl->SetVariable('base_script', BASE_SCRIPT);
     $tpl->SetVariable('title', $this->gadget->title);
     $tpl->SetVariable('lbl_word_filter', _t('SEARCH_WORD_FILTER'));
     $tpl->SetVariable('lbl_all', _t('SEARCH_WORD_FILTER_ALL'));
     $tpl->SetVariable('lbl_exact', _t('SEARCH_WORD_FILTER_EXACT'));
     $tpl->SetVariable('lbl_least', _t('SEARCH_WORD_FILTER_LEAST'));
     $tpl->SetVariable('lbl_exclude', _t('SEARCH_WORD_FILTER_EXCLUDE'));
     $tpl->SetVariable('lbl_data_filter', _t('SEARCH_DATA_FILTER'));
     $tpl->SetVariable('lbl_search_in', _t('SEARCH_SEARCH_IN'));
     $model = $this->gadget->model->load('Search');
     $options = $model->parseSearch($post, $searchable);
     $wordAll =& Piwi::CreateWidget('Entry', 'all', implode(' ', $options['all']));
     $wordExact =& Piwi::CreateWidget('Entry', 'exact', implode(' ', $options['exact']));
     $wordLeast =& Piwi::CreateWidget('Entry', 'least', implode(' ', $options['least']));
     $wordExclude =& Piwi::CreateWidget('Entry', 'exclude', implode(' ', $options['exclude']));
     $tpl->SetVariable('all', $wordAll->Get());
     $tpl->SetVariable('exclude', $wordExclude->Get());
     $tpl->SetVariable('least', $wordLeast->Get());
     $tpl->SetVariable('exact', $wordExact->Get());
     //Gadgets filter combo
     $gadgetList = $model->GetSearchableGadgets();
     $gSearchable = $this->gadget->registry->fetch('searchable_gadgets');
     $searchableGadgets = $gSearchable == '*' ? array_keys($gadgetList) : explode(', ', $gSearchable);
     $gchk =& Piwi::CreateWidget('Combo', 'gadgets');
     $gchk->addOption(_t('GLOBAL_ALL'), '');
     foreach ($searchableGadgets as $gadget) {
         $info = Jaws_Gadget::getInstance($gadget);
         if (Jaws_Error::IsError($info)) {
             continue;
         }
         $gchk->AddOption($info->title, $gadget);
     }
     $default = !is_null($post['gadgets']) ? $post['gadgets'] : '';
     $gchk->SetDefault($default);
     $tpl->SetVariable('gadgets_combo', $gchk->Get());
     //Search button
     $btnSearch =& Piwi::CreateWidget('Button', '', _t('SEARCH_BUTTON'));
     $btnSearch->SetID('btn_search');
     $btnSearch->SetSubmit(true);
     $tpl->SetVariable('btn_search', $btnSearch->Get());
     $tpl->ParseBlock('AdvancedBox');
     return $tpl->Get();
 }
示例#27
0
文件: Link.php 项目: Dulciane/jaws
 /**
  * Redirect to the URL and increase the clicks by one
  * 
  * @access  public
  */
 function Link()
 {
     $lid = jaws()->request->fetch('id', 'get');
     $lid = Jaws_XSS::defilter($lid);
     $model = $this->gadget->model->load('Links');
     $link = $model->GetLink($lid);
     if (!Jaws_Error::IsError($link) && !empty($link)) {
         $click = $model->Click($link['id']);
         if (!Jaws_Error::IsError($click)) {
             Jaws_Header::Location($link['url'], null, 301);
         }
     }
     // By default, on the errors stay in the main page
     Jaws_Header::Referrer();
 }
示例#28
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);
     }
 }
示例#29
0
 /**
  * Builds year view UI
  *
  * @access  public
  * @return  string  XHTML UI
  */
 function ViewYear()
 {
     $jdate = Jaws_Date::getInstance();
     $year = jaws()->request->fetch('year', 'get');
     $year = empty($year) ? (int) $jdate->Format(time(), 'Y') : (int) $year;
     $this->AjaxMe('site_script.js');
     $tpl = $this->gadget->template->load('ViewYear.html');
     $tpl->SetBlock('year');
     // Menubar
     $action = $this->gadget->action->load('Menubar');
     $tpl->SetVariable('menubar', $action->Menubar('Events'));
     // Current year
     $tpl->SetVariable('title', $year);
     $this->SetTitle($year . ' - ' . _t('EVENTSCALENDAR_EVENTS'));
     // Previous year
     $prevURL = $this->gadget->urlMap('ViewYear', array('year' => $year - 1));
     $tpl->SetVariable('prev_url', $prevURL);
     $tpl->SetVariable('prev', $year - 1);
     // Next year
     $nextURL = $this->gadget->urlMap('ViewYear', array('year' => $year + 1));
     $tpl->SetVariable('next_url', $nextURL);
     $tpl->SetVariable('next', $year + 1);
     // Fetch events
     $model = $this->gadget->model->load('Calendar');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $events = $model->GetYearEvents($user, null, null, $year);
     if (Jaws_Error::IsError($events)) {
         $events = array();
     }
     // Month's
     for ($s = 0; $s <= 3; $s++) {
         $tpl->SetBlock('year/season');
         for ($i = 1; $i <= 3; $i++) {
             $m = $i + $s * 3;
             $date = $jdate->ToBaseDate($year, $m);
             $month = $jdate->Format($date['timestamp'], 'MN');
             $tpl->SetBlock('year/season/month');
             $tpl->SetVariable('month', $month);
             $url = $this->gadget->urlMap('ViewMonth', array('year' => $year, 'month' => $m));
             $tpl->SetVariable('month_url', $url);
             $tpl->SetVariable('events_count', $events[$m]);
             $tpl->ParseBlock('year/season/month');
         }
         $tpl->ParseBlock('year/season');
     }
     $tpl->ParseBlock('year');
     return $tpl->Get();
 }
示例#30
0
 /**
  * Builds the upgrader page.
  *
  * @access  public
  * @return  string A block of valid XHTML to display an introduction and form.
  */
 function Display()
 {
     require_once JAWS_PATH . 'include/Jaws.php';
     $GLOBALS['app'] = jaws();
     $GLOBALS['app']->loadPreferences(array('language' => $_SESSION['upgrade']['language']), false);
     $tpl = new Jaws_Template(false, false);
     $tpl->Load('display.html', 'stages/Finished/templates');
     $tpl->SetBlock('Finished');
     $base_url = $GLOBALS['app']->getSiteURL();
     $tpl->setVariable('lbl_info', _t('UPGRADE_FINISH_INFO'));
     $tpl->setVariable('lbl_choices', _t('UPGRADE_FINISH_CHOICES', "{$base_url}/", "{$base_url}/admin.php"));
     $tpl->setVariable('lbl_thanks', _t('UPGRADE_FINISH_THANKS'));
     $tpl->SetVariable('move_log', _t('UPGRADE_FINISH_MOVE_LOG'));
     $tpl->ParseBlock('Finished');
     return $tpl->Get();
 }