[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/action/admin/ -> adminpostmanagementcommonaction.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfieldvaluefactory.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
   9      
  10  
  11      /**
  12       * \ingroup Action
  13       * @private
  14       *
  15       * there is a lot of code that can be shared amongst
  16       * AdminAddPostAction and AdminUpdatePostAction so we'll put it all here
  17       * and make these two classes extend this one
  18       */
  19      class AdminPostManagementCommonAction extends AdminAction
  20      {
  21  
  22          var $_postText;
  23          var $_postTopic;
  24          var $_postCategories;
  25          var $_postStatus;
  26          var $_sendNotification;
  27          var $_sendPings;
  28          var $_previewPost;
  29          var $_addPost;
  30          var $_commentsEnabled;
  31          var $_globalCategoryId;
  32          var $_trackbackUrls;
  33          var $_posterId;
  34          // stuff about the date
  35          var $_postYear;
  36          var $_postMonth;
  37          var $_postDay;
  38          var $_postHour;
  39          var $_postMinutes;
  40          var $_postTimestamp;
  41          // custom fields
  42          var $_customFields;
  43          var $_postSlug;
  44          var $_postId;    
  45      
  46      
  47  		function AdminPostManagementCommonAction( $actionInfo, $request ) 
  48          {
  49              $this->AdminAction( $actionInfo, $request );
  50          }
  51          
  52  		function _fetchPostDateInformation()
  53          {
  54  
  55              // fetch the timestamp that the post will have
  56                $postDateTime = $this->_request->getValue( "postDateTime" );
  57              $dateTimeParts = explode(" ", $postDateTime);
  58              $dateParts = explode("/", $dateTimeParts[0] );
  59              $timeParts = explode(":",$dateTimeParts[1] );
  60              $this->_postDay = $dateParts[0];
  61              $this->_postMonth = $dateParts[1];
  62              $this->_postYear = $dateParts[2];
  63              $this->_postHour = $timeParts[0];
  64              $this->_postMinutes = $timeParts[1];
  65              
  66              $this->_postTimestamp = new Timestamp();
  67              $this->_postTimestamp->setMinutes( $this->_postMinutes );
  68              $this->_postTimestamp->setHour( $this->_postHour );
  69              $this->_postTimestamp->setDay( $this->_postDay );
  70              $this->_postTimestamp->setMonth( $this->_postMonth );
  71              $this->_postTimestamp->setYear( $this->_postYear );
  72          }
  73          
  74          /**
  75           * @private
  76           */
  77  		function _generateCalendarInformation()
  78          {
  79              $this->_months = $this->_locale->getMonthNames();
  80              $this->_years = range( 1990, 2030 );
  81              $this->_minutes = Array( "00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
  82                                  "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
  83                                  "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
  84                                  "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
  85                                  "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
  86                                  "50", "51", "52", "53", "54", "55", "56", "57", "58", "59" );
  87              $this->_hours = Array( "00", "01", "02", "03", "04", "05", "06", "07", "08",
  88                                     "09", "10", "11", "12", "13", "14", "15", "16", "17",
  89                                     "18", "19", "20", "21", "22", "23" );
  90          }
  91          
  92          /**
  93           * sends xmlrpc pings
  94           */
  95          function sendXmlRpcPings()
  96          {
  97              // send the xmlrpc ping
  98  
  99              if( !$this->_config->getValue( "xmlrpc_ping_enabled", false ))
 100                  return "";
 101  
 102              lt_include( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
 103              $notifications = new ArticleNotifications();
 104              $resultArray = $notifications->updateNotify( $this->_blogInfo );
 105              
 106              // check to prevent throwing an error if the list is empty
 107              if( $resultArray == "" || empty( $resultArray ))
 108                  return "";
 109              
 110              $message = "";
 111              foreach( $resultArray as $host => $result ) {
 112                  if( $result == "OK" )
 113                      $message .= $this->_locale->tr("xmlrpc_ping_ok").$host.".<br/>";
 114                  else {
 115                      $message .= $this->_locale->tr("error_sending_xmlrpc_ping").$host.".";
 116                      if( $result != "" ) $message .= "<br/>".$this->_locale->tr("error_sending_xmlrpc_ping_message").$result.".";
 117                      $message .= "<br/>";
 118                   }
 119              }
 120  
 121              return $message;
 122          }
 123          
 124  		function _fetchCommonData()
 125          {
 126              if( ini_get( "magic_quotes_gpc" ))
 127                  $this->_postText = stripslashes($this->_request->getValue( "postText" ));
 128              else
 129                  $this->_postText = $this->_request->getValue( "postText" );
 130              
 131              // check if javascript code is allowed in posts
 132              $config =& Config::getConfig();
 133              if( !$config->getValue( "allow_javascript_blocks_in_posts", false )) {
 134                  $this->_postText = Textfilter::filterJavaScript( $this->_postText );
 135              }    
 136              $this->_postText = trim(Textfilter::xhtmlize( $this->_postText ));
 137              $this->_postTopic    = trim(Textfilter::xhtmlize(Textfilter::filterAllHTML($this->_request->getValue( "postTopic" ))));
 138              $this->_posterId = $this->_request->getValue( "posterId" );
 139              $this->_postCategories = $this->_request->getValue( "postCategories" );
 140              $this->_postSlug = Textfilter::filterAllHTML($this->_request->getValue( "postSlug" ));
 141              $this->_postStatus   = $this->_request->getValue( "postStatus" );
 142              $this->_sendNotification = $this->_request->getValue( "sendNotification" );
 143              $this->_sendTrackbacks = $this->_request->getValue( "sendTrackbacks" );
 144              $this->_sendPings = $this->_request->getValue( "sendPings" );            
 145              $this->_postId       = $this->_request->getValue( "postId" );
 146              $this->_commentsEnabled = $this->_request->getValue( "commentsEnabled" );
 147              $this->_globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
 148              $this->_trackbackUrls = $this->_request->getValue( "trackbackUrls" );
 149                  
 150              // fetch the custom fields
 151              $this->_customFields = $this->_request->getValue( "customField" );    
 152              
 153              // fetch the timestamp that the post will have
 154              $this->_fetchPostDateInformation();
 155  
 156              // information about the poster but only if the user is supposed to be able to change it
 157              if( $this->_userInfo->hasPermissionByName( "update_all_user_articles", $this->_blogInfo->getId()) || 
 158                  $this->_userInfo->isSiteAdmin() || 
 159                  $this->_blogInfo->getOwnerId() == $this->_userInfo->getId()) {            
 160                  $this->_posterId = $this->_request->getValue( "postUser" );
 161              }
 162              else {
 163                  $this->_posterId = $this->_userInfo->getId();
 164              }            
 165          }
 166          
 167          /**
 168           * @private
 169           */
 170  		function _getArticleCustomFields()
 171          {
 172              // prepare the custom fields            
 173              $fields = Array();
 174              if( is_array($this->_customFields)) {
 175                  foreach( $this->_customFields as $fieldId => $fieldValue ) {
 176                      // 3 of those parameters are not really need when creating a new object... it's enough that
 177                      // we know the field definition id.
 178                      $row = Array( "field_id" => $fieldId,
 179                                    "field_value" => $fieldValue,
 180                                    "field_name" => "",  // don't know
 181                                    "field_type" => -1, // don't know
 182                                    "field_description" => "", // don't know
 183                                    "article_id" => -1, // we don't know yet!
 184                                    "blog_id" => $this->_blogInfo->getId(),
 185                                    "id" => -1 ); 
 186                      // let's get the right value
 187                      $customField = CustomFieldValueFactory::getCustomFieldValueByFieldId( $fieldId, $row );
 188                      $fieldName = $customField->getName();
 189                      $fields["$fieldName"] = $customField;
 190                  }
 191              }        
 192              
 193              return $fields;
 194          }
 195      }
 196  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics