Пример #1
0
 /**
  * returns HTML code for the filters
  *
  * @param  SimpleXMLElement[]  $items           The xml items to parse output
  * @param  string              $type            The type of xml items (e.g. filter, batch, import, export...)
  * @param  RegistryEditView    $editRowView     The edit view for the row
  * @param  string              $htmlFormatting  The HTML formatting for the filters ( 'table', 'td', 'none' )
  * @return array
  */
 function xmlItems($items, $type, $editRowView, $htmlFormatting = 'none')
 {
     $lists = array();
     if (count($items) > 0) {
         $valueObj = new Registry();
         $saveName = array();
         foreach ($items as $k => $v) {
             $valname = $type . '_' . $v['name'];
             $valueObj->set($valname, $v['value']);
             /** @var $v SimpleXMLElement[] */
             $saveName[$k] = $v['xml']->attributes('name');
             /** @noinspection PhpUndefinedMethodInspection */
             $items[$k]['xml']->addAttribute('name', $type . '_' . $saveName[$k]);
             /** @var $v array */
             $editRowView->setSelectValues($v['xml'], $v['selectValues']);
         }
         $renderedViews = array();
         foreach ($items as $k => $v) {
             /** @var $v SimpleXMLElement[] */
             $viewName = $v['xml']->attributes('view');
             if ($viewName) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $view = $items[$k]['xmlparent']->getChildByNameAttr('view', 'name', $viewName);
                 if (!$view) {
                     echo 'filter view ' . $viewName . ' not defined in filters';
                 }
             } else {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $view = $items[$k]['xml']->getElementByPath('view');
             }
             $value = $items[$k]['value'];
             if ($value !== null && $value !== '') {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $classes = $items[$k]['xml']->attributes('cssclass');
                 /** @noinspection PhpUndefinedMethodInspection */
                 $items[$k]['xml']->addAttribute('cssclass', $classes . ' focus');
             }
             if ($view) {
                 if (!$viewName || !in_array($viewName, $renderedViews)) {
                     /** @var SimpleXMLElement $view */
                     $htmlFormattingView = $view->attributes('viewformatting');
                     if ($htmlFormattingView == '') {
                         $htmlFormattingView = $htmlFormatting;
                     }
                     $lists[$k] = '<div class="cb' . htmlspecialchars(ucfirst($type)) . ' cb' . htmlspecialchars(ucfirst($type)) . 'View">' . $editRowView->renderEditRowView($view, $valueObj, $this, $this->_options, 'param', $htmlFormattingView) . '</div>';
                 }
                 if ($viewName) {
                     $renderedViews[] = $viewName;
                 }
             } else {
                 $editRowView->pushModelOfData($valueObj);
                 $editRowView->extendParamAttributes($items[$k]['xml'], $this->control_name());
                 $result = $editRowView->renderParam($items[$k]['xml'], $this->control_name(), false);
                 $editRowView->popModelOfData();
                 if ($result[0] || $result[1] || $result[2]) {
                     $lists[$k] = '<div class="cb' . htmlspecialchars(ucfirst($type)) . '">' . ($result[0] ? '<span class="cbLabelSpan">' . $result[0] . '</span> ' : null) . '<span class="cbFieldSpan">' . $result[1] . '</span>' . ($result[2] ? ' <span class="cbDescrSpan">' . $result[2] . '</span>' : null) . '</div>';
                 }
             }
         }
         foreach ($items as $k => $v) {
             /** @noinspection PhpUndefinedMethodInspection */
             $items[$k]['xml']->addAttribute('name', $saveName[$k]);
         }
     }
     return $lists;
 }
 /**
  * View for <param  type="private" class="cbpaidParamsExt" method="datalist">...
  *
  * @param  string              $value                  Stored Data of Model Value associated with the element
  * @param  ParamsInterface     $pluginParams           Main settigns parameters of the plugin
  * @param  string              $name                   Name attribute
  * @param  CBSimpleXMLElement  $param                  This XML node
  * @param  string              $control_name           Name of the control
  * @param  string              $control_name_name      css id-encode of the names of the controls surrounding this node
  * @param  boolean             $view                   TRUE: view, FALSE: edit
  * @param  cbpaidTable         $modelOfData            Data of the Model corresponding to this View
  * @param  cbpaidTable[]       $modelOfDataRows        Displayed Rows if it is a table
  * @param  int                 $modelOfDataRowsNumber  Total Number of rows
  * @return null|string
  */
 public function datalist($value, &$pluginParams, $name, &$param, $control_name, $control_name_name, $view, &$modelOfData, &$modelOfDataRows, &$modelOfDataRowsNumber)
 {
     global $_CB_database;
     //TBD	$multi					=	( $param->attributes( 'multiple' ) == 'true' );
     $data = $param->getElementByPath('data');
     if ($data) {
         $dataTable = $data->attributes('table');
         if (!$dataTable) {
             if (isset($this->table)) {
                 $dataTable = $this->table;
             } elseif (is_object($modelOfData) && $modelOfData instanceof TableInterface) {
                 $dataTable = $modelOfData->getTableName();
             } elseif (is_object($modelOfData) && isset($modelOfData->_tbl)) {
                 $dataTable = $modelOfData->_tbl;
             } else {
                 $dataTable = null;
             }
         }
         $xmlsql = new XmlQuery($_CB_database, $dataTable, $pluginParams);
         $xmlsql->setExternalDataTypeValues('modelofdata', $modelOfData);
         $xmlsql->process_orderby($data->getElementByPath('orderby'));
         // <data><orderby><field> fields
         $xmlsql->process_fields($data->getElementByPath('rows'));
         // <data><rows><field> fields
         $xmlsql->process_where($data->getElementByPath('where'));
         // <data><where><column> fields
         $groupby = $data->getElementByPath('groupby');
         if (!$groupby) {
             $groupby = 'value';
         }
         if ($data->attributes('dogroupby') != 'false') {
             $xmlsql->process_groupby($groupby);
         }
         $fieldValuesInDb = $xmlsql->queryLoadObjectsList($data);
         // get the records
         if ($view) {
             if (is_array($fieldValuesInDb)) {
                 foreach ($fieldValuesInDb as $v) {
                     if ($v->value == $value) {
                         $value = $v->text;
                         break;
                     }
                 }
             }
             return htmlspecialchars($value);
         } else {
             // check if value is in possible values:
             if ($value != $param->attributes('default') && is_array($fieldValuesInDb)) {
                 $setToDefault = true;
                 foreach ($fieldValuesInDb as $v) {
                     if ($v->value == $value) {
                         $setToDefault = false;
                         break;
                     }
                 }
                 if ($setToDefault) {
                     $value = $param->attributes('default');
                 }
             }
             if ($param->attributes('blanktext') && ($param->attributes('hideblanktext') != 'true' || $value == $param->attributes('default'))) {
                 $default = (string) $param->attributes('default');
                 array_unshift($fieldValuesInDb, moscomprofilerHTML::makeOption($default, CBPTXT::T($param->attributes('blanktext'))));
             }
             //TBD	$selected			=	explode( '|*|', $value );
             $classes = 'class="' . RegistryEditView::buildClasses($param, array('form-control')) . '"';
             return moscomprofilerHTML::selectList($fieldValuesInDb, $control_name_name, $classes . $this->_title($param), 'value', 'text', $value, 2);
             // return $this->selectList( $fieldValuesInDb, $param, $control_name, $name, $selected, $multi );
         }
     }
     return null;
 }
