Herramientas - Documentación

Slides:



Advertisements
Presentaciones similares
Noviembre– La lección tres. cgaisar arcasigaasar carga caracasagasasaca caigaarcascasarsacargracias.
Advertisements

Introducción Lenguaje de manipulación de datos (Data Manipulation Language) Permite a los usuarios llevar a cabo las tareas de consulta o manipulación.
2003 HYPACK MAX Training Seminar1 Sample Case la Entrada manual de Datos de la Línea de la costa El Metodo de MANUAL –DIG Objectos –Boya (Roja)
Lenguaje de consulta de Hibernate
 Making complete sentences How to make complete sentences in Spanish. The following presentation is designed to help you learn how to do the following:
Editing Slides With Polaris Office, you can create new .ppt and .pptx presentations or edit your presentation with ease.
If anidados y Switch Prof. Lillian Bras.
Programación orientada a objetos
Bases de datos en la Web n Las bases de datos permiten almacenar de una forma estructurada y eficiente toda la información de un sitio web n Ventajas –Proporcionar.
Programación en Visual Basic Lección #8: SQL Por Antonio F. Huertas.
Empecemos: Tell your friend to do the following… 1.Set the table 2.Wash the clothes 3.Vacuum 4.Sweep the floor 5.Clean the mirror.
DELETE THIS SLIDE BEFORE HANDING IN See the rubric for more details Deadlines will not change, no excuses…all projects must be ed
MSSQL SERVER CURSO BÁSICO 1. CONCEPTOS BASICOS DE SQL. DESCRIPCIÓN DEL CURSO. Sesión 3: Índices Uso, Creación, Tipos, Eliminación LENGUAJE DE CONSULTAS.
LECCIÓN 2: SEGUNDA PARTE Today you will learn: To discusses subjects and classes at school Today you will review: How to tell time in Spanish.
Las clases de Sra. Schwarz Realidades 1 The Verb IR.
ECOM-6030 PASOS PARA LA INSTALACIÓN DE EASYPHP Prof. Nelliud D. Torres © - Derechos Reservados.
Un juego de adivinanzas: ¿Dónde está el tesoro? A1B1C1D1E1F1 A4B4C4D4E4F4 A2B2C2D2E2F2 A5B5C5D5E5F5 A3B3C3D3E3F3 A6B6C6D6E6F6 Inténtalo de nuevo Inténtalo.
AA Gerardo Morgade Donato AA Isnel Leyva Herbella.
Structure Query Languaje SQL. Introducción a SQL El lenguaje de consulta estructurado (SQL) es un lenguaje de base de datos normalizado, utilizado por.
DLM Transact SQL Sesión II Recuperación de información.
Querys a bases de datos con MS ACCESS. DEFINAMOS LOS TERMINOS: DML=Lenguaje de manipulación de datos Las sentencias DML permiten generar consultas para.
DML Transact SQL Sesión X Triggers. Duración 2 Horas.
Trabajar con módulosTrabajar con variables públicasCrear procedimientos Pasar argumentos por valor y por referencia Referencia rápida.
JoomlaDay 2009 Taller avanzado de programación. JoomlaDay - Taller Avanzado de Desarrollo - Índice ● Introducción: Presentación ● Introducción: Objetivos.
Saregune CC 2009 SQL Introducción. base de datos Una estructura ordenada de información.
¿Qué es el theming? Es el proceso de generar html y css a partir de los datos de nuestra aplicación. El diseño de una aplicación web hecha con Drupal lo.
Noviembre – La Lección Uno. mlrápaas alarpalapalas palma alasalmaalmas palmarpalmasramarasparasa.
Opciones del Package Manager. - Create new package: Me permite crear un nuevo paquete - Write new specification files for all installed, locally generated.
SQL: Structured Query Language
Bienvenidos.
EasyChair How to submit a paper Como someter un paper
Hoy es martes en el mundo
Introducción a JAVA COMP 250.
Ad_form Multirow Db_multirow.
BASE DE DATOS IUPSM CLASE PRACTICA. PROF. ING. JOSE L GUZMAN H.
GRUPO 15 SC FRAMEWORK LARAVEL
Structure Query Languaje
CONJUGATIONS TOP 10 IRREGULAR VERBS.
Lo esencial de Internet
RCM SAE JA 1011 Evaluation Criteria for Reliability-Centered Maintenance (RCM) Processes Criterios de evaluación para los procesos de Mantenimiento Centrado.
Interactive Math Notebooks
Base de Datos II Almacenamiento.
Español 2 5 de diciembre de 2016
Conoce Symfony …Así va a funcionar el nuevo drupal
Oracle Pl/SQl Developer – Nivel 1
Los doce días de Navidad Versión: PROFE y la clase de español
JSF – Beans administrados y navegación
Structure Query Languaje
How to Log in to RosettaStone and Install the Speech Component
Aggregation framework con PyMongo
EasyChair How to submit a paper Como someter un paper
Integration Services.
Direct Object Pronouns
COD ¿Qué queremos hacer?
Printing: This poster is 48” wide by 36” high. It’s designed to be printed on a large-format printer. Customizing the Content: The placeholders in this.
Unit 2 audio recording name the recording file: username unit 2 vocabulary (example: MMM4 unit 2 vocabulary) (If working in partners, include both usernames.)
EL TIEMPO PRESENTE ESPAÑOL 2.
1 Use or disclosure of data contained on this sheet is subject to the restriction on the title page of this proposal or quotation. 1 Add a Slide Title.
A PowerPoint Template Your Presentation Name. This text is a placeholder Main Content Page Layout 2 Copyright 2009.
JKSimMet Software (windows & buttons) Split Engineering Chile Ltda. General Salvo #331 oficina 201 Casilla Sucursal Panorámico Providencia – Santiago,
Fundamentals of Web Development - 2 nd Ed.Randy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar © 2017 Pearson.
Climate data in R with the raster package Jacob van Etten.
Development of the concert programme
Juliana Carmona Esteban Cano
Día 2 –Español 4 NS (HL) y NM (SL)
Direct Object Pronouns
To insert audio you need to be on that slide
Arrays Programming COMP102 Prog. Fundamentals I: Arrays / Slide 2 Arrays l An array is a collection of data elements that are of the same type (e.g.,
Welcome to PowerPoint gdskcgdskfcbskjc. Designer helps you get your point across PowerPoint Designer suggests professional designs for your presentation,
TABLET INFORMATION SUBMIT A Presentation Template.
Transcripción de la presentación:

Herramientas - Documentación * http://doc.prestashop.com/dashboard.action * https://www.prestashop.com/forums/ 1

Herramientas - Git (colaborar en el proyecto prestashop) - Jira (sistema de seguimiento de bugs. Prestashop forge) - Generador de módulos  - Validador de módulos 2

Herramientas - Herramientas de desarrollo * Netbeans * Xdebug * Firebug  * PrestaShop norm validator (PHP_CodeSniffer) https://github.com/PrestaShop/PrestaShop-norm-validator https://github.com/squizlabs/PHP_CodeSniffer * Standard coding hook (git) https://github.com/PrestaShop/standard_coding_hook * Testing framework (PHPUnit) https://phpunit.de/ https://github.com/sebastianbergmann/phpunit * Go to validator in the FAQ module 1.4.0 https://www.prestashop.com/forums/topic/113050-module-faq-gratuit-ps-14-et-ps-132/ 3

Desarrollando módulos - Ficheros * Directorio del módulo (nombre_del_módulo) * Fichero “hook” (nombre_del_módulo.php) * Ficheros de idioma (en 1.6 van dentro del directorio ./translations/) * Fichero cache de configuración (config.xml) * Controladores ./controllers/ * Clases* sobreescritas ./override/ * Ficheros de vistas (en 1.6 van dentro del directorio ./views/). “./views/css”, “./views/sass”, “./views/js”, “./views/templates/front” (vistas usadas por el controlador), “./views/templates/hooks” (vistas usadas por los hooks del módulo) * Logos (16x16 gif / 32x32 png) * Readme.md * Para versiones superiores a 1.6.0.11 puede haber un directorio ./test con los ficheros de testeo 4

Desarrollando módulos Fichero “hook” <?php if (!defined('_PS_VERSION_')) exit; class HelloWorld extends Module { } 5

Desarrollando módulos La función de inicialización: public function __construct() { $this->name = 'helloworld'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Me'; $this->bootstrap = true; // New 1.6 $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6'); // required Prestashop 1.5 $this->dependencies = array('blockcart'); // need blockcart module. ... } Desde este momento el módulo es visible en el backoffice 6

Desarrollando módulos La función de inicialización: public function __construct() { ... parent::__construct(); $this->displayName = $this->l('Hello World'); $this->description = $this->l('This is an example module'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('HELLO_WORLD_NAME')) $this->warning = $this->l('No name provided'); } Desde este momento el módulo es visible en el backoffice 7

Desarrollando módulos Ejemplo 'blockcategories' (La función de inicialización) } 8

