/**
  * Show the setup wizard
  */
 public function setup_wizard()
 {
     if (empty($_GET['page']) || 'wc-setup' !== $_GET['page']) {
         return;
     }
     $this->steps = array('introduction' => array('name' => __('Introduction', 'woocommerce'), 'view' => array($this, 'wc_setup_introduction'), 'handler' => ''), 'pages' => array('name' => __('Page Setup', 'woocommerce'), 'view' => array($this, 'wc_setup_pages'), 'handler' => array($this, 'wc_setup_pages_save')), 'locale' => array('name' => __('Store Locale', 'woocommerce'), 'view' => array($this, 'wc_setup_locale'), 'handler' => array($this, 'wc_setup_locale_save')), 'shipping_taxes' => array('name' => __('Shipping & Tax', 'woocommerce'), 'view' => array($this, 'wc_setup_shipping_taxes'), 'handler' => array($this, 'wc_setup_shipping_taxes_save')), 'payments' => array('name' => __('Payments', 'woocommerce'), 'view' => array($this, 'wc_setup_payments'), 'handler' => array($this, 'wc_setup_payments_save')), 'next_steps' => array('name' => __('Ready!', 'woocommerce'), 'view' => array($this, 'wc_setup_ready'), 'handler' => ''));
     $this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_script('select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.2');
     wp_register_script('wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array('jquery', 'select2'), WC_VERSION);
     wp_localize_script('wc-enhanced-select', 'wc_enhanced_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching…', 'enhanced select', 'woocommerce'), 'ajax_url' => admin_url('admin-ajax.php'), 'search_products_nonce' => wp_create_nonce('search-products'), 'search_customers_nonce' => wp_create_nonce('search-customers')));
     wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION);
     wp_enqueue_style('wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array('dashicons', 'install'), WC_VERSION);
     wp_register_script('wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup.min.js', array('jquery', 'wc-enhanced-select'), WC_VERSION);
     wp_localize_script('wc-setup', 'wc_setup_params', array('locale_info' => json_encode(include WC()->plugin_path() . '/i18n/locale-info.php')));
     if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
         call_user_func($this->steps[$this->step]['handler']);
     }
     ob_start();
     $this->setup_wizard_header();
     $this->setup_wizard_steps();
     $this->setup_wizard_content();
     $this->setup_wizard_footer();
     exit;
 }
コード例 #2
1
ファイル: StringFilter.php プロジェクト: sylius/grid
 /**
  * {@inheritdoc}
  */
 public function apply(DataSourceInterface $dataSource, $name, $data, array $options)
 {
     $expressionBuilder = $dataSource->getExpressionBuilder();
     if (is_array($data) && !isset($data['type'])) {
         $data['type'] = isset($options['type']) ? $options['type'] : self::TYPE_CONTAINS;
     }
     if (!is_array($data)) {
         $data = ['type' => self::TYPE_CONTAINS, 'value' => $data];
     }
     $fields = array_key_exists('fields', $options) ? $options['fields'] : [$name];
     $type = $data['type'];
     $value = array_key_exists('value', $data) ? $data['value'] : null;
     if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) {
         return;
     }
     if (1 === count($fields)) {
         $dataSource->restrict($this->getExpression($expressionBuilder, $type, current($fields), $value));
         return;
     }
     $expressions = [];
     foreach ($fields as $field) {
         $expressions[] = $this->getExpression($expressionBuilder, $type, $field, $value);
     }
     $dataSource->restrict($expressionBuilder->orX(...$expressions));
 }
コード例 #3
1
 /**
  * {@inheritdoc}
  */
 public function prepare_form($request, $template, $user, $row, &$error)
 {
     $avatar_list = $this->get_avatar_list($user);
     $category = $request->variable('avatar_local_cat', key($avatar_list));
     foreach ($avatar_list as $cat => $null) {
         if (!empty($avatar_list[$cat])) {
             $template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category));
         }
         if ($cat != $category) {
             unset($avatar_list[$cat]);
         }
     }
     if (!empty($avatar_list[$category])) {
         $template->assign_vars(array('AVATAR_LOCAL_SHOW' => true));
         $table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
         $row_count = $col_count = $avatar_pos = 0;
         $avatar_count = sizeof($avatar_list[$category]);
         reset($avatar_list[$category]);
         while ($avatar_pos < $avatar_count) {
             $img = current($avatar_list[$category]);
             next($avatar_list[$category]);
             if ($col_count == 0) {
                 ++$row_count;
                 $template->assign_block_vars('avatar_local_row', array());
             }
             $template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
             $template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
             $col_count = ($col_count + 1) % $table_cols;
             ++$avatar_pos;
         }
     }
     return true;
 }