Пример #3
0
 /**
  * Writes the edit form for new and existing module
  *
  * A new record is defined when <var>$row</var> is passed with the <var>id</var>
  * property set to 0.
  *
  * @param  array                     $options
  * @param  array                     $actionPath
  * @param  SimpleXMLElement          $viewModel
  * @param  TableInterface|\stdClass  $data
  * @param  RegistryEditController    $params
  * @param  PluginTable               $pluginRow
  * @param  string                    $viewType     ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view )
  * @param  string                    $cbprevstate
  * @param  boolean                   $htmlOutput   True to output headers for CSS and Javascript
  */
 public static function editPluginView($options, $actionPath, $viewModel, $data, $params, $pluginRow, $viewType, $cbprevstate, $htmlOutput)
 {
     global $_CB_framework, $_CB_Backend_Title, $_PLUGINS, $ueConfig;
     $name = $viewModel->attributes('name');
     $label = $viewModel->attributes('label');
     $iconPair = explode(':', $viewModel->attributes('icon'));
     if (count($iconPair) > 1) {
         $iconset = isset($iconPair[0]) ? $iconPair[0] : null;
         $icon = isset($iconPair[1]) ? $iconPair[1] : null;
     } else {
         $iconset = 'fa';
         $icon = isset($iconPair[0]) ? $iconPair[0] : null;
     }
     if ($icon) {
         if ($iconset == 'fa') {
             $icon = 'fa fa-' . $icon;
         } elseif ($iconset) {
             $icon = $iconset . $icon;
         }
     }
     $id = null;
     if (is_object($data)) {
         $dataArray = get_object_vars($data);
         if (in_array('id', $dataArray)) {
             // General object
             $id = (int) $data->id;
         } elseif (in_array('tabid', $dataArray)) {
             // Field object
             $id = (int) $data->tabid;
         } elseif (in_array('fieldid', $dataArray)) {
             // Tab object
             $id = (int) $data->fieldid;
         }
     }
     if ($id !== null) {
         if (isset($data->title)) {
             $item = $data->title;
         } elseif (isset($data->name)) {
             $item = $data->name;
         } else {
             $item = $id;
         }
         $title = ($id ? CBTxt::T('Edit') : CBTxt::T('New')) . ($label ? ' ' . htmlspecialchars(CBTxt::T($label)) . ' ' : null) . ($item ? ' [' . htmlspecialchars(CBTxt::T($item)) . ']' : null);
     } else {
         $title = $label ? htmlspecialchars(CBTxt::T($label)) : null;
     }
     if ($viewModel->attributes('label')) {
         $showDisclaimer = true;
         if ($pluginRow) {
             if (!$icon) {
                 $icon = 'cb-' . str_replace('.', '_', $pluginRow->element) . '-' . $name;
             }
             $_CB_Backend_Title = array(0 => array($icon, htmlspecialchars(CBTxt::T($pluginRow->name)) . ($title ? ': ' . $title : null)));
         } else {
             if (!$icon) {
                 $icon = 'cb-' . $name;
             }
             $_CB_Backend_Title = array(0 => array($icon, htmlspecialchars(CBTxt::T('Community Builder')) . ($title ? ': ' . $title : null)));
         }
         // Null the label so the view form doesn't output it as we already did as page title:
         $viewModel->addAttribute('label', null);
     } else {
         $showDisclaimer = false;
     }
     $htmlFormatting = $viewModel->attributes('viewformatting');
     if (!$htmlFormatting) {
         if ($_CB_framework->getUi() == 1 && (isset($ueConfig['use_divs']) && $ueConfig['use_divs'] == 1)) {
             $htmlFormatting = 'div';
         } else {
             $htmlFormatting = 'table';
         }
     }
     new cbTabs(true, 2);
     $settingsHtml = $params->draw(null, null, null, null, null, null, false, $viewType, $htmlFormatting);
     if ($htmlOutput) {
         outputCbTemplate();
         outputCbJs();
         self::outputAdminJs();
         initToolTip();
         self::outputRegTemplate();
     }
     $return = null;
     if ($pluginRow && $pluginRow->id) {
         if (!$pluginRow->published) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('PLUGIN_NAME_IS_NOT_PUBLISHED', '[plugin_name] is not published.', array('[plugin_name]' => htmlspecialchars(CBTxt::T($pluginRow->name)))) . '</div>';
         }
         if (!$_PLUGINS->checkPluginCompatibility($pluginRow)) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('PLUGIN_NAME_IS_NOT_COMPATIBLE_WITH_YOUR_CURRENT_CB_VERSION', '[plugin_name] is not compatible with your current CB version.', array('[plugin_name]' => htmlspecialchars(CBTxt::T($pluginRow->name)))) . '</div>';
         }
     }
     if (is_object($data) && isset($data->id) && $data->id) {
         if (isset($data->published) && !$data->published) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('NAME_IS_NOT_PUBLISHED', '[name] is not published.', array('[name]' => htmlspecialchars(CBTxt::T($label)))) . '</div>';
         }
         if (isset($data->enabled) && !$data->enabled) {
             $return .= '<div class="alert alert-danger">' . CBTxt::T('NAME_IS_NOT_ENABLED', '[name] is not enabled.', array('[name]' => htmlspecialchars(CBTxt::T($label)))) . '</div>';
         }
     }
     if ($viewModel->attributes('formformatting') == 'none') {
         $return .= $settingsHtml ? $settingsHtml : null;
     } else {
         cbValidator::loadValidation();
         $cssClass = RegistryEditView::buildClasses($viewModel);
         if (!$cssClass) {
             $cssClass = 'cb_form form-auto';
         }
         $return .= '<form enctype="multipart/form-data" action="' . $_CB_framework->backendUrl('index.php') . '" method="post" name="adminForm" class="cbValidation ' . htmlspecialchars($cssClass) . '" id="cbAdminFormForm">' . ($settingsHtml ? $settingsHtml : null) . '<input type="hidden" name="option" value="' . htmlspecialchars($options['option']) . '" />' . ($pluginRow ? '<input type="hidden" name="cid" value="' . (int) $pluginRow->id . '" />' : null) . ($cbprevstate ? '<input type="hidden" name="cbprevstate" value="' . htmlspecialchars($cbprevstate) . '" />' : null);
         if ($actionPath) {
             foreach ($actionPath as $k => $v) {
                 $return .= '<input type="hidden" name="' . htmlspecialchars($k) . '" value="' . htmlspecialchars($v) . '" />';
             }
         }
         $return .= cbGetSpoofInputTag('plugin') . '</form>';
     }
     if ($showDisclaimer) {
         $disclaimerTitle = 'Disclaimer';
         $disclaimerText = 'This software comes "as is" with no guarantee for accuracy, function or fitness for any purpose.';
         $disclaimerTitleTr = CBTxt::Th('Disclaimer');
         $disclaimerTextTr = CBTxt::Th('This software comes "as is" with no guarantee for accuracy, function or fitness for any purpose.');
         $return .= '<div class="cbregCopyrightfooter content-spacer" style="font-size:11px; color:black; display:block;">' . CBTxt::Th('CB_FOOTNOTE_OPEN_SOURCE_WITH_PLUGINS', 'Community Builder for Joomla, an open-source social framework by <a href="http://www.joomlapolis.com/?pk_campaign=in-cb&amp;pk_kwd=footer" target="_blank">Joomlapolis.com</a>, easy to extend with <a href="http://www.joomlapolis.com/cb-solutions?pk_campaign=in-cb&pk_kwd=footer" target="_blank">CB plugins</a>. Professional <a href="http://www.joomlapolis.com/support?pk_campaign=in-cb&pk_kwd=footer" target="_blank">Support</a> is available with a <a href="http://www.joomlapolis.com/memberships?pk_campaign=in-cb&pk_kwd=footer" target="_blank">Membership</a>.') . '<br /><strong>' . $disclaimerTitle . ':</strong> ' . $disclaimerText . ($disclaimerText != $disclaimerTextTr ? '<br /><strong>' . $disclaimerTitleTr . ':</strong> ' . $disclaimerTextTr : null) . '<br />' . CBTxt::Th('CB_FOOTNOTE_REVIEW_AND_RATE_AT_JED', 'If you use Community Builder, please post a rating and a review on the <a href="[JEDURL]" target="_blank">Joomla! Extensions Directory</a>.', array('[JEDURL]' => htmlspecialchars('http://extensions.joomla.org/extensions/clients-a-communities/communities/210 '))) . '</div>';
     }
     echo $return;
 }
