public function getLegacyKeyClass()
 {
     $class = camelcase($this->getCategoryEntity()->getAttributeKeyCategoryHandle());
     $prefix = $this->getCategoryEntity()->getPackageID() > 0 ? $this->getCategoryEntity()->getPackageHandle() : false;
     $class = core_class('Core\\Attribute\\Key\\' . $class . 'Key', $prefix);
     return $class;
 }
 public function import(\SimpleXMLElement $sx)
 {
     $em = \Database::connection()->getEntityManager();
     $em->getClassMetadata('Concrete\\Core\\Entity\\Express\\Association')->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     if (isset($sx->expressentities)) {
         foreach ($sx->expressentities->entity as $entityNode) {
             if (isset($entityNode->associations)) {
                 foreach ($entityNode->associations->association as $associationNode) {
                     $association = $em->find('Concrete\\Core\\Entity\\Express\\Association', (string) $associationNode['id']);
                     if (!is_object($association)) {
                         $class = '\\Concrete\\Core\\Entity\\Express\\' . camelcase((string) $associationNode['type']) . 'Association';
                         $association = new $class();
                         $association->setId((string) $associationNode['id']);
                     }
                     /**
                      * @var $association \Concrete\Core\Entity\Express\Association
                      */
                     $association->setTargetPropertyName((string) $associationNode['target-property-name']);
                     $association->setInversedByPropertyName((string) $associationNode['inversed-by-property-name']);
                     $em->persist($association);
                 }
             }
         }
     }
     $em->flush();
     $em->getClassMetadata('Concrete\\Core\\Entity\\Express\\Association')->setIdGenerator(new UuidGenerator());
 }
Example #3
0
 public static function controller($item)
 {
     if ($item instanceof \Page) {
         return $item->getController();
     }
     $controller = '\\Concrete\\Controller\\' . camelcase($item);
     return new $controller();
 }
 /**
  * test camelcase
  */
 public function testCamelcase()
 {
     $this->assertEquals('fooBar', camelcase('foo bar'));
     $this->assertEquals('fooBar', camelcase('FooBar'));
     $this->assertEquals('fooBar', camelcase('foo-bar'));
     $this->assertEquals('fooBar', camelcase('foo_bar'));
     $this->assertEquals('fooBarBazQUX', camelcase('foo - bar, .Baz QUX'));
 }
Example #5
0
 /**
  * @return \Concrete\Core\File\StorageLocation\Configuration\ConfigurationInterface
  */
 public function getConfigurationObject()
 {
     if ($this->getPackageID()) {
         return Core::make('\\Concrete\\Package\\' . camelcase($this->getPackageHandle()) . '\\Core\\File\\StorageLocation\\Configuration\\' . camelcase($this->getHandle()) . 'Configuration');
     } else {
         return Core::make('\\Concrete\\Core\\File\\StorageLocation\\Configuration\\' . camelcase($this->getHandle()) . 'Configuration');
     }
 }
 protected function getController()
 {
     try {
         $class = camelcase(substr($this->filename, 0, strrpos($this->filename, '.php')));
         return \Core::make('\\Concrete\\Block\\ExternalForm\\Form\\Controller\\' . $class);
     } catch (\Exception $e) {
     }
 }
 public function driver($driver = null)
 {
     $method = 'create' . camelcase($driver) . 'Driver';
     // If a custom driver is not registered, we use unmapped
     if ($driver && !isset($this->customCreators[$driver]) && !method_exists($this, $method)) {
         return $this->createStandardDriver();
     }
     return parent::driver($driver);
 }
Example #8
0
 public static function getLibrary()
 {
     if (!PageCache::$library) {
         $adapter = Config::get('concrete.cache.page.adapter');
         $class = overrideable_core_class('Core\\Cache\\Page\\' . camelcase($adapter) . 'PageCache', DIRNAME_CLASSES . '/Cache/Page/' . camelcase($adapter) . 'PageCache.php');
         PageCache::$library = new $class();
     }
     return PageCache::$library;
 }
