本文整理汇总了PHP中SwatDBClassMap类的典型用法代码示例。如果您正苦于以下问题:PHP SwatDBClassMap类的具体用法?PHP SwatDBClassMap怎么用?PHP SwatDBClassMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SwatDBClassMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getComments
protected function getComments($limit = null, $offset = null)
{
$sql = sprintf('select BlorgComment.* from BlorgComment
left outer join BlorgAuthor on BlorgComment.author = BlorgAuthor.id
where %s
order by createdate desc', $this->getWhereClause());
$this->app->db->setLimit($limit, $offset);
$wrapper = SwatDBClassMap::get('BlorgCommentWrapper');
$comments = SwatDB::query($this->app->db, $sql, $wrapper);
// efficiently load posts for all comments
$instance_id = $this->app->getInstanceId();
$post_sql = sprintf('select id, title, bodytext
from BlorgPost
where instance %s %s and id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$post_wrapper = SwatDBClassMap::get('BlorgPostWrapper');
$comments->loadAllSubDataObjects('post', $this->app->db, $post_sql, $post_wrapper);
// efficiently load authors for all comments
$instance_id = $this->app->getInstanceId();
$author_sql = sprintf('select id, name
from BlorgAuthor
where instance %s %s and id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$author_wrapper = SwatDBClassMap::get('BlorgAuthorWrapper');
$comments->loadAllSubDataObjects('author', $this->app->db, $author_sql, $author_wrapper);
return $comments;
}
开发者ID:nburka,项目名称:blorg,代码行数:25,代码来源:Index.php
示例2: loadData
protected function loadData()
{
$tag_list = new PinholeTagList($this->app, $this->tag->name, true);
$photos = $tag_list->getPhotos();
$order_array = array();
$class_name = SwatDBClassMap::get('PinholeImageSet');
$set = new $class_name();
$set->setDatabase($this->app->db);
$set->instance = $this->app->getInstance();
$set->loadByShortname('photos');
$thumb = $set->getDimensionByShortname('thumb');
foreach ($photos as $photo) {
$image = new SwatImageDisplay();
$image->image = $photo->getUri('thumb', '../');
$image->width = $photo->getWidth('thumb');
$image->height = $photo->getHeight('thumb');
$image->occupy_width = $thumb->max_width;
$image->occupy_height = $thumb->max_height;
ob_start();
$image->display();
$order_array[$photo->id] = ob_get_clean();
}
$order_widget = $this->ui->getWidget('order');
$order_widget->width = '580px';
$order_widget->height = '400px';
$order_widget->addOptionsByArray($order_array, 'text/xml');
$sql = sprintf('select sum(displayorder) from PinholePhotoTagBinding
where tag = %s', $this->app->db->quote($this->tag->id, 'integer'));
$sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
$options_list = $this->ui->getWidget('options');
$options_list->value = $sum == 0 ? 'auto' : 'custom';
}
开发者ID:gauthierm,项目名称:pinhole,代码行数:32,代码来源:PhotoOrder.php
示例3: getPhoto
protected function getPhoto($filename)
{
$sql = sprintf('select PinholePhoto.*
from PinholePhoto
inner join ImageSet on PinholePhoto.image_set = ImageSet.id
where PinholePhoto.filename = %s and ImageSet.instance %s %s', $this->app->db->quote($filename, 'text'), SwatDB::equalityOperator($this->app->getInstanceId()), $this->app->db->quote($this->app->getInstanceId(), 'integer'));
$wrapper_class = SwatDBClassMap::get('PinholePhotoWrapper');
$photos = SwatDB::query($this->app->db, $sql, $wrapper_class);
if (count($photos) == 0) {
$instance = $this->app->getInstance();
if ($instance === null) {
$message = sprintf("Photo with filename '%s' does not exist.", $filename);
} else {
$message = sprintf("Photo with filename '%s' does not exist " . "in the instance '%s'.", $filename, $instance->shortname);
}
throw new SiteNotFoundException($message);
}
$photo = $photos->getFirst();
if ($photo->private && !$this->app->session->isLoggedIn()) {
$message = sprintf("Photo with filename '%s' is private and user " . "is not logged in.", $filename);
throw new SiteNotFoundException($message);
}
$photo->setFileBase('../photos');
return $photo;
}
开发者ID:gauthierm,项目名称:pinhole,代码行数:25,代码来源:PinholePhotoLoaderPage.php
示例4: buildInternal
protected function buildInternal()
{
parent::buildInternal();
$locale = SwatI18NLocale::get();
$item_list = $this->getItemList('integer');
$dep = new AdminListDependency();
$dep->setTitle(CME::_('CME credit'), CME::_('CME credits'));
$sql = sprintf('select CMECredit.*
from CMECredit
where CMECredit.id in (%s)', $item_list);
$credits = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('CMECreditWrapper'));
foreach ($credits as $credit) {
$data = new stdClass();
$data->id = $credit->id;
$data->status_level = AdminDependency::DELETE;
$data->parent = null;
$data->title = $credit->getTitle();
$dep->entries[] = new AdminDependencyEntry($data);
}
$message = $this->ui->getWidget('confirmation_message');
$message->content = $dep->getMessage();
$message->content_type = 'text/xml';
if ($dep->getStatusLevelCount(AdminDependency::DELETE) === 0) {
$this->switchToCancelButton();
}
}
开发者ID:nrfredrickson,项目名称:Cme,代码行数:26,代码来源:Delete.php
示例5: init
protected function init()
{
parent::init();
$this->registerInternalProperty('instance', SwatDBClassMap::get('SiteInstance'));
$this->table = 'NewsletterTemplate';
$this->id_field = 'integer:id';
}
开发者ID:GervaisdeM,项目名称:deliverance,代码行数:7,代码来源:DeliveranceNewsletterTemplate.php
示例6: insertTag
/**
* Creates a new tag
*
* @throws SwatException if no database connection is set on this tag
* entry control.
*/
protected function insertTag($title, $index)
{
if ($this->app === null) {
throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
}
// check to see if the tag already exists
$instance_id = $this->app->getInstanceId();
$sql = sprintf('select * from
PinholeTag where lower(title) = lower(%s)
and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('PinholeTagDataObjectWrapper'));
// only insert if no tag already exists (prevents creating two tags on
// reloading)
if (count($tags) > 0) {
$tag_obj = $tags->getFirst();
} else {
$tag_obj = new PinholeTagDataObject();
$tag_obj->setDatabase($this->app->db);
$tag_obj->instance = $instance_id;
$tag_obj->title = $title;
$tag_obj->save();
$message = new SwatMessage(sprintf(Pinhole::_('“%s” tag has been added'), SwatString::minimizeEntities($tag_obj->title)));
$message->content_type = 'text/xml';
$message->secondary_content = sprintf(Pinhole::_('You can <a href="Tag/Edit?id=%d">edit this tag</a> ' . 'to customize it.'), $tag_obj->id);
$this->app->messages->add($message);
}
$this->tag_array[$tag_obj->name] = $tag_obj->title;
$this->selected_tag_array[$tag_obj->name] = $tag_obj->title;
}
开发者ID:gauthierm,项目名称:pinhole,代码行数:35,代码来源:PinholePhotoTagEntry.php
示例7: init
protected function init()
{
parent::init();
$this->registerInternalProperty('post', SwatDBClassMap::get('BlorgPost'));
$this->registerInternalProperty('author', SwatDBClassMap::get('BlorgAuthor'));
$this->table = 'BlorgComment';
}
开发者ID:nburka,项目名称:blorg,代码行数:7,代码来源:BlorgComment.php
示例8: insertTag
/**
* Creates a new tag
*
* @throws SwatException if no database connection is set on this tag
* entry control.
*/
protected function insertTag($title, $index)
{
if ($this->app === null) {
throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.');
}
// check to see if the tag already exists
$instance_id = $this->app->getInstanceId();
$sql = sprintf('select * from
BlorgTag where lower(title) = lower(%s) and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgTagWrapper'));
// only insert if no tag already exists (prevents creating two tags on
// reloading)
if (count($tags) > 0) {
$tag = $tags->getFirst();
} else {
$tag = new BlorgTag();
$tag->setDatabase($this->app->db);
$tag->instance = $instance_id;
$tag->title = $title;
$tag->save();
if (isset($this->app->memcache)) {
$this->app->memcache->flushNs('tags');
}
$message = new SwatMessage(sprintf(Blorg::_('The tag “%s” has been added.'), $tag->title));
$this->app->messages->add($message);
}
$this->tag_array[$tag->shortname] = $tag->title;
$this->selected_tag_array[$tag->shortname] = $tag->title;
}
开发者ID:GervaisdeM,项目名称:blorg,代码行数:35,代码来源:BlorgTagEntry.php
示例9: initReport
protected function initReport()
{
$quarter = SiteApplication::initVar('quarter', null, SiteApplication::VAR_GET);
if ($quarter === null || preg_match('/^2[0-9]{3}-0[1-4]$/', $quarter) === 0) {
throw new AdminNotFoundException('Invalid quarter.');
}
list($year, $quarter) = explode('-', $quarter, 2);
$start_month = (intval($quarter) - 1) * 3 + 1;
$quarter = new SwatDate();
$quarter->setTime(0, 0, 0);
$quarter->setDate($year, $start_month, 1);
$quarter->setTZ($this->app->default_time_zone);
$quarter->toUTC();
$type = SiteApplication::initVar('type', null, SiteApplication::VAR_GET);
$provider = new CMEProvider();
$provider->setDatabase($this->app->db);
if (!$provider->loadByShortname($type)) {
throw new AdminNotFoundException('Invalid CME provider.');
}
$sql = sprintf('select * from QuizReport
where quarter = %s and provider = %s', $this->app->db->quote($quarter->getDate(), 'date'), $this->app->db->quote($provider->id, 'integer'));
$this->report = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('CMEQuizReportWrapper'))->getFirst();
if (!$this->report instanceof CMEQuizReport) {
throw new AdminNotFoundException(sprintf('Report not found for quarter %s.', $quarter->getDate()));
}
$this->report->setFileBase('../../system/quiz-report-updater');
if (!file_exists($this->report->getFilePath())) {
throw new AdminNotFoundException(sprintf('Report file ‘%s’ not found', $this->report->getFilePath()));
}
}
开发者ID:nrfredrickson,项目名称:Cme,代码行数:30,代码来源:Download.php
示例10: init
protected function init()
{
$this->table = 'CMECredit';
$this->id_field = 'integer:id';
$this->registerInternalProperty('front_matter', SwatDBClassMap::get('CMEFrontMatter'));
$this->registerInternalProperty('quiz', SwatDBClassMap::get('CMEQuiz'));
}
开发者ID:nrfredrickson,项目名称:Cme,代码行数:7,代码来源:CMECredit.php
示例11: getComments
protected function getComments($limit = null, $offset = null)
{
$sql = sprintf('select PinholeComment.* from PinholeComment
left outer join PinholePhotographer on PinholeComment.photographer = PinholePhotographer.id
where %s
order by createdate desc', $this->getWhereClause());
$this->app->db->setLimit($limit, $offset);
$wrapper = SwatDBClassMap::get('PinholeCommentWrapper');
$comments = SwatDB::query($this->app->db, $sql, $wrapper);
// efficiently load photos for all comments
$instance_id = $this->app->getInstanceId();
$photo_sql = sprintf('select PinholePhoto.* from PinholePhoto
inner join ImageSet on ImageSet.id = PinholePhoto.image_set
where ImageSet.instance %s %s and PinholePhoto.id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$photo_wrapper = SwatDBClassMap::get('PinholePhotoWrapper');
$comments->loadAllSubDataObjects('photo', $this->app->db, $photo_sql, $photo_wrapper);
// efficiently load photographers for all comments
$instance_id = $this->app->getInstanceId();
$photographer_sql = sprintf('select id, fullname
from PinholePhotographer
where instance %s %s and id in (%%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$photographer_wrapper = SwatDBClassMap::get('PinholePhotographerWrapper');
$comments->loadAllSubDataObjects('photographer', $this->app->db, $photographer_sql, $photographer_wrapper);
return $comments;
}
开发者ID:gauthierm,项目名称:pinhole,代码行数:25,代码来源:Index.php
示例12: processDBData
protected function processDBData()
{
parent::processDBData();
$item_list = $this->getItemList('integer');
$instance_id = $this->app->getInstanceId();
// delete attached files using their dataobjects to remove the actual
// files
$sql = sprintf('select * from BlorgFile
inner join BlorgPost on BlorgPost.id = BlorgFile.post
where BlorgPost.instance %s %s and BlorgFile.post in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
$files = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgFileWrapper'));
foreach ($files as $file) {
$file->setFileBase('../');
$file->delete();
}
// delete the posts
$sql = sprintf('delete from BlorgPost
where instance %s %s and id in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list);
$num = SwatDB::exec($this->app->db, $sql);
if (isset($this->app->memcache)) {
$this->app->memcache->flushNS('posts');
}
$message = new SwatMessage(sprintf(Blorg::ngettext('One post has been deleted.', '%s posts have been deleted.', $num), SwatString::numberFormat($num)));
$this->app->messages->add($message);
}
开发者ID:nburka,项目名称:blorg,代码行数:25,代码来源:Delete.php
示例13: initPosts
protected function initPosts($shortname, $page)
{
$class_name = SwatDBClassMap::get('BlorgTag');
$tag = new $class_name();
$tag->setDatabase($this->app->db);
if (!$tag->loadByShortname($shortname, $this->app->getInstance())) {
throw new SiteNotFoundException('Page not found.');
}
$this->tag = $tag;
$memcache = isset($this->app->memcache) ? $this->app->memcache : null;
$this->loader = new BlorgPostLoader($this->app->db, $this->app->getInstance(), $memcache);
$this->loader->addSelectField('title');
$this->loader->addSelectField('bodytext');
$this->loader->addSelectField('shortname');
$this->loader->addSelectField('publish_date');
$this->loader->addSelectField('author');
$this->loader->addSelectField('comment_status');
$this->loader->addSelectField('visible_comment_count');
$this->loader->setLoadFiles(true);
$this->loader->setLoadTags(true);
$this->loader->setWhereClause(sprintf('enabled = %s and
id in (select post from BlorgPostTagBinding where tag = %s)', $this->app->db->quote(true, 'boolean'), $this->app->db->quote($tag->id, 'integer')));
$this->loader->setOrderByClause('publish_date desc');
$offset = ($page - 1) * self::MAX_POSTS;
$this->loader->setRange(self::MAX_POSTS, $offset);
$this->posts = $this->loader->getPosts();
if (count($this->posts) == 0) {
throw new SiteNotFoundException('Page not found.');
}
}
开发者ID:nburka,项目名称:blorg,代码行数:30,代码来源:BlorgTagPage.php
示例14: getSegments
protected function getSegments()
{
$sql = 'select * from MailingListCampaignSegment
where %s and instance %s %s';
$sql = sprintf($sql, $this->force_all ? '1 = 1' : sprintf('enabled = %s', $this->db->quote(true, 'boolean')), SwatDB::equalityOperator($this->getInstanceId()), $this->db->quote($this->getInstanceId(), 'integer'));
return SwatDB::query($this->db, $sql, SwatDBClassMap::get('DeliveranceCampaignSegmentWrapper'));
}
开发者ID:GervaisdeM,项目名称:deliverance,代码行数:7,代码来源:DeliveranceListCampaignSegmentCacheUpdater.php
示例15: delete
/**
* Deletes a file
*
* @param integer $file_id the id of the file to delete.
*
* @return boolean true.
*/
public function delete($file_id)
{
$instance_id = $this->app->getInstanceId();
if ($this->app->getInstance() === null) {
$path = '../../files';
} else {
$path = '../../files/' . $this->app->getInstance()->shortname;
}
$class_name = SwatDBClassMap::get('BlorgFile');
$file = new $class_name();
$file->setDatabase($this->app->db);
$file->setFileBase($path);
if ($file->load(intval($file_id))) {
if ($file->getInternalValue('instance') === $instance_id) {
$file->delete();
}
}
if ($file_id == $this->app->config->blorg->header_image) {
$this->app->config->blorg->header_image = '';
} else {
$this->app->config->blorg->feed_logo = '';
}
$this->app->config->save();
return true;
}
开发者ID:GervaisdeM,项目名称:blorg,代码行数:32,代码来源:HeaderImageAjaxServer.php
示例16: process
public function process()
{
// initialize authentication
$auth = new Sabre_HTTP_DigestAuth();
$auth->setRealm($this->app->config->site->auth_realm);
$auth->init();
// authenticate and get correct user
$email = $auth->getUsername();
$class_name = SwatDBClassMap::get('PinholeAdminUser');
$user = new $class_name();
$user->setDatabase($this->app->db);
if (!$user->loadFromEmail($email) || !$auth->validateA1($user->digest_ha1)) {
$auth->requireLogin();
echo Pinhole::_('Authentication required') . "\n";
exit;
}
// create directory for account and object tree for dav server
$root = new PinholeDavDirectory($this->app, $user);
$tree = new Sabre_DAV_ObjectTree($root);
// create server
$server = new Sabre_DAV_Server($tree);
$server->setBaseUri($this->getDavBaseUri());
// don't save temp files in the database
$tempFilePlugin = new Sabre_DAV_TemporaryFileFilterPlugin($this->getDataDir('dav/temp'));
$server->addPlugin($tempFilePlugin);
// set up lock plugin
$lockBackend = new Sabre_DAV_Locks_Backend_FS($this->getDataDir('dav/locks'));
$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
$server->addPlugin($lockPlugin);
// also allow regular web browsing
$browserPlugin = new Sabre_DAV_Browser_Plugin(false);
$server->addPlugin($browserPlugin);
// serve it up!
$server->exec();
}
开发者ID:gauthierm,项目名称:pinhole,代码行数:35,代码来源:PinholeWebDavServerPage.php
示例17: initComments
protected function initComments($page)
{
// get comments for this page
$this->comments = false;
if (isset($this->app->memcache)) {
$key = $this->getCommentsCacheKey();
$this->comments = $this->app->memcache->getNs('posts', $key);
/*
* Note: The limit of comments per page is somewhat important here.
* In extreme cases, we could run over the 1M size limit for cached
* values. This would occur when every comment is close to the
* maximum size in bodytext (8K) and the associated posts also have
* a very large bodytext (about 8K each). In these rare cases,
* caching will fail.
*/
}
if ($this->comments === false) {
$sql = sprintf('select BlorgComment.* from BlorgComment %s where %s
order by BlorgComment.createdate desc', $this->getJoinClause(), $this->getWhereClause());
$offset = ($page - 1) * $this->getPageSize();
$this->app->db->setLimit($this->getPageSize(), $offset);
$wrapper = SwatDBClassMap::get('BlorgCommentWrapper');
$this->comments = SwatDB::query($this->app->db, $sql, $wrapper);
// efficiently load posts
$post_wrapper = SwatDBClassMap::get('BlorgPostWrapper');
$post_sql = 'select id, title, shortname, bodytext, publish_date
from BlorgPost
where id in (%s)';
$this->comments->loadAllSubDataObjects('post', $this->app->db, $post_sql, $post_wrapper);
// efficiently load authors
$author_wrapper = SwatDBClassMap::get('BlorgAuthorWrapper');
$author_sql = 'select id, name, shortname, email, visible
from BlorgAuthor
where id in (%s)';
$this->comments->loadAllSubDataObjects('author', $this->app->db, $author_sql, $author_wrapper);
if (isset($this->app->memcache)) {
$this->app->memcache->setNs('posts', $key, $this->comments);
}
} else {
$this->comments->setDatabase($this->app->db);
}
// if we're not on the first page and there are no comments, 404
if ($page > 1 && count($this->comments) === 0) {
throw new SiteNotFoundException('Page not found.');
}
// get total number of comments
$this->total_count = false;
if (isset($this->app->memcache)) {
$total_key = $this->getTotalCountCacheKey();
$this->total_count = $this->app->memcache->getNs('posts', $total_key);
}
if ($this->total_count === false) {
$sql = sprintf('select count(1) from BlorgComment %s where %s', $this->getJoinClause(), $this->getWhereClause());
$this->total_count = SwatDB::queryOne($this->app->db, $sql);
if (isset($this->app->memcache)) {
$this->app->memcache->setNs('posts', $total_key, $this->total_count);
}
}
}
开发者ID:GervaisdeM,项目名称:blorg,代码行数:59,代码来源:BlorgCommentsAtomPage.php
示例18: getNewImageInstance
protected function getNewImageInstance()
{
$class_name = SwatDBClassMap::get('SiteImage');
$image = new $class_name();
$image->setDatabase($this->app->db);
$image->image_set = $this->getImageSet();
return $image;
}
开发者ID:GervaisdeM,项目名称:Building,代码行数:8,代码来源:ImageEdit.php
示例19: getNewAttachmentInstance
protected function getNewAttachmentInstance()
{
$class_name = SwatDBClassMap::get('SiteAttachment');
$attachment = new $class_name();
$attachment->setDatabase($this->app->db);
$attachment->attachment_set = $this->getAttachmentSet();
return $attachment;
}
开发者ID:GervaisdeM,项目名称:Building,代码行数:8,代码来源:AttachmentEdit.php
示例20: init
protected function init()
{
$this->table = 'AccountEarnedCMECredit';
$this->id_field = 'integer:id';
$this->registerInternalProperty('account', SwatDBClassMap::get('CMEAccount'));
$this->registerInternalProperty('credit', SwatDBClassMap::get('CMECredit'));
$this->registerDateProperty('earned_date');
}
开发者ID:nrfredrickson,项目名称:Cme,代码行数:8,代码来源:CMEAccountEarnedCMECredit.php
注:本文中的SwatDBClassMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论