function array_to_xml($phpResponse, &$phpResponseToXML)
{
    foreach ($phpResponse as $key => $value) {
        if (is_array($value)) {
            if (!is_numeric($key)) {
                // For non-numeric keys, give name same as key to the node
                $subnode = $phpResponseToXML->addChild("{$key}");
                // Recursive call to the function since the value was an array
                array_to_xml($value, $subnode);
            } else {
                // For numeric keys, give a name to the node
                //$subnode = $phpResponseToXML->addChild("item$key");
                if (current($phpResponseToXML->xpath('parent::*'))) {
                    $subnode = $phpResponseToXML->addChild("Showing");
                } else {
                    $subnode = $phpResponseToXML->addChild("Show");
                }
                //Recursive call to the function since the value was an array
                array_to_xml($value, $subnode);
            }
        } else {
            // Save the node and its value in XMLFiles format
            //$phpResponseToXML->addChild("$key","$value");
            $phpResponseToXML->{$key} = $value;
        }
    }
}
コード例 #5
0
ファイル: Index.php プロジェクト: hiro1173/legacy
 /**
  *  preprocess before forwarding.
  *
  *  @access public
  */
 function preforward()
 {
     $this->subtitle = _('Select language');
     $config = $this->backend->getConfig();
     $this->af->setApp('allow_language', $config->get('allow_language'));
     $this->af->setApp('cur_lang', current($this->backend->ctl->getLanguage()));
 }
コード例 #6
0
 static function cronCleanlogs()
 {
     global $DB;
     $pmLog = new PluginMonitoringLog();
     $pmConfig = new PluginMonitoringConfig();
     $id_restart = 0;
     $a_restarts = $pmLog->find("`action`='restart'", "`id` DESC", 1);
     if (count($a_restarts) > 0) {
         $a_restart = current($a_restarts);
         $id_restart = $a_restart['id'];
     }
     $id_reload = 0;
     $a_reloads = $pmLog->find("`action`='reload'", "`id` DESC", 1);
     if (count($a_reloads) > 0) {
         $a_reload = current($a_reloads);
         $id_reload = $a_reload['id'];
     }
     $pmConfig->getFromDB(1);
     $secs = $pmConfig->fields['logretention'] * DAY_TIMESTAMP;
     $query = "DELETE FROM `" . $pmLog->getTable() . "`\n         WHERE UNIX_TIMESTAMP(date_mod) < UNIX_TIMESTAMP()-{$secs}";
     if ($id_restart > 0 || $id_reload > 0) {
         // Keep last reload or restart command
         $id_restart = max($id_restart, $id_reload);
         $query .= " AND `id` < '" . $id_restart . "'";
     }
     $DB->query($query);
     // TODO: Delete serviceevents table content ???
     $query = "DELETE FROM `glpi_plugin_monitoring_serviceevents`\n         WHERE UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP()-{$secs}";
     $DB->query($query);
     return true;
 }
