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


PHP Utility\Sanitize类代码示例

本文整理汇总了PHP中Hubzero\Utility\Sanitize的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize类的具体用法?PHP Sanitize怎么用?PHP Sanitize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Sanitize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onContentBeforeSave

 /**
  * Finder before save content method
  * Article is passed by reference, but after the save, so no changes will be saved.
  * Method is called right after the content is saved
  *
  * @param   string The context of the content passed to the plugin
  */
 public function onContentBeforeSave($context, &$article, $isNew)
 {
     if (!$article instanceof \Hubzero\Base\Object || $context == 'com_content.article') {
         return;
     }
     $key = $this->_key($context);
     $content = ltrim($article->get($key));
     if (!$content) {
         return;
     }
     // Is there a format already applied?
     if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $content, $matches)) {
         $format = strtolower(trim($matches[1]));
         if ($format != 'html') {
             return;
         }
     } elseif (strstr($content, '</')) {
         // Force apply a format?
         if (!$this->params->get('applyFormat')) {
             return;
         }
     }
     if ($this->params->get('sanitizeBefore', 1)) {
         $content = \Hubzero\Utility\Sanitize::clean($content);
         $content = \Hubzero\Utility\Sanitize::html($content);
     }
     if ($this->params->get('applyFormat')) {
         $content = preg_replace('/^(<!-- \\{FORMAT:HTML\\} -->)/i', '', $content);
         $content = '<!-- {FORMAT:HTML} -->' . $content;
     }
     $article->set($key, $content);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:39,代码来源:formathtml.php

示例2: __invoke

 /**
  * Clean some text
  *
  * @param   string  $text  Text to clean
  * @return  string
  * @throws  \InvalidArgumentException If no text passed
  */
 public function __invoke($text = null)
 {
     if (null === $text) {
         throw new \InvalidArgumentException(__METHOD__ . '(); No text passed.');
     }
     return Sanitize::clean($text);
 }
开发者ID:mined-gatech,项目名称:framework,代码行数:14,代码来源:Clean.php