Desarrollando módulos El fichero cache: El fichero cache lo puede crear automáticamente Prestashop, y se va a utilizar para que se generen las listas de módulos de forma más rápida en el backoffice. <?xml version="1.0" encoding="UTF-8" ?> <module> <name>helloworld</name> <displayName>Hello World></displayName> <version>1.0></version> <description>This is an example module></description> <author>Moi</author> ... </module> 9

Desarrollando módulos El fichero cache: El fichero cache lo puede crear automáticamente Prestashop, y se va a utilizar para que se generen las listas de módulos de forma más rápida en el backoffice. <?xml version="1.0" encoding="UTF-8" ?> <module> ... <tab>front_office_features></tab> <confirmUninstall>Are you sure you want to uninstall?</confirmUninstall> <is_configurable>1</is_configurable> <need_instance>1</need_instance> <limited_countries></limited_countries> </module> 10

Desarrollando módulos Ejemplo 'blockbanner' (El fichero cache) </module> 11

Desarrollando módulos La función de instalación: public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() OR !$this->registerHook('leftColumn') OR !$this->registerHook('header') OR !Configuration::updateValue('HELLO_WORLD_NAME', 'World')) return false; return true; } 12

Desarrollando módulos Ejemplo 'blockcategories' (La función de instalación) $tab->module = $this->name; } 13