Пример #4
0
	/**
	 * Implements a form password field
	 *
	 * @param  string              $name          The name of the form element
	 * @param  string              $value         The value of the element
	 * @param  SimpleXMLElement  $node          The xml element for the parameter
	 * @param  string              $control_name  The control name
	 * @return string                             The html for the element
	 */
	function _form_password( $name, $value, &$node, $control_name ) {
		if ( $this->_view ) {
			$sprintf	=	 $node->attributes( 'sprintf' );
			if ( $sprintf ) {
				return htmlspecialchars( sprintf( $sprintf, $value ) );
			} else {
				return "********";		// htmlspecialchars($value);
			}
		} else {
			$size		=	$node->attributes( 'size' );
			$siz		=	( $size ? ' size="' . (int) $size . '"' : null );
			$classes	=	' class="' . htmlspecialchars( RegistryEditView::buildClasses( $node, array( 'form-control' ) ) ) . '"';
			return '<input type="password" autocomplete="off" name="'. $this->control_name( $control_name, $name ) . '" id="'. $this->control_id( $control_name, $name ) . '" value="'. htmlspecialchars($value) .'"' . $siz . $classes . ' />';
		}
	}
 /**
  * @param  SimpleXMLElement[]  $xmlToolbarMenuArray
  * @return void
  */
 static function _PLUGIN_MENU($xmlToolbarMenuArray)
 {
     if ($xmlToolbarMenuArray && count($xmlToolbarMenuArray) > 0) {
         $started = false;
         foreach ($xmlToolbarMenuArray as $xmlTBmenu) {
             if ($xmlTBmenu && count($xmlTBmenu->children()) > 0) {
                 foreach ($xmlTBmenu->children() as $menu) {
                     /** @var SimpleXMLElement $menu */
                     if ($menu->getName() == 'menu') {
                         // $name			=	$menu->attributes( 'name' );
                         $action = $menu->attributes('action');
                         $task = $menu->attributes('task');
                         $label = $menu->attributes('label');
                         $class = RegistryEditView::buildClasses($menu);
                         $description = $menu->attributes('description');
                         if (in_array($action, get_class_methods('CBtoolmenuBar')) || in_array(strtolower($action), get_class_methods('CBtoolmenuBar'))) {
                             // PHP 5 || PHP 4
                             if (!$started) {
                                 CBtoolmenuBar::startTable();
                                 $started = true;
                             }
                             switch ($action) {
                                 case 'custom':
                                 case 'customX':
                                     $icon = $menu->attributes('icon');
                                     $iconOver = $menu->attributes('iconover');
                                     CBtoolmenuBar::$action($task, $icon, $iconOver, $label, false, null, $class);
                                     break;
                                 case 'editList':
                                     CBtoolmenuBar::editListNoSelect($task, $label);
                                     break;
                                 case 'deleteList':
                                 case 'deleteListX':
                                     $message = $menu->attributes('message');
                                     CBtoolmenuBar::$action($message, $task, $label);
                                     break;
                                 case 'trash':
                                     CBtoolmenuBar::$action($task, $label, false);
                                     break;
                                 case 'preview':
                                     $popup = $menu->attributes('popup');
                                     CBtoolmenuBar::$action($popup, true);
                                     break;
                                 case 'help':
                                     $ref = $menu->attributes('href');
                                     if (!$ref) {
                                         // Backwards compatibility to CB 1.x:
                                         $ref = $menu->attributes('ref');
                                     }
                                     CBtoolmenuBar::$action($ref, true);
                                     break;
                                 case 'divider':
                                 case 'spacer':
                                     CBtoolmenuBar::$action();
                                     break;
                                 case 'back':
                                     $href = $menu->attributes('href');
                                     CBtoolmenuBar::$action($label, $href);
                                     break;
                                 case 'media_manager':
                                     $directory = $menu->attributes('directory');
                                     CBtoolmenuBar::$action($directory, $label);
                                     break;
                                 case 'linkAction':
                                     $urllink = $menu->attributes('urllink');
                                     if ($menu->attributes('task') == 'new') {
                                         CBtoolmenuBar::$action($task, $urllink, $label, $class ? $class : (checkJversion('j3.0+') ? 'btn-success' : null));
                                     } else {
                                         CBtoolmenuBar::$action($task, $urllink, $label, $class);
                                     }
                                     break;
                                 default:
                                     CBtoolmenuBar::$action($task, $label);
                                     break;
                             }
                         } elseif ($action == 'permissions') {
                             if ($description) {
                                 $headerHtml = '<div class="cbbejeoptionsintro cbbejeoptionsintro' . htmlspecialchars($task) . '">' . $description . '</div>';
                             } else {
                                 $headerHtml = null;
                             }
                             self::_PERMISSIONS($task, $headerHtml);
                             if ($label) {
                                 self::_TRANSLATECONFIGTITLE($task, $label);
                             }
                         }
                         // if ( in_array( $action, array(	'customX', 'addNew', 'addNewX', 'publish', 'publishList', 'makeDefault', 'assign', 'unpublish', 'unpublishList',
                         //								'archiveList', 'unarchiveList', ) ) ) {
                         // nothing
                         // }
                     }
                 }
             }
         }
         if ($started) {
             CBtoolmenuBar::endTable();
         }
     }
 }
