本文整理汇总了PHP中Jaws_Error::IsError方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Error::IsError方法的具体用法?PHP Jaws_Error::IsError怎么用?PHP Jaws_Error::IsError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Error
的用法示例。
在下文中一共展示了Jaws_Error::IsError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetMoblog
/**
* Get entries as Moblog
*
* @access public
* @return mixed Returns an array of phoo entries in moblog format and Jaws_Error on error
*/
function GetMoblog($album)
{
$table = Jaws_ORM::getInstance()->table('phoo_image_album');
$table->select('phoo_album_id', 'filename', 'phoo_image.id', 'phoo_image.title', 'phoo_image.description', 'phoo_image.createtime');
$table->join('phoo_image', 'phoo_image.id', 'phoo_image_album.phoo_image_id');
$table->join('phoo_album', 'phoo_album.id', 'phoo_image_album.phoo_album_id');
$table->where('phoo_image.published', true)->and();
$table->where('phoo_album.id', $album);
$table->orderBy('phoo_image.createtime desc');
$limit = $this->gadget->registry->fetch('moblog_limit');
if (Jaws_Error::isError($limit)) {
return new Jaws_Error(_t('PHOO_ERROR_GETMOBLOG'));
}
$result = $table->limit($limit)->fetchAll();
if (Jaws_Error::IsError($result)) {
return new Jaws_Error(_t('PHOO_ERROR_GETMOBLOG'));
}
foreach ($result as $key => $image) {
$result[$key]['name'] = $image['title'];
$result[$key]['thumb'] = $this->GetThumbPath($image['filename']);
$result[$key]['medium'] = $this->GetMediumPath($image['filename']);
$result[$key]['image'] = $this->GetOriginalPath($image['filename']);
$result[$key]['stripped_description'] = $image['description'];
}
return $result;
}
示例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: Display
/**
* Displays the emblems
*
* @access public
* @return string XHTML UI
*/
function Display()
{
$tpl = $this->gadget->template->load('Emblems.html');
$tpl->SetBlock('emblems');
$tpl->SetVariable('title', _t('EMBLEMS_ACTION_TITLE'));
$model = $this->gadget->model->load('Emblems');
$emblems = $model->GetEmblems(true);
if (!Jaws_Error::IsError($emblems)) {
$site = urlencode(Jaws_Utils::getBaseURL('/', false));
$page = urlencode(Jaws_Utils::getRequestURL(false));
$name = urlencode($this->gadget->registry->fetch('site_name', 'Settings'));
$slogan = urlencode($this->gadget->registry->fetch('site_slogan', 'Settings'));
$title = $GLOBALS['app']->Layout->GetTitle();
foreach ($emblems as $e) {
$e['url'] = str_replace(array('{url}', '{base_url}', '{requested_url}', '{site_name}', '{site_slogan}', '{title}'), array($page, $site, $page, $name, $slogan, $title), $e['url']);
$tpl->SetBlock('emblems/emblem');
$tpl->SetVariable('id', $e['id']);
$tpl->SetVariable('title', _t('EMBLEMS_TYPE_' . $e['type'], $e['title']));
$tpl->SetVariable('image', $GLOBALS['app']->getDataURL('emblems/' . $e['image']));
$tpl->SetVariable('url', $e['url']);
$tpl->ParseBlock('emblems/emblem');
}
}
$tpl->ParseBlock('emblems');
return $tpl->Get();
}
示例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 with the results of a tag content
*
* @access public
* @param string $action Action name
* @param array $references Array of References
* @return array An array of entries that matches a certain pattern
*/
function Execute($action, $references)
{
if (empty($action) || !is_array($references) || empty($references)) {
return false;
}
$table = Jaws_ORM::getInstance()->table('blog');
$table->select('id:integer', 'fast_url', 'title', 'summary', 'text', 'updatetime');
$result = $table->where('id', $references, 'in')->fetchAll();
if (Jaws_Error::IsError($result)) {
return array();
}
$date = Jaws_Date::getInstance();
$posts = array();
foreach ($result as $r) {
$post = array();
$post['title'] = $r['title'];
$post['url'] = $this->gadget->urlMap('SingleView', array('id' => $r['fast_url']));
$post['outer'] = false;
$post['image'] = 'gadgets/Blog/Resources/images/logo.png';
$post['snippet'] = $r['summary'];
$post['date'] = $date->ToISO($r['updatetime']);
$posts[$r['id']] = $post;
}
return $posts;
}
示例7: 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();
}
示例8: 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;
}
示例9: 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();
}
示例10: 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();
}
示例11: 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;
}
示例12: 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;
}
示例13: image
/**
* Displays the captcha image
*
* @access public
*/
function image($key)
{
$value = $this->randomEquation();
$result = $this->update($key, $value[1]);
if (Jaws_Error::IsError($result)) {
$value = '';
} else {
$value = $value[0];
}
$value .= '=?';
$bg = dirname(__FILE__) . '/resources/math.bg.png';
$im = imagecreatefrompng($bg);
imagecolortransparent($im, imagecolorallocate($im, 255, 255, 255));
$font = dirname(__FILE__) . '/resources/comicbd.ttf';
$grey = imagecolorallocate($im, 0x7f, 0x7f, 0x7f);
// shadow
imagettftext($im, 18, 0, 8, 22, $grey, $font, $value);
// text
imagettftext($im, 18, 0, 12, 24, $grey, $font, $value);
header('Content-Type: image/png');
ob_start();
imagepng($im);
$content = ob_get_contents();
ob_end_clean();
imagedestroy($im);
return $content;
}
示例14: SaveSettings
/**
* Update registry settings for phoo
*
* @access public
* @param string $default_action
* @param bool $published
* @param bool $allow_comments
* @param string $moblog_album
* @param string $moblog_limit
* @param string $photoblog_album
* @param string $photoblog_limit
* @param bool $show_exif_info
* @param bool $keep_original
* @param string $thumb_limit
* @param string $comment_status
* @param string $albums_order_type
* @param string $photos_order_type
* @return mixed True on success or Jaws_Error on failure
*/
function SaveSettings($default_action, $published, $allow_comments, $moblog_album, $moblog_limit, $photoblog_album, $photoblog_limit, $show_exif_info, $keep_original, $thumb_limit, $comment_status, $albums_order_type, $photos_order_type)
{
$rs = array();
$rs[] = $this->gadget->registry->update('default_action', $default_action);
$rs[] = $this->gadget->registry->update('published', $published);
$rs[] = $this->gadget->registry->update('allow_comments', $allow_comments);
$rs[] = $this->gadget->registry->update('moblog_album', (int) $moblog_album);
$rs[] = $this->gadget->registry->update('moblog_limit', $moblog_limit);
$rs[] = $this->gadget->registry->update('photoblog_album', $photoblog_album);
$rs[] = $this->gadget->registry->update('photoblog_limit', $photoblog_limit);
$rs[] = $this->gadget->registry->update('show_exif_info', $show_exif_info);
$rs[] = $this->gadget->registry->update('keep_original', $keep_original);
$rs[] = $this->gadget->registry->update('thumbnail_limit', $thumb_limit);
$rs[] = $this->gadget->registry->update('comment_status', $comment_status);
$rs[] = $this->gadget->registry->update('albums_order_type', $albums_order_type);
$rs[] = $this->gadget->registry->update('photos_order_type', $photos_order_type);
foreach ($rs as $r) {
if (Jaws_Error::IsError($r) || $r === false) {
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_ERROR_CANT_UPDATE_SETTINGS'), RESPONSE_ERROR);
return new Jaws_Error(_t('PHOO_ERROR_CANT_UPDATE_SETTINGS'));
}
}
$GLOBALS['app']->Session->PushLastResponse(_t('PHOO_SETTINGS_UPDATED'), RESPONSE_NOTICE);
return true;
}
示例15: ShowTrackbacks
/**
* Shows existing trackbacks for a given entry
*
* @access public
* @param int $id entry id
* @return string XHTML template content
*/
function ShowTrackbacks($id)
{
if ($this->gadget->registry->fetch('trackback') == 'true') {
$model = $this->gadget->model->load('Trackbacks');
$trackbacks = $model->GetTrackbacks($id);
$tpl = $this->gadget->template->load('Trackbacks.html');
$tpl->SetBlock('trackbacks');
$tburi = $this->gadget->urlMap('Trackback', array('id' => $id), true);
$tpl->SetVariable('TrackbackURI', $tburi);
if (!Jaws_Error::IsError($trackbacks)) {
$date = Jaws_Date::getInstance();
foreach ($trackbacks as $tb) {
$tpl->SetBlock('trackbacks/item');
$tpl->SetVariablesArray($tb);
$tpl->SetVariable('createtime-iso', $tb['createtime']);
$tpl->SetVariable('createtime', $date->Format($tb['createtime']));
$tpl->SetVariable('createtime-monthname', $date->Format($tb['createtime'], 'MN'));
$tpl->SetVariable('createtime-monthabbr', $date->Format($tb['createtime'], 'M'));
$tpl->SetVariable('createtime-month', $date->Format($tb['createtime'], 'm'));
$tpl->SetVariable('createtime-dayname', $date->Format($tb['createtime'], 'DN'));
$tpl->SetVariable('createtime-dayabbr', $date->Format($tb['createtime'], 'D'));
$tpl->SetVariable('createtime-day', $date->Format($tb['createtime'], 'd'));
$tpl->SetVariable('createtime-year', $date->Format($tb['createtime'], 'Y'));
$tpl->SetVariable('createtime-time', $date->Format($tb['createtime'], 'g:ia'));
$tpl->ParseBlock('trackbacks/item');
}
}
$tpl->ParseBlock('trackbacks');
return $tpl->Get();
}
}