Example #9
0
 public static function controller($item)
 {
     if ($item instanceof \Page) {
         return $item->getController();
     }
     $controller = '\\Concrete\\Controller\\' . camelcase($item);
     $app = Facade::getFacadeApplication();
     return $app->build($controller);
 }
 public static function getClass($pkgHandle)
 {
     if (is_dir(DIR_STARTING_POINT_PACKAGES . '/' . $pkgHandle)) {
         $class = '\\Application\\StartingPointPackage\\' . camelcase($pkgHandle) . '\\Controller';
     } else {
         $class = '\\Concrete\\StartingPointPackage\\' . camelcase($pkgHandle) . '\\Controller';
     }
     $cl = new $class();
     return $cl;
 }
Example #11
0
 protected function getController()
 {
     try {
         $class = camelcase(substr($this->filename, 0, strrpos($this->filename, '.php')));
         $cl = \Core::make(overrideable_core_class('Block\\ExternalForm\\Form\\Controller\\' . $class, DIRNAME_BLOCKS . '/external_form/form/controller/' . $this->filename));
         $cl->bID = $this->bID;
         return $cl;
     } catch (\Exception $e) {
     }
 }
Example #12
0
 public function getController()
 {
     if (isset($this->controller)) {
         return $this->controller;
     } else {
         $class = overrideable_core_class('MenuItem\\' . camelcase($this->handle) . '\\Controller', DIRNAME_MENU_ITEMS . '/' . $this->handle . '/' . FILENAME_CONTROLLER, $this->pkgHandle);
         $this->setController(\Core::make($class, array($this)));
         return $this->controller;
     }
 }
 public function registerPackage(Package $pkg)
 {
     $symfonyLoader = new SymfonyClassloader();
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Attribute', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_ATTRIBUTES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Authentication', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_AUTHENTICATION);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Block', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_BLOCKS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Theme', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_THEMES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Controller\\PageType', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Controller', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_CONTROLLERS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()) . '\\Job', DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_JOBS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Package\\' . camelcase($pkg->getPackageHandle()), DIR_PACKAGES . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_CLASSES);
     $symfonyLoader->register();
 }
 public function parse()
 {
     $sl = new StyleList();
     foreach ($this->root->set as $xset) {
         $set = $sl->addSet((string) $xset['name']);
         foreach ($xset->style as $xstyle) {
             $type = camelcase((string) $xstyle['type']);
             $style = Core::make('\\Concrete\\Core\\StyleCustomizer\\Style\\' . $type . 'Style');
             $style->setName((string) $xstyle['name']);
             $style->setVariable((string) $xstyle['variable']);
             $set->addStyle($style);
         }
     }
     return $sl;
 }
Example #15
0
 public static function getByHandle($scsHandle)
 {
     $db = Loader::db();
     $r = $db->GetRow('select scsHandle, scsIsActive, pkgID, scsName from SystemContentEditorSnippets where scsHandle = ?', array($scsHandle));
     if (is_array($r) && $r['scsHandle']) {
         $pkgHandle = false;
         if ($r['pkgID']) {
             $pkgHandle = PackageList::getHandle($r['pkgID']);
         }
         $class = overrideable_core_class('Core\\Editor\\' . camelcase($r['scsHandle']) . 'Snippet', DIRNAME_CLASSES . '/Editor/' . camelcase($r['scsHandle']) . 'Snippet.php', $pkgHandle);
         $sc = Core::make($class);
         $sc->setPropertiesFromArray($r);
         return $sc;
     }
 }
Example #16
0
 protected function createDriver($driver)
 {
     // Note –this overrides the laravel createDriver because we do concrete5
     // camelcasing magic.
     $method = 'create' . camelcase($driver) . 'Driver';
     // We'll check to see if a creator method exists for the given driver. If not we
     // will check for a custom driver creator, which allows developers to create
     // drivers using their own customized driver creator Closure to create it.
     if (isset($this->customCreators[$driver])) {
         return $this->callCustomCreator($driver);
     } elseif (method_exists($this, $method)) {
         return $this->{$method}();
     }
     throw new \InvalidArgumentException("Driver [{$driver}] not supported.");
 }
Example #17
0
 public function getValue($mode = false)
 {
     $value = $this->getValueObject();
     $controller = $this->getController();
     if (is_object($value)) {
         if ($mode != false) {
             $modes = func_get_args();
             foreach ($modes as $mode) {
                 $method = 'get' . camelcase($mode) . 'Value';
                 if (method_exists($controller, $method)) {
                     return $controller->{$method}();
                 }
             }
         } else {
             return $value->getValue();
         }
     }
     return $controller->getValue();
 }