Пример #6
0
 /**
  * Draws the control, or the default text area if a setup file is not found
  *
  * @param  string   $tag_path           The XML path to the params (by default 'params')
  * @param  string   $grand_parent_path  [optional] First find as grand-parent that node (if exists)
  * @param  string   $parent_tag         [optional] Then find as parent that node (if exists)
  * @param  string   $parent_attr        [optional] but parent with that attribute having
  * @param  string   $parent_attrvalue   [optional] that value
  * @param  string   $control_name       The control name (by default 'params')
  * @param  boolean  $paramstextarea     If there are no params XML descriptor should params be represented just as a textarea of the raw params (to avoid loosing them) ?
  * @param  string   $viewType           View type ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view )
  * @param  string   $htmlFormatting     HTML formatting type for params ( 'table', 'td', 'none', 'fieldsListArray' )
  * @return string|array                 HTML or values if $htmlFormatting = 'fieldsListArray'
  */
 function draw($tag_path = 'params', $grand_parent_path = null, $parent_tag = null, $parent_attr = null, $parent_attrvalue = null, $control_name = 'params', $paramstextarea = true, $viewType = 'depends', $htmlFormatting = 'table')
 {
     if ($this->_xml) {
         $element = $this->_xml;
         if ($element && $element->getName() == $this->_maintagname && $element->attributes($this->_attrname) == $this->_attrvalue) {
             if ($grand_parent_path != null) {
                 $element = $element->getElementByPath($grand_parent_path);
                 if (!$element) {
                     return null;
                 }
             }
             if ($parent_tag != null && $parent_attr != null && $parent_attrvalue != null) {
                 $element = $element->getChildByNameAttr($parent_tag, $parent_attr, $parent_attrvalue);
                 if ($element) {
                     if ($tag_path) {
                         /** @var SimpleXMLElement $element */
                         $element = $element->getElementByPath($tag_path);
                     }
                     if ($element !== false) {
                         $this->_xmlElem =& $element;
                     }
                 }
             } else {
                 $element = $element->getElementByPath($tag_path);
                 if ($element !== false) {
                     $this->_xmlElem = $element;
                 }
             }
         } elseif (!$tag_path) {
             $this->_xmlElem = $element;
         }
     }
     if ($this->_xmlElem !== null) {
         $controllerView = new DrawController($this->input, $this->_xmlElem, $this->_actions, $this->_options);
         $controllerView->setControl_name($control_name);
         $editRowView = new RegistryEditView($this->input, $this->_db, $this->_pluginParams, $this->_types, $this->_actions, $this->_views, $this->_pluginObject, $this->_tabId);
         $modelOfDataRows = $this->registry->getStorage();
         $editRowView->setModelOfDataRows($modelOfDataRows);
         if ($this->_extendViewParser) {
             $editRowView->setExtendedViewParser($this->_extendViewParser);
         }
         return $editRowView->renderEditRowView($this->_xmlElem, $this->registry, $controllerView, $this->_options, $viewType, $htmlFormatting);
     } else {
         if ($paramstextarea) {
             return "<textarea name=\"{$control_name}\" cols=\"40\" rows=\"10\" class=\"text_area\">" . htmlspecialchars($this->registry->asJson()) . "</textarea>";
         } else {
             return null;
         }
     }
 }
