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


PHP CostbenefitprojectionHelper::checkArray方法代码示例

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


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

示例1: display

 /**
  * display task
  *
  * @return void
  */
 function display($cachable = false, $urlparams = false)
 {
     // set default view if not set
     $view = $this->input->getCmd('view', 'Costbenefitprojection');
     $data = $this->getViewRelation($view);
     $layout = $this->input->get('layout', null, 'WORD');
     $id = $this->input->getInt('id');
     // Check for edit form.
     if (CostbenefitprojectionHelper::checkArray($data)) {
         if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_costbenefitprojection.edit.' . $data['view'], $id)) {
             // Somehow the person just went to the form - we don't allow that.
             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
             $this->setMessage($this->getError(), 'error');
             // check if item was opend from other then its own list view
             $ref = $this->input->getCmd('ref', 0);
             $refid = $this->input->getInt('refid', 0);
             // set redirect
             if ($refid > 0 && CostbenefitprojectionHelper::checkString($ref)) {
                 // redirect to item of ref
                 $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=' . (string) $ref . '&layout=edit&id=' . (int) $refid, false));
             } elseif (CostbenefitprojectionHelper::checkString($ref)) {
                 // redirect to ref
                 $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=' . (string) $ref, false));
             } else {
                 // normal redirect back to the list view
                 $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=' . $data['views'], false));
             }
             return false;
         }
     }
     return parent::display($cachable, $urlparams);
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:37,代码来源:controller.php

示例2: exportData

 public function exportData()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // check if export is allowed for this user.
     $user = JFactory::getUser();
     if ($user->authorise('help_document.export', 'com_costbenefitprojection') && $user->authorise('core.export', 'com_costbenefitprojection')) {
         // Get the input
         $input = JFactory::getApplication()->input;
         $pks = $input->post->get('cid', array(), 'array');
         // Sanitize the input
         JArrayHelper::toInteger($pks);
         // Get the model
         $model = $this->getModel('Help_documents');
         // get the data to export
         $data = $model->getExportData($pks);
         if (CostbenefitprojectionHelper::checkArray($data)) {
             // now set the data to the spreadsheet
             $date = JFactory::getDate();
             CostbenefitprojectionHelper::xls($data, 'Help_documents_' . $date->format('jS_F_Y'), 'Help documents exported (' . $date->format('jS F, Y') . ')', 'help documents');
         }
     }
     // Redirect to the list screen with error.
     $message = JText::_('COM_COSTBENEFITPROJECTION_EXPORT_FAILED');
     $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error');
     return;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:27,代码来源:help_documents.php

示例3: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  */
 public function getOptions()
 {
     // Get the user object.
     $user = JFactory::getUser();
     // Create a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($db->quoteName(array('a.id', 'a.name'), array('id', 'testcompanies_name')));
     $query->from($db->quoteName('#__costbenefitprojection_company', 'a'));
     $query->where($db->quoteName('a.published') . ' = 1');
     if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
         $companies = CostbenefitprojectionHelper::hisCompanies($user->id);
         if (CostbenefitprojectionHelper::checkArray($companies)) {
             $companies = implode(',', $companies);
             // only load this users companies
             $query->where('a.id IN (' . $companies . ')');
         } else {
             // dont allow user to see any companies
             $query->where('a.id = -4');
         }
     }
     $query->order('a.name ASC');
     $db->setQuery((string) $query);
     $items = $db->loadObjectList();
     $options = array();
     if ($items) {
         foreach ($items as $item) {
             $tmp = array('value' => $item->id, 'text' => '&nbsp;<strong>' . $item->testcompanies_name . '</strong>', 'checked' => false);
             $options[] = (object) $tmp;
         }
     }
     return $options;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:38,代码来源:companycheck.php

