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


PHP str_shorten_text函数代码示例

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


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

示例1: Dwoo_Plugin_list_tags

/**
 * Smarty {list_tags} function plugin
 *
 * Type:     function<br>
 * Name:     str<br>
 * Date:     June 22, 2006<br>
 * Purpose:  Render a list of tags
 * @author   Richard Mansfield <richard.mansfield@catalyst.net.nz>
 * @author   Penny Leach <penny@mjollnir.org>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return Internationalized string
 */
function Dwoo_Plugin_list_tags(Dwoo $dwoo, $tags, $owner)
{
    global $USER;
    if (!is_array($tags)) {
        return '';
    }
    if ($owner != $USER->get('id')) {
        return join(', ', array_map('hsc', $tags));
    }
    foreach ($tags as &$t) {
        $t = '<a class="tag" href="' . get_config('wwwroot') . 'tags.php?tag=' . urlencode($t) . '">' . hsc(str_shorten_text($t, 50)) . '</a>';
    }
    return join(', ', $tags);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:28,代码来源:function.list_tags.php

示例2: render_instance

 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     require_once get_config('docroot') . 'artefact/lib.php';
     $configdata = $instance->get('configdata');
     $result = '';
     if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
         foreach ($configdata['artefactids'] as $artefactid) {
             try {
                 $artefact = $instance->get_artefact_instance($artefactid);
             } catch (ArtefactNotFoundException $e) {
                 continue;
             }
             $icondata = array('id' => $artefactid, 'viewid' => $instance->get('view'));
             $detailsurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefactid . '&view=' . $instance->get('view');
             if ($artefact instanceof ArtefactTypeProfileIcon) {
                 require_once 'file.php';
                 $downloadurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $artefactid;
                 $size = filesize(get_dataroot_image_path('artefact/file/profileicons/', $artefactid));
             } else {
                 if ($artefact instanceof ArtefactTypeFile) {
                     $downloadurl = get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactid . '&view=' . $icondata['viewid'];
                     $size = $artefact->get('size');
                 }
             }
             $result .= '<div title="' . hsc($artefact->get('title')) . '">';
             $result .= '<div class="fl"><a href="' . hsc($downloadurl) . '">';
             $result .= '<img src="' . hsc(call_static_method(generate_artefact_class_name($artefact->get('artefacttype')), 'get_icon', $icondata)) . '" alt=""></a></div>';
             $result .= '<div style="margin-left: 30px;">';
             $result .= '<h4><a href="' . hsc($detailsurl) . '">' . str_shorten_text($artefact->get('title'), 20) . '</a></h4>';
             $description = $artefact->get('description');
             if ($description) {
                 $result .= '<p style="margin: 0;"><strong>' . hsc($description) . '</strong></p>';
             }
             $result .= '' . display_size($size) . ' | ' . strftime(get_string('strftimedaydate'), $artefact->get('ctime'));
             $result .= '</div>';
             $result .= '</div>';
         }
     }
     return $result;
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:40,代码来源:lib.php

示例3: pieform_element_checkboxes

/**
 *
 * @package    mahara
 * @subpackage form-element
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
function pieform_element_checkboxes(Pieform $form, $element)
{
    /*{{{*/
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    $submitted = $form->is_submitted();
    if ($submitted) {
        $value = isset($global[$element['name']]) ? $global[$element['name']] : array();
    }
    $result = '';
    if (count($element['elements']) > 1) {
        $id = hsc($form->get_name() . '_' . $element['name']) . '_container';
        $result .= '<a href="" onclick="pieform_element_checkboxes_update(\'' . $id . '\', true); return false;">' . get_string('selectall') . '</a>' . '&nbsp;' . ' <a href="" onclick="pieform_element_checkboxes_update(\'' . $id . '\', false); return false;">' . get_string('selectnone') . '</a>';
    }
    $result .= '<div class="cl"></div>';
    $element['name'] .= '[]';
    // Number of characters in checkbox labels (use 0 or false for no limit).
    $labelwidth = isset($element['labelwidth']) ? (int) $element['labelwidth'] : 17;
    $elementtitle = '';
    if (isset($element['title'])) {
        $elementtitle = '<span class="accessible-hidden">' . $element['title'] . ': </span>';
    }
    foreach ($element['elements'] as $e) {
        $id = $form->get_name() . '_' . $element['id'];
        $idsuffix = substr(md5(microtime()), 0, 4);
        if (!$submitted || !empty($e['disabled'])) {
            $checked = $e['defaultvalue'];
        } else {
            $checked = !empty($value[$e['value']]) || in_array($e['value'], $value);
        }
        $attributes = $form->element_attributes($element);
        $attributes = preg_replace("/\\bid=\"{$id}\"/", "id=\"{$id}{$idsuffix}\"", $attributes);
        $title = $labelwidth ? str_shorten_text($e['title'], $labelwidth, true) : $e['title'];
        $result .= '<div class="checkboxes-option"><input type="checkbox" value="' . $e['value'] . '" ' . $attributes . ($checked ? ' checked="checked"' : '') . (!empty($e['disabled']) ? ' disabled' : '') . '>' . ' <label class="checkbox" for="' . $id . $idsuffix . '">' . $elementtitle . Pieform::hsc($title) . '</label></div>';
    }
    $result .= '<div class="cl"></div>';
    return $result;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:46,代码来源:checkboxes.php

示例4: define

<?php

/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(__FILE__)) . '/init.php';
require_once 'searchlib.php';
$tag = param_variable('tag', null);
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$sort = param_alpha('sort', 'name');
$type = param_alpha('type', null);
$owner = (object) array('type' => 'user', 'id' => $USER->get('id'));
$data = get_portfolio_items_by_tag($tag, $owner, $limit, $offset, $sort, $type);
build_portfolio_search_html($data);
$data->tagdisplay = is_null($tag) ? get_string('alltags') : hsc(str_shorten_text($tag, 50));
$data->tagurl = urlencode($tag);
json_reply(false, array('data' => $data));
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:26,代码来源:tagsearch.php

示例5: email_user


//.........这里部分代码省略.........
    $smtphosts = get_config('smtphosts');
    if ($smtphosts == 'qmail') {
        // use Qmail system
        $mail->IsQmail();
    } else {
        if (empty($smtphosts)) {
            // use PHP mail() = sendmail
            $mail->IsMail();
        } else {
            $mail->IsSMTP();
            // use SMTP directly
            $mail->Host = get_config('smtphosts');
            if (get_config('smtpuser')) {
                // Use SMTP authentication
                $mail->SMTPAuth = true;
                $mail->Username = get_config('smtpuser');
                $mail->Password = get_config('smtppass');
            }
        }
    }
    if (get_config('bounces_handle') && isset($mailinfo->owner)) {
        $mail->Sender = generate_email_processing_address($mailinfo->owner, $userto);
    }
    if (empty($userfrom) || $userfrom->email == get_config('noreplyaddress')) {
        if (empty($mail->Sender)) {
            $mail->Sender = get_config('noreplyaddress');
        }
        $mail->From = get_config('noreplyaddress');
        $mail->FromName = isset($userfrom->id) ? display_name($userfrom, $userto) : get_config('sitename');
        $customheaders[] = 'Precedence: Bulk';
        // Try to avoid pesky out of office responses
        $messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n";
        if ($messagehtml) {
            $messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n";
        }
    } else {
        if (empty($mail->Sender)) {
            $mail->Sender = $userfrom->email;
        }
        $mail->From = $userfrom->email;
        $mail->FromName = display_name($userfrom, $userto);
    }
    $replytoset = false;
    if (!empty($customheaders) && is_array($customheaders)) {
        foreach ($customheaders as $customheader) {
            $mail->AddCustomHeader($customheader);
            if (0 === stripos($customheader, 'reply-to')) {
                $replytoset = true;
            }
        }
    }
    if (!$replytoset) {
        $mail->AddReplyTo($mail->From, $mail->FromName);
    }
    $mail->Subject = substr(stripslashes($subject), 0, 900);
    if ($to = get_config('sendallemailto')) {
        // Admins can configure the system to send all email to a given address
        // instead of whoever would receive it, useful for debugging.
        $mail->addAddress($to);
        $notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email);
        $messagetext = $notice . "\n\n" . $messagetext;
        if ($messagehtml) {
            $messagehtml = '<p>' . hsc($notice) . '</p>' . $messagehtml;
        }
        $usertoname = display_name($userto, $userto, true) . ' (' . get_string('divertingemailto', 'mahara', $to) . ')';
    } else {
        $usertoname = display_name($userto, $userto);
        if (empty($userto->email)) {
            throw new EmailException("Cannot send email to {$usertoname} with subject {$subject}.  User has no primary email address set.");
        }
        $mail->AddAddress($userto->email, $usertoname);
        $to = $userto->email;
    }
    $mail->WordWrap = 79;
    if ($messagehtml) {
        $mail->IsHTML(true);
        $mail->Encoding = 'quoted-printable';
        $mail->Body = $messagehtml;
        $mail->AltBody = $messagetext;
    } else {
        $mail->IsHTML(false);
        $mail->Body = $messagetext;
    }
    if ($mail->Send()) {
        if ($logfile = get_config('emaillog')) {
            $docroot = get_config('docroot');
            @($client = (string) $_SERVER['REMOTE_ADDR']);
            @($script = (string) $_SERVER['SCRIPT_FILENAME']);
            if (strpos($script, $docroot) === 0) {
                $script = substr($script, strlen($docroot));
            }
            $line = "{$to} <- {$mail->From} - " . str_shorten_text($mail->Subject, 200);
            @error_log('[' . date("Y-m-d h:i:s") . "] [{$client}] [{$script}] {$line}\n", 3, $logfile);
        }
        // Update the count of sent mail
        update_send_count($userto);
        return true;
    }
    throw new EmailException("Couldn't send email to {$usertoname} with subject {$subject}. " . "Error from phpmailer was: " . $mail->ErrorInfo);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:101,代码来源:user.php

示例6: display_title

 /**
  * Returns a short name for the artefact to be used in a list of artefacts in a view
  */
 public function display_title($maxlen = null)
 {
     if ($maxlen) {
         return str_shorten_text($this->get('title'), $maxlen, true);
     }
     return $this->get('title');
 }
开发者ID:kienv,项目名称:mahara,代码行数:10,代码来源:lib.php

示例7: artefactchooser_get_element_data

 /**
  * Optional method. If specified, allows the blocktype class to munge the
  * artefactchooser element data before it's templated
  */
 public static function artefactchooser_get_element_data($artefact)
 {
     $folderdata = ArtefactTypeFileBase::artefactchooser_folder_data($artefact);
     $artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
     $artefact->hovertitle = $artefact->description;
     $path = $artefact->parent ? ArtefactTypeFileBase::get_full_path($artefact->parent, $folderdata->data) : '';
     $artefact->description = str_shorten_text($folderdata->ownername . $path . $artefact->title, 30);
     return $artefact;
 }
开发者ID:agwells,项目名称:Mahara-1,代码行数:13,代码来源:lib.php

示例8: email_user


//.........这里部分代码省略.........
        if (empty($mail->Sender)) {
            $mail->Sender = get_config('noreplyaddress');
        }
        $mail->From = get_config('noreplyaddress');
        $mail->FromName = isset($userfrom->id) ? display_name($userfrom, $userto) : get_config('sitename');
        $customheaders[] = 'Precedence: Bulk';
        // Try to avoid pesky out of office responses
        $messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n";
        if ($messagehtml) {
            $messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n";
        }
    } else {
        if (empty($mail->Sender)) {
            $mail->Sender = $userfrom->email;
        }
        $mail->From = $userfrom->email;
        $mail->FromName = display_name($userfrom, $userto);
    }
    $replytoset = false;
    if (!empty($customheaders) && is_array($customheaders)) {
        foreach ($customheaders as $customheader) {
            // To prevent duplicated declaration of the field "Message-ID",
            // don't add it into the $mail->CustomHeader[].
            if (false === stripos($customheader, 'message-id')) {
                // Hack the fields "In-Reply-To" and "References":
                // add touser<userID>
                if (0 === stripos($customheader, 'in-reply-to') || 0 === stripos($customheader, 'references')) {
                    $customheader = preg_replace('/<forumpost(\\d+)/', '<forumpost${1}touser' . $userto->id, $customheader);
                }
                $mail->AddCustomHeader($customheader);
            } else {
                list($h, $msgid) = explode(':', $customheader, 2);
                // Hack the "Message-ID": add touser<userID> to make sure
                // the "Message-ID" is unique
                $msgid = preg_replace('/<forumpost(\\d+)/', '<forumpost${1}touser' . $userto->id, $msgid);
                $mail->MessageID = trim($msgid);
            }
            if (0 === stripos($customheader, 'reply-to')) {
                $replytoset = true;
            }
        }
    }
    $mail->Subject = substr(stripslashes($subject), 0, 900);
    try {
        if ($to = get_config('sendallemailto')) {
            // Admins can configure the system to send all email to a given address
            // instead of whoever would receive it, useful for debugging.
            $usertoname = display_name($userto, $userto, true) . ' (' . get_string('divertingemailto', 'mahara', $to) . ')';
            $mail->addAddress($to);
            $notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email);
            $messagetext = $notice . "\n\n" . $messagetext;
            if ($messagehtml) {
                $messagehtml = '<p>' . hsc($notice) . '</p>' . $messagehtml;
            }
        } else {
            $usertoname = display_name($userto, $userto);
            $mail->AddAddress($userto->email, $usertoname);
            $to = $userto->email;
        }
        if (!$replytoset) {
            $mail->AddReplyTo($mail->From, $mail->FromName);
        }
    } catch (phpmailerException $e) {
        // If there's a phpmailer error already, assume it's an invalid address
        throw new InvalidEmailException("Cannot send email to {$usertoname} with subject {$subject}. Error from phpmailer was: " . $mail->ErrorInfo);
    }
    $mail->WordWrap = 79;
    if ($messagehtml) {
        $mail->IsHTML(true);
        $mail->Encoding = 'quoted-printable';
        $mail->Body = $messagehtml;
        $mail->AltBody = $messagetext;
    } else {
        $mail->IsHTML(false);
        $mail->Body = $messagetext;
    }
    try {
        $sent = $mail->Send();
    } catch (phpmailerException $e) {
        $sent = false;
    }
    if ($sent) {
        if ($logfile = get_config('emaillog')) {
            $docroot = get_config('docroot');
            @($client = (string) $_SERVER['REMOTE_ADDR']);
            @($script = (string) $_SERVER['SCRIPT_FILENAME']);
            if (strpos($script, $docroot) === 0) {
                $script = substr($script, strlen($docroot));
            }
            $line = "{$to} <- {$mail->From} - " . str_shorten_text($mail->Subject, 200);
            @error_log('[' . date("Y-m-d h:i:s") . "] [{$client}] [{$script}] {$line}\n", 3, $logfile);
        }
        if (get_config('bounces_handle')) {
            // Update the count of sent mail
            update_send_count($userto);
        }
        return true;
    }
    throw new EmailException("Couldn't send email to {$usertoname} with subject {$subject}. " . "Error from phpmailer was: " . $mail->ErrorInfo);
}
开发者ID:patkira,项目名称:mahara,代码行数:101,代码来源:user.php

示例9: render_self

 public function render_self($options)
 {
     $smarty = smarty_core();
     $smarty->assign('title', $this->get('title'));
     $smarty->assign('description', $this->get('description'));
     $smarty->assign('viewid', isset($options['viewid']) ? $options['viewid'] : 0);
     $smarty->assign('simpledisplay', isset($options['simpledisplay']) ? $options['simpledisplay'] : false);
     if ($childrecords = $this->folder_contents()) {
         $this->add_to_render_path($options);
         usort($childrecords, array('ArtefactTypeFileBase', 'my_files_cmp'));
         $children = array();
         foreach ($childrecords as &$child) {
             $c = artefact_instance_from_id($child->id);
             $child->title = $child->hovertitle = $c->get('title');
             if (!empty($options['simpledisplay'])) {
                 $child->title = str_shorten_text($child->title, 20);
             }
             $child->date = format_date(strtotime($child->mtime), 'strfdaymonthyearshort');
             $child->iconsrc = call_static_method(generate_artefact_class_name($child->artefacttype), 'get_icon', array('id' => $child->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
         }
         $smarty->assign('children', $childrecords);
     }
     return array('html' => $smarty->fetch('artefact:file:folder_render_self.tpl'), 'javascript' => null);
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:24,代码来源:lib.php

示例10: artefactchooser_get_file_data

 public static function artefactchooser_get_file_data($artefact)
 {
     $artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
     if ($artefact->artefacttype == 'profileicon') {
         $artefact->hovertitle = $artefact->note;
         if ($artefact->title) {
             $artefact->hovertitle .= ': ' . $artefact->title;
         }
     } else {
         $artefact->hovertitle = $artefact->title;
         if ($artefact->description) {
             $artefact->hovertitle .= ': ' . $artefact->description;
         }
     }
     $folderdata = self::artefactchooser_folder_data($artefact);
     if ($artefact->artefacttype == 'profileicon') {
         $artefact->description = str_shorten_text($artefact->title, 30);
     } else {
         $path = $artefact->parent ? self::get_full_path($artefact->parent, $folderdata->data) : '';
         $artefact->description = str_shorten_text($folderdata->ownername . $path . $artefact->title, 30);
     }
     return $artefact;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:23,代码来源:lib.php

示例11: __construct

 public function __construct($data, $cron = false)
 {
     parent::__construct($data, $cron);
     $this->overridemessagecontents = true;
     $post = get_record_sql('
         SELECT
             p.subject, p.body, p.poster, p.parent, ' . db_format_tsfield('p.ctime', 'ctime') . ',
             t.id AS topicid, fp.subject AS topicsubject, f.title AS forumtitle, g.name AS groupname, f.id AS forumid
         FROM {interaction_forum_post} p
         INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic AND t.deleted = 0)
         INNER JOIN {interaction_forum_post} fp ON (fp.parent IS NULL AND fp.topic = t.id)
         INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted = 0)
         INNER JOIN {group} g ON (f.group = g.id AND g.deleted = 0)
         WHERE p.id = ? AND p.deleted = 0', array($this->postid));
     // The post may have been deleted during the activity delay
     if (!$post) {
         $this->users = array();
         return;
     }
     // A user may be subscribed via the forum or the specific topic. If they're subscribed to both, we want
     // to focus on the topic subscription because it's more specific.
     $sql = '
         SELECT
             subq2.subscriber,
             (CASE WHEN subq2.topickey IS NOT NULL THEN subq2.topickey ELSE subq2.forumkey END) AS "key",
             (CASE WHEN subq2.topickey IS NOT NULL THEN \'topic\' ELSE \'forum\' END) AS "type"
         FROM (
             SELECT subq1.subscriber, max(topickey) AS topickey, max(forumkey) AS forumkey
             FROM (
                 SELECT "user" AS subscriber, "key" AS topickey, NULL AS forumkey FROM {interaction_forum_subscription_topic} WHERE topic = ?
                 UNION ALL
                 SELECT "user" AS subscriber, NULL AS topickey, "key" AS forumkey FROM {interaction_forum_subscription_forum} WHERE forum = ?
             ) subq1
             GROUP BY subq1.subscriber
         ) subq2
         INNER JOIN {usr} u ON subq2.subscriber = u.id
         WHERE u.deleted = 0
     ';
     $params = array($post->topicid, $post->forumid);
     if ($cron) {
         $sql .= ' AND subq2.subscriber > ? ';
         $params[] = (int) $data->last_processed_userid;
         $limitfrom = 0;
         $limitnum = self::USERCHUNK_SIZE;
     } else {
         $limitfrom = '';
         $limitnum = '';
     }
     $sql .= ' ORDER BY subq2.subscriber';
     $subscribers = get_records_sql_assoc($sql, $params, $limitfrom, $limitnum);
     $this->users = $subscribers ? activity_get_users($this->get_id(), array_keys($subscribers)) : array();
     $this->fromuser = $post->poster;
     // When emailing forum posts, create Message-Id headers for threaded display by email clients
     $urlinfo = parse_url(get_config('wwwroot'));
     $hostname = $urlinfo['host'];
     $cleanforumname = clean_email_headers($post->forumtitle);
     $cleangroupname = clean_email_headers($post->groupname);
     $cleanforumname = str_replace('"', "'", strip_tags($cleanforumname));
     $cleangroupname = str_replace('"', "'", strip_tags($cleangroupname));
     $this->customheaders = array('List-Id: "' . $cleanforumname . '" <forum' . $post->forumid . '@' . $hostname . '>', 'List-Help: ' . get_config('wwwroot') . 'interaction/forum/view.php?id=' . $post->forumid, 'Message-ID: <forumpost' . $this->postid . '@' . $hostname . '>', 'X-Mahara-Group: ' . $cleangroupname, 'X-Mahara-Forum: ' . $cleanforumname);
     if ($post->parent) {
         $this->customheaders[] = 'In-Reply-To: <forumpost' . $post->parent . '@' . $hostname . '>';
         $this->customheaders[] = 'References: <forumpost' . $post->parent . '@' . $hostname . '>';
     }
     $post->posttime = strftime(get_string('strftimedaydatetime'), $post->ctime);
     // Some messages are all html and when they're 'cleaned' with
     // strip_tags(str_shorten_html($post->body, 200, true)) for display,
     // they are left empty. Use html2text instead.
     $this->message = str_shorten_text(trim(html2text($post->body)), 200, true);
     // For internal notifications.
     $post->textbody = trim(html2text($post->body));
     $post->htmlbody = clean_html($post->body);
     $this->url = 'interaction/forum/topic.php?id=' . $post->topicid . '&post=' . $this->postid;
     $this->add_urltext(array('key' => 'Topic', 'section' => 'interaction.forum'));
     $this->strings->subject = (object) array('key' => 'newforumpostnotificationsubjectline', 'section' => 'interaction.forum', 'args' => array($post->subject ? $post->subject : get_string('Re:', 'interaction.forum') . ($post->parent ? get_ancestorpostsubject($post->parent, true) : $post->topicsubject)));
     foreach ($this->users as &$user) {
         $user->subscribetype = $subscribers[$user->id]->type;
         $user->unsubscribekey = $subscribers[$user->id]->key;
     }
     $this->temp = (object) array('post' => $post);
 }
开发者ID:vohung96,项目名称:mahara,代码行数:81,代码来源:lib.php

示例12: pieform_element_viewacl

/**
 * Provides an element to manage a view ACL
 *
 * @param array    $element The element to render
 * @param Pieform  $form    The form to render the element for
 * @return string           The HTML for the element
 */
function pieform_element_viewacl(Pieform $form, $element)
{
    global $USER, $SESSION, $LANGDIRECTION;
    $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';
    $smarty = smarty_core();
    $smarty->left_delimiter = '{{';
    $smarty->right_delimiter = '}}';
    $value = $form->get_value($element);
    // Look for the presets and split them into two groups
    require_once get_config('libroot') . 'antispam.php';
    $public = false;
    if (is_probationary_user()) {
        $public = false;
    } else {
        if (get_config('allowpublicviews') && $USER->institution_allows_public_views()) {
            $public = true;
        } else {
            if (get_config('allowpublicprofiles') && $element['viewtype'] == 'profile') {
                $public = true;
            }
        }
    }
    $allpresets = array('public', 'loggedin', 'friends');
    $allowedpresets = array();
    $loggedinindex = 0;
    if ($public) {
        $allowedpresets[] = 'public';
        $loggedinindex = 1;
    }
    $allowedpresets[] = 'loggedin';
    if ($form->get_property('userview')) {
        $allowedpresets[] = 'friends';
    }
    $accesslist = array();
    if ($value) {
        foreach ($value as $item) {
            if (is_array($item)) {
                if ($item['type'] == 'public') {
                    $item['publicallowed'] = (int) $public;
                }
                if (in_array($item['type'], $allpresets)) {
                    $item['name'] = get_string($item['type'] == 'loggedin' ? 'registeredusers' : $item['type'], 'view');
                    $item['preset'] = true;
                } else {
                    $item['name'] = pieform_render_viewacl_getvaluebytype($item['type'], $item['id']);
                }
                if ($strlen($item['name']) > 30) {
                    $item['shortname'] = str_shorten_text($item['name'], 30, true);
                }
                // only show access that is still current. Expired access will be deleted if the form is saved
                if ($form->is_submitted() || empty($item['stopdate']) || time() <= strtotime($item['stopdate'])) {
                    $accesslist[] = $item;
                }
            }
        }
    }
    $defaultaccesslist = $accesslist ? 0 : 1;
    $myinstitutions = array();
    foreach ($USER->get('institutions') as $i) {
        $myinstitutions[] = array('type' => 'institution', 'id' => $i->institution, 'start' => null, 'end' => null, 'name' => hsc($i->displayname), 'preset' => false);
    }
    foreach ($allowedpresets as &$preset) {
        $preset = array('type' => $preset, 'id' => $preset, 'start' => null, 'end' => null, 'name' => get_string($preset == 'loggedin' ? 'registeredusers' : $preset, 'view'), 'preset' => true);
    }
    $allgroups = array('type' => 'allgroups', 'id' => 'allgroups', 'start' => null, 'end' => null, 'name' => get_string('allmygroups', 'group'), 'preset' => true);
    $mygroups = array();
    foreach (group_get_user_groups($USER->get('id')) as $g) {
        $group = array('type' => 'group', 'id' => $g->id, 'start' => null, 'end' => null, 'name' => $g->name, 'preset' => false);
        if ($strlen($g->name) > 30) {
            $group['shortname'] = str_shorten_text($g->name, 30, true);
        }
        $mygroups[] = $group;
    }
    $faves = array();
    foreach (get_user_favorites($USER->get('id')) as $u) {
        $fave = array('type' => 'user', 'id' => $u->id, 'start' => null, 'end' => null, 'name' => $u->name, 'preset' => false);
        if ($strlen($u->name) > 30) {
            $fave['shortname'] = str_shorten_text($u->name, 30, true);
        }
        $faves[] = $fave;
    }
    require_once get_config('libroot') . 'pieforms/pieform/elements/calendar.php';
    $options = array('dateFormat' => get_string('calendar_dateFormat', 'langconfig'), 'timeFormat' => get_string('calendar_timeFormat', 'langconfig'), 'stepHour' => 1, 'stepMinute' => 5);
    $options = pieform_element_calendar_get_lang_strings($options, $LANGDIRECTION);
    $datepickeroptionstr = '';
    foreach ($options as $key => $option) {
        if (is_numeric($option)) {
            $datepickeroptionstr .= $key . ': ' . $option . ',';
        } else {
            if (is_array($option)) {
                foreach ($option as $k => $v) {
                    if (!is_numeric($v)) {
                        if (preg_match('/^\'(.*)\'$/', $v, $match)) {
//.........这里部分代码省略.........
开发者ID:vohung96,项目名称:mahara,代码行数:101,代码来源:viewacl.php

示例13: pieform_element_scale

/**
 * Renders a set of radio buttons for scale type questions in surveys.
 *
 * @param array    $element The element to render
 * @param Pieform  $form    The form to render the element for
 * @return string           The HTML for the element
 */
function pieform_element_scale(Pieform $form, $element)
{
    /*{{{*/
    $global = $form->get_property('method') == 'get' ? $_GET : $_POST;
    $submitted = $form->is_submitted();
    if ($submitted && isset($global[$element['name']])) {
        $value = $global[$element['name']];
    }
    $result = '';
    $separator = null;
    //$separator = '';
    if (isset($element['separator'])) {
        $separator = $element['separator'];
    }
    $length = 17;
    if (isset($element['length'])) {
        $length = $element['length'];
    }
    if (!isset($element['options'])) {
        $steps = 5;
        if (isset($element['steps'])) {
            if ($element['steps'] < 2) {
                $steps = 2;
            } elseif ($element['steps'] > 10) {
                $steps = 10;
            } else {
                $steps = $element['steps'];
            }
        }
        $element['options'] = array();
        for ($i = 0; $i < $steps; $i++) {
            $element['options'] = array_merge($element['options'], array(array('value' => strval($i), 'title' => '')));
        }
    }
    // If needed, set answers in reverse order
    if (isset($element['reverse']) && $element['reverse'] == 'true') {
        $element['options'] = array_reverse($element['options']);
    }
    //$result .= "<span style='display:block-inline'>";
    $result .= "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";
    $result .= "<td width='45%' valign='top' align='right'>";
    if (isset($element['labelleft'])) {
        $result .= "<strong>" . $element['labelleft'] . "</strong>";
    }
    if (isset($element['titleleft'])) {
        $result .= $element['titleleft'];
    }
    $result .= "</td>";
    $result .= "<td width='10%' valign='top' align='center'>";
    $result .= "<div style='white-space:nowrap;'>";
    foreach ($element['options'] as $e) {
        $checked = $form->get_value($element) === $e['value'] && !is_null($form->get_value($element));
        if ($e['value'] == null) {
            $checked = false;
        }
        $result .= '<input type="radio" value="' . $e['value'] . '" ' . $form->element_attributes($element) . ($checked ? ' checked="checked"' : '') . ' style="vertical-align:top">' . Pieform::hsc(str_shorten_text($e['title'], $length, true));
        $result .= $separator;
    }
    // Strip the separator after the last option...
    //$result = substr($result, 0, -strlen($separator));
    $result .= "</div>";
    $result .= "</td>";
    $result .= "<td width='45%' valign='top' align='left'>";
    if (isset($element['titleright'])) {
        $result .= $element['titleright'];
    }
    if (isset($element['labelright'])) {
        $result .= "<strong>" . $element['labelright'] . "</strong>";
    }
    $result .= "</td>";
    $result .= "</tr></table>";
    //$result .= "</span>";
    $result .= '<div class="cl"></div>';
    return $result;
}
开发者ID:gbleydon,项目名称:mahara-survey,代码行数:82,代码来源:scale.php

示例14: get_browsable_items


//.........这里部分代码省略.........
                                    $andclause .= " AND ((e.course LIKE '%$courseids[0]%')";
                                } else if (count($courseids) > 1 ) {
                                    foreach($courseids as $key => $id) {
                                        if ($key == 0) {
                                            $andclause .= " AND ((e.course LIKE '%$id%'";
                                        } else {
                                            $andclause .= " OR e.course LIKE '%$id%'";
                                        }
                                        if ($key == count($courseids)-1) {
                                            $andclause .= ')';
                                        }
                                    }
                                }

                            } else {
                                // key != 0
                                $courseids = explode(",", $coursegroup);
                                if (count($courseids) == 1 ) {
                                    $andclause .= " AND (e.course LIKE '%$courseids[0]%')";
                                } else if (count($courseids) > 1 ) {
                                    foreach($courseids as $key => $id) {
                                        if ($key == 0) {
                                            $andclause .= " AND (e.course LIKE '%$id%'";
                                        } else {
                                            $andclause .= " OR e.course LIKE '%$id%'";
                                        }
                                        if ($key == count($courseids)-1) {
                                            $andclause .= ')';
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
            }
        }

        /**
        * The query checks for profile page images.
        */
        $profileimagesids = get_records_sql_array("
                $selectclause
                $fromclause
                $joinclause
                $join2clause
                $join3clause
                $join4clause
                $whereclause
                $andclause
                $grouporderclause
                ", array(), $offset, $limit);

        if ($profileimagesids) {
            foreach ($profileimagesids as $key => $profileimageid) {
                $view = new View($profileimageid->view);
                $view->set('dirty', false);
                $fullurl = $view->get_url();
                $avatarurl = profile_icon_url($profileimageid->owner,50,50);
                $pagetitle = str_shorten_text(display_name($profileimageid->owner), $texttitletrim, true);
                $contents['profiles'][] = array("id" => "p" . $profileimageid->id,
                                    "type" => "profile",
                                    "image" => array(
                                                "id" => $profileimageid->id,
                                                "view" => $profileimageid->view
                                            ),
                                    "page" => array(
                                                "url" => $fullurl,
                                                "title" => $pagetitle
                                    ),
                                    "owner" => array(
                                            "avatarurl" => $avatarurl
                                    )
                                );
            } // foreach
        }

        if ($profileimagesids) {
            $allprofileswithimages = get_records_sql_array("
                    SELECT va.view
                    $fromclause
                    $joinclause
                    $join2clause
                    $join3clause
                    $join4clause
                    $whereclause
                    $andclause
                    GROUP BY va.view
                    ", array());
            $count = count($allprofileswithimages);
        }

        $items = array(
                'count'  => $count,
                'data'   => $contents,
                'offset' => $offset,
                'limit'  => $limit,
        );
        return $items;
    }
开发者ID:catalyst,项目名称:mahara-browseprofiles,代码行数:101,代码来源:lib.php

示例15: get_data

 /** Code copied from blocktype::groupviews **/
 public static function get_data($groupid, $offset = 0, $limit = 20)
 {
     global $USER;
     $texttitletrim = 20;
     $items2 = null;
     if (!defined('GROUP')) {
         define('GROUP', $groupid);
     }
     // get the currently requested group
     $group = group_current_group();
     $role = group_user_access($group->id);
     if ($role) {
         // For group members, display a list of views that others have shared to the group
         // Params for get_sharedviews_data is $limit=0,$offset=0, $groupid
         $data['sharedviews'] = View::get_sharedviews_data($limit, $offset, $group->id);
         /*
         foreach ($data['sharedviews']->data as &$view) {
         	if (isset($view['template']) && $view['template']) {
         		$view['form'] = pieform(create_view_form($group, null, $view->id));
         	}				
                     }
         */
         //the array that is returned from View::get_sharedviews_data($limit, $offset, $group->id)
         //contains a few other things but we just wanted to focus on sharedviews
         //the foreach below will loop through all views shared with the group
         foreach ($data['sharedviews'] as $aView) {
             if (is_array($aView)) {
                 //20140909 JW sort the array returned by View::get_sharedviews_data($limit, $offset, $group->id)
                 //by ctime, this requires the query within get_sharedviews_data to have ctime in its select string
                 $aView = self::array_msort($aView, array('ctime' => SORT_DESC));
                 //the foreach below will loop through all the properties for a view (returned by get_data method) and assigns them to the required variables
                 foreach ($aView as $aViewProperty) {
                     //get the view
                     $viewID = $aViewProperty['id'];
                     //the page shared
                     $fullurl = $aViewProperty['fullurl'];
                     //full url of the page shared
                     $viewTitle = str_shorten_text($aViewProperty['displaytitle'], $texttitletrim, true);
                     //view's title
                     //get the owner of the view
                     $viewOwnerName = $aViewProperty['user']->firstname . " " . $aViewProperty['user']->lastname;
                     //owner of the view's name
                     $userobj = new User();
                     $userobj->find_by_id($aViewProperty['user']->id);
                     $profileurl = profile_url($userobj);
                     //owner of the view's proflie page
                     $avatarurl = profile_icon_url($aViewProperty['user']->id, 50, 50);
                     //owner of the view's profile picture
                     //get the artefact id of an image in the view
                     $theView = new View($aViewProperty['id']);
                     //create the view
                     $artefactInView = $theView->get_artefact_metadata();
                     //get all artefacts in the view
                     foreach ($artefactInView as $anArtefact) {
                         //for each artefact
                         if ($anArtefact->artefacttype == 'image') {
                             $artefactID = $anArtefact->id;
                             //if it is an image artefact assign the id and break the loop
                             break;
                         }
                         //20150331 JW added that if page contains a folder with images (galleries count as folders)
                         //it will pull an image from that folder and use it as the cover
                         if ($anArtefact->artefacttype == 'folder') {
                             $query = "SELECT id FROM {artefact} where parent = ? AND artefacttype = 'image'";
                             $imagesInAFolder = get_records_sql_array($query, array($anArtefact->id));
                             //only assign the id of an image if the folder contains at least 1 image
                             if (!empty($imagesInAFolder)) {
                                 $artefactID = $imagesInAFolder[0]->id;
                                 break;
                             }
                         }
                         //20140903 JW if there are no images on the page then set to artefactID to 0
                         //this way, when display each page, instead of a blank box it will show a place holder image
                         $artefactID = 0;
                     }
                     //the items variable below requires the contents array to be in this format
                     $contents['photos'][] = array("image" => array("id" => $artefactID, "view" => $viewID), "type" => "photo", "page" => array("url" => $fullurl, "title" => $viewTitle), "owner" => array("name" => $viewOwnerName, "profileurl" => $profileurl, "avatarurl" => $avatarurl));
                 }
             }
         }
         //20150723 JW added the if statement to check if $content is set, if not then skip
         if (isset($contents)) {
             $items2 = array('count' => $data['sharedviews']->count, 'data' => $contents, 'offset' => $offset, 'limit' => $limit);
         }
     }
     //$data['group'] = $group;
     return $items2;
 }
开发者ID:CFLAT-AUT,项目名称:Mahara-GroupImageDisplay,代码行数:89,代码来源:lib.php


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