本文整理汇总了PHP中eHelper类的典型用法代码示例。如果您正苦于以下问题:PHP eHelper类的具体用法?PHP eHelper怎么用?PHP eHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loop
/**
* Loops through the authorization array
*
*/
public function loop($array = null)
{
//reasons to fail
if (is_null($array)) {
return false;
}
if (!is_array($array)) {
return false;
}
//Populating class properties
$user =& JFactory::getUser();
if ($user->guest) {
$user->usertype = 'Public';
}
foreach ($array as $group => $pages) {
foreach ($pages as $page) {
//reasons to continue
if (strlen(trim($group)) < 1) {
continue;
}
if (strlen(trim($page)) < 1) {
continue;
}
eHelper::eb_acl($page, $group);
}
}
return true;
}
示例2: sc_faq_question
function sc_faq_question($parm = '')
{
$tp = e107::getParser();
$parm = eHelper::scDualParams($parm);
$param = $parm[1];
$params = $parm[2];
$new = e107::pref('faqs', 'new', 3);
$newDate = strtotime($new . " days ago");
$faqNew = $this->var['faq_datestamp'] > $newDate ? " faq-new" : "";
if ($param == 'expand' && !empty($this->var['faq_answer'])) {
$id = "faq_" . $this->var['faq_id'];
$url = e107::url('faqs', 'item', $this->var, 'full');
$question = $tp->toHTML($this->var['faq_question'], true, 'TITLE');
$hide = $this->item != $this->var['faq_id'] ? 'e-hideme' : '';
$text = "\n\t\t\t<a class='e-expandit faq-question{$faqNew}' href='#{$id}'>" . $question . "</a>\n\t\t\t<div id='{$id}' class='" . $hide . " faq-answer faq_answer clearfix {$faqNew}'>";
$text .= $tp->toHTML($this->var['faq_answer'], true, 'BODY');
$text .= "<div class='faq-extras'>";
if (vartrue($params['tags']) && $this->var['faq_tags']) {
$text .= "<div class='faq-tags'>" . LAN_FAQS_TAGS . ": " . $this->sc_faq_tags() . "</div>";
}
if ($this->datestamp == true) {
$text .= "<div class='faq-datestamp'>" . $tp->toDate($this->var['faq_datestamp']) . "</div>";
}
if ($this->share == true) {
$text .= "<div class='faq-share'>" . $tp->parseTemplate("{SOCIALSHARE: size=xs&type=basic&url=" . $url . "&title=" . $question . "&tags=" . $this->var['faq_tags'] . "}", true) . "</div>";
}
$text .= "</div></div>\n\t\t\t";
} else {
$text = $tp->toHTML($this->var['faq_question'], true, 'BODY');
}
return $text;
}
示例3: compile
function compile($row)
{
$tp = e107::getParser();
$res = array();
$datestamp = $tp->toDate($row['thread_datestamp'], "long");
if ($row['thread_parent']) {
$title = $row['parent_name'];
} else {
$title = $row['thread_name'];
}
$link_id = $row['thread_id'];
$uparams = array('id' => $row['user_id'], 'name' => $row['user_name']);
$link = e107::getUrl()->create('user/profile/view', $uparams);
$userlink = "<a href='" . $link . "'>" . $row['user_name'] . "</a>";
$row['thread_sef'] = eHelper::title2sef($row['thread_name'], 'dashl');
$forumTitle = "<a href='" . e107::url('forum', 'forum', $row) . "'>" . $row['forum_name'] . "</a>";
$res['link'] = e107::url('forum', 'topic', $row, array('query' => array('f' => 'post', 'id' => $row['post_id'])));
// e_PLUGIN."forum/forum_viewtopic.php?".$link_id.".post";
$res['pre_title'] = '';
// $title ? FOR_SCH_LAN_5.": " : "";
$res['title'] = $title ? $forumTitle . " | " . $title : LAN_SEARCH_9;
$res['pre_summary'] = "";
$res['summary'] = $row['post_entry'];
$res['detail'] = LAN_SEARCH_7 . $userlink . LAN_SEARCH_8 . $datestamp;
return $res;
}
示例4: toHTML
/**
* Translate to <p> tag
*/
function toHTML($code_text, $parm)
{
if ($parm && !strpos($parm, '=')) {
$parm = 'class=' . $parm;
}
$code_text = trim($code_text);
$parms = eHelper::scParams($parm);
$class = " " . e107::getBB()->getClass('p');
// consistent classes across all themes.
$id = varsettrue($parms['id']) ? ' id="' . eHelper::secureIdAttr($parms['id']) . '"' : '';
$style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : '';
return "<p{$id}{$class}{$style}>" . $code_text . '</p>';
}
示例5: busca_categorias_tags_pai
/**
* Busca o id da categoria/tag PAI
*
* @param integer $idcomponente
* @param integer $idstart
* @param boolean $tree
* @param string [categorias | tags]
* @return object/JCRUD
*/
function busca_categorias_tags_pai($idcomponente, $idstart = 0, $tabela = 'categorias')
{
$tb = $tabela == 'categorias' ? ECOMP_TABLE_CATEGORIAS : ECOMP_TABLE_TAGS;
$t = new JCRUD($tb);
$a = $t->busca("WHERE idcomponente = '{$idcomponente}' AND id = '{$idstart}'");
if ($a->idpai != 0) {
$tt = $t->busca("WHERE idcomponente = '{$idcomponente}' AND idpai = '{$idstart}'");
foreach ($tt as $tr) {
$a = eHelper::busca_categorias_tags_pai($idcomponente, $tr->id, $tabela);
}
}
return $a->id;
}
示例6: url_shortcode
/**
* Example usage (valid news data + option for full URL)
* {URL=news/view/item|news_id=1&news_sef=sef-string&category_id=1&category_sef=category-sef&options[full]=1}
*/
function url_shortcode($parm)
{
list($route, $parms) = eHelper::scDualParams($parm);
if (empty($route)) {
return '';
}
$options = array();
if (isset($parms['options'])) {
$options = $parms['options'];
unset($parms['options']);
}
return e107::getUrl()->create($route, $parms, $options);
}
示例7: toHTML
/**
* Translate youtube bbcode into the appropriate HTML
*/
function toHTML($code_text, $parm)
{
// transform to class, equal sign at 0 position is not well formed parm string
if ($parm && !strpos($parm, '=')) {
$parm = 'class=' . $parm;
}
$parms = eHelper::scParams($parm);
$class = " " . e107::getBB()->getClass('block');
$id = varsettrue($parms['id']) ? ' id=' . eHelper::secureIdAttr($parms['id']) : '';
$style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : '';
if (empty($code_text)) {
$code_text = '<!-- -->';
}
return '<div' . $id . $class . $style . '>' . $code_text . '</div>';
}
示例8: toHTML
/**
* Translate to <h*> tag
*/
function toHTML($code_text, $parm)
{
$code_text = trim($code_text);
if (empty($code_text)) {
return '';
}
$bparms = eHelper::scDualParams($parm);
$h = 'h' . ($bparms[1] ? intval($bparms[1]) : 2);
$parms = $bparms[2];
unset($bparms);
$class = " " . e107::getBB()->getClass('h2');
// consistent classes across all themes.
$id = varsettrue($parms['id']) ? ' id=' . eHelper::secureIdAttr($parms['id']) : '';
$style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : '';
return "<{$h}{$id}{$class}{$style}>" . $code_text . "</{$h}>";
}
示例9: toDB
function toDB($code_text, $parm)
{
$parms = eHelper::scParams($parm);
$safe = array();
if (vartrue($parms['class'])) {
$safe['class'] = eHelper::secureClassAttr($parms['class']);
}
if (vartrue($parms['id'])) {
$safe['id'] = eHelper::secureIdAttr($parms['id']);
}
if (vartrue($parms['style'])) {
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
}
if ($safe) {
return '[img ' . eHelper::buildAttr($safe) . ']' . $code_text . '[/img]';
}
return '[img]' . $code_text . '[/img]';
}
示例10: upgrade_post
function upgrade_post($var)
{
$db = e107::getDb();
$currentVersion = $var->current_plug['plugin_version'];
if ($currentVersion == '1.0') {
/* to fill SEF URL FOR categories*/
$db = e107::getDb();
if ($allRows = $db->retrieve('SELECT * FROM #links_page_cat', TRUE)) {
foreach ($allRows as $row) {
$id = $row["link_category_id"];
$where = 'link_category_id = ' . $id;
$update = array('link_category_sef' => eHelper::title2sef($row['link_category_name']), 'WHERE' => $where);
$db->update('links_page_cat', $update);
}
}
/* to set all existing links as active */
$db = e107::getDb('links_page');
$update = array('link_active' => 1);
$db->update('links_page', $update);
}
}
示例11: insertPost
/**
* Insert a new thread or a reply/quoted reply.
*/
function insertPost()
{
$postInfo = array();
$threadInfo = array();
$threadOptions = array();
$fp = new floodprotect();
if (isset($_POST['newthread']) && trim($_POST['subject']) == '' || trim($_POST['post']) == '') {
message_handler('ALERT', 5);
} else {
if ($fp->flood('forum_thread', 'thread_datestamp') == false && !ADMIN) {
echo "<script type='text/javascript'>document.location.href='" . e_BASE . "index.php'</script>\n";
exit;
}
$hasPoll = $this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '';
if (USER) {
$postInfo['post_user'] = USERID;
$threadInfo['thread_lastuser'] = USERID;
$threadInfo['thread_user'] = USERID;
$threadInfo['thread_lastuser_anon'] = '';
} else {
$postInfo['post_user_anon'] = $_POST['anonname'];
$threadInfo['thread_lastuser_anon'] = $_POST['anonname'];
$threadInfo['thread_user_anon'] = $_POST['anonname'];
}
$time = time();
$postInfo['post_entry'] = $_POST['post'];
$postInfo['post_forum'] = $this->data['forum_id'];
$postInfo['post_datestamp'] = $time;
$postInfo['post_ip'] = e107::getIPHandler()->getIP(FALSE);
$threadInfo['thread_lastpost'] = $time;
if (isset($_POST['no_emote'])) {
$postInfo['post_options'] = serialize(array('no_emote' => 1));
}
//If we've successfully uploaded something, we'll have to edit the post_entry and post_attachments
$newValues = array();
if ($uploadResult = $this->processAttachments()) {
foreach ($uploadResult as $ur) {
//$postInfo['post_entry'] .= $ur['txt'];
// $_tmp = $ur['type'].'*'.$ur['file'];
// if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
$type = $ur['type'];
$newValues[$type][] = $ur['file'];
// $attachments[] = $_tmp;
}
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
$postInfo['post_attachments'] = e107::serialize($newValues);
//FIXME XXX - broken encoding when saved to DB.
}
// var_dump($uploadResult);
switch ($this->action) {
// Reply only. Add the post, update thread record with latest post info.
// Update forum with latest post info
case 'rp':
$postInfo['post_thread'] = $this->id;
$newPostId = $this->forumObj->postAdd($postInfo);
break;
// New thread started. Add the thread info (with lastest post info), add the post.
// Update forum with latest post info
// New thread started. Add the thread info (with lastest post info), add the post.
// Update forum with latest post info
case 'nt':
$threadInfo['thread_sticky'] = MODERATOR ? (int) $_POST['threadtype'] : 0;
$threadInfo['thread_name'] = $_POST['subject'];
$threadInfo['thread_forum_id'] = $this->id;
$threadInfo['thread_active'] = 1;
$threadInfo['thread_datestamp'] = $time;
if ($hasPoll) {
$threadOptions['poll'] = '1';
}
if (is_array($threadOptions) && count($threadOptions)) {
$threadInfo['thread_options'] = serialize($threadOptions);
} else {
$threadInfo['thread_options'] = '';
}
if ($postResult = $this->forumObj->threadAdd($threadInfo, $postInfo)) {
$newPostId = $postResult['postid'];
$newThreadId = $postResult['threadid'];
$this->data['thread_id'] = $newThreadId;
// $this->data['thread_sef'] = $postResult['threadsef'];
$this->data['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'], 'dashl');
if ($_POST['email_notify']) {
$this->forumObj->track('add', USERID, $newThreadId);
}
}
break;
}
e107::getMessage()->addDebug(print_a($postInfo, true));
// e107::getMessage()->addDebug(print_a($this,true));
if ($postResult === -1 || $newPostId === -1) {
require_once HEADERF;
$message = LAN_FORUM_3006 . "<br ><a class='btn btn-default' href='" . $_SERVER['HTTP_REFERER'] . "'>Return</a>";
$text = e107::getMessage()->addError($message)->render();
e107::getRender()->tablerender(LAN_PLUGIN_FORUM_NAME, $text);
// change to forum-title pref.
require_once FOOTERF;
exit;
//.........这里部分代码省略.........
示例12: sc_gallery_slides
/**
* All possible parameters
* {GALLERY_SLIDES=4|limit=16&template=MY_SLIDESHOW_SLIDE_ITEM}
* first parameter is always number of slides, default is 3
* limit - (optional) total limit of pcitures to be shown
* template - (optional) template - name of template to be used for parsing the slideshow item
*/
function sc_gallery_slides($parm)
{
$tp = e107::getParser();
$this->slideMode = TRUE;
$parms = eHelper::scDualParams($parm);
$amount = $parms[1] ? intval($parms[1]) : 3;
// vartrue(e107::getPlugPref('gallery','slideshow_perslide'),3);
$parms = $parms[2];
$limit = (int) vartrue($parms['limit'], 16);
$list = e107::getMedia()->getImages('gallery_' . $this->sliderCat . '|gallery_image_' . $this->sliderCat, 0, $limit);
$tmpl = e107::getTemplate('gallery', 'gallery');
$tmpl = array_change_key_case($tmpl);
// change template key to lowercase (BC fix)
$tmpl_key = vartrue($parms['template'], 'slideshow_slide_item');
$item_template = $tmpl[$tmpl_key];
// e107::getTemplate('gallery','gallery', vartrue($parms['template'], 'SLIDESHOW_SLIDE_ITEM'));
$catList = e107::getMedia()->getCategories('gallery');
$cat = $catList['gallery_' . $this->sliderCat];
$count = 1;
foreach ($list as $row) {
$this->setVars($row)->addVars($cat);
$inner .= $count == 1 ? "\n\n<!-- SLIDE " . $count . " -->\n<div class='slide' id='gallery-item-" . $this->slideCount . "'>\n" : "";
$inner .= "\n\t" . $tp->parseTemplate($item_template, TRUE) . "\n";
$inner .= $count == $amount ? "\n</div>\n\n" : "";
if ($count == $amount) {
$count = 1;
$this->slideCount++;
} else {
$count++;
}
}
$inner .= $count != 1 ? "</div><!-- END SLIDES -->" : "";
return $inner;
}
示例13: view_all_query
function view_all_query($srch = '')
{
$sql = e107::getDb();
$tp = e107::getParser();
$text = "";
$insert = "";
$item = false;
$removeUrl = e107::url('faqs', 'index');
if (!empty($srch)) {
$srch = $tp->toDB($srch);
$insert = " AND (f.faq_question LIKE '%" . $srch . "%' OR f.faq_answer LIKE '%" . $srch . "%' OR FIND_IN_SET ('" . $srch . "', f.faq_tags) ) ";
$message = "<span class='label label-lg label-info'>" . $srch . " <a class='e-tip' title='Remove' href='" . $removeUrl . "'>×</a></span>";
e107::getMessage()->setClose(false, E_MESSAGE_INFO)->setTitle(LAN_FAQS_FILTER_ACTIVE, E_MESSAGE_INFO)->addInfo($message);
$text = e107::getMessage()->render();
}
if (!empty($_GET['id'])) {
$srch = intval($_GET['id']);
// $insert = " AND (f.faq_id = ".$srch.") ";
$item = $srch;
}
if (!empty($_GET['cat'])) {
$srch = $tp->toDB($_GET['cat']);
$insert = " AND (cat.faq_info_sef = '" . $srch . "') ";
}
if (!empty($_GET['tag'])) {
$srch = $tp->toDB($_GET['tag']);
$insert = " AND FIND_IN_SET ('" . $srch . "', f.faq_tags) ";
$message = "<span class='label label-lg label-info'>" . $srch . " <a class='e-tip' title='Remove' href='" . $removeUrl . "'>×</a></span>";
e107::getMessage()->setClose(false, E_MESSAGE_INFO)->setTitle(LAN_FAQS_FILTER_ACTIVE, E_MESSAGE_INFO)->addInfo($message);
$text = e107::getMessage()->render();
}
list($orderBy, $ascdesc) = explode('-', vartrue($this->pref['orderby'], 'faq_order-ASC'));
$query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (" . USERCLASS_LIST . ") " . $insert . " ORDER BY cat.faq_info_order, f." . $orderBy . " " . $ascdesc . " ";
if (!$sql->gen($query)) {
$message = !empty($srch) ? "<b>" . $srch . "</b> was not found in search results. <a class='e-tip' title='Reset' href='" . $removeUrl . "'>Reset</a>" : LAN_FAQS_NONE_AVAILABLE;
return "<div class='alert alert-warning alert-block'>" . $message . "</div>";
//TODO LAN
}
// -----------------
$FAQ_LISTALL = e107::getTemplate('faqs', true, 'all');
$prevcat = "";
$sc = e107::getScBatch('faqs', true);
$sc->counter = 1;
$sc->tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8');
$sc->category = $category;
if (!empty($_GET['id'])) {
$sc->item = intval($_GET['id']);
$js = "\n\t\t\t\t\$( document ).ready(function() {\n \$('html, body').animate({ scrollTop: \$('div#faq_" . $sc->item . "').offset().top - 300 }, 4000);\n\t\t\t\t});\n\n\t\t\t\t";
e107::js('footer-inline', $js);
}
// $text = $tp->parseTemplate($FAQ_START, true, $sc);
// $text = "";
if ($this->pref['list_type'] == 'ol') {
$reversed = $ascdesc == 'DESC' ? 'reversed ' : '';
$tsrch = array('<ul ', '/ul>');
$trepl = array('<ol ' . $reversed, '/ol>');
$FAQ_LISTALL['start'] = str_replace($tsrch, $trepl, $FAQ_LISTALL['start']);
$FAQ_LISTALL['end'] = str_replace($tsrch, $trepl, $FAQ_LISTALL['end']);
}
while ($rw = $sql->fetch()) {
$rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']), 'dashl');
$sc->setVars($rw);
if ($sc->item == $rw['faq_id']) {
$this->pageTitle = $rw['faq_question'];
$this->pageDescription = $rw['faq_answer'];
}
if ($rw['faq_info_order'] != $prevcat) {
if ($prevcat != '') {
$text .= $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc);
}
$text .= "\n\n<!-- FAQ Start " . $rw['faq_info_order'] . "-->\n\n";
$text .= $tp->parseTemplate($FAQ_LISTALL['start'], true, $sc);
$start = TRUE;
}
$text .= $tp->parseTemplate($FAQ_LISTALL['item'], true, $sc);
$prevcat = $rw['faq_info_order'];
$sc->counter++;
}
$text .= $start ? $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc) : "";
// $text .= $tp->parseTemplate($FAQ_END, true, $sc);
return $text;
}
示例14: step5
function step5()
{
$sql = e107::getDb();
$ns = e107::getRender();
$mes = e107::getMessage();
$stepCaption = 'Step 5: Migrate forum data';
if (!isset($_POST['move_forum_data'])) {
$text = "This step will copy all of your forum configuration from the `forum` table into the `forum_new` table.<br />\n\t\tOnce the information is successfully copied, the existing 1.0 forum table will be renamed `forum_old` and the newly created `forum_new` table will be renamed `forum`.<br />\n\t\t<br /><br />";
$text .= "\n\t\t<form method='post'>\n\t\t<input class='btn btn-success' data-loading-text='Please wait...' type='submit' name='move_forum_data' value='Proceed with forum data move' />\n\t\t</form>\n\t\t";
$ns->tablerender($stepCaption, $mes->render() . $text);
return;
}
$counts = array('parents' => 0, 'forums' => 0, 'subs' => 0);
//XXX Typo on 'parents' ?
if ($sql->select('forum')) {
$forumList = $sql->db_getList();
foreach ($forumList as $forum) {
if ($forum['forum_parent'] == 0) {
$counts['parents']++;
} elseif ($forum['forum_sub'] != 0) {
$counts['subs']++;
} else {
$counts['forums']++;
}
$tmp = $forum;
$tmp['forum_threadclass'] = $tmp['forum_postclass'];
$tmp['forum_options'] = '_NULL_';
$tmp['forum_sef'] = eHelper::title2sef($forum['forum_name'], 'dashl');
// $tmp['_FIELD_TYPES'] = $ftypes['_FIELD_TYPES'];
if ($sql->insert('forum_new', $tmp)) {
} else {
$mes->addError("Insert failed on " . print_a($tmp, true));
}
}
} else {
$counts = array('parents' => 'n/a', 'forums' => 'n/a', 'subs' => 'n/a');
}
$mes->addSuccess("\n\t\tForum data move results:\n\t\t<ul>\n\t\t<li>Number of forum parents processed: {$counts['parents']} </li>\n\t\t<li>Number of forums processed: {$counts['forums']} </li>\n\t\t<li>Number of sub forums processed: {$counts['subs']} </li>\n\t\t</ul>\n\t\t");
$result = $sql->gen('RENAME TABLE `#forum` TO `#forum_old` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add("Renaming forum to forum_old", $result);
$result = $sql->gen('RENAME TABLE `#forum_new` TO `#forum` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add("Renaming forum_new to forum", $result);
$text = "\n\t\t<form method='post' action='" . e_SELF . "?step=6'>\n\t\t<input class='btn btn-success' type='submit' name='nextStep[6]' value='Proceed to step 6' />\n\t\t</form>\n\t\t";
$ns->tablerender($stepCaption, $mes->render() . $text);
}
示例15: createUserCategory
/**
* Create a user Media-Category.
* @param $type string image | file | video
* @param $userId int - leave empty for currently logged in user.
* @param $userName string - leave blank for currently logged in user
* @param $parms (optional) - for future use.
* @return bool|int
*/
public function createUserCategory($type = 'image', $userId = USERID, $userName = USERNAME, $parms = null)
{
if ($type != 'image' && ($type = 'file' && $type != 'video')) {
return false;
}
$cat = 'user_' . $type . '_' . intval($userId);
if (!e107::getDb()->gen('SELECT media_cat_id FROM #core_media_cat WHERE media_cat_category = "' . $cat . '" LIMIT 1')) {
$insert = array('owner' => 'user', 'category' => $cat, 'title' => $userName, 'sef' => 'media-' . eHelper::title2sef($userName), 'diz' => '', 'class' => '', 'image' => '', 'order' => '');
return $this->createCategory($insert);
}
return false;
}