コード例 #7
0
ファイル: TreeData.php プロジェクト: jglaine/sugar761-ent
function get_product_categories($parent_id, $open_nodes_ids = array())
{
    $href_string = "javascript:set_return('productcategories')";
    reset($open_nodes_ids);
    $nodes = array();
    if ($parent_id == '') {
        $query = "select * from product_categories where (parent_id is null or parent_id='') and deleted=0 order by list_order";
    } else {
        $query = "select * from product_categories where parent_id ='{$parent_id}' and deleted=0 order by list_order";
    }
    $result = $GLOBALS['db']->query($query);
    while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
        $node = new Node($row['id'], $row['name']);
        $node->set_property("href", $href_string);
        if (count($open_nodes_ids) > 0 and $row['id'] == current($open_nodes_ids)) {
            $node->expanded = true;
            $node->dynamic_load = false;
            $current_id = current($open_nodes_ids);
            array_shift($open_nodes_ids);
            $child_nodes = get_product_categories($current_id, $open_nodes_ids);
            //add all returned node to current node.
            foreach ($child_nodes as $child_node) {
                $node->add_node($child_node);
            }
        } else {
            $node->expanded = false;
            $node->dynamic_load = true;
        }
        $nodes[] = $node;
    }
    return $nodes;
}
コード例 #8
0
 function apply_filters_ref_array($tag, $args)
 {
     global $wp_filter, $merged_filters, $wp_current_filter;
     // Do 'all' actions first
     if (isset($wp_filter['all'])) {
         $wp_current_filter[] = $tag;
         $all_args = func_get_args();
         _wp_call_all_hook($all_args);
     }
     if (!isset($wp_filter[$tag])) {
         if (isset($wp_filter['all'])) {
             array_pop($wp_current_filter);
         }
         return $args[0];
     }
     if (!isset($wp_filter['all'])) {
         $wp_current_filter[] = $tag;
     }
     // Sort
     if (!isset($merged_filters[$tag])) {
         ksort($wp_filter[$tag]);
         $merged_filters[$tag] = true;
     }
     reset($wp_filter[$tag]);
     do {
         foreach ((array) current($wp_filter[$tag]) as $the_) {
             if (!is_null($the_['function'])) {
                 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
             }
         }
     } while (next($wp_filter[$tag]) !== false);
     array_pop($wp_current_filter);
     return $args[0];
 }
コード例 #9
0
ファイル: tudou_bak.php プロジェクト: sunyymq/php-videos
 public function download($urls, $merge = TRUE)
 {
     if (!$urls || !is_array($urls)) {
         return FALSE;
     }
     $extFlag = FALSE;
     $videoName = $this->title;
     if (count($urls) == 1) {
         $fileName = './video/' . $videoName . '.mp4';
         $url = current($urls);
         system("curl -o {$fileName} {$url}");
     } else {
         foreach ($urls as $key => $url) {
             $videoName = './video/' . $key . 'tudou.mp4.download';
             $parts[] = $videoName;
             system("curl -o {$videoName} {$url}");
             $extFlag = TRUE;
         }
         if ($extFlag && $merge) {
             $outFile = $this->title . '.mp4';
             $this->merge($parts, 'tudou', $this->ext);
         }
     }
     return $fileName;
 }
コード例 #10
0
 /**
  * A failure occurred.
  *
  * @param  PHPUnit_Framework_Test				 $test
  * @param  PHPUnit_Framework_AssertionFailedError $e
  * @param  float								  $time
  */
 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
 {
     $this->write('fail: ' . $e->getMessage());
     $trace = current(PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE));
     $this->write('trace: ' . print_r($trace, 1));
     $this->currentTestPass = FALSE;
 }
コード例 #11
0
 protected function _getRecipient()
 {
     $rs = $this->_getMailComponent()->getRecipientSources();
     $recipientId = $this->_getParam('recipientId');
     if (!$recipientId) {
         $component = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_getParam('componentId'), array('ignoreVisible' => true));
         $source = reset($rs);
         $model = Kwf_Model_Abstract::getInstance($source['model']);
         $select = $model->select();
         if ($model->hasColumn('newsletter_component_id')) {
             $select->whereEquals('newsletter_component_id', $component->parent->componentId);
         }
         if (isset($source['select'])) {
             $select->merge($source['select']);
         }
         $row = $model->getRow($select);
         if (!$row) {
             throw new Kwf_Exception_Client(trlKwf('Preview cannot be shown because it needs at least one recipient of this newsletter'));
         }
         $recipientId = $row->id;
     }
     $select = new Kwf_Model_Select();
     $select->whereEquals('id', $recipientId);
     $subscribeModelKey = $this->_getParam('subscribeModelKey');
     if (!$subscribeModelKey) {
         $subscribeModelKey = current(array_keys($rs));
     }
     $model = $rs[$subscribeModelKey]['model'];
     $row = Kwf_Model_Abstract::getInstance($model)->getRow($select);
     return $row;
 }
