[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/dao/mylinks.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/mylink.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/data/validator/httpurlvalidator.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/data/validator/emptyvalidator.class.php" ); 10 lt_include( PLOG_CLASS_PATH."class/view/admin/adminnewlinkview.class.php" ); 11 lt_include( PLOG_CLASS_PATH."class/view/admin/adminlinkslistview.class.php" ); 12 13 /** 14 * \ingroup Action 15 * @private 16 * 17 * Adds a new link to the database, given some information 18 */ 19 class AdminAddLinkAction extends AdminAction 20 { 21 22 var $_linkName; 23 var $_linkUrl; 24 var $_linkDescription; 25 var $_linkCategoryId; 26 var $_properties; 27 28 /** 29 * Constructor. If nothing else, it also has to call the constructor of the parent 30 * class, BlogAction with the same parameters 31 */ 32 function AdminAddLinkAction( $actionInfo, $request ) 33 { 34 $this->AdminAction( $actionInfo, $request ); 35 36 // data validation 37 $this->registerFieldValidator( "linkName", new StringValidator()); 38 $this->registerFieldValidator( "linkUrl", new HttpUrlValidator()); 39 // linkRssFeed will only be validated if it is available in the form 40 $this->registerFieldValidator( "linkRssFeed", new HttpUrlValidator(), true ); 41 $this->registerFieldValidator( "linkCategoryId", new IntegerValidator()); 42 $this->registerFieldValidator( "linkDescription", new EmptyValidator()); 43 $view = new AdminNewLinkView( $this->_blogInfo ); 44 $view->setErrorMessage( $this->_locale->tr("error_adding_link" )); 45 $this->setValidationErrorView( $view ); 46 47 $this->requirePermission( "add_link" ); 48 } 49 50 /** 51 * Carries out the specified action 52 */ 53 function perform() 54 { 55 // fetch the data 56 $this->_linkName = Textfilter::filterAllHTML($this->_request->getValue( "linkName" )); 57 $this->_linkUrl = Textfilter::filterAllHTML($this->_request->getValue( "linkUrl" )); 58 $this->_linkCategoryId = $this->_request->getValue( "linkCategoryId" ); 59 $this->_linkDescription = Textfilter::filterAllHTML($this->_request->getValue( "linkDescription" )); 60 $this->_linkRss = Textfilter::filterAllHTML($this->_request->getValue( "linkRssFeed" )); 61 $this->_properties = Array(); 62 63 // adds the new link to the database 64 $myLinks = new MyLinks(); 65 $myLink = new MyLink( $this->_linkName, $this->_linkDescription, $this->_linkUrl, 66 $this->_blogInfo->getId(), $this->_linkCategoryId, 67 0, $this->_linkRss, $this->_properties ); 68 $this->notifyEvent( EVENT_PRE_LINK_ADD, Array( "link" => &$link )); 69 if( !$myLinks->addMyLink( $myLink, $this->_blogInfo->getId())) { 70 $this->_view = new AdminNewLinkView( $this->_blogInfo ); 71 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_link")); 72 $this->setCommonData(); 73 74 return false; 75 } 76 $this->notifyEvent( EVENT_POST_LINK_ADD, Array( "link" => &$link )); 77 78 // if the user has no permission to view the links, the we have to find another view 79 if( $this->userHasPermission( "view_links" )) 80 $this->_view = new AdminLinksListView( $this->_blogInfo ); 81 else 82 $this->_view = new AdminNewLinkView( $this->_blogInfo ); 83 84 $this->_view->setSuccessMessage( $this->_locale->pr("link_added_ok", $myLink->getName())); 85 $this->setCommonData(); 86 87 // clear the cache 88 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false ); 89 90 // better to return true if everything fine 91 return true; 92 } 93 } 94 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |