/** * Renders the reCAPTCHA widget. * * @param string $error The error message given by reCAPTCHA. * @param boolean $ssl Determines is the request should be made over SSL. * * @return string - The HTML to be embedded in the user's form. */ public function render($config = array()) { $config = new Library\ObjectConfig($config); $params = $this->getObject('application.extensions')->users->params; $config->append(array('captcha' => array('public_key' => $params->get('recaptcha_public_key', null), 'api_server' => 'http://www.google.com/recaptcha/api', 'api_secure_server' => 'https://www.google.com/recaptcha/api', 'options' => array('theme' => 'clean', 'lang' => 'en')), 'error' => '', 'ssl' => false)); $captcha = $config->captcha; $html = ''; if ($public_key = $captcha->public_key) { if ($config->ssl) { $server = $captcha->api_secure_server; } else { $server = $captcha->api_server; } if ($config->error) { $config->error = '&error=' . $config->error; } // Use options if any. if (count($options = $captcha->options)) { $options = Library\ObjectConfig::unbox($options); $html .= '<script type="text/javascript">'; $html .= 'var RecaptchaOptions = ' . json_encode($options); $html .= '</script> '; } $html .= '<script data-inline type="text/javascript" src="' . $server . '/challenge?k=' . $public_key . $config->error . '"></script> <noscript> <iframe src="' . $server . '/noscript?k=' . $public_key . $config->error . '" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> </noscript>'; } return $html; }
public function __construct(Library\ObjectConfig $config) { parent::__construct($config); if (isset($config->adapters)) { $this->_adapters = Library\ObjectConfig::unbox($config->adapters); } }
protected function _afterAdapterSelect(Library\CommandContext $context) { //Get the data $rows = Library\ObjectConfig::unbox($context->result); if (is_array($rows)) { $children = array(); $result = array(); /* * Create the children array */ foreach ($rows as $key => $row) { $path = array(); $parent = $row['parent_id']; //Store node by parent if (!empty($parent) && isset($rows[$parent])) { $children[$parent][] = $key; } } /* * Create the result array */ foreach ($rows as $key => $row) { if (empty($row['parent_id'])) { $result[$key] = $row; if (isset($children[$key])) { $this->_getChildren($rows, $children, $key, $result); } } } /* * If we have not been able to match all children to their parents don't perform * the path enumeration for the children. */ if (count($result) == count($rows)) { if ($context->limit) { $result = array_slice($result, $context->offset, $context->limit, true); } /* * Create the paths of each node */ foreach ($result as $key => $row) { $path = array(); $parent = $row['parent_id']; if (!empty($parent)) { $table = $this->_table; //Create node path $path = $result[$parent]['path']; $id = $result[$parent][$table->getIdentityColumn()]; $path[] = $id; } //Set the node path $result[$key]['path'] = $path; } } else { $result = $rows; } $context->result = $result; } }
protected function _initialize(Library\ObjectConfig $config) { $size = Library\ObjectConfig::unbox($config->thumbnail_size); if (empty($size)) { $config->thumbnail_size = array('x' => 200, 'y' => 150); } parent::_initialize($config); }
public function __construct(Library\ObjectConfig $config) { parent::__construct($config); if ($config->columns) { $this->_columns = Library\ObjectConfig::unbox($config->columns); } if ($config->table) { $this->_table = $config->table; } }
public function __construct(Library\ObjectConfig $config) { // Need to set strategy before parent::__construct, otherwise strategy won't be available in getMixableMethods(). if ($config->strategy) { $identifier = clone $config->object_identifier; $identifier->path = array('database', 'behavior', 'orderable'); $identifier->name = $config->strategy; $this->setStrategy($config->object_manager->getObject($identifier, Library\ObjectConfig::unbox($config))); } parent::__construct($config); }
public function groups($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => '', 'row' => '', 'package' => '', 'model' => 'groups', 'label' => 'title', 'deselect' => ''))->append(array('selected' => ''))->append(array('filter' => array('sort' => 'title'))); $identifier = 'com:products.model.' . ($config->model ? $config->model : Library\StringInflector::pluralize($config->package)); $categories = $this->getObject($identifier)->setState(Library\ObjectConfig::unbox($config->filter))->getRowset(); $options = $this->options(array('entity' => $categories, 'value' => 'id', 'label' => $config->label)); if ($config->deselect) { array_unshift($options, $this->option(array('label' => '-- Select --', 'value' => '0'))); } //Add the options to the config object $config->options = $options; return $this->optionlist($config); }
public function categories($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => 'categories_category_id', 'row' => '', 'uncategorised' => false, 'max_depth' => '9'))->append(array('selected' => $config->row->{$config->name}))->append(array('filter' => array('sort' => 'title', 'parent' => null, 'published' => null, 'table' => $config->row->getTable()->getBase()))); $categories = $this->getObject('com:categories.model.categories')->setState(Library\ObjectConfig::unbox($config->filter))->getRowset(); $iterator = new DatabaseIteratorNode($categories); $iterator->setMaxDepth($config->max_depth); $options = $this->options(array('entity' => $iterator, 'value' => 'id', 'label' => 'title')); if ($config->uncategorised) { array_unshift($options, $this->option(array('label' => $this->translate('Uncategorized'), 'value' => '0', 'id' => '0'))); } //Add the options to the config object $config->options = $options; return parent::radiolist($config); }
protected function _actionMove(Library\CommandContext $context) { $entity = $this->getModel()->getRow(); if (!$entity->isNew()) { $entity->setData(Library\ObjectConfig::unbox($context->request->data->toArray())); //Only throw an error if the action explicitly failed. if ($entity->move() === false) { $error = $entity->getStatusMessage(); throw new Library\ControllerExceptionActionFailed($error ? $error : 'Move Action Failed'); } else { $context->response->setStatus($entity->getStatus() === Library\Database::STATUS_CREATED ? self::STATUS_CREATED : self::STATUS_UNCHANGED); } } else { throw new Library\ControllerExceptionNotFound('Resource Not Found'); } return $entity; }
public function validate($row) { $mimetypes = Library\ObjectConfig::unbox($row->getContainer()->parameters->allowed_mimetypes); if (is_array($mimetypes)) { $mimetype = $row->mimetype; if (empty($mimetype)) { if (is_uploaded_file($row->file) && $row->isImage()) { $info = getimagesize($row->file); $mimetype = $info ? $info['mime'] : false; } elseif ($row->file instanceof SplFileInfo) { $mimetype = $this->getObject('com:files.mixin.mimetype')->getMimetype($row->file->getPathname()); } } if ($mimetype && !in_array($mimetype, $mimetypes)) { return $this->_error(\JText::_('Invalid Mimetype')); } } }
public function pages($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('deselect' => true, 'prompt' => '- Select -', 'disable' => array())); $options = array(); if ($config->deselect) { $options[] = $this->option(array('text' => JText::_($config->prompt))); } $menus = $this->getObject('com:pages.model.menus')->getRowset(); $pages = $this->getObject('com:pages.model.pages')->published(true)->getRowset(); foreach ($menus as $menu) { $options[] = $this->option(array('text' => $menu->title, 'value' => '', 'disable' => true)); foreach ($pages->find(array('pages_menu_id' => $menu->id)) as $page) { $options[] = $this->option(array('text' => str_repeat(str_repeat(' ', 4), $page->level) . $page->title, 'value' => $page->id, 'disable' => in_array($page->type, Library\ObjectConfig::unbox($config->disable)))); } } $config->options = $options; return $this->optionlist($config); }
public function __construct(Library\ObjectConfig $config) { parent::__construct($config); $this->_actions = Library\ObjectConfig::unbox($config->actions); $this->_title_column = Library\ObjectConfig::unbox($config->title_column); }
public function getEditorSettings() { return Library\ObjectConfig::unbox($this->_editor_settings); }
/** * Method to read child nodes of a folder * * @param array $config */ public static function getNodes($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('path' => null, 'type' => null, 'recurse' => false, 'fullpath' => false, 'filter' => null, 'map' => null, 'exclude' => array('.svn', '.git', 'CVS'), 'sort' => 'name', 'return_raw' => false)); $exclude = Library\ObjectConfig::unbox($config->exclude); $filter = Library\ObjectConfig::unbox($config->filter); $map = Library\ObjectConfig::unbox($config->map); $recurse = $config->recurse; $results = array(); foreach (new self($config->path) as $file) { if ($file->isDot() || in_array($file->getFilename(), $exclude)) { continue; } if ($file->isDir() && !$file->isDot() && $recurse) { $clone = clone $config; $clone->path = $file->getPathname(); $clone->recurse = is_int($config->recurse) ? $config->recurse - 1 : $config->recurse; $clone->return_raw = true; $child_results = self::getNodes($clone); } if ($config->type) { $method = 'is' . ucfirst($config->type === 'files' ? 'file' : 'dir'); if (!$file->{$method}()) { continue; } } if ($filter) { if (is_callable($filter)) { $ignore = call_user_func($filter, rawurldecode($file->getPathname())) === false; } else { if (is_array($filter)) { $ignore = !in_array(strtolower($file->getExtension()), $filter); } else { if (is_string($filter)) { $ignore = !preg_match("/{$filter}/", $file->getFilename()); } } } if ($ignore) { continue; } } if (is_callable($map)) { $result = call_user_func($map, rawurldecode($file->getPathname())); } else { $result = $config->fullpath ? $file->getPathname() : $file->getFilename(); } $results[] = array('path' => $result, 'modified' => $file->getMTime()); if (!empty($child_results)) { $results = array_merge($results, $child_results); } } if ($config->sort === 'modified_on') { uasort($results, array('self', '_sortByDate')); } elseif ($config->sort === 'name') { uasort($results, array('self', '_sortByName')); } if ($config->return_raw === true) { return $results; } $return = array(); foreach ($results as $result) { $return[] = $result['path']; } return $return; }