コード例 #12
0
ファイル: Venta.php プロジェクト: jcanevello/BodegaJ
 public function action_registro()
 {
     if ($this->request->method() == 'POST') {
         $aProducto = $this->request->post('prod');
         $name = $this->request->post('nombre_cliente');
         $oOrden = ORM::factory('Orden');
         $oOrden->nombre_cliente = $name;
         $dias = array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado");
         $meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
         $oOrden->fecha_emision = $dias[date('w')] . " " . date('d') . " de " . $meses[date('n') - 1] . " del " . date('Y');
         $oOrden->save();
         foreach ($aProducto as $id_prod => $oProducto) {
             $producto = ORM::factory('Producto', $id_prod);
             $oItem = ORM::factory('Item');
             $oItem->id_orden = $oOrden->id;
             $oItem->id_prod = $id_prod;
             $oItem->cantidad = (int) current($oProducto);
             $oItem->subtotal = (double) $producto->precio * (int) current($oProducto);
             $oItem->save();
             $oOrden->total += $oItem->subtotal;
             $oOrden->save();
             $producto->stock -= $oItem->cantidad;
             $producto->save();
         }
         $this->redirect('/venta/orden_pago/' . $oOrden->id);
         //            $this->redirect('/venta/orden/'.$oOrden->id);
     }
     $aProducto = ORM::factory('Producto')->find_all();
     $this->template->content = View::factory('venta/registro')->set('aProducto', $aProducto);
 }
コード例 #13
0
ファイル: Processor.php プロジェクト: AgenceStratis/migrator
 /**
  * @param mixed $item
  * @return mixed
  * @throws \Exception
  */
 public function convert($item)
 {
     foreach ($this->processors as $field => $actions) {
         // If field doesn't exist:
         // - Create new column with null value
         // - Add new route to this column
         if (!array_key_exists($field, $item)) {
             $item[$field] = null;
             $this->route[$field] = $field;
         }
         // An array of actions has been given
         if (is_array($actions) && count($actions) > 0) {
             foreach ($actions as $action) {
                 // Get action name and options
                 $name = is_array($action) ? key($action) : $action;
                 $options = is_array($action) ? current($action) : null;
                 // Set processor name in CamelCase
                 $name = implode('', array_map('ucwords', explode('_', $name)));
                 // Get processor class from action name
                 $class = 'Stratis\\Component\\Migrator\\Processor\\' . $name . 'Processor';
                 // Check if class exists
                 if (!class_exists($class)) {
                     throw new \Exception($class . ' does not exists');
                 }
                 // Use processor exec function
                 $item[$field] = $class::exec($item[$field], $options, $item);
             }
         }
     }
     return $item;
 }
コード例 #14
0
ファイル: ItemComment.php プロジェクト: hashemgamal/OSClass
 public function extendData($items)
 {
     $prefLocale = osc_current_user_locale();
     $results = array();
     foreach ($items as $item) {
         $descriptions = $this->conn->osc_dbFetchResults('SELECT * FROM %st_item_description WHERE fk_i_item_id = %d', DB_TABLE_PREFIX, $item['fk_i_item_id']);
         $item['locale'] = array();
         foreach ($descriptions as $desc) {
             $item['locale'][$desc['fk_c_locale_code']] = $desc;
         }
         if (isset($item['locale'][$prefLocale])) {
             $item['s_title'] = $item['locale'][$prefLocale]['s_title'];
             $item['s_description'] = $item['locale'][$prefLocale]['s_description'];
             $item['s_what'] = $item['locale'][$prefLocale]['s_what'];
         } else {
             $data = current($item['locale']);
             $item['s_title'] = $data['s_title'];
             $item['s_description'] = $data['s_description'];
             $item['s_what'] = $data['s_what'];
             unset($data);
         }
         $results[] = $item;
     }
     return $results;
 }
コード例 #15
0
 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     $originalValues = $values;
     if (!is_array($this->getOption('column'))) {
         $this->setOption('column', array($this->getOption('column')));
     }
     //if $values isn't an array, make it one
     if (!is_array($values)) {
         //use first column for key
         $columns = $this->getOption('column');
         $values = array($columns[0] => $values);
     }
     $qb = $this->em->createQueryBuilder()->select('a')->from($this->getOption('model'), 'a');
     $i = 0;
     foreach ($this->getOption('column') as $column) {
         if (!array_key_exists($column, $values)) {
             // one of the columns has be removed from the form
             return $originalValues;
         }
         $qb->andWhere('a.' . $column . ' = ?' . ++$i);
         $qb->setParameter($i, $values[$column]);
     }
     $object = current($qb->setMaxResults(1)->getQuery()->execute());
     // if no object or if we're updating the object, it's ok
     if (!$object || $this->isUpdate($object, $values)) {
         return $originalValues;
     }
     $error = new sfValidatorError($this, 'invalid', array('column' => implode(', ', $this->getOption('column'))));
     if ($this->getOption('throw_global_error')) {
         throw $error;
     }
     $columns = $this->getOption('column');
     throw new sfValidatorErrorSchema($this, array($columns[0] => $error));
 }