Example #18
0
 private static function getThemeNameAndDescription($dir, $pThemeHandle, $pkgHandle = '')
 {
     $res = new \stdClass();
     $res->pThemeName = '';
     $res->pThemeDescription = '';
     $res->pError = '';
     if (file_exists($dir . '/' . FILENAME_THEMES_DESCRIPTION)) {
         $con = file($dir . '/' . FILENAME_THEMES_DESCRIPTION);
         $res->pThemeName = trim($con[0]);
         $res->pThemeDescription = trim($con[1]);
     }
     $pageThemeFile = $dir . '/' . FILENAME_THEMES_CLASS;
     if (is_file($pageThemeFile)) {
         try {
             $cn = '\\Theme\\' . camelcase($pThemeHandle) . '\\PageTheme';
             $classNames = [];
             if (strlen($pkgHandle)) {
                 $classNames[] = '\\Concrete\\Package\\' . camelcase($pkgHandle) . $cn;
             } else {
                 $classNames[] = '\\Application' . $cn;
                 $classNames[] = '\\Concrete' . $cn;
             }
             $className = null;
             foreach ($classNames as $cn) {
                 if (class_exists($cn, false)) {
                     $className = $cn;
                     break;
                 }
             }
             if (is_null($className)) {
                 include_once $pageThemeFile;
                 foreach ($classNames as $cn) {
                     if (class_exists($cn, false)) {
                         $className = $cn;
                         break;
                     }
                 }
             }
             if (is_null($className)) {
                 $res->pError = t('The theme file %1$s does not define the class %2$s', FILENAME_THEMES_CLASS, ltrim($classNames[0], '\\'));
             } else {
                 $instance = new $className();
                 $extensionOf = '\\Concrete\\Core\\Page\\Theme\\Theme';
                 if (!is_a($instance, $extensionOf)) {
                     $res->pError = t('The theme file %1$s should define a %2$s class that extends the class %3$s', FILENAME_THEMES_CLASS, ltrim($className, '\\'), ltrim($extensionOf, '\\'));
                 } else {
                     if (method_exists($instance, 'getThemeName')) {
                         $s = $instance->getThemeName();
                         if (strlen($s) > 0) {
                             $res->pThemeName = $s;
                         }
                     }
                     if (method_exists($instance, 'getThemeDescription')) {
                         $s = $instance->getThemeDescription();
                         if (strlen($s) > 0) {
                             $res->pThemeDescription = $s;
                         }
                     }
                 }
             }
         } catch (\Exception $x) {
             $res->pError = $x->getMessage();
         }
     }
     return $res;
 }
Example #19
0
 /**
  * @return PageController
  */
 public function getPageController()
 {
     if (!isset($this->controller)) {
         $env = Environment::get();
         if ($this->getPageTypeID() > 0) {
             $pt = $this->getPageTypeObject();
             $ptHandle = $pt->getPageTypeHandle();
             $r = $env->getRecord(DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES . '/' . $ptHandle . '.php', $pt->getPackageHandle());
             $prefix = $r->override ? true : $pt->getPackageHandle();
             $class = core_class('Controller\\PageType\\' . camelcase($ptHandle), $prefix);
         } elseif ($this->isGeneratedCollection()) {
             $file = $this->getCollectionFilename();
             if (strpos($file, '/' . FILENAME_COLLECTION_VIEW) !== false) {
                 $path = substr($file, 0, strpos($file, '/' . FILENAME_COLLECTION_VIEW));
             } else {
                 $path = substr($file, 0, strpos($file, '.php'));
             }
             $r = $env->getRecord(DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_CONTROLLERS . $path . '.php', $this->getPackageHandle());
             $prefix = $r->override ? true : $this->getPackageHandle();
             $class = core_class('Controller\\SinglePage\\' . str_replace('/', '\\', camelcase($path, true)), $prefix);
         }
         if (isset($class) && class_exists($class)) {
             $this->controller = Core::make($class, array($this));
         } else {
             $this->controller = Core::make('\\PageController', array($this));
         }
     }
     return $this->controller;
 }
Example #20
0
 public static function getClass($pkgHandle)
 {
     // loads and instantiates the object
     $class = '\\Concrete\\Package\\' . camelcase($pkgHandle) . '\\Controller';
     if (class_exists($class)) {
         $cl = Core::make($class);
         return $cl;
     }
 }
