function admin_index() { $this->Ticket->recursive = 0; $filters = $this->AlaxosFilter->get_filter(); $data_ticket = array(); if (empty($this->params['named']['export_excel'])) { $this->set('tickets', $this->paginate($this->Ticket, $filters)); } else { Configure::write('debug', 0); $options = array(); $this->set('export_to_excel', 1); $i = 0; $tickets = $this->Ticket->find('all', array_merge_recursive($options, array('conditions' => $filters))); foreach ($tickets as $ticket) { foreach ($ticket as $indx => $module) { foreach ($module as $k => $v) { $arr_fields_in_xls = array(); if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) { $data_ticket[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } else { $data_ticket[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } } } $i++; } $this->set('tickets', $data_ticket); } }
/** * Add dynamic fields * * @param BuildBefore $event * @param string|null $alias * @param string|null $itemType * @param bool $dynamicFirst flag if true - dynamic columns will be placed before static, false - after */ public function doBuildBefore(BuildBefore $event, $alias = null, $itemType = null, $dynamicFirst = true) { $config = $event->getConfig(); // get dynamic columns and merge them with static columns from configuration $additionalColumnSettings = $this->getDynamicFields($alias, $itemType); $filtersSorters = $this->getDynamicSortersAndFilters($additionalColumnSettings); $additionalColumnSettings = ['columns' => $additionalColumnSettings, 'sorters' => $filtersSorters['sorters'], 'filters' => $filtersSorters['filters']]; $additionalColumnSettings = $this->datagridResolver->resolve($config->getName(), $additionalColumnSettings); foreach (['columns', 'sorters', 'filters'] as $itemName) { $path = '[' . $itemName . ']'; // get already defined items $items = $config->offsetGetByPath($path, []); // merge additional items with existing if ($dynamicFirst) { $items = array_merge_recursive($additionalColumnSettings[$itemName], $items); } else { $items = array_merge_recursive($items, $additionalColumnSettings[$itemName]); } // set new item set with dynamic columns/sorters/filters $config->offsetSetByPath($path, $items); } // add/configure entity config properties $this->addEntityConfigProperties($config, $itemType); // add/configure entity config actions $actions = $config->offsetGetByPath(self::PATH_ACTIONS, []); $this->prepareRowActions($actions, $itemType); $config->offsetSetByPath(self::PATH_ACTIONS, $actions); }
/** * Initialize fixture data * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _initData() { $this->_data['checkout'] = ['prices' => ['price_from' => 110, 'price_to' => 120], 'selection' => [0]]; parent::_initData(); $this->_data['fields'] = array_merge_recursive($this->_data['fields'], ['sku_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price' => ['value' => 100, 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], 'product_website_1' => ['value' => 'Yes', 'input_value' => [1], 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids'], 'shipment_type' => ['value' => 'Separately', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'bundle_selections' => ['value' => ['bundle_options' => [['title' => 'Drop-down Option', 'type' => 'Drop-down', 'required' => 'Yes', 'assigned_products' => [['search_data' => ['name' => '%item1_simple1::getName%'], 'data' => ['selection_price_value' => 10, 'selection_price_type' => 'Fixed', 'selection_qty' => 1, 'product_id' => '%item1_simple1::getProductId%']], ['search_data' => ['name' => '%item1_virtual2::getName%'], 'data' => ['selection_price_value' => 20, 'selection_price_type' => 'Percent', 'selection_qty' => 1, 'product_id' => '%item1_virtual2::getProductId%']]]]]], 'group' => static::GROUP]]); $this->_repository = Factory::getRepositoryFactory()->getMagentoBundleBundle($this->_dataConfig, $this->_data); }
protected function getRendererdActivityMaps() { $default_content = '<img src="/static/themes/whitelabel/binaries/icons/favicon-64.png">'; // Customizations should be set here // @todo Add case with custom 'toggle_content' $subjects = ['Splitbutton-normal' => ['settings' => ['as_dropdown' => false, 'css' => 'activity-map']], 'Splitbutton-normal-empty' => ['settings' => ['as_dropdown' => false, 'toggle_disabled' => true, 'css' => 'activity-map']], 'Splitbutton-normal-custom_content' => ['settings' => ['as_dropdown' => false, 'default_content' => $default_content, 'css' => 'activity-map']], 'Dropdown-normal' => ['settings' => ['as_dropdown' => true, 'css' => 'activity-map']], 'Dropdown-normal-empty' => ['settings' => ['as_dropdown' => true, 'toggle_disabled' => true, 'css' => 'activity-map']], 'Dropdown-normal-custom_content' => ['settings' => ['as_dropdown' => true, 'default_content' => $default_content, 'css' => 'activity-map']], 'Splitbutton-emphasized' => ['settings' => ['as_dropdown' => false, 'emphasized' => true, 'css' => 'activity-map']], 'Splitbutton-emphasized-empty' => ['settings' => ['as_dropdown' => false, 'emphasized' => true, 'css' => 'activity-map', 'toggle_disabled' => true]], 'Splitbutton-emphasized-custom_content' => ['settings' => ['as_dropdown' => false, 'emphasized' => true, 'css' => 'activity-map', 'default_content' => $default_content]], 'Dropdown-emphasized' => ['settings' => ['as_dropdown' => true, 'emphasized' => true, 'css' => 'activity-map']], 'Dropdown-emphasized-empty' => ['settings' => ['as_dropdown' => true, 'emphasized' => true, 'css' => 'activity-map', 'toggle_disabled' => true]], 'Dropdown-emphasized-custom_content' => ['settings' => ['as_dropdown' => true, 'emphasized' => true, 'default_content' => $default_content, 'css' => 'activity-map']]]; foreach ($this->activity_types as $activity_type_name => $activity_type) { $activity_type_selector = $activity_type['selector']; foreach ($subjects as $subject_name => $subject) { // create activity map $activity_map = new ActivityMap(); foreach ($this->sample_activities as $key => $activity_custom_state) { $activity_settings = array_merge_recursive(['form_id' => 'randomId-' . rand()], $activity_custom_state['activity']['settings']); $activity_state = ['name' => $key, 'label' => $activity_custom_state['activity']['label'], 'type' => Activity::TYPE_GENERAL, 'description' => $activity_custom_state['activity']['description'], 'verb' => 'read', 'rels' => $activity_custom_state['activity']['rels'], 'settings' => new Settings($activity_settings), 'url' => new Url(['type' => Url::TYPE_URI, 'value' => $activity_custom_state['link']])]; $activity = new Activity($activity_state); $activity_map->setItem($key, $activity); } // render map $render_settings = ['default_activity_name' => $activity_type_name, 'css' => $subject['settings']['css'] . ' ' . $activity_type_selector]; $render_settings = array_replace_recursive($subject['settings'], $render_settings); $rendered_maps[$subject_name] = $this->renderSubject($activity_map, $render_settings); } $rendered_activity_maps[$activity_type_name] = $rendered_maps; } return $rendered_activity_maps; }
public function getContent(array $extra_attr = array()) { $attr = array_merge_recursive($extra_attr, $this->attr); $sattr = $this->serializeAttr($attr, ['name', 'id']); $soptions = $this->options->serializeOptions($this->selected); return "<select {$sattr}>\n{$soptions}\n</select>"; }
function icl_register_admin_options($array, $key = "", $option = array()) { if (is_object($option)) { $option = object_to_array($option); } foreach ($array as $k => $v) { $option = $key === '' ? array($k => maybe_unserialize($this->get_option_without_filtering($k))) : $option; if (is_array($v)) { $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option[$k]); } else { $context = $this->get_context($key, $k); if ($v === '') { icl_unregister_string($context, $key . $k); } elseif (isset($option[$k]) && ($key === '' || preg_match_all('#\\[([^\\]]+)\\]#', (string) $key, $opt_key_matches) > 0)) { icl_register_string($context, $key . $k, $option[$k]); $vals = array($k => 1); $opt_keys = isset($opt_key_matches) ? array_reverse($opt_key_matches[1]) : array(); foreach ($opt_keys as $opt) { $vals = array($opt => $vals); } update_option('_icl_admin_option_names', array_merge_recursive((array) get_option('_icl_admin_option_names'), $vals)); } } } }
function paginate($term = null, $paginateOptions = array()) { $this->_controller->paginate = array('SearchIndex' => array_merge_recursive(array('conditions' => array(array('SearchIndex.active' => 1), 'or' => array(array('SearchIndex.published' => null), array('SearchIndex.published <= ' => date('Y-m-d H:i:s'))))), $paginateOptions)); if (isset($this->_controller->request->params['named']['type']) && $this->_controller->request->params['named']['type'] != 'All') { $this->_controller->request->data['SearchIndex']['type'] = Sanitize::escape($this->_controller->request->params['named']['type']); $this->_controller->paginate['SearchIndex']['conditions']['model'] = $this->_controller->data['SearchIndex']['type']; } // Add term condition, and sorting if (!$term && isset($this->_controller->request->params['named']['term'])) { $term = $this->_controller->request->params['named']['term']; } if ($term) { $term = Sanitize::escape($term); $this->_controller->request->data['SearchIndex']['term'] = $term; $term = implode(' ', array_map(array($this, 'replace'), preg_split('/[\\s_]/', $term))) . '*'; if ($this->like) { $this->_controller->paginate['SearchIndex']['conditions'][] = array('or' => array("MATCH(data) AGAINST('{$term}')", 'SearchIndex.data LIKE' => "%{$this->_controller->data['SearchIndex']['term']}%")); } else { $this->_controller->paginate['SearchIndex']['conditions'][] = "MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE)"; } $this->_controller->paginate['SearchIndex']['fields'] = "*, MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE) AS score"; if (empty($this->_controller->paginate['SearchIndex']['order'])) { $this->_controller->paginate['SearchIndex']['order'] = "score DESC"; } } return $this->_controller->paginate('SearchIndex'); }
/** * Adds a rule $rule to the class $classname. * * The container can be fully configured using rules provided by associative arrays. * See {@link https://r.je/dice.html#example3} for a description of the rules. * * @param string $classname The name of the class to add the rule for * @param array $rule The rule to add to it */ public function addRule($classname, $rule) { if (isset($rule['instanceOf']) && \is_string($rule['instanceOf']) && (!\array_key_exists('inherit', $rule) || $rule['inherit'] === true)) { $rule = \array_merge_recursive($this->getRule($rule['instanceOf']), $rule); } $this->rules[self::normalizeName($classname)] = \array_merge_recursive($this->getRule($classname), $rule); }
/** {@inheritDoc} */ public function outputArray(array $array, $count = false) { if ($this->getProperty('addall')) { $array = array_merge_recursive(array(array('id' => 0, 'name' => $this->modx->lexicon('mlmsystem_all'))), $array); } return parent::outputArray($array, $count); }
/** * Execute shortcode. * * @param Event $event An event object. * @return string|null Return modified contents. */ public function execute(Event $event) { /* @var \Grav\Common\Data\Data $options */ $options = $event['options']; /* @var \Grav\Common\Grav $grav */ $grav = $event['grav']; /* @var \Grav\Common\Page\Page $page */ $page = $event['page']; /* @var Config $config */ $config = $grav['config']; $body = trim($event['body']); // Mimic \Grav\Common\Page\Page processMarkdown() method $defaults = (array) $config->get('system.pages.markdown'); $defaults = array_merge_recursive($defaults, $this->defaults); $options->setDefaults($defaults); if (isset($page->header()->markdown)) { $options->merge($page->header()->markdown); } // Initialize the preferred variant of Parsedown if ($options->get('extra')) { $parsedown = new ParsedownExtra($page, $options->toArray()); } else { $parsedown = new Parsedown($page, $options->toArray()); } $content = $parsedown->text($body); return $content; }
/** * {@inheritDoc} */ public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null) { if ($class = $this->getElementStateClass($element, $form)) { $attribs = array_merge_recursive(compact('class'), $attribs); } return parent::render($content, $attribs, $element, $form); }
/** * Méthode qui charge le fichier plugins.xml * * @return null * @author Stephane F **/ public function loadPlugins() { if (!is_file(path('XMLFILE_PLUGINS'))) { return; } # Mise en place du parseur XML $data = implode('', file(path('XMLFILE_PLUGINS'))); $parser = xml_parser_create(PLX_CHARSET); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $data, $values, $iTags); xml_parser_free($parser); # On verifie qu'il existe des tags "plugin" if (isset($iTags['plugin'])) { # On compte le nombre de tags "plugin" $nb = sizeof($iTags['plugin']); # On boucle sur $nb for ($i = 0; $i < $nb; $i++) { $name = $values[$iTags['plugin'][$i]]['attributes']['name']; if ($instance = $this->getInstance($name)) { $this->aPlugins[$name] = $instance; $this->aHooks = array_merge_recursive($this->aHooks, $instance->getHooks()); } } } }
public function indexAction() { /** @var UserInterface $user */ $user = $this->identity(); $form = new UserForm($this->entityManager, 'user', $this->config); $form->setInputFilter(new ProfileFilter($this->entityManager, $this->config)); $form->setAttribute('action', $this->url()->fromRoute($this->routes['account']['name'], $this->routes['account']['params'], $this->routes['account']['options'], $this->routes['account']['reuseMatchedParams'])); $form->bind($user); $form->get('submit')->setValue(_('Update')); $avatar = $user->getAvatar(); $request = $this->getRequest(); if ($request->isPost()) { $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $form->setData($post); if ($form->isValid()) { if ($user->getAvatar()['error'] == 0) { $user->setAvatar($this->tssImageThumb()->process($user->getAvatar())); } else { $user->setAvatar($avatar); } $this->entityManager->flush(); $this->flashMessenger()->addInfoMessage(_('Profile updated with success!')); return $this->redirect()->toRoute($this->routes['account']['name'], $this->routes['account']['params'], $this->routes['account']['options'], $this->routes['account']['reuseMatchedParams']); } else { $this->flashMessenger()->addErrorMessage(_('Form with errors!')); } } $form->prepare(); $viewModel = new ViewModel(array('form' => $form, 'user' => $user, 'routes' => $this->routes)); return $viewModel; }
/** * Fetch policy list * Used by fetch( 'user', 'user_role', hash( 'user_id', $id ) ) template function. * * @param int $id User id or normal content object id in case of none user object (user group) * @return array(string=>array) */ function fetchUserRole($id) { $user = eZUser::fetch($id); if ($user instanceof eZUser) { $roleList = $user->roles(); } else { // user group or other non user classes: $roleList = eZRole::fetchByUser(array($id), true); } $accessArray = array(); foreach (array_keys($roleList) as $roleKey) { $role = $roleList[$roleKey]; $accessArray = array_merge_recursive($accessArray, $role->accessArray(true)); } $resultArray = array(); foreach ($accessArray as $moduleKey => $module) { $moduleName = $moduleKey; if ($moduleName != '*') { foreach ($module as $functionKey => $function) { $functionName = $functionKey; if ($functionName != '*') { $hasLimitation = true; foreach ($function as $limitationKey) { if ($limitationKey == '*') { $hasLimitation = false; $limitationValue = '*'; $resultArray[] = array('moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' => $limitationValue); } } if ($hasLimitation) { foreach ($function as $limitationKey => $limitation) { if ($limitationKey !== '*') { $policyID = str_replace('p_', '', $limitationKey); $userRoleIdSeperator = strpos($policyID, '_'); if ($userRoleIdSeperator !== false) { $policyID = substr($policyID, 0, $userRoleIdSeperator); } $limitationValue = eZPolicyLimitation::fetchByPolicyID($policyID); $resultArray[] = array('moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' => $limitationValue); } else { $limitationValue = '*'; $resultArray[] = array('moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' => $limitationValue); break; } } } } else { $limitationValue = '*'; $resultArray[] = array('moduleName' => $moduleName, 'functionName' => $functionName, 'limitation' => $limitationValue); break; } } } else { $functionName = '*'; $resultArray[] = array('moduleName' => '*', 'functionName' => $functionName, 'limitation' => '*'); break; } } return array('result' => $resultArray); }
/** * Reconfigure asset * * @return void */ protected function reconfigureAsset() { $configuredAssetConfig = $this->app['config']->get('assets', []); $foundationAssetConfig = $this->app['config']->get('inoplate.foundation.assets', []); $assetConfig = array_merge_recursive($configuredAssetConfig, $foundationAssetConfig); Assets::config($assetConfig); }
public function getNewChildSelectOptions() { if ($this->getRule()->getType()) { $type = $this->getRule()->getType(); } else { $type = Mage::app()->getRequest()->getParam('rule_type'); } $attributes = array(); $ruleClasses = $this->_getRuleClasses(); foreach ($ruleClasses as $key => $class) { $classCondition = Mage::getModel($class); $classAttributes = $classCondition->loadAttributeOptions()->getAttributeOption(); if (is_array($classAttributes)) { foreach ($classAttributes as $code => $label) { $attributes[ucfirst($key)][] = array('value' => 'email/rule_condition_' . $key . '|' . $code, 'label' => $label); } } } $conditions = parent::getNewChildSelectOptions(); $conditions = array_merge_recursive($conditions, array(array('value' => 'email/rule_condition_combine', 'label' => Mage::helper('email')->__('Conditions Combination')))); foreach ($attributes as $group => $arrAttributes) { $conditions = array_merge_recursive($conditions, array(array('label' => $group, 'value' => $arrAttributes))); } return $conditions; }
function admin_index() { $this->FrequencyType->recursive = 0; $filters = $this->AlaxosFilter->get_filter(); $data_frequencyType = array(); if (empty($this->params['named']['export_excel'])) { $this->set('frequencyTypes', $this->paginate($this->FrequencyType, $filters)); } else { Configure::write('debug', 0); $options = array(); $this->set('export_to_excel', 1); $i = 0; $frequencyTypes = $this->FrequencyType->find('all', array_merge_recursive($options, array('conditions' => $filters))); foreach ($frequencyTypes as $frequencyType) { foreach ($frequencyType as $indx => $module) { foreach ($module as $k => $v) { $arr_fields_in_xls = array(); if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) { $data_frequencyType[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } else { $data_frequencyType[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } } } $i++; } $this->set('frequencyTypes', $data_frequencyType); } $frequencies = $this->FrequencyType->Frequency->find('list'); $this->set(compact('frequencies')); }
/** * Returns aggregated metrics from all available metrics providers * * @param string $url page URL * @param array $options additional parameters, can contains: * $noexternals boolean only load Wikia code * $mobile boolean check wikiamobile skin * $providers array list of providers to get data from (defaults to all providers) * $loggedIn boolean should the metrics be aggregated for loggged-in version of the site * @return mixed report */ public function getReport($url, array $options = array()) { $providers = !empty($options['providers']) ? $options['providers'] : $this->wg->PerformanceMetricsProviders; $instances = $this->getProviders($providers); $metrics = array(); // apply options if ($options['noexternals']) { $url .= (strpos($url, '?') !== false ? '&' : '?') . 'noexternals=1'; } if ($options['mobile']) { $url .= (strpos($url, '?') !== false ? '&' : '?') . 'useskin=wikiamobile'; } // run each provider foreach ($instances as $provider) { $report = $provider->getReport($url, $options); if (!empty($report)) { $metrics = array_merge_recursive($metrics, $report); } } // each provider emits "url" entry, use only one of them if (is_array($metrics['url'])) { $metrics['url'] = reset($metrics['url']); } return $metrics; }
public function registrarProfesor() { $new_profesor = new Profesor(); $new_profesor->num_empleado = Input::get("num_empleado"); $new_profesor->password = Input::get("password"); $new_profesor->email = Input::get("email"); $new_datos_profesor = new DatosProfesor(); $new_datos_profesor->nombre = Input::get("nombre"); $new_datos_profesor->apellido_paterno = Input::get("apellido_paterno"); $new_datos_profesor->apellido_materno = Input::get("apellido_materno"); $new_datos_profesor->sexo = Input::get("sexo"); $new_datos_profesor->celular = Input::get("celular"); // Pequeño hack. Primero lo ponemos como archivo para validarlo, después le asignamos la ruta real para guardarlo $new_datos_profesor->ruta = Input::file('cv'); if ($new_profesor->validate()) { if ($new_datos_profesor->validate()) { $nombreCV = Input::get("nombre") . "_" . Input::get("apellido_paterno") . "_" . Input::get("apellido_materno") . "_CV.pdf"; //CHECAR PORQUE NO SE CREA EL PUTO CV!!! Input::file('cv')->move("CVs", $nombreCV); $new_datos_profesor->ruta = "/CVs/" . $nombreCV; //Ahora si, guardamos todo después de haberlo validado $new_profesor->save(); $new_datos_profesor->profesor()->associate($new_profesor); // Forzamos Save porque sabemos que no validará ruta como un string, sino como un file $new_datos_profesor->forceSave(); return Redirect::to('/'); } else { return Redirect::route('registro')->withErrors($new_datos_profesor->errors())->withInput(); } } else { $new_datos_profesor->validate(); $erroresValidaciones = array_merge_recursive($new_profesor->errors()->toArray(), $new_datos_profesor->errors()->toArray()); return Redirect::route('registro')->withErrors($erroresValidaciones)->withInput(); } }
public function __invoke() : array { $config = []; $config = array_merge_recursive($config, require __DIR__ . '/../config/config.global.php'); $config = array_merge_recursive($config, require __DIR__ . '/../config/dependencies.global.php'); return $config; }
/** * Setup function * * @param object $Model The calling model */ public function setup(&$Model, $settings = array()) { $Model->RevisionModel = new Model(array('table' => Inflector::tableize($Model->name) . '_revs', 'name' => 'Revision', 'ds' => $Model->useDbConfig)); $Model->RevisionModel->primaryKey = 'version_id'; $default = array('fields' => array()); $this->settings[$Model->alias] = array_merge_recursive($default, $settings); }
/** * {@inheritdoc} */ public function create($namespace, $data = null, array $options = []) { $schema = $this->schemaRegistry->getSchema($namespace); $builder = $this->formFactory->createBuilder('form', $data, array_merge_recursive(['data_class' => null], $options)); $schema->buildForm($builder); return $builder->getForm(); }
function icl_register_admin_options($array, $key = "", $option = array()) { foreach ($array as $k => $v) { if (is_array($v)) { array_push($option, $k); $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option); array_pop($option); } else { $context = $this->get_context($key, $k); if ($v === '') { icl_unregister_string($context, $key . $k); } else { icl_register_string($context, $key . $k, $v); $vals = array($k => 1); if (count($option)) { for ($i = count($option) - 1; $i >= 0; $i--) { $vals = array($option[$i] => $vals); } } $_icl_admin_option_names = get_option('_icl_admin_option_names'); $_icl_admin_option_names = array_merge_recursive((array) $_icl_admin_option_names, $vals); update_option('_icl_admin_option_names', $_icl_admin_option_names); } } } }
/** * Execute the console command. * * @return mixed */ public function fire(Filesystem $files) { $langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR); $diff = []; foreach (ModulesLoader::getRegisteredModules() as $module) { if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) { continue; } $locale = $this->input->getOption('locale'); foreach ($files->directories($module->getLocalePath()) as $localeDir) { foreach ($files->allFiles($localeDir) as $localeFile) { $vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename(); $vendorFilePath = $langDirectory . $vendorFileDir; if (file_exists($vendorFilePath)) { $localArray = $files->getRequire($localeFile->getRealPath()); $vendorArray = $files->getRequire($vendorFilePath); $array = array_keys_exists_recursive($localArray, $vendorArray); $arrayDiff = ''; foreach (array_dot($array) as $key => $value) { $arrayDiff .= "{$key}: {$value}\n"; } if (empty($arrayDiff)) { continue; } $diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir]; $diff[] = new TableSeparator(); $diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)]; $diff[] = new TableSeparator(); } } } } $this->table($this->headers, $diff); }
/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $doctrineHydrator = new DoctrineHydrator($entityManager); $this->setHydrator($doctrineHydrator)->setObject($object); $builder = new AnnotationBuilder(); /** * Go over the different form elements and add them to the form */ foreach ($builder->createForm($object)->getElements() as $element) { /** * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) { $element->setOptions(array_merge_recursive($element->getOptions(), ['object_manager' => $entityManager])); } if ($element instanceof Radio) { $attributes = $element->getAttributes(); $valueOptionsArray = 'get' . ucfirst($attributes['array']); $element->setOptions(array_merge_recursive($element->getOptions(), ['value_options' => $object->{$valueOptionsArray}()])); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } }
public function mount($pattern, $mux, $options = array()) { if ($mux instanceof \Pux\Controller) { $mux = $mux->expand(); } else { if ((!is_object($mux) || !$mux instanceof Mux) && is_callable($mux)) { $mux($mux = new Mux()); } } if ($this->expand) { $pcre = strpos($pattern, ':') !== false; // rewrite submux routes foreach ($mux->routes as $route) { // process for pcre if ($route[0] || $pcre) { $newPattern = $pattern . ($route[0] ? $route[3]['pattern'] : $route[1]); $routeArgs = PatternCompiler::compile($newPattern, array_merge_recursive($route[3], $options)); $this->appendPCRERoute($routeArgs, $route[2]); } else { $this->routes[] = array(false, $pattern . $route[1], $route[2], isset($route[3]) ? array_merge($options, $route[3]) : $options); } } } else { $muxId = $mux->getId(); $this->add($pattern, $muxId, $options); $this->submux[$muxId] = $mux; } }
function admin_index() { $this->City->recursive = 0; $filters = $this->AlaxosFilter->get_filter(); $data_city = array(); if (empty($this->params['named']['export_excel'])) { $this->set('cities', $this->paginate($this->City, $filters)); } else { Configure::write('debug', 0); $options = array(); $this->set('export_to_excel', 1); $i = 0; $cities = $this->City->find('all', array_merge_recursive($options, array('conditions' => $filters))); foreach ($cities as $city) { foreach ($city as $indx => $module) { foreach ($module as $k => $v) { $arr_fields_in_xls = array(); if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) { $data_city[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } else { $data_city[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } } } $i++; } $this->set('cities', $data_city); } $districts = $this->City->District->find('list'); $this->City->bindModel(array('belongsTo' => array('State' => array('className' => 'State', 'foreignKey' => '', 'conditions' => 'State.id = District.state_id', 'fields' => '', 'order' => '')))); $states = $this->City->State->find('list'); $this->set(compact('districts', 'states')); }
/** * @param \StackFormation\Template[] $templates * @param string|null $description * @param array $additionalData * * @return string * @throws \Exception */ public function merge(array $templates, $description = null, array $additionalData = []) { if (count($templates) == 0) { throw new \InvalidArgumentException('No templates given'); } $mergedTemplate = ['AWSTemplateFormatVersion' => '2010-09-09']; $mergeKeys = ['Parameters', 'Mappings', 'Conditions', 'Resources', 'Outputs', 'Metadata']; foreach ($templates as $template) { if (!$template instanceof \StackFormation\Template) { throw new \InvalidArgumentException('Expecting an array of \\StackFormation\\Template objects'); } try { $array = $template->getDecodedJson(); // Copy the current description into the final template if (!empty($array['Description'])) { $mergedTemplate['Description'] = $array['Description']; } // Merge keys from current template with final template foreach ($mergeKeys as $mergeKey) { if (isset($array[$mergeKey]) && is_array($array[$mergeKey])) { foreach ($array[$mergeKey] as $key => $value) { if (isset($mergedTemplate[$mergeKey][$key])) { // it's ok if the parameter has the same name and type... if ($mergeKey != 'Parameters' || $value['Type'] != $mergedTemplate[$mergeKey][$key]['Type']) { throw new \Exception("Duplicate key '{$key}' found in '{$mergeKey}'"); } } $mergedTemplate[$mergeKey][$key] = $value; } } } } catch (TemplateDecodeException $e) { if (Div::isProgramInstalled('jq')) { $tmpfile = tempnam(sys_get_temp_dir(), 'json_validate_'); file_put_contents($tmpfile, $template->getProcessedTemplate()); passthru('jq . ' . $tmpfile); unlink($tmpfile); } throw $e; } } // If a description override is specified use it if (!empty($description)) { $mergedTemplate['Description'] = trim($description); } if (empty($mergedTemplate['Description'])) { $mergedTemplate['Description'] = 'Merged Template'; } $mergedTemplate = array_merge_recursive($mergedTemplate, $additionalData); $json = json_encode($mergedTemplate, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // Check for max template size if (strlen($json) > self::MAX_CF_TEMPLATE_SIZE) { $json = json_encode($mergedTemplate, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // Re-check for max template size if (strlen($json) > self::MAX_CF_TEMPLATE_SIZE) { throw new \Exception(sprintf('Template too big (%s bytes). Maximum template size is %s bytes.', strlen($json), self::MAX_CF_TEMPLATE_SIZE)); } } return $json; }
/** * @return \Zend\Http\Response|ViewModel */ public function detailAction() { $id = (int) $this->params()->fromRoute('id', 0); $helper = new ContactHelper($this->companyCombos(), $this->getDbAdapter()); $form = $helper->getForm(); $contact = $this->contactTable()->getContact($id); $isEdit = true; if (!$contact) { $isEdit = false; $contact = new Contact(); } $form->bind($contact); $request = $this->getRequest(); if ($request->isPost()) { $post_data = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $form->setData($post_data); $form->setInputFilter($helper->getInputFilter($isEdit ? $post_data['contactId'] : 0, $post_data['name'])); if ($form->isValid()) { $this->contactTable()->saveContact($contact); $this->flashMessenger()->addSuccessMessage('Save Successful'); return $this->redirect()->toRoute('cr_contact'); } } return new ViewModel(array('form' => $form, 'id' => $id, 'isEdit' => $isEdit)); }
public function getLatestTweets($endpoint, $params) { foreach ($this->usernames as $username) { $params = $this->getParamsForUser($username, $params, $endpoint); $oauth = array('oauth_consumer_key' => $this->consumerKey, 'oauth_nonce' => time(), 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_token' => $this->oAuthAccessToken, 'oauth_timestamp' => time(), 'oauth_version' => '1.0'); $baseInfo = $this->buildBaseString(self::$endPoints[$endpoint], 'GET', $oauth, $params); $compositeKey = rawurlencode($this->consumerSecret) . '&' . rawurlencode($this->oAuthAccessTokenSecret); $oauthSignature = base64_encode(hash_hmac('sha1', $baseInfo, $compositeKey, true)); $oauth['oauth_signature'] = $oauthSignature; $url = $this->buildTwitterUrl(self::$endPoints[$endpoint], $params); // Make Requests $header = array($this->buildAuthorizationHeader($oauth), 'Expect:'); $arrayOfJsonTweets[] = $this->curlService->execJson($url, $header); } //end for loop //turn all the seperate json strings into one merged json string $mergedFeedsJson = array(); foreach ($arrayOfJsonTweets as $jsonFeed) { $mergedFeedsJson = array_merge_recursive($mergedFeedsJson, $jsonFeed); } //sort tweets by time - new // usort($mergedFeedsJson, function($a, $b) { // return strtotime($b['created_at']) - strtotime($a['created_at']); // }); return $mergedFeedsJson; }