Example #1
0
File: Form.php Project: nabble/ajde
 public static function processStatic(Ajde_Template_Parser $parser, $attributes)
 {
     $instance = new self($parser, $attributes);
     $t = new stdClass();
     // Force unique object hash, see http://www.php.net/manual/es/function.spl-object-hash.php#76220
     return $instance->process();
 }
Example #2
0
 /**
  * Create an instance and process data
  * @param  object $scope Scope
  * @param  \Carbon\Carbon $date Date
  * @param  int $period Period
  * @return self Line chart instance
  */
 public static function forge($scope, $date, $period)
 {
     $chart = new self($scope, $date);
     $chart->setPeriod($period);
     $chart->process();
     return $chart;
 }
 public static function instance()
 {
     if (!is_404()) {
         return;
     }
     $image_creator = new self();
     $image_creator->process();
 }
Example #4
0
 public function quickLogin($idNumber, $password, $rememberMe = true)
 {
     $form = new self();
     $form->idNumber = $idNumber;
     $form->password = $password;
     $form->rememberMe = $rememberMe;
     return $form->process();
 }
Example #5
0
 public static function import($uri)
 {
     $feed = new self();
     $zend_feed = \Zend_Feed::import($uri);
     $feed->feed = $zend_feed;
     $feed->encoding = $feed->feed->getDOM()->ownerDocument->encoding;
     $feed->process();
     return $feed;
 }
Example #6
0
 /**
  * Processa i dati
  * @param type $data
  */
 public function process($data)
 {
     foreach ($data as $nodeName => $nodeValue) {
         // $nodeValue è sempre un oggetto
         if ($nodeValue->count() > 0 || count($nodeValue->attributes()) > 0) {
             // se ha figli o ha attributi, allora lo considero come oggetto da parsare
             // se ha attributi li metto in $_attributes
             $clone = new self();
             $clone->process($nodeValue);
             foreach ($nodeValue->attributes() as $attrName => $attrValue) {
                 $clone->setAttribute($attrName, $attrValue);
             }
             $this->{$nodeName} = $clone;
         } else {
             // altrimenti è una stringa
             $this->{$nodeName} = (string) $nodeValue;
         }
     }
 }
Example #7
0
 /**
  * Crea una struttura dati $section con i valori $value
  * @param String $section
  * @param String|Array $value
  * @return \self
  */
 public function createChild($section, $value)
 {
     $e = explode($this->_separator, $section, 2);
     $newSection = $e[0];
     $dataSend = array($e[1] => $value);
     if ($this->{$newSection} instanceof self) {
         $child = $this->{$newSection};
     } else {
         $child = new self();
     }
     $child->process($dataSend);
     return $child;
 }
Example #8
0
 /**
  * @param string $file
  * @param string $sep (Optional.)
  * @param string $quote (Optional.)
  * @param boolean $header (Optional.)
  * @return \CsvImport
  */
 public static function import($file, $sep = self::SEP_COMMA, $quote = self::QUOTE_AUTO, $header = false)
 {
     $self = new self(array('filename' => $file, 'separator' => $sep, 'quotes' => $quote, 'header' => $header));
     return $self->process();
 }
Example #9
0
 /**
  * Create an instance and process data
  * @param  object $scope Scope
  * @param  \Carbon\Carbon $date Date
  * @return self Line chart instance
  */
 public static function forge($scope, $date)
 {
     $chart = new self($scope, $date);
     $chart->process();
     return $chart;
 }
Example #10
0
 /**
  * Parses the command line
  *
  * See getopt() for a complete description.
  *
  * @param  numeric $version      the getopt version: 1 or 2
  * @param  array   $args         the arguments
  * @param  string  $shortOptions the short options definition, e.g. "ab:c::"
  * @param  array   $longOptions  the long options definition
  * @param  string  $ambiguity    directive to handle option names ambiguity
  * @return array   the parsed options, their arguments and parameters
  * @access public
  * @static
  */
 public static function doGetopt($version = null, $args = array(), $shortOptions = '', $longOptions = array(), $ambiguity = '')
 {
     $getopt = new self();
     return $getopt->process($args, $shortOptions, $longOptions, $ambiguity, $version);
 }