Example #21
0
 public function getGroupAutomationControllerClass()
 {
     $ts = \Core::make('helper/text');
     $env = \Environment::get();
     $r = $env->getRecord(DIRNAME_CLASSES . '/User/Group/AutomatedGroup/' . camelcase($ts->handle($this->getGroupName())) . '.php');
     $prefix = $r->override ? true : $this->getPackageHandle();
     $class = core_class('\\Core\\User\\Group\\AutomatedGroup\\' . camelcase($ts->handle($this->getGroupName())), $prefix);
     return $class;
 }
Example #22
0
/**
 *  Returns a concrete5 namespaced class. $prefix is either true (for application), or a package handle or null.
 *
 * @param string $class
 * @param bool   $prefix
 *
 * @return string
 */
function core_class($class, $prefix = false)
{
    $app = \Core::make('app');
    $class = trim($class, '\\');
    if ($prefix) {
        if (substr($class, 0, 5) == "Core\\") {
            if ($prefix !== true) {
                $x = $app->make('Concrete\\Core\\Package\\PackageService')->getClass($prefix);
                if (!$x->shouldEnableLegacyNamespace()) {
                    $class = substr($class, 5);
                } else {
                    $class = "Src\\" . substr($class, 5);
                }
            } else {
                if (!Config::get('app.enable_legacy_src_namespace')) {
                    $class = "Concrete\\" . substr($class, 5);
                } else {
                    $class = "Src\\" . substr($class, 5);
                }
            }
        }
        if ($prefix === true) {
            $prefix = Config::get('app.namespace');
        } else {
            $prefix = 'Concrete\\Package\\' . camelcase($prefix);
        }
    }
    if (!$prefix) {
        $prefix = 'Concrete';
    }
    $class = '\\' . $prefix . '\\' . $class;
    return $class;
}
Example #23
0
 public function getWorkflowProgressHistoryObjectByID($wphID)
 {
     $class = '\\Concrete\\Core\\Workflow\\Progress\\' . camelcase($this->getWorkflowProgressCategoryHandle()) . 'History';
     $db = Database::connection();
     $row = $db->fetchAssoc('select * from WorkflowProgressHistory where wphID = ?', array($wphID));
     if (is_array($row) && $row['wphID']) {
         $obj = new $class();
         $obj->setPropertiesFromArray($row);
         $obj->object = @unserialize($row['object']);
         return $obj;
     }
 }
