コード例 #1
0
ファイル: FeatureTrait.php プロジェクト: pfitz/php-leaflet
 /**
  * Create feature of the given definition.
  *
  * @return Feature
  */
 protected function createFeature()
 {
     $feature = new Feature($this, $this->getId());
     $feature->setProperty('type', lcfirst(static::getType()));
     $feature->setProperty('options', $this->getOptions());
     return $feature;
 }
コード例 #2
0
 /**
  * Set an individual feature and its status
  *
  * @param string     $featureLabel
  * @param bool|array $status
  */
 public function setFeatureStatus($featureLabel, $status)
 {
     if (isset($this->featureFlags[$featureLabel])) {
         $feature = $this->get($featureLabel);
     } else {
         $feature = new Feature($featureLabel);
     }
     if (is_array($status)) {
         $feature->setStatus($status);
     } else {
         $feature->setBooleanStatus($status);
     }
     $this->featureFlags[$featureLabel] = $feature;
 }
コード例 #3
0
ファイル: subscript.php プロジェクト: andrewkrug/repucaution
 /**
  * Show list of plans
  */
 public function plans()
 {
     if (!$this->ion_auth->logged_in()) {
         redirect('/auth');
     }
     $user = $this->getUser();
     $feature = new Feature();
     $plan = new Plan();
     $this->template->layout = 'layouts/customer_settings';
     $this->template->set('features', $feature->get());
     $this->template->set('plans', $plan->getActualPlansWithoutActive($user));
     $this->template->set('user', $user);
     $this->template->set('options', $this->config->config['period_qualifier']);
     $this->template->render();
 }