Example #11
0
 public static function import($tpl_name)
 {
     $is_aliased = preg_match("~^\\@(.+)~", $tpl_name, $real_name);
     if ($is_aliased) {
         $tpl_name = $real_name[1];
     } else {
         $tpl_name = fx::getComponentFullName($tpl_name);
     }
     if (isset(self::$imported_classes[$tpl_name])) {
         return self::$imported_classes[$tpl_name];
     }
     $processor = new self();
     $processor->setTemplateName($tpl_name);
     if ($is_aliased) {
         $processor->isAliased(true);
     }
     $classname = $processor->getCompiledClassName();
     $processor->addDefaultSourceDirs();
     try {
         $processor->process();
     } catch (\Exception $e) {
         self::$imported_classes[$tpl_name] = false;
         return false;
     }
     self::$imported_classes[$tpl_name] = $classname;
     $classname::init();
     return $classname;
 }
Example #12
0
 /**
  * @param DibiConnection $dibiConnection
  * @param string $migrationsFolder
  * @param string $tempDirectory
  */
 public static function handle(DibiConnection $dibiConnection, $migrationsFolder, $tempDirectory)
 {
     $instance = new self($dibiConnection, $migrationsFolder, $tempDirectory);
     $instance->process();
 }
Example #13
0
 public static function processStatic(Parser $parser, $attributes)
 {
     $instance = new self($parser, $attributes);
     return $instance->process();
 }
Example #14
0
 /**
  * @param string $source
  * @param array $options
  * @return string
  */
 public static function minify($source, $options = [])
 {
     $min = new self($options);
     return $min->process($source);
 }
Example #15
0
 /**
  *
  * @param array $input
  */
 public static function process_request(array $input)
 {
     $c = new self();
     $c->process($input);
 }
Example #16
0
 /** @return Resource */
 private function createResourceFromObject(stdClass $object)
 {
     $processor = new self();
     return $processor->process($this->response->withBody($this->createStream(json_encode($object))), $this->fetcher);
 }