示例4: allowEdit

 /**
  * Method override to check if you can edit an existing record.
  *
  * @param   array   $data  An array of input data.
  * @param   string  $key   The name of the key for the primary key.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     // get user object.
     $user = JFactory::getUser();
     // get record id.
     $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
     // get company id
     $company = CostbenefitprojectionHelper::getId('intervention', $recordId, 'id', 'company');
     if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
         // make absolutely sure that this intervention can be edited
         $companies = CostbenefitprojectionHelper::hisCompanies($user->id);
         if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company, $companies)) {
             return false;
         }
     }
     // now check the access by sharing
     if (!CostbenefitprojectionHelper::checkIntervetionAccess($recordId, null, $company)) {
         return false;
     }
     // Access check.
     $access = $user->authorise('intervention.access', 'com_costbenefitprojection.intervention.' . (int) $recordId) && $user->authorise('intervention.access', 'com_costbenefitprojection');
     if (!$access) {
         return false;
     }
     if ($recordId) {
         // The record has been set. Check the record permissions.
         $permission = $user->authorise('intervention.edit', 'com_costbenefitprojection.intervention.' . (int) $recordId);
         if (!$permission && !is_null($permission)) {
             if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection.intervention.' . $recordId)) {
                 // Now test the owner is the user.
                 $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
                 if (empty($ownerId)) {
                     // Need to do a lookup from the model.
                     $record = $this->getModel()->getItem($recordId);
                     if (empty($record)) {
                         return false;
                     }
                     $ownerId = $record->created_by;
                 }
                 // If the owner matches 'me' then allow.
                 if ($ownerId == $user->id) {
                     if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection')) {
                         return true;
                     }
                 }
             }
             return false;
         }
     }
     // Since there is no permission, revert to the component permissions.
     return $user->authorise('intervention.edit', $this->option);
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:62,代码来源:intervention.php

示例5: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  */
 public function getOptions()
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($db->quoteName(array('a.id', 'a.name', 'a.ref'), array('id', 'causesrisks_name', 'ref')));
     $query->from($db->quoteName('#__costbenefitprojection_causerisk', 'a'));
     $query->where($db->quoteName('a.published') . ' = 1');
     $query->order('a.ref ASC');
     $db->setQuery((string) $query);
     $items = $db->loadObjectList();
     $options = array();
     $counter = 0;
     if ($items) {
         foreach ($items as $item) {
             $ref = explode('.', $item->ref);
             $target_id = implode('-', $ref);
             $key = explode('.0', $item->ref);
             $key = implode('.', $key);
             $spacer = array();
             $sub = '';
             $sub_ = '';
             foreach ($ref as $nr => $space) {
                 if ($nr > 1) {
                     $spacer[] = '<span class=\'gi\'>|&mdash;</span>';
                 }
                 if ($nr > 2) {
                     $sub = '<em>';
                     $sub_ = '</em>';
                 }
             }
             if (CostbenefitprojectionHelper::checkArray($spacer)) {
                 $tmp = array('value' => $item->id, 'text' => '<span id=' . $target_id . ' style=\'color:' . $color . ';\'>&nbsp;&nbsp;' . implode('', $spacer) . '&nbsp;' . $sub . $item->causesrisks_name . $sub_ . '&nbsp;<small>(' . $key . ')</small></span>', 'checked' => false);
                 $options[] = (object) $tmp;
             } else {
                 if ($counter & 1) {
                     $color = '#0C5B00';
                 } else {
                     $color = '#1A3867';
                 }
                 $tmp = array('value' => $item->id, 'text' => '<span id=' . $target_id . ' style=\'color:' . $color . ';\'>&nbsp;&nbsp;<strong>' . strtoupper($item->causesrisks_name) . '</strong>&nbsp;<small>(' . $key . ')</small></span>', 'checked' => false);
                 $options[] = (object) $tmp;
                 $counter++;
             }
         }
     }
     return $options;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:52,代码来源:causesriskscheck.php

示例6:

		<div id="j-sidebar-container" class="span2">
			<?php 
    echo $this->sidebar;
    ?>
		</div>
		<div id="j-main-container" class="span10">
	<?php 
} else {
    ?>
		<div id="j-main-container">
	<?php 
}
?>

	<?php 
