Пример #1
0
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param integer $fieldID, the current field id (only for poly object compatibility)
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        $return = parent::getHTMLAdmin($fieldID, $language, $prefixName);
        global $cms_user;
        $params = $this->getParamsValues();
        $prefixName = isset($inputParams['prefix']) ? $inputParams['prefix'] : '';
        $rootCategory = isset($inputParams['root']) && SensitiveIO::isPositiveInteger($inputParams['root']) ? $inputParams['root'] : false;
        //get module codename
        $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
        if ($params['multiCategories']) {
            // Get categories
            $a_all_categories = $this->getAllCategoriesAsArray($language, false, $moduleCodename, CLEARANCE_MODULE_EDIT, $rootCategory, true);
            $checkedValues = array();
            if (isset($this->_subfieldValues[0]) && is_object($this->_subfieldValues[0]) && !is_null($this->_subfieldValues[0]->getValue()) && $this->_subfieldValues[0]->getID()) {
                foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                    if (is_object($this->_subfieldValues[$subFieldID])) {
                        $checkedValues[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                    }
                }
            } elseif (sensitiveIO::isPositiveInteger($params['defaultValue'])) {
                $checkedValues[$params['defaultValue']] = $params['defaultValue'];
            }
            $valueString = implode(',', $checkedValues);
            if (is_array($a_all_categories) && $a_all_categories) {
                $fathers = array(0 => false);
                foreach ($a_all_categories as $id => $category) {
                    $level = substr_count($category, '- ');
                    $father = false;
                    if ($level && isset($fathers[$level - 1])) {
                        $father = $fathers[$level - 1];
                    }
                    $cat = new stdClass();
                    $cat->id = $id;
                    $cat->checked = isset($checkedValues[$id]);
                    $cat->cls = isset($checkedValues[$id]) ? 'x-tree-checked' : '';
                    $cat->level = $level;
                    $cat->text = str_replace('- ', '', $category);
                    if (strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8') {
                        $cat->text = io::utf8Encode($cat->text);
                    }
                    $cat->leaf = true;
                    $fathers[$level] = $cat;
                    if ($father) {
                        $father->children[] = $cat;
                        $father->leaf = false;
                        $father->expanded = true;
                    } else {
                        $availableCategories[] = $cat;
                    }
                }
            } else {
                $availableCategories[] = array('id' => '', 'text' => $language->getMessage(self::MESSAGE_EMPTY_OBJECTS_SET), 'leaf' => true);
            }
            $fieldId = md5(mt_rand() . microtime());
            $field = array();
            $field['id'] = 'tree-' . $fieldId;
            $field['xtype'] = 'treepanel';
            $field['height'] = io::isPositiveInteger($params['selectHeight']) ? (int) $params['selectHeight'] : 150;
            $field['width'] = io::isPositiveInteger($params['selectWidth']) ? (int) $params['selectWidth'] : '100%';
            $field['autoScroll'] = true;
            $field['animate'] = true;
            $field['containerScroll'] = true;
            $field['rootVisible'] = false;
            $field['root'] = array('expanded' => true, 'children' => $availableCategories);
            $field['listeners'] = array('checkchange' => array('fn' => sensitiveIO::sanitizeJSString('function(node, checked){
						var tree = Ext.getCmp(\'tree-' . $fieldId . '\');
						var input = Ext.getCmp(\'cat-' . $fieldId . '\');
						if (tree && input) {
							input.setValue(tree.getChecked(\'id\').toString());
						}
						if(checked){
		                    node.getUI().addClass(\'x-tree-checked\');
		                }else{
		                    node.getUI().removeClass(\'x-tree-checked\');
		                }
					}', false, false)));
            $return['xtype'] = 'compositefield';
            $return['labelWidth'] = 120;
            $return['items'] = array($field, array('id' => 'cat-' . $fieldId, 'xtype' => 'hidden', 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]', 'value' => $valueString));
        } else {
            if (isset($this->_subfieldValues[0]) && is_object($this->_subfieldValues[0]) && !is_null($this->_subfieldValues[0]->getValue()) && $this->_subfieldValues[0]->getID()) {
                $selectedValue = $this->_subfieldValues[0]->getValue() ? $this->_subfieldValues[0]->getValue() : '';
            } elseif (sensitiveIO::isPositiveInteger($params['defaultValue'])) {
                $selectedValue = $params['defaultValue'];
            } else {
                $selectedValue = '';
            }
            $return['xtype'] = 'atmCombo';
            $return['name'] = 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]';
            $return['hiddenName'] = $return['name'];
            $return['forceSelection'] = true;
            $return['mode'] = 'remote';
            $return['valueField'] = 'id';
            $return['displayField'] = 'label';
            $return['triggerAction'] = 'all';
            $return['allowBlank'] = true;
            $return['selectOnFocus'] = true;
            $return['editable'] = true;
            $return['typeAhead'] = true;
            $return['value'] = $selectedValue;
            $return['store'] = array('url' => PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/list-categories.php', 'baseParams' => array('fieldId' => $this->_field->getID(), 'module' => $moduleCodename, 'query' => ''), 'root' => 'objects', 'fields' => array('id', 'label'));
        }
        return $return;
    }
Пример #2
0
    } else {
        $content .= '<item>' . "\n" . '    <title>RSS Feed Error ..</title>' . "\n" . '    <guid isPermaLink="false">Error' . time() . '</guid>' . "\n" . '    <description><![CDATA[';
        switch ($error) {
            case 1:
                $content .= 'Error : RSS ID not found or not a valid integer ... Please contact the webmaster here : ' . APPLICATION_MAINTAINER_EMAIL;
                break;
            case 2:
                $content .= 'Error : Invalid RSS ID found ... Please contact the webmaster here : ' . APPLICATION_MAINTAINER_EMAIL;
                break;
            case 3:
                $content .= 'Error : RSS Content generation error or no valid content for this RSS feed ... Please contact the webmaster here : ' . APPLICATION_MAINTAINER_EMAIL;
                break;
        }
        $content .= ']]></description>' . "\n" . '    <link>' . CMS_websitesCatalog::getMainURL() . '</link>' . "\n" . '</item>';
    }
    $content .= '	</channel>' . "\n" . '</rss>';
    if ('utf-8' != strtolower(APPLICATION_DEFAULT_ENCODING)) {
        $content = io::utf8Encode($content);
    }
    //output content to record it into cache
    echo $content;
    $content = $cache->endSave();
}
unset($cache);
//send RSS content
if (!isset($_REQUEST['atm-previz'])) {
    header('Content-type: text/xml; charset=UTF-8');
    echo $content;
} else {
    echo '<pre>' . htmlspecialchars($content) . '</pre>';
}