Пример #7
0
 /**
  * Renders as ECHO HTML code of a table
  *
  * @param SimpleXMLElement $modelView
  * @param array $modelRows
  * @param DrawController $controllerView
  * @param array $options
  * @param string $viewType ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view )
  */
 protected function renderList(&$modelView, &$modelRows, &$controllerView, &$options, $viewType = 'view')
 {
     global $_CB_framework;
     static $JS_loaded = 0;
     $pluginParams = $this->_pluginParams;
     $renderer = new RegistryEditView($this->input, $this->_db, $pluginParams, $this->_types, $this->_actions, $this->_views, $this->_pluginObject, $this->_tabid);
     $renderer->setParentView($modelView);
     $renderer->setModelOfDataRows($modelRows);
     $name = $modelView->attributes('name');
     $listFieldsRows = $modelView->getElementByPath('listfields/rows');
     $listFieldsPager = $modelView->getElementByPath('listfields/paging');
     $filtersArray = $controllerView->filters($renderer, 'table');
     $batchArray = $controllerView->batchprocess($renderer, 'table');
     outputCbJs();
     $tableLabel = trim(CBTxt::Th($modelView->attributes('label')));
     $tableMenu = $modelView->getElementByPath('tablemenu');
     if (!$JS_loaded++) {
         if ($controllerView->pageNav !== null) {
             $searchButtonJs = $controllerView->pageNav->limitstartJs(0);
         } else {
             $searchButtonJs = 'cbParentForm( this ).submit();';
         }
         $js = "\$( '.cbTableHeader' ).on( 'click', '.cbTableHeaderExpand', function() {" . "\$( this ).removeClass( 'btn-default cbTableHeaderExpand' ).addClass( 'btn-primary cbTableHeaderCollapse' );" . "\$( this ).find( '.fa' ).removeClass( 'fa-caret-down' ).addClass( 'fa-caret-up' );" . "\$( '.' + \$( this ).data( 'toggle' ) ).slideDown();" . "});" . "\$( '.cbTableHeader' ).on( 'click', '.cbTableHeaderCollapse', function() {" . "var toggle = \$( this ).data( 'toggle' );" . "\$( this ).removeClass( 'btn-primary cbTableHeaderCollapse' ).addClass( 'btn-default cbTableHeaderExpand' );" . "\$( this ).find( '.fa' ).removeClass( 'fa-caret-up' ).addClass( 'fa-caret-down' );" . "\$( '.' + toggle ).slideUp();" . "if ( toggle == 'cbBatchTools' ) {" . "\$( '.' + toggle ).find( 'input,textarea,select' ).val( '' );" . "if ( \$.fn.cbselect ) {" . "\$( '.' + toggle ).find( 'select.cbSelect2' ).each( function() {" . "\$( this ).cbselect( 'set', '' );" . "});" . "}" . "} else {" . "\$( '.' + toggle ).find( 'input,textarea,select' ).each( function() {" . "var value = null;" . "if ( \$( this ).hasClass( 'cbSelect2' ) ) {" . "if ( \$.fn.cbselect ) {" . "value = \$( this ).cbselect( 'get' );" . "} else {" . "value = \$( this ).val();" . "}" . "} else {" . "value = \$( this ).val();" . "}" . "if ( ( value != null ) && ( value != '' ) ) {" . "\$( '.cbTableHeaderClear' ).click(); return;" . "}" . "});" . "}" . "});" . "\$( '.cbTableHeader' ).on( 'click', '.cbTableHeaderClear', function() {" . "\$( '.cbTableHeader' ).find( 'input,textarea,select' ).val( '' );" . "if ( \$.fn.cbselect ) {" . "\$( '.cbTableHeader' ).find( 'select.cbSelect2' ).each( function() {" . "\$( this ).cbselect( 'set', '' );" . "});" . "}" . $searchButtonJs . "});" . "\$( '.cbTableBrowserRowsHeader' ).on( 'click', '.cbTableBrowserSort', function() {" . "\$( '.cbTableHeader' ).find( '.cbTableBrowserSorting > select' ).val( \$( this ).data( 'table-sort' ) ).change();" . "});" . ($this->_filtered ? "\$( '.cbSearchToolsToggle' ).click();" : null);
         $_CB_framework->outputCbJQuery($js);
     }
     $return = '<div class="table-responsive cbTableBrowserDiv' . ($name ? ' cbDIV' . htmlspecialchars($name) : null) . '">';
     if ($tableLabel || $tableMenu || $controllerView->hasSearchFields() || $controllerView->hasOrderbyFields() || count($filtersArray) > 0 || count($batchArray) > 0) {
         $return .= '<table class="table table-noborder cbTableBrowserHeader' . ($name ? ' cbTA' . htmlspecialchars($name) : null) . '">' . '<thead>' . '<tr class="cbTableHeader">';
         if ($tableLabel || $tableMenu) {
             $return .= '<th style="width: 10%;" class="text-left cbTableBrowserLabel' . ($name ? ' cbTH' . htmlspecialchars($name) : null) . '">' . ($tableLabel ? $tableLabel : null);
             if ($tableMenu) {
                 $menuIndex = 1;
                 $return .= $tableLabel ? '<div><small>[ ' : null;
                 foreach ($tableMenu->children() as $menu) {
                     /** @var SimpleXMLElement $menu */
                     $menuAction = $menu->attributes('action');
                     $menuLabelHtml = trim(CBTxt::Th(htmlspecialchars($menu->attributes('label'))));
                     $menuDesc = $menu->attributes('description');
                     if ($menuDesc) {
                         $menuDesc = ' title="' . trim(htmlspecialchars(CBTxt::T($menuDesc))) . '"';
                     }
                     $return .= $menuIndex > 1 ? ' - ' : null;
                     if ($menuAction) {
                         $data = null;
                         $link = $controllerView->drawUrl($menuAction, $menu, $data, 0, true);
                         if ($link) {
                             $return .= '<a href="' . $link . '"' . $menuDesc . '>' . $menuLabelHtml . '</a>';
                         }
                     } elseif ($menuDesc) {
                         $return .= '<span' . $menuDesc . '>' . $menuLabelHtml . '</span>';
                     } else {
                         $return .= $menuLabelHtml;
                     }
                     $menuIndex++;
                 }
                 $return .= $tableLabel ? ' ]</small></div>' : null;
             }
             $return .= '</th>';
         }
         if ($controllerView->hasSearchFields() || $controllerView->hasOrderbyFields() || count($filtersArray) > 0 || count($batchArray) > 0) {
             $return .= '<th class="cbTableHeaderTools">' . '<div class="text-left clearfix cbTableBrowserTools">';
             if ($controllerView->hasSearchFields()) {
                 $return .= $controllerView->quicksearchfields();
             }
             if (count($filtersArray) > 0) {
                 if ($controllerView->hasSearchFields()) {
                     $return .= ' ';
                 }
                 $return .= '<button type="button" class="btn btn-default cbSearchToolsToggle cbTableHeaderExpand" data-toggle="cbSearchTools">' . CBTxt::Th('Search Tools') . ' <span class="fa fa-caret-down"></span></button>';
             }
             if (count($batchArray) > 0) {
                 if (count($filtersArray) > 0 || $controllerView->hasSearchFields()) {
                     $return .= ' ';
                 }
                 $return .= '<button type="button" class="btn btn-default cbBatchToolsToggle cbTableHeaderExpand" data-toggle="cbBatchTools">' . CBTxt::Th('Batch Tools') . ' <span class="fa fa-caret-down"></span></button>';
             }
             $return .= ' <button type="button" class="btn btn-default cbTableHeaderClear">' . CBTxt::Th('Clear') . '</button>';
             if ($controllerView->hasOrderbyFields()) {
                 if (count($filtersArray) > 0 || count($batchArray) > 0 || $controllerView->hasSearchFields()) {
                     $return .= ' ';
                 }
                 $return .= '<span class="text-right pull-right cbTableBrowserSorting">' . $controllerView->orderbyfields() . '</span>';
             }
             $return .= '</div>';
             if (count($filtersArray) > 0) {
                 $return .= '<fieldset class="cbFilters cbSearchTools cbFieldset">' . '<legend>' . CBTxt::Th('Search Tools') . '</legend>' . implode(' ', $filtersArray) . '</fieldset>';
             }
             if (count($batchArray) > 0) {
                 $return .= '<fieldset class="cbBatchProcess cbBatchTools cbFieldset">' . '<legend>' . CBTxt::Th('Batch Tools') . '</legend>' . implode(' ', $batchArray) . '</fieldset>';
             }
             $return .= '</th>';
         }
         $return .= '</tr>' . '</thead>' . '</table>';
     }
     if ($listFieldsRows) {
         $columnCount = 0;
         $return .= '<table class="table table-hover cbTableBrowserRows' . ($name ? ' cbTL' . htmlspecialchars($name) : null) . '">' . '<thead>' . '<tr class="cbTableBrowserRowsHeader">';
         foreach ($listFieldsRows->children() as $field) {
             /** @var SimpleXMLElement $field */
             if ($field->attributes('type') != 'hidden' && Access::authorised($field)) {
                 $classes = RegistryEditView::buildClasses($field);
                 $attributes = ($classes ? ' class="' . htmlspecialchars($classes) . '"' : null) . ($field->attributes('width') || $field->attributes('align') ? ' style="' . ($field->attributes('width') ? 'width: ' . htmlspecialchars($field->attributes('width')) . ';' : null) . ($field->attributes('align') ? 'text-align: ' . htmlspecialchars($field->attributes('align')) . ';' : null) . '"' : null) . ($field->attributes('nowrap') ? ' nowrap="nowrap"' : null);
                 $fieldName = $field->attributes('name');
                 $fieldOrdering = $field->attributes('allowordering');
                 $return .= '<th' . $attributes . '>';
                 if ($field->attributes('type') == 'primarycheckbox') {
                     $jsToggleAll = "cbToggleAll( this, " . count($modelRows) . ", '" . $controllerView->fieldId('id') . "' );";
                     $return .= '<input type="checkbox" id="' . $controllerView->fieldId('toggle') . '" name="' . $controllerView->fieldName('toggle') . '" value="" onclick="' . $jsToggleAll . '" />';
                 } else {
                     $fieldIcon = null;
                     if ($fieldOrdering) {
                         $fieldSort = explode(',', $fieldOrdering);
                         $fieldAsc = in_array('ascending', $fieldSort);
                         $fieldDesc = in_array('descending', $fieldSort);
                         if ($fieldAsc && $this->orderby == $fieldName . '_asc') {
                             // If ascending is allowed and is already active then set click to descending if descending is allowed:
                             if ($fieldDesc) {
                                 $return .= '<a href="javascript: void(0);" class="text-nowrap cbTableBrowserSort cbTableBrowserSortDesc" data-table-sort="' . htmlspecialchars($fieldName . '_desc') . '">';
                             } else {
                                 $return .= '<a href="javascript: void(0);">';
                             }
                             $fieldIcon = ' <span class="fa fa-sort-alpha-asc text-default"></span>';
                         } elseif ($fieldDesc && $this->orderby == $fieldName . '_desc') {
                             // If descending is allowed and is already active then set click to ascending if ascending is allowed:
                             if ($fieldAsc) {
                                 $return .= '<a href="javascript: void(0);" class="text-nowrap cbTableBrowserSort cbTableBrowserSortAsc" data-table-sort="' . htmlspecialchars($fieldName . '_asc') . '">';
                             } else {
                                 $return .= '<a href="javascript: void(0);">';
                             }
                             $fieldIcon = ' <span class="fa fa-sort-alpha-desc text-default"></span>';
                         } elseif ($fieldSort[0] == 'ascending') {
                             // Default to ascending if this field allows it:
                             $return .= '<a href="javascript: void(0);" class="cbTableBrowserSort cbTableBrowserSortAsc" data-table-sort="' . htmlspecialchars($fieldName . '_asc') . '">';
                         } elseif ($fieldSort[0] == 'descending') {
                             // Default to descending if this field allows it:
                             $return .= '<a href="javascript: void(0);" class="cbTableBrowserSort cbTableBrowserSortDesc" data-table-sort="' . htmlspecialchars($fieldName . '_desc') . '">';
                         } else {
                             $return .= '<a href="javascript: void(0);">';
                         }
                     }
                     $return .= $field->attributes('description') ? cbTooltip(2, CBTxt::Th($field->attributes('description')), null, null, null, CBTxt::Th($field->attributes('label')), null, 'data-hascbtooltip="true"') : CBTxt::Th($field->attributes('label'));
                     if ($fieldOrdering) {
                         $return .= $fieldIcon . '</a>';
                     }
                 }
                 if ($field->attributes('type') == 'ordering') {
                     if (!$fieldOrdering || in_array($this->orderby, array($fieldName . '_asc', $fieldName . '_desc', $fieldName))) {
                         if ($fieldOrdering) {
                             $field->addAttribute('noordering', 'false');
                         }
                         if (strpos($field->attributes('onclick'), 'number') !== false) {
                             $jsOrderSave = "cbsaveorder( this, " . count($modelRows) . ", '" . $controllerView->fieldId('id', null, false) . "', '" . $controllerView->taskName(false) . "', '" . $controllerView->subtaskName(false) . "', '" . $controllerView->subtaskValue('saveorder/' . $field->attributes('name'), false) . "' );";
                             $return .= ' <a href="javascript: void(0);" onclick="' . $jsOrderSave . '">' . '<span class="fa fa-save fa-lg text-default" title="' . htmlspecialchars(CBTxt::T('Save Order')) . '"></span>' . '</a>';
                         }
                     } else {
                         if ($fieldOrdering) {
                             $field->addAttribute('noordering', 'true');
                         }
                     }
                 }
                 $return .= '</th>';
                 $columnCount++;
             }
         }
         $return .= '</tr>' . '</thead>' . '</tbody>';
         $total = count($modelRows);
         $controllerView->pageNav->setRowsNumber($total);
         if ($total) {
             for ($i = 0; $i < $total; $i++) {
                 $controllerView->pageNav->setRowIndex($i);
                 $renderer->setModelOfDataRowsNumber($i);
                 $row = $modelRows[$i];
                 $rowlink = $listFieldsRows->attributes('link');
                 if ($rowlink) {
                     $hrefRowEdit = $controllerView->drawUrl($rowlink, $listFieldsRows, $row, $row->id, false);
                     if ($hrefRowEdit) {
                         if ($listFieldsRows->attributes('target') == '_blank') {
                             $onclickJS = 'window.open(\'' . htmlspecialchars(cbUnHtmlspecialchars($hrefRowEdit)) . '\', \'cbinvoice\', \'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no\'); return false;';
                         } else {
                             $onclickJS = "window.location='" . htmlspecialchars(cbUnHtmlspecialchars($hrefRowEdit)) . "'";
                         }
                         $rowOnclickHtml = ' onclick="' . $onclickJS . '"';
                     } else {
                         $rowOnclickHtml = null;
                     }
                 } else {
                     $rowOnclickHtml = null;
                 }
                 $controllerView->setControl_name($this->name . '[rows][' . $i . ']');
                 $return .= '<tr class="cbTableBrowserRow"' . $rowOnclickHtml . '>' . $renderer->renderEditRowView($listFieldsRows, $row, $controllerView, $options, $viewType, 'td') . '</tr>';
             }
         }
         $controllerView->setControl_name($this->name);
         $return .= '</tbody>';
         if ($total && (!$listFieldsPager || $listFieldsPager && $listFieldsPager->attributes('type') != 'none')) {
             if ($listFieldsPager) {
                 $showPageLinks = strpos($listFieldsPager->attributes('type'), 'nopagelinks') === false;
                 $showLimitBox = strpos($listFieldsPager->attributes('type'), 'nolimitbox') === false;
                 $showPagesCount = strpos($listFieldsPager->attributes('type'), 'nopagescount') === false;
             } else {
                 $showPageLinks = true;
                 $showLimitBox = true;
                 $showPagesCount = true;
             }
             if ($controllerView->pageNav->total <= $controllerView->pageNav->limit) {
                 $showPageLinks = false;
             }
             $return .= '<tfoot>' . '<tr class="cbTableBrowserRowsPaging">' . '<th colspan="' . (int) $columnCount . '" class="text-center">' . $controllerView->pageNav->getListFooter($showPageLinks, $showLimitBox, $showPagesCount) . '</th>' . '</tr>' . '</tfoot>' . '</table>';
         } elseif ($controllerView->pageNav !== null) {
             $return .= '</table>' . $controllerView->pageNav->getLimitBox(false);
         } else {
             $return .= '</table>';
         }
     } elseif ($controllerView->pageNav !== null) {
         $return .= $controllerView->pageNav->getLimitBox(false);
     }
     $return .= '<input type="hidden" name="' . $controllerView->fieldName('subtask') . '" value="" />';
     $statistics = $controllerView->getStatistics();
     if ($statistics) {
         foreach ($statistics as $stat) {
             $return .= $renderer->renderEditRowView($stat['view'], $stat['values'], $controllerView, $options, 'view', 'table');
         }
     }
     $return .= '</div>';
     echo $return;
 }