if ($this->hasPackage && CostbenefitprojectionHelper::checkArray($this->headerList) && CostbenefitprojectionHelper::checkArray($this->headers)) {
    ?>
		<fieldset class="uploadform">
			<legend><?php 
    echo JText::_('COM_COSTBENEFITPROJECTION_IMPORT_LINK_FILE_TO_TABLE_COLUMNS');
    ?>
</legend>
			<div class="control-group">
				<label class="control-label" ><h4><?php 
    echo JText::_('COM_COSTBENEFITPROJECTION_IMPORT_TABLE_COLUMNS');
    ?>
</h4></label>
				<div class="controls">
					<label class="control-label" ><h4><?php 
    echo JText::_('COM_COSTBENEFITPROJECTION_IMPORT_FILE_COLUMNS');
    ?>
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:31,代码来源:default.php

示例7: postSaveHook

 /**
  * Function that allows child controller access to model data
  * after the data has been saved.
  *
  * @param   JModel  &$model     The data model object.
  * @param   array   $validData  The validated data.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function postSaveHook(JModelLegacy $model, $validData = array())
 {
     if ($validData['id'] >= 0) {
         // get user object
         $user = JFactory::getUser();
         // if id is 0 get id
         if (0 >= (int) $validData['id']) {
             // Get the created by id
             $created_by = isset($validData['created_by']) && $validData['created_by'] > 0 ? $validData['created_by'] : $user->id;
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Select id of this company
             $query->select($db->quoteName(array('id')));
             $query->from($db->quoteName('#__costbenefitprojection_company'));
             $query->where($db->quoteName('name') . ' = ' . $db->quote($validData['name']));
             $query->where($db->quoteName('email') . ' = ' . $db->quote($validData['email']));
             $query->where($db->quoteName('country') . ' = ' . (int) $validData['country']);
             $query->where($db->quoteName('service_provider') . ' = ' . (int) $validData['service_provider']);
             $query->where($db->quoteName('created_by') . ' = ' . (int) $created_by);
             if (isset($validData['created'])) {
                 $query->where($db->quoteName('created') . ' = ' . $db->quote($validData['created']));
             }
             $db->setQuery($query);
             $db->execute();
             if ($db->getNumRows()) {
                 $validData['id'] = $db->loadResult();
             } else {
                 return;
             }
         }
         // user setup if not set
         if (0 >= (int) $validData['user'] && (int) $validData['id'] > 0) {
             $userIs = CostbenefitprojectionHelper::userIs($user->id);
             if (1 == $userIs) {
                 // this is a company so just use its id
                 $userId = $user->id;
                 // add this user id to this company
                 $validData['user'] = $userId;
                 $model->save($validData);
             } else {
                 // setup config array
                 $newUser = array('name' => $validData['name'], 'email' => $validData['email']);
                 $userId = CostbenefitprojectionHelper::createUser($newUser);
                 if (!is_int($userId)) {
                     $this->setMessage($userId, 'error');
                 } else {
                     // add this user id to this company
                     $validData['user'] = $userId;
                     $model->save($validData);
                 }
             }
         }
         // only continue if we have a company id
         if ((int) $validData['id'] > 0) {
             // get params
             $params = JComponentHelper::getParams('com_costbenefitprojection');
             // get all this users companies
             $hisCompanies = CostbenefitprojectionHelper::hisCompanies($validData['user']);
             if (CostbenefitprojectionHelper::checkArray($hisCompanies)) {
                 // set the user group based on the overall status of its companies
                 $departments = CostbenefitprojectionHelper::getVars('company', $hisCompanies, 'id', 'department');
                 if (in_array(2, $departments)) {
                     $memberGroups = $params->get('advancedmembergroup');
                 } else {
                     $memberGroups = $params->get('memberbasicgroup');
                 }
             } else {
                 // first company so act simply on this company department status
                 if (2 == $validData['department']) {
                     $memberGroups = $params->get('advancedmembergroup');
                 } else {
                     $memberGroups = $params->get('memberbasicgroup');
                 }
             }
             // update the user groups
             JUserHelper::setUserGroups((int) $validData['user'], (array) $memberGroups);
             // Get a db connection.
             $db = JFactory::getDbo();
             // Create a new query object.
             $query = $db->getQuery(true);
             // Select all records in scaling factors the belong to this company
             $query->select($db->quoteName(array('id', 'causerisk', 'published')));
             $query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
             $query->where($db->quoteName('company') . ' = ' . (int) $validData['id']);
             $db->setQuery($query);
             $db->execute();
             if ($db->getNumRows()) {
//.........这里部分代码省略.........
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:101,代码来源:company.php

示例8: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  */
 public function getOptions()
 {
     // Get the user object.
     $user = JFactory::getUser();
     // Create a new query object.
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($db->quoteName(array('a.id', 'a.user'), array('id', 'service_provider_user')));
     $query->from($db->quoteName('#__costbenefitprojection_service_provider', 'a'));
     $query->where($db->quoteName('a.published') . ' = 1');
     if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
         $serviceProviders = CostbenefitprojectionHelper::hisServiceProviders($user->id);
         if (CostbenefitprojectionHelper::checkArray($serviceProviders)) {
             $serviceProviders = implode(',', $serviceProviders);
             // only load this users service providers
             $query->where('a.id IN (' . $serviceProviders . ')');
         } else {
             // don't allow user to see any service providers
             $query->where('a.id = -4');
         }
     }
     $query->order('a.user ASC');
     $db->setQuery((string) $query);
     $items = $db->loadObjectList();
     $options = array();
     if ($items) {
         foreach ($items as $item) {
             $options[] = JHtml::_('select.option', $item->id, JFactory::getUser($item->service_provider_user)->name);
         }
     }
     return $options;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:37,代码来源:serviceprovider.php

示例9: save

 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     $filter = JFilterInput::getInstance();
     // set the metadata to the Item Data
     if (isset($data['metadata']) && isset($data['metadata']['author'])) {
         $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
         $metadata = new JRegistry();
         $metadata->loadArray($data['metadata']);
         $data['metadata'] = (string) $metadata;
     }
     // Set the empty testcompanies item to data
     if (!isset($data['testcompanies'])) {
         $data['testcompanies'] = '';
     }
     // Set the testcompanies string to JSON string.
     if (isset($data['testcompanies'])) {
         $data['testcompanies'] = (string) json_encode($data['testcompanies']);
     }
     // Set the Params Items to data
     if (isset($data['params']) && is_array($data['params'])) {
         $params = new JRegistry();
         $params->loadArray($data['params']);
         $data['params'] = (string) $params;
     }
     // Alter the uniqe field for save as copy
     if ($input->get('task') == 'save2copy') {
         // Automatic handling of other uniqe fields
         $uniqeFields = $this->getUniqeFields();
         if (CostbenefitprojectionHelper::checkArray($uniqeFields)) {
             foreach ($uniqeFields as $uniqeField) {
                 $data[$uniqeField] = $this->generateUniqe($uniqeField, $data[$uniqeField]);
             }
         }
     }
     if (parent::save($data)) {
         return true;
     }
     return false;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:49,代码来源:service_provider.php

示例10: setDocument

 /**
  * Prepares the document
  */
 protected function setDocument()
 {
     // always make sure jquery is loaded.
     JHtml::_('jquery.framework');
     // Load the header checker class.
     require_once JPATH_COMPONENT_SITE . '/helpers/headercheck.php';
     // Initialize the header checker.
     $HeaderCheck = new HeaderCheck();
     // Load uikit options.
     $uikit = $this->params->get('uikit_load');
     // Set script size.
     $size = $this->params->get('uikit_min');
     // Set css style.
     $style = $this->params->get('uikit_style');
     // The uikit css.
     if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) {
         $this->document->addStyleSheet(JURI::root(true) . '/media/com_costbenefitprojection/uikit/css/uikit' . $style . $size . '.css');
     }
     // The uikit js.
     if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) {
         $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/uikit/js/uikit' . $size . '.js');
     }
     // Load the needed uikit components in this view.
     $uikitComp = $this->get('UikitComp');
     if ($uikit != 2 && isset($uikitComp) && CostbenefitprojectionHelper::checkArray($uikitComp)) {
         // load just in case.
         jimport('joomla.filesystem.file');
         // loading...
         foreach ($uikitComp as $class) {
             foreach (CostbenefitprojectionHelper::$uk_components[$class] as $name) {
                 // check if the CSS file exists.
                 if (JFile::exists(JPATH_ROOT . '/media/com_costbenefitprojection/uikit/css/components/' . $name . $style . $size . '.css')) {
                     // load the css.
                     $this->document->addStyleSheet(JURI::root(true) . '/media/com_costbenefitprojection/uikit/css/components/' . $name . $style . $size . '.css');
                 }
                 // check if the JavaScript file exists.
                 if (JFile::exists(JPATH_ROOT . '/media/com_costbenefitprojection/uikit/js/components/' . $name . $size . '.js')) {
                     // load the js.
                     $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/uikit/js/components/' . $name . $size . '.js');
                 }
             }
         }
     }
     // add the google chart builder class.
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/chartbuilder.php';
     // load the google chart js.
     $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/js/google.jsapi.js');
     $this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js');
     $this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js');
     // Add the CSS for Footable.
     $this->document->addStyleSheet(JURI::root() . 'media/com_costbenefitprojection/footable/css/footable.core.min.css');
     // Use the Metro Style
     if (!isset($this->fooTableStyle) || 0 == $this->fooTableStyle) {
         $this->document->addStyleSheet(JURI::root() . 'media/com_costbenefitprojection/footable/css/footable.metro.min.css');
     } elseif (isset($this->fooTableStyle) && 1 == $this->fooTableStyle) {
         $this->document->addStyleSheet(JURI::root() . 'media/com_costbenefitprojection/footable/css/footable.standalone.min.css');
     }
     // Add the JavaScript for Footable
     $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.js');
     $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.sort.js');
     $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.filter.js');
     $this->document->addScript(JURI::root() . 'media/com_costbenefitprojection/footable/js/footable.paginate.js');
     // set header
     JToolbarHelper::title(JText::_('COM_COSTBENEFITPROJECTION_COMBINED_RESULTS_OF') . ' (' . $this->names . ')', 'cogs');
     // add custom css
     $this->document->addStyleSheet(JURI::root(true) . "/administrator/components/com_costbenefitprojection/assets/css/dashboard.css");
     // add custom js
     $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/js/chartMenu.js');
     $this->document->addScript(JURI::root(true) . '/media/com_costbenefitprojection/js/table2excel.js');
     // set chart stuff
     $this->Chart['backgroundColor'] = $this->params->get('admin_chartbackground');
     $this->Chart['width'] = $this->params->get('admin_mainwidth');
     $this->Chart['chartArea'] = array('top' => $this->params->get('admin_chartareatop'), 'left' => $this->params->get('admin_chartarealeft'), 'width' => $this->params->get('admin_chartareawidth') . '%');
     $this->Chart['legend'] = array('textStyle' => array('fontSize' => $this->params->get('admin_legendtextstylefontsize'), 'color' => $this->params->get('admin_legendtextstylefontcolor')));
     $this->Chart['vAxis'] = array('textStyle' => array('color' => $this->params->get('admin_vaxistextstylefontcolor')));
     $this->Chart['hAxis']['textStyle'] = array('color' => $this->params->get('admin_haxistextstylefontcolor'));
     $this->Chart['hAxis']['titleTextStyle'] = array('color' => $this->params->get('admin_haxistitletextstylefontcolor'));
     // notice session controller
     $session = JFactory::getSession();
     $this->menuNotice = $session->get('CT_SubMenuNotice', 'empty');
     if ($this->menuNotice == 'empty') {
         $session->set('CT_SubMenuNotice', '1');
     } elseif ($this->menuNotice < 6) {
         $this->menuNotice++;
         $session->set('CT_SubMenuNotice', $this->menuNotice);
     }
     // add the document default css file
     $this->document->addStyleSheet(JURI::root(true) . '/administrator/components/com_costbenefitprojection/assets/css/combinedresults.css');
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:92,代码来源:view.html.php