コード例 #16
0
 /**
  * @group ZF-11258
  */
 public function testZF11258()
 {
     $validator = new File\UploadFile();
     $this->assertFalse($validator->isValid(__DIR__ . '/_files/nofile.mo'));
     $this->assertTrue(array_key_exists('fileUploadFileErrorFileNotFound', $validator->getMessages()));
     $this->assertContains("not found", current($validator->getMessages()));
 }
コード例 #17
0
ファイル: Collection.php プロジェクト: niko-afv/BlogPersonal
 public function current()
 {
     $this->coerceType($this->key());
     if (is_array($this->modelData[$this->collection_key])) {
         return current($this->modelData[$this->collection_key]);
     }
 }
コード例 #18
0
ファイル: bug35022.php プロジェクト: badlamer/hhvm
function foo(&$state)
{
    $contentDict = end($state);
    for ($contentDict = end($state); $contentDict !== false; $contentDict = prev($state)) {
        echo key($state) . " => " . current($state) . "\n";
    }
}
コード例 #19
0
 private function _splitToTokens()
 {
     $content = $this->_doc_content;
     $tmp = array();
     $tmp2 = array();
     $slength = array();
     $content = str_replace(".", " ", $content);
     $tmp = explode(" ", $content);
     foreach ($tmp as $word) {
         // let's count only words with more then 4 chars
         if (mb_strlen($word, $this->_charset) > 3) {
             $tmp2[$word] = $word;
             $slength[$word] = strlen($word);
         }
     }
     array_multisort($slength, SORT_DESC, $tmp2, SORT_ASC);
     $count = count($slength);
     // Save only top15 (by length) sentences/words
     for ($i = 0; $i < $count && $i < 15; $i++) {
         $this->_tokens[] = current($tmp2);
         next($tmp2);
     }
     $this->length = count($this->_tokens);
     return $this;
 }
コード例 #20
0
 function sendAcknowledge($services_id)
 {
     global $DB;
     $pmService = new PluginMonitoringService();
     $pmComponent = new PluginMonitoringComponent();
     $pmTag = new PluginMonitoringTag();
     $pmService->getFromDB($services_id);
     $hostname = '';
     $queryh = "SELECT * FROM `glpi_plugin_monitoring_componentscatalogs_hosts` \n         WHERE `id` = '" . $pmService->fields['plugin_monitoring_componentscatalogs_hosts_id'] . "'\n         LIMIT 1";
     $resulth = $DB->query($queryh);
     while ($datah = $DB->fetch_array($resulth)) {
         $itemtype = $datah['itemtype'];
         $item = new $itemtype();
         if ($item->getFromDB($datah['items_id'])) {
             $hostname = $itemtype . "-" . $datah['items_id'] . "-" . preg_replace("/[^A-Za-z0-9]/", "", $item->fields['name']);
         }
     }
     $a_component = current($pmComponent->find("`id`='" . $pmService->fields['plugin_monitoring_components_id'] . "'", "", 1));
     $service_description = preg_replace("/[^A-Za-z0-9]/", "", $a_component['name']) . "-" . $pmService->fields['id'];
     $tag = PluginMonitoringEntity::getTagByEntities($pmService->fields['entities_id']);
     $ip = $pmTag->getIP($tag);
     $auth = $pmTag->getAuth($tag);
     $url = 'http://' . $ip . ':7760/';
     $action = 'acknowledge';
     $a_fields = array('host_name' => urlencode($hostname), 'service_description' => urlencode($service_description), 'author' => urlencode($_SESSION['glpiname']), 'comment' => urlencode(''));
     $this->sendCommand($url, $action, $a_fields, '', $auth);
 }
