public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false) { $object = parent::getObject($objectType, $properties, $add_underscore, $include_empty_fields); $cPlatformXml = $this->getValue('cplatform_xml'); $doc = new DOMDocument(); $doc->loadXML($cPlatformXml); $itemsNode = $doc->getElementsByTagName('items')->item(0); $cPlatformArray = array(); if ($itemsNode) { $itemNodes = $itemsNode->getElementsByTagName('item'); foreach ($itemNodes as $itemNode) { $keyNode = $itemNode->getElementsByTagName('key')->item(0); $valueNode = $itemNode->getElementsByTagName('value')->item(0); $keyVal = new Kaltura_Client_Type_KeyValue(); $keyVal->key = $keyNode->nodeValue; $filter = new Zend_Filter_Alnum(true); $keyVal->value = $filter->filter($valueNode->nodeValue); $cPlatformArray[] = $keyVal; } } $object->cPlatformTvSeries = $cPlatformArray; $object->cPlatformTvSeriesField = $this->getValue('c_platform_tv_series_field'); // because parent::getObject doesn't include empty fields $object->feedLink = $this->getValue('feed_link'); // because parent::getObject doesn't include empty fields return $object; }
/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { $valuesExpected = array('abc123' => 'abc123', 'abc 123' => 'abc123', 'abcxyz' => 'abcxyz', 'AZ@#4.3' => 'AZ43'); foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $this->_filter->filter($input)); } }
/** * dijit.form.RadioButton * * @param string $id * @param string $value * @param array $params Parameters to use for dijit creation * @param array $attribs HTML attributes * @param array $options Array of radio options * @param string $listsep String with which to separate options * @return string */ public function radioButton( $id, $value = null, array $params = array(), array $attribs = array(), array $options = null, $listsep = "<br />\n" ) { $attribs['name'] = $id; if (!array_key_exists('id', $attribs)) { $attribs['id'] = $id; } $attribs = $this->_prepareDijit($attribs, $params, 'element'); if (is_array($options) && $this->_useProgrammatic() && !$this->_useProgrammaticNoScript()) { $baseId = $id; if (array_key_exists('id', $attribs)) { $baseId = $attribs['id']; } require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); foreach (array_keys($options) as $key) { $optId = $baseId . '-' . $filter->filter($key); $this->_createDijit($this->_dijit, $optId, array()); } } return $this->view->formRadio($id, $value, $attribs, $options, $listsep); }
/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { $valuesExpected = array('abc123' => 'abc123', 'abc 123' => 'abc123', 'abcxyz' => 'abcxyz', 'AZ@#4.3' => 'AZ43', '' => ''); foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead"); } }
/** * Ensures that the allowWhiteSpace option works as expected * * @return void */ public function testAllowWhiteSpace() { $this->_filter->allowWhiteSpace = true; $valuesExpected = array('abc123' => 'abc123', 'abc 123' => 'abc 123', 'abcxyz' => 'abcxyz', 'AZ@#4.3' => 'AZ43', '' => '', "\n" => "\n", " \t " => " \t "); foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead"); } }
/** * Get the item id * * @return string */ public function getId() { if (empty($this->_id)) { $filter = new Zend_Filter_Alnum(); $filteredLabel = $filter->filter($this->getLabel()); $this->setId($filteredLabel); } return $this->_id; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value contains only alphabetic and digit characters * * @param string $value * @return boolean */ public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Alnum */ require_once 'Zend/Filter/Alnum.php'; self::$_filter = new Zend_Filter_Alnum(); } self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_ALNUM); return false; } return true; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value contains only alphabetic and digit characters * * @param string $value * @return boolean */ public function isValid($value) { if (!is_string($value) && !is_int($value) && !is_float($value)) { $this->_error(self::INVALID); return false; } $this->_setValue($value); if ('' === $value) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Alnum */ //require_once 'Zend/Filter/Alnum.php'; self::$_filter = new Zend_Filter_Alnum(); } self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; if ($value != self::$_filter->filter($value)) { $this->_error(self::NOT_ALNUM); return false; } return true; }
/** * Sets default option values for this instance * * @param boolean $allowWhiteSpace * @return void */ public function __construct($allowWhiteSpace = false) { $this->allowWhiteSpace = (boolean) $allowWhiteSpace; if (null === self::$_unicodeEnabled) { self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; } }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if $value contains only alphabetic and digit characters * * @param string $value * @return boolean */ public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ('' === $valueString) { $this->_error(self::STRING_EMPTY); return false; } if (null === self::$_filter) { /** * @see Zend_Filter_Alnum */ //require-once 'Dkplus/Filter/AlnumUnderline.php'; self::$_filter = new Dkplus_Filter_AlnumUnderline(); } self::$_filter->setMeansEnglishAlphabet($this->_meansEnglishAlphabet); self::$_filter->allowWhiteSpace = $this->allowWhiteSpace; if ($valueString !== self::$_filter->filter($valueString)) { $this->_error(self::NOT_ALNUM); return false; } return true; }
/** * Sets default option values for this instance * * @param boolean $allowWhiteSpace * @return void */ public function __construct($allowWhiteSpace = false) { $this->allowWhiteSpace = (bool) $allowWhiteSpace; if (null === self::$_unicodeEnabled) { self::$_unicodeEnabled = @preg_match('/\\pL/u', 'a') ? true : false; } if (null === self::$_meansEnglishAlphabet) { $this->_locale = new Zend_Locale(Zend_Locale::BROWSER); self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), array('ja')); } }
/** * Ensures that the allowWhiteSpace option works as expected * * @return void */ public function testAllowWhiteSpace() { $this->_filter->allowWhiteSpace = true; if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative a-zA-Z match $valuesExpected = array('abc123' => 'abc123', 'abc 123' => 'abc 123', 'abcxyz' => 'abcxyz', 'AZ@#4.3' => 'AZ43', '' => '', "\n" => "\n", " \t " => " \t "); } if (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. $valuesExpected = array('a B 45' => 'a B 5', 'z3 x' => 'z3x'); } else { //The Alphabet means each language's alphabet. $valuesExpected = array('abc123' => 'abc123', 'abc 123' => 'abc 123', 'abcxyz' => 'abcxyz', 'če2 t3ně' => 'če2 t3ně', 'gr z5e4gżółka' => 'gr z5e4gżółka', 'Be3l5 gië' => 'Be3l5 gië', '' => ''); } foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $result = $this->_filter->filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead"); } }
/** * Sets default option values for this instance * * @param boolean $allowWhiteSpace * @return void */ public function __construct($allowWhiteSpace = false) { if ($allowWhiteSpace instanceof Zend_Config) { $allowWhiteSpace = $allowWhiteSpace->toArray(); } elseif (is_array($allowWhiteSpace)) { if (array_key_exists('allowwhitespace', $allowWhiteSpace)) { $allowWhiteSpace = $allowWhiteSpace['allowwhitespace']; } else { $allowWhiteSpace = false; } } $this->allowWhiteSpace = (bool) $allowWhiteSpace; if (null === self::$_unicodeEnabled) { self::$_unicodeEnabled = @preg_match('/\\pL/u', 'a') ? true : false; } if (null === self::$_meansEnglishAlphabet) { $this->_locale = new Zend_Locale('auto'); self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), array('ja', 'ko', 'zh')); } }
/** * Oauth Connect * */ public function oauthAction() { $namespace = $this->_getOauthStorage(); $info = $namespace->info; $users = new Users_Model_User_Table(); if (empty($info->email)) { $row = $users->getByTwitterid($info->twitterId); } else { $row = $users->getByEmail($info->email); if (!$row) { if (self::OAUTH_FACEBOOK == $this->_getParam('type')) { $row = $users->getByFacebookid($info->facebookId); } elseif (self::OAUTH_GOOGLE == $this->_getParam('type')) { $row = $users->getByGoogleid($info->googleId); } } } if (!$row) { $loginFilter = new Zend_Filter_Alnum(); $info->login = $loginFilter->filter($info->login); if ($users->getByLogin($info->login)) { $form = new Users_Form_Auth_RegisterLogin(); if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) { $info->login = $form->getValue('login'); } else { $this->view->login = $info->login; $this->view->form = $form; return; } } $row = $users->createRow($info->getArrayCopy()); $row->role = Users_Model_User::ROLE_USER; $row->status = Users_Model_User::STATUS_ACTIVE; $row->save(); } $row->login(); $namespace->unsetAll(); $this->_helper->flashMessenger->addMessage('Now You\'re Logging!'); $this->_helper->redirector(false, false, false); }
/** * Setter for {@see $_namedParamPrefix} * * @param String $value * @return void */ public function setNamedParamPrefix($value) { $alnumFilter = new Zend_Filter_Alnum(); $this->_namedParamPrefix = $alnumFilter->filter($value); }
public function createAction() { $this->_helper->layout->disableLayout(); $filename = $this->_getParam('filename'); $alpha = new Zend_Filter_Alnum(); $filename = $alpha->filter($filename); $filename .= '.xml'; $siteId = $this->_getParam('site_id'); $menu = new Zend_Navigation(); $gmDate = gmdate('Y-m-d'); $locales = Axis::single('locale/language')->select(array('id', 'locale'))->fetchPairs(); foreach ($locales as $languageId => &$_locale) { $_locale = Axis_Locale::getLanguageUrl($_locale); } $categories = Axis::single('catalog/category')->select('*')->addName()->addKeyWord()->order('cc.lft')->addSiteFilter($siteId)->addDisabledFilter()->fetchAll(); $config = Axis::config()->sitemap; $changefreq = $config->categories->frequency; $priority = $config->categories->priority; $_container = $menu; $lvl = 0; foreach ($categories as $_category) { if (!isset($locales[$_category['language_id']])) { continue; } $uri = $this->view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word']), 'locale' => $locales[$_category['language_id']], 'controller' => 'catalog', 'action' => 'view'), false, true); $page = new Zend_Navigation_Page_Uri(array('label' => $_category['name'], 'title' => $_category['name'], 'uri' => $uri, 'order' => $_category['lft'], 'visible' => 'enabled' === $_category['status'] ? true : false, 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority, 'id' => $_category['id'] . $_category['language_id'])); $lvl = $lvl - $_category['lvl'] + 1; for ($i = 0; $i < $lvl; $i++) { $_container = $_container->getParent(); } $lvl = $_category['lvl']; $_container->addPage($page); $_container = $page; } $products = Axis::single('catalog/product_category')->select()->distinct()->from('catalog_product_category', array())->joinLeft('catalog_product', 'cp.id = cpc.product_id', array('id'))->addName()->addKeyWord()->addActiveFilter()->addDateAvailableFilter()->addSiteFilter($siteId)->columns(array('category_id' => 'cc.id'))->fetchAll(); $changefreq = $config->products->frequency; $priority = $config->products->priority; foreach ($products as $_product) { if (!isset($locales[$_product['language_id']])) { continue; } $uri = $this->view->hurl(array('cat' => array('value' => $_product['id'], 'seo' => $_product['key_word']), 'locale' => $locales[$_product['language_id']], 'controller' => 'catalog', 'action' => 'view'), false, true); $page = new Zend_Navigation_Page_Uri(array('label' => $_product['name'], 'title' => $_product['name'], 'uri' => $uri, 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority)); $_container = $menu->findBy('id', $_product['category_id'] . $_product['language_id']); if (null !== $_container) { $_container->addPage($page); } } $categories = Axis::single('cms/category')->select(array('id', 'parent_id'))->addCategoryContentTable()->columns(array('ccc.link', 'ccc.title', 'ccc.language_id'))->addActiveFilter()->addSiteFilter($siteId)->where('ccc.link IS NOT NULL')->fetchAll(); $changefreq = $config->cms->frequency; $priority = $config->cms->priority; foreach ($categories as $_category) { if (!isset($locales[$_category['language_id']])) { continue; } $title = empty($_category['title']) ? $_category['link'] : $_category['title']; $page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_category', 'params' => array('cat' => $_category['link'], 'locale' => $locales[$_category['language_id']]), 'id' => 'cms' . $_category['id'] . $_category['language_id'], 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority)); $_container = $menu->findBy('id', 'cms' . $_category['parent_id'] . $_category['language_id']); if (null === $_container) { $_container = $menu; } $_container->addPage($page); } $pages = array(); if ($config->cms->showPages && !empty($categories)) { $pages = Axis::single('cms/page')->select(array('id', 'name'))->join(array('cpca' => 'cms_page_category'), 'cp.id = cpca.cms_page_id', 'cms_category_id')->join('cms_page_content', 'cp.id = cpc.cms_page_id', array('link', 'title', 'language_id'))->where('cp.is_active = 1')->where('cpca.cms_category_id IN (?)', array_keys($categories))->fetchAll(); foreach ($pages as $_page) { $title = empty($_page['title']) ? $_page['link'] : $_page['title']; $page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_page', 'params' => array('page' => $_page['link'], 'locale' => $locales[$_page['language_id']]), 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority)); $_container = $menu->findBy('id', 'cms' . $_page['cms_category_id'] . $_page['language_id']); if (null !== $_container) { $_container->addPage($page); } } } $content = $this->view->navigation()->sitemap($menu)->setFormatOutput(true)->setUseSitemapValidators(false)->render(); $this->getResponse()->clearAllHeaders()->setHeader('Content-Description', 'File Transfer', true)->setHeader('Content-Type', 'application/octet-stream', true)->setHeader('Content-Disposition', 'attachment; filename=' . $filename, true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setHeader('Expires', '0', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Pragma', 'public', true); $this->getResponse()->setBody($content); }
protected function _load() { if (!is_array($this->_options) || empty($this->_options) || !isset($this->_options[0]) || !$this->_options[0] || preg_match('~^\\s*$~', $this->_options[0])) { throw new Exceptions_SeotoasterException($this->_translator->translate('You should provide a form name.')); } if (strtolower($this->_options[0]) == 'conversioncode') { return $this->_conversionCode($this->_options); } $sessionHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Session'); $useCaptcha = isset($this->_options[1]) && $this->_options[1] == 'captcha' ? true : false; $useRecaptcha = isset($this->_options[1]) && $this->_options[1] == 'recaptcha' ? true : false; $uploadLimitSize = is_numeric(end($this->_options)) ? end($this->_options) : self::UPLOAD_LIMIT_SIZE; $formMapper = Application_Model_Mappers_FormMapper::getInstance(); $pageMapper = Application_Model_Mappers_PageMapper::getInstance(); $form = $formMapper->findByName($this->_options[0]); $pageHelper = new Helpers_Action_Page(); $pageHelper->init(); if ($useCaptcha || $useRecaptcha) { if ($form != null) { $form->setCaptcha(1); $formMapper->save($form); } if ($useRecaptcha) { $recaptchaTheme = 'red'; $recaptchaWidgetId = uniqid('recaptcha_widget_'); if (isset($this->_options[2])) { $recaptchaTheme = $this->_options[2]; if ($recaptchaTheme == 'custom') { $this->_view->customRecaptcha = true; } } $this->_view->recaptchaWidgetId = $recaptchaWidgetId; $this->_view->addScriptPath($this->_websiteHelper->getPath() . 'seotoaster_core/application/views/scripts/backend/form/'); $this->_view->recaptchaCode = Tools_System_Tools::generateRecaptcha($recaptchaTheme, $recaptchaWidgetId); } if ($useCaptcha) { $this->_view->captchaId = Tools_System_Tools::generateCaptcha(); } } if (isset($sessionHelper->toasterFormError)) { $this->_view->toasterFormError = $sessionHelper->toasterFormError; unset($sessionHelper->toasterFormError); } if (isset($sessionHelper->toasterFormSuccess)) { $this->_view->toasterFormSuccess = $sessionHelper->toasterFormSuccess; unset($sessionHelper->toasterFormSuccess); } $trackingConversionUrl = 'form-' . $this->_options[0] . '-thank-you'; $trackingConversionUrl = $pageHelper->filterUrl($trackingConversionUrl); $trackingPageExist = $pageMapper->findByUrl($trackingConversionUrl); if ($trackingPageExist instanceof Application_Model_Models_Page) { $this->_view->trackingConversionUrl = $trackingConversionUrl; } $this->_view->useRecaptcha = $useRecaptcha; $this->_view->useCaptcha = $useCaptcha; $this->_view->form = Application_Model_Mappers_FormMapper::getInstance()->findByName($this->_options[0]); $this->_view->allowMidification = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL); $this->_view->formName = $this->_options[0]; $this->_view->uploadLimitSize = $uploadLimitSize; $filter = new Zend_Filter_Alnum(); $this->_view->formId = $filter->filter($this->_options[0]); $this->_view->pageId = $this->_toasterOptions['id']; $this->_view->websiteTmp = $this->_websiteHelper->getTmp(); $this->_view->formUrl = $this->_toasterOptions['url']; return $this->_view->render('form.phtml'); }
/** * Generates a set of radio button elements. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are extracted in place of added parameters. * * @param mixed $value The radio value to mark as 'checked'. * * @param array $options An array of key-value pairs where the array * key is the radio value, and the array value is the radio text. * * @param array|string $attribs Attributes added to each radio. * * @return string The radio buttons XHTML. */ public function JQueryRadio($name, $value = null, $attribs = null, $options = null, $listsep = "\n") { $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); extract($info); // name, value, attribs, options, listsep, disable // retrieve attributes for labels (prefixed with 'label_' or 'label') $label_attribs = array(); foreach ($attribs as $key => $val) { $tmp = false; $keyLen = strlen($key); if (6 < $keyLen && substr($key, 0, 6) == 'label_') { $tmp = substr($key, 6); } elseif (5 < $keyLen && substr($key, 0, 5) == 'label') { $tmp = substr($key, 5); } if ($tmp) { // make sure first char is lowercase $tmp[0] = strtolower($tmp[0]); $label_attribs[$tmp] = $val; unset($attribs[$key]); } } $labelPlacement = 'append'; foreach ($label_attribs as $key => $val) { switch (strtolower($key)) { case 'placement': unset($label_attribs[$key]); $val = strtolower($val); if (in_array($val, array('prepend', 'append'))) { $labelPlacement = $val; } break; } } // the radio button values and labels $options = (array) $options; // build the element $xhtml = ''; $list = array(); // should the name affect an array collection? $name = $this->view->escape($name); if ($this->_isArray && '[]' != substr($name, -2)) { $name .= '[]'; } // ensure value is an array to allow matching multiple times $value = (array) $value; // XHTML or HTML end tag? $endTag = ' />'; if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) { $endTag = '>'; } // add radio buttons to the list. require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); foreach ($options as $opt_value => $opt_label) { // Should the label be escaped? if ($escape) { $opt_label = $this->view->escape($opt_label); } // is it disabled? $disabled = ''; if (true === $disable) { $disabled = ' disabled="disabled"'; } elseif (is_array($disable) && in_array($opt_value, $disable)) { $disabled = ' disabled="disabled"'; } // is it checked? $checked = ''; if (in_array($opt_value, $value)) { $checked = ' checked="checked"'; } // generate ID $optId = $id . '-' . $filter->filter($opt_value); // Wrap the radios in labels $labelPlacement = 'prepend'; $radio = '<input type="' . $this->_inputType . '"' . ' name="' . $name . '"' . ' id="' . $optId . '"' . ' value="' . $this->view->escape($opt_value) . '"' . $checked . $disabled . $this->_htmlAttribs($attribs) . $endTag . '<label' . $this->_htmlAttribs($label_attribs) . ' for="' . $optId . '">' . $opt_label . '</label>'; // add to the array of radio buttons $list[] = $radio; } // done! $xhtml .= implode($listsep, $list); return $xhtml; }
/** * Generates a set of radio button elements. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are extracted in place of added parameters. * * @param mixed $value The radio value to mark as 'checked'. * * @param array $options An array of key-value pairs where the array * key is the radio value, and the array value is the radio text. * * @param array|string $attribs Attributes added to each radio. * * @return string The radio buttons XHTML. */ public function formMultiColumnCheckbox($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n") { $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); extract($info); // name, value, attribs, options, listsep, disable // retrieve attributes for labels (prefixed with 'label_' or 'label') $label_attribs = array(); foreach ($attribs as $key => $val) { $tmp = false; $keyLen = strlen($key); if (6 < $keyLen && substr($key, 0, 6) == 'label_') { $tmp = substr($key, 6); } elseif (5 < $keyLen && substr($key, 0, 5) == 'label') { $tmp = substr($key, 5); } if ($tmp) { // make sure first char is lowercase $tmp[0] = strtolower($tmp[0]); $label_attribs[$tmp] = $val; unset($attribs[$key]); } } $labelPlacement = 'append'; foreach ($label_attribs as $key => $val) { switch (strtolower($key)) { case 'placement': unset($label_attribs[$key]); $val = strtolower($val); if (in_array($val, array('prepend', 'append'))) { $labelPlacement = $val; } break; } } // the radio button values and labels $options = (array) $options; // build the element $xhtml = ''; $list = array(); // should the name affect an array collection? $name = $this->view->escape($name); if ($this->_isArray && '[]' != substr($name, -2)) { $name .= '[]'; } // ensure value is an array to allow matching multiple times $value = (array) $value; // XHTML or HTML end tag? $endTag = ' />'; if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) { $endTag = '>'; } // add radio buttons to the list. // require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); $column_count = 3; $count = count($options); $perColumn = (int) ceil($count / $column_count); $i = $j = 0; $columns = array(); foreach ($options as $opt_value => $opt_label) { // Should the label be escaped? if ($escape) { $opt_label = $this->view->escape($opt_label); } // is it disabled? $disabled = ''; if (true === $disable) { $disabled = ' disabled="disabled"'; } elseif (is_array($disable) && in_array($opt_value, $disable)) { $disabled = ' disabled="disabled"'; } // is it checked? $checked = ''; if (in_array($opt_value, $value)) { $checked = ' checked="checked"'; } // generate ID $optId = $id . '-' . $filter->filter($opt_value); // Wrap the radios in labels $radio = '<label class="newline" ' . $this->_htmlAttribs($label_attribs) . ' for="' . $optId . '">' . ('prepend' == $labelPlacement ? $opt_label : '') . '<input type="' . $this->_inputType . '"' . ' name="' . $name . '"' . ' id="' . $optId . '"' . ' value="' . $this->view->escape($opt_value) . '"' . $checked . $disabled . $this->_htmlAttribs($attribs) . $endTag . ('append' == $labelPlacement ? $opt_label : '') . '</label>'; if ($perColumn === $i && $j < $column_count) { $i = 0; $j++; $count = $count - $perColumn; } $columns[$j][] = $radio; $i++; } // done! $xhtml .= '<div style="clear: both;">' . "\n"; for ($i = 0; $i < count($columns); $i++) { $xhtml .= '<div style="width: 30%; float: left;">' . "\n"; $xhtml .= implode($listsep, $columns[$i]); $xhtml .= '</div>' . "\n\n"; } $xhtml .= "</div>\n"; return $xhtml; }
/** * @return void */ public function searchArtefatoDestinoAction() { $sqArtefato = $this->getRequest()->getParam('extraParam'); $objZFAlpha = new \Zend_Filter_Alnum(true); $query = $objZFAlpha->filter($this->getRequest()->getParam('query')); $criteria = array('sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso(), 'sqPessoaRecebimento' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidadeRecebimento' => \Core_Integration_Sica_User::getUserUnit(), 'nuArtefato' => $query, 'sqArtefato' => $sqArtefato); $listInMyDashboard = $this->getService('ProcessoEletronico')->searchInMyDashboard($criteria); $this->_helper->json($listInMyDashboard); }
public function exportSearchExcelAction() { $content = $this->getLayout()->createBlock('icc_tec/adminhtml_roster_grid')->getExcelFile(); $roster_rows = file($content['value']); // content is just an array of where the file (et al.) has been put $headings_row = array_shift($roster_rows); try { $conn = Mage::getSingleton('core/resource')->getConnection('core_write'); $conn->beginTransaction(); foreach ($roster_rows as $row) { $id = array_shift(explode(',', $row)); // first element is the id of the roster row $roster = Mage::getModel('icc_tec/roster')->load($id); if (is_null($roster->getInitialExportDate())) { $roster->setInitialExportDate(time()); $roster->save(); } } $file_name = 'events.xml'; $zf = new Zend_Filter_Int(); $prod_id = $zf->filter($this->getRequest()->getParam('id')); $product = Mage::getModel('catalog/product')->load($prod_id); $zf = new Zend_Filter_Alnum(); $file_name = $zf->filter('RosterFor' . $product->getName()) . '.xml'; $this->_prepareDownloadResponse($file_name, $content); $conn->commit(); } catch (Exception $e) { Mage::log('Could not download and uppdate download dates for roster with. Last roster id: ' . $id . ' with exception: ' . $e->getMessage(), null, 'export-event-excel-exception.log'); $conn->rollback(); } }
public function formFancySelect($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n") { $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); extract($info); // name, value, attribs, options, listsep, disable // retrieve attributes for labels (prefixed with 'label_' or 'label') $label_attribs = array(); foreach ($attribs as $key => $val) { $tmp = false; $keyLen = strlen($key); if (6 < $keyLen && substr($key, 0, 6) == 'label_') { $tmp = substr($key, 6); } elseif (5 < $keyLen && substr($key, 0, 5) == 'label') { $tmp = substr($key, 5); } if ($tmp) { // make sure first char is lowercase $tmp[0] = strtolower($tmp[0]); $label_attribs[$tmp] = $val; unset($attribs[$key]); } } // add class formLabelRadio to label per default $label_attribs['class'] = (isset($label_attribs['class']) ? $label_attribs['class'] . ' ' : '') . 'formLabelRadio'; $labelPlacement = 'append'; foreach ($label_attribs as $key => $val) { switch (strtolower($key)) { case 'placement': unset($label_attribs[$key]); $val = strtolower($val); if (in_array($val, array('prepend', 'append'))) { $labelPlacement = $val; } break; } } if (isset($attribs['multiple'])) { $this->_inputType = 'checkbox'; $this->_isArray = true; } // the radio button values and labels $options = (array) $options; // build the element $xhtml = array(); // should the name affect an array collection? $name = $this->view->escape($name); if ($this->_isArray && '[]' != substr($name, -2)) { $name .= '[]'; } // ensure value is an array to allow matching multiple times $value = (array) $value; // XHTML or HTML end tag? $endTag = ' />'; if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) { $endTag = '>'; } // add container open tag $xhtml[] = '<div class="formFancySelect">'; $xhtml[] = '<div class="formFancySelectOptions">'; $xhtml[] = '<div>'; // add radio buttons to the list. require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); foreach ($options as $opt_value => $opt_label) { // Should the label be escaped? if ($escape) { $opt_label = $this->view->escape($opt_label); } // is it disabled? $disabled = ''; if (true === $disable) { $disabled = ' disabled="disabled"'; } elseif (is_array($disable) && in_array($opt_value, $disable)) { $disabled = ' disabled="disabled"'; } // is it checked? $checked = ''; if (in_array($opt_value, $value)) { $checked = ' checked="checked"'; } // generate ID $optId = $id . '-' . $filter->filter($opt_value); // set class $attribs['class'] = 'form' . ucfirst($this->_inputType); // Wrap the radios in labels $radio = '<label' . $this->_htmlAttribs($label_attribs) . '>' . ('prepend' == $labelPlacement ? '<span>' . $opt_label . '</span>' : '') . '<input type="' . $this->_inputType . '"' . ' name="' . $name . '"' . ' id="' . $optId . '"' . ' value="' . $this->view->escape($opt_value) . '"' . $checked . $disabled . $this->_htmlAttribs($attribs) . $endTag . ('append' == $labelPlacement ? '<span>' . $opt_label . '</span>' : '') . '</label>'; // add to the array of radio buttons $xhtml[] = $radio; } // add container close tag $xhtml[] = '</div>'; $xhtml[] = '</div>'; $xhtml[] = '</div>'; $xhtml[] = '<div class="formFancySelectLabel">'; if (isset($attribs['notice'])) { $xhtml[] = $attribs['notice']; } $xhtml[] = '</div>'; if (isset($attribs['show_choice'])) { $xhtml[] = '<div class="formFancySelectValue"></div>'; } else { $xhtml[] = '<div class="clear"></div>'; } return implode("\n", $xhtml); }
/** * Generates a set of radio button elements. * * @access public * * @param string|array $name If a string, the element name. If an * array, all other parameters are ignored, and the array elements * are extracted in place of added parameters. * * @param mixed $value The radio value to mark as 'checked'. * * @param array $options An array of key-value pairs where the array * key is the radio value, and the array value is the radio text. * * @param array|string $attribs Attributes added to each radio. * * @return string The radio buttons XHTML. */ public function formMultiText($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n") { $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); extract($info); // name, value, attribs, options, listsep, disable // the radio button values and labels $options = (array) $options; // build the element $xhtml = ''; $list = array(); $checkedId = null; // should the name affect an array collection? $name = $this->view->escape($name); if ($this->_isArray && '[]' != substr($name, -2)) { $name .= '[]'; } //get cehcked if (isset($attribs['checked'])) { $checkedId = $attribs['checked']; unset($attribs['checked']); } // ensure value is an array to allow matching multiple times $value = (array) $value; // XHTML or HTML end tag? $endTag = ' />'; if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) { $endTag = '>'; } // add radio buttons to the list. require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); $i = 0; foreach ($options as $opt_value => $opt_label) { // Should the label be escaped? if ($escape) { $opt_label = $this->view->escape($opt_label); } //checked $checked = ''; if ($checkedId === $opt_value) { $checked = 'checked="checked"'; } // is it disabled? $disabled = ''; if (true === $disable) { $disabled = ' disabled="disabled"'; } elseif (is_array($disable) && in_array($opt_value, $disable)) { $disabled = ' disabled="disabled"'; } // generate ID $optId = $id . '-' . $filter->filter($opt_value); // Wrap the textareas $radio = '<div>' . '<input style="float: left;" type="radio" ' . ' name="right_' . substr($name, 0, -2) . '"' . ' value="' . $i . '"' . $checked . $endTag . '<textarea ' . ' name="' . $name . '"' . $disabled . $this->_htmlAttribs($attribs) . '>' . $this->view->escape($opt_label) . '</textarea>' . '<input type="hidden" ' . ' name="id_' . $name . '"' . ' value="' . $this->view->escape($opt_value) . '"' . $endTag . '</div>'; // add to the array of radio buttons $list[] = $radio; $i++; } // done! $xhtml .= implode($listsep, $list); return $xhtml; }
/** * Returns only the alphabetic characters and digits in value. * * @deprecated since 0.8.0 * @param mixed $value * @return string */ public static function getAlnum($value) { require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); return $filter->filter($value); }
public function testRadioLabelContainsForAttributeTag() { $options = array('foo bar' => 'Foo', 'bar baz' => 'Bar', 'baz' => 'Baz'); $html = $this->helper->formRadio(array('name' => 'foo[bar]', 'value' => 'bar', 'options' => $options)); require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); foreach ($options as $key => $value) { $id = 'foo-bar-' . $filter->filter($key); $this->assertRegexp('/<label([^>]*)(for="' . $id . '")/', $html); } }
public function formFancySelect($name, $value = null, $attribs = null, $options = null, $listsep = "<br />\n") { $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); extract($info); // name, id, value, attribs, options, listsep, disable // get label $label = isset($attribs['label']) ? $attribs['label'] : null; unset($attribs['label']); // get notice $notice = isset($attribs['notice']) ? $attribs['notice'] : null; unset($attribs['notice']); // get notice $showChoice = isset($attribs['show_choice']) ? $attribs['show_choice'] : false; unset($attribs['show_choice']); // get label attribs $labelAttribs = $this->getAttribsNamespaceValue($attribs, 'label'); // is multiple choice if (isset($attribs['multiple'])) { $this->_inputType = 'checkbox'; $this->_isArray = true; unset($attribs['multiple']); } // the radio button values and labels $options = (array) $options; // build the element $xhtml = array(); // should the name affect an array collection? $name = $this->view->escape($name); if ($this->_isArray && '[]' != substr($name, -2)) { $name .= '[]'; } // ensure value is an array to allow matching multiple times $value = (array) $value; // XHTML or HTML end tag? $endTag = ' />'; if ($this->view instanceof Zend_View_Abstract && !$this->view->doctype()->isXhtml()) { $endTag = '>'; } // add container open tag $xhtml[] = '<div id="' . $this->view->escape($id) . '" class="formFancySelect">'; $xhtml[] = ' <div class="formFancySelectOptions">'; $xhtml[] = ' <div>'; // add radio buttons to the list. require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); foreach ($options as $optionValue => $optionLabel) { // Should the label be escaped? $optionLabel = $this->view->escape($optionLabel); // is it disabled? $disabled = ''; if (true === $disable) { $disabled = ' disabled="disabled"'; } elseif (is_array($disable) && in_array($optionValue, $disable)) { $disabled = ' disabled="disabled"'; } // is it checked? $checked = ''; if (in_array($optionValue, $value)) { $checked = ' checked="checked"'; } // generate ID $optId = $id . '-' . $filter->filter($optionValue); // set class $attribs['class'] = 'form' . ucfirst($this->_inputType); // Wrap the radios in labels $radio = ' <label' . $this->_htmlAttribs($labelAttribs) . '>' . '<input type="' . $this->_inputType . '"' . ' name="' . $name . '"' . ' id="' . $optId . '"' . ' value="' . $this->view->escape($optionValue) . '"' . $checked . $disabled . $this->_htmlAttribs($attribs) . $endTag . '<span>' . $optionLabel . '</span>' . '</label>'; // add to the array of radio buttons $xhtml[] = $radio; } // add container close tag $xhtml[] = ' </div>'; $xhtml[] = ' </div>'; $xhtml[] = '</div>'; $xhtml[] = '<div class="formFancySelectLabel">'; if (!empty($notice)) { $xhtml[] = $notice; } $xhtml[] = '</div>'; if ($showChoice) { $xhtml[] = '<div class="formFancySelectValue"></div>'; } else { $xhtml[] = '<div class="formFancySelectClear"></div>'; } return implode("\n", $xhtml); }
/** * Displays the file list in an HTML format * URL example : http://<url>/Adminfiles/Services/displayfiles/format/json * * @return void */ public function displaypeopleAction() { $r = $this->getRequest(); $ts = 1; if (isset($r->vmode)) { $this->view->vmode = $r->vmode; if ($r->vmode == 'list') { $ts = 3; } } $this->view->embeded = 'no'; $this->view->context = 'default'; if (isset($r->embeded)) { $this->view->embeded = $r->embeded; } if (isset($r->context)) { $this->view->context = $r->context; } $this->view->files = array(); $fltr = new Zend_Filter_Digits(); $desc = $fltr->filter($r->desc); $order = $fltr->filter($r->order); $count = $fltr->filter($r->count); $offset = $fltr->filter($r->offset); $filter = $fltr->filter($r->filter); $fcompany = $fltr->filter($r->fcompany); $fgroup = $fltr->filter($r->fgroup); $fstatus = $fltr->filter($r->fstatus); $fltr = new Zend_Filter_Alnum(); $searchstr = $fltr->filter($r->searchstr); // GDE - #52-Ajouts exports CSV - 07/08/2013 // On enregistre les filtres afin de pouvoir les utiliser lors de l'export $registry = new Zend_Session_Namespace('registry-people'); if (!$this->isCsv()) { $registry->peopleFilterCompany = $fcompany; $registry->peopleFilterGroup = $fgroup; $registry->peopleFilterStatus = $fstatus; $registry->searchstr = $searchstr; } else { $fcompany = $registry->peopleFilterCompany; $fgroup = $registry->peopleFilterGroup; $fstatus = $registry->peopleFilterStatus; $searchstr = $registry->searchstr; } if (isset($r->embeded)) { $this->view->embeded = $r->embeded; } if (isset($r->context)) { $this->view->context = $r->context; } // define filters $filters = ''; if (isset($searchstr)) { $filters .= " AND ( (LOWER( CONCAT(users.fname, ' ', users.lname)) LIKE '%" . addslashes(strtolower($searchstr)) . "%') OR login like '%" . addslashes(strtolower($searchstr)) . "%' ) "; } if (isset($r->fgroup) && trim($fgroup) != '') { $filters .= " AND users.usersgroups_id = {$fgroup} "; } if (isset($r->fstatus) && trim($fstatus) != '') { $filters .= " AND users.active = {$fstatus} "; } if (isset($r->fcompany)) { if ($r->fcompany != '') { $filters .= " AND companies.id = '" . addslashes($r->fcompany) . "' "; } } // GDE - #52-Ajouts exports CSV - 07/08/2013 // On d�sactive la limitation du nombre de r�sultats pour l'export csv if ($this->isCsv()) { $count = 0; } $sql = UsersOp::getSqlUserList($this->usersData, array($filters, $order, $count, $offset, $fcompany, $fgroup, $searchstr)); $sqlCount = UsersOp::getSqlUserList($this->usersData, array($filters, $order, $count, $offset, $fcompany, $fgroup, $searchstr), true); $this->view->users_id = $this->usersId; $this->view->people = $this->_db->fetchAll($sql); //$where, $order, $count, $offset // sets the number of pages if (!$this->isCsv()) { $resultCount = $this->_db->fetchAll($sqlCount); $this->view->nbpages = ceil($resultCount[0]['cnt'] / $count); } }
/** * * @param type name desc * @uses Clase::methodo() * @return type desc */ public function urlFriendly($value, $valuechange = '', $min = '') { if (!self::$_unicodeEnabled) { // POSIX named classes are not supported, use alternative a-zA-Z0-9 match $pattern = '/[^a-zA-Z0-9]/'; } else { if (self::$_meansEnglishAlphabet) { //The Alphabet means english alphabet. $pattern = '/[^a-zA-Z0-9]/u'; } else { //The Alphabet means each language's alphabet. $pattern = '/[^\\p{L}\\p{N}]/u'; } } if (trim($valuechange) != "") { $str = preg_replace('/\\s\\s+/', ' ', preg_replace($pattern, ' ', $value)); $replace = array("á", "à", "é", "è", "í", "ì", "ó", "ò", "ú", "ù", "ñ", "Ñ", "Á", "À", "É", "È", "Í", "Ì", "Ó", "Ò", "Ú", "Ù"); $change = array("a", "a", "e", "e", "i", "i", "o", "o", "u", "u", "n", "N", "A", "A", "E", "E", "I", "I", "O", "O", "U", "U"); $str = str_replace($replace, $change, $str); if ($min == 1) { return str_replace(" ", $valuechange, strtoupper($str)); } if ($min == 0) { return str_replace(" ", $valuechange, strtolower($str)); } if ($min == '') { return str_replace(" ", $valuechange, $str); } } else { return parent::filter($value); } }
public function testEachRadioShouldUseAttributeIdWhenSpecified() { $options = array('foo bar' => 'Foo', 'bar baz' => 'Bar', 'baz' => 'Baz'); $html = $this->helper->formRadio(array('name' => 'foo[bar]', 'value' => 'bar', 'attribs' => array('id' => 'foo-bar'), 'options' => $options)); require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); foreach ($options as $key => $value) { $id = 'foo-bar-' . $filter->filter($key); $this->assertRegexp('/<input([^>]*)(id="' . $id . '")/', $html); } }
public function ajaxsignupAction() { $session = $this->_getSession(); if ($session->isLoggedIn()) { $this->_redirect('*/*/'); return; } $helper = Mage::helper('common'); $session->setEscapeMessages(true); // prevent XSS injection in user input if ($this->getRequest()->isPost()) { $errors = array(); // validate data $password = $this->getRequest()->getPost('password'); $email = $this->getRequest()->getPost('email'); $gender = $this->getRequest()->getPost('gender'); $mobile = $this->getRequest()->getPost('mobile'); $gaCookies = Mage::getModel('nosql/parse_ga')->getCookies(); if (!is_array($gaCookies) || count($gaCookies) <= 0) { $gaCookies = Mage::helper('common')->getCustomCookies(); } $source = strtolower($gaCookies['campaign']['source']); $campaign = strtolower($gaCookies['campaign']['name']); $filter = new Zend_Filter_Alnum(); $password = $filter->filter($password); $emailArr = explode('@', $email); if (!Zend_Validate::is($email, 'EmailAddress')) { $errors[] = 'Please enter valid email address.'; } else { if (!Zend_Validate::is($password, 'NotEmpty')) { $errors[] = 'Please enter password.'; } else { if (!Zend_Validate::is($password, 'StringLength', array(6))) { $errors[] = 'The minimum password length is 6.'; } } } if (count($errors) == 0) { try { $websiteId = Mage::app()->getWebsite()->getId(); $store = Mage::app()->getStore(); $customer = Mage::getModel('customer/customer')->setId(null); $customer->setWebsiteId($websiteId); $customer->loadByEmail($email); $mobcheck = $helper->checkMob($mobile); if (!$customer->getId() && !$mobcheck) { if ($this->getRequest()->getPost('is_subscribed')) { $data = array('email' => $email, 'password' => $password, 'gender' => $gender, 'mobile' => $mobile, 'is_subscribed' => true, 'source' => $source, 'campaign' => $campaign); } else { $data = array('email' => $email, 'password' => $password, 'gender' => $gender, 'mobile' => $mobile, 'source' => $source, 'campaign' => $campaign); } Mage::getSingleton('core/session')->setNewCustData($data); $result = $helper->generateOtp($mobile, $email); if ($result == true) { echo 1; } else { echo $result; } } else { if ($customer->getId()) { echo 'You have an existing account using this email id.'; } else { if ($mobcheck) { echo 'You have an existing account using this phone no.'; } else { echo 'Try Again !'; } } } } catch (Exception $ex) { echo $ex->getMessage(); } } else { echo implode($errors, '<br>'); } } else { echo 'Invalid data'; } die; }