Пример #8
0
 /**
  * Saves the CB plugin view after an edit view form submit
  *
  * @param  array                     $options
  * @param  array                     $actionPath
  * @param  array                     $keyValues
  * @param  array                     $parametersValues
  * @param  SimpleXMLElement          $viewModel
  * @param  TableInterface            $data
  * @param  RegistryEditController    $params
  * @param  string                    $mode
  * @param  string                    $dataModelType
  * @param  PluginTable               $plugin
  * @param  SimpleXMLElement          $dataModel
  * @param  RegistryInterface         $pluginParams
  * @param  string                    $cbprevstate
  * @param  int                       $ui
  * @return null|string                                  NULL: ok, STRING: error
  */
 protected function savePluginView($options, $actionPath, $keyValues, $parametersValues, $viewModel, $data, $params, &$mode, $dataModelType, $plugin, $dataModel, $pluginParams, $cbprevstate, $ui)
 {
     global $_CB_framework;
     new cbTabs(false, 2, -1, false);
     // prevents output of CB tabs js code until we are done with drawing (or redirecting)
     $resultingMsg = null;
     cbSpoofCheck('plugin');
     $postArray = $this->input->getNamespaceRegistry('post')->asArray();
     // List of variables to exclude from the $postArray:
     $exclude = array('option', 'cid', 'cbprevstate', cbSpoofField());
     foreach ($actionPath as $k => $v) {
         $exclude[] = $k;
     }
     // Remove the exclude variables from the $postArray before being used in the below cases:
     foreach ($exclude as $v) {
         if (isset($postArray[$v])) {
             unset($postArray[$v]);
         }
     }
     // Fix multi-selects and multi-checkboxes arrays to |*|-delimited strings:
     $postArray = $this->recursiveMultiSelectFix($postArray);
     foreach ($postArray as $key => $value) {
         if (property_exists($data, $key)) {
             $postArray[$key] = is_array($value) ? json_encode($value) : $value;
         }
     }
     $errorMsg = null;
     switch ($dataModelType) {
         case 'sql:row':
             if ($ui == 2) {
                 if (true !== ($error = RegistryEditView::validateAndBindPost($params, $postArray))) {
                     $errorMsg = $error;
                     break;
                 }
                 if (!$data->bind($postArray)) {
                     $errorMsg = $data->getError();
                     break;
                 }
             } else {
                 RegistryEditView::setFieldsListArrayValues(true);
                 $fields = $params->draw(null, null, null, null, null, null, false, 'param', 'fieldsListArray');
                 // New CB2.0 way for bind():
                 foreach ($fields as $key => $value) {
                     if (property_exists($data, $key)) {
                         $data->{$key} = is_array($value) ? json_encode($value) : $value;
                     }
                 }
             }
             if (!$data->check()) {
                 $errorMsg = $data->getError();
                 break;
             }
             $dataModelKey = $data->getKeyName();
             $dataModelValueOld = $data->{$dataModelKey};
             if ($mode == 'savecopy') {
                 if (!$data->canCopy($data)) {
                     $errorMsg = $data->getError();
                     break;
                 }
                 if (!$data->copy($data)) {
                     $errorMsg = $data->getError();
                     break;
                 }
             } else {
                 if (!$data->store()) {
                     $errorMsg = $data->getError();
                     break;
                 }
             }
             $dataModelValue = $data->{$dataModelKey};
             // Id changed; be sure to update the url encase of redirect:
             if (count($keyValues) == 1) {
                 $urlKeys = array_keys($keyValues);
                 $urlDataKey = $urlKeys[0];
                 if ($mode == 'savenew') {
                     unset($actionPath[$urlDataKey]);
                 } elseif ($dataModelValue != $dataModelValueOld) {
                     $actionPath[$urlDataKey] = $dataModelValue;
                 }
             }
             if ($data->hasFeature('checkout')) {
                 /** @var \CBLib\Database\Table\CheckedOrderedTable $data */
                 $data->checkin();
             }
             $this->savePluginViewOrder($data, $viewModel);
             $resultingMsg = $data->cbResultOfStore();
             break;
         case 'sql:field':
             // <data name="params" type="sql:field" table="#__cbsubs_config" class="cbpaidConfig" key="id" value="1" valuetype="sql:int" />
             $dataModelName = $dataModel->attributes('name');
             $dataModelKey = $dataModel->attributes('key');
             $dataModelValue = $dataModel->attributes('value');
             if ($ui == 2) {
                 if (true !== ($error = RegistryEditView::validateAndBindPost($params, $postArray))) {
                     $errorMsg = $error;
                     break;
                 }
             }
             $rawParams = array();
             $rawParams[$dataModelName] = json_encode($postArray);
             $xmlsql = new XmlQuery($this->db, null, $pluginParams);
             $xmlsql->process_data($dataModel);
             if ($dataModelValue) {
                 $result = $xmlsql->queryUpdate($rawParams);
             } else {
                 $result = $xmlsql->queryInsert($rawParams, $dataModelKey);
             }
             if (!$result) {
                 $errorMsg = $xmlsql->getErrorMsg();
             }
             break;
         case 'parameters':
             if ($ui == 2) {
                 if (true !== ($error = RegistryEditView::validateAndBindPost($params, $postArray))) {
                     $errorMsg = $error;
                     break;
                 }
             }
             $rawParams = array();
             $rawParams['params'] = json_encode($postArray);
             // $plugin = new PluginTable( $this->_db );
             // $plugin->load( $pluginId );
             if (!$plugin->bind($rawParams)) {
                 $errorMsg = $plugin->getError();
                 break;
             }
             if (!$plugin->check()) {
                 $errorMsg = $plugin->getError();
                 break;
             }
             if (!$plugin->store()) {
                 $errorMsg = $plugin->getError();
                 break;
             }
             $plugin->checkin();
             $plugin->updateOrder("type='" . $plugin->getDbo()->getEscaped($plugin->type) . "' AND ordering > -10000 AND ordering < 10000 ");
             $resultingMsg = $plugin->cbResultOfStore();
             break;
         case 'class':
             if ($ui == 2) {
                 if (true !== ($error = RegistryEditView::validateAndBindPost($params, $postArray))) {
                     $errorMsg = $error;
                     break;
                 }
             }
             if (!$data->bind($postArray)) {
                 $errorMsg = $data->getError();
                 break;
             }
             if (!$data->check()) {
                 $errorMsg = $data->getError();
                 break;
             }
             if (!$data->store()) {
                 $errorMsg = $data->getError();
                 break;
             }
             if ($data->hasFeature('checkout')) {
                 /** @var \CBLib\Database\Table\CheckedOrderedTable $data */
                 $data->checkin();
             }
             $this->savePluginViewOrder($data, $viewModel);
             $resultingMsg = $data->cbResultOfStore();
             break;
         case 'sql:multiplerows':
         default:
             echo 'Save error: showview data type: ' . $dataModelType . ' not implemented !';
             exit;
             break;
     }
     if ($ui == 2) {
         $url = 'index.php?option=' . $options['option'] . '&view=' . $options['view'];
         if ($options['view'] == 'editPlugin') {
             $url .= '&cid=' . $options['pluginid'];
         }
         $url = $_CB_framework->backendUrl($url);
     } else {
         $url = 'index.php';
         if (count($options) > 0) {
             $fixOptions = array();
             foreach ($options as $k => $v) {
                 $fixOptions[$k] = $k . '=' . urlencode($v);
             }
             $url .= '?' . implode('&', $fixOptions);
         }
     }
     if (isset($data->title)) {
         $dataItem = CBTxt::T($data->title);
     } elseif (isset($data->name)) {
         $dataItem = CBTxt::T($data->name);
     } else {
         $dataItem = null;
     }
     if ($errorMsg) {
         if (in_array($mode, array('save', 'savenew', 'savecopy'))) {
             $mode = 'apply';
         }
         $msg = CBTxt::T('FAILED_TO_SAVE_LABEL_ITEM_BECAUSE_ERROR', 'Failed to save [label] [item] because: [error]', array('[label]' => $viewModel->attributes('label'), '[item]' => $dataItem, '[error]' => $errorMsg));
         $msgType = 'error';
     } else {
         $msg = CBTxt::T('SUCCESSFULLY_SAVED_LABEL_ITEM', 'Successfully saved [label] [item]', array('[label]' => $viewModel->attributes('label'), '[item]' => $dataItem));
         $msgType = 'message';
     }
     switch ($mode) {
         case 'apply':
         case 'savenew':
         case 'savecopy':
             unset($actionPath['view']);
             foreach ($actionPath as $k => $v) {
                 if ($v !== '') {
                     $url .= '&' . $k . '=' . $v;
                 }
             }
             foreach ($parametersValues as $k => $v) {
                 $url .= '&' . $k . '=' . $v;
             }
             if ($cbprevstate) {
                 $url .= '&cbprevstate=' . $cbprevstate;
             }
             break;
         case 'save':
             if ($cbprevstate) {
                 $prevUrl = base64_decode($cbprevstate);
                 // $parametersValues[]		=	"'" . base64_encode( implode( '&', $cbprevstate ) ) . "'";
                 if (!preg_match('$[:/]$', $prevUrl)) {
                     $prevUrl = str_replace('&pluginid=', '&cid=', $prevUrl);
                     if ($ui == 2) {
                         $url = $_CB_framework->backendUrl('index.php?' . $prevUrl);
                     } else {
                         $url = 'index.php?' . $prevUrl;
                     }
                 }
             }
             break;
     }
     if ($resultingMsg) {
         if ($ui != 2) {
             return $resultingMsg;
             // in frontend, for now, don't redirect here: think this is right !
         } else {
             // If not an apply then change it to an apply so we can redisplay the view with the resulting message above it:
             if (in_array($mode, array('save', 'savenew', 'savecopy'))) {
                 $mode = 'apply';
             }
             echo $resultingMsg;
         }
     } else {
         if ($ui != 2) {
             return null;
             // in frontend, for now, don't redirect here: think this is right !
             // $url	=	cbUnHtmlspecialchars( cbSef( $url ) );
         }
         if ($mode == 'apply' && $errorMsg) {
             $_CB_framework->enqueueMessage($msg, $msgType);
         } else {
             cbRedirect($ui == 2 ? $url : cbSef(htmlspecialchars($url), false), $msg, $msgType);
         }
     }
     return null;
 }
