protected function _initColumns() { parent::_initColumns(); $this->_columns->add(new Kwf_Grid_Column('id')); //shows editDialog $this->_columns->add(new Kwf_Grid_Column_Button('properties', ' ', 20))->setButtonIcon('/assets/silkicons/newspaper.png')->setTooltip(trlKwf('Properties')); if (is_instance_of(Kwc_Abstract::getSetting($this->_getParam('class'), 'extConfig'), 'Kwc_Directories_Item_Directory_ExtConfigEditButtons')) { $extConfigType = 'extConfig'; } else { if (is_instance_of(Kwc_Abstract::getSetting($this->_getParam('class'), 'extConfigControllerIndex'), 'Kwc_Directories_Item_Directory_ExtConfigEditButtons')) { $extConfigType = 'extConfigControllerIndex'; } } $extConfig = Kwf_Component_Abstract_ExtConfig_Abstract::getInstance($this->_getParam('class'), $extConfigType)->getConfig(Kwf_Component_Abstract_ExtConfig_Abstract::TYPE_DEFAULT); $extConfig = $extConfig['items']; if (count($extConfig['countDetailClasses']) > 1 && !$this->_getModel()->hasColumn('component')) { throw new Kwf_Exception('If you have more than one detail-component your table has to have a column named "component"'); } $i = 0; foreach ($extConfig['contentEditComponents'] as $ec) { $name = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($ec['componentClass'], 'componentName')); $icon = Kwc_Abstract::getSetting($ec['componentClass'], 'componentIcon'); $icon = new Kwf_Asset($icon); $this->_columns->add(new Kwc_Directories_Item_Directory_Trl_ControllerEditButton('edit_' . $i, ' ', 20))->setColumnType('editContent')->setEditComponentClass($ec['componentClass'])->setEditComponent($ec['component'])->setEditType($ec['type'])->setEditIdTemplate($ec['idTemplate'])->setEditComponentIdSuffix($ec['componentIdSuffix'])->setButtonIcon($icon->toString(array('arrow')))->setTooltip(trlKwf('Edit {0}', $name)); $i++; } }
protected function _processInput($postData) { $users = Kwf_Registry::get('userModel'); $showPassword = false; //is there a password auth? foreach ($users->getAuthMethods() as $auth) { if ($auth instanceof Kwf_User_Auth_Interface_Password) { $showPassword = true; } } if (!$showPassword) { throw new Kwf_Exception("No password auth method found"); } //if a redirect auth doesn't allow password hide it foreach ($users->getAuthMethods() as $auth) { if ($auth instanceof Kwf_User_Auth_Interface_Redirect) { if (!$auth->allowPasswordForUser($users->getAuthedUser())) { $label = $auth->getLoginRedirectLabel(); $label = Kwf_Trl::getInstance()->trlStaticExecute($label['name']); $msg = $this->getData()->trlKwf("This user doesn't have a password, he must log in using {0}", $label); $this->_errors[] = array('messages' => array($msg)); break; } } } parent::_processInput($postData); }
public function setUp() { $trlElements = array(); $trlElements['kwf']['de']['.-decimal separator'] = ','; $trlElements['kwf']['de']['C-locale'] = 'de_AT.UTF-8, de.UTF-8, de_DE.UTF-8'; Kwf_Trl::getInstance()->setTrlElements($trlElements); }
public function assets(Kwf_Assets_Package $assetsPackage, $language = null) { if (!$language) { $language = Kwf_Trl::getInstance()->getTargetLanguage(); } $indent = str_repeat(' ', 8); $ret = ''; foreach ($assetsPackage->getPackageUrls('text/css', $language) as $file) { $ret .= "{$indent}<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlspecialchars($file) . "\" />\n"; } foreach ($assetsPackage->getPackageUrls('text/css; media=print', $language) as $file) { $ret .= "{$indent}<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlspecialchars($file) . "\" "; if (!Kwf_Config::getValue('debug.assets.usePrintCssForAllMedia')) { $ret .= "media=\"print\" "; } $ret .= "/>\n"; } foreach ($assetsPackage->getPackageUrls('text/javascript', $language) as $file) { $ret .= "{$indent}<script type=\"text/javascript\" src=\"" . htmlspecialchars($file) . "\"></script>\n"; } foreach ($assetsPackage->getPackageUrls('text/javascript; defer', $language) as $file) { $ret .= "<script type=\"text/javascript\">\n var se=document.createElement('script');se.type='text/javascript';se.async=true;\n se.src='" . $file . "';\n var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(se,s);\n </script>"; } return $ret; }
public function setUp() { parent::setUp('Kwc_Trl_NewsCategories_Root'); $trlElements = array(); $trlElements['kwf']['de'] = array(); Kwf_Trl::getInstance()->setTrlElements($trlElements); }
public static function getValue($key, $what = self::NAME) { $language = Kwf_Trl::getInstance()->getTargetLanguage(); $masterFile = KWF_PATH . '/Kwf/Form/Field/SelectCountry/countries.xml'; $cacheId = "countries_{$language}_{$what}"; $cache = Kwf_Cache::factory('File', 'File', array('master_file' => $masterFile, 'lifetime' => null, 'automatic_serialization' => true), array('cache_dir' => 'cache/config')); $result = $cache->load($cacheId); if (!$result) { $xml = simplexml_load_file($masterFile); $result = array(); $x = 0; foreach ($xml->country as $country) { $value = null; foreach ($country as $k => $c) { if ($k == $what) { $attributes = $c->attributes(); if (isset($attributes['language']) && $attributes['language'] == $language) { $result[(string) $country->iso2] = (string) $c; } } } } $cache->save($result, $cacheId); } if (isset($result[$key])) { return $result[$key]; } return null; }
public function setUp() { parent::setUp('Kwc_Trl_StaticPage_Root_Component'); $trlElements = array(); $trlElements['kwf']['de']['Visible-'] = 'Sichtbar'; Kwf_Trl::getInstance()->setTrlElements($trlElements); }
public function assets(Kwf_Assets_Package $assetsPackage, $language = null, $subroot = null) { if (!$language) { $language = Kwf_Trl::getInstance()->getTargetLanguage(); } $ev = new Kwf_Events_Event_CreateAssetsPackageUrls(get_class($assetsPackage), $assetsPackage, $subroot); Kwf_Events_Dispatcher::fireEvent($ev); $prefix = $ev->prefix; $indent = str_repeat(' ', 8); $ret = ''; foreach ($assetsPackage->getPackageUrls('text/css', $language) as $file) { $ret .= "{$indent}<link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlspecialchars($prefix . $file) . "\" />\n"; } foreach ($assetsPackage->getPackageUrls('text/css; ie8', $language) as $file) { $ret .= "{$indent}<!--[if lte IE 8]><link rel=\"stylesheet\" type=\"text/css\" href=\"" . htmlspecialchars($prefix . $file) . "\" /><![endif]-->\n"; } foreach ($assetsPackage->getPackageUrls('text/javascript; ie8', $language) as $file) { $ret .= "{$indent}<!--[if lte IE 8]><script type=\"text/javascript\" src=\"" . htmlspecialchars($prefix . $file) . "\"></script><![endif]-->\n"; } foreach ($assetsPackage->getPackageUrls('text/javascript', $language) as $file) { $ret .= "{$indent}<script type=\"text/javascript\" src=\"" . htmlspecialchars($prefix . $file) . "\"></script>\n"; } foreach ($assetsPackage->getPackageUrls('text/javascript; defer', $language) as $file) { //single line to allow parsing $ret .= "<script type=\"text/javascript\">var se=document.createElement('script');se.type='text/javascript';se.async=true;se.src='" . $prefix . $file . "';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(se,s);</script>\n"; } return $ret; }
public function trlStaticExecute($language = null) { parent::trlStaticExecute($language); $trl = Kwf_Trl::getInstance(); $values = $this->getValues(); if (is_array($values)) { foreach ($values as $k => $v) { $newKey = $k; $newValue = $v; if (is_string($k)) { $newKey = $trl->trlStaticExecute($k, $language); } //TODO key nicht (immer) übersetzen if (is_string($v)) { $newValue = $trl->trlStaticExecute($v, $language); } else { if (is_array($v)) { foreach ($v as $k2 => $v2) { if (is_string($v2)) { $newValue[$k2] = $trl->trlStaticExecute($v2, $language); } } } } unset($values[$k]); $values[$newKey] = $newValue; } $this->setProperty('values', $values); } }
protected function _initColumns() { $this->_model = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting(Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->_getParam('componentId'))->parent->componentClass, 'childModel'))->getReferencedModel('Order'); $cc = Kwc_Abstract::getChildComponentClasses($this->_getParam('class'), 'payment'); $paymentsFilterData = array(); $payments = array(); foreach ($cc as $k => $c) { $payments[$k] = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($c, 'componentName')); $paymentsFilterData[] = array($k, $payments[$k]); } $this->_filters['text'] = true; if (count($payments) > 1) { $this->_filters['payment'] = array('type' => 'ComboBox', 'text' => trlKwf('Payment'), 'data' => $paymentsFilterData, 'width' => 100); } $this->_filters['canceled'] = array('type' => 'Button', 'skipWhere' => true, 'cls' => 'x2-btn-text-icon', 'icon' => '/assets/silkicons/stop.png', 'text' => trlKwf('canceled'), 'tooltip' => trlKwf('Show canceled orders')); $this->_filters['shipped'] = array('type' => 'Button', 'skipWhere' => true, 'cls' => 'x2-btn-text-icon', 'icon' => '/assets/silkicons/package.png', 'text' => trlKwf('shipped'), 'tooltip' => trlKwf('Show shipped orders')); $this->_columns->add(new Kwf_Grid_Column('order_number', trlKwf('Order Nr'), 50)); $this->_columns->add(new Kwf_Grid_Column('invoice_number', trlKwf('Invoice Nr'), 50))->setHidden(true); $this->_columns->add(new Kwf_Grid_Column_Datetime('date', trlKwf('Date'))); $this->_columns->add(new Kwf_Grid_Column('firstname', trlKwf('Firstname'), 90)); $this->_columns->add(new Kwf_Grid_Column('lastname', trlKwf('Lastname'), 90)); $this->_columns->add(new Kwf_Grid_Column('country', trlKwf('Country'), 15)); // TODO: Pfusch $this->_columns->add(new Kwf_Grid_Column('sum_amount', trlKwf('Amt'), 30))->setData(new Kwc_Shop_Cart_Checkout_OrdersController_SumAmount())->setSortable(false); $this->_columns->add(new Kwf_Grid_Column('sum_price', trlKwf('Sum'), 50))->setData(new Kwc_Shop_Cart_Checkout_OrdersController_SumPrice())->setSortable(false)->setRenderer('euroMoney'); if (count($payments) > 1) { $this->_columns->add(new Kwf_Grid_Column('payment', trlKwf('Payment'), 80))->setData(new Kwc_Shop_Cart_Checkout_OrdersController_Payment($payments))->setSortable(false); } $this->_columns->add(new Kwf_Grid_Column_Date('payed', trlKwf('Payed'))); if (Kwc_Abstract::getSetting($this->_getParam('class'), 'generateInvoices')) { $this->_columns->add(new Kwf_Grid_Column_Button('invoice', trlcKwf('Invoice', 'IN'))); } $this->_columns->add(new Kwf_Grid_Column_Button('shipped', trlcKwf('Shipped', 'SH')))->setButtonIcon('/assets/silkicons/package_go.png'); $this->_columns->add(new Kwf_Grid_Column('shipped')); }
protected function _initFields() { parent::_initFields(); $this->setCreateMissingRow(true); if (!$this->getClass()) { return; } $generators = Kwc_Abstract::getSetting($this->getClass(), 'generators'); $classes = $generators['child']['component']; foreach ($classes as $key => $class) { if (!$class) { continue; } $form = Kwc_Abstract_Form::createChildComponentForm($this->getClass(), "-{$key}", $key); if ($form && count($form->fields)) { if ($this->_getIdTemplateForChild($key)) { $form->setIdTemplate($this->_getIdTemplateForChild($key)); } if (!$this->_createFieldsets || !Kwc_Abstract::hasSetting($class, 'componentName')) { $this->add($form); } else { $name = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($class, 'componentName')); $name = str_replace('.', ' ', $name); $this->add(new Kwf_Form_Container_FieldSet($name))->setName($key)->add($form); } } } }
public static function getPlaceholders(Kwc_Mail_Recipient_Interface $recipient, $language) { $ret = array(); $trl = Kwf_Trl::getInstance(); $ret['firstname'] = $recipient->getMailFirstname(); $ret['lastname'] = $recipient->getMailLastname(); if ($recipient instanceof Kwc_Mail_Recipient_TitleInterface) { $replace = array($recipient->getMailTitle(), $recipient->getMailLastname()); $politeM = $trl->trlKwf('Dear Mr. {0} {1}', $replace, $language); $politeF = $trl->trlKwf('Dear Mrs. {0} {1}', $replace, $language); if ($recipient->getMailGender() == 'male' && $recipient->getMailLastname()) { $t = $trl->trlKwf('Dear Mr. {0} {1}', $replace, $language); } else { if ($recipient->getMailGender() == 'female' && $recipient->getMailLastname()) { $t = $trl->trlKwf('Dear Mrs. {0} {1}', $replace, $language); } else { $t = $trl->trlKwf('Dear Mrs./Mr. {0} {1}', $replace, $language); } } $ret['salutation_polite'] = trim(str_replace(' ', ' ', $t)); if ($recipient->getMailGender() == 'male') { $t = $trl->trlKwf('Mr. {0}', $recipient->getMailTitle(), $language); } else { if ($recipient->getMailGender() == 'female') { $t = $trl->trlKwf('Mrs. {0}', $recipient->getMailTitle(), $language); } else { $t = $recipient->getMailTitle(); } } $ret['salutation_title'] = trim(str_replace(' ', ' ', $t)); $ret['title'] = $recipient->getMailTitle(); } if ($recipient instanceof Kwc_Mail_Recipient_GenderInterface) { $replace = array($recipient->getMailLastname()); if ($recipient->getMailGender() == 'male') { $ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Mr. {0}', $replace, $language); $ret['salutation_hello'] = $trl->trlKwf('Hello Mr. {0}', $replace, $language); $ret['salutation'] = $trl->trlKwf('Mr.', array(), $language); $ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname male', 'Dear {0}', array($recipient->getMailFirstname()), $language); } else { if ($recipient->getMailGender() == 'female') { $ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Mrs. {0}', $replace, $language); $ret['salutation_hello'] = $trl->trlKwf('Hello Mrs. {0}', $replace, $language); $ret['salutation'] = $trl->trlKwf('Mrs.', array(), $language); $ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname female', 'Dear {0}', array($recipient->getMailFirstname()), $language); } else { $replace = array($recipient->getMailFirstname(), $recipient->getMailLastname()); if ($recipient->getMailFirstname() && $recipient->getMailLastname()) { $ret['salutation_polite_notitle'] = trim($trl->trlKwf('Dear {0} {1}', $replace, $language)); } else { $ret['salutation_polite_notitle'] = $trl->trlKwf('Dear Sir or Madam', array(), $language); } $ret['salutation_hello'] = trim($trl->trlKwf('Hello {0} {1}', $replace, $language)); $ret['salutation_firstname'] = $trl->trlcKwf('salutation firstname unknown gender', 'Dear {0}', array($recipient->getMailFirstname()), $language); } } } return $ret; }
public function getCardForms() { $ret = array(); $title = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($this->_class, 'componentName')); $title = str_replace('.', ' ', $title); $ret['form'] = array('form' => Kwc_Abstract_Form::createComponentForm($this->_class, 'child'), 'title' => $title); return $ret; }
public function tearDown() { Kwf_Trl::getInstance()->setWebCodeLanguage(null); Kwf_Trl::getInstance()->unsetTrlElements(); Kwf_Cache_SimpleStatic::clear('trl-'); Kwf_Cache_SimpleStatic::clear('trlp-'); parent::tearDown(); }
public function setUp() { parent::setUp('Kwc_Trl_DateHelper_Root'); $trlElements = array(); $trlElements['kwf']['de']['Y-m-d-'] = 'd.m.Y'; $trlElements['kwf']['de']['Y-m-d H:i-'] = 'd.m.Y H:i'; Kwf_Trl::getInstance()->setTrlElements($trlElements); }
public function setUp() { $trlElements = array(); $trlElements['kwf']['de']['Yes-'] = 'Ja'; $trlElements['kwf']['de']['.-decimal separator'] = ','; $trlElements['kwf']['de'][',-thousands separator'] = '.'; Kwf_Trl::getInstance()->setTrlElements($trlElements); }
public function trlStaticExecute($language = null) { parent::trlStaticExecute($language); if (!$language) { $language = Kwf_Trl::getInstance()->getTargetLanguage(); } $this->_floatValidator->setLocale($language); }
public function getReplacements($parsedElements, $language) { $ret = array(); $trl = Kwf_Trl::getInstance(); foreach ($parsedElements as $i => $trlelement) { $values = array(); if (!isset($trlelement['error'])) { if ($trlelement['source'] == Kwf_Trl::SOURCE_KWF) { $mode = "Kwf"; $source = Kwf_Trl::SOURCE_KWF; } else { $mode = ''; $source = Kwf_Trl::SOURCE_WEB; } //TODO: vereinfachen if ($trlelement['type'] == 'trl') { $values['before'] = $trlelement['before']; $values['tochange'] = $trlelement['text']; $method = $trlelement['type'] . $mode; $values['now'] = $trl->{$method}($values['tochange'], array(), $language); $values['now'] = str_replace("'", "\\'", $values['now']); $values['now'] = str_replace($values['tochange'], $values['now'], $values['before']); } else { if ($trlelement['type'] == 'trlc') { $values['context'] = $trlelement['context']; $values['before'] = $trlelement['before']; $values['tochange'] = $trlelement['text']; $method = $trlelement['type'] . $mode; $values['now'] = $trl->{$method}($values['context'], $values['tochange'], array(), $language); $beforeWithoutContext = preg_replace('#[\'"]' . $values['context'] . '[\'"], ?#', '', $values['before']); $values['now'] = str_replace($values['tochange'], $values['now'], $beforeWithoutContext); } else { if ($trlelement['type'] == 'trlp') { $values['before'] = $trlelement['before']; $values['single'] = $trlelement['text']; $values['plural'] = $trlelement['plural']; $newValues = Kwf_Trl::getInstance()->getTrlpValues(null, $values['single'], $values['plural'], $trlelement['source'], $language); $values['now'] = str_replace($values['plural'], $newValues['plural'], $values['before']); $values['now'] = str_replace($values['single'], $newValues['single'], $values['now']); } else { if ($trlelement['type'] == 'trlcp') { $values['before'] = $trlelement['before']; $values['context'] = $trlelement['context']; $values['single'] = $trlelement['text']; $values['plural'] = $trlelement['plural']; $newValues = Kwf_Trl::getInstance()->getTrlpValues($values['context'], $values['single'], $values['plural'], $trlelement['source'], $language); $beforeWithoutContext = preg_replace('#[\'"]' . $values['context'] . '[\'"], ?#', '', $values['before']); $values['now'] = str_replace($values['plural'], $newValues['plural'], $beforeWithoutContext); $values['now'] = str_replace($values['single'], $newValues['single'], $values['now']); } } } } $ret[] = array('search' => $values['before'], 'replace' => $values['now']); } } return $ret; }
public function componentToString(Kwf_Component_Data $data) { $row = $data->getComponent()->getRow(); $fRow = $row->getParentRow(Kwc_Abstract::getSetting($data->componentClass, 'uploadModelRule')); if (!$fRow) { return str_replace('.', ' ', Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($data->componentClass, 'componentName'))); } return $fRow->filename . '.' . $fRow->extension; }
public function getTemplateVars($values, $fieldNamePostfix = '', $idPrefix = '') { $ret = parent::getTemplateVars($values, $fieldNamePostfix, $idPrefix); $name = $this->getFieldName(); $valueYear = 0; $valueMonth = 0; $valueDay = 0; $value = isset($values[$name]) ? $values[$name] : $this->getDefaultValue(); if ($value) { $value = strtotime($value); if ($value) { $valueYear = (int) date('Y', $value); $valueMonth = (int) date('m', $value); $valueDay = (int) date('d', $value); } } $kwfTrl = Kwf_Trl::getInstance(); $ret['id'] = $idPrefix . str_replace(array('[', ']'), array('_', '_'), $name . $fieldNamePostfix); $ret['html'] = "<select name=\"{$name}_day\">"; $ret['html'] .= "<option value=\"\">{$kwfTrl->trlKwf('Day', array(), $this->_language)}</option>"; for ($i = 1; $i <= 31; $i++) { $v = str_pad($i, 2, '0', STR_PAD_LEFT); $ret['html'] .= "<option value=\"{$v}\""; if ($i == $valueDay) { $ret['html'] .= ' selected="selected"'; } $ret['html'] .= ">{$i}</option>"; } $ret['html'] .= "</select>"; $ret['html'] = '<div class="outerSelect day">' . $ret['html'] . '</div><div class="outerSelect month">'; $months = array($kwfTrl->trlKwf('January', array(), $this->_language), $kwfTrl->trlKwf('February', array(), $this->_language), $kwfTrl->trlKwf('March', array(), $this->_language), $kwfTrl->trlKwf('April', array(), $this->_language), $kwfTrl->trlKwf('May', array(), $this->_language), $kwfTrl->trlKwf('June', array(), $this->_language), $kwfTrl->trlKwf('July', array(), $this->_language), $kwfTrl->trlKwf('August', array(), $this->_language), $kwfTrl->trlKwf('September', array(), $this->_language), $kwfTrl->trlKwf('October', array(), $this->_language), $kwfTrl->trlKwf('November', array(), $this->_language), $kwfTrl->trlKwf('December', array(), $this->_language)); $ret['html'] .= "<select name=\"{$name}_month\">"; $ret['html'] .= "<option value=\"\">{$kwfTrl->trlKwf('Month', array(), $this->_language)}</option>"; for ($i = 1; $i <= 12; $i++) { $v = str_pad($i, 2, '0', STR_PAD_LEFT); $ret['html'] .= "<option value=\"{$v}\""; if ($i == $valueMonth) { $ret['html'] .= ' selected="selected"'; } $ret['html'] .= ">{$months[$i - 1]}</option>"; } $ret['html'] .= "</select>"; $ret['html'] = $ret['html'] . '</div><div class="outerSelect year">'; $ret['html'] .= "<select name=\"{$name}_year\">"; $ret['html'] .= "<option value=\"\">{$kwfTrl->trlKwf('Year', array(), $this->_language)}</option>"; for ($i = date('Y'); $i >= 1900; $i--) { $ret['html'] .= "<option value=\"{$i}\""; if ($i == $valueYear) { $ret['html'] .= ' selected="selected"'; } $ret['html'] .= ">{$i}</option>"; } $ret['html'] .= "</select>"; $ret['html'] = $ret['html'] . '</div>'; return $ret; }
public function setAssetsPackage(Kwf_Assets_Package $package) { $t = Kwf_Model_Abstract::getInstance(Kwc_Abstract::getSetting($this->getClass(), 'stylesModel')); $urls = $package->getPackageUrls('text/css', Kwf_Trl::getInstance()->getTargetLanguage()); $styleEditorUrl = Kwc_Admin::getInstance($this->getClass())->getControllerUrl() . '/styles-content'; $styleEditorUrl .= '?t=' . $t->getMTime(); $urls[] = $styleEditorUrl; $this->fields['content']->setStylesCssFile($styleEditorUrl); $this->fields['content']->setCssFiles($urls); }
public function trlStaticExecute($language = null) { parent::trlStaticExecute($language); $locale = Kwf_Trl::getInstance()->trlcKwf('locale', 'C', array(), $language); if ($locale == 'C') { $locale = 'en_US'; } $l = Zend_Locale::findLocale($locale); $this->_floatValidator->setLocale($l); }
public function load($row, array $info = array()) { $content = parent::load($row, $info); $c = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($row->component_id, array('ignoreVisible' => true, 'limit' => 1)); if ($c) { $content = Kwf_Trl::getInstance()->trlStaticExecute($content, $c->getLanguage()); } $ret = array('componentId' => $row->component_id, 'content' => $content); return $ret; }
public function __construct() { $acl = Zend_Registry::get('acl'); $this->_roles = array(); foreach ($acl->getRoles() as $role) { if ($role instanceof Kwf_Acl_Role) { $roleName = Kwf_Trl::getInstance()->trlStaticExecute($role->getRoleName()); $this->_roles[$role->getRoleId()] = $roleName; } } }
public function processOutput($output, $renderer) { if (!preg_match('#{dynamicContent ([^ ]*) ([^}]*)}#', $output, $m)) { throw new Kwf_Exception("didn't find {dynamicContent"); } $componentClass = $m[1]; $language = $m[2]; $dynamicContent = call_user_func(array($componentClass, 'getDynamicContent'), $this->_componentId, $componentClass); $dynamicContent = Kwf_Trl::getInstance()->trlStaticExecute($dynamicContent, $language); return str_replace('{dynamicContent ' . $componentClass . ' ' . $language . '}', $dynamicContent, $output); }
public function tearDown() { Kwf_Events_ModelObserver::getInstance()->setSkipFnF(true); Kwf_Component_Data_Root::reset(); Kwf_Component_Cache::clearInstance(); Kwf_Model_Abstract::clearInstances(); Kwf_Events_Dispatcher::clearCache(); Kwf_Events_Subscriber::clearInstances(); Kwf_Component_PagesMetaModel::clearInstance(); Kwf_Trl::getInstance()->unsetTrlElements(); }
protected function _fetchData($order, $limit, $start) { $usedComponents = Kwc_Admin::getAvailableComponents('./Kwc'); $ret = array(); foreach ($usedComponents as $c) { $name = Kwf_Trl::getInstance()->trlStaticExecute(Kwc_Abstract::getSetting($c, 'componentName')); $path = str_replace('_', '/', $c); $ret[] = array('class' => $c, 'name' => $name, 'parentClass' => get_parent_class($c), 'hasTemplate' => file_exists($path . '.tpl'), 'hasCss' => file_exists($path . '.css')); } return $ret; }
public function indexAction() { $maskedTexts = $this->_findMaskedTexts('./'); $trl = Kwf_Trl::getInstance(); $this->_createXmlFromTexts($maskedTexts, 'hlp.xml', $trl->getLanguages()); $kwfLanguages = array_unique(array_merge(array('en'), $trl->getLanguages())); $maskedTexts = $this->_findMaskedTexts(KWF_PATH, true); $maskedTexts += $this->_findMaskedTexts('./application', true); $this->_createXmlFromTexts($maskedTexts, KWF_PATH . '/hlp.xml', $kwfLanguages); echo "Parsing durchgelaufen\n"; $this->_helper->viewRenderer->setNoRender(true); }
protected function _build() { if (!file_exists('build/trl')) { mkdir('build/trl'); } foreach (glob('build/trl/*') as $f) { unlink($f); } $config = Zend_Registry::get('config'); $langs = array(); if ($config->webCodeLanguage) { $langs[] = $config->webCodeLanguage; } if ($config->languages) { foreach ($config->languages as $lang => $name) { $langs[] = $lang; } } try { if (Kwf_Component_Data_Root::getComponentClass()) { foreach (Kwc_Abstract::getComponentClasses() as $c) { if (Kwc_Abstract::getFlag($c, 'hasAvailableLanguages')) { foreach (call_user_func(array($c, 'getAvailableLanguages'), $c) as $i) { if (!in_array($i, $langs)) { $langs[] = $i; } } } } } } catch (Kwf_Trl_BuildFileMissingException $e) { $originatingException = $e->getSettingsNonStaticTrlException(); if ($originatingException) { throw $originatingException; } throw $e; } foreach ($langs as $l) { if ($l != $config->webCodeLanguage) { $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_WEB, $l, true); file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_WEB, $l, true), serialize($c)); $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_WEB, $l, false); file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_WEB, $l, false), serialize($c)); } if ($l != 'en') { $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_KWF, $l, true); file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_KWF, $l, true), serialize($c)); $c = $this->_loadTrlArray(Kwf_Trl::SOURCE_KWF, $l, false); file_put_contents(Kwf_Trl::generateBuildFileName(Kwf_Trl::SOURCE_KWF, $l, false), serialize($c)); } } }
function hlpKwf($key, $language = null) { if (!$language) { $language = Kwf_Trl::getInstance()->getTargetLanguage(); } if ($this->_xml) { $element = $this->_xmlKwf->xpath("/hlp/text[@key='{$key}']/{$language}"); if ($element) { return (string) $element[0]; } } return null; }