コード例 #21
0
 /**
  * Tests all campaigns are returned.
  */
 function testGetAllCampaigns()
 {
     // Insert campaigns
     $numCampaigns = 2;
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'normal campaign';
     $aCampaignId = DataGenerator::generate($doCampaigns, $numCampaigns);
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->campaignname = 'market campaign';
     $doCampaigns->type = DataObjects_Campaigns::CAMPAIGN_TYPE_MARKET_CAMPAIGN_OPTIN;
     $marketCampaignId = DataGenerator::generateOne($doCampaigns);
     // Call method
     $aCampaigns = $this->oDalCampaigns->getAllCampaigns('name', 'up');
     // Test same number of campaigns are returned.
     $this->assertEqual(count($aCampaigns), $numCampaigns);
     // Call method with market campaigns
     $aIncludeSystemTypes = array(DataObjects_Campaigns::CAMPAIGN_TYPE_MARKET_CAMPAIGN_OPTIN);
     $aCampaigns = $this->oDalCampaigns->getAllCampaigns('name', 'up', $aIncludeSystemTypes);
     $this->assertEqual(count($aCampaigns), $numCampaigns + 1);
     // test ordering, fisrt should be market campaign
     reset($aCampaigns);
     $aCampaign = current($aCampaigns);
     $this->assertEqual($aCampaign['campaignname'], 'market campaign');
     // reverse order
     $aCampaigns = $this->oDalCampaigns->getAllCampaigns('name', 'down', $aIncludeSystemTypes);
     $this->assertEqual(count($aCampaigns), $numCampaigns + 1);
     // test ordering, fisrt should be market campaign
     reset($aCampaigns);
     $aCampaign = current($aCampaigns);
     $this->assertEqual($aCampaign['campaignname'], 'market campaign');
 }
コード例 #22
0
 /**
  * Perform operations after collection load
  *
  * @param string $tableName
  * @param string $columnName
  * @return void
  */
 protected function performAfterLoad($tableName, $columnName)
 {
     $items = $this->getColumnValues($columnName);
     if (count($items)) {
         $connection = $this->getConnection();
         $select = $connection->select()->from(['cms_entity_store' => $this->getTable($tableName)])->where('cms_entity_store.' . $columnName . ' IN (?)', $items);
         $result = $connection->fetchPairs($select);
         if ($result) {
             foreach ($this as $item) {
                 $entityId = $item->getData($columnName);
                 if (!isset($result[$entityId])) {
                     continue;
                 }
                 if ($result[$entityId] == 0) {
                     $stores = $this->storeManager->getStores(false, true);
                     $storeId = current($stores)->getId();
                     $storeCode = key($stores);
                 } else {
                     $storeId = $result[$item->getData($columnName)];
                     $storeCode = $this->storeManager->getStore($storeId)->getCode();
                 }
                 $item->setData('_first_store_id', $storeId);
                 $item->setData('store_code', $storeCode);
                 $item->setData('store_id', [$result[$entityId]]);
             }
         }
     }
 }
コード例 #23
0
ファイル: Nip.php プロジェクト: lstaszak/zf_zk_aleph
 public function isValid($sValue)
 {
     $this->_setValue($sValue);
     if (null === self::$_filter) {
         require_once 'Zend/Filter/Digits.php';
         self::$_filter = new Zend_Filter_Digits();
     }
     $sValueFiltered = self::$_filter->filter($sValue);
     $nLength = strlen($sValueFiltered);
     if ($nLength != 10) {
         $this->_error(self::LENGTH);
         return false;
     }
     $nMod = 11;
     $nSum = 0;
     $aWeights = array(6, 5, 7, 2, 3, 4, 5, 6, 7);
     preg_match_all("/\\d/", $sValueFiltered, $aDigits);
     $aValueFiltered = $aDigits[0];
     foreach ($aValueFiltered as $nDigit) {
         $nWeight = current($aWeights);
         $nSum += $nDigit * $nWeight;
         next($aWeights);
     }
     if (($nSum % $nMod == 10 ? 0 : $nSum % $nMod) != $aValueFiltered[$nLength - 1]) {
         $this->_error(self::CHECKSUM, $sValueFiltered);
         return false;
     }
     return true;
 }
