[pLog-svn] r507 - in plog/trunk/class: dao net summary/action

su baochen subaochen at 126.com
Thu Dec 16 13:38:05 GMT 2004


在 2004-12-16四的 14:29 +0200,Oscar Renalias写道:
> Hi,
> 
> I am not quite sure about adding the profileLink method... I don't
> think it's really necessary to have a method when this is something
> that we could do in two lines:
> 
> $picture = $userInfo->getPicture();
> $url->resourceLink( $picture );
> 
> The getPicture() object of the UserInfo class returns a
> GalleryResource object and as a such, we can use all the methods that
> can generate urls for resources: resourceLink(),
> resourceDownloadLink(), resourcePreviewLink(), etc.

Oh, I must to say that, I have not noticed resource*Link method:-(,
sorry.

> 
> If we still decide to implement the method, it can be done in a very easy way:
> 
>         function profileLink($blogInfo = null) {
>                if( $blogInfo == null ) {
>                                $blogInfo = $this->_blogInfo;
>             }
> 
>                        $this->addParameter( "blogId", $blogInfo->getId());
> 
>             $ownerInfo = $blogInfo->getOwnerInfo();
>             $pic = $ownerInfo->getPicture();
>             return( $this->resourceLink( $pic ));
>         }

En, great! But, what if $pic == null ? that is, user does not select
their picture, so need:

if(!$pic)
	return "imgs/no-user-picture.jpg";

I vote +1 to add this method, because page designer may need this to
show user picture... How about write like this?

        function profileLink($blogInfo = null) {
            if( $blogInfo == null ) {
                 $blogInfo = $this->_blogInfo;
            }

            $this->addParameter( "blogId", $blogInfo->getId());

            $ownerInfo = $blogInfo->getOwnerInfo();
            $pic = $ownerInfo->getPicture();
	    if(!$pic){
               return "imgs/no-user-picture.jpg";
            } else {
               return( $this->resourceLink( $pic ));
            }
        }
     


> 
> also by doing it as suggested above, we can implement it in
> BaseRequestGenerator since the methods used are not dependent on the
> format of the urls used...

That's ok.

> 
> Also, one more thing: we should try to stick to the project coding
> standards (http://www.plogworld.net/wikinew/index.php/Coding_Guidelines)
> I'm not saying that pLog's coding standards are the best ones but when
> you have thousands of lines of code typed in one way and a few typed
> in another, it looks kind of weird sometimes :-)

I'm sorry, you mean the way I named the variable and function or class?
or the tab and space problem? I always "set expandtab" when using vi...

Anyway, I'd like to stick to the current coding standards... Just let me
know the problem.

> 
> Oscar
> 
> On Thu, 16 Dec 2004 04:10:11 +0000 (GMT),
> subaochen at devel.plogworld.net <subaochen at devel.plogworld.net> wrote:
> > Author: subaochen
> > Date: 2004-12-16 04:10:10 +0000 (Thu, 16 Dec 2004)
> > New Revision: 507
> > 
> > Modified:
> >    plog/trunk/class/dao/bloginfo.class.php
> >    plog/trunk/class/dao/users.class.php
> >    plog/trunk/class/net/rawrequestgenerator.class.php
> >    plog/trunk/class/summary/action/dousercreation.class.php
> > Log:
> > add profileLink to get user picture
> > 
> > I don't know how to add the same function to other *requestgenerator.class.php though.
> > 
> > Modified: plog/trunk/class/dao/bloginfo.class.php
> > ===================================================================
> > --- plog/trunk/class/dao/bloginfo.class.php     2004-12-16 04:06:14 UTC (rev 506)
> > +++ plog/trunk/class/dao/bloginfo.class.php     2004-12-16 04:10:10 UTC (rev 507)
> > @@ -17,7 +17,7 @@
> >         {
> > 
> >                 var $_blog;
> > -               var $_owner;
> > +               var $_owner; // owner id
> >                 var $_about;
> >                 var $_settings;
> >                 var $_id;
> > @@ -222,6 +222,7 @@
> >                 }
> > 
> >          /**
> > +         * @param owner id
> >           * @private
> >           */
> >                 function setOwner( $owner )
> > @@ -449,4 +450,4 @@
> >                         return $quota;
> >                 }
> >         }
> > -?>
> > \ No newline at end of file
> > +?>
> > 
> > Modified: plog/trunk/class/dao/users.class.php
> > ===================================================================
> > --- plog/trunk/class/dao/users.class.php        2004-12-16 04:06:14 UTC (rev 506)
> > +++ plog/trunk/class/dao/users.class.php        2004-12-16 04:10:10 UTC (rev 507)
> > @@ -459,7 +459,7 @@
> > 
> >              $result = $this->_db->Execute($query);
> > 
> > -            if($result)
> > +            if($result && $result->RecordCount() >= 1)
> >                  return true;
> >              else
> >                  return false;
> > 
> > Modified: plog/trunk/class/net/rawrequestgenerator.class.php
> > ===================================================================
> > --- plog/trunk/class/net/rawrequestgenerator.class.php  2004-12-16 04:06:14 UTC (rev 506)
> > +++ plog/trunk/class/net/rawrequestgenerator.class.php  2004-12-16 04:10:10 UTC (rev 507)
> > @@ -225,7 +225,32 @@
> > 
> >              return $link;
> >          }
> > +
> >          /**
> > +         * get user profile picture link
> > +         */
> > +        function profileLink($blogInfo = null){
> > +               if( $blogInfo == null ) {
> > +                               $blogInfo = $this->_blogInfo;
> > +            }
> > +
> > +                       $this->addParameter( "blogId", $blogInfo->getId());
> > +
> > +            $ownerInfo = $blogInfo->getOwnerInfo();
> > +            $pic = $ownerInfo->getPicture();
> > +            if(!$pic){
> > +                // show a default user picture
> > +                return "imgs/no-user-picture.jpg";
> > +            } else {
> > +                           $this->addParameter( "resource", $pic->getFileName());
> > +            }
> > +
> > +            $link = $this->getResourceServerUrl().$this->getRequest();
> > +
> > +            return $link;
> > +        }
> > +
> > +        /**
> >           * Returns the url where the rss feed is running
> >           *
> >           * @param blogInfo A BlogInfo object containing information about the blog.
> > 
> > Modified: plog/trunk/class/summary/action/dousercreation.class.php
> > ===================================================================
> > --- plog/trunk/class/summary/action/dousercreation.class.php    2004-12-16 04:06:14 UTC (rev 506)
> > +++ plog/trunk/class/summary/action/dousercreation.class.php    2004-12-16 04:10:10 UTC (rev 507)
> > @@ -51,6 +51,7 @@
> > 
> >              // check if this email account has registered and quit if so
> >              if( $users->emailExists($this->userEmail)) {
> > +                $this->log->debug("email address ".$this->userEmail."  has used by someone.");
> >                                 $this->_view = new SummaryView( "registerstep1" );
> >                                 //$this->_form->hasRun( true );
> >                                 $this->_form->setFieldValidationStatus( "userEmail", false );
> > 
> > _______________________________________________
> > pLog-svn mailing list
> > pLog-svn at devel.plogworld.net
> > http://devel.plogworld.net/mailman/listinfo/plog-svn
> >
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-svn
> 
-- 
Best regards,
---
subaochen <subaochen at 126.com>





More information about the pLog-svn mailing list