Desarrollando módulos Ejemplo 'blockcategories' (La función de instalación) !$this->registerHook('leftColumn') || } 14

Desarrollando módulos Ejemplo 'blockcategories' (La función de instalación) } 15

Desarrollando módulos La función de desinstalación: public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('HELLO_WORLD_NAME') ) return false; return true; } 16

Desarrollando módulos Ejemplo 'blockcategories' (La función de desinstalación) public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('HELLO_WORLD_NAME') ) return false; return true; } 17

Desarrollando módulos Función para mostrar algo en algún hook: public function hookDisplayLeftColumn($params) { $this->context->smarty->assign(array( 'name' => Configuration::get('HELLO_WORLD_NAME') )); return $this->display(__FILE__, 'helloworld.tpl'); } 18

Desarrollando módulos Función para mostrar algo en algún hook (Cont.) Podemos reutilizar el código para otro hook: public function hookDisplayRightColumn($params) { return $this->hookDisplayLeftColumn($params); } 19

Desarrollando módulos Función para mostrar algo en algún hook (Cont.) Si queremos añadir archivos css o js utilizaremos: public function hookDisplayHeader($params) { $this->context->controller->addCSS($this->_path.'views/css/helloworld.css', 'all'); } 20

Desarrollando módulos Función para mostrar algo en algún hook (Cont.) HookDisplay...: Para usar un Hook en un Template usamos Smarty, {hook h='NameOfHook'}     </div> Para usar un Hook en un Controller, Hook::exec('NameOfHook')     $this->context->smarty->assign('HOOK_LEFT_COLUMN', Hook::exec('leftColumn')); 21

Desarrollando módulos Función para mostrar algo en algún hook (Cont.) HookDisplay... (Cont.) Para usar un Hook en un Módulo debemos crear un método no estático y publico, cuyo nombre comience por "hook", seuido de "Display" o "Action" (según el hook en el que queramos mostrar o ejecutar código), y el nombre del hook que queramos. Al metodo le pasaremos un solo argumento, con información del objeto context. } 22

Desarrollando módulos Función para mostrar algo en algún hook (Cont.) HookDisplay... (Cont.) Para responder a la llamada de un hook en el módulo, este hook debe estar registrado en PrestaShop. El registro se realiza con la función "registerHook". El registro* se crea durante la instalación del módulo. } 23

Desarrollando módulos Función para mostrar algo en algún hook (Cont.) HookDisplay... (Cont.) Podemos crear un nuevo hook, añadiendo un nuevo registro a la tabla "ps_hook"*, y teniendo en cuenta que vamos a tener que incorporar este hook a nuestro tema... $myHook->save(); Desde la versión 1.5, se añaden automaticamente los hook a la tabla 'ps_hook', cuando llamamos a la función registerHook('nameOfHook') en la clase del módulo. 24

Desarrollando módulos Configurar nuestro módulo: public function getContent()  {     $output = '';     if (Tools::isSubmit('submit'.$this->name))      {          $HELLO_WORLD_NAME = strval(Tools::getValue('HELLO_WORLD_NAME'));          if (!$HELLO_WORLD_NAME OR              empty($HELLO_WORLD_NAME) OR              !Validate::isGenericName($HELLO_WORLD_NAME))              $output .= $this->displayError( $this->l('Invalid Configuration value') );          else          ... } 25

Desarrollando módulos Configurar nuestro módulo (Cont.) public function getContent()  {     ...         else          {              Configuration::updateValue('HELLO_WORLD_NAME',              $HELLO_WORLD_NAME);              $output .= $this->displayConfirmation($this->l('Settings updated'));          }     }      return $output.$this->displayForm();  } 26