Example #17
0
 /**
  * Minify Javascript
  *
  * @param string $string
  * @return string
  */
 public static function minify($string)
 {
     $self = new self();
     return $self->process($string);
 }
 /**
  * Parses the command line
  *
  * See the configuration definition/example in the class Doc Block.
  *
  * Example 1: returning an index array
  * <code>
  * array(
  *    [0] => array(
  *      [0] => array([0] => "--foo", [1] => null),
  *      [1] => array([0] => "b", [1] => "car"),
  *      [2] => array([0] => "c", [1] => null)),
  *    [1] => array([0] => "param1", [1] => "param2")
  * );
  * </code>
  *
  * Example 2: returning an associative array
  * <code>
  * array(
  *    [0] => array("foo" => null, "bar" => "car", "c" => null),
  *    [1] => array([0] => "param1", [1] => "param2")
  * );
  * </code>
  *
  * @param  array   $config      the command configuration, see the configuration
  *                              definition/example in the class Doc Block
  * @param  string  $convertName returns short option names if set to
  *                              "long2short", long ones if set to "short2long",
  *                              as in the command line by default
  * @param  boolean $returnAssoc returns an associative array if true,
  *                              an index array if false
  * @param  string  $ambiguity   directive to handle option names ambiguity,
  *                              e.g. "--foo" and "--foobar":
  *                              <ul>
  *                              <li>"loose": allowed if "--foo" does not
  *                              accept an argument, this is the default
  *                              behaviour</li>
  *                              <li>"strict": no ambiguity allowed</li>
  *                              <li>"shortcuts": implies "strict", the use of
  *                              partial option names is allowed,
  *                              e.g. "--f" or "--fo" instead of "--foo"</li>
  *                              </ul>
  * @param  boolean $exitHelp    if "--help" is one of the options:
  *                              <ul>
  *                              <li>true: displays the command usage and exits</li>
  *                              <li>false: returns the command usage as:
  *                              <ul>
  *                              <li>an index array, e.g.
  *                              array([0] => array([0] => array("h", "Usage:...")))</li>
  *                              <li>an associative, e.g.
  *                              array([0] => array("h" => "Usage:..."))</li>
  *                              </ul></li>
  *                              </ul>
  * @return array   the parsed options, their arguments and parameters
  * @access public
  * @static
  */
 public static function getoptplus($config = array(), $convertName = '', $returnAssoc = false, $ambiguity = '', $exitHelp = true)
 {
     $getopt = new self();
     return $getopt->process($config, $convertName, $returnAssoc, $ambiguity, $exitHelp);
 }
    /**
     * @param XMLField[]|XMLField $xmlField
     * @return mixed
     */
    public function getFieldContent($xmlField)
    {
        $rootImport = $this->importINI->variable( 'XMLImportSettings', 'RootImport' );

        if (is_array($xmlField))
        {
            /* @type $xmlField XMLField[] */
            $mapping = XMLImportMapping::getByFieldName($xmlField[0]->getParentType(), $xmlField[0]->internalFieldName);
        }
        elseif (is_null($xmlField->fieldNode))
            return false;
        else
            $mapping = XMLImportMapping::getByFieldName($xmlField->getParentType(), $xmlField->internalFieldName);

        /* @type $xmlField XMLField */
        switch ($mapping['type'])
        {
            case 'text':
            {
                /* @type $xmlField XMLField */
                $fieldContent = strip_tags(trim($xmlField->fieldNode->nodeValue));
                $returnContent = $fieldContent;
            }
            break;
            case 'image':
            case 'video':
            case 'pdf':
            case 'audio':
            case 'contact':
            case 'file':
            case 'media_content':
            case 'html_media':
            {
                if (!is_array($xmlField))
                {
                    try
                    {
                        $xmlFieldBuilder    = new XMLFieldBuilder($this->xmlParser, $this->importINI, $xmlField->fieldNode);
                        $xmlFieldMixer      = new self($xmlFieldBuilder, $this->xmlParser, $this->importINI, $this->publisherInfos, $this->rootImportFolder);
                        $fieldContent       = $xmlFieldMixer->process($mapping['type']);

                        if ( !isset($fieldContent['language']) )
                        {
                            $emulatedXMLField                       = new stdClass();
                            $emulatedXMLField->calculatedValue      = $this->publisherInfos['default_language'];
                            $emulatedXMLField->internalFieldName    = 'language';
                            $fieldContent['language']               = $emulatedXMLField;
                            $illustrativeMediaFields                = XMLImportMapping::getByFieldName('illustrative_media', $xmlField->internalFieldName);

                            if ( $illustrativeMediaFields === false && $this->publisherInfos['default_language_medias'] == 0 )
                                XMLImportMonitor::log($xmlField->internalFieldName . ' : The Field\'s language has been defaulted to ' . $this->publisherInfos['default_language'] . ', publisher settings says it shouldn\'t have.', 'warning');
                        }

                        $returnContent = $fieldContent;
                    }
                    catch (MandatoryException $e)
                    {
                        XMLImportMonitor::log($xmlField->internalFieldName . ' : ' . $e->getMessage(), 'warning');
                    }
                }
                else
                {
                    $returnContent = false;

                    /* @type $xmlField XMLField[] */
                    foreach ($xmlField as $index => $field)
                    {
                        if (is_null($field->fieldNode))
                            continue;

                        try
                        {
                            $xmlFieldBuilder    = new XMLFieldBuilder($this->xmlParser, $this->importINI, $field->fieldNode);
                            $xmlFieldMixer      = new self($xmlFieldBuilder, $this->xmlParser, $this->importINI, $this->publisherInfos, $this->rootImportFolder);
                            $fieldContent       = $xmlFieldMixer->process($mapping['type']);

                            if (is_array($fieldContent) && count($fieldContent) > 0)
                            {
                                if ( !isset($fieldContent['language']) )
                                {
                                    $emulatedXMLField                       = new stdClass();
                                    $emulatedXMLField->calculatedValue      = $this->publisherInfos['default_language'];
                                    $emulatedXMLField->internalFieldName    = 'language';
                                    $fieldContent['language']               = $emulatedXMLField;
                                    $illustrativeMediaFields                = XMLImportMapping::getByFieldName('illustrative_media', $field->internalFieldName);

                                    if ( $illustrativeMediaFields === false && $this->publisherInfos['default_language_medias'] == 0 )
                                        XMLImportMonitor::log($field->internalFieldName . ' : The Field\'s language has been defaulted to ' . $this->publisherInfos['default_language'] . ', publisher settings says it shouldn\'t have.', 'warning');
                                }

                                $field->calculatedValue = $fieldContent;
                                $returnContent          = true;
                            }
                            else
                                unset($xmlField[$index]);

                            $this->blobedFiles = array_merge($this->blobedFiles, $xmlFieldMixer->blobedFiles);
                        }
                        catch (MandatoryException $e)
                        {
                            XMLImportMonitor::log($field->internalFieldName . ':' . $e->getMessage(), 'warning');

                            unset($xmlField[$index]);
                        }
                    }
                }
            }
            break;
            case 'richtext':
            {

                $fieldContent = str_replace(array(
                        "\n\r",
                        "\n",
                        "\r"
                    ), array(
                        ' ',
                        ' ',
                        ' '
                    ), trim($xmlField->fieldNode->nodeValue)
                );

                $returnContent = $fieldContent;
            }
            break;
            case 'taxonomy':
            {
                $fieldContent = str_replace( ' ', '', trim($xmlField->fieldNode->nodeValue) );
                $contentArray = explode('|', $fieldContent);

                if ($contentArray !== false && $contentArray != "")
                {
                    $mmDB = MMDB::instance();

                    foreach ($contentArray as $key => $value)
                    {
                        $value = trim($value);
                        if ($value != "")
                        {
                            //Check if key exists in table 'taxonomy'
                            $result = $mmDB->arrayQuery('SELECT 1 FROM mm_taxonomy WHERE code = "' . $contentArray[$key] . '"');

                            if (empty($result))
                            {
                                XMLImportMonitor::log('The taxonomy {' . $contentArray[$key] . '} in field {' . $xmlField->fieldName . '} doesn\'t exists', 'notice');

                                unset($contentArray[$key]);
                            }
                            else
                                $contentArray[$key] = $value;
                        }
                        else
                            unset($contentArray[$key]);
                    }
                    if (count($contentArray))
                    {
                        $returnContent = array_unique($contentArray);
                    }
                }
            }
            break;
            case 'integer':
            {
                $fieldContent = filter_var(trim($xmlField->fieldNode->nodeValue), FILTER_VALIDATE_INT);

                if ($fieldContent !== false)
                    $returnContent = $fieldContent;
            }
            break;
            case 'date':
            {
                $fieldContent = trim($xmlField->fieldNode->nodeValue);
                $datePattern  = "/(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2}) (?P<hour>\d{2}):(?P<minute>\d{2})/";

                if (preg_match($datePattern, $fieldContent, $m))
                    $returnContent = "{$m['year']}-{$m['month']}-{$m['day']} {$m['hour']}:{$m['minute']}:00";
            }
            break;
            case 'filename':
            {
                $folderMap = array(
                    'image' => 'images',
                    'html' => 'html',
                    'pdf' => 'pdf',
                    'audio' => 'audio',
                    'video' => 'videos',
                    'link' => 'link',
                    'file' => 'file',
                    'html_media' => 'html'
                );

                if ( trim($xmlField->fieldNode->nodeValue) != "" )
                {
                    $fieldContent = trim($xmlField->fieldNode->nodeValue);

                    if (isset($folderMap[$xmlField->getParentType()]))
                        $folder = $folderMap[$xmlField->getParentType()];
                    else
                        break;
                    
                    $filepathFromRootImport = "{$this->rootImportFolder}/{$this->publisherInfos['path']}/$folder/$fieldContent";

                    if ( file_exists( "$rootImport/$filepathFromRootImport" )
                        || file_exists ( "$rootImport/{$this->rootImportFolder}/{$this->publisherInfos['path']}/archived/$folder/$fieldContent" ) )
                    {
                        if ($mapping['specialProcess'] == 'storeBlob')
                            $returnContent = "$rootImport/$filepathFromRootImport";
                        else
                            $returnContent  = $filepathFromRootImport;
                    }
                    else
                        $fieldContent = "{$this->rootImportFolder}/{$this->publisherInfos['path']}/$folder/$fieldContent";
                }
            }
            break;
            case 'wxh':
            {
                $fieldContent = trim($xmlField->fieldNode->nodeValue);

                if (preg_match("/(\d+)\s*[xX\s]\s*(\d+)/", $fieldContent, $match))
                    $returnContent = "{$match[1]}x{$match[2]}";
            }
            break;
            case 'email':
            {
                $fieldContent = filter_var(trim($xmlField->fieldNode->nodeValue), FILTER_VALIDATE_EMAIL);

                if ($fieldContent !== false)
                    $returnContent = $fieldContent;
            }
            break;
            case 'media_type':
            {
                /* @type $availableRelatedContent array */
                $fieldContent            = strtolower(trim($xmlField->fieldNode->nodeValue));
                $availableRelatedContent = $this->importINI->variable('XMLImportSettings', 'AvailableRelatedContent');

                if (in_array($fieldContent, $availableRelatedContent))
                    $returnContent = $fieldContent;
            }
            break;
            case 'enum':
            {
                $fieldContent = strtolower(trim($xmlField->fieldNode->nodeValue));
                $enumMapping  = XMLImportMapping::getByFieldName('enum_values', $xmlField->internalFieldName);

                if ( $enumMapping !== false && in_array($fieldContent, $enumMapping) )
                    $returnContent = $fieldContent;
            }
            break;
            case 'boolean':
            {
                $fieldContent = filter_var(trim($xmlField->fieldNode->nodeValue), FILTER_VALIDATE_BOOLEAN);
                $returnContent = ($fieldContent === false) ? 0 : 1;
            }
            break;
            case 'reference_article_id':
            {
                $fieldContent  = trim($xmlField->fieldNode->nodeValue);
                $returnContent = $fieldContent;
            }
            break;
            default:
            {
                XMLImportMonitor::log('The field {' . $xmlField->fieldName . '} has an unknown type : {' . $mapping['type'] . '}', 'error');
                return false;
            }
        }

        if (!isset($returnContent))
        {
            if (!empty($fieldContent) && (is_string($fieldContent) || is_numeric($fieldContent)))
            {
                $reportValue = $fieldContent;

                XMLImportMonitor::log('The field {' . $xmlField->fieldName . '} of type {' . $mapping['type'] . '} has an incorrect value : {' . $reportValue . '}', 'warning');
            }

            return false;
        }

        if (!is_array($xmlField))
            $xmlField->calculatedValue = $returnContent;

        return $returnContent;
    }
 /**
  * Computes the control flow graph starting at the given root node.
  * 
  * @param \PHPParser_Node $node
  * 
  * @return ControlFlowGraph
  */
 public static function computeGraph(\PHPParser_Node $node)
 {
     $cfa = new self();
     $cfa->process($node);
     return $cfa->getGraph();
 }
Example #21
0
 /**
  * "Minify" an HTML page
  *
  * @param string $html
  *
  * @param array $options
  *
  * 'cssMinifier' : (optional) callback function to process content of STYLE
  * elements.
  *
  * 'jsMinifier' : (optional) callback function to process content of SCRIPT
  * elements. Note: the type attribute is ignored.
  *
  * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
  * unset, minify will sniff for an XHTML doctype.
  *
  * @return string
  */
 public static function minify($html, $options = array())
 {
     $min = new self($html, $options);
     return $min->process();
 }
Example #22
0
 public static function processContent($content, $cssUrl = null, $options = array(), $downloader = array())
 {
     $merger = new self($options, $downloader);
     return $merger->process($cssUrl, null, $content);
 }