本文整理汇总了PHP中Jaws_Error类的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Error类的具体用法?PHP Jaws_Error怎么用?PHP Jaws_Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Jaws_Error类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
/**
* Returns an array with the results of a search
*
* @access public
* @param string $pSql Prepared search(WHERE) SQL
* @return array An array of entries that matches a certain pattern
*/
function Execute($pSql = '')
{
$sql = '
SELECT
[id], [title], [description], [user_filename], [update_time]
FROM [[directory]]
WHERE
[hidden] = {hidden}
';
$sql .= ' AND ' . $pSql;
$sql .= ' ORDER BY id desc';
$params = array();
$params['hidden'] = false;
$types = array('text', 'text', 'text', 'integer');
$result = Jaws_DB::getInstance()->queryAll($sql, $params, $types);
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$files = array();
foreach ($result as $p) {
$file = array();
$file['title'] = $p['title'];
$file['url'] = $this->gadget->urlMap('Directory', array('id' => $p['id']));
$file['image'] = 'gadgets/Directory/Resources/images/logo.png';
$file['snippet'] = $p['description'];
$file['date'] = $p['update_time'];
$stamp = $p['update_time'];
$files[$stamp] = $file;
}
return $files;
}
示例2: GetSettings
/**
* Get registry settings for Phoo
*
* @access public
* @return mixed array with the settings or Jaws_Error on error
*/
function GetSettings()
{
$ret = array();
$ret['default_action'] = $this->gadget->registry->fetch('default_action');
$ret['resize_method'] = $this->gadget->registry->fetch('resize_method');
$ret['moblog_album'] = $this->gadget->registry->fetch('moblog_album');
$ret['moblog_limit'] = $this->gadget->registry->fetch('moblog_limit');
$ret['photoblog_album'] = $this->gadget->registry->fetch('photoblog_album');
$ret['photoblog_limit'] = $this->gadget->registry->fetch('photoblog_limit');
$ret['allow_comments'] = $this->gadget->registry->fetch('allow_comments');
$ret['published'] = $this->gadget->registry->fetch('published');
$ret['show_exif_info'] = $this->gadget->registry->fetch('show_exif_info');
$ret['keep_original'] = $this->gadget->registry->fetch('keep_original');
$ret['thumbnail_limit'] = $this->gadget->registry->fetch('thumbnail_limit');
$ret['comment_status'] = $this->gadget->registry->fetch('comment_status');
$ret['use_antispam'] = $this->gadget->registry->fetch('use_antispam');
$ret['albums_order_type'] = $this->gadget->registry->fetch('albums_order_type');
$ret['photos_order_type'] = $this->gadget->registry->fetch('photos_order_type');
foreach ($ret as $r) {
if (Jaws_Error::IsError($r)) {
if (isset($GLOBALS['app']->Session)) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_FETCH_SETTINGS'), RESPONSE_ERROR);
}
return new Jaws_Error(_t('PHOO_ERROR_CANT_FETCH_SETTINGS'));
}
}
return $ret;
}
示例3: image
/**
* Displays the captcha image
*
* @access public
* @param int $key Captcha key
* @return mixed Captcha raw image data
*/
function image($key)
{
$value = Jaws_Utils::RandomText();
$result = $this->update($key, $value);
if (Jaws_Error::IsError($result)) {
$value = '';
}
$bg = dirname(__FILE__) . '/resources/simple.bg.png';
$im = imagecreatefrompng($bg);
imagecolortransparent($im, imagecolorallocate($im, 255, 255, 255));
// Write it in a random position..
$darkgray = imagecolorallocate($im, 0x10, 0x70, 0x70);
$x = 5;
$y = 20;
$text_length = strlen($value);
for ($i = 0; $i < $text_length; $i++) {
$fnt = rand(7, 10);
$y = rand(6, 10);
imagestring($im, $fnt, $x, $y, $value[$i], $darkgray);
$x = $x + rand(15, 25);
}
header("Content-Type: image/png");
ob_start();
imagepng($im);
$content = ob_get_contents();
ob_end_clean();
imagedestroy($im);
return $content;
}
示例4: Auth
/**
* Authenticate user/password
*
* @access public
* @param string $user User's name or email
* @param string $password User's password
* @return mixed Array of user's information otherwise Jaws_Error
*/
function Auth($user, $password)
{
if (!function_exists('imap_open')) {
return Jaws_Error::raiseError('Undefined function imap_open()', __FUNCTION__);
}
$mbox = @imap_open('{' . $this->_Server . ':' . $this->_Port . ($this->_SSL ? '/imap/ssl' : '') . '}INBOX', $user, $password);
if ($mbox) {
@imap_close($mbox);
$result = array();
$result['id'] = strtolower('imap:' . $user);
$result['internal'] = false;
$result['username'] = $user;
$result['superadmin'] = false;
$result['internal'] = false;
$result['groups'] = array();
$result['nickname'] = $user;
$result['concurrents'] = 0;
$result['email'] = '';
$result['url'] = '';
$result['avatar'] = 'gadgets/Users/Resources/images/photo48px.png';
$result['language'] = '';
$result['theme'] = '';
$result['editor'] = '';
$result['timezone'] = null;
return $result;
}
return Jaws_Error::raiseError(_t('GLOBAL_ERROR_LOGIN_WRONG'), __FUNCTION__);
}
示例5: Execute
/**
* Returns an array with the results of a search
*
* @access public
* @param string $pSql Prepared search (WHERE) SQL
* @return array An array of entries that matches a certain pattern
*/
function Execute($pSql = '')
{
// TODO: must be converted to Jaws_ORM
$sql = '
SELECT
[id], [title], [contents], [updatetime]
FROM [[blocks]]
';
$sql .= ' WHERE ' . $pSql;
$sql .= ' ORDER BY [createtime] desc';
$result = Jaws_DB::getInstance()->queryAll($sql);
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$blocks = array();
foreach ($result as $r) {
$block = array();
$block['title'] = $r['title'];
$block['url'] = $this->gadget->urlMap('Block', array('id' => $r['id']));
$block['image'] = 'gadgets/Blocks/Resources/images/logo.png';
$block['snippet'] = $r['contents'];
$block['date'] = $date->ToISO($r['updatetime']);
$blocks[] = $block;
}
return $blocks;
}
示例6: Execute
/**
* Returns an array of the search results
*
* @access public
* @param string $pSql Prepared search(WHERE) SQL
* @return array Array of entries match a certain pattern
*/
function Execute($pSql = '')
{
$sql = '
SELECT
[id], [title], [quotation], [updatetime]
FROM [[quotes]]
WHERE [published] = {published}
';
$sql .= ' AND ' . $pSql;
$sql .= ' ORDER BY [id] desc';
$params = array();
$params['published'] = true;
$result = Jaws_DB::getInstance()->queryAll($sql, $params);
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$quotations = array();
foreach ($result as $r) {
$quotation = array();
$quotation['title'] = $r['title'];
$quotation['url'] = $this->gadget->urlMap('ViewQuote', array('id' => $r['id']));
$quotation['image'] = 'gadgets/Quotes/Resources/images/logo.png';
$quotation['snippet'] = $r['quotation'];
$quotation['date'] = $date->ToISO($r['updatetime']);
$quotations[] = $quotation;
}
return $quotations;
}
示例7: Validate
/**
* Validates any data provided to the stage.
*
* @access public
* @return bool|Jaws_Error Returns either true on success, or a Jaws_Error
* containing the reason for failure.
*/
function Validate()
{
if ($_SESSION['install']['predefined']) {
return true;
}
$request = Jaws_Request::getInstance();
$postReq = $request->fetch(array('secure', 'customize'), 'post');
$_SESSION['secure'] = !empty($postReq['secure']);
$_SESSION['customize'] = !empty($postReq['customize']);
// try to entering to secure transformation mode
if ($_SESSION['secure'] && (!isset($_SESSION['pub_key']) || empty($_SESSION['pub_key']))) {
require_once JAWS_PATH . 'include/Jaws/Crypt.php';
$pkey = Jaws_Crypt::Generate_RSA_KeyPair(512);
if (!Jaws_Error::isError($pkey)) {
$_SESSION['pub_key'] = $pkey['pub_key'];
$_SESSION['pvt_key'] = $pkey['pvt_key'];
} else {
return new Jaws_Error(_t('INSTALL_AUTH_ERROR_RSA_KEY_GENERATION'), 0, JAWS_ERROR_WARNING);
}
}
$key_file = INSTALL_PATH . 'key.txt';
if (file_exists($key_file)) {
$key = trim(file_get_contents($key_file));
if ($key === $_SESSION['install']['Authentication']['key']) {
_log(JAWS_LOG_DEBUG, "Input log and session key match");
return true;
}
_log(JAWS_LOG_DEBUG, "The key found doesn't match the one below, please check that you entered the key correctly");
return new Jaws_Error(_t('INSTALL_AUTH_ERROR_KEY_MATCH', 'key.txt'), 0, JAWS_ERROR_WARNING);
}
_log(JAWS_LOG_DEBUG, "Your key file was not found, please make sure you created it, and the web server is able to read it.");
return new Jaws_Error(_t('INSTALL_AUTH_ERROR_KEY_FILE', 'key.txt'), 0, JAWS_ERROR_WARNING);
}
示例8: LoginHistory
/**
*
* @access public
* @return string HTML content with menu and menu items
*/
function LoginHistory($limit = 5)
{
if (!$GLOBALS['app']->Session->Logged()) {
return false;
}
$logModel = Jaws_Gadget::getInstance('Logs')->model->load('Logs');
$logs = $logModel->GetLogs(array('gadget' => 'Users', 'action' => 'Login', 'user' => $GLOBALS['app']->Session->GetAttribute('user')), $limit);
if (Jaws_Error::IsError($logs) || empty($logs)) {
return false;
}
$tpl = $this->gadget->template->load('LoginHistory.html');
$tpl->SetBlock('history');
$date = Jaws_Date::getInstance();
$tpl->SetVariable('title', _t('LOGS_LOGIN_HISTORY'));
foreach ($logs as $log) {
$tpl->SetBlock('history/' . $log['status']);
$tpl->SetVariable('ip', long2ip($log['ip']));
$tpl->SetVariable('agent', $log['agent']);
$tpl->SetVariable('status_title', _t('GLOBAL_HTTP_ERROR_TITLE_' . $log['status']));
$tpl->SetVariable('date', $date->Format($log['insert_time'], 'd MN Y H:i'));
$tpl->ParseBlock('history/' . $log['status']);
}
$tpl->ParseBlock('history');
return $tpl->Get();
}
示例9: UpdateUserRating
/**
* Update user rate of a reference item
*
* @access public
* @param string $gadget Gadget name
* @param string $action Action name
* @param int $reference Reference
* @param int $item Rating item
* @param int $rate User rate(if null user old rate will be removed)
* @return mixed Rate value or Jaws_Error on failure
*/
function UpdateUserRating($gadget, $action, $reference, $item = 0, $rate = null)
{
$objORM = Jaws_ORM::getInstance();
// fetch reference item from parent table(rating)
$rid = $objORM->table('rating')->upsert(array('gadget' => $gadget, 'action' => $action, 'reference' => $reference, 'item' => $item))->where('gadget', $gadget)->and()->where('action', $action)->and()->where('reference', $reference)->and()->where('item', $item)->exec();
if (Jaws_Error::IsError($rid)) {
return $rid;
}
// insert/update user rate
$uip = bin2hex(inet_pton($_SERVER['REMOTE_ADDR']));
$objORM->beginTransaction();
if (is_null($rate)) {
// delete user rate
$result = $objORM->table('rating_details')->delete()->where('rid', $rid)->and()->where('uip', $uip)->exec();
} else {
// update/insert user rate
$result = $objORM->table('rating_details')->upsert(array('rid' => $rid, 'uip' => $uip, 'rate' => (int) $rate))->where('rid', $rid)->and()->where('uip', $uip)->exec();
}
if (Jaws_Error::IsError($result)) {
return $result;
}
// update rating statistics
$result = $objORM->table('rating')->update(array('rates_count' => Jaws_ORM::getInstance()->table('rating_details')->select('count(id)')->where('rid', $rid), 'rates_sum' => Jaws_ORM::getInstance()->table('rating_details')->select('sum(rate)')->where('rid', $rid), 'rates_avg' => Jaws_ORM::getInstance()->table('rating_details')->select('avg(rate)')->where('rid', $rid)))->where('id', $rid)->exec();
if (Jaws_Error::IsError($result)) {
return $result;
}
//commit transaction
$objORM->commit();
return true;
}
示例10: Random
/**
* Displays a random image from one of the galleries.
*
* @access public
* @param int $albumid album ID
* @return string XHTML template content
* @see Phoo_Model::GetRandomImage()
*/
function Random($albumid = null)
{
$model = $this->gadget->model->load('Random');
$r = $model->GetRandomImage($albumid);
if (Jaws_Error::IsError($r) || empty($r)) {
return false;
}
$tpl = $this->gadget->template->load('Random.html');
$tpl->SetBlock('random_image');
$imgData = Jaws_Image::getimagesize(JAWS_DATA . 'phoo/' . $r['thumb']);
if (!Jaws_Error::IsError($imgData)) {
$tpl->SetVariable('width', $imgData[0]);
$tpl->SetVariable('height', $imgData[1]);
}
$tpl->SetVariable('title', _t('PHOO_ACTIONS_RANDOM'));
$tpl->SetVariable('url', $this->gadget->urlMap('ViewImage', array('id' => $r['id'], 'albumid' => $r['phoo_album_id'])));
$tpl->SetVariable('name', $r['name']);
$tpl->SetVariable('filename', $r['filename']);
$tpl->SetVariable('thumb', $GLOBALS['app']->getDataURL('phoo/' . $r['thumb']));
$tpl->SetVariable('medium', $GLOBALS['app']->getDataURL('phoo/' . $r['medium']));
$tpl->SetVariable('image', $GLOBALS['app']->getDataURL('phoo/' . $r['image']));
$tpl->SetVariable('img_desc', $r['stripped_description']);
$tpl->ParseBlock('random_image');
return $tpl->Get();
}
示例11: 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);
}
示例12: Execute
/**
* Returns an array with the results of a search
*
* @access public
* @param string $pSql Prepared search (WHERE) SQL
* @return mixed An array of entries that matches a certain pattern or False on error
*/
function Execute($pSql = '')
{
$sql = '
SELECT
[id], [term], [description], [createtime]
FROM [[glossary]]
';
$sql .= ' WHERE ' . $pSql;
$sql .= " ORDER BY [createtime] desc";
$result = Jaws_DB::getInstance()->queryAll($sql);
if (Jaws_Error::IsError($result)) {
return false;
}
$date = Jaws_Date::getInstance();
$entries = array();
foreach ($result as $r) {
$entry = array();
$entry['title'] = $r['term'];
$entry['url'] = $this->gadget->urlMap('ViewTerm', array('term' => $r['id']));
$entry['image'] = 'gadgets/Glossary/Resources/images/logo.png';
$entry['snippet'] = $r['description'];
$entry['date'] = $date->ToISO($r['createtime']);
$stamp = str_replace(array('-', ':', ' '), '', $r['createtime']);
$entries[$stamp] = $entry;
}
return $entries;
}
示例13: Upgrade
/**
* Upgrades the gadget
*
* @access public
* @param string $old Current version (in registry)
* @param string $new New version (in the $gadgetInfo file)
* @return mixed True on success, Jaws_Error otherwise
*/
function Upgrade($old, $new)
{
if (version_compare($old, '2.0.0', '<')) {
$variables = array();
$variables['logon_hours'] = str_pad('', 42, 'F');
$result = $this->installSchema('schema.xml', $variables, '1.0.0.xml');
if (Jaws_Error::IsError($result)) {
return $result;
}
// update users passwords
$usersTable = Jaws_ORM::getInstance()->table('users');
$usersTable->update(array('password' => $usersTable->concat(array('{SSHA1}', 'text'), 'password')))->where($usersTable->length('password'), 32, '>')->exec();
$usersTable->update(array('password' => $usersTable->concat(array('{MD5}', 'text'), 'password')))->where($usersTable->length('password'), 32)->exec();
// ACL keys
$this->gadget->acl->insert('ManageFriends');
$this->gadget->acl->insert('AccessDashboard');
$this->gadget->acl->insert('ManageDashboard');
}
if (version_compare($old, '2.1.0', '<')) {
$this->gadget->registry->delete('anon_repetitive_email');
}
if (version_compare($old, '2.2.0', '<')) {
$result = $this->installSchema('schema.xml', '', '2.1.0.xml');
if (Jaws_Error::IsError($result)) {
return $result;
}
}
return true;
}
示例14: PluginInfo
/**
* Builds UI for the plugin information
*
* @access public
* @param string $plugin Plugin's name
* @return string XHTML UI
*/
function PluginInfo($plugin)
{
$objPlugin = $GLOBALS['app']->LoadPlugin($plugin);
if (Jaws_Error::IsError($objPlugin)) {
return $objPlugin->getMessage();
}
$tpl = $this->gadget->template->loadAdmin('Plugin.html');
$tpl->SetBlock('info');
$tpl->SetVariable('lbl_version', _t('COMPONENTS_VERSION') . ':');
$tpl->SetVariable('lbl_example', _t('COMPONENTS_PLUGINS_USAGE') . ':');
$tpl->SetVariable('lbl_accesskey', _t('COMPONENTS_PLUGINS_ACCESSKEY') . ':');
$tpl->SetVariable('lbl_friendly', _t('COMPONENTS_PLUGINS_FRIENDLY') . ':');
$tpl->SetVariable('accesskey', $objPlugin->GetAccessKey() ? $objPlugin->GetAccessKey() : _t('COMPONENTS_PLUGINS_NO_ACCESSKEY'));
$tpl->SetVariable('friendly', $objPlugin->friendly ? _t('COMPONENTS_PLUGINS_FRIENDLY') : _t('COMPONENTS_PLUGINS_NOT_FRIENDLY'));
$tpl->SetVariable('example', $objPlugin->example ? $objPlugin->example : _t('COMPONENTS_PLUGINS_NO_EXAMPLE'));
$tpl->SetVariable('version', $objPlugin->version);
$button =& Piwi::CreateWidget('Button', 'btn_install', _t('COMPONENTS_INSTALL'), STOCK_SAVE);
$button->AddEvent(ON_CLICK, 'javascript:setupComponent();');
$button->SetStyle('display:none');
$tpl->SetVariable('install', $button->Get());
$button =& Piwi::CreateWidget('Button', 'btn_uninstall', _t('COMPONENTS_UNINSTALL'), STOCK_DELETE);
$button->AddEvent(ON_CLICK, 'javascript:setupComponent();');
$button->SetStyle('display:none');
$tpl->SetVariable('uninstall', $button->Get());
$tpl->ParseBlock('info');
return $tpl->Get();
}
示例15: PollResultsUI
/**
* Get the poll results
*
* @access public
* @param int $pid Poll ID
* @return string XHTML template content
*/
function PollResultsUI($pid)
{
$tpl = $this->gadget->template->loadAdmin('Reports.html');
$tpl->SetBlock('PollResults');
$model = $this->gadget->model->load('Poll');
$poll = $model->GetPoll($pid);
if (Jaws_Error::IsError($poll)) {
//we need to handle errors
return '';
}
$answers = $model->GetPollAnswers($poll['id']);
if (!Jaws_Error::IsError($answers)) {
$total_votes = array_sum(array_map(create_function('$row', 'return $row["votes"];'), $answers));
$tpl->SetVariable('lbl_total_votes', _t('POLL_REPORTS_TOTAL_VOTES'));
$tpl->SetVariable('total_votes', $total_votes);
foreach ($answers as $answer) {
$tpl->SetBlock('PollResults/answer');
$tpl->SetVariable('answer', $answer['answer']);
$percent = $total_votes == 0 ? 0 : floor($answer['votes'] / $total_votes * 100);
$tpl->SetVariable('percent', _t('POLL_REPORTS_PERCENT', $percent));
$tpl->SetVariable('image_width', floor($percent * 1.5));
$tpl->SetVariable('votes', $answer['votes']);
$tpl->ParseBlock('PollResults/answer');
}
}
$tpl->ParseBlock('PollResults');
return $tpl->Get();
}