コード例 #24
0
ファイル: abstract.php プロジェクト: walteraries/anahita
 /**
  * Parse the segments of a URL.
  *
  * @param   array   The segments of the URL to parse.
  * @return  array   The URL attributes to be used by the application.
  */
 public function parse(&$segments)
 {
     $path = implode('/', $segments);
     $vars = array();
     $matches = array();
     if (preg_match('/(\\d+)-([^\\/]+)/', $path, $matches)) {
         $vars['alias'] = $matches[2];
         $path = str_replace($matches[0], $matches[1], $path);
         $segments = array_filter(explode('/', $path));
     }
     $path = implode('/', $segments);
     $matches = array();
     if (preg_match('/@(\\w+)/', $path, $matches)) {
         $vars['oid'] = $matches[1];
         if (isset($matches[2])) {
             $vars['view'] = $matches[2];
         }
         $path = ltrim(str_replace($matches[0], '', $path), '/');
         $segments = array_filter(explode('/', $path));
     }
     $vars = array_merge($vars, parent::parse($segments));
     if (isset($vars['id']) && current($segments)) {
         $vars['alias'] = array_shift($segments);
     }
     return $vars;
 }
コード例 #25
0
 /**
  * (non-PHPdoc)
  * @see tao_helpers_form_FormContainer::initElements()
  */
 public function initElements()
 {
     $fileName = '';
     $instances = array();
     if (isset($this->data['instance'])) {
         $instance = $this->data['instance'];
         if ($instance instanceof core_kernel_classes_Resource) {
             $instances[$instance->getUri()] = $instance->getLabel();
         }
     } elseif (isset($this->data['class'])) {
         $class = $this->data['class'];
         if ($class instanceof core_kernel_classes_Class) {
             foreach ($class->getInstances() as $instance) {
                 $instances[$instance->getUri()] = $instance->getLabel();
             }
         }
     } else {
         throw new common_Exception('No class nor instance specified for export');
     }
     $instances = tao_helpers_Uri::encodeArray($instances, tao_helpers_Uri::ENCODE_ARRAY_KEYS);
     $descElt = tao_helpers_form_FormFactory::getElement('desc', 'Label');
     $descElt->setValue(__('Enables you to export a published delivery'));
     $this->form->addElement($descElt);
     $instanceElt = tao_helpers_form_FormFactory::getElement('exportInstance', 'Radiobox');
     $instanceElt->setDescription(__('Items'));
     $instanceElt->setAttribute('checkAll', true);
     $instanceElt->setOptions($instances);
     $instanceElt->setValue(current(array_keys($instances)));
     $this->form->addElement($instanceElt);
     $this->form->createGroup('options', __('Export Options'), array('desc', 'filename', 'exportInstance'));
 }
コード例 #26
0
ファイル: FeedViewHandler.php プロジェクト: dstansby/camdram
 /**
  * @param $data array
  * @param format string, either rss or atom
  */
 protected function createFeed(View $view, Request $request)
 {
     $feed = new Feed();
     $data = $view->getData();
     $item = current($data);
     $annotationData = $this->reader->read($item);
     if ($item && ($feedData = $annotationData->getFeed())) {
         $class = get_class($item);
         $feed->setTitle($feedData->getName());
         $feed->setDescription($feedData->getDescription());
         $feed->setLink($this->urlGen->generateCollectionUrl($class));
         $feed->setFeedLink($this->urlGen->generateCollectionUrl($class, $request->getRequestFormat()), $request->getRequestFormat());
     } else {
         $feed->setTitle('Camdram feed');
         $feed->setDescription('Camdram feed');
     }
     $lastModified = null;
     $accessor = PropertyAccess::createPropertyAccessor();
     // Add one or more entries. Note that entries must be manually added once created.
     foreach ($data as $document) {
         $entry = $feed->createEntry();
         $entry->setTitle($accessor->getValue($document, $feedData->getTitleField()));
         $entry->setLink($this->urlGen->generateUrl($document));
         $entry->setDescription($this->twig->render($feedData->getTemplate(), array('entity' => $document)));
         if ($accessor->isReadable($document, $feedData->getUpdatedAtField())) {
             $entry->setDateModified($accessor->getValue($document, $feedData->getUpdatedAtField()));
         }
         $feed->addEntry($entry);
         if (!$lastModified || $entry->getDateModified() > $lastModified) {
             $lastModified = $entry->getDateModified();
         }
     }
     $feed->setDateModified($lastModified);
     return $feed->export($request->getRequestFormat());
 }
