当前位置: 首页>>代码示例>>PHP>>正文


PHP SwatDBClassMap::get方法代码示例

本文整理汇总了PHP中SwatDBClassMap::get方法的典型用法代码示例。如果您正苦于以下问题:PHP SwatDBClassMap::get方法的具体用法?PHP SwatDBClassMap::get怎么用?PHP SwatDBClassMap::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SwatDBClassMap的用法示例。


在下文中一共展示了SwatDBClassMap::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的SwatDBClassMap::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。