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


PHP FabrikString::rtrimword方法代码示例

本文整理汇总了PHP中FabrikString::rtrimword方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikString::rtrimword方法的具体用法?PHP FabrikString::rtrimword怎么用?PHP FabrikString::rtrimword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FabrikString的用法示例。


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

示例1: storeDatabaseFormat

 /**
  * formats the posted data for insertion into the database
  * @param mixed thie elements posted form data
  * @param array posted form data
  */
 function storeDatabaseFormat($val, $data)
 {
     if ($this->getGroup()->canRepeat()) {
         $str = '';
         foreach ($val as $v) {
             $str .= $v[0] . GROUPSPLITTER;
         }
         $str = FabrikString::rtrimword($str, GROUPSPLITTER);
         return $str;
     } else {
         //if sent via inline edit val is string already
         return is_array($val) ? $val[0] : $val;
     }
 }
开发者ID:nikshade,项目名称:fabrik21,代码行数:19,代码来源:fabrikyesno.php

示例2: onDoContentSearch

 /**
  * Fabrik Search method
  *
  * The sql must return the following fields that are
  * used in a common display routine: href, title, section, created, text,
  * browsernav
  * @param string Target search string
  * @param string mathcing option, exact|any|all
  * @param string ordering option, newest|oldest|popular|alpha|category
  * @param mixed An array if restricted to areas, null if search all
  */
 function onDoContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     if (defined('COM_FABRIK_SEARCH_RUN')) {
         return;
     }
     define('COM_FABRIK_SEARCH_RUN', true);
     JModel::addIncludePath(COM_FABRIK_FRONTEND . DS . 'models', 'FabrikFEModel');
     $user = JFactory::getUser();
     $db = FabrikWorker::getDbo(true);
     require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
     // load plugin params info
     $limit = $this->params->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     switch ($ordering) {
         case 'oldest':
             $order = 'a.created ASC';
             break;
         case 'popular':
             $order = 'a.hits DESC';
             break;
         case 'alpha':
             $order = 'a.title ASC';
             break;
         case 'category':
             $order = 'b.title ASC, a.title ASC';
             $morder = 'a.title ASC';
             break;
         case 'newest':
         default:
             $order = 'a.created DESC';
             break;
     }
     //get all tables with search on
     $query = $db->getQuery(true);
     $query->select('id')->from('#__{package}_lists')->where('published = 1');
     $db->setQuery($query);
     $list = array();
     $ids = $db->loadColumn();
     if ($db->getErrorNum() != 0) {
         jexit('search:' . $db->getErrorMsg());
     }
     $section = $this->params->get('search_section_heading');
     $urls = array();
     //$$$ rob remove previous search results?
     JRequest::setVar('resetfilters', 1);
     //ensure search doesnt go over memory limits
     $memory = (int) FabrikString::rtrimword(ini_get('memory_limit'), 'M') * 1000000;
     $usage = array();
     $memSafety = 0;
     $listModel = JModel::getInstance('list', 'FabrikFEModel');
     $app = JFactory::getApplication();
     foreach ($ids as $id) {
         //	unset enough stuff in the table model to allow for correct query to be run
         $listModel->reset();
         /// $$$ geros - http://fabrikar.com/forums/showthread.php?t=21134&page=2
         $key = 'com_fabrik.list' . $id . '.filter.searchall';
         $app->setUserState($key, null);
         unset($table);
         unset($elementModel);
         unset($params);
         unset($query);
         unset($allrows);
         $used = memory_get_usage();
         $usage[] = memory_get_usage();
         if (count($usage) > 2) {
             $diff = $usage[count($usage) - 1] - $usage[count($usage) - 2];
             if ($diff + $usage[count($usage) - 1] > $memory - $memSafety) {
                 JError::raiseNotice(500, 'Some records were not searched due to memory limitations');
                 break;
             }
         }
         // $$$rob set this to current table
         //otherwise the fabrik_list_filter_all var is not used
         JRequest::setVar('listid', $id);
         $listModel->setId($id);
         $filterModel = $listModel->getFilterModel();
         $requestKey = $filterModel->getSearchAllRequestKey();
         //set the request variable that fabrik uses to search all records
         JRequest::setVar($requestKey, $text, 'post');
         $table = $listModel->getTable(true);
         $fabrikDb = $listModel->getDb();
         $params = $listModel->getParams();
         //test for swap too boolean mode
         $mode = JRequest::getVar('searchphraseall', 'all');
         //$params->set('search-mode-advanced', true);
         $params->set('search-mode-advanced', $mode);
//.........这里部分代码省略.........
开发者ID:rhotog,项目名称:fabrik,代码行数:101,代码来源:fabrik.php

示例3: render

 /**
  * draws the form element
  * @param int repeat group counter
  * @return string returns element html
  */
 function render($data, $repeatCounter = 0)
 {
     $name = $this->getHTMLName($repeatCounter);
     $id = $this->getHTMLId($repeatCounter);
     $element = $this->getElement();
     $params =& $this->getParams();
     $str = "<div class=\"fabrikSubElementContainer\" id=\"{$id}\">";
     $arVals = $this->getSubOptionValues();
     $arTxt = $this->getSubOptionLabels();
     $options_per_row = intval($params->get('ck_options_per_row', 0));
     // 0 for one line
     $selected = $this->getValue($data, $repeatCounter);
     $aRoValues = array();
     if ($options_per_row > 0) {
         $percentageWidth = floor(floatval(100) / $options_per_row) - 2;
         $div = "<div class=\"fabrik_subelement\" style=\"float:left;width:" . $percentageWidth . "%\">\n";
     }
     for ($ii = 0; $ii < count($arVals); $ii++) {
         if ($options_per_row > 0) {
             $str .= $div;
         }
         $thisname = FabrikString::rtrimword($name, '[]') . "[{$ii}]";
         $label = "<span>" . $arTxt[$ii] . "</span>";
         $value = htmlspecialchars($arVals[$ii], ENT_QUOTES);
         //for values like '1"'
         $chx = "<input type=\"checkbox\" class=\"fabrikinput checkbox\" name=\"{$thisname}\" value=\"" . $value . "\" ";
         if (is_array($selected) and in_array($arVals[$ii], $selected)) {
             if ($params->get('icon_folder') != -1 && $params->get('icon_folder') != '') {
                 $aRoValues[] = $this->_replaceWithIcons($arVals[$ii]);
             } else {
                 $aRoValues[] = $arTxt[$ii];
             }
             $chx .= " checked=\"checked\" />\n";
         } else {
             $chx .= " />\n";
         }
         $str .= $params->get('element_before_label') == '1' ? "<label>" . $chx . $label . "</label>\n" : "<label>" . $label . $chx . "</label>\n";
         if ($options_per_row > 0) {
             $str .= "</div> <!-- end row div -->\n";
         }
     }
     if (!$this->_editable) {
         $splitter = $params->get('icon_folder') != -1 && $params->get('icon_folder') != '' ? ' ' : ', ';
         return implode($splitter, $aRoValues);
     }
     if ($options_per_row > 0) {
         $str .= "<br />";
     }
     $str .= "</div>";
     if ($params->get('allow_frontend_addtocheckbox', false)) {
         $onlylabel = $params->get('chk-allowadd-onlylabel');
         $str .= $this->getAddOptionFields($onlylabel, $repeatCounter);
     }
     return $str;
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:60,代码来源:checkbox.php

示例4: getCordsFromData

 private function getCordsFromData($d)
 {
     $v = trim($d);
     $v = FabrikString::ltrimword($v, "(");
     if (strstr($v, ",")) {
         if (strstr($v, ":")) {
             $ar = explode(":", $v);
             array_pop($ar);
             $v = explode(",", $ar[0]);
         } else {
             $v = explode(",", $v);
         }
         $v[1] = FabrikString::rtrimword($v[1], ")");
     } else {
         $v = array(0, 0);
     }
     return $v;
 }
开发者ID:romuland,项目名称:khparts,代码行数:18,代码来源:googlemap.php

示例5: getFilterQuery

 /**
  * Build the filter query for the given element.
  * Can be overwritten in plugin - e.g. see checkbox element which checks for partial matches
  *
  * @param   string  $key            Element name in format `tablename`.`elementname`
  * @param   string  $condition      =/like etc.
  * @param   string  $value          Search string - already quoted if specified in filter array options
  * @param   string  $originalValue  Original filter value without quotes or %'s applied
  * @param   string  $type           Filter type advanced/normal/prefilter/search/querystring/searchall
  *
  * @return  string	sql query part e,g, "key = value"
  */
 public function getFilterQuery($key, $condition, $value, $originalValue, $type = 'normal')
 {
     $element = $this->getElement();
     $db = JFactory::getDbo();
     $condition = JString::strtoupper($condition);
     $this->encryptFieldName($key);
     $glue = 'OR';
     if ($element->filter_type == 'checkbox' || $element->filter_type == 'multiselect') {
         $str = array();
         if ($condition === 'NOT IN') {
             $partialComparison = ' NOT LIKE ';
             $comparison = ' <> ';
             $glue = ' AND ';
         } else {
             $partialComparison = ' LIKE ';
             $comparison = ' = ';
             $glue = ' OR ';
         }
         switch ($condition) {
             case 'IN':
             case 'NOT IN':
                 /**
                  * Split out 1,2,3 into an array to iterate over.
                  * It's a string if pre-filter, array if element filter
                  */
                 if (!is_array($originalValue)) {
                     $originalValue = explode(',', $originalValue);
                 }
                 foreach ($originalValue as &$v) {
                     $v = trim($v);
                     $v = FabrikString::ltrimword($v, '"');
                     $v = FabrikString::ltrimword($v, "'");
                     $v = FabrikString::rtrimword($v, '"');
                     $v = FabrikString::rtrimword($v, "'");
                 }
                 break;
             default:
                 $originalValue = (array) $originalValue;
                 break;
         }
         foreach ($originalValue as $v2) {
             $v2 = str_replace("/", "\\\\/", $v2);
             $str[] = '(' . $key . $partialComparison . $db->quote('%"' . $v2 . '"%') . $glue . $key . $comparison . $db->quote($v2) . ') ';
         }
         $str = '(' . implode($glue, $str) . ')';
     } else {
         $originalValue = trim($value, "'");
         /*
          * JSON stored values will back slash "/". So we need to add "\\\\"
          * before it to escape it for the query.
          */
         $originalValue = str_replace("/", "\\\\/", $originalValue);
         if (strtoupper($condition) === 'IS NULL') {
             $value = '';
         }
         switch ($condition) {
             case '=':
             case '<>':
                 $condition2 = $condition == '=' ? 'LIKE' : 'NOT LIKE';
                 $glue = $condition == '=' ? 'OR' : 'AND';
                 $db = FabrikWorker::getDbo();
                 $str = "({$key} {$condition} {$value} " . " {$glue} {$key} {$condition2} " . $db->quote('["' . $originalValue . '"%') . " {$glue} {$key} {$condition2} " . $db->quote('%"' . $originalValue . '"%') . " {$glue} {$key} {$condition2} " . $db->quote('%"' . $originalValue . '"]') . ")";
                 break;
             default:
                 $str = " {$key} {$condition} {$value} ";
                 break;
         }
     }
     return $str;
 }
开发者ID:ankaau,项目名称:GathBandhan,代码行数:82,代码来源:elementlist.php

示例6: makeInstallSQL

 /**
  * create the SQL install file
  *
  * @param   object  $row  package
  *
  * @return  string  path
  */
 protected function makeInstallSQL($row)
 {
     $sql = '';
     $config = JFactory::getConfig();
     $db = FabrikWorker::getDbo(true);
     // Create the sql for the cloned fabrik meta data tables
     foreach ($this->tables as $table) {
         $db->setQuery('SHOW CREATE TABLE ' . $table);
         $tbl = $db->loadRow();
         $tbl = str_replace('_fabrik_', '_' . $row->component_name . '_', $tbl[1]);
         $tbl = str_replace($config->get('dbprefix'), '#__', $tbl);
         $sql .= str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $tbl) . ";\n\n";
         $table = str_replace(array('_fabrik_', '{package}'), array('_' . $row->component_name . '_', $row->component_name), $table);
         $sql .= 'TRUNCATE TABLE ' . $table . ";\n\n";
     }
     foreach ($row->blocks as $block => $ids) {
         $key = FabrikString::rtrimword($block, 's');
     }
     // Create the sql to build the db tables that store the data.
     $formModel = JModelLegacy::getInstance('form', 'FabrikFEModel');
     $lookups = $this->getInstallItems($row);
     $lids = $lookups->list;
     JArrayHelper::toInteger($lids);
     $plugins = array();
     foreach ($lids as $lid) {
         $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
         $listModel->setId($lid);
         $sql .= "\n\n" . $listModel->getCreateTableSQL(true);
     }
     foreach ($lookups->form as $fid) {
         $formModel->setId($fid);
         if (!in_array($fid, $lookups->list)) {
             $lookups->list[] = $fid;
         }
         // @FIXME get sql to create tables for dbjoin/cdd elements (need to do if not exists)
         $dbs = $formModel->getElementOptions(false, 'name', true, true, array());
     }
     $sql .= "\n\n";
     if (isset($lookups->visualization)) {
         $vrow = FabTable::getInstance('Visualization', 'FabrikTable');
         $vrow->load($vid);
         $visModel = JModelLegacy::getInstance($vrow->plugin, 'fabrikModel');
         $visModel->setId($vid);
         $listModels = $visModel->getlistModels();
         foreach ($listModels as $lmodel) {
             $vrow = FabTable::getInstance('Visualization', 'FabrikTable');
             $vrow->load($vid);
             $visModel = JModel::getInstance($vrow->plugin, 'fabrikModel');
             $visModel->setId($vid);
             $listModels = $visModel->getlistModels();
             foreach ($listModels as $lmodel) {
                 $sql .= $lmodel->getCreateTableSQL(true);
                 // Add the table ids to the $lookups->list
                 if (!in_array($lmodel->getId(), $lookups->list)) {
                     $lookups->list[] = $lmodel->getId();
                 }
             }
         }
     }
     $path = $this->outputPath . 'admin/sql/install.mysql.uft8.sql';
     JFile::write($path, $sql);
     return $path;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:70,代码来源:package.php

示例7: save

 /**
  * save the pacakge
  * @param array data
  * @return bol
  */
 public function save($data)
 {
     $canvas = $data['params']['canvas'];
     $canvas = json_decode($canvas);
     $o = new stdClass();
     if (is_null($canvas)) {
         JError::raiseError(E_ERROR, 'malformed json package object');
     }
     $o->canvas = $canvas;
     $data['params'] = json_encode($o);
     $return = parent::save($data);
     $data['id'] = $this->getState($this->getName() . '.id');
     $packageId = $this->getState($this->getName() . '.id');
     $blocks = is_object($o->canvas) ? $o->canvas->blocks : array();
     foreach ($blocks as $fullkey => $ids) {
         $key = FabrikString::rtrimword($fullkey, 's');
         $tbl = JString::ucfirst($key);
         foreach ($ids as $id) {
             $item = $this->getTable($tbl);
             $item->load($id);
             if ($key == 'list') {
                 //also assign the form to the package
                 $form = $this->getTable('Form');
                 $form->load($item->form_id);
                 if (!in_array($form->id, $blocks->form)) {
                     $o->canvas->blocks->form[] = $item->id;
                 }
             }
         }
     }
     // resave the data to update blocks
     $data['params'] = json_encode($o);
     $return = parent::save($data);
     return $return;
 }
开发者ID:romuland,项目名称:khparts,代码行数:40,代码来源:package.php

示例8: sums

 /**
  * Build the sums() sql statement
  *
  * @return string
  */
 private function sums()
 {
     $params = $this->getParams();
     $sums = explode(',', $params->get('pivot_sum'));
     $db = $this->model->getDb();
     $fn = (int) $params->get('pivot_count', '0') == 1 ? 'COUNT' : 'SUM';
     foreach ($sums as &$sum) {
         $sum = trim($sum);
         $sum = FabrikString::rtrimword($sum, '_raw');
         $as = FabrikString::safeColNameToArrayKey($sum);
         $statement = $fn . '(' . FabrikString::safeColName($sum) . ')';
         $statement .= ' AS ' . $db->quoteName($as);
         $statement .= ', ' . $fn . '(' . FabrikString::safeColName($sum) . ')';
         $statement .= ' AS ' . $db->quoteName($as . '_raw');
         $sum = $statement;
     }
     $sum = implode(', ', $sums);
     return $sum;
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:24,代码来源:pivot.php

示例9: stripElementsFromUrl

 /**
  * Strip out any element names from url qs vars
  *
  * @param   string  $url  URL
  *
  * @return  string
  */
 protected function stripElementsFromUrl($url)
 {
     $url = explode('?', $url);
     if (count($url) == 1) {
         return $url;
     }
     $filtered = array();
     $bits = explode('&', $url[1]);
     foreach ($bits as $bit) {
         $parts = explode('=', $bit);
         $key = $parts[0];
         $key = FabrikString::rtrimword($key, '_raw');
         if (!$this->hasElement($key)) {
             $filtered[] = implode('=', $parts);
         }
     }
     $url = $url[0] . '?' . implode('&', $filtered);
     return $url;
 }
开发者ID:glauberm,项目名称:cinevi,代码行数:26,代码来源:form.php

示例10: render

 /**
  * Draws the html form element
  *
  * @param   array  $data           to pre-populate element with
  * @param   int    $repeatCounter  repeat group counter
  *
  * @return  string	elements html
  */
 public function render($data, $repeatCounter = 0)
 {
     $name = $this->getHTMLName($repeatCounter);
     $id = $this->getHTMLId($repeatCounter);
     $params = $this->getParams();
     $bits = $this->inputProperties($repeatCounter);
     $value = $this->getValue($data, $repeatCounter);
     $opts = array();
     if ($value == '') {
         $value = array('label' => '', 'link' => '');
     } else {
         if (!is_array($value)) {
             $value = FabrikWorker::JSONtoData($value, true);
             /**
              * In some legacy case, data is like ...
              * [{"label":"foo","link":"bar"}]
              * ... I think if it came from 2.1.  So lets check to see if we need
              * to massage that into the right format
              */
             if (array_key_exists(0, $value) && is_object($value[0])) {
                 $value = JArrayHelper::fromObject($value[0]);
             } elseif (array_key_exists(0, $value)) {
                 $value['label'] = $value[0];
             }
         }
     }
     if (count($value) == 0) {
         $value = array('label' => '', 'link' => '');
     }
     if (FabrikWorker::getMenuOrRequestVar('rowid') == 0 && FArrayHelper::getValue($value, 'link', '') === '') {
         $value['link'] = $params->get('link_default_url');
     }
     if (!$this->isEditable()) {
         $lbl = trim(FArrayHelper::getValue($value, 'label'));
         $href = trim(FArrayHelper::getValue($value, 'link'));
         $w = new FabrikWorker();
         $href = is_array($data) ? $w->parseMessageForPlaceHolder($href, $data) : $w->parseMessageForPlaceHolder($href);
         $opts['target'] = trim($params->get('link_target', ''));
         $opts['smart_link'] = $params->get('link_smart_link', false);
         $opts['rel'] = $params->get('rel', '');
         $title = $params->get('link_title', '');
         if ($title !== '') {
             $opts['title'] = strip_tags($w->parseMessageForPlaceHolder($title, $data));
         }
         return FabrikHelperHTML::a($href, $lbl, $opts);
     }
     $labelname = FabrikString::rtrimword($name, '[]') . '[label]';
     $linkname = FabrikString::rtrimword($name, '[]') . '[link]';
     $bits['name'] = $labelname;
     $bits['placeholder'] = FText::_('PLG_ELEMENT_LINK_LABEL');
     $bits['value'] = $value['label'];
     $bits['class'] .= ' fabrikSubElement';
     unset($bits['id']);
     $layout = $this->getLayout('form');
     $layoutData = new stdClass();
     $layoutData->id = $id;
     $layoutData->name = $name;
     $layoutData->linkAttributes = $bits;
     $bits['placeholder'] = FText::_('PLG_ELEMENT_LINK_URL');
     $bits['name'] = $linkname;
     $bits['value'] = FArrayHelper::getValue($value, 'link');
     if (is_a($bits['value'], 'stdClass')) {
         $bits['value'] = $bits['value']->{0};
     }
     $layoutData->labelAttributes = $bits;
     return $layout->render($layoutData);
 }
开发者ID:LGBGit,项目名称:tierno,代码行数:75,代码来源:link.php

示例11: resize

 /**
  * resize an image to a specific width/height using standard php gd graphics lib
  * @param int maximum image Width (px)
  * @param int maximum image Height (px)
  * @param string current images folder pathe (must have trailing end slash)
  * @param string destination folder path for resized image (must have trailing end slash)
  * @param string file name of the image to resize
  * @param bol save the resized image
  * @return object? image
  *
  */
 function resize($maxWidth, $maxHeight, $origFile, $destFile)
 {
     /* check if the file exists*/
     if (!$this->storage->exists($origFile)) {
         return JError::raiseError(500, "no file found for {$origFile}");
     }
     /* Load image*/
     $img = null;
     $ext = $this->GetImgType($origFile);
     if (!$ext) {
         return;
     }
     ini_set('display_errors', true);
     $memory = ini_get('memory_limit');
     $intmemory = FabrikString::rtrimword($memory, 'M');
     if ($intmemory < 50) {
         ini_set('memory_limit', '50M');
     }
     if ($ext == 'jpg' || $ext == 'jpeg') {
         $img = imagecreatefromjpeg($origFile);
         $header = "image/jpeg";
     } else {
         if ($ext == 'png') {
             $img = imagecreatefrompng($origFile);
             $header = "image/png";
             /* Only if your version of GD includes GIF support*/
         } else {
             if ($ext == 'gif') {
                 if (function_exists(imagecreatefromgif)) {
                     $img = imagecreatefromgif($origFile);
                     $header = "image/gif";
                 } else {
                     JError::raiseWarning(21, "imagecreate from gif not available");
                 }
             }
         }
     }
     /* If an image was successfully loaded, test the image for size*/
     if ($img) {
         /* Get image size and scale ratio*/
         $width = imagesx($img);
         $height = imagesy($img);
         $scale = min($maxWidth / $width, $maxHeight / $height);
         /* If the image is larger than the max shrink it*/
         if ($scale < 1) {
             $new_width = floor($scale * $width);
             $new_height = floor($scale * $height);
             /* Create a new temporary image*/
             $tmp_img = imagecreatetruecolor($new_width, $new_height);
             /* Copy and resize old image into new image*/
             imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
             imagedestroy($img);
             $img = $tmp_img;
         }
     }
     if (!$img) {
         JError::raiseWarning(21, "no image created for {$origFile}, extension = {$ext} , destination = {$destFile} ");
     }
     /* save the file
     		 * wite them out to output buffer first so that we can use JFile to write them
     		 to the server (potential using J ftp layer)  */
     if ($header == "image/jpeg") {
         ob_start();
         imagejpeg($img, "", 100);
         $image = ob_get_contents();
         ob_end_clean();
         $this->storage->write($destFile, $image);
     } else {
         if ($header == "image/png") {
             ob_start();
             imagepng($img, "", 0);
             $image = ob_get_contents();
             ob_end_clean();
             $this->storage->write($destFile, $image);
         } else {
             if (function_exists("imagegif")) {
                 ob_start();
                 imagegif($img, "", 100);
                 $image = ob_get_contents();
                 ob_end_clean();
                 $this->storage->write($destFile, $image);
             } else {
                 /* try using imagemagick to convert gif to png:*/
                 $image_file = imgkConvertImage($image_file, $baseDir, $destDir, ".png");
             }
         }
     }
     $this->_thumbPath = $destFile;
     ini_set('memory_limit', $memory);
//.........这里部分代码省略.........
开发者ID:rhotog,项目名称:fabrik,代码行数:101,代码来源:image.php

示例12: formatForJoins

 /**
  * Collapses 'repeated joined' rows into a single row.
  * If a group is not repeating we just use the first row's data (as subsequent rows will contain the same data
  * Otherwise if the group is repeating we append each repeated record's data into the first row's data
  * All rows execpt the first row for each group are then unset (as unique subsequent row's data will be contained within
  * the first row)
  * @param array $data
  */
 function formatForJoins(&$data)
 {
     $merge = $this->mergeJoinedData();
     if (empty($merge)) {
         return;
     }
     $listid = $this->getTable()->id;
     $dbprimaryKey = FabrikString::safeColNameToArrayKey($this->getTable()->db_primary_key);
     $formModel =& $this->getFormModel();
     foreach ($data as $groupk => $group) {
         $last_pk = '';
         $last_i = 0;
         $count = count($group);
         $can_repeats = array();
         for ($i = 0; $i < $count; $i++) {
             // $$$rob if rendering J article in PDF format __pk_val not in pdf table view
             //$next_pk = isset($data[$groupk][$i]->__pk_val) ? $data[$groupk][$i]->__pk_val : $data[$groupk][$i]->id;
             $next_pk = isset($data[$groupk][$i]->__pk_val) ? $data[$groupk][$i]->__pk_val : $data[$groupk][$i]->{$dbprimaryKey};
             if (!empty($last_pk) && $last_pk == $next_pk) {
                 foreach ($data[$groupk][$i] as $key => $val) {
                     $origKey = $key;
                     $tmpkey = FabrikString::rtrimword($key, '_raw');
                     // $$$ hugh - had to cache this stuff, because if you have a lot of rows and a lot of elements,
                     // doing this many hundreds of times causes huge slowdown, exceeding max script execution time!
                     // And we really only need to do it once for the first row.
                     if (!isset($can_repeats[$tmpkey])) {
                         $elementModel =& $formModel->getElement($tmpkey);
                         $can_repeats[$tmpkey] = $elementModel ? $elementModel->getGroup()->canRepeat() : 0;
                     }
                     if (isset($data[$groupk][$last_i]->{$key}) && $can_repeats[$tmpkey]) {
                         // $$$ rob - what about data like yes/no where each viewable option needs to be shown?
                         // $$$ rob - yeah commenting this out, not a good idea - as other cols for this record may have
                         // different data so you end up with this col having 3 entries and the next col having four and you can't
                         // see the correlation between the two sets of data.
                         //if ($data[$groupk][$last_i]->$key != $val) {
                         // $$$ rob meant that only one link to details was shown in admin - dont see the point in that
                         //if (preg_match("#\W+fabrik___rowlink.*\W+listid=$listid\W#",$val)) {
                         //continue;
                         //}
                         if ($origKey == $tmpkey) {
                             $data[$groupk][$last_i]->{$key} .= "<br >\n" . $val;
                         } else {
                             $json = json_decode($data[$groupk][$last_i]->{$origKey});
                             $json = $val;
                             $data[$groupk][$last_i]->{$origKey} = json_encode($json);
                             //$data[$groupk][$last_i]->$origKey .= GROUPSPLITTER.$val;
                         }
                     }
                 }
                 unset($data[$groupk][$i]);
                 continue;
             } else {
                 $last_i = $i;
                 // $$$rob if rendering J article in PDF format __pk_val not in pdf table view
                 $last_pk = $next_pk;
             }
         }
         // $$$ rob ensure that we have a sequental set of keys otherwise ajax json will turn array into object
         $data[$groupk] = array_values($data[$groupk]);
     }
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:69,代码来源:list.php

示例13: gridItems

 /**
  * Build array of items for use in grid()
  *
  * @param   array   $values              Option values
  * @param   array   $labels              Option labels
  * @param   array   $selected            Selected options
  * @param   string  $name                Input name
  * @param   string  $type                Checkbox/radio etc
  * @param   bool    $elementBeforeLabel  Element before or after the label - deprecated - not used in Joomla 3
  * @param   array   $classes             Label classes
  * @param   bool    $buttonGroup         Should it be rendered as a bootstrap button group (radio only)
  *
  * @return  array  Grid items
  */
 public static function gridItems($values, $labels, $selected, $name, $type = 'checkbox', $elementBeforeLabel = true, $classes = array(), $buttonGroup = false)
 {
     $j3 = FabrikWorker::j3();
     $version = new JVersion();
     for ($i = 0; $i < count($values); $i++) {
         $item = array();
         $thisname = $type === 'checkbox' ? FabrikString::rtrimword($name, '[]') . '[' . $i . ']' : $name;
         $label = '<span>' . $labels[$i] . '</span>';
         // For values like '1"'
         $value = htmlspecialchars($values[$i], ENT_QUOTES);
         $inputClass = FabrikWorker::j3() ? '' : $type;
         if (array_key_exists('input', $classes)) {
             $inputClass .= ' ' . implode(' ', $classes['input']);
         }
         $chx = '<input type="' . $type . '" class="fabrikinput ' . $inputClass . '" name="' . $thisname . '" value="' . $value . '" ';
         $sel = in_array($values[$i], $selected);
         $chx .= $sel ? ' checked="checked" />' : ' />';
         $labelClass = FabrikWorker::j3() && !$buttonGroup ? $type : '';
         $item[] = '<label class="fabrikgrid_' . $value . ' ' . $labelClass . '">';
         $item[] = $elementBeforeLabel == '1' ? $chx . $label : $label . $chx;
         $item[] = '</label>';
         $items[] = implode("\n", $item);
     }
     return $items;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:39,代码来源:html.php

示例14: render


//.........这里部分代码省略.........
     /*
      * $$$ hugh testing slide-show display
      */
     if ($params->get('fu_show_image') === '3' && !$this->isEditable()) {
         // Failed validations - format different!
         if (array_key_exists('id', $values)) {
             $values = array_keys($values['id']);
         }
         $rendered = $this->buildCarousel($id, $values, $params, $data);
         return $rendered;
     }
     if ($params->get('fu_show_image') !== '0' && !$params->get('ajax_upload') || !$this->isEditable()) {
         // Failed validations - format different!
         if (array_key_exists('id', $values)) {
             $values = array_keys($values['id']);
         }
         // End failed validations
         foreach ($values as $value) {
             if (is_object($value)) {
                 $value = $value->file;
             }
             $render = $this->loadElement($value);
             if ($use_wip && $this->isEditable() || $value != '' && ($storage->exists(COM_FABRIK_BASE . $value) || JString::substr($value, 0, 4) == 'http')) {
                 $render->render($this, $params, $value);
             }
             if ($render->output != '') {
                 if ($this->isEditable()) {
                     // $$$ hugh - TESTING - using HTML5 to show a selected image, so if no file, still need the span, hidden, but not the actual delete button
                     if ($use_wip && empty($value)) {
                         $render->output = '<span class="fabrikUploadDelete fabrikHide" id="' . $id . '_delete_span">' . $render->output . '</span>';
                     } else {
                         $render->output = '<span class="fabrikUploadDelete" id="' . $id . '_delete_span">' . $this->deleteButton($value, $repeatCounter) . $render->output . '</span>';
                     }
                     /*
                     if ($use_wip)
                     {
                     	$render->output .= '<video id="' . $id . '_video_preview" controls></video>';
                     }
                     */
                 }
                 $allRenders[] = $render->output;
             }
         }
     }
     if (!$this->isEditable()) {
         if ($render->output == '' && $params->get('default_image') != '') {
             $render->output = '<img src="' . $params->get('default_image') . '" alt="image" />';
             $allRenders[] = $render->output;
         }
         $str[] = '<div class="fabrikSubElementContainer">';
         $ul = '<ul class="fabrikRepeatData"><li>' . implode('</li><li>', $allRenders) . '</li></ul>';
         $str[] = count($allRenders) < 2 ? implode("\n", $allRenders) : $ul;
         $str[] = '</div>';
         return implode("\n", $str);
     }
     $allRenders = implode('<br/>', $allRenders);
     $allRenders .= $allRenders == '' ? '' : '<br/>';
     $capture = '';
     switch ($device_capture) {
         case 1:
             $capture = ' capture="camera"';
         case 2:
             $capture = ' accept="image/*"' . $capture;
             break;
         case 3:
             $capture = ' capture="microphone"';
         case 4:
             $capture = ' accept="audio/*"' . $capture;
             break;
         case 5:
             $capture = ' capture="camcorder"';
         case 6:
             $capture = ' accept="video/*"' . $capture;
             break;
         default:
             $capture = implode(",.", $this->_getAllowedExtension());
             $capture = $capture ? ' accept=".' . $capture . '"' : '';
             break;
     }
     $str[] = $allRenders . '<input class="fabrikinput" name="' . $name . '" type="file" id="' . $id . '"' . $capture . ' />' . "\n";
     if ($params->get('fileupload_storage_type', 'filesystemstorage') == 'filesystemstorage' && $params->get('upload_allow_folderselect') == '1') {
         $rDir = JPATH_SITE . '/' . $params->get('ul_directory');
         $folders = JFolder::folders($rDir);
         $str[] = FabrikHelperHTML::folderAjaxSelect($folders);
         if ($groupModel->canRepeat()) {
             $uploadName = FabrikString::rtrimword($name, "[{$repeatCounter}]") . "[ul_end_dir][{$repeatCounter}]";
         } else {
             $uploadName = $name . '[ul_end_dir]';
         }
         $str[] = '<input name="' . $uploadName . '" type="hidden" class="folderpath"/>';
     }
     if ($params->get('ajax_upload')) {
         $str = array();
         $str[] = $allRenders;
         $str = $this->plupload($str, $repeatCounter, $values);
     }
     array_unshift($str, '<div class="fabrikSubElementContainer">');
     $str[] = '</div>';
     return implode("\n", $str);
 }
开发者ID:LGBGit,项目名称:tierno,代码行数:101,代码来源:fileupload.php

示例15: renderCheckBoxList

 /**
  * Render checkbox list in form
  *
  * @param   array  $data           Form data
  * @param   int    $repeatCounter  Repeat group counter
  * @param   array  &$html          HTML to assign output to
  * @param   array  $tmp            List of value/label objects
  * @param   array  $default        Default values - the lookup table's primary key values
  *
  * @since   3.0.7
  *
  * @return  void
  */
 protected function renderCheckBoxList($data, $repeatCounter, &$html, $tmp, $default)
 {
     $id = $this->getHTMLId($repeatCounter);
     $name = $this->getHTMLName($repeatCounter);
     $params = $this->getParams();
     $optsPerRow = (int) $params->get('dbjoin_options_per_row', 0);
     $html[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
     $editable = $this->isEditable();
     $attribs = 'class="fabrikinput inputbox" id="' . $id . '"';
     $name = FabrikString::rtrimword($name, '[]');
     $targetIds = $this->multiOptionTargetIds($data, $repeatCounter);
     if ($targetIds !== false) {
         $default = $targetIds;
     }
     $html[] = FabrikHelperHTML::aList('checkbox', $tmp, $name, $attribs, $default, 'value', 'text', $optsPerRow, $editable);
     if (empty($tmp)) {
         $tmpids = array();
         $o = new stdClass();
         $o->text = 'dummy';
         $o->value = 'dummy';
         $tmpids[] = $o;
         $tmp = $tmpids;
         $dummy = FabrikHelperHTML::aList('checkbox', $tmp, $name, $attribs, $default, 'value', 'text', 1, true);
         $html[] = '<div class="chxTmplNode">' . $dummy . '</div>';
     }
     $html[] = '</div>';
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:40,代码来源:databasejoin.php


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