Example #1
0
 function generateControllerPage($merge_values)
 {
     $target_folder = AMP_pathFlip(AMP_LOCAL_PATH . '/custom/system/');
     if (!is_dir($target_folder)) {
         AMP_mkdir($target_folder);
     }
     $target_path = $target_folder . $this->getControllerPage();
     #$result_file = vsprintf( file_get_contents( $this->getScaffoldPath( ). 'Controller.inc.php' ), $merge_values );
     $result_file = $this->stupidSingleQuoteVsprintfWorkaround(file_get_contents($this->getScaffoldPath() . 'Controller.inc.php'), $merge_values);
     $this->_writeFile($target_path, $result_file);
 }
function AMP_add_image_subfolder($folder_name)
{
    $ok = false;
    foreach (AMP_lookup('image_classes') as $image_class => $image_class_name) {
        $class_folder = AMP_LOCAL_PATH . AMP_IMAGE_PATH . $image_class . DIRECTORY_SEPARATOR . $folder_name;
        $ok = AMP_mkdir($class_folder);
        if (!$ok) {
            trigger_error('Unable to create folder' . $class_folder);
            break;
        }
    }
    if ($ok) {
        AMP_lookup_clear_cached('image_folders');
        return $folder_name;
    }
    return false;
}
Example #3
0
 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;
 }