本文整理汇总了PHP中FabrikString::ltrimword方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikString::ltrimword方法的具体用法?PHP FabrikString::ltrimword怎么用?PHP FabrikString::ltrimword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikString
的用法示例。
在下文中一共展示了FabrikString::ltrimword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tagify
/**
* Tagify a string
*
* @param string $data Tagify
*
* @return string Tagified string
*/
protected function tagify($data)
{
$name = $this->getFullName(true, false);
$params = $this->getParams();
$listModel = $this->getlistModel();
$filters = $listModel->getFilterArray();
$fkeys = JArrayHelper::getValue($filters, 'key', array());
$data = explode(",", strip_tags($data));
$tags = array();
$url = $params->get('textarea_tagifyurl');
if ($url == '') {
$url = $_SERVER['REQUEST_URI'];
$bits = explode('?', $url);
$root = JArrayHelper::getValue($bits, 0, '', 'string');
$bits = JArrayHelper::getValue($bits, 1, '', 'string');
$bits = explode("&", $bits);
$fullName = $this->getFullName(true, false);
for ($b = count($bits) - 1; $b >= 0; $b--) {
$parts = explode("=", $bits[$b]);
if (count($parts) > 1) {
$key = FabrikString::ltrimword(FabrikString::safeColNameToArrayKey($parts[0]), '&');
if ($key == $fullName) {
unset($bits[$b]);
}
if ($key == $fullName . '[value]') {
unset($bits[$b]);
}
if ($key == $fullName . '[condition]') {
unset($bits[$b]);
}
}
}
}
$url = $root . '?' . implode('&', $bits);
// $$$ rob 24/02/2011 remove duplicates from tags
$data = array_unique($data);
$img = FabrikWorker::j3() ? 'bookmark.png' : 'tag.png';
$icon = FabrikHelperHTML::image($img, 'form', @$this->tmpl, array('alt' => 'tag'));
foreach ($data as $d) {
$d = trim($d);
if ($d != '') {
if (trim($params->get('textarea_tagifyurl')) == '') {
$qs = strstr($url, '?');
if (substr($url, -1) === '?') {
$thisurl = $url . $name . '[value]=' . $d;
} else {
$thisurl = strstr($url, '?') ? $url . '&' . $name . '[value]=' . urlencode($d) : $url . '?' . $name . '[value]=' . urlencode($d);
}
$thisurl .= '&' . $name . '[condition]=CONTAINS';
$thisurl .= '&resetfilters=1';
} else {
$thisurl = str_replace('{tag}', urlencode($d), $url);
}
$tags[] = '<a href="' . $thisurl . '" class="fabrikTag">' . $icon . $d . '</a>';
}
}
return implode(' ', $tags);
}
示例2: exists
/**
* Does a file exist
*
* @param string $filepath File path to test
*
* @return bool
*/
public function exists($filepath)
{
if ($filepath == '\\') {
return false;
}
if (JFile::exists($filepath)) {
return true;
}
$filepath = COM_FABRIK_BASE . '/' . FabrikString::ltrimword($filepath, COM_FABRIK_BASE . '/');
return JFile::exists($filepath);
}
示例3: exists
/**
* Does a file exist
*
* @param string $filepath File path to test
* @param bool $prependRoot also test with root prepended
*
* @return bool
*/
public function exists($filepath, $prependRoot = true)
{
if (empty($filepath) || $filepath == '\\') {
return false;
}
if (JFile::exists($filepath)) {
return true;
}
if ($prependRoot) {
$filepath = COM_FABRIK_BASE . '/' . FabrikString::ltrimword($filepath, COM_FABRIK_BASE . '/');
return JFile::exists($filepath);
}
return false;
}
示例4: _strToCoords
function _strToCoords($v, $zoomlevel = 0)
{
$o = new stdClass();
$o->coords = array('', '');
$o->zoomlevel = (int) $zoomlevel;
if (strstr($v, ",")) {
$ar = explode(":", $v);
$o->zoomlevel = count($ar) == 2 ? array_pop($ar) : 4;
$v = FabrikString::ltrimword($ar[0], "(");
$v = rtrim($v, ")");
$o->coords = explode(",", $v);
} else {
$o->coords = array(0, 0);
}
return $o;
}
示例5: tagify
/**
* tagify a string
* @param string to tagify
* @return string tagified string
*/
protected function tagify($data)
{
$name = $this->getFullName(false, true, false);
$params = $this->getParams();
$listModel = $this->getlistModel();
$filters = $listModel->getFilterArray();
$fkeys = JArrayHelper::getValue($filters, 'key', array());
$data = explode(",", strip_tags($data));
$tags = array();
$url = $params->get('textarea_tagifyurl');
if ($url == '') {
$url = $_SERVER['REQUEST_URI'];
$bits = explode('?', $url);
$bits = JArrayHelper::getValue($bits, 1, '', 'string');
$bits = explode("&", $bits);
foreach ($bits as $bit) {
$parts = explode("=", $bit);
if (count($parts) > 1) {
$key = FabrikString::ltrimword(FabrikString::safeColNameToArrayKey($parts[0]), '&');
if ($key == $this->getFullName(false, true, false)) {
$url = str_replace($key . '=' . $parts[1], '', $url);
}
}
}
}
// $$$ rbo 24/02/2011 remove duplicates from tags
$data = array_unique($data);
$icon = FabrikHelperHTML::image('tag.png', 'form', @$this->tmpl, array('alt' => 'tag'));
foreach ($data as $d) {
$d = trim($d);
if ($d != '') {
if (trim($params->get('textarea_tagifyurl')) == '') {
$qs = strstr($url, '?');
if (substr($url, -1) === '?') {
$thisurl = "{$url}{$name}={$d}";
} else {
$thisurl = strstr($url, '?') ? "{$url}&{$name}=" . urlencode($d) : "{$url}?{$name}=" . urlencode($d);
}
} else {
$thisurl = str_replace('{tag}', urlencode($d), $url);
}
$tags[] = '<a href="' . $thisurl . '" class="fabrikTag">' . $icon . $d . '</a>';
}
}
return implode(" ", $tags);
}
示例6: _xmlExport
/**
*
*/
function _xmlExport($xml)
{
$archiveName = 'fabrik_package-' . $this->label;
require_once JPATH_SITE . '/includes/Archive/Tar.php';
$archivePath = JPATH_SITE . '/components/com_fabrik/' . $archiveName . '.tgz';
if (JFile::exists($archivePath)) {
@unlink($archivePath);
}
$zip = new Archive_Tar($archivePath);
$fileName = $archiveName . '.xml';
$fileName = $this->_bufferFile;
//$ok = $zip->addModify('/tmp/' . $fileName, '', "/tmp/");
//, '', dirname( $fileName) . "/"
$fileName = str_replace(JPATH_SITE, '', $this->_bufferFile);
$fileName = FabrikString::ltrimword($fileName, "/administrator/");
$ok = $zip->addModify($fileName, '', "components/com_fabrik");
for ($i = 0; $i < count($this->_aFiles); $i++) {
$this->_aFiles[$i] = JPATH_SITE . '/components/com_fabrik/tmpl/' . $this->_aFiles[$i];
}
$zip->addModify($this->_aFiles, '', JPATH_SITE . '/components/com_fabrik');
$this->_output_file($archivePath, $archiveName . '.tgz');
}
示例7: getGroupByHeadings
/**
* Get lists group by headings
*
* @return array heading names
*/
public function getGroupByHeadings()
{
$formModel = $this->getFormModel();
$input = $this->app->input;
$base = JURI::getInstance();
$base = $base->toString(array('scheme', 'user', 'pass', 'host', 'port', 'path'));
$qs = $input->server->get('QUERY_STRING', '', 'string');
if (JString::stristr($qs, 'group_by')) {
$qs = FabrikString::removeQSVar($qs, 'group_by');
$qs = FabrikString::ltrimword($qs, '?');
$qs = str_replace('&', '&', $qs);
}
$url = $base;
if (!empty($qs)) {
$url .= JString::strpos($url, '?') !== false ? '&' : '?';
$url .= $qs;
}
$url .= JString::strpos($url, '?') !== false ? '&' : '?';
$a = array();
list($h, $x, $b, $c) = $this->getHeadings();
$o = new stdClass();
$o->label = FText::_('COM_FABRIK_NONE');
$o->group_by = '';
$a[$url . 'group_by=0'] = $o;
foreach ($h as $key => $v) {
if (!in_array($key, array('fabrik_select', 'fabrik_edit', 'fabrik_view', 'fabrik_delete', 'fabrik_actions'))) {
/**
* $$$ hugh - other junk is showing up in $h, like 85___14-14-86_list_heading, or element
* names ending in _form_heading. May not be the most efficient method, but we need to
* test if $key exists as an element, as well as the simple in_array() test above.
*/
if ($formModel->hasElement($key, false, false)) {
$thisUrl = $url . 'group_by=' . $key;
$o = new stdClass();
$o->label = strip_tags($v);
$o->group_by = $key;
$a[$thisUrl] = $o;
}
}
}
return $a;
}
示例8: buildQueryWhere
/**
* Create the where part for the query that selects the list options
*
* @param array $data Current row data to use in placeholder replacements
* @param bool $incWhere Should the additional user defined WHERE statement be included
* @param string $thisTableAlias Db table alias
* @param array $opts Options
* @param JDatabaseQuery $query Append where to JDatabaseQuery object or return string (false)
*
* @return string|JDatabaseQuery
*/
protected function buildQueryWhere($data = array(), $incWhere = true, $thisTableAlias = null, $opts = array(), $query = false)
{
$where = '';
$listModel = $this->getlistModel();
$params = $this->getParams();
$element = $this->getElement();
$whereaccess = $params->get('database_join_where_access', 26);
$where = $this->mustApplyWhere($whereaccess, $element->id) && $incWhere ? $params->get('database_join_where_sql') : '';
$join = $this->getJoin();
$thisTableAlias = is_null($thisTableAlias) ? $join->table_join_alias : $thisTableAlias;
// $$$rob 11/10/2011 remove order by statements which will be re-inserted at the end of buildQuery()
if (preg_match('/(ORDER\\s+BY)(.*)/i', $where, $matches)) {
$this->orderBy = str_replace("{thistable}", $join->table_join_alias, $matches[0]);
$where = str_replace($this->orderBy, '', $where);
$where = str_replace($matches[0], '', $where);
}
if (!empty($this->autocomplete_where)) {
$mode = JArrayHelper::getValue($opts, 'mode', 'form');
$displayType = $params->get('database_join_display_type', 'dropdown');
$filterType = $element->filter_type;
if ($mode == 'filter' && $filterType == 'auto-complete' || $mode == 'form' && $displayType == 'auto-complete' || $mode == 'filter' && $displayType == 'auto-complete') {
$where .= JString::stristr($where, 'WHERE') ? ' AND ' . $this->autocomplete_where : ' WHERE ' . $this->autocomplete_where;
}
}
if ($where == '') {
return $query ? $query : $where;
}
$where = str_replace("{thistable}", $thisTableAlias, $where);
$w = new FabrikWorker();
$lang = JFactory::getLanguage();
$data = is_array($data) ? $data : array();
if (!isset($data['lang'])) {
$data['lang'] = $lang->getTag();
}
$where = $w->parseMessageForPlaceHolder($where, $data, false);
if (!$query) {
return $where;
} else {
// $where = JString::str_ireplace('WHERE', '', $where);
$where = FabrikString::ltrimword($where, 'WHERE', true);
$query->where($where);
return $query;
}
}
示例9: tagBaseUrl
/**
* Get base tag url
*
* @param string $fullName Full name (key value to remove from querystring)
*
* @return string
*/
public static function tagBaseUrl($fullName)
{
$url = $_SERVER['REQUEST_URI'];
$bits = explode('?', $url);
$root = JArrayHelper::getValue($bits, 0, '', 'string');
$bits = JArrayHelper::getValue($bits, 1, '', 'string');
$bits = explode("&", $bits);
for ($b = count($bits) - 1; $b >= 0; $b--) {
$parts = explode("=", $bits[$b]);
if (count($parts) > 1) {
$key = FabrikString::ltrimword(FabrikString::safeColNameToArrayKey($parts[0]), '&');
if ($key == $fullName) {
unset($bits[$b]);
}
if ($key == $fullName . '[value]') {
unset($bits[$b]);
}
if ($key == $fullName . '[condition]') {
unset($bits[$b]);
}
}
}
$url = $root . '?' . implode('&', $bits);
return $url;
}
示例10: canUpload
/**
* Checks if the file can be uploaded
*
* @param array File information
* @param string An error message to be returned
* @return boolean
*/
function canUpload($file, &$err, &$params)
{
if (empty($file['name'])) {
$err = 'Please input a file for upload';
return false;
}
if (!is_uploaded_file($file['tmp_name'])) {
//handle potential malicous attack
$err = JText::_('File has not been uploaded');
return false;
}
jimport('joomla.filesystem.file');
$format = strtolower(JFile::getExt($file['name']));
$allowable = explode(',', strtolower($params->get('ul_file_types')));
$format = FabrikString::ltrimword($format, '.');
$format2 = ".{$format}";
if (!in_array($format, $allowable) && !in_array($format2, $allowable)) {
$err = 'WARNFILETYPE';
return false;
}
$maxSize = (int) $params->get('upload_maxsize', 0);
if ($maxSize > 0 && (int) $file['size'] > $maxSize) {
$err = 'WARNFILETOOLARGE';
return false;
}
$ignored = array();
$user = JFactory::getUser();
$imginfo = null;
if ($params->get('restrict_uploads', 1)) {
$images = explode(',', $params->get('image_extensions'));
if (in_array($format, $images)) {
// if its an image run it through getimagesize
if (($imginfo = getimagesize($file['tmp_name'])) === FALSE) {
$err = 'WARNINVALIDIMG';
return false;
}
} else {
if (!in_array($format, $ignored)) {
// if its not an image...and we're not ignoring it
/*$allowed_mime = explode(',', $upload_mime);
$illegal_mime = explode(',', $upload_mime_illegal);
if (function_exists('finfo_open') && $params->get('check_mime',1)) {
// We have fileinfo
$finfo = finfo_open(FILEINFO_MIME);
$type = finfo_file($finfo, $file['tmp_name']);
if (strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) {
$err = 'WARNINVALIDMIME';
return false;
}
finfo_close($finfo);
} else if (function_exists('mime_content_type') && $params->get('check_mime',1)) {
// we have mime magic
$type = mime_content_type($file['tmp_name']);
if (strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) {
$err = 'WARNINVALIDMIME';
return false;
}
}*/
}
}
}
$xss_check = JFile::read($file['tmp_name'], false, 256);
$html_tags = array('abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', 'blockquote', 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', 'link', 'listing', 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', 'ol', 'optgroup', 'option', 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', 'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var', 'wbr', 'xml', 'xmp', '!DOCTYPE', '!--');
foreach ($html_tags as $tag) {
// A tag is '<tagname ', so we need to add < and a space or '<tagname>'
if (JString::stristr($xss_check, '<' . $tag . ' ') || JString::stristr($xss_check, '<' . $tag . '>')) {
$err = 'WARNIEXSS';
return false;
}
}
return true;
}
示例11: runPlugins
/**
* run form & element plugins - yeah!
* @param string method to check and call - corresponds to stage of form processing
* @param object model calling the plugin form/table
* @param string plugin type to call form/table
* @return array of bools: false if error found and processed, otherwise true
*/
function runPlugins($method, &$oRequest, $type = 'form')
{
if ($type == 'form') {
// $$$ rob allow for table plugins to hook into form plugin calls - methods are mapped as:
//form method = 'onLoad' => table method => 'onFormLoad'
$tmethod = 'onForm' . FabrikString::ltrimword($method, 'on');
$this->runPlugins($tmethod, $oRequest->getListModel(), 'list');
}
$params =& $oRequest->getParams();
//$this->getPlugInGroup($type);
$return = array();
$usedPlugins = (array) $params->get('plugins');
$usedLocations = (array) $params->get('plugin_locations');
$usedEvents = (array) $params->get('plugin_events');
$this->_data = array();
if ($type != 'list') {
if (method_exists($oRequest, 'getGroupsHiarachy')) {
$groups =& $oRequest->getGroupsHiarachy();
foreach ($groups as $groupModel) {
$elementModels =& $groupModel->getPublishedElements();
foreach ($elementModels as $elementModel) {
if (method_exists($elementModel, $method)) {
$elementModel->{$method}($oRequest);
}
}
}
}
}
$c = 0;
$runPlugins = 0;
// if true then a plugin has returned true from runAway() which means that any other plugin in the same group
// should not be run.
$runningAway = false;
foreach ($usedPlugins as $usedPlugin) {
if ($runningAway) {
// "I soiled my armour I was so scared!"
break;
}
if ($usedPlugin != '') {
$plugin = $this->getPlugIn($usedPlugin, $type);
//testing this if statement as onLoad was being called on form email plugin when no method availbale
$plugin->renderOrder = $c;
if (method_exists($plugin, $method)) {
$modelTable = $oRequest->getTable();
$pluginParams =& $plugin->setParams($params, $c);
$location = JArrayHelper::getValue($usedLocations, $c);
$event = JArrayHelper::getValue($usedEvents, $c);
if ($plugin->canUse($oRequest, $location, $event) && method_exists($plugin, $method)) {
$pluginArgs = array();
if (func_num_args() > 3) {
$t =& func_get_args();
$pluginArgs =& array_splice($t, 3);
}
$preflightMethod = $method . "_preflightCheck";
$preflightCheck = method_exists($plugin, $preflightMethod) ? $plugin->{$preflightMethod}($pluginParams, $oRequest, $pluginArgs) : true;
if ($preflightCheck) {
$ok = $plugin->{$method}($pluginParams, $oRequest, $pluginArgs);
if ($ok === false) {
$return[] = false;
} else {
$thisreturn = $plugin->customProcessResult($method, $oRequest);
$return[] = $thisreturn;
$m = $method . '_result';
if (method_exists($plugin, $m)) {
$this->_data[] = $plugin->{$m}($c);
}
}
$runPlugins++;
if ($plugin->runAway($method)) {
$runningAway = true;
}
$mainData = $this->_data;
if ($type == 'list' && $method !== 'observe') {
$this->runPlugins('observe', $oRequest, 'list', $plugin, $method);
}
$this->_data = $mainData;
}
}
}
$c++;
}
}
$this->_runPlugins = $runPlugins;
return array_unique($return);
}
示例12: getLegend
/**
* Get the js code to create the legend
*
* @return string
*/
public function getLegend()
{
$this->setupEvents();
$ref = $this->getJSRenderContext();
// @TODO: json encode the returned value and move to the view
$aLegend = "{$ref}.addLegend([";
foreach ($this->events as $listId => $record) {
$listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
$listModel->setId($listId);
$table = $listModel->getTable();
foreach ($record as $data) {
$rubbish = $table->db_table_name . '___';
$colour = FabrikString::ltrimword($data['colour'], $rubbish);
$legend = FabrikString::ltrimword($data['legendtext'], $rubbish);
$label = empty($legend) ? $table->label : $legend;
$aLegend .= "{'label':'" . $label . "','colour':'" . $colour . "'},";
}
}
$aLegend = rtrim($aLegend, ",") . "]);";
return $aLegend;
}
示例13: removeDashes
/**
* Remove '-' from string
*
* @param string $str String to remove - from
*
* @return string
*/
protected function removeDashes($str)
{
$str = FabrikString::ltrimword($str, '-');
return $str;
}
示例14: getAdminJS
function getAdminJS()
{
$element =& $this->getElement();
$mooversion = FabrikWorker::getMooVersion() == 1 ? 1.2 : 1.1;
$script = "\tvar fabrikdropdown = new fabrikAdminDropdown({'mooversion':'{$mooversion}'});\n" . "\tpluginControllers.push({element:'fabrikdropdown', controller: fabrikdropdown});\n";
$sub_values = explode("|", $element->sub_values);
$sub_texts = explode("|", $element->sub_labels);
$sub_intial_selections = explode("|", FabrikString::ltrimword($element->sub_intial_selection, '|'));
$json = array();
for ($ii = 0; $ii < count($sub_values) && $ii < count($sub_texts); $ii++) {
$bits = array(html_entity_decode($sub_values[$ii], ENT_QUOTES), html_entity_decode($sub_texts[$ii], ENT_QUOTES));
if (in_array($sub_values[$ii], $sub_intial_selections)) {
$bits[] = 'checked';
}
$json[] = $bits;
}
$script .= "\tfabrikdropdown.addSubElements(" . json_encode($json) . ");\n";
return $script;
}
示例15: getGroupByHeadings
/**
* Get lists group by headings
*
* @return array heading names
*/
public function getGroupByHeadings()
{
$base = JURI::getInstance();
$base = $base->toString(array('scheme', 'user', 'pass', 'host', 'port', 'path'));
//$base .= JString::strpos($base, '?') ? '&' : '?';
$qs = JRequest::getVar('QUERY_STRING', '', 'server');
if (JString::stristr($qs, 'group_by')) {
$qs = FabrikString::removeQSVar($qs, 'group_by');
$qs = FabrikString::ltrimword($qs, '?');
}
$url = $base;
if (!empty($qs)) {
$url .= JString::strpos($url, '?') !== false ? '&' : '?';
$url .= $qs;
}
$url .= JString::strpos($url, '?') !== false ? '&' : '?';
$a = array();
list($h, $x, $b, $c) = $this->getHeadings();
$a[$url . 'group_by=0'] = JText::_('COM_FABRIK_NONE');
foreach ($h as $key => $v) {
if (!in_array($key, array('fabrik_select', 'fabrik_edit', 'fabrik_view', 'fabrik_delete', 'fabrik_actions'))) {
$thisurl = $url . 'group_by=' . $key;
$a[$thisurl] = strip_tags($v);
}
}
return $a;
}