コード例 #27
0
ファイル: Details.php プロジェクト: sagmahajan/aswan_release
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $layer = $this->getLayer();
         // if this is a product view page
         if (Mage::registry('product')) {
             // get collection of categories this product is associated with
             $categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
             // if the product is associated with any category
             if ($categories->count()) {
                 // show products from this category
                 $this->setCategoryId(current($categories->getIterator()));
             }
         }
         $origCategory = null;
         if ($this->getCategoryId()) {
             $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
             if ($category->getId()) {
                 $origCategory = $layer->getCurrentCategory();
                 $layer->setCurrentCategory($category);
             }
         }
         $this->_productCollection = $layer->getProductCollection();
         if ($origCategory) {
             $layer->setCurrentCategory($origCategory);
         }
     }
     return $this->_productCollection;
 }
コード例 #28
0
ファイル: List.php プロジェクト: shebin512/Magento_Zoff
 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $layer = $this->getLayer();
         /* @var $layer Mage_Catalog_Model_Layer */
         if ($this->getShowRootCategory()) {
             $this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
         }
         // if this is a product view page
         if (Mage::registry('product')) {
             // get collection of categories this product is associated with
             $categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
             // if the product is associated with any category
             if ($categories->count()) {
                 // show products from this category
                 $this->setCategoryId(current($categories->getIterator()));
             }
         }
         $origCategory = null;
         if ($this->getCategoryId()) {
             $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
             if ($category->getId()) {
                 $origCategory = $layer->getCurrentCategory();
                 $layer->setCurrentCategory($category);
             }
         }
         // $this->_productCollection = $layer->getProductCollection();
         $this->_productCollection = $layer->getProductCollection()->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id', 'is_in_stock>=0', 'left')->setOrder('inventory_in_stock', 'desc');
         $this->prepareSortableFieldsByCategory($layer->getCurrentCategory());
         if ($origCategory) {
             $layer->setCurrentCategory($origCategory);
         }
     }
     return $this->_productCollection;
 }
コード例 #29
0
ファイル: actions.class.php プロジェクト: noikiy/qdpm
 public function executeIndex(sfWebRequest $request)
 {
     app::setPageTitle('Gantt Chart', $this->getResponse());
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTasksAccess('view', false, $this->projects);
     } else {
         $this->checkTasksAccess('view');
     }
     if (!$this->getUser()->hasAttribute('gantt_filter' . $this->get_pid($request))) {
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), Tasks::getDefaultFilter($request, $this->getUser(), 'ganttChart'));
     }
     $this->filter_by = $this->getUser()->getAttribute('gantt_filter' . $this->get_pid($request));
     if ($fb = $request->getParameter('filter_by')) {
         $this->filter_by[key($fb)] = current($fb);
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by);
         $this->redirect('ganttChart/index' . $this->add_pid($request));
     }
     if ($request->hasParameter('remove_filter')) {
         unset($this->filter_by[$request->getParameter('remove_filter')]);
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by);
         $this->redirect('ganttChart/index' . $this->add_pid($request));
     }
     $this->tasks_tree = array();
     $this->tasks_list = $this->getTasks($request, $this->tasks_tree);
 }
コード例 #30
0
 function definition()
 {
     $mform =& $this->_form;
     $mnet_peer =& $this->_customdata['peer'];
     $myservices =& mnet_get_service_info($mnet_peer);
     $mform->addElement('hidden', 'hostid', $mnet_peer->id);
     $count = 0;
     foreach ($myservices as $name => $versions) {
         $version = current($versions);
         $langmodule = ($version['plugintype'] == 'mod' ? '' : $version['plugintype'] . '_') . $version['pluginname'];
         // TODO there should be a moodle-wide way to do this
         if ($count > 0) {
             $mform->addElement('html', '<hr />');
         }
         $mform->addElement('html', '<h3>' . get_string($name . '_name', $langmodule, $mnet_peer->name) . '</h3>' . get_string($name . '_description', $langmodule, $mnet_peer->name));
         $mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
         $pubstr = get_string('publish', 'mnet');
         if (!empty($version['hostsubscribes'])) {
             $pubstr .= ' <a class="notifysuccess" title="' . s(get_string('issubscribed', 'mnet', $mnet_peer->name)) . '">&radic;</a> ';
         }
         $mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
         $substr = get_string('subscribe', 'mnet');
         if (!empty($version['hostpublishes'])) {
             $substr .= ' <a class="notifysuccess" title="' . s(get_string('ispublished', 'mnet', $mnet_peer->name)) . '">&radic;</a> ';
         }
         $mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid'] . ']', $substr);
         $count++;
     }
     $this->add_action_buttons();
 }