示例11: save

 /**
  * Method to save the form data.
  *
  * @param   array  $data  The form data.
  *
  * @return  boolean  True on success.
  *
  * @since   1.6
  */
 public function save($data)
 {
     $input = JFactory::getApplication()->input;
     $filter = JFilterInput::getInstance();
     // set the metadata to the Item Data
     if (isset($data['metadata']) && isset($data['metadata']['author'])) {
         $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
         $metadata = new JRegistry();
         $metadata->loadArray($data['metadata']);
         $data['metadata'] = (string) $metadata;
     }
     // Set the empty causesrisks item to data
     if (!isset($data['causesrisks'])) {
         $data['causesrisks'] = '';
     }
     // Set the causesrisks string to JSON string.
     if (isset($data['causesrisks'])) {
         $data['causesrisks'] = (string) json_encode($data['causesrisks']);
     }
     // Set the Params Items to data
     if (isset($data['params']) && is_array($data['params'])) {
         $params = new JRegistry();
         $params->loadArray($data['params']);
         $data['params'] = (string) $params;
     }
     // Alter the name for save as copy
     if ($input->get('task') == 'save2copy') {
         $origTable = clone $this->getTable();
         $origTable->load($input->getInt('id'));
         if ($data['name'] == $origTable->name) {
             list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']);
             $data['name'] = $name;
             $data['alias'] = $alias;
         } else {
             if ($data['alias'] == $origTable->alias) {
                 $data['alias'] = '';
             }
         }
         $data['published'] = 0;
     }
     // Automatic handling of alias for empty fields
     if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0) {
         if ($data['alias'] == null) {
             if (JFactory::getConfig()->get('unicodeslugs') == 1) {
                 $data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['name']);
             } else {
                 $data['alias'] = JFilterOutput::stringURLSafe($data['name']);
             }
             $table = JTable::getInstance('country', 'costbenefitprojectionTable');
             if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) {
                 $msg = JText::_('COM_COSTBENEFITPROJECTION_COUNTRY_SAVE_WARNING');
             }
             list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']);
             $data['alias'] = $alias;
             if (isset($msg)) {
                 JFactory::getApplication()->enqueueMessage($msg, 'warning');
             }
         }
     }
     // Alter the uniqe field for save as copy
     if ($input->get('task') == 'save2copy') {
         // Automatic handling of other uniqe fields
         $uniqeFields = $this->getUniqeFields();
         if (CostbenefitprojectionHelper::checkArray($uniqeFields)) {
             foreach ($uniqeFields as $uniqeField) {
                 $data[$uniqeField] = $this->generateUniqe($uniqeField, $data[$uniqeField]);
             }
         }
     }
     if (parent::save($data)) {
         return true;
     }
     return false;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:83,代码来源:country.php

