本文整理汇总了PHP中jaws函数的典型用法代码示例。如果您正苦于以下问题:PHP jaws函数的具体用法?PHP jaws怎么用?PHP jaws使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jaws函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ViewPage
/**
* 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: ViewTerm
/**
* 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: OpenNote
/**
* 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: Attachment
/**
* 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: UpdateProperties
/**
* 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: DeleteNote
/**
* 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: SaveChanges
/**
* 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: UpdateNote
/**
* 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: Pingback
/**
* 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: UpdateProperties
/**
* 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: getData
/**
* 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: Run
/**
* Does any actions required to finish the stage, such as DB queries.
*
* @access public
* @return bool|Jaws_Error Either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function Run()
{
// Connect to database
require_once JAWS_PATH . 'include/Jaws/DB.php';
$objDatabase = Jaws_DB::getInstance('default', $_SESSION['upgrade']['Database']);
if (Jaws_Error::IsError($objDatabase)) {
_log(JAWS_LOG_DEBUG, "There was a problem connecting to the database, please check the details and try again");
return new Jaws_Error(_t('UPGRADE_DB_RESPONSE_CONNECT_FAILED'), 0, JAWS_ERROR_WARNING);
}
// upgrade core database schema
$old_schema = JAWS_PATH . 'upgrade/Resources/schema/0.9.0.xml';
$new_schema = JAWS_PATH . 'upgrade/Resources/schema/schema.xml';
if (!file_exists($old_schema)) {
return new Jaws_Error(_t('GLOBAL_ERROR_SQLFILE_NOT_EXISTS', '0.9.0.xml'), 0, JAWS_ERROR_ERROR);
}
if (!file_exists($new_schema)) {
return new Jaws_Error(_t('GLOBAL_ERROR_SQLFILE_NOT_EXISTS', 'schema.xml'), 0, JAWS_ERROR_ERROR);
}
_log(JAWS_LOG_DEBUG, "Upgrading core schema");
$result = Jaws_DB::getInstance()->installSchema($new_schema, '', $old_schema);
if (Jaws_Error::isError($result)) {
_log(JAWS_LOG_ERROR, $result->getMessage());
if ($result->getCode() !== MDB2_ERROR_ALREADY_EXISTS) {
return new Jaws_Error($result->getMessage(), 0, JAWS_ERROR_ERROR);
}
}
// Create application
include_once JAWS_PATH . 'include/Jaws.php';
$GLOBALS['app'] = jaws();
$GLOBALS['app']->Registry->Init();
// Upgrading core gadgets
$gadgets = array('UrlMapper', 'Settings', 'ControlPanel', 'Policy', 'Layout', 'Users', 'Comments');
foreach ($gadgets as $gadget) {
$objGadget = Jaws_Gadget::getInstance($gadget);
if (Jaws_Error::IsError($objGadget)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading core gadget: " . $gadget);
return $objGadget;
}
$installer = $objGadget->installer->load();
if (Jaws_Error::IsError($installer)) {
_log(JAWS_LOG_DEBUG, "There was a problem loading installer of core gadget: {$gadget}");
return $installer;
}
if (Jaws_Gadget::IsGadgetInstalled($gadget)) {
$result = $installer->UpgradeGadget();
} else {
continue;
//$result = $installer->InstallGadget();
}
if (Jaws_Error::IsError($result)) {
_log(JAWS_LOG_DEBUG, "There was a problem installing/upgrading core gadget: {$gadget}");
return $result;
}
}
return true;
}
示例13: SetLangData
/**
* 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: VCardBuild
/**
* 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: check
/**
* 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;
}