function _addElementCaptcha($name, $field_def) { $false = false; if ($this->_has_captcha) { return $false; } $this->_has_captcha = true; // use recaptcha if its set up if (defined('RECAPTCHA_PRIVATE_KEY') && RECAPTCHA_PRIVATE_KEY) { require 'recaptcha/recaptchalib.php'; $error_html = ""; if (isset($_POST['recaptcha_response_field']) && !AMPForm::validate_recaptcha()) { $error_html = "<!-- BEGIN error --><span style=\"color: #ff0000\">" . AMP_TEXT_ERROR_FORM_CAPTCHA_FAILED . "</span><br /><!-- END error -->\t"; } $fRef = $this->form->addElement('static', 'captcha_' . $name, "", $error_html . recaptcha_get_html(RECAPTCHA_PUBLIC_KEY)); $this->form->addElement('hidden', 'recaptcha_response_field'); $this->form->addRule('recaptcha_response_field', AMP_TEXT_ERROR_REQUIRED_FIELD_MISSING, 'required'); $rule_config = array('AMPForm', 'validate_recaptcha'); $this->form->addRule('recaptcha_response_field', AMP_TEXT_ERROR_FORM_CAPTCHA_FAILED, 'callback', $rule_config); return $fRef; // use craptastic captcha otherwise } else { $this->_addUniqueIdValue(); require_once 'AMP/Content/Display/HTML.inc.php'; $renderer = new AMPDisplay_HTML(); $this->form->addElement('static', 'captcha_' . $name, "", $renderer->image(AMP_Url_AddVars(AMP_CONTENT_URL_CAPTCHA, array('key=' . AMP_SYSTEM_UNIQUE_VISITOR_ID)), array('align' => 'center'))); $defaults = $this->_getDefault($name); $fRef = $this->form->addElement('text', $name, $field_def['label'], $defaults); require_once 'AMP/Form/Element/Captcha.inc.php'; $captcha_demo = new PhpCaptcha(array()); $rule_config = array($captcha_demo, 'Validate'); $this->form->addRule($name, AMP_TEXT_ERROR_FORM_CAPTCHA_FAILED, 'callback', $rule_config); return $fRef; } }
function AMP_navCountDisplay_Section($section_id) { if (!$section_id) { return false; } if (is_array($section_id)) { return false; } static $renderer = false; static $layout_lists = false; static $layout_content = false; static $navcount_layouts = false; if (!$renderer) { $renderer = new AMPDisplay_HTML(); } if (!$layout_lists) { $layout_lists =& AMPContent_Lookup::instance('navLayoutsBySectionList'); } if (!$layout_content) { $layout_content =& AMPContent_Lookup::instance('navLayoutsBySection'); } if (!$navcount_layouts) { $navcount_layouts =& AMPContent_Lookup::instance('navLayoutLocationCount'); } $count_lists = false; $count_content = false; $layout_id_content = $layout_content ? array_search($section_id, $layout_content) : false; $layout_id_lists = $layout_lists ? array_search($section_id, $layout_lists) : false; $url_vars_lists = array('action=add', 'section_id_list=' . $section_id); $url_vars_content = array('action=add', 'section_id=' . $section_id); if ($layout_id_lists) { //$count_lists = "( " . $navcount_layouts[ $layout_id_lists ] . " )"; $count_lists = $navcount_layouts[$layout_id_lists]; $url_vars_lists = array('id=' . $layout_id_lists); } if ($layout_id_content) { //$count_content = "( " . $navcount_layouts[ $layout_id_content ] . " )"; $count_content = $navcount_layouts[$layout_id_content]; $url_vars_content = array('id=' . $layout_id_content); } $navlink_lists = $renderer->link(AMP_URL_AddVars(AMP_SYSTEM_URL_NAV_LAYOUT, $url_vars_lists), $count_lists . $renderer->image('/img/list_page' . ($count_lists ? '' : '_create') . '.png'), array('title' => sprintf(AMP_TEXT_WHAT_FOR_WHAT, $count_content ? AMP_TEXT_SYSTEM_LINK_NAV_LAYOUT_EDIT : AMP_TEXT_SYSTEM_LINK_NAV_LAYOUT_CREATE, AMP_TEXT_LIST_PAGES))); $navlink_content = $renderer->link(AMP_URL_AddVars(AMP_SYSTEM_URL_NAV_LAYOUT, $url_vars_content), $count_content . $renderer->image('/img/content_page' . ($count_content ? '' : '_create') . '.png'), array('title' => sprintf(AMP_TEXT_WHAT_FOR_WHAT, $count_content ? AMP_TEXT_SYSTEM_LINK_NAV_LAYOUT_EDIT : AMP_TEXT_SYSTEM_LINK_NAV_LAYOUT_CREATE, AMP_TEXT_CONTENT_PAGES))); return $renderer->div($navlink_lists . $navlink_content, array('class' => 'icon')); return $renderer->in_P($navlink_lists . $renderer->newline() . $navlink_content); }
function _commit_crop_thumbnail($real_sizes) { $target_path = AMP_image_path($this->_model->getName(), AMP_IMAGE_CLASS_CROP); #AMP_mkdir( substr( $target_path, 0, strlen( $target_path ) - strlen( $this->_model->getName() - 1))); AMP_mkdir(dirname($target_path)); $new_image =& $this->_model->crop($real_sizes['start_x'], $real_sizes['start_y'], $real_sizes['start_x'] + $real_sizes['width'], $real_sizes['start_y'] + $real_sizes['height']); if (!$new_image) { return $this->_commit_crop_failure(); } $this->_model->write_image_resource($new_image, $target_path); $cropped_image = new AMP_System_File_Image($target_path); if (!$cropped_image->width) { return $this->_commit_crop_failure(); } $target_path = AMP_image_path($this->_model->getName(), AMP_IMAGE_CLASS_THUMB); $thumb_ratio = AMP_IMAGE_WIDTH_THUMB / $cropped_image->width; $thumb_sizes = $this->_resize_ratio(array('height' => $cropped_image->height, 'width' => $cropped_image->width), $thumb_ratio); $thumb_image =& $cropped_image->resize($thumb_sizes['width'], $thumb_sizes['height']); if (!$thumb_image) { return $this->_commit_crop_failure(AMP_TEXT_THUMBNAIL); } $cropped_image->write_image_resource($thumb_image, $target_path); $renderer = new AMPDisplay_HTML(); $this->message($renderer->image(AMP_image_url($this->_model->getName(), AMP_IMAGE_CLASS_CROP), array('border' => 1)) . $renderer->newline(2) . sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $cropped_image->getName() . $renderer->space() . AMP_TEXT_CROP), $this->_unique_action_key(), $this->_model->get_url_edit()); return true; }