Пример #9
0
 /**
  * Renders the header of the menu group
  *
  * @param  SimpleXMLElement  $param
  * @param  string              $htmlFormatting
  * @return string
  */
 protected function renderMenuGroupHeader(&$param, $htmlFormatting)
 {
     $html = array();
     $legend = $param->attributes('label');
     $description = $param->attributes('description');
     $cssclass = RegistryEditView::buildClasses($param);
     if ($htmlFormatting == 'table') {
         $html[] = '<tr><td colspan="3" style="width: 100%;"' . ($cssclass ? ' class="' . htmlspecialchars($cssclass) . '"' : '') . '>';
     } elseif ($htmlFormatting == 'td') {
         $html[] = '<td' . ($cssclass ? ' class="' . htmlspecialchars($cssclass) . '"' : '') . '>';
     }
     if ($legend) {
         $html[] = '<h2>' . CBTxt::Th($legend) . '</h2>';
     }
     if ($htmlFormatting == 'table') {
         $html[] = '<table class="table table-noborder">';
         if ($description) {
             $html[] = '<tr><td colspan="3" style="width: 100%;"><strong>' . CBTxt::Th($description) . '</strong></td></tr>';
         }
     } elseif ($htmlFormatting == 'td') {
         if ($description) {
             $html[] = '<td colspan="3" style="width: 100%;"><strong>' . CBTxt::Th($description) . '</strong></td>';
         }
     } else {
         if ($description) {
             $html[] = '<strong>' . CBTxt::Th($description) . '</strong>';
         }
     }
     if (!in_array($htmlFormatting, array('table', 'td'))) {
         $html[] = '<div class="cbButtonMenu' . ($cssclass ? ' ' . htmlspecialchars($cssclass) : '') . '">';
     }
     return implode('', $html);
 }
Пример #10
0
 /**
  * Renders all parameters (including inheritance magic)
  *
  * @param  SimpleXMLElement  $xmlParentElement  The parent XML node for which to render all child node parameters
  * @param  string            $control_name      The control name
  * @param  cbTabs            $tabs              The CB tab (if applicable)
  * @param  string            $viewType          The view type ( 'view', 'param', 'depends': means: <param> tag => param, <field> tag => view )
  * @param  string            $htmlFormatting    The html formatting type ( 'table', 'td', 'div', 'span', 'none', 'fieldsListArray' )
  * @return string|array                         HTML or values depending on $htmlFormatting
  */
 public function renderAllParams(&$xmlParentElement, $control_name = 'params', $tabs = null, $viewType = 'depends', $htmlFormatting = 'table')
 {
     return $this->registryEditView->renderAllParams($xmlParentElement, $control_name, $tabs, $viewType, $htmlFormatting);
 }