Desarrollando módulos Configurar nuestro módulo (Cont.)  Para mostrar nuestra página de configuración: public function displayForm()  { }   27

Desarrollando módulos Configurar nuestro módulo (Cont.)  Para mostrar nuestra página de configuración: public function displayForm()  {      $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Get default Language      $fields_form[0]['form'] = array( // Init Fields form array         'legend' => array( 'title' => $this->l('Settings') ),              'input' => array( …   }   28

Desarrollando módulos Configurar nuestro módulo (Cont.)  public function displayForm()  {      ... 'input' => array(                  array(                      'type' => 'text',                      'label' => $this->l('Configuration value'),                      'name' => 'HELLO_WORLD_NAME',                      'class' => 'fixed-width-xs', // extra small                      'required' => true )             ),              'submit' => array( …   }   29

Desarrollando módulos Configurar nuestro módulo (Cont.)  public function displayForm()  {      ... 'submit' => array(                  'title' => $this->l('Save'),                  'class' => 'button' )             ); …   }   30

Desarrollando módulos Configurar nuestro módulo (Cont.)  public function displayForm()  {      …       $helper = new HelperForm();      $helper->module = $this; // Module, Token and currentIndex     $helper->name_controller = $this->name;      $helper->token = Tools::getAdminTokenLite('AdminModules');      $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;      ... }   31

Desarrollando módulos Configurar nuestro módulo (Cont.)  public function displayForm()  {      …       $helper->default_form_language = $default_lang; // Language      $helper->allow_employee_form_lang = $default_lang;      $helper->title = $this->displayName; // title and Toolbar      $helper->show_toolbar = true; // false -> remove toolbar      $helper->toolbar_scroll = true; // true- > Toolbar is always visible on the top of the screen.      $helper->submit_action = 'submit'.$this->name;      … }   32

Desarrollando módulos Configurar nuestro módulo (Cont.)  public function displayForm()  {      …   $helper->toolbar_btn = array(          'save' => array( 'desc' => $this->l('Save'),              'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'. $this- >name.'&token='.Tools::getAdminTokenLite('AdminModules' ), ),          'back' => array( 'desc' => $this->l('Back to list'),              'href' =>AdminController::$currentIndex.'&token='. Tools::getAdminTokenLite('AdminModules') ) );     ... } 33

Desarrollando módulos Configurar nuestro módulo (Cont.)  Para mostrar nuestra página de configuración: public function displayForm()  {      …    $helper->fields_value['HELLO_WORLD_NAME'] = Configuration::get('HELLO_WORLD_NAME'); // Load current value      return $helper->generateForm($fields_form);  } 34

Desarrollando módulos - Ficheros * Directorio del módulo (nombre_del_módulo) * Fichero “hook” (nombre_del_módulo.php) * Ficheros de idioma (en 1.6 van dentro del directorio ./translations/) * Fichero cache de configuración (config.xml) * Controladores ./controllers/ * Clases* sobreescritas ./override/ * Ficheros de vistas (en 1.6 van dentro del directorio ./views/). “./views/css”, “./views/sass”, “./views/js”, “./views/templates/front” (vistas usadas por el controlador), “./views/templates/hooks” (vistas usadas por los hooks del módulo) * Logos (16x16 gif / 32x32 png) * Readme.md * Para versiones superiores a 1.6.0.11 puede haber un directorio ./test con los ficheros de testeo 35

Desarrollando módulos Mecanismo automático de actualización del módulo: Creamos un subdirectorio ./upgrade/ dentro del directorio de nuestro módulo.  En la función de inicialización debemos definir cual va a ser la nueva versión de nuestro módulo ($this->version = '1.1';) Creamos un script en php para cada nueva versión (/upgrade/install-1.1.php) /* * File /upgrade/install-1.1.php      */      function upgrade_module_1_1($    module)   {          //Process Module upgrade to 1.1       // ....       return     true; // Return true if successful .  } 36

Desarrollando módulos Modelo: Dentro de nuestro módulo podemos crear nuestro ObjectModel, para acceder a nuestra tabla, incluso podemos crear tantos como tablas . Los métodos principales son: public __construct( integer $id = null, integer $id_lang = null, integer $id_shop = null ) // Build object   public boolean add( boolean $autodate = true, boolean $null_values= false ) // Add current object to database  public boolean delete( ) // Delete current object from database  public new duplicateObject( ) // Duplicate current object to database    public array getFields( ) // Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)  ...   37

Desarrollando módulos Modelo (Cont.) Dentro de nuestro módulo podemos crear nuestro ObjectModel, para acceder a nuestra tabla, incluso podemos crear tantos como tablas . Los métodos principales son (Cont.) ... public hydrate( array $data, integer $id_lang = null) // Fill (hydrate) a list of objects in order to get a collection of these objects  public static array hydrateCollection( string $class, array $datas, integer $id_lang = null )   public boolean save( boolean $null_values = false, boolean $autodate =     true) // Save current object to database (add or update) public boolean toggleStatus( ) // Toggle object status in database   public boolean update( boolean $null_values = false ) // Update current object to database  // Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval...)   38

Desarrollando módulos Modelo (Cont.)  La definición: /**  * Example for the CMS Template( CMSCore) */   public static$definition= array(      'table' => 'cms',      'primary' => 'id_cms',      'multilang' => true,//'multilang_shop' => true [multi-idioma + multi-tienda]     'fields' => array( ... 39

Desarrollando módulos Modelo (Cont.)  La definición (Cont.) /**  * Example for the CMS Template( CMSCore) */   public static$definition= array(      … 'fields' => array(          'id_cms_category' =>array('type' => self::TYPE_INT, 'validate'=> 'isUnsignedInt'),         'position' => array('type' => self::TYPE_INT),          'active' => array ('type' => self::TYPE_BOOL),          // Lang fields ... 40

Desarrollando módulos Modelo (Cont.)  La definición (Cont.) public static$definition= array(      … // Lang fields    'meta_description' =>array('type'=>self::TYPE_STRING, 'lang'=>true, 'validate'=>'isGenericName', 'size'=>255),     'meta_keywords' => array('type'=>self::TYPE_STRING, 'lang'=>true, 'validate'=>'isGenericName', 'size'=>255),      'meta_title' => array('type' =>self::TYPE_STRING, 'lang'=>true, 'validate'=>'isGenericName', 'required'=>true, 'size'=>128),       'link_rewrite' => array('type' => self::TYPE_STRING, 'lang'=>true, 'validate'=>'isLinkRewrite', 'required'=>true, 'size'=>128),      'content' => array ('type' => self::TYPE_HTML, 'lang' => true,'validate' => 'isString', 'size' => 3999999999999),      ) );  41

Desarrollando módulos Modelo (Cont.)  Tipos de campos para la definición:      * TYPE_BOOL     * TYPE_DATE         * TYPE_FLOAT         * TYPE_HTML             * TYPE_INT      * TYPE_NOTHING             * TYPE_STRING 42

Desarrollando módulos La clase DBQuery: public __toString( ): Generate and get the query  public string build( ): Generate and get the query public from( string $table, mixed $alias= null ): Set table for FROM clause public groupBy( string $fields ): Add a GROUP BY restriction public having( string $restriction ): Add a restriction in HAVING clause( each restriction will be separated by AND statement) public innerJoin( string $table, string $alias = null, string $on = null ): Add INNER JOIN clause, E.g. $this->innerJoin('product p ON ...')  ... 43

Desarrollando módulos La clase DBQuery (Cont.) …   public join( string $join ): Add JOIN clause, E.g. $this->join('RIGHT JOIN '._DB_PREFIX_.'product p ON ...');  public leftJoin( string $table, string $alias= null, string $on= null ): Add LEFT JOIN clause  public leftOuterJoin( string $table, string $alias = null, string $on = null ): Add LEFT OUTER JOIN clause  public limit( string $limit, mixed $offset= 0 ): Limit results in query public naturalJoin( string $table, string $alias = null ): Add NATURAL JOIN clause  publicorderBy( string $fields ): Add an ORDER B restriction  public select( string $fields ): Add fields in query selection  public where( string $restriction ): Add a restriction in WHERE clause (each restriction will be separated by AND statement) 44

Desarrollando módulos La clase DBQuery (Cont.)  $sql = new DbQuery();  $sql->select('*');      $sql->from('cms', 'c');      $sql->innerJoin('cms_lang', 'l', 'c.id_cms = l.id_cms AND l.id_lang = '.(int)$id_lang);      $sql->where('c.active = 1');      $sql->orderBy('position');      return Db::getInstance()->executeS($sql);         45

Desarrollando módulos Helpers Continuaremos... 46