示例3: check

 /**
  * Validate data
  *
  * @return  boolean  True if data is valid
  */
 public function check()
 {
     $this->title = trim($this->title);
     if ($this->title == '') {
         $this->setError(Lang::txt('Missing title for the wish list'));
         return false;
     }
     $this->description = rtrim(stripslashes($this->description));
     $this->description = Sanitize::clean($this->description);
     $this->description = nl2br($this->description);
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:17,代码来源:wishlist.php

示例4: onIndex

 /**
  * onIndex 
  * 
  * @param string $type
  * @param integer $id 
  * @param boolean $run 
  * @access public
  * @return void
  */
 public function onIndex($type, $id, $run = false)
 {
     if ($type == 'publication') {
         if ($run === true) {
             // Establish a db connection
             $db = App::get('db');
             // Sanitize the string
             $id = \Hubzero\Utility\Sanitize::paranoid($id);
             // Get the record
             $sql = "SELECT\n\t\t\t\t\t#__publications.id,\n\t\t\t\t\talias,\n\t\t\t\t\t#__publications.access,\n\t\t\t\t\tmaster_doi,\n\t\t\t\t\tpublished_up,\n\t\t\t\t\t#__publications.created_by,\n\t\t\t\t\tabstract,\n\t\t\t\t\tdescription,\n\t\t\t\t\ttitle,\n\t\t\t\t\tdoi,\n\t\t\t\t\tstate,\n\t\t\t\t\trelease_notes,\n\t\t\t\t\tMAX(#__publication_versions.id) as latestVersion\n\t\t\t\t\tFROM #__publications \n\t\t\t\tLEFT JOIN #__publication_versions\n\t\t\t\tON #__publications.id = #__publication_versions.publication_id\n\t\t\t\tWHERE #__publications.id = {$id};";
             $row = $db->setQuery($sql)->query()->loadObject();
             // Get the name of the author
             if (isset($row->latestVersion)) {
                 $sql1 = "SELECT user_id, name FROM #__publication_authors WHERE publication_version_id={$row->latestVersion} AND role != 'submitter';";
                 $authors = $db->setQuery($sql1)->query()->loadAssocList();
                 // Get any tags
                 $sql2 = "SELECT tag\n\t\t\t\t\t\tFROM #__tags\n\t\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\t\tWHERE #__tags_object.objectid = {$row->latestVersion} AND #__tags_object.tbl = 'publications';";
                 $tags = $db->setQuery($sql2)->query()->loadColumn();
             } else {
                 $authors = array();
                 $tags = array();
             }
             // @TODO: PHP 5.5 includes array_column()
             $owners = array();
             $authorNames = array();
             if (isset($authors) && !empty($authors)) {
                 foreach ($authors as $author) {
                     array_push($owners, $author['user_id']);
                 }
                 foreach ($authors as $author) {
                     array_push($authorNames, $author['name']);
                 }
             }
             // Determine the path
             if ($row->alias != '') {
                 $path = '/publications/' . $row->alias;
             } else {
                 $path = '/publications/' . $id;
             }
             // Public condition
             if ($row->state == 1 && $row->access == 0) {
                 $access_level = 'public';
             } elseif ($row->state == 1 && $row->access == 1) {
                 $access_level = 'registered';
             } else {
                 $access_level = 'private';
             }
             // Authors have access
             $owner_type = 'user';
             // So does submitter;
             array_push($owners, $row->created_by);
             // Get the title
             $title = $row->title;
             // Build the description, clean up text
             $content = $row->abstract . ' ' . $row->description . ' ' . $row->release_notes;
             $content = preg_replace('/<[^>]*>/', ' ', $content);
             $content = preg_replace('/ {2,}/', ' ', $content);
             $description = \Hubzero\Utility\Sanitize::stripAll($content);
             if (isset($row->doi)) {
                 $doi = $row->doi;
             } else {
                 $doi = '';
             }
             // Create a record object
             $record = new \stdClass();
             $record->id = $type . '-' . $id;
             $record->hubtype = $type;
             $record->title = $title;
             $record->description = $description;
             $record->author = $authorNames;
             $row->doi = $doi;
             $record->tags = $tags;
             $record->path = $path;
             $record->access_level = $access_level;
             $record->owner = $owners;
             $record->owner_type = $owner_type;
             // Return the formatted record
             return $record;
         } else {
             $db = App::get('db');
             $sql = "SELECT id FROM #__publications;";
             $ids = $db->setQuery($sql)->query()->loadColumn();
             return $ids;
         }
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:95,代码来源:publications.php

示例5:

?>
								<?php 
echo 'Email: ' . $this->shipping['email'];
?>
</td>
							</tr>
							<?php 
if ($this->shipping['comments']) {
    ?>
							<tr>
								<th style="text-align: right; padding: 0 0.5em; font-weight: bold; white-space: nowrap; vertical-align: top;" align="right"><?php 
    echo Lang::txt('COM_STORE_DETAILS');
    ?>
:</th>
								<td style="text-align: left; padding: 0 0.5em; vertical-align: top;" width="100%" align="left"><?php 
    echo \Hubzero\Utility\Sanitize::stripAll($this->shipping['comments']);
    ?>
</td>
							</tr>
							<?php 
}
?>
						</tbody>
					</table>
				</td>
			</tr>
		</tbody>
	</table>

	<!-- Start Spacer -->
	<table class="tbl-spacer" width="100%" cellpadding="0" cellspacing="0" border="0">
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:confirmation_html.php

示例6: saveTask

 /**
  * Saves a project
  * Redirects to main listing
  *
  * @param   boolean  $redirect
  * @return  void
  */
 public function saveTask($redirect = false)
 {
     // Check for request forgeries
     Request::checkToken();
     // Config
     $setup_complete = $this->config->get('confirm_step', 0) ? 3 : 2;
     // Incoming
     $formdata = $_POST;
     $id = Request::getVar('id', 0);
     $action = Request::getVar('admin_action', '');
     $message = rtrim(\Hubzero\Utility\Sanitize::clean(Request::getVar('message', '')));
     // Load model
     $model = new Models\Project($id);
     if (!$model->exists()) {
         App::redirect('index.php?option=' . $this->_option, Lang::txt('COM_PROJECTS_NOTICE_ID_NOT_FOUND'), 'error');
     }
     $title = $formdata['title'] ? rtrim($formdata['title']) : $model->get('title');
     $type = isset($formdata['type']) ? $formdata['type'] : 1;
     $model->set('title', $title);
     $model->set('about', rtrim(\Hubzero\Utility\Sanitize::clean($formdata['about'])));
     $model->set('type', $type);
     $model->set('modified', Date::toSql());
     $model->set('modified_by', User::get('id'));
     $model->set('private', Request::getInt('private', 0));
     $this->_message = Lang::txt('COM_PROJECTS_SUCCESS_SAVED');
     // Was project suspended?
     $suspended = false;
     if ($model->isInactive()) {
         $suspended = $model->table('Activity')->checkActivity($id, Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_SUSPENDED'));
     }
     $subject = Lang::txt('COM_PROJECTS_PROJECT') . ' "' . $model->get('alias') . '" ';
     $sendmail = 0;
     // Get project managers
     $managers = $model->table('Owner')->getIds($id, 1, 1);
     // Admin actions
     if ($action) {
         switch ($action) {
             case 'delete':
                 $model->set('state', 2);
                 $what = Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_DELETED');
                 $subject .= Lang::txt('COM_PROJECTS_MSG_ADMIN_DELETED');
                 $this->_message = Lang::txt('COM_PROJECTS_SUCCESS_DELETED');
                 break;
             case 'suspend':
                 $model->set('state', 0);
                 $what = Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_SUSPENDED');
                 $subject .= Lang::txt('COM_PROJECTS_MSG_ADMIN_SUSPENDED');
                 $this->_message = Lang::txt('COM_PROJECTS_SUCCESS_SUSPENDED');
                 break;
             case 'reinstate':
                 $model->set('state', 1);
                 $what = $suspended ? Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_REINSTATED') : Lang::txt('COM_PROJECTS_ACTIVITY_PROJECT_ACTIVATED');
                 $subject .= $suspended ? Lang::txt('COM_PROJECTS_MSG_ADMIN_REINSTATED') : Lang::txt('COM_PROJECTS_MSG_ADMIN_ACTIVATED');
                 $this->_message = $suspended ? Lang::txt('COM_PROJECTS_SUCCESS_REINSTATED') : Lang::txt('COM_PROJECTS_SUCCESS_ACTIVATED');
                 break;
         }
         // Add activity
         $model->recordActivity($what, 0, '', '', 'project', 0, $admin = 1);
         $sendmail = 1;
     } elseif ($message) {
         $subject .= ' - ' . Lang::txt('COM_PROJECTS_MSG_ADMIN_NEW_MESSAGE');
         $sendmail = 1;
         $this->_message = Lang::txt('COM_PROJECTS_SUCCESS_MESSAGE_SENT');
     }
     // Save changes
     if (!$model->store()) {
         $this->setError($model->getError());
         return false;
     }
     // Incoming tags
     $tags = Request::getVar('tags', '', 'post');
     // Save the tags
     $cloud = new Models\Tags($model->get('id'));
     $cloud->setTags($tags, User::get('id'), 1);
     // Save params
     $incoming = Request::getVar('params', array());
     if (!empty($incoming)) {
         foreach ($incoming as $key => $value) {
             if ($key == 'quota' || $key == 'pubQuota') {
                 // convert GB to bytes
                 $value = Helpers\Html::convertSize(floatval($value), 'GB', 'b');
             }
             $model->saveParam($key, $value);
         }
     }
     // Add members if specified
     $this->model = $model;
     $this->_saveMember();
     // Change ownership
     $this->_changeOwnership();
     // Send message
     if ($this->config->get('messaging', 0) && $sendmail && count($managers) > 0) {
         // Email config
//.........这里部分代码省略.........
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:101,代码来源:projects.php

示例7: saveTask

 /**
  * Save an event
  *
  * @return     void
  */
 public function saveTask()
 {
     // Check if they are logged in
     if (User::isGuest()) {
         $this->loginTask();
         return;
     }
     // good ol' form validation
     Request::checkToken();
     Request::checkHoneypot() or die('Invalid Field Data Detected. Please try again.');
     $offset = $this->offset;
     // Incoming
     $start_time = Request::getVar('start_time', '08:00', 'post');
     $start_time = $start_time ? $start_time : '08:00';
     $start_pm = Request::getInt('start_pm', 0, 'post');
     $end_time = Request::getVar('end_time', '17:00', 'post');
     $end_time = $end_time ? $end_time : '17:00';
     $end_pm = Request::getInt('end_pm', 0, 'post');
     $time_zone = Request::getVar('time_zone', -5, 'post');
     $tags = Request::getVar('tags', '', 'post');
     // Bind the posted data to an event object
     $row = new Event($this->database);
     if (!$row->bind($_POST)) {
         throw new Exception($row->getError(), 500);
     }
     // New entry or existing?
     if ($row->id) {
         $state = 'edit';
         // Existing - update modified info
         $row->modified = strftime("%Y-%m-%d %H:%M:%S", time() + $offset * 60 * 60);
         if (User::get('id')) {
             $row->modified_by = User::get('id');
         }
     } else {
         $state = 'add';
         // New - set created info
         $row->created = strftime("%Y-%m-%d %H:%M:%S", time() + $offset * 60 * 60);
         if (User::get('id')) {
             $row->created_by = User::get('id');
         }
     }
     // Set some fields and do some cleanup work
     if ($row->catid) {
         $row->catid = intval($row->catid);
     }
     //$row->title = htmlentities($row->title);
     $row->content = $_POST['econtent'];
     $row->content = \Hubzero\Utility\Sanitize::clean($row->content);
     // Get the custom fields defined in the events configuration
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
         $fields = array_map('trim', $fields);
         // Wrap up the content of the field and attach it to the event content
         $fs = $this->config->fields;
         foreach ($fields as $param => $value) {
             if (trim($value) != '') {
                 $row->content .= '<ef:' . $param . '>' . $this->_clean($value) . '</ef:' . $param . '>';
             } else {
                 foreach ($fs as $f) {
                     if ($f[0] == $param && end($f) == 1) {
                         throw new Exception(Lang::txt('EVENTS_REQUIRED_FIELD_CHECK', $f[1]), 500);
                     }
                 }
             }
         }
     }
     // Clean adresse
     $row->adresse_info = $this->_clean($row->adresse_info);
     // Clean contact
     $row->contact_info = $this->_clean($row->contact_info);
     // Clean extra
     $row->extra_info = $this->_clean($row->extra_info);
     // Prepend http:// to URLs without it
     if ($row->extra_info != NULL) {
         if (substr($row->extra_info, 0, 7) != 'http://' && substr($row->extra_info, 0, 8) != 'https://') {
             $row->extra_info = 'http://' . $row->extra_info;
         }
     }
     // Reformat the time into 24hr format if necessary
     if ($this->config->getCfg('calUseStdTime') == 'YES') {
         list($hrs, $mins) = explode(':', $start_time);
         $hrs = intval($hrs);
         $mins = intval($mins);
         if ($hrs != 12 && $start_pm) {
             $hrs += 12;
         } else {
             if ($hrs == 12 && !$start_pm) {
                 $hrs = 0;
             }
         }
         if ($hrs < 10) {
             $hrs = '0' . $hrs;
         }
         if ($mins < 10) {
             $mins = '0' . $mins;
//.........这里部分代码省略.........
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:101,代码来源:events.php

示例8: _feed

 /**
  * Display a feed of comments
  *
  * @return    void
  */
 protected function _feed()
 {
     if (!$this->params->get('comments_feeds')) {
         $this->action = 'view';
         $this->_view();
         return;
     }
     // Set the mime encoding for the document
     Document::setType('feed');
     // Load the comments
     $comment = new \Plugins\Hubzero\Comments\Models\Comment();
     $filters = array('parent' => 0, 'item_type' => $this->obj_type, 'item_id' => $this->obj_id);
     if ($this->obj instanceof \Hubzero\Base\Model) {
         $title = $this->obj->get('title');
     } else {
         $title = $this->obj->title;
     }
     // Start a new feed object
     $doc = Document::instance();
     $doc->link = Route::url($this->url);
     $doc->title = Config::get('sitename') . ' - ' . Lang::txt(strtoupper($this->_option));
     $doc->title .= $title ? ': ' . stripslashes($title) : '';
     $doc->title .= ': ' . Lang::txt('PLG_HUBZERO_COMMENTS');
     $doc->description = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_DESCRIPTION', Config::get('sitename'), stripslashes($title));
     $doc->copyright = Lang::txt('PLG_HUBZERO_COMMENTS_RSS_COPYRIGHT', date("Y"), Config::get('sitename'));
     // Start outputing results if any found
     if ($comment->replies('list', $filters)->total() > 0) {
         foreach ($comment->replies() as $row) {
             // URL link to article
             $link = Route::url('index.php?option=' . $this->_option . '&section=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $row->id);
             $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS');
             if (!$row->get('anonymous')) {
                 $author = $row->creator('name');
             }
             // Prepare the title
             $title = Lang::txt('PLG_HUBZERO_COMMENTS_COMMENT_BY', $author) . ' @ ' . $row->created('time') . ' on ' . $row->created('date');
             // Strip html from feed item description text
             if ($row->isReported()) {
                 $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE');
             } else {
                 $description = $row->content('clean');
             }
             @($date = $row->created() ? date('r', strtotime($row->created())) : '');
             // Load individual item creator class
             $item = new \Hubzero\Document\Type\Feed\Item();
             $item->title = $title;
             $item->link = $link;
             $item->description = $description;
             $item->date = $date;
             $item->category = '';
             $item->author = $author;
             // Loads item info into rss array
             $doc->addItem($item);
             // Check for any replies
             if ($row->replies()->total()) {
                 foreach ($row->replies() as $reply) {
                     // URL link to article
                     $link = Route::url('index.php?option=' . $this->_option . '&section=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $reply->id);
                     $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS');
                     if (!$reply->anonymous) {
                         $cuser = User::getInstance($reply->created_by);
                         $author = $cuser->get('name');
                     }
                     // Prepare the title
                     $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $row->id, $author) . ' @ ' . Date::of($reply->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($reply->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
                     // Strip html from feed item description text
                     if ($reply->reports) {
                         $description = Lang::txt('PLG_HUBZERO_COMMENTS_REPORTED_AS_ABUSIVE');
                     } else {
                         $description = is_object($p) ? $p->parse(stripslashes($reply->content)) : nl2br(stripslashes($reply->content));
                     }
                     $description = html_entity_decode(\Hubzero\Utility\Sanitize::clean($description));
                     @($date = $reply->created ? gmdate('r', strtotime($reply->created)) : '');
                     // Load individual item creator class
                     $item = new \Hubzero\Document\Type\Feed\Item();
                     $item->title = $title;
                     $item->link = $link;
                     $item->description = $description;
                     $item->date = $date;
                     $item->category = '';
                     $item->author = $author;
                     // Loads item info into rss array
                     $doc->addItem($item);
                     if ($reply->replies) {
                         foreach ($reply->replies as $response) {
                             // URL link to article
                             $link = Route::url('index.php?option=' . $this->_option . '&section=' . $section->alias . '&category=' . $category->alias . '&alias=' . $entry->alias . '#c' . $response->id);
                             $author = Lang::txt('PLG_HUBZERO_COMMENTS_ANONYMOUS');
                             if (!$response->anonymous) {
                                 $cuser = User::getInstance($response->created_by);
                                 $author = $cuser->get('name');
                             }
                             // Prepare the title
                             $title = Lang::txt('PLG_HUBZERO_COMMENTS_REPLY_TO_COMMENT', $reply->id, $author) . ' @ ' . Date::of($response->created)->toLocal(Lang::txt('TIME_FORMAT_HZ1')) . ' ' . Lang::txt('PLG_HUBZERO_COMMENTS_ON') . ' ' . Date::of($response->created)->toLocal(Lang::txt('DATE_FORMAT_HZ1'));
                             // Strip html from feed item description text
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:comments.php

示例9: out

 /**
  * Static method for formatting results
  *
  * @param      object $row Database row
  * @return     string HTML
  */
 public static function out($row)
 {
     $row->href = Route::url($row->href);
     $month = Date::of($row->publish_up)->toLocal('M');
     $day = Date::of($row->publish_up)->toLocal('d');
     $year = Date::of($row->publish_up)->toLocal('Y');
     // Start building the HTML
     $html = "\t" . '<li class="event">' . "\n";
     $html .= "\t\t" . '<p class="event-date"><span class="month">' . $month . '</span> <span class="day">' . $day . '</span> <span class="year">' . $year . '</span></p>' . "\n";
     $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n";
     if ($row->ftext) {
         $row->ftext = str_replace('[[BR]]', '', $row->ftext);
         // Remove tags to prevent tables from being displayed within a table.
         $row->ftext = strip_tags($row->ftext);
         $html .= "\t\t" . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->ftext)), 200) . "\n";
     }
     $html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n";
     $html .= "\t" . '</li>' . "\n";
     // Return output
     return $html;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:27,代码来源:events.php

示例10: rtrim

}
$base = rtrim(Request::base(), '/');
$html = '<h3>' . $this->escape(stripslashes($name)) . ' <span>(' . Lang::txt('COM_TAGS_RESULTS_THROUGH_OF', $this->filters['start'] + 1, $ttl, $total) . ')</span></h3>' . "\n";
if ($this->results) {
    $html .= '<ol class="results">' . "\n";
    foreach ($this->results as $row) {
        $obj = 'plgTags' . ucfirst($row->section);
        if (method_exists($obj, 'out')) {
            $html .= call_user_func(array($obj, 'out'), $row);
        } else {
            // @todo accomodate scope (aka) group citations
            if (strstr($row->href, 'index.php')) {
                $row->href = Route::url($row->href);
            }
            $html .= "\t" . '<li>' . "\n";
            $html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . \Hubzero\Utility\Sanitize::clean($row->title) . '</a></p>' . "\n";
            if ($row->ftext) {
                $html .= "\t\t" . '<p>' . \Hubzero\Utility\String::truncate(strip_tags($row->ftext), 200) . "</p>\n";
            }
            $html .= "\t\t" . '<p class="href">' . $base . $row->href . '</p>' . "\n";
            $html .= "\t" . '</li>' . "\n";
        }
    }
    $html .= '</ol>' . "\n";
} else {
    $html = '<p class="warning">' . Lang::txt('COM_TAGS_NO_RESULTS') . '</p>';
}
echo $html;
?>
				</div><!-- / .container-block -->
				<?php 
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:view.php

示例11: _filterHandler

 /**
  * Applies filters to Citations model and returns applied filters
  * @param array  $filters array of POST values
  * @return	array sanitized and validated filter values
  */
 private function _filterHandler($filters = array(), $scope_id = 0)
 {
     $citations = \Components\Citations\Models\Citation::all();
     // require citations
     if (!$citations) {
         return false;
     }
     // get the ones for this group
     $citations->where('scope', '=', 'member');
     $citations->where('scope_id', '=', $scope_id);
     $citations->where('published', '!=', $citations::STATE_DELETED);
     // don't include deleted citations
     if (count($filters) > 0) {
         foreach ($filters as $filter => $value) {
             // sanitization
             $value = \Hubzero\Utility\Sanitize::clean($value);
             // we handle things differently in search and sorting
             if ($filter != 'search' && $filter != 'sort' && $filter != 'tag' && $value != "") {
                 switch ($filter) {
                     case 'author':
                         $citations->where('author', 'LIKE', "%{$value}%", 'and', 1);
                         break;
                     case 'publishedin':
                         $citations->where('date_publish', 'LIKE', "%{$value}-%");
                         break;
                     case 'year_start':
                         $citations->where('year', '>=', $value);
                         break;
                     case 'year_end':
                         $citations->where('year', '<=', $value);
                         break;
                     case 'filter':
                         if ($value == 'aff') {
                             $value = 1;
                         } else {
                             $value = 0;
                         }
                         $citations->where('affiliated', '=', $value);
                         break;
                     default:
                         $citations->where($filter, '=', $value);
                         break;
                 }
             }
             // end if not search & not sort & non-empty value
             // for searching
             if ($filter == "search" && $value != "") {
                 $terms = preg_split('/\\s+/', $value);
                 $value = \Hubzero\Utility\Sanitize::clean($value);
                 $term = $value;
                 $collection = array();
                 $columns = array('author', 'title', 'isbn', 'doi', 'publisher', 'abstract');
                 foreach ($columns as $column) {
                     foreach ($terms as $term) {
                         // copy the original item
                         $cite = clone $citations;
                         // do some searching
                         $cite->where($column, 'LIKE', "%{$term}%");
                         foreach ($cite as $c) {
                             // put for collection later
                             array_push($collection, $c->id);
                         }
                         // end foreach $cite
                     }
                     // end foreach terms
                 }
                 // end foreach columns
                 // remove duplicates
                 $collection = array_unique($collection);
                 // pull the appropriate ones.
                 $citations->whereIn('id', $collection);
             }
             // end searching
             // for tags
             if ($filter == "tag" && $value != "") {
                 $collection = array();
                 $cite = clone $citations;
                 foreach ($cite as $c) {
                     foreach ($c->tags as $tag) {
                         if ($tag->tag == $value) {
                             array_push($collection, $c->id);
                         }
                     }
                 }
                 // remove duplicates
                 $collection = array_unique($collection);
                 // get the tagged ones
                 $citations->whereIn('id', $collection);
             }
             // end if tags
             if ($filter == "sort" && $value != "") {
                 $clause = explode(" ", $value);
                 $citations->order($clause[0], $clause[1]);
             }
         }
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:citations.php

示例12: feedTask


//.........这里部分代码省略.........
     if ($area) {
         $activeareas = array($area);
     } else {
         $activeareas = $areas;
     }
     // Get the search results
     if (count($activeareas) > 1) {
         $sqls = Event::trigger('tags.onTagView', array($tags, $limit, $limitstart, $sort, $activeareas));
         if ($sqls) {
             $s = array();
             foreach ($sqls as $sql) {
                 if (!is_string($sql)) {
                     continue;
                 }
                 if (trim($sql) != '') {
                     $s[] = $sql;
                 }
             }
             $query = "(";
             $query .= implode(") UNION (", $s);
             $query .= ") ORDER BY ";
             switch ($sort) {
                 case 'title':
                     $query .= 'title ASC, publish_up';
                     break;
                 case 'id':
                     $query .= "id DESC";
                     break;
                 case 'date':
                 default:
                     $query .= 'publish_up DESC, title';
                     break;
             }
             $query .= $limit != 'all' && $limit > 0 ? " LIMIT {$limitstart}, {$limit}" : "";
         }
         $this->database->setQuery($query);
         $results = array($this->database->loadObjectList());
     } else {
         $results = Event::trigger('tags.onTagView', array($tags, $limit, $limitstart, $sort, $activeareas));
     }
     // Run through the array of arrays returned from plugins and find the one that returned results
     $rows = array();
     if ($results) {
         foreach ($results as $result) {
             if (is_array($result) && !empty($result)) {
                 $rows = $result;
                 break;
             }
         }
     }
     // Build some basic RSS document information
     $title = Lang::txt(strtoupper($this->_option)) . ': ';
     for ($i = 0, $n = count($tags); $i < $n; $i++) {
         if ($i > 0) {
             $title .= '+ ';
         }
         $title .= $tags[$i]->get('raw_tag') . ' ';
     }
     $title = trim($title);
     $title .= ': ' . $area;
     // Set the mime encoding for the document
     Document::setType('feed');
     // Start a new feed object
     $doc = Document::instance();
     $doc->link = Route::url('index.php?option=' . $this->_option);
     $doc->title = Config::get('sitename') . ' - ' . $title;
     $doc->description = Lang::txt('COM_TAGS_RSS_DESCRIPTION', Config::get('sitename'), $title);
     $doc->copyright = Lang::txt('COM_TAGS_RSS_COPYRIGHT', gmdate("Y"), Config::get('sitename'));
     $doc->category = Lang::txt('COM_TAGS_RSS_CATEGORY');
     // Start outputing results if any found
     if (count($rows) > 0) {
         include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'helper.php';
         foreach ($rows as $row) {
             // Prepare the title
             $title = strip_tags($row->title);
             $title = html_entity_decode($title);
             // Strip html from feed item description text
             $description = html_entity_decode(String::truncate(Sanitize::stripAll(stripslashes($row->ftext)), 300));
             $author = '';
             @($date = $row->publish_up ? date('r', strtotime($row->publish_up)) : '');
             if (isset($row->data3) || isset($row->rcount)) {
                 $resourceEx = new \Components\Resources\Helpers\Helper($row->id, $this->database);
                 $resourceEx->getCitationsCount();
                 $resourceEx->getLastCitationDate();
                 $resourceEx->getContributors();
                 $author = strip_tags($resourceEx->contributors);
             }
             // Load individual item creator class
             $item = new \Hubzero\Document\Type\Feed\Item();
             $item->title = $title;
             $item->link = $row->href;
             $item->description = $description;
             $item->date = $date;
             $item->category = isset($row->data1) ? $row->data1 : '';
             $item->author = $author;
             // Loads item info into rss array
             $doc->addItem($item);
         }
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:tags.php

示例13: dorequestTask

 /**
  * Add membership request for user
  *
  * @return  array
  */
 public function dorequestTask()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         $this->loginTask(Lang::txt('COM_GROUPS_INVITE_MUST_BE_LOGGED_IN_TO_REQUEST'));
         return;
     }
     Request::checkToken();
     //check to make sure we have  cname
     if (!$this->cn) {
         $this->_errorHandler(400, Lang::txt('COM_GROUPS_ERROR_NO_ID'));
     }
     // Load the group page
     $this->view->group = Group::getInstance($this->cn);
     // Ensure we found the group info
     if (!$this->view->group || !$this->view->group->get('gidNumber')) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Get the group params
     $gparams = new Registry($this->view->group->get('params'));
     // If membership is managed in seperate place disallow action
     if ($gparams->get('membership_control', 1) == 0) {
         $this->setNotification(Lang::txt('COM_GROUPS_MEMBERSHIP_MANAGED_ELSEWHERE'), 'error');
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->view->group->get('cn')));
         return;
     }
     //make sure group has restricted policy
     if ($this->view->group->get('join_policy') != 1) {
         return;
     }
     //add user to applicants
     $this->view->group->add('applicants', array(User::get('id')));
     $this->view->group->update();
     // Instantiate the reason object and bind the incoming data
     $row = new Reason($this->database);
     $row->uidNumber = User::get('id');
     $row->gidNumber = $this->view->group->get('gidNumber');
     $row->reason = Request::getVar('reason', Lang::txt('GROUPS_NO_REASON_GIVEN'), 'post');
     $row->reason = \Hubzero\Utility\Sanitize::stripAll($row->reason);
     $row->date = Date::toSql();
     // Check and store the reason
     if (!$row->check()) {
         return App::abort(500, $row->getError());
     }
     if (!$row->store()) {
         return App::abort(500, $row->getError());
     }
     // Log the membership request
     Log::log(array('gidNumber' => $this->view->group->get('gidNumber'), 'action' => 'membership_requested', 'comments' => array(User::get('id'))));
     // Log activity
     $url = Route::url('index.php?option=' . $this->_option . '&cn=' . $this->view->group->get('cn'));
     $recipients = array(['group', $this->view->group->get('gidNumber')], ['user', User::get('id')]);
     foreach ($this->view->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => 'requested', 'scope' => 'group', 'scope_id' => $this->view->group->get('gidNumber'), 'description' => Lang::txt('COM_GROUPS_ACTIVITY_GROUP_USER_REQUESTED', '<a href="' . $url . '">' . $this->view->group->get('description') . '</a>'), 'details' => array('title' => $this->view->group->get('description'), 'url' => $url, 'cn' => $this->view->group->get('cn'), 'gidNumber' => $this->view->group->get('gidNumber'))], 'recipients' => $recipients]);
     // E-mail subject
     $subject = Lang::txt('COM_GROUPS_JOIN_REQUEST_EMAIL_SUBJECT', $this->view->group->get('cn'));
     // Build the e-mail message
     $eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'request'));
     $eview->option = $this->_option;
     $eview->sitename = Config::get('sitename');
     $eview->user = User::getInstance();
     $eview->group = $this->view->group;
     $eview->row = $row;
     $html = $eview->loadTemplate();
     $html = str_replace("\n", "\r\n", $html);
     // Get the system administrator e-mail
     $emailadmin = Config::get('mailfrom');
     // Build the "from" portion of the e-mail
     $from = array();
     $from['name'] = Config::get('sitename') . ' ' . Lang::txt(strtoupper($this->_name));
     $from['email'] = Config::get('mailfrom');
     // build array of managers
     $managers = array();
     foreach ($this->view->group->get('managers') as $m) {
         $profile = User::getInstance($m);
         if ($profile) {
             $managers[$profile->get('email')] = $profile->get('name');
         }
     }
     // create new message
     $message = new \Hubzero\Mail\Message();
     // build message object and send
     $message->setSubject($subject)->addFrom($from['email'], $from['name'])->setTo($managers)->addHeader('X-Mailer', 'PHP/' . phpversion())->addHeader('X-Component', 'com_groups')->addHeader('X-Component-Object', 'group_membership_requested')->addPart($html, 'text/plain')->send();
     //tell the user they just did good
     $this->setNotification(Lang::txt('COM_GROUPS_INVITE_REQUEST_FORWARDED'), 'passed');
     // Push through to the groups listing
     App::redirect($url);
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:95,代码来源:membership.php

示例14: saveParam

 /**
  * Save param
  *
  * @param      string 	$param
  * @param      string 	$value
  *
  * @return     void
  */
 public function saveParam($param = '', $value = '')
 {
     // Clean up incoming
     $param = \Hubzero\Utility\Sanitize::paranoid($param, array('-', '_'));
     $value = \Hubzero\Utility\Sanitize::clean($value);
     if (!$this->exists()) {
         return false;
     }
     if (!$param || !$value) {
         return false;
     }
     $this->version->saveParam($this->get('version_id'), trim($param), htmlentities($value));
     return $value;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:22,代码来源:publication.php

示例15: save

 /**
  * Save an entry
  *
  * @return    string
  */
 private function save()
 {
     Request::checkToken();
     //get request vars
     $event = Request::getVar('event', array(), 'post');
     $event['time_zone'] = Request::getVar('time_zone', -5);
     $event['params'] = Request::getVar('params', array());
     $event['content'] = Request::getVar('content', '', 'post', 'STRING', JREQUEST_ALLOWRAW);
     $registration = Request::getVar('include-registration', 0);
     //set vars for saving
     $event['catid'] = '-1';
     $event['state'] = 1;
     $event['scope'] = 'group';
     $event['scope_id'] = $this->group->get('gidNumber');
     $event['modified'] = Date::toSql();
     $event['modified_by'] = $this->user->get('id');
     // repeating rule
     $event['repeating_rule'] = $this->_buildRepeatingRule();
     //if we are updating set modified time and actor
     if (!isset($event['id']) || $event['id'] == 0) {
         $event['created'] = Date::toSql();
         $event['created_by'] = $this->user->get('id');
     }
     // timezone
     $timezone = new DateTimezone(Config::get('offset'));
     //parse publish up date/time
     if (isset($event['publish_up']) && $event['publish_up'] != '') {
         // combine date & time
         if (isset($event['publish_up_time'])) {
             $event['publish_up'] = $event['publish_up'] . ' ' . $event['publish_up_time'];
         }
         $event['publish_up'] = Date::of($event['publish_up'], $timezone)->format("Y-m-d H:i:s");
         unset($event['publish_up_time']);
     }
     //parse publish down date/time
     if (isset($event['publish_down']) && $event['publish_down'] != '') {
         // combine date & time
         if (isset($event['publish_down_time'])) {
             $event['publish_down'] = $event['publish_down'] . ' ' . $event['publish_down_time'];
         }
         $event['publish_down'] = Date::of($event['publish_down'], $timezone)->format("Y-m-d H:i:s");
         unset($event['publish_down_time']);
     }
     //parse register by date/time
     if (isset($event['registerby']) && $event['registerby'] != '') {
         //remove @ symbol
         $event['registerby'] = str_replace("@", "", $event['registerby']);
         $event['registerby'] = Date::of($event['registerby'], $timezone)->format("Y-m-d H:i:s");
     }
     //stringify params
     if (isset($event['params']) && count($event['params']) > 0) {
         $params = new \Hubzero\Config\Registry($event['params']);
         $event['params'] = $params->toString();
     }
     //did we want to turn off registration?
     if (!$registration) {
         $event['registerby'] = '0000-00-00 00:00:00';
     }
     //instantiate new event object
     $eventsModelEvent = new \Components\Events\Models\Event();
     // attempt to bind
     if (!$eventsModelEvent->bind($event)) {
         $this->setError($eventsModelEvent->getError());
         $this->event = $eventsModelEvent;
         return $this->edit();
     }
     if (isset($event['content']) && $event['content']) {
         $event['content'] = \Hubzero\Utility\Sanitize::clean($event['content']);
     }
     if (isset($event['extra_info']) && $event['extra_info'] && !\Hubzero\Utility\Validate::url($event['extra_info'])) {
         $this->setError('Website entered does not appear to be a valid URL.');
         $this->event = $eventsModelEvent;
         return $this->edit();
     }
     //make sure we have both start and end time
     if ($event['publish_up'] == '') {
         $this->setError('You must enter an event start, an end date is optional.');
         $this->event = $eventsModelEvent;
         return $this->edit();
     }
     //check to make sure end time is greater than start time
     if (isset($event['publish_down']) && $event['publish_down'] != '0000-00-00 00:00:00' && $event['publish_down'] != '') {
         $up = strtotime($event['publish_up']);
         $down = strtotime($event['publish_down']);
         $allday = isset($event['allday']) && $event['allday'] == 1 ? true : false;
         // make sure up greater than down when not all day
         // when all day event up can equal down
         if ($up >= $down && !$allday || $allday && $up > $down) {
             $this->setError('You must an event end date greater than the start date.');
             $this->event = $eventsModelEvent;
             return $this->edit();
         }
     }
     //make sure registration email is valid
     if ($registration && isset($event['email']) && $event['email'] != '' && !filter_var($event['email'], FILTER_VALIDATE_EMAIL)) {
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:calendar.php


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