コード例 #4
0
 public function processFeatures()
 {
     if (!Feature::isFeatureActive()) {
         return;
     }
     if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) {
         // delete all objects
         $product->deleteFeatures();
         // add new objects
         $languages = Language::getLanguages(false);
         foreach ($_POST as $key => $val) {
             if (preg_match('/^feature_([0-9]+)_value/i', $key, $match)) {
                 if (!empty($val)) {
                     foreach ($val as $v) {
                         $product->addFeaturesToDB($match[1], $v);
                     }
                 } else {
                     if ($default_value = $this->checkFeatures($languages, $match[1])) {
                         $id_value = $product->addFeaturesToDB($match[1], 0, 1);
                         foreach ($languages as $language) {
                             if ($cust = Tools::getValue('custom_' . $match[1] . '_' . (int) $language['id_lang'])) {
                                 $product->addFeaturesCustomToDB($id_value, (int) $language['id_lang'], $cust);
                             } else {
                                 $product->addFeaturesCustomToDB($id_value, (int) $language['id_lang'], $default_value);
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $this->errors[] = Tools::displayError('A product must be created before adding features.');
     }
 }
コード例 #5
0
 function getContent()
 {
     $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>');
     // Smarty
     $template_vars = array('id_tab' => Tools::getValue('id_tab'), 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'token' => Tools::getValue('token'), 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), '_module_dir_' => _MODULE_DIR_, 'ebay_categories' => EbayCategoryConfiguration::getEbayCategories($this->ebay_profile->id), 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'possible_attributes' => AttributeGroup::getAttributesGroups($this->context->cookie->id_lang), 'possible_features' => Feature::getFeatures($this->context->cookie->id_lang, true), 'date' => pSQL(date('Ymdhis')), 'conditions' => $this->_translatePSConditions(EbayCategoryConditionConfiguration::getPSConditions()), 'form_items_specifics' => EbaySynchronizer::getNbSynchronizableEbayCategoryCondition(), 'form_items_specifics_mixed' => EbaySynchronizer::getNbSynchronizableEbayCategoryConditionMixed(), 'isOneDotFive' => $is_one_dot_five);
     return $this->display('formItemsSpecifics.tpl', $template_vars);
 }
コード例 #6
0
    public static function getFrontFeaturesStatic($id_lang, $id_product)
    {
        if (!Feature::isFeatureActive()) {
            return array();
        }
        if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) {
            self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT name, value, pf.id_feature
				FROM ' . _DB_PREFIX_ . 'feature_product pf
				LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'feature f ON (f.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ')
				' . Shop::addSqlAssociation('feature', 'f') . '
				WHERE pf.id_product = ' . (int) $id_product . '
				ORDER BY f.position ASC');
        }
        $features = self::$_frontFeaturesCache[$id_product . '-' . $id_lang];
        foreach ($features as &$feature) {
            if ($feature['id_feature'] == 9 && Context::getContext()->language->id != 1) {
                $feature['value'] = Tools::rus2translit($feature['value']);
            }
        }
        return $features;
        //return self::$_frontFeaturesCache[$id_product.'-'.$id_lang];
    }
コード例 #7
0
 function getContent()
 {
     // Check if the module is configured
     if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
         return '<p class="error"><b>' . $this->ebay->l('Please configure the \'General settings\' tab before using this tab') . '</b></p><br /><script type="text/javascript">$("#menuTab4").addClass("wrong")</script>';
     }
     $iso = $this->context->language->iso_code;
     $iso_tiny_mce = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     // Display Form
     $url_vars = array('id_tab' => '4', 'section' => 'template');
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $url_vars['controller'] = Tools::getValue('controller');
     } else {
         $url_vars['tab'] = Tools::getValue('tab');
     }
     $action_url = $this->_getUrl($url_vars);
     if (Tools::getValue('reset_template')) {
         $ebay_product_template = EbayProductTemplate::getContent($this->ebay, $this->smarty);
     } else {
         $ebay_product_template = Tools::getValue('ebay_product_template', $this->ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE'));
     }
     $ebay_product_template_title = $this->ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE_TITLE');
     $smarty_vars = array('action_url' => $action_url, 'ebay_product_template' => $ebay_product_template, 'ebay_product_template_title' => $ebay_product_template_title, 'features_product' => Feature::getFeatures($this->context->language->id), 'ad' => dirname($_SERVER['PHP_SELF']), 'base_uri' => __PS_BASE_URI__, 'is_one_dot_three' => Tools::substr(_PS_VERSION_, 0, 3) == '1.3', 'is_one_dot_five' => version_compare(_PS_VERSION_, '1.5', '>'), 'theme_css_dir' => _THEME_CSS_DIR_);
     if (Tools::substr(_PS_VERSION_, 0, 3) == '1.3') {
         $smarty_vars['theme_name'] = _THEME_NAME_;
         $smarty_vars['language'] = file_exists(_PS_ROOT_DIR_ . '/js/tinymce/jscripts/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     } elseif (version_compare(_PS_VERSION_, '1.5', '>')) {
         $smarty_vars['iso'] = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     } else {
         $smarty_vars['iso_type_mce'] = $iso_tiny_mce;
         $smarty_vars['ps_js_dir'] = _PS_JS_DIR_;
     }
     return $this->display('formTemplateManager.tpl', $smarty_vars);
 }
コード例 #8
0
 public function create_sql($sql_type, $data)
 {
     if (Feature::is_check_user_login($sql_type)) {
         return new Check_user_login_sql($data);
     } else {
         if (Feature::is_add_receipt($sql_type)) {
             return new Add_receipt_sql($data);
         } else {
             if (Feature::is_remove_product($sql_type)) {
                 return new Remove_product_sql($data);
             } else {
                 if (Feature::is_push_alter_product_data($sql_type)) {
                     return new Push_alter_product_data_sql($data);
                 } else {
                     if (Feature::is_push_new_product_data($sql_type)) {
                         return new Push_new_product_data_sql($data);
                     } else {
                         if (Feature::is_get_list_of_product_info($sql_type)) {
                             return new Get_list_of_product_info_sql($data);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #9
0
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $shops = Shop::getShops();
     if (count($this->context->employee->getAssociatedShops()) > 1) {
         $shops = array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), $shops);
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Specific price rules')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'options' => array('query' => $shops, 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency:'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group:'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity:'), 'name' => 'from_quantity', 'size' => 6, 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.):'), 'name' => 'price', 'size' => 6, 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'date', 'label' => $this->l('From:'), 'name' => 'from', 'size' => 12), array('type' => 'date', 'label' => $this->l('To:'), 'name' => 'to', 'size' => 12), array('type' => 'select', 'label' => $this->l('Reduction type:'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Reduction:'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 2);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 2), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
コード例 #10
0
 public function initFieldsetFeaturesDetachables()
 {
     $this->fields_form[2]['form'] = array('legend' => array('title' => $this->l('Optional features'), 'icon' => 'icon-puzzle-piece'), 'description' => $this->l('Some features can be disabled in order to improve performance.'), 'input' => array(array('type' => 'hidden', 'name' => 'features_detachables_up'), array('type' => 'switch', 'label' => $this->l('Combinations'), 'name' => 'combination', 'is_bool' => true, 'disabled' => Combination::isCurrentlyUsed(), 'values' => array(array('id' => 'combination_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'combination_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Product Combinations.'), 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null), array('type' => 'switch', 'label' => $this->l('Features'), 'name' => 'feature', 'is_bool' => true, 'values' => array(array('id' => 'feature_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'feature_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Product Features.')), array('type' => 'switch', 'label' => $this->l('Customer Groups'), 'name' => 'customer_group', 'is_bool' => true, 'disabled' => Group::isCurrentlyUsed(), 'values' => array(array('id' => 'group_1', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'group_0', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('Choose "No" to disable Customer Groups.'))), 'submit' => array('title' => $this->l('Save')));
     $this->fields_value['combination'] = Combination::isFeatureActive();
     $this->fields_value['feature'] = Feature::isFeatureActive();
     $this->fields_value['customer_group'] = Group::isFeatureActive();
 }
コード例 #11
0
 public function ajaxProcessUpdatePositions()
 {
     if ($this->tabAccess['edit'] === '1') {
         $way = (int) Tools::getValue('way');
         $id = (int) Tools::getValue('id');
         $table = 'feature';
         $positions = Tools::getValue($table);
         if (empty($positions)) {
             $table = 'feature_value';
             $positions = Tools::getValue($table);
         }
         $new_positions = array();
         foreach ($positions as $v) {
             if (!empty($v)) {
                 $new_positions[] = $v;
             }
         }
         foreach ($new_positions as $position => $value) {
             $pos = explode('_', $value);
             if (isset($pos[2]) && (int) $pos[2] === $id) {
                 if ($table == 'feature') {
                     if ($feature = new Feature((int) $pos[2])) {
                         if (isset($position) && $feature->updatePosition($way, $position, $id)) {
                             echo 'ok position ' . (int) $position . ' for feature ' . (int) $pos[1] . '\\r\\n';
                         } else {
                             echo '{"hasError" : true, "errors" : "Can not update feature ' . (int) $id . ' to position ' . (int) $position . ' "}';
                         }
                     } else {
                         echo '{"hasError" : true, "errors" : "This feature (' . (int) $id . ') can t be loaded"}';
                     }
                     break;
                 } elseif ($table == 'feature_value') {
                     if ($feature_value = new FeatureValue((int) $pos[2])) {
                         if (isset($position) && $feature_value->updatePosition($way, $position, $id)) {
                             echo 'ok position ' . (int) $position . ' for feature value ' . (int) $pos[2] . '\\r\\n';
                         } else {
                             echo '{"hasError" : true, "errors" : "Can not update feature value ' . (int) $id . ' to position ' . (int) $position . ' "}';
                         }
                     } else {
                         echo '{"hasError" : true, "errors" : "This feature value (' . (int) $id . ') can t be loaded"}';
                     }
                     break;
                 }
             }
         }
     }
 }
コード例 #12
0
ファイル: Placemark.php プロジェクト: jtet/php-libkml
 public function toExtGeoJSON()
 {
     $json_data = parent::toExtGeoJSON();
     if (isset($this->geometry)) {
         $json_data = array_merge($json_data, array('type' => 'Feature', 'geometry' => $this->geometry->toJSON()));
     }
     return $json_data;
 }
コード例 #13
0
 /**
  *	Set the active user ID to work with.
  *
  *	@param $ID int The user's ID
  **/
 public static function setUser($ID = FALSE)
 {
     if (!$ID) {
         return;
     }
     $ID = (int) $ID;
     self::$current_user = $ID;
 }
コード例 #14
0
ファイル: Container.php プロジェクト: jtet/php-libkml
 public function __toString()
 {
     $parent_string = parent::__toString();
     $output = array();
     $output[] = $parent_string;
     foreach ($this->features as $feature) {
         $output[] = $feature->__toString();
     }
     return implode("\n", $output);
 }
コード例 #15
0
ファイル: configure.php プロジェクト: swk/bluebox
 public function finalizeInstall()
 {
     try {
         Feature::reregister('intercom', 'intercom', 'Intercom', 'Two-way intercom feature, dial feature number and extension', User::TYPE_SYSTEM_ADMIN);
     } catch (FeatureException $e) {
         if ($e->getCode() != 0 || $e->getCode() == -2) {
             throw $e;
         }
     }
 }
コード例 #16
0
 public function getValue($source)
 {
     $value = '';
     if (array_key_exists('feature', $source)) {
         $values = Feature::where('id', '=', $source['feature']);
         if ($values->count()) {
             $value = $values->first()->feature;
         }
     }
     return $value;
 }
コード例 #17
0
ファイル: import.php プロジェクト: tianxang/php-handwriting
function import()
{
    try {
        $page = isset($_GET['page']) ? $_GET['page'] : null;
        if ($page == 0) {
            del_feature();
        }
        $results = get_writing($page);
        $size = sizeof($results);
        foreach ($results as $r) {
            $f = new Feature();
            $w = json_decode($r->writing);
            $char_id = $r->char_id;
            $features = $f->make_feature($w);
            //获取特征
            $dic = new Dictionary();
            $dict_feature = $dic->get_feature($char_id);
            //获取数据库中已存的特征值
            $dict_feature = isset($dict_feature) ? json_decode($dict_feature) : null;
            $t = new Trainer();
            $t->train($features, $dict_feature);
            $c = new Character();
            $first_stroke_type = $c->get_first_stroke_type($w);
            //首笔的笔画类型(横竖撇点折)
            $int_strokes = sizeof($w->s);
            //笔画数
            $dic->update_character($char_id, json_encode($t->train_features), $int_strokes, $first_stroke_type);
        }
        if ($size > 0) {
            echo "<meta HTTP-EQUIV=REFRESH CONTENT='5;URL=import.php?page=" . ($page + 1) . "'>";
        } else {
            echo "导入完成";
        }
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
 public function getCMSFields()
 {
     $fields = new FieldList();
     $feature = $this->Feature();
     if ($feature->exists()) {
         $fields->push(ReadonlyField::create("FeatureTitle", "Feature", $feature->Title));
         $fields->push($feature->getValueField());
     } else {
         $selected = Feature::get()->innerJoin("ProductFeatureValue", "Feature.ID = ProductFeatureValue.FeatureID")->filter("ProductFeatureValue.ProductID", Controller::curr()->currentPageID())->getIDList();
         $features = Feature::get()->filter("ID:not", $selected);
         $fields->push(DropdownField::create("FeatureID", "Feature", $features->map()->toArray()));
         $fields->push(LiteralField::create("creationnote", "<p class=\"message\">You can choose a value for this feature after saving.</p>"));
     }
     return $fields;
 }
コード例 #19
0
ファイル: Overlay.php プロジェクト: jtet/php-libkml
 public function __toString()
 {
     $parent_string = parent::__toString();
     $output = array();
     $output[] = $parent_string;
     if (isset($this->color)) {
         $output[] = sprintf("<color>%s</color>", $this->color);
     }
     if (isset($this->drawOrder)) {
         $output[] = sprintf("<drawOrder>%s</drawOrder>", $this->drawOrder);
     }
     if (isset($this->icon)) {
         $output[] = $this->icon->__toString();
     }
     return implode("\n", $output);
 }
コード例 #20
0
    /**
     * Display form
     *
     * @global string $currentIndex Current URL in order to keep current Tab
     */
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        echo '
		<h2>' . $this->l('Add a new feature value') . '</h2>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . Tools::getValue('token') . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_feature_value" value="' . $obj->id . '" />' : '') . '
			<fieldset class="width2">
				<legend><img src="../img/t/AdminFeatures.gif" />' . $this->l('Add a new feature value') . '</legend>
				<label>' . $this->l('Value:') . ' </label>
				<div class="margin-form">';
        foreach ($this->_languages as $language) {
            echo '
					<div id="value_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input size="33" type="text" name="value_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'value', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>
					<script type="text/javascript">
						var flag_fields = \'value\';
					</script>';
        }
        $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'value', false, true);
        echo '
					<div class="clear"></div>
				</div>
				<label>' . $this->l('Feature:') . ' </label>
				<div class="margin-form">
					<select name="id_feature">';
        $features = Feature::getFeatures($this->_defaultFormLanguage);
        foreach ($features as $feature) {
            echo '<option value="' . $feature['id_feature'] . '"' . ($this->getFieldValue($obj, 'id_feature') == $feature['id_feature'] ? ' selected="selected"' : '') . '>' . $feature['name'] . '</option>';
        }
        echo '
					</select><sup> *</sup>
				</div>
				' . Module::hookExec('featureValueForm', array('id_feature_value' => $obj->id)) . '
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab("Root.Features", $grid = GridField::create("Features", "Features", $this->owner->Features(), GridFieldConfig_RecordEditor::create()));
     $grid->getConfig()->removeComponentsByType('GridFieldDataColumns')->removeComponentsByType('GridFieldAddNewButton')->addComponent(new GridFieldAddNewInlineButton())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldOrderableRows());
     $grid->getConfig()->getComponentByType('GridFieldEditableColumns')->setDisplayFields(array('FeatureID' => function ($record, $column, $grid) {
         $dropdown = new DropdownField($column, 'Feature', Feature::get()->map('ID', 'Title')->toArray());
         $dropdown->addExtraClass('on_feature_select_fetch_value_field');
         return $dropdown;
     }, 'Value' => function ($record, $column, $grid) {
         if ($record->FeatureID) {
             $field = $record->Feature()->getValueField();
             $field->setName($column);
             return $field;
         }
         return new HiddenField($column);
     }));
 }
コード例 #22
0
 public function process()
 {
     parent::process();
     $hasProduct = false;
     $product_list = Tools::getValue('compare_product_list');
     $postProducts = isset($product_list) ? rtrim($product_list, '|') : '';
     if (!Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
         return Tools::redirect('404.php');
     }
     if ($postProducts) {
         $ids = array_unique(explode('|', $postProducts));
         if (sizeof($ids) > 0) {
             if (sizeof($ids) > Configuration::get('PS_COMPARATOR_MAX_ITEM')) {
                 $ids = array_slice($ids, 0, Configuration::get('PS_COMPARATOR_MAX_ITEM'));
             }
             $listProducts = array();
             $listFeatures = array();
             foreach ($ids as $id) {
                 $curProduct = new Product((int) $id, true, (int) self::$cookie->id_lang);
                 if (!Validate::isLoadedObject($curProduct)) {
                     continue;
                 }
                 if (!$curProduct->active) {
                     unset($ids[$k]);
                     continue;
                 }
                 foreach ($curProduct->getFrontFeatures(self::$cookie->id_lang) as $feature) {
                     $listFeatures[$curProduct->id][$feature['id_feature']] = $feature['value'];
                 }
                 $cover = Product::getCover((int) $id);
                 $curProduct->id_image = Tools::htmlentitiesUTF8(Product::defineProductImage(array('id_image' => $cover['id_image'], 'id_product' => $id), self::$cookie->id_lang));
                 $curProduct->allow_oosp = Product::isAvailableWhenOutOfStock($curProduct->out_of_stock);
                 $listProducts[] = $curProduct;
             }
             if (sizeof($listProducts) > 0) {
                 $width = 80 / sizeof($listProducts);
                 $hasProduct = true;
                 $ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang);
                 self::$smarty->assign(array('ordered_features' => $ordered_features, 'product_features' => $listFeatures, 'products' => $listProducts, 'link' => new Link(), 'width' => $width, 'homeSize' => Image::getSize('home')));
                 self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
             }
         }
     }
     self::$smarty->assign('hasProduct', $hasProduct);
 }
コード例 #23
0
ファイル: NetworkLink.php プロジェクト: cdyweb/php-libkml
 public function __toString()
 {
     $parent_string = parent::__toString();
     $output = array();
     $output[] = sprintf("<NetworkLink%s>", isset($this->id) ? sprintf(" id=\"%s\"", $this->id) : "");
     $output[] = $parent_string;
     if (isset($this->refreshVisibility)) {
         $output[] = sprintf("\t<refreshVisibility>%d<refreshVisibility>", $this->refreshVisibility);
     }
     if (isset($this->flyToView)) {
         $output[] = sprintf("\t<flyToView>%d<flyToView>", $this->flyToView);
     }
     if (isset($this->link)) {
         $output[] = $this->link->__toString();
     }
     $output[] = "</NetworkLink>";
     return implode("\n", $output);
 }
 public function index($request)
 {
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(403);
     }
     $id = $request->getVar('ID');
     if (!$id) {
         return $this->httpError(400);
     }
     $feature = Feature::get()->byId($id);
     if (!$feature) {
         return $this->httpError(404);
     }
     if (!$feature->canView()) {
         return $this->httpError(403);
     }
     $field = $feature->getValueField()->setName($request->getVar('Name'));
     return $field->forTemplate();
 }
コード例 #25
0
    /**
     * Display form
     *
     * @global string $currentIndex Current URL in order to keep current Tab
     */
    public function displayForm($token = NULL)
    {
        global $currentIndex;
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $languages = Language::getLanguages();
        $obj = $this->loadObject(true);
        echo '
		<script type="text/javascript">
			id_language = Number(' . $defaultLanguage . ');
		</script>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . ($token ? $token : $this->token) . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_feature_value" value="' . $obj->id . '" />' : '') . '
			<fieldset class="width3"><legend><img src="../img/t/AdminFeatures.gif" />' . $this->l('Value') . '</legend>
				<label>' . $this->l('Value:') . ' </label>
				<div class="margin-form">';
        foreach ($languages as $language) {
            echo '
					<div id="value_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
						<input size="33" type="text" name="value_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'value', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, 'value', 'value');
        echo '
					<div style="clear: both;"></div>
				</div>
				<label>' . $this->l('Feature:') . ' </label>
				<div class="margin-form">
					<select name="id_feature">';
        $features = Feature::getFeatures($defaultLanguage);
        foreach ($features as $feature) {
            echo '<option value="' . $feature['id_feature'] . '"' . ($this->getFieldValue($obj, 'id_feature') == $feature['id_feature'] ? ' selected="selected"' : '') . '>' . $feature['name'] . '</option>';
        }
        echo '
					</select><sup> *</sup>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
コード例 #26
0
    public static function getFrontFeaturesStatic($id_lang, $id_product)
    {
        if (!Feature::isFeatureActive()) {
            return array();
        }
        if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) {
            self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT name, GROUP_CONCAT(value ORDER BY fv.position SEPARATOR ", ") AS value, pf.id_feature
				FROM ' . _DB_PREFIX_ . 'feature_product pf
				LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = ' . (int) $id_lang . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ')
				LEFT JOIN ' . _DB_PREFIX_ . 'feature f ON f.id_feature = pf.id_feature
				LEFT JOIN ' . _DB_PREFIX_ . 'feature_value fv ON fv.id_feature_value = pf.id_feature_value
				' . Shop::addSqlAssociation('feature', 'f') . '
				WHERE pf.id_product = ' . (int) $id_product . '
				GROUP BY name, pf.id_feature
				ORDER BY f.position ASC');
        }
        return self::$_frontFeaturesCache[$id_product . '-' . $id_lang];
    }
コード例 #27
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['CriteriaSearchCategoryFeature'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['CriteriaSearchCategoryFeature'][$this->getPrimaryKey()] = true;
     $keys = CriteriaSearchCategoryFeatureTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getCategoryId(), $keys[2] => $this->getFeatureId(), $keys[3] => $this->getSearchable());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aCategory) {
             $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aFeature) {
             $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
コード例 #28
0
 public static function getFrontFeaturesStatic($id_lang, $id_product)
 {
     if (!Feature::isFeatureActive()) {
         return array();
     }
     if (!array_key_exists($id_product . '-' . $id_lang, self::$_frontFeaturesCache)) {
         if (Module::isInstalled('blocklayered') && Module::isEnabled('blocklayered')) {
             Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('SET @@group_concat_max_len = 4096');
             self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
                 SELECT `name`, GROUP_CONCAT(value ORDER BY `fv`.`position` SEPARATOR ", ") AS `value`, `pf`.`id_feature`, `liflv`.`url_name`, `liflv`.`meta_title`
                 FROM `' . _DB_PREFIX_ . 'feature_product` `pf`
                 LEFT JOIN `' . _DB_PREFIX_ . 'feature_lang` `fl` ON (`fl`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = ' . (int) $id_lang . ')
                 LEFT JOIN `' . _DB_PREFIX_ . 'feature_value_lang` `fvl` ON (`fvl`.`id_feature_value` = `pf`.`id_feature_value` AND `fvl`.`id_lang` = ' . (int) $id_lang . ')
                 LEFT JOIN `' . _DB_PREFIX_ . 'feature` `f` ON (`f`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = ' . (int) $id_lang . ')
                 LEFT JOIN ' . _DB_PREFIX_ . 'feature_value `fv` ON `fv`.`id_feature_value` = `pf`.`id_feature_value`
                 LEFT JOIN `' . _DB_PREFIX_ . 'layered_indexable_feature_lang_value` `liflv` ON (`f`.`id_feature` = `liflv`.`id_feature` AND `liflv`.`id_lang` = ' . (int) $id_lang . ')
                 ' . Shop::addSqlAssociation('feature', 'f') . '
                 WHERE pf.`id_product` = ' . (int) $id_product . '
                 GROUP BY `name`, pf.`id_feature`
                 ORDER BY f.`position` ASC');
         } else {
             Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('SET @@group_concat_max_len = 4096');
             self::$_frontFeaturesCache[$id_product . '-' . $id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
                 SELECT `name`, GROUP_CONCAT(value ORDER BY `fv`.`position` SEPARATOR ", ") AS `value`, `pf`.`id_feature`
                 FROM ' . _DB_PREFIX_ . 'feature_product `pf`
                 LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang `fl` ON (`fl`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = ' . (int) $id_lang . ')
                 LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang `fvl` ON (`fvl`.`id_feature_value` = `pf`.`id_feature_value` AND `fvl`.`id_lang` = ' . (int) $id_lang . ')
                 LEFT JOIN ' . _DB_PREFIX_ . 'feature `f` ON `f`.`id_feature` = `pf`.`id_feature`
                 LEFT JOIN ' . _DB_PREFIX_ . 'feature_value `fv` ON `fv`.`id_feature_value` = `pf`.`id_feature_value`
                 ' . Shop::addSqlAssociation('feature', 'f') . '
                 WHERE pf.id_product = ' . (int) $id_product . '
                 GROUP BY `name`, pf.`id_feature`
                 ORDER BY f.`position` ASC');
         }
     }
     return self::$_frontFeaturesCache[$id_product . '-' . $id_lang];
 }
コード例 #29
0
ファイル: auth.php プロジェクト: andrewkrug/repucaution
 public function plans()
 {
     $post = $this->input->post();
     if (!empty($post)) {
         if (isset($post['planId'])) {
             $selectedPlan = $post['planId'];
             redirect('auth/register/' . $selectedPlan, 'refresh');
         }
     }
     $feature = new Feature();
     $plan = new Plan();
     $this->template->set('features', $feature->get());
     $withTrial = !$this->ion_auth->logged_in();
     CssJs::getInst()->add_js('libs/eq-height.js');
     $this->template->set('plans', $plan->getActualPlans($withTrial));
     $this->template->set('options', $this->config->config['period_qualifier']);
     $this->template->render();
 }
コード例 #30
0
ファイル: Search.php プロジェクト: rongandat/vatfairfoot
    public static function getFeatures($db, $id_product, $id_lang)
    {
        if (!Feature::isFeatureActive()) {
            return '';
        }
        $features = '';
        $featuresArray = $db->executeS('
		SELECT fvl.value FROM ' . _DB_PREFIX_ . 'feature_product fp
		LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fp.id_feature_value = fvl.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ')
		WHERE fp.id_product = ' . (int) $id_product);
        foreach ($featuresArray as $feature) {
            $features .= $feature['value'] . ' ';
        }
        return $features;
    }