示例12: getDummyComp

 protected function getDummyComp()
 {
     // insure we only get this once
     if (!CostbenefitprojectionHelper::checkArray($this->dummyComp)) {
         // Create a new query object.
         $query = $this->db->getQuery(true);
         // Get from #__costbenefitprojection_service_provider as a
         $query->select($this->db->quoteName(array('a.testcompanies'), array('testcompanies')));
         $query->from($this->db->quoteName('#__costbenefitprojection_service_provider', 'a'));
         // load the query
         $this->db->setQuery($query);
         $this->db->execute();
         if ($this->db->getNumRows()) {
             // get the test companies
             $testcompanies = $this->db->loadColumn();
             // global Ids
             $global = array();
             // okay now we loop the test companies to build a global id set
             foreach ($testcompanies as $json) {
                 if (CostbenefitprojectionHelper::checkJson($json)) {
                     $global = array_merge($global, json_decode($json, true));
                 }
             }
             // now insure the ids are unique
             $this->dummyComp = array_unique($global);
         }
     }
     return $this->dummyComp;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:29,代码来源:costbenefitprojection.php

示例13: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  */
 public function getOptions()
 {
     $jinput = JFactory::getApplication()->input;
     $client = $jinput->get('id', 0, 'INT');
     $countries = CostbenefitprojectionHelper::hisCountries(null, $client, 'company');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($db->quoteName(array('a.year', 'a.country'), array('year', 'country')));
     $query->from($db->quoteName('#__costbenefitprojection_health_data', 'a'));
     $query->where($db->quoteName('a.published') . ' = 1');
     if (CostbenefitprojectionHelper::checkArray($countries)) {
         $query->where($db->quoteName('a.country') . ' IN (' . implode(',', $countries) . ')');
     }
     $query->order('a.country ASC');
     $db->setQuery((string) $query);
     $items = $db->loadObjectList();
     $options = array();
     if ($items) {
         $years = array();
         foreach ($items as $item) {
             if (!CostbenefitprojectionHelper::checkArray($years) || !in_array($item->year . '_' . $item->country, $years)) {
                 if (!CostbenefitprojectionHelper::checkArray($countries) || $client == 0) {
                     $countryName = ' (' . CostbenefitprojectionHelper::getCountryName($item->country) . ')';
                 } else {
                     $countryName = '';
                 }
                 $options[] = JHtml::_('select.option', $item->year, $item->year . $countryName);
                 $years[$item->year] = $item->year . '_' . $item->country;
             }
         }
     }
     return $options;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:38,代码来源:datayear.php

示例14: getExImPortHeaders

 /**
  * Method to get header.
  *
  * @return mixed  An array of data items on success, false on failure.
  */
 public function getExImPortHeaders()
 {
     // Get a db connection.
     $db = JFactory::getDbo();
     // get the columns
     $columns = $db->getTableColumns("#__costbenefitprojection_causerisk");
     if (CostbenefitprojectionHelper::checkArray($columns)) {
         // remove the headers you don't import/export.
         unset($columns['asset_id']);
         unset($columns['checked_out']);
         unset($columns['checked_out_time']);
         $headers = new stdClass();
         foreach ($columns as $column => $type) {
             $headers->{$column} = $column;
         }
         return $headers;
     }
     return false;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:24,代码来源:causesrisks.php

示例15: array

        }
        if (array_key_exists($key, $datatype)) {
            // this should be save since all data passed is internal
            $head .= $datatype[$key];
        }
        if (array_key_exists($key, $datahide)) {
            // this should be save since all data passed is internal
            $head .= $datahide[$key];
        }
        $head .= '>' . $header . '</th>';
    }
    $scalingfactors = '<table class="footable metro-blue toggle-circle" data-page-size="10"><thead><tr>' . $head . '</tr></thead><tbody>' . $body . '</tbody><tfoot class="hide-if-no-paging"><tr><td colspan="10"><div class="pagination pagination-centered"></div></td></tr></tfoot></table>';
}
// set interventions
$interventions = '<div class="uk-alert">' . JText::_('COM_COSTBENEFITPROJECTION_NO_INTERVENTIONS_SET') . '</div>';
if (isset($displayData->idCompanyInterventionE) && CostbenefitprojectionHelper::checkArray($displayData->idCompanyInterventionE)) {
    // the values to display
    $keys = array('id' => JText::_('ID'), 'name' => JText::_('COM_COSTBENEFITPROJECTION_NAME'), 'type' => JText::_('COM_COSTBENEFITPROJECTION_TYPE'), 'coverage' => JText::_('COM_COSTBENEFITPROJECTION_COVERAGE'), 'share' => JText::_('COM_COSTBENEFITPROJECTION_SHARE'), 'description' => JText::_('COM_COSTBENEFITPROJECTION_DESCRIPTION'), 'reference' => JText::_('COM_COSTBENEFITPROJECTION_REFERENCE'), 'intervention' => JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION'), 'published' => JText::_('COM_COSTBENEFITPROJECTION_STATUS'));
    $rows = array('published' => 'setPublised', 'intervention' => 'setIntervention', 'name' => 'setInterventionLink', 'type' => 'setInterventionType', 'share' => 'setInterventionShare');
    // header switces
    $datahide = array('id' => ' data-ignore="true" data-hide="all"', 'share' => ' data-hide="phone,tablet"', 'description' => ' data-hide="all"', 'reference' => ' data-hide="all"', 'intervention' => ' data-hide="all"');
    $datatype = array('id' => ' data-type="numeric"', 'coverage' => ' data-type="numeric"');
    $datatoggle = array('name' => ' data-toggle="true"');
    // set the body
    $body = '';
    foreach ($displayData->idCompanyInterventionE as $details) {
        if (CostbenefitprojectionHelper::checkObject($details)) {
            // build the dl list
            $body .= '<tr>';
            foreach ($keys as $key => $header) {
                if (array_key_exists($key, $rows)) {
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:31,代码来源:companydetails.php


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