Example #24
0
function fk_str_format($txt, $f = 'html:no-tags', $f_2 = '')
{
    // Para:  'a', 'e', 'i', 'o', 'u', 'n','A', 'E', 'I', 'O', 'U', 'N'
    $find = encodedArray('4SzpLO0s8yz6LPEswSzJLM0s0yzaLNE=');
    // Para:  'a', 'e', 'i', 'o', 'u', 'n','A', 'E', 'I', 'O', 'U', 'N','<','>','"'
    $arr1 = encodedArray('4SzpLO0s8yz6LPEswSzJLM0s0yzaLNEsPCw+');
    $findHtml = array_merge($arr1, array('"'));
    // Add quot
    switch ($f) {
        //---------HTML---------------
        case "html":
            $repl = array('&aacute;', '&eacute;', '&iacute;', '&oacute;', '&uacute;', '&ntilde;', '&Aacute;', '&Eacute;', '&Iacute;', '&Oacute;', '&Uacute;', '&Ntilde;', '&lt;', '&gt;', '&quot;');
            $txt = str_replace($findHtml, $repl, $txt);
            $txtrs = $txt;
            break;
            //---------HTML respetando los <>---------------
        //---------HTML respetando los <>---------------
        case "html:no-tags":
            $repl = array('&aacute;', '&eacute;', '&iacute;', '&oacute;', '&uacute;', '&ntilde;', '&Aacute;', '&Eacute;', '&Iacute;', '&Oacute;', '&Uacute;', '&Ntilde;');
            $txt = str_replace($find, $repl, $txt);
            $txtrs = $txt;
            break;
            //---------Texto plano---------------
        //---------Texto plano---------------
        case "txt":
            $repl = array('a', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N');
            $txt = str_replace($find, $repl, $txt);
            $txtrs = $txt;
            break;
            //---------For Url link---------------
        //---------For Url link---------------
        case "url":
            //Rememplazamos caracteres especiales latinos
            $repl = array('a', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N');
            $txt = str_replace($find, $repl, $txt);
            // Añaadimos los guiones
            $find2 = array(' ', '&', '\\r\\n', '\\n', '+');
            $txt = str_replace($find2, '-', $txt);
            // Eliminamos y Reemplazamos demás caracteres especiales
            $find3 = array('/[^A-Za-z0-9\\-<>.$]/', '/[\\-]+/', '/<[^>]*>/');
            $repl = array('', '-', '');
            $txt = preg_replace($find3, $repl, $txt);
            $txtrs = $txt;
            break;
        case "php_var":
            //Rememplazamos caracteres especiales latinos
            $repl = array('a', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N');
            $txt = str_replace($find, $repl, trim($txt));
            // Anadimos los guiones
            $find2 = array(' ', '&', '\\r\\n', '\\n', '+');
            $txt = str_replace($find2, '_', $txt);
            // Eliminamos y Reemplazamos demas caracteres especiales
            $find3 = array('/[^A-Za-z0-9\\-<>.$]/', '/[\\-]+/', '/<[^>]*>/');
            $repl = array('_', '_', '');
            $txt = preg_replace($find3, $repl, $txt);
            $txtrs = $txt;
            break;
            //---------For CamelCase---------------
        //---------For CamelCase---------------
        case "camelcase":
            $txtrs = camelcase($txt);
            break;
        default:
            $txtrs = $txt;
            break;
    }
    // End Case
    // Second Format "CamelCase"
    if ($f_2 == 'camelcase') {
        $txtrs = camelcase($txtrs);
    }
    return $txtrs;
}
Example #25
0
 public function getCustomInspector()
 {
     $name = camelcase($this->getCustomImporter()) . 'Inspector';
     $class = overrideable_core_class('Core\\File\\Type\\Inspector\\' . $name, 'File/Type/Inspector/' . $name . '.php', $this->getPackageHandle());
     $cl = Core::make($class);
     return $cl;
 }
Example #26
0
/**
 * Returns corresponding controller name for given $string.
 *
 * @param  string $class_name
 * @return string Singularized and camelized $class_name
 */
function to_controller($class_name)
{
    return camelcase(singularize($class_name)) . 'Controller';
}
Example #27
0
 public static function camelcase($file)
 {
     return camelcase($file);
 }
Example #28
0
 /**
  * Returns the controller class for the currently selected captcha library.
  *
  * @return mixed
  */
 public function getController()
 {
     $class = overrideable_core_class('Core\\Antispam\\' . camelcase($this->saslHandle) . 'Controller', DIRNAME_CLASSES . '/Antispam/' . camelcase($this->saslHandle) . 'Controller.php', $this->getPackageHandle());
     $app = Facade::getFacadeApplication();
     $cl = $app->make($class);
     return $cl;
 }
 /**
  * Returns a package's class.
  * @param string $pkgHandle Handle of package
  * @return Package
  */
 public function getClass($pkgHandle)
 {
     $app = \Core::make('app');
     $cache = $app->make('cache/request');
     $item = $cache->getItem('package/class/' . $pkgHandle);
     $cl = $item->get();
     if ($item->isMiss()) {
         $item->lock();
         // loads and instantiates the object
         $cl = \Concrete\Core\Foundation\ClassLoader::getInstance();
         $cl->registerPackageController($pkgHandle);
         $class = '\\Concrete\\Package\\' . camelcase($pkgHandle) . '\\Controller';
         try {
             $cl = $app->make($class);
         } catch (\Exception $ex) {
             $cl = $app->make('Concrete\\Core\\Package\\BrokenPackage', array($pkgHandle));
         }
         $cache->save($item->set($cl));
     }
     return clone $cl;
 }
Example #30
0
 /**
  * @return \Concrete\Core\File\StorageLocation\Configuration\ConfigurationInterface
  */
 public function getConfigurationObject()
 {
     $class = core_class('\\Core\\File\\StorageLocation\\Configuration\\' . camelcase($this->getHandle()) . 'Configuration', $this->getPackageHandle());
     return Core::make($class);
 }